Scripting API
SceneModule
PlaneTracker

PlaneTracker

The PlaneTracker class provides functionality for locating a 3D plane based on 2D screen coordinates.

Inherits From : SceneObjectBase

Plane tracker behavior will be changing from V133 onwards. Previously, the plane tracker would use a Z-up coordinate system on devices and a Y-up coordinate system in Spark AR Studio. By changing the device coordinate system to Y-up, plane tracking effects now perform with more consistency across all surfaces.

This change will only affect projects created or updated in Spark AR Studio v133 or later. If you have previously created effects that include a custom solution to address the rotation of the coordinate system on device, you may find that they work differently after updating to v133. Effects that were published before v133 will be unaffected until they are updated to v133 or later.

Properties

PropertyDescription
confidence
(get) confidence: StringSignal
(set) (Not Available)


Returns tracking confidence level info.
This value indicates if PlaneTracker is currently tracking and how confident it is in reported results.
Possible values:
- HIGH
- MEDIUM
- LOW
- NOT_TRACKING

Methods

MethodDescription
performHitTest
performHitTest(screenXLocation: number, screenYLocation: number): Promise<Point3D>
performHitTest(screenLocation: Point2D): Promise<Point3D>


Returns a promise that is resolved with a point on tracked plane in local coordinates of PlaneTracker (in 3D units)
or null if plane is not found at given screen location.
trackPoint
trackPoint(screenLocation: Point2D): void
trackPoint(screenX: number, screenY: number): void
trackPoint(screenLocation: Vec2Signal, gestureState: StringSignal): void


PlaneTracker origin is bound to a point in 3d space, located on detected plane.
This method updates PlaneTracker to track 3d point currently under given screen coordiantes.
This also triggers new plane detection, in result this object's transform will be modified.
Version with signal parameters can be used in touch gestures for continuous updating:
TouchGestures.onPan().subscribe(function(gesture) {
planeTracker.trackPoint(gesture.location, gesture.state);
});