爲什麼THREE.Vector3.sub在此方案中返回(0,0,0)?three.js:THREE.Vector3.sub()異常行爲
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);
這是來自THREE.Vector3的原型的子功能:
sub: function (a, b) {
this.x = a.x - b.x;
this.y = a.y - b.y;
this.z = a.z - b.z;
return this;
},
控制檯輸出:
THREE.Vector3 X:0 Y:0 Z: 0
爲什麼不是t他輸出(0,50,-50)?
的代碼可以看出,在這裏的行動: https://dl.dropbox.com/u/2070405/webgl_lines_splines_jon.html
或者試試這個'console.log(p1_relative_to_p0.x,p1_relative_to_p0.y,p1_relative_to_p0.z )'。 – mrdoob
... Firefox我來了 – loldrup