API

Class BoundingBoxRenderer

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

Implements

Index
backColor: Color3 = ...

Color of the bounding box lines placed behind an object

enabled: boolean = true

When false, no bounding boxes will be rendered

frontColor: Color3 = ...

Color of the bounding box lines placed in front of an object

name: "BoundingBoxRenderer" = SceneComponentConstants.NAME_BOUNDINGBOXRENDERER

The component name helpful to identify the component in the list of scene components.

onAfterBoxRenderingObservable: Observable<BoundingBox> = ...

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.

onBeforeBoxRenderingObservable: Observable<BoundingBox> = ...

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.

onResourcesReadyObservable: Observable<BoundingBoxRenderer> = ...

Observable raised after resources are created

scene: Scene

The scene the component belongs to.

showBackLines: boolean = true

Defines if the renderer should show the back lines or not

  • get useInstances(): 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

  • 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