AM_MouselookAvatar

AM_MouselookAvatar

Extends the avatar actor mixin to separate rotation into pitch and yaw components. Yaw is used to control the avatar's facing. Pitch is ignored when calculating facing, but is used with yaw to determine camera direction.

Note - AM_Avatar must be paired with PM_MouselookAvatar in the pawn.

Extends

Members

# lookPitch :number

The pitch angle of the avatar in radians. Pitch is ignored in determining the actor's facing, but affects camera direction.

Warning: You usually shouldn't set the avatar's lookPitch directly. Instead let it be controlled automatically by events from the avatar's pawn.

Type:
  • number

# lookYaw :number

The yaw angle of the avatar in radians. Yaw is used to determine the actor's facing.

Warning: You usually shouldn't set the avatar's lookYaw directly. Instead let it be controlled automatically by events from the avatar's pawn.

Type:
  • number

# tickStep :Array.<number>

The frequency in milliseconds of the actor's tick method. Every tick the actor will apply its velocity and spin to adjust its position. Generally, for a first-person avatar you want to leave this at its default of 15ms so that it runs every frame.

Type:
  • Array.<number>
Inherited From:
Default Value:
  • 15

# velocity :Array.<number>

The velocity of the actor in units/millisecond. Every tick the actor will move the velocity from its current position. The velocity is a 3-vector.

Warning: You usually shouldn't set an avatar's velocity directly. Instead let it be controlled automatically by events from the avatar's pawn.

Type:
  • Array.<number>
Inherited From:
Default Value:
  • [0,0,0]

# spin :Array.<number>

The spin of the actor in radians/millisecond. Every tick the actor will rotate the spin from its current position. The spin is a quaternion.

Warning: You usually shouldn't set an avatar's spin directly. Instead let it be controlled automatically by events from the avatar's pawn.

Type:
  • Array.<number>
Inherited From:
Default Value:
  • [0,0,0,1]

# translation :Array.<number>

The local translation of the actor relative to its parent. The value is a 3D vector.

Type:
  • Array.<number>
Inherited From:
Default Value:
  • [0,0,0]
Fires:
  • translationChanged
  • localChanged
  • globalChanged
Example:
spatialActor.set({translation: [1,0,0]}); // Translate this actor one unit in the X direction from its parent.

# rotation :Array.<number>

The local rotation of the actor relative to its parent. The value is a quaternion.

Type:
  • Array.<number>
Inherited From:
Default Value:
  • [0,0,0,1]
Fires:
  • rotationChanged
  • localChanged
  • globalChanged
Example:
spatialActor.set({rotation: q_axisAngle([1,0,0], toRad(90))}); // Rotate this actor 90 degrees around the X axis relative to its parent.

# scale :Array.<number>

The local scale of the actor relative to its parent. The value is a 3D vector.

Warning: Do not set the scale to 0!

Type:
  • Array.<number>
Inherited From:
Default Value:
  • [1,1,1]
Fires:
  • scaleChanged
  • localChanged
  • globalChanged
Example:
spatialActor.set({scale: [2,2,2])}); // Double the size of this actor relative to its parent.

# local :Array.<number>

The local 4x4 transformation matrix. This is the actor's transform relative to its parent.

Warning - Do NOT set this matrix directly. Set the independent translation, rotation, and scale components and let the actor combine them to get the local matrix.

Type:
  • Array.<number>
Inherited From:

# global :Array.<number>

The global 4x4 transformation matrix. This is the actor's transform relative to world space, taking into account its local transform and the local transforms of all of its parents.

Warning - Do NOT set this matrix directly. Set the independent translation, rotation, and scale components and let the actor combine them to get the global matrix.

Type:
  • Array.<number>
Inherited From:

# parent :Actor

The parent of the actor in the hierarchical tree.

Type:
Inherited From:
Example:
const treeActor = TreeActor.create({parent: parentActor});

Methods

# tick()

The actor's tick runs every tickStep milliseconds. It will use the actor's velocity and spin to automatically update the translation and rotation. You can overload the tick method if the actor needs to perform other periodic updates.

Inherited From:
Default Value:
  • 15

# moveTo(translation)

Tells the actor to move to a new xyz position. The actor moves immediately to the new translation, while its pawn smoothly interpolates over the next few frames. If you want the pawn to pop the new position, set the actor's translation property instead.

Note: All movement is relative to the actor's parent.

Parameters:
Name Type Description
translation Array.<number>

A 3-vector containing the new translation for the actor.

Inherited From:

# rotateTo(rotation)

Tells the actor to rotate to a new orientation. The actor moves immediately to the new rotation, while its pawn smoothly interpolates over the next few frames. If you want the pawn to pop the new position, set the actor's rotation property instead.

Note: All movement is relative to the actor's parent.

Parameters:
Name Type Description
rotation Array.<number>

A quaternion containing the new rotation for the actor.

Inherited From:

# scaleTo(scale)

Tells the actor to scale to a new size. The actor transitions immediately to the new scale, while its pawn smoothly interpolates over the next few frames. If you want the pawn to pop the new scale, set the actor's scale property instead.

Note: All movement is relative to the actor's parent.

Warning: Do not set the scale to 0!

Parameters:
Name Type Description
scale Array.<number>

A 3-vector containing the new scale for the actor.

Inherited From: