Used to track objects in the camera. Moves the local ScreenTransform to match the detected image.

See the Object Tracking guide and the Hand Gestures Guide for more information.

// @input Component.ObjectTracking objectTracking

script.objectTracking.onObjectFound = function() {
print("Object has been found!");
};

script.objectTracking.onObjectLost = function() {
print("Object has been lost!");
};
// @input Component.ObjectTracking  handTracking

var descriptor = "open";
// All possible descriptors for Hand Tracking are:
// "victory", "open", "index_finger", "horns", "close", "thumb"

script.handTracking.registerDescriptorStart(descriptor, function () {
print(descriptor + " gesture was detected!");
});
interface ObjectTracking {
    autoEnableWhenTracking: boolean;
    enabled: boolean;
    objectIndex: number;
    objectSpecificData: ObjectSpecificData;
    onObjectFound: (() => void);
    onObjectLost: (() => void);
    sceneObject: SceneObject;
    uniqueIdentifier: string;
    destroy(): void;
    getSceneObject(): SceneObject;
    getTransform(): Transform;
    getTypeName(): string;
    isOfType(type: string): boolean;
    isSame(other: ScriptObject): boolean;
    isTracking(): boolean;
    registerDescriptorEnd(descriptor: string, callback: ((descriptor: string) => void)): void;
    registerDescriptorStart(descriptor: string, callback: ((descriptor: string) => void)): void;
}

Hierarchy (view full)

Properties

autoEnableWhenTracking: boolean

If true, child objects of this Component's SceneObject will be disabled when the object is not being tracked.

enabled: boolean

If disabled, the Component will stop enacting its behavior.

objectIndex: number

The index of the object being tracked.

objectSpecificData: ObjectSpecificData

Gets additional data of the current object being tracked.

onObjectFound: (() => void)

Function that gets called when the tracked object is found.

onObjectLost: (() => void)

Function that gets called when the tracked object is lost.

sceneObject: SceneObject
uniqueIdentifier: string

Methods

  • Destroys the component.

    Returns void

  • Returns the name of this object's type.

    Returns string

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

    Parameters

    • type: string

    Returns boolean

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

    Parameters

    Returns boolean

  • Returns true if the object is currently being tracked on camera.

    Returns boolean

  • Registers a callback to be executed when the passed in descriptor ends for this tracked object. For example, the possible descriptors for hand tracking are: "victory", "open", "index_finger", "horns", "close", "thumb".

    Parameters

    • descriptor: string
    • callback: ((descriptor: string) => void)
        • (descriptor): void
        • Parameters

          • descriptor: string

          Returns void

    Returns void

  • Registers a callback to be executed when the passed in descriptor starts for this tracked object. For example, the possible descriptors for hand tracking are: "victory", "open", "index_finger", "horns", "close", "thumb".

    Parameters

    • descriptor: string
    • callback: ((descriptor: string) => void)
        • (descriptor): void
        • Parameters

          • descriptor: string

          Returns void

    Returns void