PM_Smoothed

PM_Smoothed

Extends the spatial pawn mixin to support view-side interpolation. Smoothed pawns interpolate their position every frame, always converging on the "true position" contained by their actor. Use the smoothed mixins for continuously moving objects, particularly if the actor or the session as a whole is running at a low tick rate.

Note: PM_Smoothed does generate some overhead. If the object is stationary, consider using PM_Spatial instead.

Note: PM_Smoothed must be paired with AM_Smoothed in the actor.

Extends

Members

# translation :Array.<number>

The local translation of the pawn relative to its parent. The value is a 3D vector. This is the interpolated value. If you want the actor's true value, use this.actor.translation.

Type:
  • Array.<number>

# rotation :Array.<number>

The local rotation of the pawn relative to its parent. The value is a quaternion. This is the interpolated value. If you want the actor's true value, use this.actor.translation.

Type:
  • Array.<number>
Overrides:

# scale :Array.<number>

The local scale of the pawn relative to its parent. The value is a 3D vector. This is the interpolated value. If you want the actor's true value, use this.actor.scale.

Type:
  • Array.<number>
Overrides:

# tug :number

A value ranging from 0 to 1 that determines how quickly the pawn will converge on the actor's position during interpolation. If it's set to 0, the pawn will never move at all. If the tug is set to 1, the pawn will snap to the actor's current position every frame.

A pawn's tug is a trade-off between smoothness and responsiveness. Higher tug values converge faster, but also more jittery, and vice versa.

Note: If pawns are arranged in a hierachy in the scene graph, the children will use the tug of their parents. (Mixing different tug values leads to jitter.)

Type:
  • number
Example:
class SmoothedPawn extends mix(Pawn).with(PM_Smoothed) {
      constructor(...args) {
          super(...args);
          this.tug = 0.02. // Converge slowly.
      }
}

# local :Array.<number>

The local 4x4 transformation matrix. This is the pawn's transform relative to its parent, and is derived from its translation, rotation, and scale. This value is read directly from the spatial pawn's actor.

Type:
  • Array.<number>
Inherited From:

# global :Array.<number>

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

Type:
  • Array.<number>
Inherited From:

# lookGlobal :Array.<number>

By default, this is the same as global. However you can override it if you want to add an additional transform for a camera attached to the pawn. (For example, first-person avatars should override lookGlobal to let the user look up and down without changing the pawn's facing.)

Type:
  • Array.<number>
Inherited From:

# parent :Pawn

The parent of the pawn in the hierarchical tree. This is the pawn associated with the parent of this pawn's actor. This property is updated automatically, when the actor's parent changes.

Type:
Inherited From:
Example:
if (treePawn.parent.actor === treePawn.actor.parent ) {console.log("Always true!")};

Methods

# update(time, delta)

Called every frame by ViewRoot. Overload this to create your pawn's custom update.

Parameters:
Name Type Description
time number

The view time in milliseconds of the current frame.

delta number

The elapsed time in milliseconds since the previous frame.

Inherited From:

# preUpdate(time, delta)

Called every frame by ViewRoot right before update(). Use this only for operations that must occur before everything else.

Parameters:
Name Type Description
time number

The view time in milliseconds of the current frame.

delta number

The elapsed time in milliseconds since the previous frame.

Inherited From:

# postUpdate(time, delta)

Called every frame by ViewRoot right after update(). Use this only for operations that must occur after everything else.

Parameters:
Name Type Description
time number

The view time in milliseconds of the current frame.

delta number

The elapsed time in milliseconds since the previous frame.

Inherited From: