API

Interface EngineOptions

Interface defining initialization parameters for Engine class

interface EngineOptions {
    adaptToDeviceRatio?: boolean;
    antialias?: boolean;
    audioEngine?: boolean;
    audioEngineOptions?: IAudioEngineOptions;
    canvasTabIndex?: number;
    deterministicLockstep?: boolean;
    disableWebGL2Support?: boolean;
    doNotHandleContextLost?: boolean;
    doNotHandleTouchAction?: boolean;
    failIfMajorPerformanceCaveat?: boolean;
    forceSRGBBufferSupportState?: boolean;
    limitDeviceRatio?: number;
    lockstepMaxSteps?: number;
    loseContextOnDispose?: boolean;
    premultipliedAlpha?: boolean;
    stencil?: boolean;
    timeStep?: number;
    useExactSrgbConversions?: boolean;
    useHighPrecisionFloats?: boolean;
    useHighPrecisionMatrix?: boolean;
    useLargeWorldRendering?: boolean;
    xrCompatible?: boolean;
}

Hierarchy (View Summary)

Index
adaptToDeviceRatio?: boolean

Defines whether to adapt to the device's viewport characteristics (default: false)

antialias?: boolean

Defines whether MSAA is enabled on the canvas.

audioEngine?: boolean

Defines if webaudio should be initialized as well

audioEngineOptions?: IAudioEngineOptions

Specifies options for the audio engine

canvasTabIndex?: number

Defines the tab index to set on the rendering canvas (default: 1). Any value >= 0 makes the canvas focusable so it can capture keyboard events and places it in the document's sequential tab order (0 follows DOM order, a positive value forces an explicit order). Use -1 to keep the canvas focusable programmatically (via focus()) while excluding it from the tab order.

deterministicLockstep?: boolean

Defines if animations should run using a deterministic lock step

disableWebGL2Support?: boolean

Defines if webgl2 should be turned off even if supported

doNotHandleContextLost?: boolean

Defines that engine should ignore context lost events If this event happens when this parameter is true, you will have to reload the page to restore rendering

doNotHandleTouchAction?: boolean

Defines that engine should ignore modifying touch action attribute and style If not handle, you might need to set it up on your side for expected touch devices behavior.

failIfMajorPerformanceCaveat?: boolean

Will prevent the system from falling back to software implementation if a hardware device cannot be created

forceSRGBBufferSupportState?: boolean

If sRGB buffer support is not set during construction, use this value to force a specific state This was originally added to mitigate an issue when processing textures in chrome/edge/firefox. The browser issue has since been fixed. This option remains for backward compatibility. This will not influence NativeEngine and WebGPUEngine which set the behavior to true during construction.

limitDeviceRatio?: number

Defines if the engine should no exceed a specified device ratio

lockstepMaxSteps?: number

Defines the maximum steps to use with deterministic lock step mode

loseContextOnDispose?: boolean

Defines if the gl context should be released. It's false by default for backward compatibility, but you should probably pass true (see https://registry.khronos.org/webgl/extensions/WEBGL_lose_context/)

premultipliedAlpha?: boolean

Defines whether the canvas should be created in "premultiplied" mode (if false, the canvas is created in the "opaque" mode) (true by default)

stencil?: boolean

Defines whether the stencil buffer should be enabled.

timeStep?: number

Defines the seconds between each deterministic lock step

useExactSrgbConversions?: boolean

True if the more expensive but exact conversions should be used for transforming colors to and from linear space within shaders. Otherwise, the default is to use a cheaper approximation.

useHighPrecisionFloats?: boolean

Defines that engine should compile shaders with high precision floats (if supported). True by default

useHighPrecisionMatrix?: boolean

Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default. Note that setting useLargeWorldRendering will also set high precision matrices

useLargeWorldRendering?: boolean

LargeWorldRendering helps avoid floating point imprecision of rendering large worlds by

  1. Forcing highPrecisionMatrices (matrix computations in 64 bits instead of 32)
  2. Enabling floatingOriginMode in all scenes -- offsetting position-related uniform and attribute values before passing to shader so that active camera is centered at origin and world is offset by active camera position

NOTE that if this mode is set during engineCreation, all scenes will have floatingOrigin offset and you do not need to send floatingOriginMode option to each scene creation. If you'd like to have only specific scenes using the offset logic, you can set the flag on those scenes directly -- however, to achieve proper large world rendering, you must also set the useHighPrecisionMatrix option on engine.

xrCompatible?: boolean

Make the canvas XR Compatible for XR sessions