分组 Object3D 几何中顶点的世界位置 [英] World Position of Vertex in grouped Object3D Geometry

查看:15
本文介绍了分组 Object3D 几何中顶点的世界位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我已经花了 7 个小时从这里找到的答案中尝试了每种组合:

如何在three.js中获取顶点的绝对位置?

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?

我试图找到一个平面几何体的顶点位置,该平面位于一个 Object3D 内,它位于一个组内.

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

我可以毫无问题地获得 Object3D 的全局坐标,即使组或 Object3D 四处移动,但顶点要么只给我它们的局部坐标,要么给我与它们的位置无关的垃圾数字,或者未定义,或者告诉我它找不到这个或那个东西.

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.

任何帮助将不胜感激.

推荐答案

您可以在 Object3D 上使用某种快捷方式 - localToWorld().您必须确保更新矩阵,这通常在您渲染时自动发生.为了安全起见,请复制 Vector3.

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]) )

这篇关于分组 Object3D 几何中顶点的世界位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆