Class
DeviceCapabilities
View sourceGroups browser capability flags used by a Device resource.
A new instance starts with webgpu, webgl, and webAudio set to false.
Its canvas flag is initialized from window.CanvasRenderingContext2D.
DevicePlugin refreshes the canvas, webgl, and webgpu flags
from the current browser environment; webAudio remains application-managed.
Examples
import { Device } from '@wimaengine/device'
const device = new Device()
if (device.capabilities.webgpu) {
console.log('Use the WebGPU renderer')
}Constructor
Properties
webgpu: boolean
View sourceWhether the browser exposes WebGPU support. Defaults to false until
DevicePlugin checks the current browser environment.
Default: false
webgl: boolean
View sourceWhether the browser exposes WebGL support. Defaults to false until
DevicePlugin checks the current browser environment.
Default: false
canvas: boolean
View sourceWhether the browser exposes 2D canvas support.
Initialized from window.CanvasRenderingContext2D. DevicePlugin
refreshes this flag when it populates the Device resource.
Default: !!window.CanvasRenderingContext2D
webAudio: boolean
View sourceWhether the browser exposes WebAudio support.
This flag defaults to false and is not populated by
DevicePlugin. Application code may set it before serialization.
Default: false
Methods
staticserialize(value: DeviceCapabilities): DeviceCapabilitiesSerial
View sourceConverts capability flags to plain serializable data.
The result contains webgpu, webgl, canvas, and webAudio fields. The
source instance is not changed, and the values are copied as-is.
staticdeserialize(value: DeviceCapabilitiesSerial, out?: DeviceCapabilities): DeviceCapabilities
View sourceRestores capability flags from plain serializable data.
If out is supplied, its object identity is preserved and all four
fields are overwritten. Otherwise, a new DeviceCapabilities is returned.
The input is expected to contain the four capability fields; this method
performs no validation or coercion.
