public Particle(double m, THREE.Vector3 pos) { position = pos.clone(); previous = pos.clone(); original = pos.clone(); acc = new THREE.Vector3(0, 0, 0); mass = m; invMass = 1.0 / mass; }
public void integrate(double deltaT) { if (IsFixed) { ToOriginal(); return; } acc.multiplyScalar(ParticleConstants.DAMPING); THREE.Vector3 newPos = this.position.clone().sub(previous); newPos.add(acc.multiplyScalar(deltaT * deltaT)); newPos.add(position); previous = position.clone(); position = newPos; acc.set(0, 0, 0); }
public void addForce(THREE.Vector3 force) { THREE.Vector3 a = force.clone(); a.multiplyScalar(invMass); acc.add(a); }