pmndrs / gltfjsx

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

Additional UV sets being removed with --transform, no option to make sure these are preserved #235

Open Prungus opened 7 months ago

Prungus commented 7 months ago

When processing gltf or glb models that contain meshes with multiple UV sets, they are always removed without any way to ensure they stay. I have tested all flags with transform and there does not seem to be a way to keep multiple UV sets on the meshes. This is especially burdensome as Three.js has included proper support for multiple UV sets via texture channels as of r153

donmccurdy commented 5 months ago

The keepAttributes: false option passed to glTF Transform here is responsible for removing unused UVs:

https://github.com/pmndrs/gltfjsx/blob/de1d1c2e007cb693934ad9b3d460a1c13ae891c4/src/utils/transform.js#L68

As you note, gltfjsx doesn't expose an option to override that today. One workaround would be to pre-process the file with glTF Transform first, and skip --transform.

npx @gltf-transform/cli optimize input.glb output.glb --compress meshopt --texture-compress webp --texture-resize 2048

glTF Transform is configurable, and this is not exactly the same set of optimizations as gltfjsx has chosen, but you can try different options with the CLI to see what you prefer.

npx @gltf-transform/cli --help
npx @gltf-transform/cli optimize --help