---
title: "LOD in three.js with THREE.LOD | Spatial Compiler"
description: "Use THREE.LOD in three.js: add the detailed mesh at distance 0 and lighter meshes farther out with addLevel, and pass a hysteresis value to stop flicker."
canonical: https://appliedmanifold.com/mesh/lod-threejs/
site: "Applied Manifold: The spatial compute cloud for 3D reality"
---

1.  [Home](https://appliedmanifold.com/)
2.  [meshfx](https://appliedmanifold.com/mesh/)
3.  LOD in three.js

meshfx // LOD // THREEJS

# How to use LOD in three.js

In three.js you build LOD with a `THREE.LOD` object: add the detailed mesh at distance 0 and simpler meshes at larger distances with `addLevel(mesh, distance)`, then add the LOD to your scene. The renderer shows the right level for each camera distance, and the simpler meshes come from your 3D editor as separate GLB files.

[Get Free API Key](https://console.appliedmanifold.com/sign-in?next=/api-keys) [meshfx docs →](https://appliedmanifold.com/docs/mesh/)

pyrofx effects work today, and new accounts start with $5 of usage.

**MODULE // meshfx AVAILABLE**

meshfx measures faults, checks repairs and makes LODs for a triangle budget. meshfx runs on the hosted API: try it in the [Playground](https://appliedmanifold.com/playground/).

-   Object: THREE.LOD
-   addLevel(mesh, distance, hysteresis)
-   Distances in scene units

01 // CODE

## Load three levels and switch by distance

1.  Export three versions of the model from your 3D editor, for example 20,000, 5,000 and 1,000 triangles, as `rock_lod0.glb`, `rock_lod1.glb` and `rock_lod2.glb`.
2.  Load all three with `GLTFLoader`.
3.  Add each one to a `THREE.LOD` at the distance where it takes over, in scene units (meters for glTF).
4.  Add the LOD to the scene and fly the camera out to check each switch.

rock-lod.js

```
import * as THREE from 'three';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';

const loader = new GLTFLoader();
const files = ['rock_lod0.glb', 'rock_lod1.glb', 'rock_lod2.glb'];
const distances = [0, 15, 40];

const gltfs = await Promise.all(files.map((f) => loader.loadAsync(f)));
const lod = new THREE.LOD();
gltfs.forEach((gltf, i) => lod.addLevel(gltf.scene, distances[i]));
lod.position.set(0, 0, -10);
scene.add(lod);
```

02 // FLICKER

## Stop levels flickering at the switch distance

When the camera sits right at a switch distance, small movements can flip the level back and forth. Pass a hysteresis value as the third argument, as in `lod.addLevel(mesh, 15, 0.1)`, so the switch back happens about 10 percent closer than the switch out.

`lod.autoUpdate` is true by default, so the renderer updates the level for you. If you render one scene with several cameras, set it to false and call `lod.update(camera)` yourself.

03 // WHAT LOD SAVES

## What LOD saves in a browser

LOD cuts the triangles drawn per frame, but the browser still downloads every level. Keep the far levels very light, share one material and texture across levels, and load the detailed level last if the model starts far from the camera.

For hundreds of copies of the same object, `InstancedMesh` saves more than LOD, because it draws every copy in one call.

04 // meshfx

## meshfx for lod in three.js

meshfx reduces toward a triangle budget and makes LODs by count, ratio, explicit budgets or error. Each level reports measured distance, outline and faults. Godot 4 is the supported output target. Hosted meshfx runs are available in the Playground.

05 // RELATED

## Related pages

-   [LOD in Unity AvailableSet up a LOD Group in Unity by hand or from \_LOD suffixes in an FBX, pick switch points, and cross-fade between levels.](https://appliedmanifold.com/mesh/lod-unity/)
-   [LOD in Godot 4 AvailableHow Godot 4's automatic import LODs work, how to tune them with lod\_bias, and when to use visibility ranges instead.](https://appliedmanifold.com/mesh/lod-godot/)
-   [Web polycount AvailableTriangle and file size budgets for browser scenes and three.js games, and how to count what each frame draws.](https://appliedmanifold.com/mesh/polycount-web/)
-   [Collision in three.js AvailableCollision in three.js with a hidden low-poly mesh in your GLB, the Octree and Capsule addons, or a physics library with simple shapes.](https://appliedmanifold.com/mesh/collision-mesh-threejs/)
-   [Level of detail (LOD) AvailableLOD keeps lighter versions of a model and swaps them in as it shrinks on screen, cutting triangles without visible loss.](https://appliedmanifold.com/learn/lod/)
-   [FBX to GLB AvailableConvert an FBX file to GLB by hand, and what changes on the way: units, axes, materials, n-gons and animation.](https://appliedmanifold.com/mesh/convert-fbx-to-glb/)
-   [meshfxmeshfx reads an input model, repairs surface faults and compiles reduced GLB levels of detail for Godot, three.js or any glTF loader.](https://appliedmanifold.com/docs/mesh/)

[All pages in meshfx →](https://appliedmanifold.com/mesh/)

[← LOD in Roblox](https://appliedmanifold.com/mesh/lod-roblox/)[Collision in Godot 4 →](https://appliedmanifold.com/mesh/collision-mesh-godot/)

06 // FAQ

## three.js LOD questions

[All questions →](https://appliedmanifold.com/faq/)

**README.LOD\_THREEJS**

### What is LOD in three.js?

THREE.LOD is an object that holds multiple mesh versions and displays the appropriate one based on distance from the camera.

### How do I set up a three.js LOD object?

Create a THREE.LOD instance, call addLevel with each mesh and switch distance in meters, then add it to your scene.

### How do I prevent LOD popping in three.js?

Switch at distances where changes cover few pixels and pass a hysteresis value as the third argument to addLevel.

### How much should I reduce polycount between three.js LOD levels?

Cut each level to a quarter or third of the previous mesh, using two lower levels so web downloads stay small.

## Explore meshfx outputs

Inspect compiled meshfx outputs and their reports. Hosted meshfx runs are available in the Playground.

[Get Free API Key](https://console.appliedmanifold.com/sign-in?next=/api-keys) [meshfx →](https://appliedmanifold.com/docs/mesh/)

[All effects, guides and explainers →](https://appliedmanifold.com/effects/)
