Scale a .glb file object in centi metres with @react-three/fiber and @react-three/drei

Hi everyone :wave:!
I’ve an empty room 3d model “empty room.glb” which I have imported using useLoader and useGLTF hooks and now I want to scale it in mm, cm or m but I don’t know how can I do so.

Three doesn’t have a concept of measure - it just uses arbitrary scale, you are free to interpret it however you need. If you are unable to scale the room to 1x1x1 in Blender, you can try the following:

  1. Load room model.
  2. Use Box3 expandByObject to create a bounding box of the entire room model.
  3. Scale the room by inverse size of the Box3, ex.:
const box3 = new Three.Box3();
const size = new Three.Vector3();




Output of this operation should be a room that’s 1x1x1 - which you can assume is 1metre by 1 metre by 1 metre. Just keep in mind - doing that kind of scaling in code may lead to chaos over time - if you can fix the model to have proper size in Blender, I’d definitely recommend doing so there.

1 Like

If your source glTF file is correctly configured, then its original units are in meters. Note that models found on sites like TurboSquid or Sketchfab may or may not use correct units.

1 Like

Do you know what are the measurements of a ???
My room’s model is exactly like that except one upper face, I think we can hide it with something I’m not sure about it too. But first I want to know the measurements of this then will move to next step.

You can find the size of the object in world units using the code @mjurczyk posted above. Supposing that was a 5m cube, and you wanted to scale it to 5cm, you’d divide the scale by 100.

1 Like