What could be causing THREE.Vector3.sub to return (0,0,0) in this specific case?
p0 = new THREE.Vector3( 0, 100, 50 );
p1 = new THREE.Vector3( 0, 50, 100 );
dummy = new THREE.Vector3(0,0,0);
p1_relative_to_p0 = dummy.sub(p1, p0);
console.log(p1_relative_to_p0);
this is the sub function implementation within THREE.Vector3's prototype:
sub: function ( a, b ) {
this.x = a.x - b.x;
this.y = a.y - b.y;
this.z = a.z - b.z;
return this;
},
output displayed on console:
THREE.Vector3 x: 0 y: 0 z: 0
Why isn't the output (0, 50, -50) instead? What could be the reason behind this unexpected result?
You can view the code in action by visiting the following link: