How are the Parameters for the Default Camera Computed?

How is the default position for the Initial Camera (Home Button) computed ? The target seems to be the model center. How can I compute the camera position ?


the camera target is computed based on the extents of the bounding box of the model with a few adjustments. Depending on the model, the default camera might also be baked into the model coming from the CAD System.

Hope this helps.

1 Like

Hello @y2kveer,

If your workflow involves “intercepting” the camera before it is set in the Web Viewer, you could try using a callback for that, in particular, modelStructureReady.

In the code snippet below, you can get the camera object and then modify it to your liking:

function myFunction() {
	console.log("myFunction callback");

	modelStructureReady: myFunction,


Worth noting is that the Home button camera setting is not affected. So if you activate the Home button again, it will use the original camera setting.


1 Like

Thanks @guido and @tino for the reply.
The problem is when I initialize the viewer with a scs file which contains hidden elements only, the default camera is set as if it is an empty viewer (NavCube Top View), which is fine.
But when another model is loaded in the same viewer (‘arboldea.scs’) the default view stays the same (NavCube Top View)

This does not occur if I load the arboleda model first and then the file with the hidden elements. In that case the view is properly set.

I want to ensure that the default view stays the same regardless of the order in which the files are loaded by setting the parameters of the camera.

This post describes how to create the standard views, but I want to create the default view that the webviewer creates (or is exported along with the scs file)

Below is the main part of the internal fitWorld() code that is used in the viewer to perform a fit world based on the model bounding. That should get you mostly there. On top of that you probably want to use the getViewAxies() function to determine the up and front vector of the model and adjust the view direction based on that.

 const extents = bounding.extents();
 const extentsLength = extents.length();

  const width = camera.getWidth();
  const eye = Point3.subtract(camera.getPosition(), camera.getTarget());
  const eyeLength = eye.length();
  const newEyeLength = (extentsLength * eyeLength) / width;

  const target =;
  const position = Point3.add(target, eye.normalize().scale(newEyeLength));


1 Like