The canvas element.
Graphics device options.
Optionalantialias?: booleanBoolean that indicates whether or not to perform anti-aliasing if possible. Defaults to true.
Optionaldepth?: booleanBoolean that indicates that the drawing buffer is requested to have a depth buffer of at least 16 bits. Defaults to true.
OptionaldeviceTypes?: string[]An array of DEVICETYPE_*** constants, defining the order in which the devices are attempted to get created. Defaults to an empty array. If the specified array does not contain DEVICETYPE_WEBGL2, it is internally added to its end. Typically, you'd only specify DEVICETYPE_WEBGPU, or leave it empty. Use DEVICETYPE_WEBGPU_BARE to create a WebGPU device without optional features and with default spec limits, useful for testing on constrained devices.
OptionaldisplayFormat?: stringThe display format of the canvas. Defaults to DISPLAYFORMAT_LDR. Can be:
OptionalglslangUrl?: stringThe URL to the glslang script. Required only if user-defined shaders or shader chunk overrides are specified in GLSL and need to be transpiled to WGSL for use with the DEVICETYPE_WEBGPU device type. This is not required if only the engine's built-in shaders are used, as those are provided directly in WGSL. Not used for DEVICETYPE_WEBGL2 device type creation.
OptionalpowerPreference?: "default" | "high-performance" | "low-power"A hint indicating what configuration of GPU would be selected. Possible values are:
Defaults to 'default'.
Optionalstencil?: booleanBoolean that indicates that the drawing buffer is requested to have a stencil buffer of at least 8 bits. Defaults to true.
OptionaltransientColor?: booleanBoolean that requests the multi-sampled (MSAA)
color attachment of the back-buffer to be allocated as a transient ("memoryless") attachment,
allowing tile-based GPUs to keep its contents in on-chip memory and avoid VRAM allocation.
WebGPU only, and only effective when anti-aliasing (MSAA) is enabled - it has no effect on
single-sampled color, which is always presented. Ignored on devices without transient attachment
support. Incompatible with a scene color grab pass (sceneColorMap): the attachment must be
cleared on load and discarded on store. Defaults to false.
OptionaltransientDepth?: booleanBoolean that requests the back-buffer depth
attachment to be allocated as a transient ("memoryless") attachment (see transientColor).
Applies to both single- and multi-sampled depth. WebGPU only; ignored on devices without
transient attachment support. Incompatible with a scene depth grab pass (sceneDepthMap), a
depth prepass, or any depth resolve, as the depth cannot be sampled or copied out. Defaults to
false.
OptionaltwgslUrl?: stringAn url to twgsl script, required if glslangUrl was specified.
OptionalxrCompatible?: booleanBoolean that hints to the user agent to use a
compatible graphics adapter for an immersive XR device. When omitted in a browser, defaults to
true if navigator.xr is present, otherwise false (see GraphicsDevice constructor).
Creates a graphics device.