World Position of Vertex in grouped Object3D Geometry

雨燕双飞 提交于 2019-12-24 10:46:54

问题


I've spend 7 hours so far trying every combination from the answers found here already:

How to get the absolute position of a vertex in three.js?

I'm trying to find the vertex positions of the geometry of a plane, which is inside an Object3D, which is inside a group.

I can get the global coordinates of the Object3D without issue, even when the group or the Object3D are moved around, but the vertices either only give me their local coordinates, or give me garbage numbers that don't correlate to their position, or are undefined, or tell me that it can't find this or that thing.

Any help would be greatly appreciated.


回答1:


You can use somewhat of a shortcut - localToWorld() on Object3D. You have to make sure that the matrix is updated which usually happens automatically when you render. To be on the safe side make a copy of the Vector3.

yourObject3d.updateMatrixWorld()
yourObject3d.localToWorld( new THREE.Vector3().copy(yourGeometry.vertices[someVertex]) )


来源:https://stackoverflow.com/questions/51511499/world-position-of-vertex-in-grouped-object3d-geometry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!