How to get position of a vertex on a morphed SkinnedMesh?

I am trying to get the position of a vertex on a model for positioning another 3D object on it. Some old stackoverflow topics mention getting the info from mesh.geometry.vertices[n] which is not the case for the version im using (0.110.0).

Any Idea how I can get that info?

This refers to the (legacy) THREE.Geometry class. When using THREE.BufferGeometry, you can access the vertex buffer like so:

var vertex = new THREE.Vector3();
var positionAttribute = geometry.getAttribute( 'position' );

for ( var i = 0; i < positionAttribute.count; i ++ ) {

    vertex.fromBufferAttribute( positionAttribute, i );

    // do something with vertex

}

However, computing the animated vertex with JavaScript is not trivial since this logic is normally implemented on the GPU (vertex shader). You essentially have to implement the same vertex displacement on the CPU. The following thread might help here:

1 Like

There is no skeleton involved so far, just a couple of blend shapes at this point. fromBufferAttribute does work but the position seems to be far off. I’ll experiment more.