Skip to main content

TrackedMesh

Class

Represents a mesh generated by world 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.

Represents a mesh generated by world tracking. Only available when world mesh tracking is supported and enabled.

Index

Example

script.createEvent("WorldTrackingMeshesAddedEvent").bind(onMeshesAdded);

function onMeshesAdded(eventData) {
var trackedMeshes = eventData.getMeshes();
print(trackedMeshes.length + " meshes were added");

for (var i = 0; i < trackedMeshes.length; i++) {
print("TrackedMesh is valid " + trackedMeshes[i].isValid);
print("Transformation matrix " + trackedMeshes[i].transform);
var m = trackedMeshes[i].transform;

var pos = m.column3;
print("Position " + pos);

var rot = quat.lookAt(
new vec3(m.column2.x,m.column2.y,m.column2.z),
new vec3(m.column1.x,m.column1.y,m.column1.z)
);
print("Rotation " + rot);
var s = new vec3(
m.column0.length,
m.column1.length,
m.column2.length
);
print("Scale " + s);
}
}

Extends

Properties

isValid

readonly isValid: boolean

Returns whether the tracked mesh is valid.


transform

readonly transform: mat4

Returns the World Transformation matrix of the detected mesh.

Methods

getTypeName()

static getTypeName(): TypeName<TrackedMesh>

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<TrackedMesh>

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