Skip to content
cjcliffe edited this page Nov 28, 2011 · 9 revisions

CubicVR.Envelope

The Envelope class provides a generic way to create and evaluate simple or complex curves. It's primary use is in conjunction with a Motion controller to animate a SceneObject, Light or Camera in a Scene but can be used on it's own.

Constructor:

Envelope( init )

Parameters:

init - This can be undefined or an object constructor.

Object Constructor:

  • init
    • in_behavior : Input behavior (before envelope start) from enums for this curve, default: "constant".
    • out_behavior : Output behavior (after envelope end) from enums for this curve, default: "constant".
      • "reset" : reset to 0
      • "constant" : maintain values
      • "repeat" : repeat
      • "oscillate" : oscillate or "ping-pong"
      • "offset" : offset repeat (accumulate loop offsets)
      • "linear" : continue indefinitely at the incoming/outing tangents

Methods:

addKey( time, value, key_init ) or addKey( key_init )

Add a new key frame to the Envelope.

Parameters:

  • time : Time of keyframe to insert.
  • value : Value of key.
  • key_init (optional) : An object constructor representing the new key structure/options.
    • time: Time of keyframe to insert.
    • value: Value of key.
    • shape: one of the following enums, default "tcb":
      • "tcb" : Tension / Continuity / Bias
      • "herm" : Hermite
      • "bez2" : 2D Bezier
      • "line" : Linear
      • "step" : Step (constant)
      • "bezi" : 1D Bezier
    • tension: If using TCB shape, tension value.
    • continuity: If using TCB shape, continuity value.
    • bias: If using TCB shape, bias value.
    • param: Parameters for HERM and BEZ2. X/Y tangent pairs in relative offsets, format: [inTime, inValue, outTime, outValue].

Returns:

The inserted key, structure matches key_init for setting properties.

evaluate( time )

Evaluate the envelope, interpolate and return the value at the given time index.

Parameters:

time - Time (or X value) to evaluate.

Returns:

Value of envelope at given time.

empty()

Checks if the Envelope has any keys.

Returns:

true if the Envelope has no keys, false otherwise.

Clone this wiki locally