Class: core/PointOfInterestFeature

core/PointOfInterestFeature(host, optionsopt, targetopt, lookOptionsopt, blinkOptionsopt)

PointOfInterest controls the gaze direction of the host. Given one or more
animations of type Blend2dState, it calculates the angles between the lookTracker
object (generally a joint in the host's skeleton) and the lookTarget (the object
the host should look at) and drives the managed Blend2dStates' X and Y blend
values using the result. You can optionally add saccadic movement to any managed
animation to help make the host's eyes appear alive when focused on the same
point for exteded periods of time. If blink animations are specified, a blink
will be played during large changes in gaze direction.

Constructor

new core/PointOfInterestFeature(host, optionsopt, targetopt, lookOptionsopt, blinkOptionsopt)

Parameters:
Name Type Attributes Description
host core/HostObject

Host that owns the feature.

options Object <optional>

Options for the feature.

target Object <optional>

3D transformation node that the host should try to
look at.

options.lookTracker Object

3D transformation node that represents
the direction the host is currently looking during animation.

options.scene Object <optional>

Engine-specific scene object that contains
the host. This object must be defined if using 'setTargetByName' or 'SetTargetById'
methods.

lookOptions Object <optional>

Options for the look animation layers.

Properties
Name Type Attributes Default Description
blendTime number <optional>
0.1

Default amount of time it will
take to manipulate the weights of the look layers.

easingFn number <optional>
Quadratic.InOut

Default easing function
to use when manipulating look layer weights.

layers Array.<Object> <optional>
[]

An array of layer options
objects to register as look layers.

blinkOptions Object <optional>

Options for the blink animation layers.

Properties
Name Type Attributes Default Description
blendTime number <optional>
0.075

Default amount of time it
will take to manipulate the weights of the blink layers.

easingFn number <optional>
Quadratic.InOut

Default easing function
to use when manipulating blink layer weights.

layers Array.<Object> <optional>
[]

An array of layer options
objects to register as blink layers.

Implements:

Extends

Members

(readonly) host

Gets the host that manages the feature.

Overrides:

(readonly) owner

Gets the engine owner object of the host.

Overrides:

target :Object|null

Gets and sets the target object the host should look at.

Type:
  • Object | null

Methods

(static) _sphericalToBlendValue(theta, phi) → {Object}

Calculate horizontal and vertical look angles in degrees given spherical theta
and phi angles in radians.

Parameters:
Name Type Description
theta number

Vertical/polar angle in radians where 0 points directly
along positive Y axis.

phi number

Horizontal/azimuthal angle in radians.

Returns:
  • An object with the signature {h: number, v: number} where
    h represents horizontal rotation in degrees and v represents vertical rotation
    in degrees.
Type
Object

discard()

Clean up once the feature is no longer in use. Remove the feature namespace
from the host and remove reference to the host.

Overrides:
Implements:

emit(message, valueopt)

Emit feature messages from the host. Feature messages will be prefixed with
the class name of the feature.

Parameters:
Name Type Attributes Description
message string

The message to emit.

value any <optional>

Optional parameter to pass to listener callbacks.

Overrides:

installApi()

Adds a namespace to the host with the name of the feature to contain properties
and methods from the feature that users of the host need access to.

Overrides:

listenTo(message, callback)

Listen to a feature message from the host object.

Parameters:
Name Type Description
message string

Message to listen for.

callback function

The callback to execute when the message is received.

Overrides:

registerBlinkLayer(layerName, optionsopt)

Start keeping track of an animation layer that owns a blink animation. Blink
animations can be of any type, but if it is of type randomAnimation then a
it will be randomized each time a blink is called.

Parameters:
Name Type Attributes Description
layerName string

Name of the layer to keep track of.

options Object <optional>

Options for the layer.

Properties
Name Type Attributes Default Description
animation string <optional>
'blink'

Name of the blink animation
on the layer.

blendTime number <optional>
PointOfInterestFeature.DEFAULT_LAYER_OPTIONS.blendTime

Default amount of time to use when manipulating the layer's weight.

easingFn function <optional>

Default easing function to use when
manipulating the layer's weight.

registerLookLayer(layerName, optionsopt)

Start keeping track of an animation layer that owns a blend2d animation with
blendWeights corresponding to horizontal and vertical look angles.

Parameters:
Name Type Attributes Description
layerName string

Name of the layer to keep track of.

options Object <optional>

Options for the layer.

Properties
Name Type Attributes Default Description
animation string <optional>
'look'

Name of the animation on the
layer whose blendWeights will be driven based on the angle between the lookTracker
and the lookTarget. This animation must be of type blend2d.

maxSpeed number <optional>
25

The maximum speed at which the blend2d
blendWeights can be manipulated.

forwardAxis string <optional>
'PositiveZ'

Axis pointing from the
front of the lookReference object. Valid options are 'PositiveX', 'NegativeX',
'PositiveY', 'NegativeY', 'PositiveZ', 'NegativeZ'.

lookReference Object <optional>

3D transformation node that the lookTracker
rotation limits should be calculated relative to. Defaults to the host owner.

hasSaccade number <optional>
false

Whether or not to include
saccadic motion onto the blendWeight animation. This should only be set to
true for blend2d animations representing eye animation.

blendTime number <optional>
PointOfInterestFeature.DEFAULT_LAYER_OPTIONS.blendTime

Default amount of time to use when manipulating layer weight.

easingFn function <optional>

Default easing function to use when
manipulating layer weight.

setTarget(target)

Sets a new target to look at.

Parameters:
Name Type Description
target Object | null

The new target to look at.

setTargetById(target)

Finds an object given its id and sets it as the new target to look at.
Should be overloaded for each rendering engine implementation.

Parameters:
Name Type Description
target string | number

Id to search for.

setTargetByName(target)

Finds an object given its name and sets it as the new target to look at.
Should be overloaded for each rendering engine implementation.

Parameters:
Name Type Description
target string

Name to search for.

stopListening(message, callbackopt)

Stop listening to a message from the host object.

Parameters:
Name Type Attributes Description
message string

Message to stop listening for.

callback function <optional>

Optional callback to remove. If none is defined,
remove all callbacks for the message.

Overrides:

stopListeningByRegexp(regexp, callbackopt)

Stop listening to a message matching the given regular expression from the
host object.

Parameters:
Name Type Attributes Description
regexp Regexp

The regular expression to stop listening for.

callback function <optional>

Optional callback to remove. If none is defined,
remove all callbacks for the message.

Overrides:

stopListeningToAll()

Stop listening to all messages.

Overrides:

update(deltaTime)

Executes each time the host is updated.

Parameters:
Name Type Description
deltaTime number

Amount of time since the last host update was
called.

Overrides: