details of objects tool

This commit is contained in:
Ladd 2026-01-05 01:45:21 -06:00
parent c2806c9ac4
commit f7f8eb93b9
3 changed files with 10 additions and 6 deletions

View File

@ -46,10 +46,10 @@ export class Pointer {
});
window.addEventListener('focus', () => {
console.log('window focus');
// console.log('window focus');
});
window.addEventListener('blur', () => {
console.log('window blur');
// console.log('window blur');
});
}

View File

@ -68,7 +68,11 @@ export class System {
const obj = this.getSelectedOrCreating();
if (obj === undefined) return;
const start = this.selectedObjectStart;
obj.position = add(start, sub(r, start.pointer));
const delta = sub(r, start.pointer);
// TODO: Calculate work done by pointer here?
// Either interpolate the acceleration and use m*a, or
// measure the change in the object's kinetic energy
obj.position = add(start, delta);
obj.velocity = zero;
}

View File

@ -63,9 +63,9 @@ export class ObjectsTool extends Tool {
// })));
objectEl.innerHTML =
`<span style="background-color: rgb(${r},${g},${b});">&nbsp;&nbsp;</span>` +
`E<sub>k</sub>: ${obj.kineticEnergy.toExponential(1)}` +
`<br>&nbsp;&nbsp;W<sub>p</sub>: ${obj.workDoneByPointer.toExponential(1)}` +
`<br>&nbsp;&nbsp;W<sub>f</sub>: ${obj.workDoneByForces.toExponential(1)}`;
`E<sub>k</sub>: ${obj.kineticEnergy.toFixed(0)}` +
`<br>&nbsp;&nbsp;W<sub>p</sub>: ${obj.workDoneByPointer.toFixed(0)}` +
`<br>&nbsp;&nbsp;W<sub>f</sub>: ${obj.workDoneByForces.toFixed(0)}`;
// `${obj.mass.toPrecision(3)} ` +
// `${distance.toPrecision(3)}`;