Skip to main content

Constructors

constructor

Parameters: Returns: Viewer

Accessors

Utils

Returns: Utils

World

Returns: World

Methods

cancelLoad

Cancels any ongoing loading operations, with the option of unloading an current progress Parameters:
  • url: string
  • (optional) unload: boolean
Returns: A promise which resolves when the operation completes

createExtension

Creates and registers the extension of the specified type constructor Parameters:
  • type: Extension subclass
Returns: The extension instance

dispose

Disposes the viewer instance Returns: void

getContainer

Gets HTML container used at viewer initialisation Returns: HTMLElement

getExtension

Gets the extension of type T registered with the viewer. Returns: Extension subclass, undefined if it does not exist

getObjectProperties

Returns PropertyInfo objects for all loaded objects. Properties are automatically extracted and cached when models are loaded. Parameters:
  • (optional) resourceURL: The resource URL to get properties for. If omitted, returns properties for all loaded resources.
Returns: PropertyInfo[]

getRenderer

Gets the SpeckleRenderer instance associated with the viewer. Returns: SpeckleRenderer

getViews

Gets all the current SpeckleView instances. Returns: SpeckleView[]

getWorldTree

Gets the WorldTree instance associated with the viewer. Returns: WorldTree[]

hasExtension

Returns true if specified extension type exists, false otherwise Returns: boolean

init

Initializes the viewer asynchronously and loads required assets. Returns: Promise< void >

loadObject

Loads an object using the specified loader. Parameters:
  • loader: SpeckleLoader
  • (optional) autoFit: boolean - Whether to automatically fit the view to the loaded object
Returns: Promise< void >

on

Subscribes handlers to ViewerEvents. Parameters:
  • eventType: The ViewerEvent the handler needs to register to
  • handler: The event handler
Returns: void

query

General purpose mechanism for getting spatial information from the viewer. Parameters:
  • query: The Query to run
Returns: QueryResult

requestRender

Requests the viewer to render one or more frames. Parameters:
  • (optional) flags: UpdateFlags. If no flags are provided it defaults to UpdateFlags.RENDER.
Returns: void

resize

Resize the viewer manually. The dimensions will be inherited from the container. Returns: void

screenshot

Takes a snapshot of the current viewer camera view and returns it as a base64 encoded string. Returns: A promise which resolves to a base64 encoded image.

setLightConfiguration

Applies the provided LightConfiguration. Returns: void

unloadAll

Unloads and disposes everything that’s currently loaded. Returns: _Promise< void > _

unloadObject

Unloads and disposes the specified resource associated with the provided url. Parameters:
  • url: The resource id to unload.
Returns: _Promise< void > _

Typedefs

LightConfiguration

  • enabled: Enables direct lighting (sun).
  • castShadow: Enables shadows.
  • intensity: Direct light(sun) intensity.
  • color: Direct light(sun) color.
  • indirectLightIntensity: Indirect IBL intensity.
  • shadowcatcher: Enables The Shadowcatcher. 🛸

ObjectLayers

All the layers the viewer uses for rendering objects and props. Rendering order generally follows the order of layers values. The same layers are also used for raycasting, where they are all enabled by default except STREAM_CONTENT_POINT which is disabled

PropertyInfo

  • key: Property identifier, flattened (e.g., "level.name").
  • objectCount: Total number of objects that have this property.
  • type: The property value type - numeric, string, or boolean.
  • path: Property path as an array (e.g., ["level", "name"]).
  • concatenatedPath: Full property path, same as key.
  • name: The property name (last segment of path, e.g., "name").

NumericPropertyInfo

Extended property info for numeric properties, includes min/max range and all value-to-object mappings.

StringPropertyInfo

Extended property info for string properties, includes value groups mapping string values to object IDs.

BooleanPropertyInfo

Extended property info for boolean properties, includes value groups mapping boolean values to object IDs.

SelectionEvent

Payload for ViewerEvent.ObjectClicked and ViewerEvent.ObjectDoubleClicked.
  • multiple: Whether this is a multiple selection or not.
  • event: The browser PointerEvent piggybacked.
  • hits: The array of hits sorted by distance, where closest is first. node is the intersected TreeNode and point is it’s point of intersection.

SpeckleView

  • origin: The origin (location) of the view
  • target: The point where the view is “looking at”.
  • (optional) name: Human readable name
  • (optional) upDirection: The view’s basis up
  • (optional) name: The view’s basis forward

SunLightConfiguration

  • elevation: Sun elevation in polar coordinates.
  • azimuth: Sun azimuth in polar coordinates.
  • radius: Sun distance from World center.

UpdateFlags

Specifies which rendering aspects need to be updated. UpdateFlags work by bit masking. So if you want multiple flags, you need to OR them.

UtilsInterface

Two utilities that help you move values form NDC to Screen space and back.

ViewerEvent

All the events the viewer can emit.

ViewerEventPayload

Mapping of viewer events to event handler argument types

ViewerParams

  • showStats: Displays a stats panel.
  • environmentSrc: The URL of the image used for indirect IBL.
  • verbose: Enables viewer logs.
  • restrictInputToCanvas: Restricts all input listening, especially keyboard, to the viewer’s rendering canvas

Asset

  • id: Mandatory id of the asset.
  • src: The URL of the asset. Supports inline base64 encoded assets
  • type: AssetType
    For correct asset caching use need to use unique asset ids!

WorldClass

Utility class for keeping track of the total dimensions of loaded objects. It’s mostly used for informative purposes

Constants

DefaultViewerParams

Last modified on July 18, 2026