Evaluate SkinnedMesh default pose AABB (from GLB with transformation)

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.

The original file contains a scaling of 100:

I made a version with a scale of 2 for testing:

I’m using Box3.setFromObject and observed that the boxes were evaluated from SkinnedMesh without any bone transformation.
https://threejs.org/docs/#api/en/math/Box3.setFromObject

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.

Actually, I replaced:

  threeObject.traverse((node) => {
	const mesh = node as THREE.SkinnedMesh;
	if (mesh.type === 'SkinnedMesh') {
	  mesh.pose();
	}
  });

by:

posed.updateMatrixWorld(true);

and it solved my issue.

Out of curiosity, I’m still wondering why pose() had this side effect.

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.