ARHandler Class

Module: Physics

AR class handles all the augmented reality related tasks.

Can be used to detect if the host system is capable of displaying AR content and checks for the availability of WebXR with the required modes.

Methods

arAvailable

() Boolean

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

Checks if there is support for WebAR or WebXR.

Returns:

Boolean:

True if the browser supports AR.

enterAR

(
  • renderer
  • onSuccess
)

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

If booth API are available the WebXR API is used.

When displaying AR 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 AR successfully.

exitAR

(
  • renderer
)

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

Parameters:

  • renderer WebGLRenderer

    Renderer used to draw the scene.

getXRSession

() Promise

Get WebXR session.

Returns:

Promise:

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

Attributes

ADDITIVE

String static

Primarily used by AR devices with transparent lenses which directly allow reality to pass through to the user's eyes.

ALPHA_BLEND

String static

Used by headsets or goggles which use cameras to capture the real world and display it digitally on the screen or screens used to render the content for the user to see, this offers a way to create an AR presentation using a VR device.

OPAQUE

String static

The rendered image is drawn without allowing any pass-through imagery. This is primarily used by fully-immersive VR headsets.

webXRSession

XRSession

WebXR session if there is one active.

webXRSupported

Boolean

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