Skip to main content

ColocatedTrackingComponent

Class

Allows SceneObject to be tracked in a Connected Lens Experience.

  • 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.

Since Lens Scripting v148

Index

Remarks

Creates Colocated Connected Lenses experiences by enabling the creation and tracking of a shared space which can be used to place several users in the same coordinate frame. This shared space will be made available and can be tracked by any friend you invite to join your session via Snapcode. Users are expected to be located in the same room when using the colocated feature. This component needs to be attached to the camera.

Extends

Properties

buildingProgress

readonly buildingProgress: number

Provides the shared space building progress expressed in values 0-1. These values can be used to populate a progress bar. Once this value has reached 1, the colocated tracking component attempts to share the space which the user created.

Since

Lens Scripting Version 148


canBuild

readonly canBuild: boolean

Indicates whether a shared space can be built on this device. Colocated Tracking is available on devices with ARKit/ARCore in the rear camera. This flag should be checked before attempting to build or join a session. If it is false, you should inform users: "Sorry, your device does not support shared AR experiences."

Since

Lens Scripting Version 149


canTrack

readonly canTrack: boolean

Indicates whether a shared space is present and ready to be tracked.

Since

Lens Scripting Version 148


enabled

enabled: boolean

If disabled, the Component will stop enacting its behavior.

Default Value

true

Inherited from

Component.enabled


isBeingDestroyed

readonly isBeingDestroyed: 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

Component.isBeingDestroyed


isBuilding

readonly isBuilding: boolean

Indicates whether a shared space building operation is in progress. Once the flag is false, the shared space still needs to be shared. Use onTrackingAvailable to determine when your space has been shared.

Since

Lens Scripting Version 148


isEnabledInHierarchy

readonly isEnabledInHierarchy: boolean

Returns true if this Component, its SceneObject, and all of that SceneObjects parents are enabled.

Inherited from

Component.isEnabledInHierarchy


isJoining

readonly isJoining: boolean

Indicates whether a session joining operation is in progress.

Since

Lens Scripting Version 148


isTracking

readonly isTracking: boolean

Indicates whether a shared space is actively being tracked. This value will be true while tracking is active, either with or without the shared space in view. This property matches the equivalent one in MarkerTrackingComponent.

Since

Lens Scripting Version 148


onBuildFailed

readonly onBuildFailed: event0<void>

Event fired when the building operation fails (for example, sharing your space failed). Once onTrackingAvailable event is triggered, this event will not be triggered anymore.

Since

Lens Scripting Version 148


onFound

readonly onFound: event0<void>

Event fired when a shared space starts being actively tracked. This property is an analogue of the onMarkerFound property in MarkerTrackingComponent.

Since

Lens Scripting Version 148


onJoinFailed

readonly onJoinFailed: event0<void>

Event fired when a join operation completes but no shared space was found in the session.

Since

Lens Scripting Version 148


onLost

readonly onLost: event0<void>

Event fired when a shared space stops being actively tracked. This property is an analogue of the onMarkerLost property in MarkerTrackingComponent.

Since

Lens Scripting Version 148


onTrackingAvailable

readonly onTrackingAvailable: event0<void>

Event fired when a shared space has been shared or received and the device can attempt to start tracking. If this event is not being triggered for a long period, the process will time out and onBuildFailed event will be triggered.

Since

Lens Scripting Version 148


sceneObject

readonly sceneObject: SceneObject

The SceneObject this component is on.

Inherited from

Component.sceneObject


uniqueIdentifier

readonly uniqueIdentifier: string

Since

Lens Scripting Version 176

Inherited from

Component.uniqueIdentifier

Methods

destroy()

destroy(): void

Destroys the component.

Returns

void

Inherited from

Component.destroy


getSceneObject()

getSceneObject(): SceneObject

Returns the SceneObject the component is attached to.

Returns

SceneObject

Inherited from

Component.getSceneObject


getTransform()

getTransform(): Transform

Returns the Transform this component is attached to.

Returns

Transform

Inherited from

Component.getTransform


getTypeName()

static getTypeName(): TypeName<ColocatedTrackingComponent>

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

Since

Lens Scripting Version 148

Overrides

Component.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

Component.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

Component.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

Component.isSame


join()

join(session): void

Joins an existing session, retrieving the shared space that the colocated session initiator just created. Throws an exception if a join or build operation is in progress or if a shared space is already present.

Parameters

ParameterType
sessionMultiplayerSession

Returns

void

Since

Lens Scripting Version 148


startBuilding()

startBuilding(session): void

Starts the shared space building process locally in the session initiator's device.

If a session is provided, the shared space is placed into the session after building has completed, which is required for Colocated experiences running on mobile devices. When running the experience in Lens Studio Preview or solo mode the session is not required.

Throws an exception if a join or build operation is in progress or if a map is already present.

Parameters

ParameterType
sessionMultiplayerSession

Returns

void

Since

Lens Scripting Version 148

See also

Connected Lenses Overview