But in my scene all looks fine. Also, If i remove clicked object, actually it is removed from scene. I think I missed some point their positions cant be (0,0,0). How can I reach their relative position ?
回答1:
Try this, then read position(). I had the same issue, got an answer here. (geom is your Meshes geometry.)
objMesh.centroid =new THREE.Vector3();for(var i =0, l = geom.vertices.length; i < l; i++){ objMesh.centroid.add(geom.vertices[i].clone());} objMesh.centroid.divideScalar(geom.vertices.length);var offset = objMesh.centroid.clone(); objMesh.geometry.applyMatrix(new THREE.Matrix4().makeTranslation(-offset.x,-offset.y,-offset.z)); objMesh.position.copy(objMesh.centroid);
回答2:
The position is relative to the parent
Multiply the position by the transform of the parent to get the world-space coordinates, if that's what you're seeking
回答3:
That is because all objects in a obj file have their pivot at World 0,0,0 no matter where their local pivot was before exporting.