VRHandler Class

Module: Physics

VR class handles all the virtual reality related tasks.

Can be used to detect if the host system is capable of displaying VR content and checks for the availability of WebXR and/or WebVR.

Methods

enterVR

(
  • renderer
  • onSuccess
)

Enter virtual reality mode using WebXR or WebVR depending on the API available.

If booth API are available the WebXR API is used.

When displaying VR content the display.requestAnimationFrame should be used to call the render method.

Parameters:

  • renderer WebGLRenderer

    Renderer used to draw the scene.

  • onSuccess Function

    Method called if the application entered VR successfully.

exitVR

(
  • renderer
)

Enter virtual reality mode, if the application is not running on VR mode does not do anything.

Parameters:

  • renderer WebGLRenderer

    Renderer used to draw the scene.

getVRDisplays

() Promise

Used to get the first VR display available, the display is returned as argument of the onDisplay function.

Returns:

Promise:

Promise used to get the display, receives the display as argument.

getXRSession

() Promise

Get WebXR session.

Returns:

Promise:

Promise used to get the XR session, receives the session as argument.

vrAvailable

() Boolean

Check if there is any VR API available, on the device.

Checks if there is support for WebVR or WebXR.

Returns:

Boolean:

True if the browser supports vr.

Attributes

webVRDisplay

VRDisplay

WebVR display if there is one active.

webVRHasDisplay

Boolean

Flag indicating if there are any VR displays available.

Checked on the library bootup if WebVR is available, while the check does not finish it is set to null.

webXRSession

XRSession

WebXR session if there is one active.

webXRSupported

Boolean

Flag checking if there is support for XR immersive VR mode.

Checked on the library startup if XR is supported, while the check does not finish it is set to null.