Class: Curve

pc.Curve

A curve is a collection of keys (time/value pairs). The shape of the curve is defined by its type that specifies an interpolation scheme for the keys.

Constructor

new Curve(dataopt)

Creates a new curve.
Parameters:
Name Type Attributes Description
data Array.<Number> <optional>
An array of keys (pairs of numbers with the time first and value second)
Properties:
Name Type Description
length Number The number of keys in the curve. [read only]
Source:

Methods

add(time, value) → {Array.<Number>}

Add a new key to the curve.
Parameters:
Name Type Description
time Number Time to add new key
value Number Value of new key
Source:
Returns:
[time, value] pair
Type
Array.<Number>

clone() → {pc.Curve}

Returns a clone of the specified curve object.
Source:
Returns:
A clone of the specified curve
Type
pc.Curve

get(index) → {Array.<Number>}

Return a specific key.
Parameters:
Name Type Description
index Number The index of the key to return
Source:
Returns:
The key at the specified index
Type
Array.<Number>

(private) quantize(precision) → {Array}

Sample the curve at regular intervals over the range [0..1]
Parameters:
Name Type Description
precision Number The number of samples to return.
Source:
Returns:
The set of quantized values.
Type
Array

(private) quantizeClamped(precision, min, max) → {Array}

Sample the curve at regular intervals over the range [0..1] and clamp the resulting samples to [min..max].
Parameters:
Name Type Description
precision Number The number of samples to return.
min Number The minimum output value.
max Number The maximum output value.
Source:
Returns:
The set of quantized values.
Type
Array

sort()

Sort keys by time.
Source:

value(time) → {Number}

Returns the interpolated value of the curve at specified time.
Parameters:
Name Type Description
time Number The time at which to calculate the value
Source:
Returns:
The interpolated value
Type
Number