API

Class ObjectRenderer

A class that renders objects to the currently bound render target. This class only renders objects, and is not concerned with the output texture or post-processing.

Index
activeCamera: Nullable<Camera>

Define the camera used to render the objects.

cameraForLOD: Nullable<Camera>

Define the camera used to calculate the LOD of the objects. If not defined, activeCamera will be used. If not defined nor activeCamera, scene's active camera will be used.

customIsReadyFunction: (
    mesh: AbstractMesh,
    refreshRate: number,
    preWarm?: boolean,
) => boolean

Override the mesh isReady function with your own one.

customRenderFunction: (
    opaqueSubMeshes: SmartArray<SubMesh>,
    alphaTestSubMeshes: SmartArray<SubMesh>,
    transparentSubMeshes: SmartArray<SubMesh>,
    depthOnlySubMeshes: SmartArray<SubMesh>,
    beforeTransparents?: () => void,
) => void

Override the render function with your own one.

customRenderTransparentSubMeshes?: (
    transparentSubMeshes: SmartArray<SubMesh>,
) => void

Custom render function for transparent submeshes.

dontSetTransformationMatrix: boolean = false

If true, the object renderer will not set the view/projection/transformation matrices for the active camera (default: false). By default, the view/projection/transformation matrices are set from the active camera (either ObjectRenderer.activeCamera or scene.activeCamera). Sets this property to true if you want to define your own transformation matrices (use the onInitRenderingObservable observable to set your own matrices, to be sure they will be correctly taken into account)

enableBoundingBoxRendering: boolean = false

Enables the rendering of bounding boxes for meshes (still subject to Mesh.showBoundingBox or scene.forceShowBoundingBoxes). Default is false.

enableOutlineRendering: boolean = true

Enables the rendering of outline/overlay for meshes (still subject to Mesh.renderOutline/Mesh.renderOverlay). Default is true.

forceLayerMaskCheck: boolean = false

Force checking the layerMask property even if a custom list of meshes is provided (ie. if renderList is not undefined)

getCustomRenderList: Nullable<
    (
        layerOrFace: number,
        renderList: Nullable<Immutable<AbstractMesh[]>>,
        renderListLength: number,
    ) => Nullable<AbstractMesh[]>,
> = null

Use this function to overload the renderList array at rendering time. Return null to render with the current renderList, else return the list of meshes to use for rendering. For 2DArray, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of the cube (if the RTT is a cube, else layerOrFace=0). The renderList passed to the function is the current render list (the one that will be used if the function returns null). The length of this list is passed through renderListLength: don't use renderList.length directly because the array can hold dummy elements!

onAfterRenderingManagerRenderObservable: Observable<number> = ...

An event triggered after the rendering group is processed

onAfterRenderObservable: Observable<number> = ...

An event triggered after rendering the objects. Note: This observable is also triggered during readiness checks (e.g. when calling scene.isReady()), in which case the render target is not bound to the output. Observers should avoid performing GPU state changes (such as clearing or modifying the framebuffer) unless the render target is actually bound.

onBeforeRenderingManagerRenderObservable: Observable<number> = ...

An event triggered before the rendering group is processed

onBeforeRenderObservable: Observable<number> = ...

An event triggered before rendering the objects. Note: This observable is also triggered during readiness checks (e.g. when calling scene.isReady()), in which case the render target is not bound to the output. Observers should avoid performing GPU state changes (such as clearing or modifying the framebuffer) unless the render target is actually bound.

onFastPathRenderObservable: Observable<number> = ...

An event triggered when fast path rendering is used

onFinishRenderingObservable: Observable<ObjectRenderer> = ...

An event triggered when finishRender is called

onInitRenderingObservable: Observable<ObjectRenderer> = ...

An event triggered when initRender is called

options: Required<ObjectRendererOptions>

The options used by the object renderer

particleSystemList: Nullable<IParticleSystem[]> = null

Define the list of particle systems to render. If not provided, will render all the particle systems of the scene. Note that the particle systems are rendered only if renderParticles is set to true.

renderAlphaTestMeshes: boolean = true

Define if alpha test meshes should be rendered (default is true). No effect if renderMeshes is false.

renderDepthOnlyMeshes: boolean = true

Define if depth only meshes should be rendered (default is true). No effect if renderMeshes is false.

renderListPredicate: (AbstractMesh: AbstractMesh) => boolean

Use this predicate to dynamically define the list of mesh you want to render. If set, the renderList property will be overwritten.

renderMeshes: boolean = true

Define if meshes should be rendered (default is true).

renderOpaqueMeshes: boolean = true

Define if opaque meshes should be rendered (default is true). No effect if renderMeshes is false.

renderParticles: boolean = true

Define if particles should be rendered (default is true).

renderPassId: number

Current render pass id. Note it can change over the rendering as there's a separate id for each face of a cube / each layer of an array layer!

renderSprites: boolean = false

Define if sprites should be rendered (default is false).

renderTransparentMeshes: boolean = true

Define if transparent meshes should be rendered (default is true). No effect if renderMeshes is false.

spriteManagerList: Nullable<ISpriteManager[]> = null

Define the list of sprite managers to render. If not provided, will render all the sprite managers of the scene. An empty array will render no sprite managers. Note that the sprite managers are rendered only if renderSprites is set to true.

REFRESHRATE_RENDER_ONCE: number = 0

Objects will only be rendered once which can be useful to improve performance if everything in your render is static for instance.

REFRESHRATE_RENDER_ONEVERYFRAME: number = 1

Objects will be rendered every frame and is recommended for dynamic contents.

REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number = 2

Objects will be rendered every 2 frames which could be enough if your dynamic objects are not the central point of your effect and can save a lot of performances.

  • This method makes sure everything is setup before "render" can be called

    Parameters

    • viewportWidth: number

      Width of the viewport to render to

    • viewportHeight: number

      Height of the viewport to render to

    Returns void

  • This function will check if the renderer is ready to render (textures are loaded, shaders are compiled)

    Parameters

    • viewportWidth: number

      defines the width of the viewport

    • viewportHeight: number

      defines the height of the viewport

    Returns boolean

    true if all required resources are ready

  • Makes sure the list of meshes is ready to be rendered You should call this function before "initRender", but if you know the render list is ok, you may call "initRender" directly

    Returns void

  • Renders all the objects (meshes, particles systems, sprites) to the currently bound render target texture.

    Parameters

    • passIndex: number = 0

      defines the pass index to use (default: 0)

    • skipOnAfterRenderObservable: boolean = false

      defines a flag to skip raising the onAfterRenderObservable

    Returns void

  • Sets a specific material to be used to render a mesh/a list of meshes with this object renderer

    Parameters

    • mesh: any

      mesh or array of meshes

    • Optionalmaterial: any

      material or array of materials to use for this render pass. If undefined is passed, no specific material will be used but the regular material instead (mesh.material). It's possible to provide an array of materials to use a different material for each rendering pass.

    Returns void

  • Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.

    Parameters

    • renderingGroupId: number

      The rendering group id corresponding to its index

    • autoClearDepthStencil: boolean

      Automatically clears depth and stencil between groups if true.

    • depth: boolean = true

      Automatically clears depth between groups if true and autoClear is true.

    • stencil: boolean = true

      Automatically clears stencil between groups if true and autoClear is true.

    Returns void

  • Overrides the default sort function applied in the rendering group to prepare the meshes. This allowed control for front to back rendering or reversely depending of the special needs.

    Parameters

    • renderingGroupId: number

      The rendering group id corresponding to its index

    • opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number> = null

      The opaque queue comparison function use to sort.

    • alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number> = null

      The alpha test queue comparison function use to sort.

    • transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number> = null

      The transparent queue comparison function use to sort.

    Returns void

  • Indicates if the renderer should render the current frame. The output is based on the specified refresh rate. When snapshot rendering is active, this always returns true to ensure render pass topology stays consistent between the recording frame and playback frames.

    Returns boolean

    true if the renderer should render the current frame