AnchorModule
ClassEntry 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
Since Lens Scripting v376
Entry point to the anchoring system. Open an AnchorSession to create, save, discover, and track anchors. Spectacles only.
Index
Properties
Methods
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
uniqueIdentifier
readonlyuniqueIdentifier:string
Since
Lens Scripting Version 176
Inherited from
Methods
getTypeName()
staticgetTypeName():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
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
openSession()
openSession(
options?):Promise<AnchorSession>
SPECS
Start working with anchors. Optionally pass an area to scope which saved anchors are relevant.
Parameters
| Parameter | Type |
|---|---|
options? | AnchorSessionOptions |
Returns
Promise<AnchorSession>
Since
Lens Scripting Version 376
Nested types
Enumerations
| Enumeration | Description |
|---|---|
| AnchorScope | Who can access an anchor. |
| AnchorTrackingState | The tracking state of an AnchorComponent. |
| AnchorType | The kind of anchor. |
Classes
| Class | Description |
|---|---|
| Anchor | A 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). |
| AnchorSession | 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. |
| AnchorSessionOptions | Options for opening an AnchorSession. |
| SaveOptions | Options for saving an anchor. |
| WorldAnchor | A spatial anchor fixed to a point in the user's mapped space. |