A Viewer can exist completely without a Session, as a Session can exist without a Viewer. The Viewer is responsible for rendering and rendering related settings. For example, camera and light management happens here. Additionally, a Viewer has many options, as rendering options can be enabled or disable (shadows, ambient occlusion, etc.) and scene properties can be adjusted (groundplane, grid, etc.).
By reusing the simple example from the first section, we will now disable the groundplane. The logic presented can be used for many of the standard properties.
// just call the update function for the groundplane value viewer.groundPlaneVisibility = false;
In our next example we create an Orthographic Camera, which will be assigned as the default camera automatically.
// create an orthographic camera, it will be assigned automatically const camera = viewer.createOrthographicCamera(); // we now update the direction of the orthographic camera camera.direction = ORTHOGRAPHIC_CAMERA_DIRECTION.FRONT;
Therefore, we now create a new Light Scene and add a few lights to it.
// create a light scene, it will be assigned automatically const lightScene = viewer.createLightScene(); // add a new ambient light, it will be added to the current light scene const ambientLight = lightScene.addAmbientLight(); // add a new directional light, it will be added to the current light scene const directionalLight = lightScene.addDirectionalLight(); // change the color of the directional light directionalLight.color = '#0000ff';