Create a viewer instance for using the webgi viewer SDK.
Private
Readonly
_canvasPrivate
Readonly
_containerPrivate
Readonly
_defaultPrivate
_isPrivate
_lastPrivate
_lastPrivate
_lastPrivate
_lastPrivate
_needsPrivate
_needsPrivate
_objectPrivate
Readonly
_sceneThe Scene attached to the viewer, this cannot be changed.
Private
_tempPrivate
_tempReadonly
assetReadonly
debugIf the viewer is enabled. Set this false
to disable RAF loop.
Specifies how many frames to render in a single request animation frame. Keep to 1 for realtime rendering. Note: should be max (screen refresh rate / animation frame rate) like 60Hz / 30fps
Readonly
pluginsEnable or disable all rendering, Animation loop including any frame/render events won't be fired when this is false.
Readonly
renderReadonly
resizeThe ResizeObserver observing the canvas element. Add more elements to this observer to resize viewer on their size change.
Readonly
typeStatic
Readonly
ConfigStatic
ConsoleStatic
DialogStatic
Readonly
VERSIONGet the HTML Canvas Element where the viewer is rendering
Get the HTML Element containing the canvas
The renderer for the viewer that's attached to the canvas. This is wrapper around WebGLRenderer and EffectComposer and manages post-processing passes and rendering logic
Protected
_animationPrivate
_onPrivate
_onPrivate
_renderPrivate
_resolveRest
...args: any[]Private
_setAdd a plugin to the viewer.
The instance of the plugin to add or the class of the plugin to add.
Rest
...args: any[]Arguments for the constructor of the plugin, in case a class is passed.
Add a plugin to the viewer(sync).
Rest
...args: any[]Add multiple plugins to the viewer.
List of plugin instances or classes
Add multiple plugins to the viewer(sync).
List of plugin instances or classes
Add an object to the scene model root. If an imported scene model root is passed, it will be loaded with viewer configuration, unless importConfig is false
Optional
options: AddObjectOptionsDeserialize all the plugins and their settings from a preset. Used in fromJSON.
The output of serializePlugins.
Optional
meta: SerializationMetaTypeThe meta object.
Disposes the viewer and frees up all resource and events. Do not use the viewer after calling dispose.
viewer.scene.disposeSceneModels()
This function is not fully implemented yet. There might be some memory leaks.Rest
...args: any[]Exports an object/mesh/material/texture/render-target/plugin-preset/viewer to a blob. If no object is given, a glb is exported with the current viewer state.
Optional
obj: ITexture | ThreeViewer | IMaterial<IMaterialEvent<IMaterialEventTypes>, IMaterialEventTypes> | IObject3D<IObject3DEvent<IObject3DEventTypes>, IObject3DEventTypes> | IRenderTarget | IViewerPlugin<ThreeViewer, boolean>Optional
options: ExportFileOptionsSerialize all the viewer and plugin settings.
Indicate that the output will be converted and saved as binary data. (default: false)
Optional
pluginFilter: string[]List of PluginType to include. If empty, no plugins will be serialized. If undefined, all plugins will be serialized.
Serialize a single plugin settings.
Optional
plugin: string | IViewerPlugin<ThreeViewer, boolean> | Class<IViewerPlugin<ThreeViewer, boolean>>Serialize multiple plugin settings.
Optional
filter: string[]List of PluginType to include. If empty, no plugins will be serialized. If undefined, all plugins will be serialized.
Export the scene to a file (default: glb with viewer config) and return a blob
Optional
options: ExportFileOptionsOptional
selected: Object3D<Event, string>Optional
duration: numberOptional
ease: "linear" | Easing | "easeIn" | "easeOut" | "easeInOut" | "circIn" | "circOut" | "circInOut" | "backIn" | "backOut" | "backInOut" | "anticipate" | "bounceOut" | "bounceIn" | "bounceInOut" | "easeInOutSine"Deserialize all the viewer and plugin settings.
use async importConfig to import a json/config exported with exportConfig or toJSON.
The serialized JSON object retured from toJSON.
Optional
meta: SerializationMetaTypeThe meta object
use assetManager instead. Gets the Asset manager, contains useful functions for managing, loading and inserting assets.
Get the Plugin by a constructor type or add a new plugin of the specified type if it doesn't exist.
Rest
...args: any[]arguments for the constructor of the plugin, used when a new plugin is created.
Get the Plugin by a constructor type or add a new plugin to the viewer of the specified type if it doesn't exist(sync).
Rest
...args: any[]arguments for the constructor of the plugin, used when a new plugin is created.
Get the Plugin by a constructor type or by the string type. Use string type if the plugin is not a dependency and you don't want to bundle the plugin.
The class of the plugin to get, or the string type of the plugin to get which is in the static PluginType property of the plugin
Imports an object/model/material/texture/viewer-config/plugin-preset/... to the viewer scene from url or an IAsset object. Same as importSingle
Optional
options: ImportAddOptionsDeserialize and import all the viewer and plugin settings, exported with exportConfig.
Deserialize and import a single plugin settings. Can also use importConfig to import only plugin config.
Optional
plugin: IViewerPlugin<ThreeViewer, boolean>Add an object/model/material/viewer-config/plugin-preset/... to the viewer scene from url or an IAsset object. Same as addAssetSingle
Optional
options: ImportAddOptionsOptional
extraResources: Partial<SerializationResourcesType>Remove a plugin instance or a plugin class. Works similar to addPlugin
Remove a plugin instance or a plugin class(sync). Works similar to addPluginSync
Serialize all the plugins and their settings to save or create presets. Used in toJSON.
The meta object.
Optional
filter: string[]List of PluginType for the to include. If empty, no plugins will be serialized. If undefined, all plugins will be serialized.
Set the background image of the scene from url or an IAsset object.
Set the viewer to dirty and trigger render of the next frame.
Optional
source: anyThe source of the dirty event. like plugin or 3d object
Optional
event: EventThe event that triggered the dirty event.
Set the environment map of the scene from url or an IAsset object.
Serialize all the viewer and plugin settings and versions.
Indicate that the output will be converted and saved as binary data. (default: true)
Optional
pluginFilter: string[]List of PluginType to include. If empty, no plugins will be serialized. If undefined, all plugins will be serialized.
Generated using TypeDoc
Three Viewer
The ThreeViewer is the main class in the framework to manage a scene, render and add plugins to it.