Class
DevicePlugin
View sourceExtendsPlugin
Adds a browser-aware Device resource to an App.
Register this plugin when application code needs browser rendering
capabilities and detected PlatformOS and Browser values.
It populates the resource from the current browser environment and keeps it
available for application code to read. The WebAudio capability remains
available for application-managed state.
This plugin depends on CorePlugin and ReflectPlugin.
Register those plugins before this plugin as shown in the example.
Examples
import { App } from '@wimaengine/app'
import { CorePlugin } from '@wimaengine/core'
import { ReflectPlugin } from '@wimaengine/reflect'
import { Device, DevicePlugin } from '@wimaengine/device'
const app = new App()
app
.registerPlugin(new ReflectPlugin())
.registerPlugin(new CorePlugin())
.registerPlugin(new DevicePlugin())
.run()
// Read the resource from the app's world.
function chooseRenderer(world) {
const device = world.getResource(Device)
return device.capabilities.webgl ? 'webgl' : 'canvas'
}Constructor
Methods
register(app: App): void
View sourceAdds the Device resource and detects the browser capabilities,
platform, and browser used by the application.
requires(): TypeId[]
View sourceReturns the plugin IDs for the CorePlugin and
ReflectPlugin dependencies.
