/usr/share/javascript/three/examples/js/nodes/utils/VelocityNode.js is in libjs-three 80+dfsg2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | /**
* @author sunag / http://www.sunag.com.br/
*/
THREE.VelocityNode = function( target, params ) {
THREE.Vector3Node.call( this );
this.requestUpdate = true;
this.target = target;
this.position = this.target.position.clone();
this.velocity = new THREE.Vector3();
this.moment = new THREE.Vector3();
this.params = params || {};
};
THREE.VelocityNode.prototype = Object.create( THREE.Vector3Node.prototype );
THREE.VelocityNode.prototype.constructor = THREE.VelocityNode;
THREE.VelocityNode.prototype.updateAnimation = function( delta ) {
this.velocity.subVectors( this.target.position, this.position );
this.position.copy( this.target.position );
switch ( this.params.type ) {
case "elastic":
delta *= this.params.fps || 60;
var spring = Math.pow( this.params.spring, delta );
var friction = Math.pow( this.params.friction, delta );
// spring
this.moment.x += this.velocity.x * spring;
this.moment.y += this.velocity.y * spring;
this.moment.z += this.velocity.z * spring;
// friction
this.moment.x *= friction;
this.moment.y *= friction;
this.moment.z *= friction;
this.value.copy( this.moment );
break;
default:
this.value.copy( this.velocity );
break;
}
};
|