Optionalcurves: [Bezier, number][]The pieces as [function, startX], sorted by start; the first starts at 0.
Always 'function'.
Static ReadonlyTABLE_Sample count of the table built by refreshTable.
Drops the sampled table, so later reads go back to evaluating the curve.
A copy with its own pieces.
The index of the piece t falls in, or -1 when t is outside [0, 1] or there are no pieces.
The curve's value at t, clamped to the ends outside [0, 1]: from the sampled table when
PiecewiseBezier.refreshTable has built one, from the curve otherwise.
Optionalt: numberEvaluates the curve itself, ignoring any sampled table.
The x where piece index ends: the next piece's start, or 1 for the last.
The x where piece index starts.
Inserts func as a piece starting at t, after the pieces that start at or before it, so the
pieces stay sorted. t is clamped to [0, 1].
Rebuilds the sampled table when the curve changed, otherwise does nothing.
Evaluating this curve means a piece lookup plus a cubic; a particle system does that once per particle per frame. Sampling it once and interpolating costs two loads and a lerp instead. Sampling error at PiecewiseBezier.TABLE_SIZE points stays around 1e-5 for the shapes a curve editor produces — far below what a colour or a size can show.
The curve is public and mutable (a curve editor writes straight into
functions and a Bezier's p), so this compares the control points
against the ones the table was built from and only resamples on a real
change. That is a handful of float compares per frame.
The sampled table genValue currently reads from, or null while none has been built. Lets a compiled behavior pass interpolate the table inline instead of calling in here once per particle.
Moves the end of piece index, the next piece's start; the last piece always ends at 1, so
it is ignored there.
Moves the start of piece index; the first piece always starts at 0, so index 0 is ignored.
The JSON form, {type: 'PiecewiseBezier', functions: [{function, start}]}.
An SVG path d attribute drawing the curve over x in [0, length] with segments straight
segments; empty below one segment.
Staticfrom
A curve made of cubic Bezier segments, each starting at its own time in [0, 1]: Unity's animation curve. Sampled through a table of PiecewiseBezier.TABLE_SIZE values.