[SOLVED] How to create model with fixed size

hello, I am trying to load different models from gltf using loader but I have a json file with specs of size and origin. Something like this.

{
        "origin": { "x": 1.25, "y": 0.35, "z": -1.75 },
        "size": { "width": 1.75, "height": 0.03, "depth": 0.5 },
        "instanceID": "178"
}

How do I resize the gltf model to have exactly that size in the scene. I am trying to recreate a scene based on a json file generated from another builder application written in godot.

Hi @DANIEL_SSEJJEMBA,

One way to do this:

  1. Load your gltf model in scene.
  2. Measure its total aabb by creating a pc.BoundingBox and adding the bounding box for each mesh instance.
  3. Now you can measure the exact difference from your JSON spec for each side and calculate the scaling factor. And you can scale the model entity accordingly.
1 Like

Thanks @Leonidas for the quick reply. I was thinking about using the same thing too but landed on calculatedWidth and calculatedHeight from pc.ElementComponent thought maybe there was a simpler way to do this without using calculated scales.

1 Like

That property won’t help you much since it’s used only by UI elements.

1 Like

Ohhh thanks for the insights… amazing I don’t have to spend hours making it work… I’ll just go with the calculated scales…

1 Like