Josh Bowman
Josh Bowman

Reputation: 140

World Position of Vertex in grouped Object3D Geometry

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.

Upvotes: 1

Views: 232

Answers (1)

pailhead
pailhead

Reputation: 5421

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

Upvotes: 2

Related Questions