RendererMainSettings: RendererRuntimeSettings & {
    canvas: HTMLCanvasElement;
    createImageBitmapSupport:
        | "auto"
        | "basic"
        | "options"
        | "full";
    enableContextSpy: boolean;
    fontEngines: (typeof SdfTextRenderer | typeof CanvasTextRenderer)[];
    forceWebGL2: boolean;
    numImageWorkers: number;
    platform: typeof Platform | null;
    quadBufferSize: number;
    renderEngine: typeof CanvasRenderer | typeof WebGlCoreRenderer;
    strictBounds: boolean;
}

Configuration settings for RendererMain

Type declaration

  • canvas: HTMLCanvasElement

    Canvas object to use for rendering

    This is used to render the scene graph. If not provided, a new canvas element will be created and appended to the target element.

  • createImageBitmapSupport:
        | "auto"
        | "basic"
        | "options"
        | "full"

    createImageBitmap support for the runtime

    This is used to determine if and which version of the createImageBitmap API is supported by the runtime. This is used to determine if the renderer can use createImageBitmap to load images.

    Options supported

    • Auto - Automatically determine the supported version
    • Basic - Supports createImageBitmap(image)
    • Options - Supports createImageBitmap(image, options)
    • Full - Supports createImageBitmap(image, sx, sy, sw, sh, options)

    Note with auto detection, the renderer will attempt to use the most advanced version of the API available. If the API is not available, the renderer will fall back to the next available version.

    This will affect startup performance as the renderer will need to determine the supported version of the API.

    full

  • enableContextSpy: boolean

    Include context call (i.e. WebGL) information in FPS updates

    When enabled the number of calls to each context method over the fpsUpdateInterval will be included in the FPS update payload's contextSpyData property.

    Enabling the context spy has a serious impact on performance so only use it when you need to extract context call information.

    false (disabled)

  • fontEngines: (typeof SdfTextRenderer | typeof CanvasTextRenderer)[]

    Font Engines

    The font engines to use for text rendering. CanvasTextRenderer is supported on all platforms. SdfTextRenderer is a more performant renderer. When using renderEngine=CanvasCoreRenderer you can only use CanvasTextRenderer. The renderEngine=WebGLCoreRenderer supports both CanvasTextRenderer and SdfTextRenderer.

    This setting is used to enable tree shaking of unused font engines. Please import your font engine(s) as follows:

    import { CanvasTextRenderer } from '@lightning/renderer/canvas';
    import { SdfTextRenderer } from '@lightning/renderer/webgl';

    If both CanvasTextRenderer and SdfTextRenderer are provided, the first renderer provided will be asked first if it can render the font. If it cannot render the font, the next renderer will be asked. If no renderer can render the font, the text will not be rendered.

    Note that if you have fonts available in both engines the second font engine will not be used. This is because the first font engine will always be asked first.

    '[]'
    
  • forceWebGL2: boolean

    Force WebGL2

    Force the renderer to use WebGL2. This can be used to force the renderer to use WebGL2 even if the browser supports WebGL1.

    false

  • numImageWorkers: number

    Number or Image Workers to use

    On devices with multiple cores, this can be used to improve image loading as well as reduce the impact of image loading on the main thread. Set to 0 to disable image workers.

    2

  • platform: typeof Platform | null

    Provide an alternative platform abstraction layer

    By default the Lightning 3 renderer will load a webplatform, assuming it runs inside a web browsr. However for special cases there might be a need to provide an abstracted platform layer to run on non-web or non-standard JS engines

    null

  • quadBufferSize: number

    Quad buffer size in bytes

    4 * 1024 * 1024
    
  • renderEngine: typeof CanvasRenderer | typeof WebGlCoreRenderer

    Renderer Engine

    The renderer engine to use. Spawns a WebGL or Canvas renderer. WebGL is more performant and supports more features. Canvas is supported on most platforms.

    Note: When using CanvasCoreRenderer you can only use CanvasTextRenderer. The WebGLCoreRenderer supports both CanvasTextRenderer and SdfTextRenderer for Text Rendering.

  • strictBounds: boolean

    Enable strictBounds

    Enable strict bounds for the renderer. This will ensure that the renderer will not render outside the bounds of the canvas.

    true