3D Model Optimizer
Operator: Abdulla Al Fahad. How tools are built and checked
A 3D model that looks fine on a desktop can be too heavy for a web page or an AR viewer: too many triangles, hundreds of draw calls, textures larger than the screen, and a file that takes seconds to arrive on a phone. Shrinking a GLB, glTF, OBJ, STL or PLY file here uses the same open-source steps that command-line pipelines use; the model is shown before and after side by side, and a GLB is written.
The numbers come from the document itself: triangles drawn, vertices stored, draw calls (mesh primitives), mipmapped texture memory and file size are measured before and after, so you can see which step paid off.
Key features
- Welding of vertices whose position, normal, UVs, joints and weights all match, so skinned and morphed meshes are never welded across joints
- Mesh simplification with meshoptimizer: a target share of the vertices, an error limit as a share of the mesh radius, and optional locked borders
- Merging of meshes that share a material into fewer draw calls, skipped automatically when the file has animations or skins
- Attribute quantisation (14-bit positions, 10-bit normals, 12-bit UVs) plus EXT_meshopt_compression, or Draco edgebreaker compression
- Texture downscaling to a longest side you choose, with optional WebP re-encoding when it saves bytes; a texture over 60 megapixels is refused rather than decoded
What each optimisation step changes
Input can be a binary GLB, a glTF whose buffers and images are embedded as data, or an OBJ, STL or PLY mesh, which is welded and given smooth vertex normals before it enters the pipeline. A .gltf that points at separate .bin or image files is refused with a message, because a browser cannot read sibling files you did not select.
The simplification ratio follows gltf-transform's meaning: it is the share of vertices to keep, not of triangles. The error limit is a second brake: the simplifier stops early when removing more would move the surface by more than that fraction of the mesh radius, so a low limit can leave more triangles than the ratio alone asks for.
Draco output needs a Draco decoder in the viewer (three.js, Babylon.js and model-viewer have one). Meshopt output needs the meshopt decoder. WebP textures add EXT_texture_webp as a required extension. KTX2 and Basis Universal textures are not produced, because their encoders are too heavy to run in a tab.
How it works
The page uses @gltf-transform 4.5.1 in a worker: dedup, weld, flatten and join, simplify, prune, texture resizing, quantize, and reorder plus meshopt or Draco, in that order. The meshoptimizer 1.3.0 WebAssembly is bundled in its own JavaScript; the Draco 1.5.9 encoder and decoder are served unchanged from this site under /draco/.
Triangles and draw calls are counted per node that draws a mesh, so an instanced mesh counts every time it is drawn. Texture memory is width × height × 4 bytes plus a third for mipmaps, which is what a GPU typically holds, not the PNG or JPEG size.
The before and after views are drawn by a small WebGL 2 renderer with flat shading and each material's base colour. They do not draw textures, so judge shape and silhouette there and judge texture quality in your target viewer.
Common use cases
- A 180,000-triangle product scan has to load in a product page on a phone: simplify to about a third, quantise, compress with meshopt, and check the silhouette in the right-hand view.
- A kitchen set exported from a design tool has 140 meshes that share eight materials: merging by material turns 140 draw calls into eight, one for each material, which matters more on mobile than the triangle count.
- An AR scene has four 4096 px PNG textures: downscaling to 2048 px and re-encoding as WebP cuts the mipmapped texture memory to a quarter and shrinks the file as well.
How to use this tool
- Drop a model; files up to 300 MB are accepted, and textures inside it up to 60 megapixels each.
- Choose which geometry steps to run and set the share of vertices to keep and the error limit.
- Pick Meshopt, Draco or no compression, and set the largest texture side.
- Press Optimise model and watch the step list as it runs.
- Compare the two views, read the table, and download the GLB.
Example
A UV sphere generated in code with 200 × 100 segments, saved as a GLB (illustrative, not a downloadable sample)
Keep 25% of the vertices, error limit 1.00%, weld on, merge on, meshopt compression with quantisation, then the same model with DracoTable after each run
Before: 39,600 triangles, 19,802 vertices, 713,796 bytes. After simplification and quantisation, before any meshopt or Draco compression: 9,900 triangles, 4,952 vertices, about 139,800 bytes. With meshopt: about 42,600 to 43,000 bytes. With Draco: about 28,300 bytes.Tips for best results
- Turn on locked borders for models made of separate pieces that must meet (a terrain tile, a character with hands as separate meshes), or the simplifier will open seams between them.
- If simplification stops far above your target, raise the error limit a little rather than lowering the ratio further; the limit is what stopped it.
- Draco usually gives the smallest file, meshopt the fastest decode; try both on your model and open the result in your own viewer before you ship.
Common pitfalls
Merging meshes removes the individual nodes, so scripts that look up a part by name will not find it. Leave merging off if the page needs to address parts.
Simplification is lossy. Thin shells, text in relief and sharp small details are the first things to degrade; look at the wireframe as well as the shaded view.
Common errors and how to fix them
- The page says the .gltf points at separate files
- Export a .glb, or a .gltf with embedded buffers and images, from your 3D tool. The page cannot read files next to the one you chose.
- The page says a texture is over the 60 megapixel limit
- A single embedded image is larger than the tab can safely decode (for example 20,000 × 20,000 pixels). Shrink that texture in an image editor, or remove it from the model, and open the model again.
- The worker stops with an out-of-memory message
- Turn Draco off, lower the largest texture side, or split the scene; very large scenes with many 8K textures can exceed what a tab may allocate.
- Textures look unchanged after optimising
- Textures at or below your size limit are left alone, and a WebP re-encode is kept only when it is smaller. The notes under the table say what happened.
Best practices
- Optimise from your original export, not from a file that has already been simplified or compressed.
- Test the output in the exact viewer and decoder versions of your site, because Draco and meshopt both need decoder support there.
What the file size and the frame rate each depend on
File size is mostly vertex data and textures; compression and quantisation attack that. Frame rate depends on triangles drawn, draw calls and texture memory; simplification, merging and texture downscaling attack those. The table separates the five measures so a step that shrank the download but not the draw calls is visible as such.
In the sphere example, simplification and quantisation took the sphere from 39,600 triangles and 713,796 bytes to 9,900 triangles and about 139,800 bytes before any compression; meshopt then took it to about 43,000 bytes, and Draco to about 28,300. Quantisation accounts for much of the first drop, not simplification alone.
Frequently asked questions
Why is my triangle count not exactly the ratio I asked for?
The ratio is a share of vertices and the error limit can stop the simplifier first. Open edges and split vertices also hold back collapses, which is why the page welds before simplifying.
Does it keep animations and skins?
Skinned and animated files go through welding, simplification, quantisation and compression, but meshes are not merged. Simplifying a skinned mesh can distort it at joints, so check the result in motion.
Why does the preview show no textures?
The preview renderer draws geometry with each material's base colour so it stays small and fast. Textures are measured in the table and resized in the output, but they are not drawn in the two views.