pmndrs / gltfjsx

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

Transform name #152

Closed servinlp closed 1 year ago

servinlp commented 1 year ago

What I want

When using the --transform option I wan't to be able to transform to GLTF instead of GLB.

Why I want it

In our current workflow we prefer the use of GLTF + BIN + textures over GLB's when relevant. This because a lot of times the large file size is partially or primarily do to texture files. To optimize this we like to use services like Cloudflare Polish. This will, depending on your browser support, automatically send a WebP version of the texture reducing the total size.

In the future Polish will also be supporting AVIF.

To improve efficiency, we now use Polish to compress your images, and serve fewer bytes over the wire. When possible, we’ll also serve a WebP version of your image (and AVIF too, coming soon).

Quote here

How to achieve this

When playing around with the repo I noticed that if you change the output file name from glb to gltf (here) it already works. (When testing with a file that was already GLTF + BIN + textures.)

My idea was to maybe add an option to the --transform where you specify glb or gltf. Or add the option to give a custom name to the file and thus tell it to be a glb or gltf.

Love to hear others opinion on this.

drcmda commented 1 year ago

you don't need --transform, it is just a small helper calling gltf-transform for you. you can use any other tool for compression.

btw, as for texture compression: https://twitter.com/0xca0a/status/1547258568956678144

  1. npx @squoosh/cli --mozjpeg '{"quality":60}' -d squooshed ./
  2. edit gltf to use the jpgs instead
  3. npx gltfjsx scene.gltf --transform --instance --agressive

until now has the smallest results i have seen so far. i wanted to add squoosh to gltfjsx but it looks like the library isn't maintained, so it feel out and now it is incompatible with node. i hope it's going to catch up again.