I am developing a web-based 3D editor based on Babylon.js and have encountered a few issues:
Step 1:
I provide an import button, which imports the GLB model and performs optimization and compression using gltf-transform. Below, I will share the specific code.
Step 2:
I modify the models in the scene, such as their position and size. This is the current functionality, and in the future, there will also be material modifications, etc.
Step 3:
I provide a save button. After clicking “Save,” it exports a new GLB using GLTF2Export.GLBAsync.
The steps above outline the process. Below are the issues I am encountering:
- The size of the model I imported is 65.8M.
- After optimization, the size of the imported model is 10M.
- After using GLTF2Export.GLBAsync to save, the size is 180M.
(I understand why it becomes large, as I have seen similar cases on other forums, so I thought about optimizing it again after export.) - After re-optimizing the exported model, its size is 6M.
Question 1:
Why is the size of the re-optimized model (step 4) smaller than the optimized model (step 2), even though I adjusted the parameters in gltf-transform but could not get the same size?
This issue causes problems when I re-import the model from step 4 back into Babylon.js because content is lost. It undergoes another optimization, and the file gets smaller again after saving, which is not what I want.
I would expect the size from step 2 to step 4 to remain the same, as I didn’t make any changes to the model after importing. Could you please help me identify where I might have gone wrong? I will provide the code below.