gltfjsx
gltfjsx copied to clipboard
Error when using typescript flag on object with animation
I get the following error when running gltjsx -t ./{model}.gltf
on any model that has an animation:
TypeError: Cannot read properties of undefined (reading 'name') at file:///**/.npm/_npx/16b3f312213fced0/node_modules/gltfjsx/src/utils/parser.js:103:60 at Array.map (<anonymous>) at printTypes (file:///**/.npm/_npx/16b3f312213fced0/node_modules/gltfjsx/src/utils/parser.js:103:34) at parse (file:///**/.npm/_npx/16b3f312213fced0/node_modules/gltfjsx/src/utils/parser.js:436:27) at file:///**/.npm/_npx/16b3f312213fced0/node_modules/gltfjsx/src/gltfjsx.js:52:26 at file:///**/.npm/_npx/16b3f312213fced0/node_modules/gltfjsx/src/bin/GLTFLoader.js:1215:7 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
I tried to do some debugging and it seems the animations array comes in as [ undefined ]. It works fine without the types flag. Attached is a cube with a small rotate animation for reproducibility. cube.gltf.zip
I believe this was introduced in https://github.com/pmndrs/gltfjsx/commit/e71898376e666677bb9cd54b160bcc64a2316afe. Animations are being overridden when we wrap the reassign the gltf
parameter at the top of parser/parse
I had debugged that initially and it wasn't hitting that if statement. Instead of an empty array, it'll actually fill the array with a matching number of undefineds as animations in the gltf (ex [undefined, undefined] for 2 animations.
After more diving, I think it is caused by 7b3377a9. Seems the loadAnimation method was completely gutted for some reason.
Hi - whats up with the gutted load animation?