Defines the contract for the rendering strategy used internally within a Viewer.

A Viewer uses an implementation of this internally to allocate and render geometry and materials using an available browser 3D graphics API, such as WebGL or WebGPU.

Usage

import {Viewer} from "@xeokit/viewer";

const myViewer = new Viewer({
id: "myViewer",
renderers: new WebGLRenderer({ }) // Or WebGPURenderer, MockRenderer etc.
});
interface Renderer {
    rendererObjects: {
        [key: string]: RendererObject;
    };
    get viewer(): Viewer;
    attachSceneModel(sceneModel): void | SDKError;
    attachView(view): void | SDKError;
    attachViewer(viewer): void | SDKError;
    beginSnapshot(viewIndex, params?): any;
    clear(viewIndex): void | SDKError;
    detachSceneModel(sceneModel): void | SDKError;
    detachView(view): void | SDKError;
    detachViewer(): void | SDKError;
    endSnapshot(): any;
    getCapabilities(capabilities): void;
    getNeedsRender(viewIndex): boolean | SDKError;
    getSAOSupported(): boolean;
    pick(viewIndex, pickParams, pickResult?): PickResult;
    readSnapshot(params): string;
    readSnapshotAsCanvas(params): HTMLCanvasElement;
    render(viewIndex, params): void | SDKError;
    renderSnapshot(): any;
    setEdgesEnabled(viewIndex, enabled): void | SDKError;
    setImageDirty(viewIndex?): void | SDKError;
    setNeedsRebuild(viewIndex): void | SDKError;
    setPBREnabled(viewIndex, enabled): void | SDKError;
    setSAOEnabled(viewIndex, enabled): void | SDKError;
    setTransparentEnabled(viewIndex, enabled): void | SDKError;
}

Properties

rendererObjects: {
    [key: string]: RendererObject;
}

Interfaces through which each ViewObject shows/hides/highlights/selects/xrays/colorizes its SceneObject within the Renderer that's configured on its Viewer.

Type declaration

  • [key: string]: RendererObject

Accessors

Methods

  • Internal

    Initializes this Renderer by attaching a Viewer.

    Parameters

    • viewer: Viewer

      Viewer to attach.

    Returns void | SDKError

    void

    • Viewer successfully attached.
  • Enters snapshot mode for the given View.

    Parameters

    • viewIndex: number
    • Optional params: {
          height: number;
          width: number;
      }
      • height: number
      • width: number

    Returns any

  • Internal

    Clears the renderer for the given view.

    Parameters

    Returns void | SDKError

    void

    • Success.
  • Internal

    Detaches the given @xeokit/viewer!View from this Renderer.

    The Renderer will then cease rendering for that View.

    Parameters

    • view: View

      The View to detach.

    Returns void | SDKError

    void

    • View successfully detached.
  • Internal

    Detaches the Viewer that is currently attached, if any.

    Returns void | SDKError

    void

    • Viewer successfully detached.
  • Exits snapshot mode.

    Switches rendering back to the main canvas.

    Returns any

  • Internal

    Gets the capabilities of this Renderer.

    Parameters

    • capabilities: Capabilities

      Returns the capabilities of this WebGLRenderer.

    Returns void

  • Internal

    Gets if a new frame needs to be rendered for the given View.

    Parameters

    Returns boolean | SDKError

    boolean

    • True if a new frame needs to be rendered for the View.
  • Internal

    Gets whether this Renderer supports SAO.

    Returns boolean

  • Internal

    Picks a ViewerObject within a View.

    Parameters

    • viewIndex: number

      Handle to the View, returned earlier by Renderer.attachView.

    • pickParams: PickParams

      Picking parameters.

    • Optional pickResult: PickResult

      Picking results, when caller wants to manage them externally.

    Returns PickResult

    @xeokit/viewer!PickResult

    • Picking attempt completed.

    Throws

    SDKError

    • No View is currently attached to this Renderer.
    • Can't find a View attached to this Renderer with the given handle.
    • Illegal picking parameters given.
  • When in snapshot mode, gets an image of the snapshot canvas.

    Parameters

    • params: any

    Returns string

    The image data URI.

  • Returns an HTMLCanvas containing an image of the snapshot canvas.

    • The HTMLCanvas has a CanvasRenderingContext2D.
    • Expects the caller to draw more things on the HTMLCanvas (annotations etc).

    Parameters

    • params: any

    Returns HTMLCanvasElement

  • Internal

    Renders a frame for a View.

    Parameters

    • viewIndex: number

      Handle to the View, returned earlier by Renderer.attachView.

    • params: {
          force?: boolean;
      }

      Rendering params.

      • Optional force?: boolean

        True to force a render, else only render if needed.

    Returns void | SDKError

    SDKError

    • No View is currently attached to this Renderer.
    • Can't find a View attached to this Renderer with the given handle.
  • When in snapshot mode, renders a frame of the current Scene state to the snapshot canvas.

    Returns any

  • Internal

    Enable/disable edge enhancement for the given View.

    Parameters

    • viewIndex: number

      Handle to the View, returned earlier by Renderer.attachView.

    • enabled: boolean

      Whether to enable or disable edges for the View.

    Returns void | SDKError

    void

    • Success.
  • Internal

    Indicates that the renderers needs to render a new frame for the given View.

    Parameters

    Returns void | SDKError

    void

    • Success.
  • Internal

    Triggers a rebuild of the shaders within this Renderer for the given View.

    Parameters

    Returns void | SDKError

    void

    • Success.
  • Internal

    Enable/disable physically-based rendering (PBR) for the given View.

    Parameters

    • viewIndex: number

      Handle to the View, returned earlier by Renderer.attachView.

    • enabled: boolean

      Whether to enable or disable PBR for the View.

    Returns void | SDKError

    void

    • Success.
  • Internal

    Enable/disable scaleable ambient obscurrance SAO for the given View.

    Parameters

    • viewIndex: number

      Handle to the View, returned earlier by Renderer.attachView.

    • enabled: boolean

      Whether to enable or disable SAO for the View.

    Returns void | SDKError

    void

    • Success.
  • Internal

    Enable/disable rendering of transparent objects for the given View.

    Parameters

    • viewIndex: number

      Handle to the View, returned earlier by Renderer.attachView.

    • enabled: boolean

      Whether to enable or disable transparent objects for the View.

    Returns void | SDKError

    void

    • Success.