donmccurdy / glTF-Transform

glTF 2.0 SDK for JavaScript and TypeScript, on Web and Node.js.
https://gltf-transform.dev
MIT License
1.43k stars 150 forks source link

Dedup causing animation errors #923

Closed timothyallan closed 1 year ago

timothyallan commented 1 year ago

I've got an odd one where dedup causes an issue with one part of a model which is animated. Works great before dedup, afterwards, the animation is botched up.

Grab the .glb of this free model https://sketchfab.com/3d-models/medieval-fantasy-book-06d5a80a04fc4c5ab552759e9a97d91a , pop it into https://gltf.report/ , change the the default script to only include dedup and run it i.e.

await document.transform(
    // Remove duplicate vertex or texture data, if any.
    dedup(),
);

export the processed model, import into https://gltf-viewer.donmccurdy.com/ to get the animations going and look at the second flag animating on the tower.

donmccurdy commented 1 year ago

Hi @timothyallan, thanks for reporting the issue! I'm having trouble seeing a difference in the exported file - if that's obvious to you maybe we're getting different results somehow, could you share the resulting file? .ZIP files can be attached to github comments.

Or if it's less obvious I may need a screenshot or screencapture to see the issue.

timothyallan commented 1 year ago

Ohh that's interesting, I didn't think it might be a platform dependent issue. I've attached the post dedup model + an mp4 so you can see the issue.

https://user-images.githubusercontent.com/1995135/234376589-3116cc47-df6c-4514-b2d1-1672acbd59d4.mp4 Medieval-v1.glb.zip

donmccurdy commented 1 year ago

I've reduced the model to a simplified version containing just the two flags, and the issue appears pretty clearly here:

MorphFlags.zip

Interestingly, I don't see the same problem when viewing the model in Babylon.js (https://sandbox.babylonjs.com/) so I think this may be an engine-related bug, occurring when a geometry is reused with different morph target animation. Will file a ticket on the three.js repository in a bit.

EDIT: Opened https://github.com/mrdoob/three.js/pull/25976.

donmccurdy commented 1 year ago

Fixed in three.js upstream, should be available in the viewer after the next release or two. Thanks for the report!

timothyallan commented 1 year ago

Thanks Don, I appreciate all the work you do for the community!