Skip to main content

LookAtComponent

Class

Orients a SceneObject towards a target SceneObject.

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

Index

Example

// Switches through LookAt targets in a list on each tap
//@input Component.LookAtComponent lookAt
//@input SceneObject[] targets

var targetIndex = 0;

script.createEvent("TapEvent").bind(function(eventData)
{
if(script.targets.length > 0)
{
targetIndex = (targetIndex + 1) % script.targets.length;
script.lookAt.target = script.targets[targetIndex];
}
});
// Set aimVectors to [-Z Aim, Y Up]
// (Useful for aiming the camera since it faces towards -Z)
//@input Component.LookAtComponent lookAt
script.lookAt.aimVectors = LookAtComponent.AimVectors.NegativeZAimYUp;

Extends

Properties

aimVectors

aimVectors: AimVectors

The "aim" and "up" vectors used when determining rotation. LookAtComponent will try to point the Aim axis of the SceneObject towards the target, while keeping the Up axis of the SceneObject pointing towards worldUpVector.

Default Value

LookAtComponent.AimVectors.XAimYUp

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


isEnabledInHierarchy

readonly isEnabledInHierarchy: boolean

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

Inherited from

Component.isEnabledInHierarchy


lookAtMode

lookAtMode: LookAtMode

Controls the method of rotation being used.

Default Value

LookAtComponent.LookAtMode.LookAtPoint

offsetRotation

offsetRotation: quat

Adds an additional rotation offset.

Default Value

(1, 0, 0, 0)

sceneObject

readonly sceneObject: SceneObject

The SceneObject this component is on.

Inherited from

Component.sceneObject


target

target: SceneObject

The SceneObject this LookAtComponent targets.

Default Value

null

uniqueIdentifier

readonly uniqueIdentifier: string

Since

Lens Scripting Version 176

Inherited from

Component.uniqueIdentifier


worldUpVector

worldUpVector: WorldUpVector

The vector to be considered the "up" vector when determining rotation.

Default Value

LookAtComponent.WorldUpVector.SceneY

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

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

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

Nested types

Enumerations

EnumerationDescription
AimVectorsThe "aim" and "up" vectors used with LookAtComponent when determining rotation. LookAtComponent will try to point the Aim axis of the SceneObject towards the target, while keeping the Up axis of the SceneObject pointing towards worldUpVector.
LookAtModeModes used in LookAtComponent.lookAtMode to determine the rotation method being used.
WorldUpVectorUsed with LookAtComponent to set the "up" vector when determining rotation.