【发布时间】:2017-04-22 22:18:27
【问题描述】:
我需要获取网格中人脸的世界位置。这是我的代码:
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]);。 This answer 有一些进一步的解释。 -
谢谢,我去看看。
-
是的,这很好,谢谢。
标签: javascript three.js