Behavior

altspace/utilities/behaviors. Behavior

Base class for all behaviors. Use this class as a pattern, but do not use directly.

Constructor

new Behavior()

Members

type :string

The string name of this class. This is used for THREE.Object3D#getBehaviorByType.

Methods

awake(obj, scene)

Called when the behavior is attached to an object. Any setup that requires the object should be done here, e.g. adding event listeners.

Parameters:
Name Type Description
obj Object3D

The new parent object

scene Scene

The scene the object is a member of

dispose(obj)

Called when the behavior is removed from its object. Clean up your event handlers, etc. here.

Parameters:
Name Type Description
obj Object3D

The object this behavior was once attached to

start()

Called when the behavior is ready to start. This is guaranteed to run after all behaviors are awake. Any setup that requires interdependence on other behaviors or objects should be done here.

update(deltaTime)

Called every frame after awake/start. Run anything that needs to happen over time here, e.g. animations.

Parameters:
Name Type Description
deltaTime integer

The number of milliseconds elapsed since the last update