Scaling user-uploaded GLB files for AR: bake the scale into the root
People upload GLB files in whatever units their tool used. glTF is in meters, so a mug modeled in centimeters and exported without converting units comes out 100 times too big. In Vi3w the same model opens in a 3D view,
People upload GLB files in whatever units their tool used. glTF is in meters, so a mug modeled in centimeters and exported without converting units comes out 100 times too big. In Vi3w the same model opens in a 3D view, in WebXR on Android, in Scene Viewer, and in Quick Look on iPhone.
The rule we use
- Models from 5 cm to 40 cm stay at real size
- Anything larger is scaled down so its longest side is 40 cm
- Anything under 5 cm becomes 10 cm
- The author can switch to real size, for example for a 2.9 m machine that should stand on the floor at full size
Where we apply it
We bake the scale into the root of the published GLB, and into the root of the USDZ we generate for iPhone. Both are built from the same scene at publish. Quick Look and Scene Viewer take the size from the file, so the file is the only place where the rule reaches them too.
Try it
A product page with the rule above:
https://www.vi3w.net/product-ar-viewer?utm_source=devto&utm_medium=community&utm_campaign=vi3w-launch&utm_content=vdev-02
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.