WonderlandEngine
WonderlandEngine
Main Wonderland Engine instance.
Controls the canvas, rendering, and JS <-> WASM communication.
- WonderlandEngine
- .arSupported: boolean
- .i18n: I18N
- .onResize: Emitter<void[]>
- .onSceneLoaded: Emitter<void[]>
- .onXRSessionEnd: Emitter<void[]>
- .onXRSessionStart: Emitter<[XRSession, XRSessionMode]>
- .scene: Scene
- .vrSupported: boolean
- .xr: null | XR
- .autoResizeCanvas
- .autoResizeCanvas
- .canvas
- .physics
- .runtimeVersion
- .textures
.xrBaseLayer.xrFrame.xrFramebuffer- .xrFramebufferScaleFactor
- .xrFramebufferScaleFactor
.xrSession- .isRegistered(typeOrClass) ⇒ boolean
- .nextFrame(fixedDelta) ⇒ void
- .registerComponent(…classes) ⇒ void
- .requestXRSession(mode, features, optionalFeatures) ⇒ Promise<XRSession>
- .resize(width, height, devicePixelRatio) ⇒ void
- .start() ⇒ void
- .wrapObject(objectId) ⇒ Object3D
.arSupported: boolean
Whether AR is supported by the browser.
.i18n: I18N
Access to internationalization.
.onResize: Emitter<void[]>
Emitter for canvas / main framebuffer resize events.
Usage from a within a component:
Note: The size of the canvas is in physical pixels, and is set via resize.
.onSceneLoaded: Emitter<void[]>
Emitter for scene loaded events.
Listeners get notified when a call to () finishes, which also happens after the main scene has replaced the loading screen.
Usage from a within a component:
|
|
.onXRSessionEnd: Emitter<void[]>
Emitter for WebXR session end events.
Usage from a within a component:
|
|
.onXRSessionStart: Emitter<[XRSession, XRSessionMode]>
Emitter for WebXR session start events.
Usage from a within a component:
|
|
By default, this emitter is retained and will automatically call any callback added while a session is already started:
.scene: Scene
Current main scene.
.vrSupported: boolean
Whether VR is supported by the browser.
.xr: null | XR
WebXR related state, null
if no XR session is active.
.autoResizeCanvas
true
if the canvas is automatically resized by the engine.
.autoResizeCanvas
true
if the canvas is automatically resized by the engine.
.canvas
Canvas element that Wonderland Engine renders to.
.physics
Physics manager, only available when physx is enabled in the runtime.
.runtimeVersion
Retrieves the runtime version.
.textures
Texture managger.
Use this to load or programmatically create new textures at runtime.
.xrBaseLayer
Current WebXR base layer or null
if no session active.
Deprecated: Use baseLayer on the xr object instead.
.xrFrame
Current WebXR frame or null
if no session active.
Deprecated: Use frame on the xr object instead.
.xrFramebuffer
Current WebXR framebuffer or null
if no session active.
Deprecated: Use framebuffers on the xr object instead.
.xrFramebufferScaleFactor
Framebuffer scale factor.
.xrFramebufferScaleFactor
Framebuffer scale factor.
.xrSession
Current WebXR session or null
if no session active.
Deprecated: Use session on the xr object instead.
.isRegistered(typeOrClass: string | ComponentConstructor<Component>) ⇒ boolean
Checks whether the given component is registered or not.
Returns: true
if the component is registered, false
otherwise.
Param | Type | Description |
---|---|---|
typeOrClass | string | ComponentConstructor<Component> | A string representing the component typename (e.g., 'cursor-component' ),
or a component class (e.g., CursorComponent ). |
.nextFrame(fixedDelta: number) ⇒ void
Run the next frame.
Note: The engine automatically schedules next frames. You should only use this method for testing.
Param | Type | Description |
---|---|---|
fixedDelta | number | The elapsed time between this frame and the previous one. |
.registerComponent(…classes: ComponentConstructor<Component>[][]) ⇒ void
1.0.0+Register a custom JavaScript component type.
You can register a component directly using a class inheriting from Component:
|
|
Param | Type | Description |
---|---|---|
classes | ComponentConstructor<Component>[] | Custom component(s) extending Component. |
.requestXRSession(mode: XRSessionMode, features: string[], optionalFeatures: string[]) ⇒ Promise<XRSession>
Request a XR session.
Note: Please use this call instead of directly calling navigator.xr.requestSession()
.
Wonderland Engine requires to be aware that a session is started, and this
is done through this call.
Returns: A promise resolving with the XRSession
, a string error message otherwise.
Param | Type | Description |
---|---|---|
mode | XRSessionMode | The XR mode. |
features | string[] | An array of required features, e.g., ['local-floor', 'hit-test'] . |
optionalFeatures | string[] | An array of optional features, e.g., ['bounded-floor', 'depth-sensing'] . |
.resize(width: number, height: number, devicePixelRatio: number) ⇒ void
Resize the canvas and the rendering context.
Note: The width
and height
parameters will be scaled by the
devicePixelRatio
value. By default, the pixel ratio used is
window.devicePixelRatio.
Param | Type | Description |
---|---|---|
width | number | The width, in CSS pixels. |
height | number | The height, in CSS pixels. |
devicePixelRatio | number | The pixel ratio factor. |
.start() ⇒ void
Start the engine if it’s not already running.
When using the loadRuntime function, this method is called automatically.
.wrapObject(objectId: number) ⇒ Object3D
Wrap an object ID using Object.
Note: This method performs caching and will return the same instance on subsequent calls.
Returns: The object
Param | Type | Description |
---|---|---|
objectId | number | ID of the object to create. |