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

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.

  • Internal

    Diagnostic: read back every mip × face of the GGX-prefiltered IBL cubemap for the given view and tile them onto an HTMLCanvasElement for visual inspection. Returns null when IBL hasn't been initialised for the view, or when the prefilter pipeline isn't allocated.

    Used to localise IBL artifacts to a specific mip without guessing. Call from the browser console:

    const c = studio.renderer.debugDumpPrefilteredCubemap(0);
    document.body.appendChild(c);

    Parameters

    • viewIndex: number = 0

    Returns HTMLCanvasElement

  • 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

  • Internal

    Enables (or disables) opt-in step-level timing inside the renderer's MeshManager, which fires synchronously on every SceneModel.createMesh call. Use to attribute time across the substeps (getMeshBatch, batchAddMesh, rendererMeshCtor) during a workload like a model load. Off by default so the hot path takes no performance.now() hit in normal use.

    Read the recorded numbers with getMeshManagerStepStats.

    Parameters

    • enabled: boolean

    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

  • Returns submitted-geometry stats for a View's most recently completed frame: the total number of draw calls and primitives issued across all render passes (color, shadow cascades, SAO, …).

    numPrimitives is summed from the per-view packed draw ranges, so it reflects visibility and culling — culled meshes drop out of the count. It's the metric to watch to confirm culling is reducing GPU work, since it moves even while the display caps the frame rate. numDrawCalls, by contrast, barely changes with culling: this renderer draws a whole batch per call, so culling trims primitives within a draw rather than removing draws.

    Returns null when no Viewer is attached or the render inspector has not recorded a frame for this view yet. The inspector is enabled by Studio; in a bare WebGLRenderer setup, enable it first via getRenderInspector.

    Parameters

    Returns { numDrawCalls: number; numPrimitives: number }