Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in bounding box calculation for skinned meshes #330

Closed
mattrossman opened this issue Mar 30, 2023 · 0 comments · Fixed by #331
Closed

Regression in bounding box calculation for skinned meshes #330

mattrossman opened this issue Mar 30, 2023 · 0 comments · Fixed by #331

Comments

@mattrossman
Copy link
Contributor

mattrossman commented Mar 30, 2023

Three.js r151 introduced bounding volumes for SkinnedMesh, see mrdoob/three.js#25612. This causes unexpected behavior with Box3.setFromObject()

Take for example this model: bobby.glb.zip

r150 r151
image image

GLTFLoader doesn't update bone world matrices after a model loads (see mrdoob/three.js#24772) which means the SkinnedMesh.computeBoundingBox() call within Box3.expandByObject() can result in an incorrect bounding box.

A workaround is to call .updateMatrixWorld() on the object before calculating the bounding box.

setContent ( object, clips ) {
this.clear();
const box = new Box3().setFromObject(object);
const size = box.getSize(new Vector3()).length();
const center = box.getCenter(new Vector3());

+object.updateMatrixWorld()

 const box = new Box3().setFromObject(object);
 const size = box.getSize(new Vector3()).length();
 const center = box.getCenter(new Vector3());
donmccurdy added a commit that referenced this issue Mar 31, 2023
Context: #330

---------

Co-authored-by: Don McCurdy <[email protected]>
felix0174 added a commit to felix0174/three-gltf-viewer that referenced this issue Dec 24, 2024
gler1016 added a commit to gler1016/threejs-gltf-viewer that referenced this issue Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant