Tracking

To enable or disable a specific tracker (e.g. ARKit), use

await viewarApi.trackers.ARKit.activate();      // Enable tracking.
await viewarApi.trackers.ARKit.reset();         // Reset tracking.
await viewarApi.trackers.ARKit.deactivate();    // Disable tracking.

There can only be one tracking active at one time. If one tracker gets enabled, the previous active tracker will be deactivated. The first tracker in the list can be selected with

let tracker = Object.values(viewarApi.trackers)[0];

Some trackers need to be initialized and detect the ground plane before they can start working (see tracking systems table in Basic Concepts). Therefore you can listen to the trackingTargetStatusChanged event for a tracker. After a ground is found the ground position needs to be confirmed (either automatically or with after a user input).

let tracker = Object.values(viewarApi.trackers)[0];

const onTrackingTargetStatusChanged = async function() {
    // Check if tracker is tracking and confirm ground.
    if (tracker.tracking) {
        tracker.off('trackingTargetStatusChanged', onTrackingTargetStatusChanged);    // Ground plane needs to be confirmed only once.
        await tracker.confirmGround();        // Automatically confirm ground when ground plane is found.
    }
};

// Listen for tracking changed status.
tracker.on('trackingTargetStatusChanged', onTrackingTargetStatusChanged);

After deactivating or resetting a tracker, the tracker needs to be calibrated again. This means that the detected and/or confirmed ground plane will be lost.