Class
Device
View sourceDescribes the detected platform, browser, and rendering capabilities for an application.
Install DevicePlugin to add this world resource to an application.
It fills the DeviceCapabilities flags and detects values from
PlatformOS and Browser so application code can choose
compatible behavior for the current environment. A new instance starts
with PlatformOS.Unknown and Browser.Unknown.
webAudio remains false until application code changes it.
Examples
import { Device } from '@wimaengine/device'
// With DevicePlugin installed, read the resource from a world.
function chooseRenderer(world) {
const device = world.getResource(Device)
if (device.capabilities.webgpu) return 'webgpu'
if (device.capabilities.webgl) return 'webgl'
return device.capabilities.canvas ? 'canvas' : 'none'
}Constructor
Properties
capabilities: DeviceCapabilities
View sourceCapability flags for the current device and browser.
Default: ...
platform: number
View sourceDetected operating system or platform.
The value starts as PlatformOS.Unknown and remains unknown when
no supported platform is detected.
Default: PlatformOS.Unknown
browser: number
View sourceBrowser detected for the current application environment.
The value starts as Browser.Unknown and remains unknown when no
supported browser is detected.
Default: Browser.Unknown
Methods
isMobile(): boolean
View sourceReports whether the detected platform is mobile.
isPc(): boolean
View sourceReports whether the detected platform is a PC platform.
staticserialize(value: Device): DeviceSerial
View sourceConverts a device resource to a plain object.
The result contains capabilities, platform, and browser fields.
staticdeserialize(value: DeviceSerial, out?: Device): Device
View sourceRestores a device from a plain object.
When out is supplied, it is populated and returned. Its existing
DeviceCapabilities object is reused, and its platform and
browser values are replaced. Otherwise, a new Device is created.
