RealityAPI#

Interface RealityAPI

The RealityAPI provides functionalities for controlling an XRSession together with all XR capable members.

Example

// Start by connecting to the XR Session
const xrSessionState = await webvis.getContext().connectXRSession();

// Get a list of all available XR members
const xrMembers = webvis.getContext().getXRMembers();

// The local XR member is always the first one in the list
const localXRMember = xrMembers[0];

// To kick-off modeltracking, let the XRMember enter the INIT mode
webvis.getContext().enterXRMemberInitMode(localXRMember);

// You can also hardreset the modeltracker by specifying the `resetHard` option
webvis.getContext().enterXRMemberInitMode(localXRMember, {resetHard: true});

// By default, enterXRMemberInitMode will fit the current model to the viewport
// If you want to disable this behavior, you can set the `fitView` option to false
webvis.getContext().enterXRMemberInitMode(localXRMember, {fitView: false});

// The modeltracker will try to align the virtual model and its real world counterpart.
// If this process is successful, this will automatically anchor the 3D model to the SLAM pose (provided e.g. by the ARKit)
// You can also manually fixate the model by calling the `exitXRMemberInitMode` method
webvis.getContext().exitXRMemberInitMode(localXRMember);

Hierarchy

Methods

  • Experimental

    Enters the initialization phase for modeltracking. This is also used to reset the current modeltracking. It will also trigger a XRMemberStateChangedEvent event with FIXATED set to false. By default the modeltracking will be softreset. If you choose to reset different data on the modeltracker you can do so by specifying the XRInitOptions.

    Parameters

    • memberId: number

      The XRMember that the operation should be applied on.

    • Optional xrInitOptions: XRInitOptions

      Specify initialization options. E.g. reset behavior of modeltracker. Default is softreset.

    Returns Promise<boolean>

    Returns a Promise which reports whether the operation was successful or not.

  • Experimental

    Exits the initialization phase for modeltracking, this will also anchor the model at the current position.

    Parameters

    • memberId: number

      The XRMember that the operation should be applied on.

    Returns Promise<boolean>

    Returns a Promise which reports whether the operation was successful or not.

  • Experimental

    Exports init template for modeltracking. Usage: After a successful tracking session, the learned init template data can be exported with this function and stored for later.

    Only supported if the XRMember has the MODELTRACKER capability.

    The aquired data can be imported via importXRInitTemplate function

    Parameters

    • memberId: number

      the XRMember that the operation should be applied on

    Returns Promise<string>

    base64 encoded init template data

  • Experimental

    Anchors the model at the current position. It will also trigger a XRMemberStateChangedEvent event with FIXATED set to true.

    Parameters

    • memberId: number

      The XRMember that the operation should be applied on.

    Returns Promise<boolean>

    Returns a Promise which reports whether the operation was successful or not.

  • Experimental

    Get the XRMemberInfo for a given XRMember.

    Parameters

    • memberId: number

      The XRMember that the operation should be applied on.

    Returns XRMemberInfo

    Returns an XRMemberInfo struct containing all relevant infos (memberId, XRCapabilities, sessionMemberData) for the given member.

  • Experimental

    Get the runtime state of a given XRMember.

    Parameters

    • memberId: number

      The XRMember that the state should be queried from.

    Returns XRMemberState

    Returns either the member state if the member exist or return undefined if XR is not connected or the memberId does not exist.

  • Experimental

    Lists all the available XRMembers in the current session.

    Returns number[]

    Returns a Promise with the list of the IDs of all available XRMembers.

  • Experimental

    Imports init template for modeltracking. When using Model tracking, Init templates are captured during the tracking process. This initialization data is linked to previously visited view-points along the traveled camera path. Once the tracking is lost the templates are used to quickly reinitialize from similar view-points without the user having to align the line model with the real object.

    Once the init template data is imported. It will stay until enterInitMode with resetInitTemplate set to true is called.

    Only supported if the XRMember has the MODELTRACKER capability.

    The input data can be aquired via exportXRInitTemplate function

    Parameters

    • memberId: number

      the XRMember that the operation should be applied on

    • template: string

    Returns Promise<void>

  • Experimental

    Execute whatever is necessary to enable XRCapbilities on the given member, e.g. start the camera or forward to the booster.

    Parameters

    • memberId: number

      The XRMember that the operation should be applied on.

    Returns Promise<boolean>

    Returns a Promise which reports whether the operation was successful or not.

  • Returns Promise<boolean>

    returns true if resetting was successfull or false if not

    Deprecated

    Restart modeltracker initialization for the local xr member

  • Experimental

    Sets the passed fusion mode for the given XRMember. The fusion mode determines which inputs will be used for the final visualization.

    Parameters

    • memberId: number

      the XRMember that the operation should be applied on

    • xrFusionMode: XRFusionMode

      the fusion mode that should be set

    Returns Promise<boolean>

    returns a Promise which reports whether the operation was successful or not

  • Experimental

    This will change the XRMemberSettings for the specified XRMember.

    Parameters

    • memberId: number

      The XRMember that the operation should be applied on.

    • settings: XRMemberSettings

      The quality threshold for the modeltracker must be between 0 and 1

    Returns Promise<boolean>

    Returns a Promise which reports whether the operation was successful or not.

  • Returns Promise<boolean>

    returns true if the operation was successfull or false if not

    Deprecated

    Show expert dialog for developers or advanced users

  • Returns Promise<boolean>

    returns true if starting was successfull or false if it could not start AR

    Deprecated

    Start AR. Projects the camera stream in the background and starts searching for the given reference. The reference is defined by setting the realproperty on the particular node via the webvis API. E.g. webvis.setProperty(0, pluginAPI.realProperty, pluginAPI.realState.Enabled)

  • Experimental

    Puts the image stream in the background of the renderer. It will also trigger a XRMemberStateChangedEvent event with FOLLOWING set to true.

    Parameters

    • memberId: number

      The XRMember that the operation should be applied on.

    Returns Promise<boolean>

    Returns a Promise which reports whether the operation was successful or not.

  • Returns Promise<boolean>

    returns true if stopping was successfull or false if it could not stop AR

    Deprecated

    Stop AR. Stop projecting the camera stream in the background and reset background to default color.

  • Experimental

    Stops the image stream in the background of the renderer. It will also trigger a XRMemberStateChangedEvent event with FOLLOWING set to false.

    Parameters

    • memberId: number

      The XRMember that the operation should be applied on.

    Returns Promise<boolean>

    Returns a Promise which reports whether the operation was successful or not.

  • Experimental

    Unfixates the model. The model will move with the device. It will also trigger a XRMemberStateChangedEvent event with FIXATED set to false.

    Parameters

    • memberId: number

      The XRMember that the operation should be applied on.

    Returns Promise<boolean>

    Returns a Promise which reports whether the operation was successful or not.