pmndrs / gltfjsx

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

Issue with Transform #136

Open PaulLockett opened 2 years ago

PaulLockett commented 2 years ago

I run this and get this error:

you can see the code and find the .gltf file here: link

I want to be able to export my new 3d design after using this tool to manipulate it. I think the -T transform function will let me do that.

~/NFTShowcaseAnimation$ npx gltfjsx first_try.gltf -t -T
prune: Removed types... Primitive (14), Buffer (4)
 Parse  transforming first_try-transformed.glb
Error: GLB must have 0–1 buffers.
    at n.writeJSON (/home/runner/NFTShowcaseAnimation/node_modules/@gltf-transform/core/dist/core.js:1:76233)
    at n.writeBinary (/home/runner/NFTShowcaseAnimation/node_modules/@gltf-transform/core/dist/core.js:1:77483)
    at n.r.Yt (/home/runner/NFTShowcaseAnimation/node_modules/@gltf-transform/core/dist/core.js:1:79620)
    at n.r.write (/home/runner/NFTShowcaseAnimation/node_modules/@gltf-transform/core/dist/core.js:1:78505)
    at transform (/home/runner/NFTShowcaseAnimation/node_modules/@react-three/gltfjsx/src/utils/transform.js:30:6)
    at async WriteStream.<anonymous> (/home/runner/NFTShowcaseAnimation/node_modules/@react-three/gltfjsx/src/gltfjsx.js:43:11)
donmccurdy commented 2 years ago

I can't access the replit (password protected), but this error might happen if the .gltf file has multiple .bin resources — does that sound right? Some consolidation to pack those into a .glb.

A quick workaround might be to drop the file into https://gltf.report/, open the script tab, and run the script below:

const buffers = document.getRoot().listBuffers();
const mainBuffer = buffers[0];

document.getRoot().listAccessors().forEach((accessor) => {
    accessor.setBuffer(buffers[0]);
});

buffers.forEach((buffer, index) => {
    if (index > 0) buffer.dispose();
});

console.log('... ✅ Done');