Three.js object3d.translateZ 在所有位置值中导致 NaN
Three.js object3d.translateZ causes NaN in all position values
似乎当我在我的对象上使用 translate[X|Y|Z]
时,它的位置被破坏并且只包含 NaN
个值。
Three.jsr70
位置是相对的,绝对是不同的:
我的代码
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吗?
好的,看来我错过了重要的事情。如果对象的旋转是 NaN
,则平移将失败。
似乎当我在我的对象上使用 translate[X|Y|Z]
时,它的位置被破坏并且只包含 NaN
个值。
Three.jsr70
位置是相对的,绝对是不同的:
我的代码
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吗?
好的,看来我错过了重要的事情。如果对象的旋转是 NaN
,则平移将失败。