Initial Camera Distance

Hi guys,

Sorry for the dumb question, but I’m stumped.

In the Model Viewer scene, how can I get the camera to initialise at a certain zoom distance? I’ve tried moving the camera, changing the distance in the script, changing the FOV. Everything I can think of. But it still starts with the model far away with everything visible.

I’m guessing the camera initialises somewhere to take in the whole scene? Please can you help me out with how to start the scene at a fixed zoom distance decided by me?

Many thanks for your help.


Model Viewer script tries to get model AABB and move camera away enough to see all content of scene.
You could replace content of setBestCameraPositionForModel with this:

this.reset(pc.Vec3.ZERO, this.entity.getPosition().length());

And it will pretty much focus center of scene and stay at same distance as you set it’s position.
I agree, it is not the easiest to hack around script :frowning:

Great. Thank you. That’s a big help!

Sorry. One more thing. The camera also rotates up? How can I take that out too?

Change lines 159 and 160 of camera.js from:

this.rotX = -180;
this.rotY = 0;


this.rotX = -40;
this.rotY = 30;