Skip to main content

LocationAsset

Class

Provides a frame of reference in which to localize objects to the real world.

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

Provides a frame of reference in which to localize objects to the real world. Use with LocatedAtComponent.

Index

Example

// @input Asset.Texture myTexture

const currentObj = script.sceneObject;
const imageComponent = currentObj.createComponent(Image.getTypeName());
const imageMaterial = imageComponent.mainPass;
imageMaterial.baseTex = script.myTexture;
@component
export class AssetExample extends BaseScriptComponent {
@input()
myTexture: Texture;

onAwake() {
const currentObj = this.sceneObject
const imageComponent = currentObj.createComponent(Image.getTypeName());
const imageMaterial = imageComponent.mainPass;
imageMaterial.baseTex = this.myTexture;
}
}

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

adjacentTile()

adjacentTile(xOffset, yOffset, zoomOffset): LocationAsset

Returns the LocationAsset Tile that is specified by the containing tile and the specified xOffset, yOffset and zoomOffset. When zooming in, index offset is relative to the center. When zooming out or not zooming, index offset is relative to the containing tile.

Parameters

ParameterType
xOffsetnumber
yOffsetnumber
zoomOffsetnumber

Returns

LocationAsset

Since

Lens Scripting Version 228


fromSerialized()

static fromSerialized(serialized): LocationAsset

Exposes user dataSPECS

Deserialize the provided serialized LocationAsset.

Parameters

ParameterType
serializedstring

Returns

LocationAsset


getAROrigin()

static getAROrigin(): LocationAsset

Gets the origin position of the LocationAsset.

Returns

LocationAsset

Since

Lens Scripting Version 229


getGeoAnchoredPosition()

static getGeoAnchoredPosition(longitude, latitude): Anchor

Get an Anchor based on the given GPS coordinate.

Parameters

ParameterType
longitudenumber
latitudenumber

Returns

Anchor

Since

Lens Scripting Version 172


getNearby()

static getNearby(xOffset, yOffset, zoomOffset): LocationAsset

Gets nearby LocationAsset tiles, where each argument represents the x,y,z position relative to the current LocationAsset.

Parameters

ParameterType
xOffsetnumber
yOffsetnumber
zoomOffsetnumber

Returns

LocationAsset

Since

Lens Scripting Version 172


getProxy()

static getProxy(proxyId): LocationAsset

Get a Proxy LocationAsset with the proxyId embedded in the locationId. proxyId must not be null, must start with an alpha char, and consist only of alphanumerics or ".".

Parameters

ParameterType
proxyIdstring

Returns

LocationAsset

Since

Lens Scripting Version 191


getProxyId()

getProxyId(): string

Gets the Proxy LocationID if the LocationAsset is a proxyLocation; returns null otherwise. This is useful in instances where a callback may return a mix of different location assets, and the creator of the proxy asset has specific handling in mind for particular proxy locations.

Returns

string

Since

Lens Scripting Version 191


getTypeName()

static getTypeName(): TypeName<LocationAsset>

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

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


toSerialized()

toSerialized(): string

Exposes user dataSPECS

Serialize the LocationAsset to a string representation.

Returns

string