I’m trying to calculate an AABB of the default pose of a SkinnedMesh. The model comes from a GLB file that contains a transformation on the object. I read that it can be an issue, but I’m working on a tool so users may use files with transformations.
I added this code and it applied the bone transformation, but it makes the object 2 time bigger.
threeObject.traverse((node) => {
const mesh = node as THREE.SkinnedMesh;
if (mesh.type === 'SkinnedMesh') {
mesh.pose();
}
});
Does it apply the scaling twice?
I guess, it’s not the right way to refresh the model.
It seems that Box3.setFromObject uses a cache and the precise parameter allows to bypass it for geometries but not for objects.
It makes investigations a bit difficult, because calling Box3.setFromObject has side effects on following calls.
Is there a way to reset boundingBox attributes?
I probably missed something obvious, please let me know if there is something wrong in my way of measuring skinned mesh AABB from a GLB file.
If you want complete reliability (ie. work with the skinned mesh on a geometry, not a bone level), I’d look into:
It generates a proper static geo from a skinned mesh in any pose… very useful for calculating bounding boxes and the like. It’s a bit too perf-heavy to do at runtime, but works great for on-load calculations.