Skip to main content

Interface: ICustomRenderer

viewer.ICustomRenderer

interface

description Interface for custom renderers. This is a specification for implementers to model: it is not an exported method or class.

A custom renderer allows the API user to render directly into the viewer's GL context using the viewer's camera.

Custom renderers must have a unique id. They must implement render, onReferenceChanged, onAdd, and onRemove. They can trigger rendering using Viewer.triggerRerender.

The viewer uses a metric topocentric local east, north, up coordinate system.

Custom renderers can calculate the topocentric positions of their objects using the reference parameter of the renderer interface methods and the geodeticToEnu method.

During a render pass, custom renderers are called in the order they were added.

Properties#

id#

• id: string

A unique renderer id.

Defined in#

viewer/interfaces/ICustomRenderer.ts:34


renderPass#

• renderPass: Opaque

The custom renderer's render pass.

description The ICustomRenderer.render method will be called during this render pass.

Defined in#

viewer/interfaces/ICustomRenderer.ts:42

Methods#

onAdd#

â–¸ onAdd(viewer, reference, context): void

Method called when the renderer has been added to the viewer. This gives the renderer a chance to initialize gl resources and register event listeners.

description Custom renderers are added with the with Viewer.addCustomRenderer method.

Calculate the topocentric positions for scene objects using the provided reference and the geodeticToEnu function.

Parameters#

NameTypeDescription
viewerIViewerThe viewer this custom renderer was just added to.
referenceLngLatAltThe viewer's current reference position.
contextWebGLRenderingContext | WebGL2RenderingContext- The viewer's gl context.

Returns#

void

Defined in#

viewer/interfaces/ICustomRenderer.ts:64


onReference#

â–¸ onReference(viewer, reference): void

Method called when the viewer's reference position has changed. This gives the renderer a chance to reposition its scene objects.

description Calculate the updated topocentric positions for scene objects using the provided reference and the geodeticToEnu function.

Parameters#

NameTypeDescription
viewerIViewerThe viewer this custom renderer is added to.
referenceLngLatAltThe viewer's current reference position.

Returns#

void

Defined in#

viewer/interfaces/ICustomRenderer.ts:82


onRemove#

â–¸ onRemove(viewer, context): void

Method called when the renderer has been removed from the viewer. This gives the renderer a chance to clean up gl resources and event listeners.

description Custom renderers are remove with the Viewer.removeCustomRenderer method.

Parameters#

NameTypeDescription
viewerIViewerThe viewer this custom renderer was just removed from.
contextWebGLRenderingContext | WebGL2RenderingContext- The viewer's gl context.

Returns#

void

Defined in#

viewer/interfaces/ICustomRenderer.ts:100


render#

â–¸ render(context, viewMatrix, projectionMatrix): void

Called during an animation frame allowing the renderer to draw into the GL context. The layer cannot make assumptions about the current GL state.

description Take a look at the WebGL model view projection article on MDN for an introduction to the view and projection matrices.

Parameters#

NameTypeDescription
contextWebGLRenderingContext | WebGL2RenderingContextThe viewer's WebGL context.
viewMatrixnumber[]The viewer's view matrix.
projectionMatrixnumber[]The viewers's projection matrix.

Returns#

void

Defined in#

viewer/interfaces/ICustomRenderer.ts:119