HTMLCanvasElement for the viewer used to operate on. Defined only while the viewer is initialized.
List of canvas events, such as mouse events or pointer events or touch events that the viewer should listen and redirect to the draggers and components.
By default, the following events are redirected:
The Client
instance that is used to load model reference files from the Open Cloud Server.
List of names of available components.
List of names of available draggers.
The following draggers are available by default:
For a quick reference on how to implement your own dragger, see IDragger.
Viewer options.
Saves the viewer state at the viewpoint.
To save a viewpoint to the server for a specific file, use the File.saveViewpoint()
.
Sets the viewer state to the specified viewpoint.
To get a list of available viewpoints from the server for a specific file, use the
File.getViewpoints()
.
Viewpoint data.
Fires the event. Alias to emitEvent().
The type of event that gets fired.
The event properties.
Executes the command denoted by the given command ID.
ID of the command to execute.
Parameters passed to the command handler function.
Returns the result of the command handler function. Returns undefined
when the command
doesn't exists.
Returns the component reference, or null
if there is no component with the specified name.
Initializes the viewer it with the specified canvas. Call dispose() to release allocated resources.
Fires:
HTMLCanvasElement for the viewer used to operate on.
Optional
onProgress: (event: ProgressEvent) => voidA callback function that handles events measuring progress of viewer initialization.
Removes the listener from an event type. Alias to removeEventListener().
The type of the event that gets removed.
The listener function that gets removed.
Registers a new listener for the event type. Alias to addEventListener()
The type of event to listen to.
The function that gets called when the event is fired.
Loads a file into the viewer.
The viewer must be initialized before opening the file. Otherwise, open()
does
nothing.
This method requires a Client
instance to be specified to load file from the Open Cloud Server.
The file geometry data on the Open Cloud Server must be converted into a format siutable for the
viewer, otherwise an exception will be thrown.
For files from Open Cloud Server, the default model will be loaded. If there is no default model, first availiable model will be loaded. If no models are found in the file, an exception will be thrown.
The file extension is used to determine the file format. For a ArrayBuffer
, Blob
and Data URL
,
a file format must be specified using params.format
parameter (see below). If no appropriate
loader is found for the specified format, an exception will be thrown.
If there was an active dragger before opening the file, it will be deactivated. After opening the file, you must manually activate the required dragger.
To open a large files, enable partial streaming mode before opening. For example:
viewer.options.enableStreamingMode = true;
viewer.options.enablePartialMode = true;
await viewer.open(file);
Fires:
File to load.
Loading parameters.
Optional
format?: stringFile format string. Required when loading a file as ArrayBuffer
, Blob
or
Data URL
.
Optional
mode?: stringFile opening mode. Can be one of:
open
- Unloads an open file and opens a new one. This is default mode.append
- Appends a file to an already open file. This mode is not supported for all formats.Changes the active dragger. The viewer must be initialized before activating the dragger, otherwise an exception will be thrown.
Fires:
Dragger name. Can be one of the draggers list or an ampty string to deactivate the current dragger.
Returns the new active dragger reference or null
if there is no dragger with the given
name.
Viewer core interface.