Skip to content
🎉 Angular Three v4 is here! Read the announcement

Curve Editor

angular-three-tweakpane/curve provides a Tweakpane curve editor without depending on Ecctrl. Its data is structurally compatible with Ecctrl curve data, so the same authored curve can be passed to an Ecctrl curve consumer after normalization.

ExportPurpose
TweakpaneCurveThe curve-editor directive. Its selector is tweakpane-curve.
TweakpaneCurveApiImperative Tweakpane curve API.
TWEAKPANE_CURVE_PLUGINThe public Tweakpane plugin export.
normalizeCurveDataNormalizes user-authored or persisted curve data for the editor.
TweakpaneCurveData / TweakpaneCurvePointThe editor’s public curve-data and point shapes.
TweakpaneCurveParamsDomain and range bounds: minX, maxX, minY, and maxY.
TweakpaneCurveApiEventsPublic event map for the curve API.

The required value model is the curve data. label labels the Tweakpane control, and params supplies optional minX, maxX, minY, and maxY bounds. Place the editor in a Tweakpane pane or folder.

import { Component, signal } from '@angular/core';
import { TweakpanePane } from 'angular-three-tweakpane';
import {
TweakpaneCurve,
normalizeCurveData,
type TweakpaneCurveData,
type TweakpaneCurveParams,
} from 'angular-three-tweakpane/curve';
@Component({
template: `
<tweakpane-pane title="Grip curve">
<tweakpane-curve
label="Longitudinal grip"
[params]="params"
[value]="curve()"
(valueChange)="curve.set($event)"
/>
</tweakpane-pane>
`,
imports: [TweakpaneCurve, TweakpanePane],
})
export class CurveEditor {
readonly params: TweakpaneCurveParams = { minX: 0, maxX: 1, minY: 0, maxY: 1 };
readonly curve = signal<TweakpaneCurveData>(
normalizeCurveData({
points: [
{ x: 0, y: 0, r_out: Math.PI / 4, w_out: 0.55 },
{ x: 1, y: 1, r_in: -Math.PI / 6, w_in: 0.4 },
],
}),
);
}

Points are draggable. Each point can also have incoming and outgoing tangent handles:

FieldMeaning
r_in / r_outIncoming and outgoing tangent angles, in radians.
w_in / w_outIncoming and outgoing tangent weights.

Drag a tangent handle to author its angle and weight. Double-click the graph to add a point; use Delete, Backspace, or the context menu to remove one.

TweakpaneCurveApi.value is a getter/setter for the current curve value. Subscribe with on('change', listener) and unsubscribe with off('change', listener). A change listener receives { value, last }, where last indicates the final event in an interaction.

The selector and CSS class names use the tweakpane-* prefix.

See the curve editor example.