2015-05-26 86 views
0

看起來,當我在我的對象上使用translate[X|Y|Z]時,它的位置會受到損壞,並且只包含NaN值。Three.js object3d.translateZ導致所有位置值中的NaN

weird

three.js所R70

的位置是相對的,絕對是不同的: comparison

我的代碼

if (!this.following) return false; 

var mesh = this.get(); //One mesh 
this.mesh.lookAt(this.mesh.worldToLocal((new THREE.Vector3(0, 0, 0)).setFromMatrixPosition(this.following.whom.matrixWorld))); //this.following.whom is another mesh 

var followerPosition = mesh.localToWorld(new THREE.Vector3(0, 0, 0)); 
var followeePosition = this.following.whom.localToWorld(new THREE.Vector3(0, 0, 0)); 
var distance = followerPosition.distanceTo(followeePosition); 

if (distance > this.following.distance) { //this.following.distance is scalar value 
    mesh.translateZ(distance * 0.02); 
} 

return true; 

我在做什麼錯?在處理相對值時,我不能使用transformZ嗎?

+0

你的代碼到底是什麼。你只是顯示結果。 – gaitat

+0

使用three.js的非縮小版本並使用調試器。 – WestLangley

+0

我已經添加了我的代碼 – Misiur

回答

0

好吧,似乎我錯過了重要的事情。如果對象的旋轉是NaN,則翻譯將失敗。