3D model viewer.

See "@xeokit/sdk/viewer" for usage.

Constructors

  • Creates a Viewer.

    Parameters

    • Optionalparams: { id?: string; logging?: boolean; scene?: Scene }

      Viewer configuration.

      • Optionalid?: string

        ID for this Viewer, automatically generated by default.

      • Optionallogging?: boolean

        Enables or disables error logging to the console for this Viewer. Default value is false.

      • Optionalscene?: Scene

        Contains model representations. The same Scene can be attached to any number of Viewers.

    Returns Viewer

Properties

destroyed: boolean

True once this Viewer has been destroyed.

Don't use this Viewer if this is false.

events: ViewerEvents

The events emitted by this Viewer.

id: string

ID of this Viewer.

logging: boolean = false

Enables or disables error logging to the console for this Viewer.

Default value is false.

numViews: number

The number of Views belonging to this Viewer.

scene: Scene

The Viewer's scene representation.

The !SceneModel | SceneModels is the container of !SceneModel | SceneModels and !SceneObject | SceneObjects, which contain the geometry and materials for models currently loaded in the Viewer.

viewList: View[]

List of all the Views in this Viewer.

Each View is an independently configurable view of the Viewer's models, with its own canvas, camera position, section planes, lights, and object visual states.

views: { [key: string]: View }

Map of all the Views in this Viewer.

Each View is mapped here against View.id.

Each View is an independently configurable view of the Viewer's models, with its own canvas, camera position, section planes, lights, and object visual states.

Methods

  • Creates a new View within this Viewer.

    const viewResult = myViewer.createView({
    id: "myView",
    elementId: "myView1"
    });

    if (!viewResult.ok) {
    console.error(viewResult.error);
    } else {
    const view = viewResult.value;
    view.camera.eye = [-3.933, 2.855, 27.018];
    view.camera.look = [4.400, 3.724, 8.899];
    view.camera.up = [-0.018, 0.999, 0.039];

    //...
    }

    Parameters

    Returns SDKResult<View>

    A result containing the created View on success, or an error message on failure.