0
我需要獲取網格中的面的世界位置。這是我的代碼爲:在縮放父網格之後獲取頂點的世界位置
var that = this,
addPoint,
geometry = mesh.geometry,
worldPos = mesh.getWorldPosition();
that.allMeshes[mesh.uuid] = {
mesh: mesh,
points: {}
};
addPoint = function (currPoint, face) {
var point = that.octree.add([worldPos.x + currPoint.x, worldPos.y + currPoint.y, worldPos.z + currPoint.z], {mesh: mesh, geometry: geometry, face: face});
that.allMeshes[mesh.uuid].points[point.id] = point;
};
geometry.faces.forEach(function(face) {
//Get the faces points cords
addPoint(geometry.vertices[face.a], face);
addPoint(geometry.vertices[face.b], face);
addPoint(geometry.vertices[face.c], face);
}, this);
這一切都工作得很好,除非父網格縮放然後。有誰知道如何解決這個問題?
看看'THREE.Object3D.localToWorld'它可以改變一個地方載體向世界途徑。用法:'var worldVertex = yourMesh.localToWorld(yourMesh.geometry.vertices [i]);'。 [這個答案](http://stackoverflow.com/questions/43265361/rotating-icosahedron-with-circles-located-at-every-vertex-in-three-js/43325479#43325479)有一些進一步的解釋。 – TheJim01
謝謝,我會看看。 – arpo
是的,這很有用,謝謝。 – arpo