Skip to main content

WebGL API

NovoRender.View

A 3D view.

Remarks

3D views will render a scene into a provided canvas element. Any changes to the scene, camera or settings are automatically rendered in a background animation loop. When the camera stops moving, additional frames may also be rendered to incrementally refine the quality of the output image over a certain period. Setting the render property to false will stop such automatic updates.

Properties​

autoRender​

• autoRender: boolean

Flag whether to automatically render or not. Default is true.


camera​

• camera: Camera

The camera to use.


lastRenderOutput​

• Readonly lastRenderOutput: RenderOutput

The last rendered frame, if any.


performanceStatistics​

• Readonly performanceStatistics: PerformanceStatistics

Performance statistics from previously rendered frame.


scene​

• Optional scene: Scene

The scene to render.

Remarks

Assigning a new scene initiates a sequence of geometry downloads that may take a few seconds to produce any visual results and then refine over time.


settings​

• Readonly settings: RenderSettings

Current render settings.

Methods​

adjustQuality​

â–¸ adjustQuality(framerateTargets?): number

Dynamically adjust render quality to match device performance.

Parameters​

NameTypeDescription
framerateTargets?ObjectThe maximum # of milliseconds between rendered frames before reducing resolution, and minimum # of milliseconds for restoring quality. Default is 200ms, or 5 frames/second and 33.3 ms, or 30 fps
framerateTargets.lowerBoundnumber-
framerateTargets.upperBoundnumber-

Returns​

number

The last measured median frame interval, or undefined if not yet available.

Remarks

Calling this function may reduce render resolution when rendering performance drops below the specified threshold. This is particularly useful to maintain acceptable performance on mobile devices with limited fillrate and triangle capacity.


applySettings​

â–¸ applySettings(changes): void

Apply render settings changes using deep copy.

Parameters​

NameTypeDescription
changesPartial<Readonly<RenderSettings>>changes to current render settings.

Returns​

void

â–¸ applySettings(changes): void

Apply render settings changes using deep copy.

Parameters​

NameTypeDescription
changesPartial<Readonly<RenderSettings>>changes to current render settings.

Returns​

void


convertToBlob​

â–¸ convertToBlob(options?): Promise<Blob>

Convert image to a data blob.

Parameters​

NameTypeDescription
options?ImageEncodeOptions_Image encoding options.

Returns​

Promise<Blob>

A Promise to a Blob object representing the latest rendered image or undefined if device/browser does not yet support this functionality.

Remarks

See https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/convertToBlob for more details.

â–¸ convertToBlob(options?): Promise<Blob>

Convert image to a data blob.

Parameters​

NameTypeDescription
options?ImageEncodeOptions_Image encoding options.

Returns​

Promise<Blob>

A Promise to a Blob object representing the latest rendered image or undefined if device/browser does not yet support this functionality.

Remarks

See https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/convertToBlob for more details.


invalidateCamera​

â–¸ invalidateCamera(): void

Signal changed camera to force rerender.

Returns​

void


measure​

â–¸ measure(x, y): Promise<MeasureInfo>

Get MeasureInfo of nearest object (if any) at the specified pixel coordinate.

Parameters​

NameTypeDescription
xnumberview x coordinate (0=left)
ynumberview y coordinate (0=top)

Returns​

Promise<MeasureInfo>

undefined if no object intersection was found.


pick​

â–¸ pick(x, y): Promise<PickInfo>

Pick nearest object (if any) at the specified pixel coordinate.

Parameters​

NameTypeDescription
xnumberview x coordinate (0=left)
ynumberview y coordinate (0=top)

Returns​

Promise<PickInfo>

undefined if no object intersection was found.


render​

â–¸ render(frameCallback?): Promise<RenderOutput>

Render the next frame.

Parameters​

NameType
frameCallback?() => void

Returns​

Promise<RenderOutput>

A promise of the rendered output.

Remarks

This function is meant to be called in a loop. You should avoid calling it from a timer or a requestAnimationFrame callback since it's already being throttled to the screen's vertical blanking. If the existing state has already been rendered, it will wait until there are changes before initiating a new render. The returned render output object will have methods for post processing and for getting an image you can display in your own canvas. You must call dispose() on the returned render output object before you can call this function again.

â–¸ render(frameCallback?): Promise<RenderOutput>

Render the next frame.

Parameters​

NameType
frameCallback?() => void

Returns​

Promise<RenderOutput>

A promise of the rendered output.

Remarks

This function is meant to be called in a loop. You should avoid calling it from a timer or a requestAnimationFrame callback since it's already being throttled to the screen's vertical blanking. If the existing state has already been rendered, it will wait until there are changes before initiating a new render. The returned render output object will have methods for post processing and for getting an image you can display in your own canvas. You must call dispose() on the returned render output object before you can call this function again.


transferToImageBitmap​

â–¸ transferToImageBitmap(): Promise<ImageBitmap>

Transfer recently rendered image to a bitmap.

Returns​

Promise<ImageBitmap>

A Promise to the transferred bitmap or undefined if device/browser does not yet support this functionality.

Remarks

See https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/transferToImageBitmap for more details.

â–¸ transferToImageBitmap(): Promise<ImageBitmap>

Transfer recently rendered image to a bitmap.

Returns​

Promise<ImageBitmap>

A Promise to the transferred bitmap or undefined if device/browser does not yet support this functionality.

Remarks

See https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/transferToImageBitmap for more details.


updatePickBuffers​

â–¸ updatePickBuffers(): Promise<void>

Updates the pick buffers

Returns​

Promise<void>