API

Interface EngineOptions

Options for createEngine. Per-surface options for the primary surface (the canvas passed to createEngine) come from SurfaceOptions and are passed alongside the engine options as a single union: createEngine(canvas, opts: EngineOptions & SurfaceOptions).

interface EngineOptions {
    alphaMode?: GPUCanvasAlphaMode;
    format?: GPUTextureFormat;
    maxDevicePixelRatio?: number;
    msaaSamples?: 1 | 4;
    requiredLimits?: Record<string, number | undefined>;
    srgb?: boolean;
    useFloatingOrigin?: boolean;
    useHighPrecisionMatrix?: boolean;
}

Hierarchy (View Summary)

Index
alphaMode?: GPUCanvasAlphaMode

WebGPU canvas alpha mode. Use "premultiplied" to enable canvas transparency (clear color with alpha < 1 will let HTML content underneath show through). Defaults to "opaque".

format?: GPUTextureFormat

Override the swapchain format. Defaults to navigator.gpu.getPreferredCanvasFormat(). Must be a format accepted by GPUCanvasContext.configure() (i.e. not a *-srgb format — use srgb for that).

maxDevicePixelRatio?: number

Clamps the effective device pixel ratio used for the swapchain backing store. Defaults to unclamped (full devicePixelRatio).

msaaSamples?: 1 | 4

MSAA sample count for the main render pass. WebGPU only permits 1 (no MSAA) or 4 (4x MSAA). Defaults to 4.

requiredLimits?: Record<string, number | undefined>

Extra WebGPU device limits to request when calling adapter.requestDevice(). Use to raise per-device caps such as maxColorAttachmentBytesPerSample (default 32), which is required when rendering into many MRT attachments. Caller is responsible for staying within the adapter's reported limits.

srgb?: boolean

Render the swapchain through an sRGB view so the GPU applies linear→sRGB encoding on store (and decodes sRGB→linear when sampling sRGB textures), making alpha blending — e.g. text/sprite anti-aliasing — gamma-correct. The canvas is configured with the base format plus viewFormats: [<format>-srgb], and pipelines target the *-srgb view. Color fed to renderers should be linear (e.g. via packedSrgbToLinearRgba), and color textures sampled for blending should use an sRGB format. Defaults to false.

useFloatingOrigin?: boolean

Enable floating-origin (Large World Rendering) for every scene on this engine. Requires useHighPrecisionMatrix: true — throws synchronously if set without it. Defaults to false.

When true, createEngine dynamically imports the LWR runtime (large-world/floating-origin.js) so engines without LWR never pull the module into their bundle (tree-shaken via the dynamic-import gate, same pattern as the F64 storage module).

useHighPrecisionMatrix?: boolean

Enable Float64 intermediate precision for world matrix computations. Defaults to false.