Get position mesh during animation (imported .glb model)

Hi guys,

I’m trying to get the center point of a mesh during an animation, but so far I’m only able to get the static-mesh position (the position the animation was started in). For this project, I’m using Blender and the gltf exporter to export it to a .glb file. The animations are also created in blender and started with the Three.js AnimationMixer.

When I log the mesh of the object, the position stored in object.geometry.attributes.position does not change but returns the original position of the mesh.

var handL = this.model.getObjectByName( 'handL' ) // handL is of type SkinnedMesh
var boundingBox = handL.geometry.boundingBox;

var position = new THREE.Vector3();
position.subVectors( boundingBox.max, boundingBox.min );
position.multiplyScalar( 0.5 );
position.add( boundingBox.min );

position.applyMatrix4( handL.matrixWorld );
console.log(position)

https://stackoverflow.com/questions/14211627/three-js-how-to-get-position-of-a-mesh (the other proposed answer returned a position of (0,0,0) in my case)

Currently using Three.js version 104

Is there something that I’m missing?

Thanks,
Jurjen

Skeletal Animations are handled on the GPU so this data is not exactly accessible in js code at runtime.

Perhaps someone knows some workaround, but as far as I am aware there is none.

A reasonable option is getting the bounding box of the skeleton (all bones) and the center from it, as the bones are transformed on js side anyway and the world positions are already computed as well. Transforming all vertices on CPU to get the exact would kill your performance. A more precise yet not more expensive option is to define spheres (a radius) on the bones to capture the volume of the geometry.