The RealityAPI provides functionalities for controlling an XRSession together with all XR capable members.
Example
// Start by connecting to the XR Session constxrSessionState = awaitwebvis.getContext().connectXRSession();
// Get a list of all available XR members constxrMembers = webvis.getContext().getXRMembers();
// The local XR member is always the first one in the list constlocalXRMember = 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);
Enters the initialization phase for modeltracking. This is also used to reset
the current modeltracking. It will also trigger a
XRMemberStateChangedEvent event with XRState.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.
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.
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 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.
showExpertDialog
showExpertDialog(): Promise<boolean>
Deprecated
Show expert dialog for developers or advanced users
Returns Promise<boolean>
returns true if the operation was successfull or false if not
startAR
startAR(): Promise<boolean>
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)
Returns Promise<boolean>
returns true if starting was successfull or false if it could not start AR
The RealityAPI provides functionalities for controlling an XRSession together with all XR capable members.
Example