These examples are a continuation of our simple example, please have a look there first.

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;
TYPESCRIPT

Cameras

One of the standard adaptions is to change some Camera properties. We distinguish here between a Perspective Camera and an Orthographic Camera.

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;
TYPESCRIPT

Lights

For lights, we always handle a bunch of them at once, that's why we introduce Light Scenes. A Light Scene is a grouping of lights. The lights in a Light Scene can be freely manipulated.

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';
TYPESCRIPT