Skip to main content

WebGL API

NovoRender.API

A NovoRender API instance.

Properties​

animate​

• animate: FrameRequestCallback

Callback that is called on each frame just before rendering.

Remarks

Using this callback instead of in your own requestAnimationFrame() callback is recommended to ensure your updates are applied consistently and are properly synchronized. If you have disabled automatic rendering by setting run = false, this callback is not called unless you manually call update.


deviceProfile​

• deviceProfile: DeviceProfile

Performance profile for current device.


run​

• run: boolean

Enable or disable automatic rendering.

Remarks

This value is set to true by default when a new API is created. When true, the api will use requestAnimationFrame() callback to automatically update all active views and controllers. Setting it to false will have the effect of pausing all rendering and camera motion. You may still call update to manually render all views frame and update camera motion controllers.


version​

• Readonly version: string

API version string, expressed using semantic versioning https://semver.org/.

Methods​

availableEnvironments​

â–¸ availableEnvironments(indexUrl?): Promise<readonly EnvironmentDescription[]>

Retrieve list of available background/IBL environments.

Parameters​

NameTypeDescription
indexUrl?stringThe absolute or relative url of the index.json file. Relative url will be relative to the novorender api script url. If undefined, "/assets/env/index.json" will be used by default.

Returns​

Promise<readonly EnvironmentDescription[]>

The controller object

â–¸ availableEnvironments(indexUrl?): Promise<readonly EnvironmentDescription[]>

Retrieve list of available background/IBL environments.

Parameters​

NameTypeDescription
indexUrl?stringThe absolute or relative url of the index.json file. Relative url will be relative to the novorender api script url. If undefined, "/assets/env/index.json" will be used by default.

Returns​

Promise<readonly EnvironmentDescription[]>

The controller object


createCameraController​

â–¸ createCameraController(params): CameraController

Create a camera motion controller.

Parameters​

NameTypeDescription
paramsStaticControllerParamsThe controller parameters.

Returns​

CameraController

The controller object

â–¸ createCameraController(params): CameraController

Create a camera motion controller.

Parameters​

NameTypeDescription
paramsTurntableControllerParamsThe controller parameters.

Returns​

CameraController

The controller object

â–¸ createCameraController(params, domElement): CameraController

Create a camera motion controller.

Parameters​

NameTypeDescription
paramsOrbitControllerParamsThe controller parameters.
domElementHTMLElementThe HTML DOM element to listen for mouse/touch events. This can only be set when the controller is created.

Returns​

CameraController

The controller object

â–¸ createCameraController(params, domElement): CameraController

Create a camera motion controller.

Parameters​

NameTypeDescription
paramsFlightControllerParamsThe controller parameters.
domElementHTMLElementThe HTML DOM element to listen for mouse/touch events. This can only be set when the controller is created.

Returns​

CameraController

The controller object

â–¸ createCameraController(params, domElement): CameraController

Create a camera motion controller.

Parameters​

NameTypeDescription
paramsOrthoControllerParamsThe controller parameters.
domElementHTMLElementThe HTML DOM element to listen for mouse/touch events. This can only be set when the controller is created.

Returns​

CameraController

The controller object

â–¸ createCameraController(params): CameraController

Create a camera motion controller.

Parameters​

NameTypeDescription
paramsStaticControllerParamsThe controller parameters.

Returns​

CameraController

The controller object

â–¸ createCameraController(params): CameraController

Create a camera motion controller.

Parameters​

NameTypeDescription
paramsTurntableControllerParamsThe controller parameters.

Returns​

CameraController

The controller object

â–¸ createCameraController(params, domElement): CameraController

Create a camera motion controller.

Parameters​

NameTypeDescription
paramsOrbitControllerParamsThe controller parameters.
domElementHTMLElementThe HTML DOM element to listen for mouse/touch events. This can only be set when the controller is created.

Returns​

CameraController

The controller object

â–¸ createCameraController(params, domElement): CameraController

Create a camera motion controller.

Parameters​

NameTypeDescription
paramsFlightControllerParamsThe controller parameters.
domElementHTMLElementThe HTML DOM element to listen for mouse/touch events. This can only be set when the controller is created.

Returns​

CameraController

The controller object

â–¸ createCameraController(params, domElement): CameraController

Create a camera motion controller.

Parameters​

NameTypeDescription
paramsOrthoControllerParamsThe controller parameters.
domElementHTMLElementThe HTML DOM element to listen for mouse/touch events. This can only be set when the controller is created.

Returns​

CameraController

The controller object


createHighlight​

â–¸ createHighlight(params): Highlight

Create an object highlight

Parameters​

NameTypeDescription
paramsNeutralHighlightParamsHighlight parameters.

Returns​

Highlight

A highlight object that can be used in objectHighlights.

â–¸ createHighlight(params): Highlight

Create an object highlight

Parameters​

NameTypeDescription
paramsTransparentHighlightParamsHighlight parameters.

Returns​

Highlight

A highlight object that can be used in objectHighlights.

â–¸ createHighlight(params): Highlight

Create an object highlight

Parameters​

NameTypeDescription
paramsColorHighlightParamsHighlight parameters.

Returns​

Highlight

A highlight object that can be used in objectHighlights.

â–¸ createHighlight(params): Highlight

Create an object highlight

Parameters​

NameTypeDescription
paramsRGBATransformHighlightParamsHighlight parameters.

Returns​

Highlight

A highlight object that can be used in objectHighlights.

â–¸ createHighlight(params): Highlight

Create an object highlight

Parameters​

NameTypeDescription
paramsHSLATransformHighlightParamsHighlight parameters.

Returns​

Highlight

A highlight object that can be used in objectHighlights.

â–¸ createHighlight(params): Highlight

Create an object highlight

Parameters​

NameTypeDescription
paramsNeutralHighlightParamsHighlight parameters.

Returns​

Highlight

A highlight object that can be used in objectHighlights.

â–¸ createHighlight(params): Highlight

Create an object highlight

Parameters​

NameTypeDescription
paramsTransparentHighlightParamsHighlight parameters.

Returns​

Highlight

A highlight object that can be used in objectHighlights.

â–¸ createHighlight(params): Highlight

Create an object highlight

Parameters​

NameTypeDescription
paramsColorHighlightParamsHighlight parameters.

Returns​

Highlight

A highlight object that can be used in objectHighlights.

â–¸ createHighlight(params): Highlight

Create an object highlight

Parameters​

NameTypeDescription
paramsRGBATransformHighlightParamsHighlight parameters.

Returns​

Highlight

A highlight object that can be used in objectHighlights.

â–¸ createHighlight(params): Highlight

Create an object highlight

Parameters​

NameTypeDescription
paramsHSLATransformHighlightParamsHighlight parameters.

Returns​

Highlight

A highlight object that can be used in objectHighlights.


createView​

â–¸ createView(settings?, htmlRenderCanvas?): Promise<View>

Create a 3D View.

Parameters​

NameTypeDescription
settings?Partial<Readonly<RenderSettings>>Initial RenderSettingParams settings to use for view.
htmlRenderCanvas?HTMLCanvasElement-

Returns​

Promise<View>

A promise of a newly created View.

Remarks

It is recommend that you specify the initial display pixel width and height here to avoid unnecessary reallocation of render buffers.

â–¸ createView(settings?, htmlRenderCanvas?): Promise<View>

Create a 3D View.

Parameters​

NameTypeDescription
settings?Partial<Readonly<RenderSettings>>Initial RenderSettingParams settings to use for view.
htmlRenderCanvas?HTMLCanvasElementCanvas to render to. If none is specified, an OffscreenCanvas is used instead. Beware that not all browsers support OffscreenCanvas yet.

Returns​

Promise<View>

A promise of a newly created View.

Remarks

It is recommend that you specify the initial display pixel width and height here to avoid unnecessary reallocation of render buffers.


dispose​

â–¸ dispose(): void

Stop all rendering and release all resources.

Returns​

void

Remarks

Calling this function will effectively destroy this instance of the API and any associated scenes and views etc. This function allows you to explicitly release the associated GPU resources and memory caches used by the API without waiting for the garbage collector to do so.

â–¸ dispose(): void

Stop all rendering and release all resources.

Returns​

void

Remarks

Calling this function will effectively destroy this instance of the API and any associated scenes and views etc. This function allows you to explicitly release the associated GPU resources and memory caches used by the API without waiting for the garbage collector to do so.


loadAsset​

â–¸ loadAsset(url): Promise<DynamicAsset>

Load the specificed asset into memory.

Parameters​

NameTypeDescription
urlURLThe asset url.

Returns​

Promise<DynamicAsset>

A promise of the loaded DynamicAsset.

Remarks

Assets must be passed to createDynamicObject to be rendered. Currently, this must be a glTF file (.gltf | .glb). Cross domain urls requires CORS headers to be set appropriately.

â–¸ loadAsset(url): Promise<DynamicAsset>

Load the specificed asset into memory.

Parameters​

NameTypeDescription
urlURLThe asset url.

Returns​

Promise<DynamicAsset>

A promise of the loaded DynamicAsset.

Remarks

Assets must be passed to createDynamicObject to be rendered. Currently, this must be a glTF file (.gltf | .glb). Cross domain urls requires CORS headers to be set appropriately.


loadEnvironment​

â–¸ loadEnvironment(environment): Promise<Environment>

Load the specificed environment into memory.

Parameters​

NameType
environmentEnvironmentDescription

Returns​

Promise<Environment>

A promise of the loaded Environment.

â–¸ loadEnvironment(environment): Promise<Environment>

Load the specificed environment into memory.

Parameters​

NameType
environmentEnvironmentDescription

Returns​

Promise<Environment>

A promise of the loaded Environment.


loadScene​

â–¸ loadScene(id, db?): Promise<Scene>

Load the specificed scene into memory.

Parameters​

NameType
idstring | URL
db?ObjectDB

Returns​

Promise<Scene>

A promise of the loaded Scene.

Remarks

The loaded scene will not include all 3D or object data immediately as these are automatically downloaded on demand.

â–¸ loadScene(id, db?): Promise<Scene>

Load the specificed scene into memory.

Parameters​

NameType
idstring | URL
db?ObjectDB

Returns​

Promise<Scene>

A promise of the loaded Scene.

Remarks

The loaded scene will not include all 3D or object data immediately as these are automatically downloaded on demand.


update​

â–¸ update(): Promise<void>

Manually update all views and camera controllers.

Returns​

Promise<void>

Remarks

If you have disabled automatic rendering by setting run = false, you can call this function to manually update instead. This may be useful if you are using requestAnimationFrame yourself and want to have full control over the order by which state gets updated. The returned promise will resolve at the next animation frame, typically 1/60 of a second, which can be useful if you intend to run a realtime update loop.

â–¸ update(): Promise<void>

Manually update all views and camera controllers.

Returns​

Promise<void>

Remarks

If you have disabled automatic rendering by setting run = false, you can call this function to manually update instead. This may be useful if you are using requestAnimationFrame yourself and want to have full control over the order by which state gets updated. The returned promise will resolve at the next animation frame, typically 1/60 of a second, which can be useful if you intend to run a realtime update loop.