calibrations
This commit is contained in:
parent
a50c7c2a58
commit
106707d6b2
@ -36,11 +36,16 @@ export class MassObject {
|
||||
this.color.r = Math.random() * 256;
|
||||
this.color.g = Math.random() * 256;
|
||||
this.color.b = Math.random() * 256;
|
||||
this.created = document.timeline.currentTime;
|
||||
this.timeCreated = this.sim.time;
|
||||
this.rawTimeCreated = this.sim.rawTime;
|
||||
}
|
||||
|
||||
get age() {
|
||||
return document.timeline.currentTime - this.created;
|
||||
return this.sim.time - this.timeCreated;
|
||||
}
|
||||
|
||||
get rawAge() {
|
||||
return this.sim.rawTime - this.rawTimeCreated;
|
||||
}
|
||||
|
||||
get radius() {
|
||||
|
||||
@ -15,10 +15,10 @@ export const simOptions = {
|
||||
merge: ['Merge Masses<br>on Collision', 'boolean', true, {wide: true}],
|
||||
},
|
||||
param: {
|
||||
gravity: ['Gravity', 'number', 4E4],
|
||||
timeScale: ['Time Scale', 'number', 0.2],
|
||||
massCreationRate: ['Mass Creation Rate', 'number', 10],
|
||||
massAcceleration: ['Mass Rate Accel', 'boolean', true, {wide: true}],
|
||||
gravity: ['Gravity', 'number', 1],
|
||||
timeScale: ['Time Scale', 'number', 0.1],
|
||||
massCreationRate: ['Mass Creation Rate', 'number', 1],
|
||||
massAcceleration: ['Mass Rate Accel', 'boolean', false, {wide: true}],
|
||||
},
|
||||
debug: {
|
||||
objectsInfo: ['Objects Info', 'boolean', false],
|
||||
|
||||
10
system.js
10
system.js
@ -157,8 +157,8 @@ export class System {
|
||||
// Convert pointer velocity to simulation scale
|
||||
// Including time scale - if time is slow, our motion is relatively faster
|
||||
const pointer = {...this.sim.pointer.latestVelocity};
|
||||
obj.velocity.x = pointer.x / this.sim.display.scale * this.sim.timeScale;
|
||||
obj.velocity.y = pointer.y / this.sim.display.scale * this.sim.timeScale;
|
||||
obj.velocity.x = pointer.x / this.sim.display.scale / this.sim.timeScale;
|
||||
obj.velocity.y = pointer.y / this.sim.display.scale / this.sim.timeScale;
|
||||
if (this.sim.panning?.velocity) {
|
||||
obj.velocity.x += this.sim.panning.velocity.x;
|
||||
obj.velocity.y += this.sim.panning.velocity.y;
|
||||
@ -242,9 +242,11 @@ export class System {
|
||||
let massCreationRate = this.sim.getOption('param.massCreationRate');
|
||||
// Mass creation rate acceleration
|
||||
if (this.sim.getOption('param.massAcceleration')) {
|
||||
massCreationRate *= obj.age;
|
||||
// TODO: Separate parameter for mass creation acceleration rate
|
||||
massCreationRate *= obj.rawAge;
|
||||
}
|
||||
obj.mass += massCreationRate * elapsedTime;
|
||||
// Keep consistent time scale
|
||||
obj.mass += massCreationRate * elapsedTime / this.sim.timeScale;
|
||||
}
|
||||
|
||||
// Calculate forces due to gravity.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user