Class BoundingBoxRenderer
Implements
Index
Constructors
constructor
-
Instantiates a new bounding box renderer in a scene.
Parameters
- scene: Scene
the scene the renderer renders in
Returns BoundingBoxRenderer
- scene: Scene
Properties
back Color
Color of the bounding box lines placed behind an object
enabled
When false, no bounding boxes will be rendered
front Color
Color of the bounding box lines placed in front of an object
Readonlyname
The component name helpful to identify the component in the list of scene components.
on After Box Rendering Observable
Observable raised after rendering a bounding box When BoundingBoxRenderer.useInstances enabled, this would only be triggered once for one rendering, instead of once every bounding box. Events would be triggered with a dummy box to keep backwards compatibility, the passed bounding box has no meaning and should be ignored.
on Before Box Rendering Observable
Observable raised before rendering a bounding box When BoundingBoxRenderer.useInstances enabled, this would only be triggered once for one rendering, instead of once every bounding box. Events would be triggered with a dummy box to keep backwards compatibility, the passed bounding box has no meaning and should be ignored.
on Resources Ready Observable
Observable raised after resources are created
scene
The scene the component belongs to.
show Back Lines
Defines if the renderer should show the back lines or not
Accessors
shader Language
-
get shaderLanguage(): ShaderLanguage
Gets the shader language used in this renderer.
Returns ShaderLanguage
use Instances
-
get useInstances(): boolean
Returns boolean
-
set useInstances(val: boolean): void
Sets whether to use instanced rendering. When not enabled, BoundingBoxRenderer renders in a loop, calling engine.drawElementsType for each bounding box in renderList, making every bounding box 1 or 2 draw call. When enabled, it collects bounding boxes to render, and render all boxes in 1 or 2 draw call. This could make the rendering with many bounding boxes much faster than not enabled, but could result in a difference in rendering result if BoundingBoxRenderer.showBackLines enabled, because drawing the black/white part of each box one after the other can be different from drawing the black part of all boxes and then the white part. Also, when enabled, events of BoundingBoxRenderer.onBeforeBoxRenderingObservable and BoundingBoxRenderer.onAfterBoxRenderingObservable would only be triggered once for one rendering, instead of once every bounding box. Events would be triggered with a dummy box to keep backwards compatibility, the passed bounding box has no meaning and should be ignored.
Parameters
- val: boolean
whether to use instanced rendering
Returns void
- val: boolean
Methods
dispose
-
Dispose and release the resources attached to this renderer.
Returns void
rebuild
-
Rebuilds the elements related to this component in case of context lost for instance.
Returns void
register
-
Registers the component in a given scene
Returns void
render
-
Render the bounding boxes of a specific rendering group
Parameters
- renderingGroupId: number
defines the rendering group to render
Returns void
- renderingGroupId: number
render Occlusion Bounding Box
-
In case of occlusion queries, we can render the occlusion bounding box through this method
Parameters
- mesh: AbstractMesh
Define the mesh to render the occlusion bounding box for
Returns void
- mesh: AbstractMesh
when Ready Async
-
Checks if the renderer is ready asynchronously.
Parameters
- timeStep: number = 16
Time step in ms between retries (default is 16)
- maxTimeout: number = 30000
Maximum time in ms to wait for the graph to be ready (default is 30000)
Returns Promise<void>
The promise that resolves when the renderer is ready
- timeStep: number = 16
Component responsible of rendering the bounding box of the meshes in a scene. This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties