WebGL renderer backing a Viewer.

WebGLRenderer owns and manages the WebGL rendering pipeline for a Viewer. It is responsible for:

  • Attaching to and detaching from a Viewer
  • Initializing and tearing down internal rendering state when a Scene is present
  • Responding to Viewer and Scene events by updating GPU-resident data
  • Exposing capabilities and GPU memory inspection APIs for diagnostics and tooling

See @xeokit/webglrenderer for usage.

Constructors

Properties

_viewManager: ViewManager

Manages views and their rendering lifecycle - only exists when a Viewer with a Scene is attached to the renderer.

The ViewManager core is a central part of the renderer’s internal state, managing views, batches, and GPU resources. It only exists while a Viewer with an attached Scene is present.

This API is exposed on the renderer for internal developer docs and debugging/telemetry only and is not covered by semantic versioning. It may change or be removed at any time.

events: WebGLRendererEvents = ...

Events emitted by this renderer.

These events describe lifecycle transitions (Viewer attachment, rendering start/stop), WebGL context issues, and error reporting.

logging: boolean = true

Enables or disables logging of errors to the console.

Accessors

  • get debugging(): boolean

    Indicates whether debugging features are enabled.

    When true, the renderer and its components may emit additional events and perform extra checks to facilitate debugging and diagnostics. This may incur performance overhead, so it should be disabled in production.

    Returns boolean

  • set debugging(value: boolean): void

    Enables or disables debugging features.

    When true, the renderer and its components may emit additional events and perform extra checks to facilitate debugging and diagnostics.

    Parameters

    • value: boolean

    Returns void

  • get rendering(): boolean

    Indicates whether the renderer is actively rendering.

    Rendering is considered active when a Viewer with an attached Scene is present and the renderer’s internal rendering state has been initialized.

    Returns boolean

Methods

  • Attaches a Viewer to this renderer.

    If the Viewer already has an active Scene, the renderer immediately initializes its internal rendering state and begins rendering. Otherwise, rendering begins once a Scene is attached to the Viewer.

    Parameters

    • viewer: Viewer

      Viewer to attach.

    Returns SDKResult<void>

    Success or failure. Attaching while another Viewer is already attached is an error.

  • Destroys this renderer instance.

    Detaches any attached Viewer, releases internal resources and subscriptions, and emits events.onRendererDestroyed. After this call, the instance should be considered unusable.

    Returns void

  • Retrieves the capabilities of the WebGLRenderer. Populates the provided Capabilities object with information about supported WebGL features, such as texture compression formats and WebGL2 support.

    Parameters

    • capabilities: Capabilities

      The object to populate with capability information.

    Returns void

  • Performs a GPU-accelerated pick operation in the specified View.

    This method queries the renderer to identify the ViewObject (and optionally the 3D surface position) at a given canvas coordinate or along a specified world-space ray. Picking is performed using the renderer's internal GPU resources and shaders.

    Parameters

    • view: View

      The View in which to perform the pick. Must belong to the currently attached Viewer.

    • pickParams: PickParams

      Parameters specifying the pick mode and target (canvas coordinates or world-space ray).

    Returns SDKResult<PickResult>

    An SDKResult containing the PickResult on success, or an error result on failure.

    • Returns an error if no Viewer with an attached Scene is present, or if the View does not belong to the attached Viewer.
    • The returned PickResult is a transient, renderer-owned instance. Its contents are valid only until the next pick operation. Do not modify or retain the result.