pmndrs / gltfjsx

🎮 Turns GLTFs into JSX components
https://gltf.pmnd.rs
MIT License
4.73k stars 312 forks source link

Some meshes not in original position #78

Open stackola opened 3 years ago

stackola commented 3 years ago

Using gltfjx sometimes breaks some objects positions.

Probably related to https://github.com/pmndrs/gltfjsx/issues/76 and https://github.com/pmndrs/gltfjsx/issues/62

Minimal repo: https://codesandbox.io/s/quizzical-kapitsa-ugjgg

You can see the top canvas renders the JSX file, while the bottom canvas renders the GLTF as a primitive object.

The primitive object is 100% correct, but the JSX one is just a little bit messed up. Of the 20 parts, 2 or 3 are not in their correct position. Note: both canvases use the exact same GLTF file.

What even stranger: The GLTF file works fine in the online viewer ( https://gltf.pmnd.rs/ )

Any help on how to work around that would be appreciated.

drcmda commented 3 years ago

try a higher precision, that is most likely it. for really, really small models this can make a difference. it defaults to 2 digits.

scratch that, i see you did. will look into it later, something must cause it ... 🤔

stackola commented 3 years ago

I'll just let you know we worked around the issue somehow, and it's related to animations. With a cleaner animation setup in blender, the exported GLTF works just fine with gltfjsx

joergjaeckel commented 3 years ago

Had exactly the same problem and just solved it by clearing position, rotation and scale in Blender. Without clearing, the meshes inside the group had position and rotation props set. Showed correct in the online viewer but not local in r3f (Removing props did not help really)

drcmda commented 3 years ago

these would also work with larger precision, it's a cli flag: --precision=6

but maybe there's a way it can be automated. anyone knows how i could test that cutting it to n digits would cut off floating point numbers? or something like a calculation that returns the smallest amount of numbers?

technoo0 commented 3 years ago

@joergjaeckel it worked for me also just applied the scale and rotation in blender and I worked this is the blender docs https://docs.blender.org/manual/en/2.79/editors/3dview/object/editing/transform/clear_apply.html#apply