Skip to main content

AnchorModule.AnchorSession

Class

Your connection to the anchor system for an area.

  • Snapchat: not supported
  • SPECS: fully supported
  • Camera Kit Web: not supported
  • Camera Kit Mobile: not supported
  • SnapchatNot supported — Available on SPECS only
  • SPECSFully supported
  • Camera Kit WebNot supported — Available on SPECS only
  • Camera Kit MobileNot supported — Available on SPECS only

Platform details

  • Snapchat — Not supported — Available on SPECS only.

  • SPECS — Fully supported.

  • Camera Kit Web — Not supported — Available on SPECS only.

  • Camera Kit Mobile — Not supported — Available on SPECS only.

Since Lens Scripting v376

Your connection to the anchor system for an area. Use it to create, save, delete, discover, and track anchors. Close it only when tracking is no longer required.

Index

Extends

Properties

area

readonly area: string

SPECS

The area this session is using, or null if it was opened without one.

Since

Lens Scripting Version 376


onAnchorNearby

readonly onAnchorNearby: event1<Anchor, void>

SPECS

Called when a previously saved anchor is found nearby. Set it on an AnchorComponent to track it.

Since

Lens Scripting Version 376

Methods

clearAllAnchors()

clearAllAnchors(): Promise<void>

SPECS

Delete all saved anchors for this Lens, across every area.

Returns

Promise<void>

Since

Lens Scripting Version 376


clearArea()

clearArea(): Promise<void>

SPECS

Permanently delete the anchors this Lens saved in the session's area. Fails if the session has no area.

Returns

Promise<void>

Since

Lens Scripting Version 376


close()

close(): Promise<void>

SPECS

Close the session and stop tracking.

Returns

Promise<void>

Since

Lens Scripting Version 376


createWorldAnchor()

createWorldAnchor(toWorldFromAnchor): Promise<WorldAnchor>

SPECS

Create an anchor at a world position (world-from-anchor). Set the returned Anchor on an AnchorComponent to start tracking.

Parameters

ParameterType
toWorldFromAnchormat4

Returns

Promise<WorldAnchor>

Since

Lens Scripting Version 376


deleteAnchor()

deleteAnchor(anchor): Promise<void>

SPECS

Permanently delete a saved anchor. Tracking stops immediately.

Parameters

ParameterType
anchorAnchor

Returns

Promise<void>

Since

Lens Scripting Version 376


getTypeName()

static getTypeName(): TypeName<AnchorSession>

SPECS

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

Since

Lens Scripting Version 376

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


resolveAnchor()

resolveAnchor(anchorId): Promise<Anchor>

SPECS

Turn a saved anchor id (from Anchor.id) back into an anchor you can track.

Parameters

ParameterType
anchorIdstring

Returns

Promise<Anchor>

Since

Lens Scripting Version 376


saveAnchor()

saveAnchor(anchor, options?): Promise<void>

SPECS

Save an anchor so it can be found again in later sessions via onAnchorNearby.

Parameters

ParameterType
anchorAnchor
options?SaveOptions

Returns

Promise<void>

Since

Lens Scripting Version 376