glTF for VR: how to optimize 3D models for headsets

By the Turbl team · · 11 min read

glTF optimization for VR means three things: fewer draw calls, fewer triangles, and textures the graphics chip can read in compressed form. Two free command-line tools do most of the work, glTF Transform and gltfpack. Compressing the file alone does not raise the frame rate. It only shortens the download.

What glTF and GLB are

glTF is an open file format for 3D models and scenes. The Khronos Group maintains it, the same body behind WebGL and Vulkan. Khronos calls it "the JPEG of 3D". Version 2.0 became an international standard in 2022, as ISO/IEC 12113:2022.

A glTF model comes in two shapes:

  • .gltf is a JSON text file. The geometry sits in a separate .bin file and the textures in separate image files.
  • .glb is the same content packed into one binary file. Use this on the web. One file means one download.

glTF is the web's 3D format because it is built for delivery, not for editing. Every major web 3D library reads it, as the comparison of WebXR frameworks shows.

glTF grows through extensions. An extension is an optional feature with a name, such as KHR_texture_basisu. Most of the optimizations below are extensions. Your loader has to support each one the file uses.

What makes a model heavy in VR

A standalone headset like the Quest runs on a phone-class chip. It draws the scene twice, once per eye, at 72 frames per second or more. Three things in a model cost the most.

Draw calls. A draw call is one instruction to the graphics chip (the GPU): draw this mesh with this material. Each one costs processor time, however small the mesh.

Triangles. Every surface in a model is made of triangles. Models made for film, 3D printing or 3D scans often have millions.

Texture memory. A texture is an image wrapped on a model. A JPEG or PNG is small on disk, but the GPU cannot read those formats. The browser unpacks them to raw pixels. A 2048 x 2048 texture takes about 16.8 MB of memory unpacked, and about 22 MB with mipmaps. Mipmaps are smaller copies of a texture, used when the surface is far away.

Khronos gives a real example in its KTX Artist Guide. A lamp model with JPEG and PNG textures was about 13 MB as a file. In GPU memory it grew to 96 MB. With compressed KTX textures the file was 10 MB and used 21 MB of GPU memory.

File size is a fourth, smaller problem. A big file loads slowly, but it does not lower the frame rate once it is loaded.

Target budgets for Quest

Meta does not publish limits for WebXR, the browser standard for VR pages. It does publish example ranges for native apps, on a page last updated October 30, 2024. Needle, the company behind Needle Engine, publishes a tighter suggestion for browser scenes.

Budget, whole scene per frameDraw callsTrianglesSource
Quest 2 and Quest Pro, native app80 to 200750,000 to 1 millionMeta
Quest 3 and Quest 3S, native app200 to 3001.3 to 1.8 millionMeta
Quest, WebXR sceneunder 100 to 150under 200,000 to 300,000 visibleNeedle

Meta's draw call figures are for a "busy simulation", such as a multiplayer shooter with many animated characters. For a light scene such as a puzzle or escape room, Meta lists 400 to 600 draw calls on Quest 2 and 700 to 1,000 on Quest 3. Meta notes that its numbers are examples and that results vary. Plan against the WebXR row if your scene runs in the browser.

These are budgets for everything on screen, not for one model. A workable way to split them:

  • A background prop: a few hundred to a few thousand triangles, one material.
  • A hero object the player holds and inspects: tens of thousands of triangles at most, one or two materials.
  • Textures: 1024 pixels for most objects, 2048 for the few that fill the view. Khronos advises textures "usually no larger than 2048x2048".

The split is a rule of thumb, not a published standard. Measure the full scene on a real headset. The guide to WebXR performance on Meta Quest shows how to find out which limit you are hitting.

Measure first

Install glTF Transform, a free command-line tool and JavaScript library. As of November 2026 the current version is 4.5, and it needs Node.js 20 or newer.

npm install --global @gltf-transform/cli
gltf-transform inspect model.glb

inspect prints tables for scenes, meshes, materials, textures and animations. Read four things: the number of meshes and materials (roughly your draw call count), the triangles per mesh, the size of each texture, and the extensions the file needs.

A scan with 2 million triangles needs simplifying. A product model with eight 4096 pixel textures needs texture work.

glTF optimization with one command

glTF Transform has an optimize command that runs its whole pipeline.

gltf-transform optimize input.glb output.glb --texture-compress webp --texture-size 1024

By default, optimize does this:

  • Removes duplicate and unused data.
  • Turns repeated meshes into GPU instances, so many copies draw in one call.
  • Merges materials that differ only in plain color values into one material with a small palette texture.
  • Flattens the scene and joins meshes that share a material, which cuts draw calls.
  • Welds identical vertices and simplifies geometry within a very small error limit.
  • Resizes textures to a maximum of 2048 pixels, unless you set --texture-size.
  • Compresses geometry and animation with Meshopt.

In the example, --texture-compress webp shrinks the download only. The KTX2 section below shows the option that also saves GPU memory.

Two warnings. First, joining merges named parts. If your code looks up a door or a wheel by name to animate it, add --join-named false, or the part may no longer exist. Second, optimization loses data. Keep the original file and always optimize from it.

gltfpack is the other main tool. It comes from the meshoptimizer project. Download a binary from the project's releases page. An npm package exists, but the project recommends the native binary because it is faster and supports texture compression.

gltfpack -i input.glb -o output.glb -cc -tc

-cc compresses geometry and animation with Meshopt, at its higher compression level. -tc converts textures to KTX2. gltfpack also merges meshes by default, unless their nodes are animated. Add -kn to keep named nodes so your code can still move them.

glTF Transformgltfpack
Installnpm, needs Node.js 20 or newerNative binary or npm
StyleMany small commands, plus optimizeOne command with flags
Geometry compressionMeshopt, Draco or quantizationMeshopt
KTX2 texturesYes, needs KTX-Software 4.4 or newer installedYes, in the native binary
Also a code libraryYes, JavaScriptNo

Pick gltfpack for a fast one-step pipeline. Pick glTF Transform when you need control over single steps or want to script them.

Fewer triangles

Simplification removes triangles while trying to keep the shape. Both tools use the same meshoptimizer algorithm.

gltf-transform simplify input.glb output.glb --ratio 0.5 --error 0.001

--ratio 0.5 aims to keep half the vertices. --error 0.001 stops the tool when the shape would change by more than 0.1 percent of the model's size. The tool stops at whichever limit it reaches first. Run gltf-transform weld first for the best result.

In gltfpack, the flag is -si 0.5.

Automatic simplification works well on dense scans and sculpted models. A model that is already low-poly has few triangles to spare, so the result often looks broken. Reduce those by hand in a 3D editor. Check the result in the headset, because flaws that hide on a monitor show up at arm's length.

Meshopt vs Draco

Both compress geometry so the file downloads faster. Neither makes the model draw faster. After loading, the GPU holds the same triangles.

MeshoptDraco
CompressesGeometry, morph targets, animationTriangle geometry only
DecodingAbout 1 GB per second on desktop hardware, per the specAdds load time
glTF extensionEXT_meshopt_compressionKHR_draco_mesh_compression

Draco's cost is decode time on the headset before the model appears. The glTF Transform docs also warn that for geometry under 1 MB, the Draco decoder download may outweigh the saving.

Meshopt output is designed to be compressed a second time by the web server. Turn on gzip or Brotli for .glb files to get the full saving. It is the default in gltf-transform optimize.

A newer KHR_meshopt_compression extension exists. Its spec is a release candidate as of November 2026. gltfpack and Blender 5.3 can already write it. Stay with the EXT version unless you know your loader reads the new one.

KTX2 textures

KTX2 is a container for textures that stay compressed in GPU memory. The glTF extension is KHR_texture_basisu. The file holds a universal format called Basis Universal. At load time, a small decoder converts it to whatever compressed format the device's GPU supports.

Meta recommends KTX 2.0 with Basis Universal for WebXR on Quest. The file may be larger than a JPEG, but the texture is smaller in memory and faster for the GPU to read. Needle's docs say compressed textures use 4 to 8 times less GPU memory than uncompressed ones.

Basis Universal has two modes:

ModeSizeQualityUse for
ETC1SSmallerLowerBase color, emissive, flat or simple images
UASTCLargerHigherNormal maps, packed roughness and metalness maps

A normal map is a texture that fakes small surface detail.

With --texture-compress ktx2, glTF Transform uses UASTC for normal, occlusion and roughness/metalness maps and ETC1S for the rest:

gltf-transform optimize input.glb output.glb --texture-compress ktx2 --texture-size 1024

This needs the ktx tool from Khronos KTX-Software, version 4.4 or newer, on your system. Texture width and height must be multiples of four for KHR_texture_basisu. Stick to powers of two (512, 1024, 2048) and you are safe.

WebP and AVIF, the other options for --texture-compress, only shrink the download. In memory they unpack to full size, like JPEG and PNG. Choose them when download size is your only problem.

Blender export settings

Start clean at export and the tools have less to fix. In Blender, use File, Export, glTF 2.0. These names are from the Blender 5.3 manual.

  • Format: glTF Binary (.glb).
  • Include, Selected Objects: export only what you selected.
  • Data, Mesh, Apply Modifiers: on, so the exported mesh matches what you see.
  • Data, Scene Graph, GPU Instances: on when the scene repeats one mesh many times.
  • Draco Compression and Meshopt Compression: leave both off if you will run glTF Transform or gltfpack afterwards. Compress once, as the last step.

Before exporting, join parts that never move apart, and reuse one material where you can.

Loading the optimized file in three.js

A compressed file needs matching decoders. In three.js, you attach them to the loader. These paths match the three.js docs as of November 2026 (release 187).

import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js';
import { MeshoptDecoder } from 'three/addons/libs/meshopt_decoder.module.js';

const ktx2Loader = new KTX2Loader()
  .setTranscoderPath('/basis/')
  .detectSupport(renderer);

const loader = new GLTFLoader();
loader.setKTX2Loader(ktx2Loader);
loader.setMeshoptDecoder(MeshoptDecoder);

const gltf = await loader.loadAsync('/models/output.glb');
scene.add(gltf.scene);

/basis/ is a folder you serve yourself. Copy the files from examples/jsm/libs/basis/ in the three.js package into it. For a Draco file, create a DRACOLoader, point it at the Draco decoder files with setDecoderPath, and pass it to loader.setDRACOLoader.

If a file fails to load after optimization, a missing decoder is the usual cause. Run gltf-transform inspect and compare the required extensions with what your loader has. The React Three Fiber VR tutorial covers loading models in a React scene. You can check that the file loads with the methods in testing WebXR without a headset. Judge frame rate only on the real device.

If you do not build the scene by hand

This pipeline is for people who model or download assets and write the scene code. AI builders work differently. Turbl builds a WebXR scene from a text description, and the AI makes the objects from that description. You can attach files such as a logo or product photos. Importing your own 3D models is not a listed feature as of November 2026. For a project built around your own models, use a framework and the steps above.

FAQ

How many triangles can a Quest handle?

Meta's example ranges for native apps are 750,000 to 1 million triangles per frame on Quest 2 and 1.3 to 1.8 million on Quest 3 and 3S. In the browser, plan for less. Needle suggests under 200,000 to 300,000 visible triangles for WebXR on Quest.

Should I use Draco or Meshopt?

Use Meshopt for VR in most cases. It decodes fast and also compresses animation. Serve the file with gzip or Brotli. Try Draco only if a test on your own model shows a clearly smaller download.

Does compressing a GLB make it run faster?

Not by itself. Draco and Meshopt only shrink the download. The frame rate improves when you cut draw calls, cut triangles, or switch to KTX2 textures that stay compressed in GPU memory.

Why is my KTX2 file bigger than the JPEG?

That is normal. KTX2 is built to stay compressed in GPU memory, not to be the smallest file. A JPEG is small on disk but unpacks to full size in memory. In VR, the memory saving is worth more.

Sources

Keep reading