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 inviewer/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 inviewer/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.
#
ParametersName | Type | Description |
---|---|---|
viewer | IViewer | The viewer this custom renderer was just added to. |
reference | LngLatAlt | The viewer's current reference position. |
context | WebGLRenderingContext | WebGL2RenderingContext | - The viewer's gl context. |
#
Returnsvoid
#
Defined inviewer/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.
#
ParametersName | Type | Description |
---|---|---|
viewer | IViewer | The viewer this custom renderer is added to. |
reference | LngLatAlt | The viewer's current reference position. |
#
Returnsvoid
#
Defined inviewer/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.
#
ParametersName | Type | Description |
---|---|---|
viewer | IViewer | The viewer this custom renderer was just removed from. |
context | WebGLRenderingContext | WebGL2RenderingContext | - The viewer's gl context. |
#
Returnsvoid
#
Defined inviewer/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.
#
ParametersName | Type | Description |
---|---|---|
context | WebGLRenderingContext | WebGL2RenderingContext | The viewer's WebGL context. |
viewMatrix | number [] | The viewer's view matrix. |
projectionMatrix | number [] | The viewers's projection matrix. |
#
Returnsvoid