no extra ssh on commit
This commit is contained in:
parent
bff693ee9f
commit
403ce4b683
@ -8,7 +8,7 @@ Uses `npm` for `eslint`.
|
||||
TODO
|
||||
----
|
||||
|
||||
[x] Numeric Option Type
|
||||
[ ] Numeric Option Type
|
||||
[ ] Time Indicator
|
||||
[ ] Selection Box
|
||||
[ ] Object List
|
||||
|
||||
11
commit
11
commit
@ -19,16 +19,5 @@ git commit "$@"
|
||||
|
||||
git push
|
||||
|
||||
ssh lentilz "
|
||||
set -oe pipefail
|
||||
export NVM_DIR=\"\$HOME/.nvm\"
|
||||
[ -s \"\$NVM_DIR/nvm.sh\" ] && \. \"\$NVM_DIR/nvm.sh\" # This loads nvm
|
||||
cd ~/code/gravity-dev
|
||||
git add .
|
||||
git stash
|
||||
git pull
|
||||
git stash pop
|
||||
npm i
|
||||
"
|
||||
echo >&2
|
||||
echo >&2 "Committed and deployed to https://laddhoffman.com/gravity-dev/"
|
||||
|
||||
@ -2,6 +2,7 @@ import { MassObject } from './object.js';
|
||||
import {
|
||||
MASS_CREATION_RATE,
|
||||
DISPLAY_OBJECTS_INFO,
|
||||
GRAVITATIONAL_CONSTANT,
|
||||
ZOOM_TO_FIT_PADDING,
|
||||
} from './config.js';
|
||||
|
||||
@ -168,7 +169,6 @@ export class Objects {
|
||||
}
|
||||
|
||||
computeForces() {
|
||||
const gravity = this.sim.getOption('param.gravity');
|
||||
if (this.objects.length < 2) return;
|
||||
this.forEachObject(obj => {
|
||||
obj.forces = [];
|
||||
@ -179,7 +179,7 @@ export class Objects {
|
||||
const dy = (B.position.y - A.position.y);
|
||||
const dSquared = dx ** 2 + dy ** 2;
|
||||
const d = Math.sqrt(dSquared);
|
||||
const F = gravity * A.mass * B.mass / dSquared;
|
||||
const F = GRAVITATIONAL_CONSTANT * A.mass * B.mass / dSquared;
|
||||
const Fx = F * dx / d;
|
||||
const Fy = F * dy / d;
|
||||
A.forces.push({ x: Fx, y: Fy });
|
||||
|
||||
18
style.css
18
style.css
@ -47,7 +47,7 @@ div.lhg-toolbar div.lhg-tool {
|
||||
border-color: #282;
|
||||
}
|
||||
|
||||
div.lhg-tool button, div.lhg-tool input {
|
||||
div.lhg-tool button {
|
||||
font-family: monospace;
|
||||
font-size: 10pt;
|
||||
width: 6em;
|
||||
@ -66,10 +66,6 @@ div.lhg-tool button, div.lhg-tool input {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
div.lhg-tool input {
|
||||
width: 5EM;
|
||||
}
|
||||
|
||||
div.lhg-tool button:hover {
|
||||
background-color: #444;
|
||||
}
|
||||
@ -90,24 +86,16 @@ div.lhg-toolbar-header > * {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
div.lhg-tool .lhg-tool-info {
|
||||
div.lhg-tool button.lhg-tool-info {
|
||||
background-color: #111;
|
||||
border-color: #282;
|
||||
border-width: 0px;
|
||||
}
|
||||
|
||||
div.lhg-tool .lhg-wide {
|
||||
div.lhg-tool button.lhg-wide {
|
||||
width: 12em;
|
||||
}
|
||||
|
||||
div.lhg-tool input.lhg-wide {
|
||||
width: 11em;
|
||||
}
|
||||
|
||||
div.lhg-tool .lhg-tool-info.lhg-wide {
|
||||
width: 11em;
|
||||
}
|
||||
|
||||
div.lhg-tool > div {
|
||||
/* border: 2px red solid; */
|
||||
}
|
||||
|
||||
@ -2,12 +2,10 @@
|
||||
import {
|
||||
DISPLAY_ACCELERATION_VECTORS,
|
||||
DISPLAY_VELOCITY_VECTORS,
|
||||
GRAVITATIONAL_CONSTANT,
|
||||
MERGE_ON_COLLIDE,
|
||||
PATH_TRACES_DASHED,
|
||||
PAUSE_DURING_CREATION,
|
||||
PAUSE_DURING_SELECTION,
|
||||
TOOL_INFO_CLASSNAME,
|
||||
WIDE_CLASSNAME,
|
||||
} from '../config.js';
|
||||
import {Tool} from '../tool.js';
|
||||
@ -32,11 +30,6 @@ export class Options extends Tool {
|
||||
items: [
|
||||
{type: 'boolean', name: 'merge', title: 'Merge Masses', default: MERGE_ON_COLLIDE, wide: true},
|
||||
]
|
||||
}, {
|
||||
type: 'group', name: 'param', title: 'Parameters',
|
||||
items: [
|
||||
{type: 'number', name: 'gravity', title: 'Gravity', default: GRAVITATIONAL_CONSTANT},
|
||||
]
|
||||
}];
|
||||
|
||||
values = {};
|
||||
@ -69,32 +62,6 @@ export class Options extends Tool {
|
||||
});
|
||||
return button;
|
||||
}
|
||||
case 'number': {
|
||||
const div = document.createElement('div');
|
||||
const title = document.createElement('button');
|
||||
const input = document.createElement('input');
|
||||
const maxLength = item.maxLength || 8;
|
||||
div.appendChild(title);
|
||||
div.appendChild(input);
|
||||
div.classList.add(WIDE_CLASSNAME);
|
||||
title.classList.add(TOOL_INFO_CLASSNAME);
|
||||
if (item.wide) {
|
||||
// title.classList.add(WIDE_CLASSNAME);
|
||||
input.classList.add(WIDE_CLASSNAME);
|
||||
}
|
||||
title.innerHTML = item.title;
|
||||
input.value = item.default;
|
||||
this.setOption(path, item.default);
|
||||
|
||||
input.addEventListener('input', () => {
|
||||
input.value = input.value.slice(0, maxLength);
|
||||
});
|
||||
|
||||
input.addEventListener('change', () => {
|
||||
this.setOption(path, input.value);
|
||||
});
|
||||
return div;
|
||||
}
|
||||
default:
|
||||
throw new Error('unknown option type');
|
||||
}
|
||||
|
||||
29
tool/zoom.js
29
tool/zoom.js
@ -22,23 +22,19 @@ export class Zoom extends Tool {
|
||||
const zoomOut = document.createElement('button');
|
||||
const zoomIn = document.createElement('button');
|
||||
const zoomAll = document.createElement('button');
|
||||
const zeroVelocity = document.createElement('button');
|
||||
|
||||
this.div.appendChild(currentScale);
|
||||
this.div.appendChild(zoomOut);
|
||||
this.div.appendChild(zoomIn);
|
||||
this.div.appendChild(zoomAll);
|
||||
this.div.appendChild(zeroVelocity);
|
||||
|
||||
zoomAll.classList.add(WIDE_CLASSNAME);
|
||||
zeroVelocity.classList.add(WIDE_CLASSNAME);
|
||||
currentScale.classList.add(WIDE_CLASSNAME);
|
||||
currentScale.classList.add(TOOL_INFO_CLASSNAME);
|
||||
|
||||
zoomOut.innerHTML = 'Zoom<br>Out';
|
||||
zoomIn.innerHTML = 'Zoom<br>In';
|
||||
zoomAll.innerHTML = 'Zoom to Fit';
|
||||
zeroVelocity.innerHTML = 'Zero Net Velocity';
|
||||
currentScale.innerHTML = this.displayScaleText;
|
||||
|
||||
this.sim.onZoom(() => {
|
||||
@ -88,30 +84,5 @@ export class Zoom extends Tool {
|
||||
};
|
||||
this.sim.scheduleZoom({x, y}, factor, netVelocity)
|
||||
});
|
||||
|
||||
zeroVelocity.addEventListener('click', () => {
|
||||
// Determine average momentum
|
||||
const netMomentum = {x: 0, y: 0};
|
||||
let totalMass = 0;
|
||||
let count = 0;
|
||||
this.sim.objects.forEachObject(obj => {
|
||||
count++;
|
||||
netMomentum.x += obj.mass * obj.velocity.x;
|
||||
netMomentum.y += obj.mass * obj.velocity.y;
|
||||
totalMass += obj.mass;
|
||||
});
|
||||
if (!count) {
|
||||
return;
|
||||
}
|
||||
const netVelocity = {
|
||||
x: netMomentum.x / totalMass,
|
||||
y: netMomentum.y / totalMass,
|
||||
};
|
||||
// Apply offset to all object velocities
|
||||
this.sim.objects.forEachObject(obj => {
|
||||
obj.velocity.x -= netVelocity.x;
|
||||
obj.velocity.y -= netVelocity.y;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user