-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
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
SkinnedMesh: Incorrect bounding box and culling #14499
Comments
Tested it in my loader and it's working fine. So whatever the issue is, it's not a three.js bug. EDIT: oops, spoke too soon. It's possible to rotate and zoom the model so that the visor or helmet disappear. However from other angles I can zoom right into the interior of the head without clipping occurring. EDIT EDIT: (sorry should have tested more thoroughly before I started typing 😆 ) It seems the clipping is occurring with one file but not the other - the one with the pose applied displays correctly. @soadzoor that's what you were describing as well, right? |
Yes, right. I wouldn't call it "clipping" though, but "disappearing", since the whole "mesh" disappears suddenly. I also had the head and the helmet joined together with the rest of the body, so they would be one single mesh, but that didn't really make any difference, probably because it has a different material, so it becomes a different mesh in three.js. As far as I know, in glTF, it always becomes a separate mesh, when it has different materials, at least in three.js |
This depends on how the exporter creates the file — three.js does support multi-material meshes, but the exporter might not write data that way, or there might be some technical reason the exporter indicates a multi-material mesh but three.js has to split it (e.g. we can't have one mesh containing both points and triangles). |
Try |
@WestLangley yes, |
Bounding boxes exist only on the CPU, and that is where the frustum culling is occurring. Skinning occurs on the GPU. So in your case, either the skinned vertices are translated away from the bounding box, or the bounding box is not correct for some reason. See if you can track that down. |
I see. Thanks! |
Yea, it seems like the skinned vertices are translated away from the bounding box: So I guess there's no "easy" solution for this, but to recalculate the position of the bounding box manually, or set |
You can enlarge the head's bound box, manually, or perhaps set it to be the union of the bounding boxes of the head and body. boundingBox.union( boundingBox2 ); Whatever you do, do it just once, not every frame. |
@WestLangley thanks for the tip, seem like a pretty nice workaround. I'll close the thread I guess |
I've been testing this in quite a few models, and it seems like every skinned model that consists of multiple meshes exhibits this behaviour. Testing the same models in other system (Babylon.js, FBX review,sketchfab), they display correctly. So I think we do need to consider this a three.js bug. Here's a video of the most obvious example I could find (model was shared in #14520). Kind of NSFW I guess. |
Has there been any progress on this? I have a scene with multiple animated characters, and the bounding boxes for the skinned meshes are way off the models. Maybe unrelated, but I also noticed that the way the animated models are created in Blender, I end up with an "Object3D" parent that has a Skeleton child and a SkinnedMesh child. SkinnedMesh expects to have a Skeleton child, but my animations are working so maybe this doesn't matter anyway. I only noticed because I can't add a SkeletonHelper to the SkinnedMesh - I have to create it from the Parent. |
This is just how the Blender exporter creates models.
SkinnedMesh doesn't depend on its bones being children; it is common but not a requirement.
I've been doing: const helper = new SkeletonHelper( mesh.skeleton.bones[ 0 ].parent ); This should work regardless of whether the mesh is the parent or not. Perhaps we could set up SkeletonHelper to figure this out automatically. :) |
Using three^0.124.0 and Blender 2.9
|
I don't have control over threejs in most cases, e.g. when using model-viewer or other existing viewers, so code workarounds are not possible. For reference, @mrdoob had mentioned here that he came up with an efficient solution; but I'm not sure that's already implemented anywhere? |
Related #21507. |
I encountered the same problem:
Is there currently a correct solution? |
Make sure you call |
It really works for me. Thanks. |
There is actually issues tracking the missing world matrix computation in I have tried to fix this issue in #21411 since developers frequently report incorrect bounding volumes but unfortunately the PR did not get enough support. @donmccurdy I have noticed that many users struggle with |
@Mugen87 if we can do |
Description of the problem
Hi,
I've been playing around with a model for a while, and noticed that if I load it in three.js and zoom closely to the head, it disappears, along with the helmet.
I'm sure it's not the clipping field, because they disappear suddenly, from one frame to another.
I'm also sure this bug is not limited to @donmccurdy 's gltf viewer ( https://gltf-viewer.donmccurdy.com/ ), as I tested it in a project made from scratch recently, and the bug appears there, too.
It works flawlessly in the babylon sandbox: http://sandbox.babylonjs.com/, so I believe this has something to do with three.js.
Also, I think it has something to do with the fact that the mesh is skinned. If I apply the armature pose in blender before exporting, then the model appears correctly in three.js as well.
I attach a zip with 2 model files, one with skin, the other one with the applied pose:
player.zip
Three.js:
![capture2](https://user-images.githubusercontent.com/10392261/42885336-02355ef4-8aa1-11e8-897b-531b6a133272.PNG)
Babylon.js:
![capture](https://user-images.githubusercontent.com/10392261/42885318-f717b404-8aa0-11e8-8611-1cd9f75d7a1c.PNG)
Three.js version
Browser
OS
The text was updated successfully, but these errors were encountered: