meshfx // THREE.JS

Why is my model the wrong size in three.js

Your model looks the wrong size in three.js because three.js has no fixed unit: GLTFLoader loads glTF in meters, and your camera and scene decide how that looks. Measure the loaded model with a Box3, compare it with the size you expect, then fix the file or set scale on the loaded scene once.

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.

  • three.js: no fixed unit
  • GLTFLoader: glTF loads in meters
  • Measure with Box3().setFromObject()

01 // CODE

Measure and scale a loaded model

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

new GLTFLoader().load('crate.glb', (gltf) => {
  const size = new THREE.Box3().setFromObject(gltf.scene).getSize(new THREE.Vector3());
  console.log('size', size);
  // this crate should be 1 m tall
  gltf.scene.scale.multiplyScalar(1 / size.y);
  scene.add(gltf.scene);
});

02 // HOW TO

Fix the size for three.js

  1. Load the model and log its bounding box size, as in the code.
  2. Compare with the real size. Around 100 times too big points to a model built in centimeters.
  3. Fix the source if you can: scale it to real size in your 3D editor, apply the scale and export the GLB again.
  4. Otherwise set gltf.scene.scale once after loading.
  5. Set the camera's near and far to fit the scene, since a model far outside that range is clipped away.

meshfx has units and origin settings, can face a named axis and rename nodes. Set the scale using the known dimensions of your source, then inspect the output in Godot 4. Hosted meshfx runs are available in the Playground.

03 // WHY

Why the camera makes size confusing

In three.js only the view tells you a model is too big. A huge model fills the screen or puts the camera inside it, so you see nothing, and a tiny one sits as a dot near the origin. Lights with distance falloff and physics libraries do assume a unit, usually meters, so a model at real size keeps them right.

05 // FAQ

three.js model size questions

All questions →

README.MODEL_WRONG_SIZE_THREEJS
How do I load a GLB at the right size in three.js?

Load it with GLTFLoader, measure gltf.scene with Box3 and scale it once if the file is off. A correct GLB is already in meters.

Why does my OBJ or FBX load at a different size than my GLB in three.js?

glTF is always meters while OBJ has no unit and FBX is often centimeters. Scale those models by 0.01 if needed or convert them to GLB.

Why can I not see my model in a three.js viewer?

It may be so large that the camera sits inside it or so small that it is a dot. Measure it with Box3 then move the camera back.

What size should I build a model for three.js?

Build at real size in meters and export as GLB. Your camera, lights and any physics library can then share the same unit.

Explore meshfx outputs

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

All effects, guides and explainers →