Options used to configure the Lightning Stage

See the Runtime Configuration for more information.

interface Options {
    autostart: boolean;
    bufferMemory: number;
    canvas: null | HTMLCanvasElement;
    canvas2d: boolean;
    clearColor: null | number | RGBA;
    context: null | CanvasRenderingContext2D | WebGLRenderingContext;
    debugFrame: boolean;
    defaultFontFace: string;
    devicePixelRatio: number;
    fixedDt: number;
    fontSharp: boolean | { fontSize: number; precision: number };
    forceTxCanvasSource: boolean;
    h: number;
    memoryPressure: number;
    pauseRafLoopOnIdle: boolean;
    platform: null | typeof WebPlatform;
    precision: number;
    readPixelsAfterDraw: boolean;
    readPixelsAfterDrawThreshold: number;
    readPixelsBeforeDraw: boolean;
    srcBasePath: null | string;
    textRenderIssueMargin: number;
    useImageWorker: boolean;
    w: number;
}

Properties

autostart: boolean

If set to false, no automatic binding to requestAnimationFrame

true

bufferMemory: number

Memory size of quad buffer (in bytes)

2e6

canvas: null | HTMLCanvasElement

If specified, an existing Canvas to be used for rendering by Lightning

null (create new canvas)

canvas2d: boolean

If set to true, the Lightning uses a canvas2d instead of WebGL for rendering.

See Runtime Config - Limitations of Canvas2D for information about the limitations of using Canvas2D.

false

clearColor: null | number | RGBA

Color to clear the Stage with before each frame

Value can be one of 3 types:

  • number representing an ARGB color (i.e. 0xfffefdfc)
  • RGBA color array tuple
  • null
    • Causes the stage buffer to not be cleared before each frame

[0, 0, 0, 0] (transparent)

context: null | CanvasRenderingContext2D | WebGLRenderingContext

If specified, an existing WebGL / Canvas2D context to be used

null (create a new context)

debugFrame: boolean

If set to true, logs debug information about each frame including how many render-to-texture elements were re-rendered.

This may impact performance and should not be turned on in production.

false

defaultFontFace: string

Default font family to use for text

See TextTexture.Settings.fontFace for how this value ends up being used.

The special CSS defined font family values of "serif" and "sans-serif" may be used as well.

'sans-serif'

devicePixelRatio: number

The Device Pixel Ratio (DPR) affects how touch events are registered and handled on a device, including the conversion of physical pixel coordinates to logical pixel coordinates and the adjustment of element size and layout based on the device's pixel density.

1

fixedDt: number

Use fixed time step per frame (in ms)

0 (use auto dt)

fontSharp: boolean | { fontSize: number; precision: number }

FontSharp settings

See Runtime Config - FontSharp for more information.

{precision:0.6666666667, fontSize: 24}

forceTxCanvasSource: boolean

If set to true, forces the Render Engine to use the canvasSource over getImageData for text

This helps with text generation on certain devices.

See PR #393 for more information about this option.

false

h: number

Height of the rendered Stage

1080

memoryPressure: number

Maximum GPU memory usage in pixels

See Runtime Config - GPU Memory Tweak for more information.

24e6

pauseRafLoopOnIdle: boolean

If set to true, will stop the Render Engine from calling RequestAnimationFrame when there are no stage updates.

See Issue #380 for more information about this option.

false

platform: null | typeof WebPlatform

Set an alternative platform class type

null (WebPlatform will be used)

precision: number

Global stage scaling

See Runtime Config - Downscaling for more information.

1

readPixelsAfterDraw: boolean

If set to true, forces the Render Engine to readPixels after drawing, turning the Render pipeline synchronous.

This option helps with flickering artifacts on certain devices.

Note: This will affect performance!

You may set readPixelsAfterDrawThreshold to control the number of render-to-texture element re-renders that trigger the syncronous pipeline.

See PR #393 for more information about this option.

false

readPixelsAfterDrawThreshold: number

If readPixelsAfterDraw is set to true, this is the number of render-to-texture element re-renders in a frame that will trigger the synchronous Render pipeline.

This can enable full performance on frames that would not normally suffer from the flickering artifacts exhibited on certain devices.

0

readPixelsBeforeDraw: boolean

If set to true, forces the Render Engine to readPixels before drawing, turning the Render pipeline synchronous.

This option helps with flickering artifacts on certain devices.

Note: This will affect performance!

false

srcBasePath: null | string

Base path used by the ImageTexture

null

textRenderIssueMargin: number

Number of additional pixels to add to the width of every text texture

WARNING: This can distort text.

0

useImageWorker: boolean

Use image web workers, if web works are supported on the platform, for fetching and processing images off-thread (web only)

true

w: number

Width of the rendered Stage

1920