LookAtComponent
Lens Studio v1.0.0+
Scripting Name: Component.LookAtComponent
Inherits from Component
Inner Classes: LookAtComponent.AimVectors
, LookAtComponent.LookAtMode
, LookAtComponent.WorldUpVector
Description
Every frame, LookAtComponent rotates its SceneObject to face towards a target SceneObject.
Properties
aimVectors
: LookAtComponent.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
.
lookAtMode
: LookAtComponent.LookAtMode
Controls the method of rotation being used.
offsetRotation
: quat
Adds an additional rotation offset.
target
: SceneObject
The SceneObject this LookAtComponent targets.
worldUpVector
: LookAtComponent.WorldUpVector
The vector to be considered the “up” vector when determining rotation.
Inherited Methods
destroy()
: void
Destroys the component.
getSceneObject()
: SceneObject
Returns the SceneObject the component is attached to.
getTransform()
: Transform
Returns the Transform this component is attached to.
isSame(SerializableWithUID other)
: Boolean
Returns true if this object is the same as other
. Useful for checking if two references point to the same thing.
getTypeName()
: String
Returns the name of this object’s type.
isOfType(String type)
: Boolean
Returns true if the object matches or derives from the passed in type.
Inherited Properties
enabled
: Boolean
If disabled, the Component will stop enacting its behavior.
Examples
// 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;
Still Looking for help?
Visit Support