About the gltf-transform Tool

Hello,When I am using the gltf-transform command:

gltf-transform optimize xxx. glb xxx. glb --compress meshopt --texture-compress webp --texture-size 512

Looking in the sandbox some mesh added a parent node TransformNode, like this, is this normal?

the mesh node94 should be named XA_Sweat_01, but it is now a TransformNode
I don’t want this,because I feel trouble, such as when I want to operate mesh, I must first use scene. getTransfromNodeByName (’ xxx '). getChildMeshs (), but I will have to use gltf-transform, because I’m in the mobile terminal, the model should be as small as possible!!!

gltf-transform optimize xxx. glb xxx. glb --compress meshopt --texture-compress webp --texture-size 512

This command will have these optimizations:

Can you tell me which command adds a parent node to the mesh? I tried each command individually and couldn’t find which command did this

Cc @bghgary

Most of the commands which are used in optimize command of GLTF-Transform, may change node hierarchy in GLTF/GLB files.
It is hard to say without the model which command you should omit in order to keep the node hierarchy the same. Try to exclude dedup and instance commands and see what will happen (I guess it is instance). In other words, do not use optimize for your file, use separate commands and see what breaks your file herarchy.
One may also perform a quick check (include/exclude some commands, for example) with my online tool (based partially on GLTF-Transform) - https://glb.babylonpress.org/

I don’t know for sure without a repro, but IIRC meshopt requires a parent node to scale the mesh because of quantization.


I did execute each command individually and found no problems, but with meshopt, the effect of meshopt is surprising and hard to resist!!!

I tried this tool and selected webp for image and 512 for size!!
The optimization strategy selects these:




After the export I checked with the sandbox and it seems that the parent node was also added

I can’t seem to live without meshopt because it has so many optimizations!!!
The only trouble is bad code maintenance later, if change for others, they don’t know meshopt, may need to change a lot of code, inside the code with a lot of scene.gtTransformNodeByName.

Is it possible to share your GLB model to have a look?

You may try to use Draco compression, it gives even better results sometimes.

I tried Draco compression earlier with threejs, but some iphones had problems, Android was fine, so I gave up Draco compression
There is the glb model,It has some drawbacks!!!

My final idea is to compress resources as losslessly as possible, such as using meshopt, and I can also accept adding TransformNodes

If Draco is not an option for you and there are some transform nodes after meshopt - you can use scene. getNodeByName() to use the same names as before optimization.

Or, since optimized files are the final ones to be used in production, just use their node hierachy to access relevant meshes/transform nodes.

Here is the screenshot with KTX textures - note the giant decrease of VRAM used even in comparison with WEBP textures.

With meshopt compression it has the size of 290 Kb (1.6 Mb original size).
my-opt2meshopt.zip (168.4 KB)

Well done, but why did I export the model with 435kb according to your configuration? The one you gave me is only 289kb. For the picture, I chose ktx2/ETC1S, whose size is 512 and setting is the same as yours. Why is mine 150kb larger? Did I miss something somewhere?

The file was additionally meshopted through GLTF-Transform CLI interface.
You will achieve the same results using only CLI when using the same commands + meshopt at the end.
Ask more questions if you have any!