Skip to main content

AnchorModule

Class

Entry point to the anchoring system.

  • 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

Entry point to the anchoring system. Open an AnchorSession to create, save, discover, and track anchors. Spectacles only.

Index

Example

const anchorModule = require('LensStudio:AnchorModule');
const session = await anchorModule.openSession();
const object = script.getSceneObject();
const anchor = await session.createWorldAnchor(object.getTransform().getWorldTransform());
// Track the anchor by assigning it to an AnchorComponent on the object you want anchored.
const tracker = object.createComponent(AnchorComponent.getTypeName());
tracker.anchor = anchor;
// Persist it so it can be found again in a later session.
await session.saveAnchor(anchor, { scope: AnchorModule.AnchorScope.Private });

Extends

Properties

name

name: string

The name of the Asset in Lens Studio.

Default Value

""

Inherited from

Asset.name


uniqueIdentifier

readonly uniqueIdentifier: string

Since

Lens Scripting Version 176

Inherited from

Asset.uniqueIdentifier

Methods

getTypeName()

static getTypeName(): TypeName<AnchorModule>

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

Since

Lens Scripting Version 376

Overrides

Asset.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

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

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

Asset.isSame


openSession()

openSession(options?): Promise<AnchorSession>

SPECS

Start working with anchors. Optionally pass an area to scope which saved anchors are relevant.

Parameters

ParameterType
options?AnchorSessionOptions

Returns

Promise<AnchorSession>

Since

Lens Scripting Version 376

Nested types

Enumerations

EnumerationDescription
AnchorScopeWho can access an anchor.
AnchorTrackingStateThe tracking state of an AnchorComponent.
AnchorTypeThe kind of anchor.

Classes

ClassDescription
AnchorA saved place the system can recognise and track — an identity plus metadata. Passive: holding an Anchor does not track it (set it on an AnchorComponent to track). Always obtained from an AnchorModule.AnchorSession (create, discover, or resolve).
AnchorSessionYour 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.
AnchorSessionOptionsOptions for opening an AnchorSession.
SaveOptionsOptions for saving an anchor.
WorldAnchorA spatial anchor fixed to a point in the user's mapped space.