Skip to content
Advertisement

ThreeJS Match GLTF Model To Size Of Bounding Box

I want to scale the imported GLB Model to the same size a cube in my scene. It is needed to make sure that the model stays inside the shadow casting areas and is big enough to make the shadows visible.

I ‘ve calculated the bounding Boxes of both objects already:

JavaScript

and

JavaScript

but now I do not know what to do with them to modify the scale of the GLTF Model

JavaScript

I’ve already researched quite a bit but I do not seem to understand the solutions I’ve found so far.

How can I modify the model scale to match the sceneBounds with the information I have?

UPDATE: To get the bounding box use .setFromObject() instead:

JavaScript

Advertisement

Answer

For example like this:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement