gltfjsx icon indicating copy to clipboard operation
gltfjsx copied to clipboard

Some meshes not in original position

Open stackola opened this issue 3 years ago • 5 comments

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.

stackola avatar Apr 20 '21 12:04 stackola

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 ... 🤔

drcmda avatar Apr 20 '21 16:04 drcmda

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

stackola avatar Apr 21 '21 20:04 stackola

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)

joergjaeckel avatar May 20 '21 17:05 joergjaeckel

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?

drcmda avatar May 20 '21 19:05 drcmda

@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

technoo0 avatar Jun 01 '21 08:06 technoo0