How to scale down/up a model for consistency

I have an interface wherein I can upload models. Now the issue is that some models are coming as very large and some very small even though with a scale of 1.0

Now this makes the model go outside the canvas viewport.

is there a way to fix this programmatically? Such that the model is always scaled down to fit inside the canvas bounds?

Thanks :slight_smile:

You often do it the other way around. Meaning you do not touch the object’s scale but update the camera’s position and view frustum so it encloses the object. This is done by computing the bounding box of the object and use it to derive updated camera parameters. Check out how gltf-viewer does it:

1 Like

@Mugen87 Great approach, tried this and now the model was indeed in my canvas viewport.
But the issue is that I’m uploading this model to a DB.

Now on the user app, this model will already be scaled up (since we only modified the camera) such that when the user sees the model/or download, it’ll again be very huge.

Now in this case, Do you think it’ll be better to scale up/down the model dynamically?