Skip to main content

TrackedPlane

Class

A representation for plane detected by native tracking.

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

A representation for plane detected by native tracking. Can be used with TrackedPoint.

Index

Example

// @input Component.RenderMeshVisual renderMeshVisual

script.createEvent("WorldTrackingPlanesAddedEvent").bind(function (eventData) {
var eventPlanes = eventData.getPlanes();

for (var i = 0; i < eventPlanes.length; i++) {
var eventPlane = eventPlanes[i];

script.renderMeshVisual.mesh = eventPlane.mesh;
}
});

Extends

Properties

classification

readonly classification: TrackedPlaneClassification

SPECS only

The semantic class of the plane, see TrackedPlaneClassification. It can change as more of the plane is observed, see WorldTrackingPlanesUpdatedEvent.

Since

Lens Scripting Version 387

Example

//@input Component.DeviceTracking deviceTracking
//@input Component.RenderMeshVisual planeVisual

script.deviceTracking.worldOptions.nativePlaneTrackingType = NativePlaneTrackingType.Both;
script.deviceTracking.worldOptions.enablePlaneClassification = true;

var colors = {
[TrackedPlaneClassification.Wall]: new vec4(1, 0, 0, 1),
[TrackedPlaneClassification.Floor]: new vec4(1, 1, 0, 1),
[TrackedPlaneClassification.Table]: new vec4(0, 1, 0, 1),
};

// Show the last updated plane in the color of its class.
script.createEvent("WorldTrackingPlanesUpdatedEvent").bind(function (eventData) {
var plane = eventData.getPlanes()[0];
script.planeVisual.mesh = plane.mesh;
script.planeVisual.getSceneObject().getTransform().setWorldTransform(plane.transform);
script.planeVisual.mainPass.baseColor = colors[plane.classification] || new vec4(0.5, 0.5, 0.5, 1);
});

isValid

readonly isValid: boolean

Whether the detected plane is still available to utilize

Since

Lens Scripting Version 144


mesh

readonly mesh: RenderMesh

A coarse mesh describing the shape of the tracked plane. Can be displayed by RenderMeshVisual

Since

Lens Scripting Version 144


orientation

readonly orientation: TrackedPlaneOrientation

Returns the orientation of the detected plane, either vertical or horizontal.

Since

Lens Scripting Version 144


pivot

readonly pivot: vec3

The center point of the detected plane

Since

Lens Scripting Version 144


size

readonly size: vec3

The size of the detected plane, where it is described as width, 0, depth

Since

Lens Scripting Version 144


transform

readonly transform: mat4

The position, rotation, and scale of the detected plane

Since

Lens Scripting Version 144

Methods

getTypeName()

static getTypeName(): TypeName<TrackedPlane>

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<TrackedPlane>

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame