ObjectTracking
ClassUsed to track objects in 2D space, such as body parts, pet, hand.
- Available on all platforms
Index
Properties
Methods
Remarks
Moves the local ScreenTransform to match the detected image.
Example
// @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!");
});
Extends
Properties
autoEnableWhenTracking
autoEnableWhenTracking:
boolean
If true, child objects of this Component's SceneObject will be disabled when the object is not being tracked.
Default Value
true
enabled
enabled:
boolean
If disabled, the Component will stop enacting its behavior.
Default Value
true
Inherited from
isBeingDestroyed
readonlyisBeingDestroyed:boolean
Returns true if this Component is currently being destroyed. Becomes true as soon as
destruction begins via Component#destroy or destruction of its owning SceneObject,
before any OnDestroyEvent callbacks fire.
Since
Lens Scripting Version 364
Example
if (!script.isBeingDestroyed) {
// Component is still fully alive
}
Inherited from
isEnabledInHierarchy
readonlyisEnabledInHierarchy:boolean
Returns true if this Component, its SceneObject, and all of that SceneObjects parents are enabled.
Inherited from
Component.isEnabledInHierarchy
objectIndex
objectIndex:
number
The index of the object being tracked.
Default Value
0
objectSpecificData
readonlyobjectSpecificData:ObjectSpecificData
Gets additional data of the current object being tracked.
Since
Lens Scripting Version 145
onObjectFound
onObjectFound: () =>
void
Function that gets called when the tracked object is found.
Returns
void
onObjectLost
onObjectLost: () =>
void
Function that gets called when the tracked object is lost.
Returns
void
sceneObject
readonlysceneObject:SceneObject
The SceneObject this component is on.
Inherited from
uniqueIdentifier
readonlyuniqueIdentifier:string
Since
Lens Scripting Version 176
Inherited from
Methods
destroy()
destroy():
void
Destroys the component.
Returns
void
Inherited from
getSceneObject()
getSceneObject():
SceneObject
Returns the SceneObject the component is attached to.
Returns
Inherited from
getTransform()
getTransform():
Transform
Returns the Transform this component is attached to.
Returns
Inherited from
getTypeName()
staticgetTypeName():TypeName<ObjectTracking>
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<ObjectTracking>
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
isTracking()
isTracking():
boolean
Returns true if the object is currently being tracked on camera.
Returns
boolean
registerDescriptorEnd()
registerDescriptorEnd(
descriptor,callback):void
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
| Parameter | Type |
|---|---|
descriptor | string |
callback | (descriptor) => void |
Returns
void
registerDescriptorStart()
registerDescriptorStart(
descriptor,callback):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
| Parameter | Type |
|---|---|
descriptor | string |
callback | (descriptor) => void |
Returns
void
See also
Object Tracking guide. @seeHand Gestures guide.