details of objects tool
This commit is contained in:
parent
c2806c9ac4
commit
f7f8eb93b9
@ -46,10 +46,10 @@ export class Pointer {
|
|||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('focus', () => {
|
window.addEventListener('focus', () => {
|
||||||
console.log('window focus');
|
// console.log('window focus');
|
||||||
});
|
});
|
||||||
window.addEventListener('blur', () => {
|
window.addEventListener('blur', () => {
|
||||||
console.log('window blur');
|
// console.log('window blur');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -68,7 +68,11 @@ export class System {
|
|||||||
const obj = this.getSelectedOrCreating();
|
const obj = this.getSelectedOrCreating();
|
||||||
if (obj === undefined) return;
|
if (obj === undefined) return;
|
||||||
const start = this.selectedObjectStart;
|
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;
|
obj.velocity = zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -63,9 +63,9 @@ export class ObjectsTool extends Tool {
|
|||||||
// })));
|
// })));
|
||||||
objectEl.innerHTML =
|
objectEl.innerHTML =
|
||||||
`<span style="background-color: rgb(${r},${g},${b});"> </span>` +
|
`<span style="background-color: rgb(${r},${g},${b});"> </span>` +
|
||||||
`E<sub>k</sub>: ${obj.kineticEnergy.toExponential(1)}` +
|
`E<sub>k</sub>: ${obj.kineticEnergy.toFixed(0)}` +
|
||||||
`<br> W<sub>p</sub>: ${obj.workDoneByPointer.toExponential(1)}` +
|
`<br> W<sub>p</sub>: ${obj.workDoneByPointer.toFixed(0)}` +
|
||||||
`<br> W<sub>f</sub>: ${obj.workDoneByForces.toExponential(1)}`;
|
`<br> W<sub>f</sub>: ${obj.workDoneByForces.toFixed(0)}`;
|
||||||
|
|
||||||
// `${obj.mass.toPrecision(3)} ` +
|
// `${obj.mass.toPrecision(3)} ` +
|
||||||
// `${distance.toPrecision(3)}`;
|
// `${distance.toPrecision(3)}`;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user