Class WebXR
Wrapper of the WebXR API in the browser.
Namespace: Evergine.WebXR
Assembly: Evergine.WebXR.dll
Syntax
public class WebXR
Methods
Dispose()
Disposes the shared memory between Evergine and the browser.
Declaration
public void Dispose()
EndImmersiveSession()
Finishes the current immersive version.
Declaration
public void EndImmersiveSession()
GetInstance()
Singleton instance.
Declaration
public static WebXR GetInstance()
Returns
Type | Description |
---|---|
WebXR | The singleton instance. |
Init(xrFrameCallback)
Configures the WebXR library. It must be called before creating the WebGL context to enable WebXR attributes.
Declaration
public void Init(xrFrameCallback onFrame)
Parameters
Type | Name | Description |
---|---|---|
xrFrameCallback | onFrame | Callback when a new frame is ready. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Throws invalid operation exception if WebXR is unavailable. |
MustBgOpaque(string)
Logic to detect if the background should be rendered (opaque) or not.
Declaration
public bool MustBgOpaque(string immersiveMode)
Parameters
Type | Name | Description |
---|---|---|
string | immersiveMode | Immersive mode. |
Returns
Type | Description |
---|---|
bool | False if background shouldn't be rendered, true owtherwise. |
RequestImmersiveSessionAsync(string, string, string, string)
Request the browser an immersive session.
Declaration
public Task<bool> RequestImmersiveSessionAsync(string immersiveMode, string canvasId, string contextType, string overlayId)
Parameters
Type | Name | Description |
---|---|---|
string | immersiveMode | Session mode. |
string | canvasId | Canvas ID. |
string | contextType | WebGL2 only supported. |
string | overlayId | Id of the overlay layer. |
Returns
Type | Description |
---|---|
Task<bool> | Async true if the mode is requested correctly. |
SetViewerPose(ref ViewProperties[])
Translates the WebXR pose object into a ViewProperties one.
Declaration
public bool SetViewerPose(ref ViewProperties[] viewerProperties)
Parameters
Type | Name | Description |
---|---|---|
ViewProperties[] | viewerProperties | ViewProperties object. |
Returns
Type | Description |
---|---|
bool | True if the pose is available, False otherwise. |
StartRequestAnimationFrame()
Starts requesting frames from the browser.
Declaration
public void StartRequestAnimationFrame()
StopRequestAnimationFrame()
Tells the browser to stop requesting frames.
Declaration
public void StopRequestAnimationFrame()