Files
feuerwerk/src/core/graph/nodes/data/Lerp.ts
T
adminandClaude Opus 5.5 297fca3e94 Show Direction and Curve of a node only where they matter
An animation key shows Direction only for one of the ten curves and
the Curve row only for Curve. Lerp and Set sound FX parameters hid
them on the node body, but the inspector still offered both rows for
every easing, so a linear Lerp had a Direction to pick that did
nothing.

- A node definition can name `idleParams`: settings that do nothing
  at the current values. The node body and the inspector both leave
  them out.
- `hiddenParams` stays as it was. It only trims the node body, the
  inspector keeps those rows (the Order of an event, the mode of
  Find), so it could not take this job.
- Lerp and Set sound FX parameters use `idleEasing` (formerly
  `hiddenEasing`) for it.
- The idle settings are part of the node signature of the inspector.
  Picking an easing that needs Direction or Curve rebuilds the
  section, and the row appears.

Tests:
- easing-curves: 14 tests (+1), node-catalog: 381, green
- e2e 06 (149 checks, green) checks that a new linear Lerp has no
  Direction and no Curve row in the inspector. Picking Cubic brings
  the Direction row, and Out is picked there as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 22:15:15 +02:00

28 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { NodeDef } from '../../NodeRegistry';
import { asNumber } from '../../values';
import { curvesOf, easingOfParams, easingParams, idleEasing } from '../easing';
import { num, withDefault } from '../shared';
import { easedShare } from '../../../model/animation';
import { LERP } from '../../../model/curve';
export const Lerp: NodeDef = {
type: LERP,
label: 'Lerp',
category: 'data',
description:
'Blends from a to b as t runs from 0 to 1, along the chosen easing – the same ones an animation ' +
'key offers. t is held in 0…1. Step stays at a until t reaches 1. Back, Elastic and a Curve ' +
'asset may overshoot b.',
inputs: [withDefault(num('a'), 0), withDefault(num('b'), 1), withDefault(num('t'), 0)],
outputs: [num('result')],
params: easingParams(),
idleParams: idleEasing,
run: (_ctx, inputs, params, _def, _entry, lookup) => {
const a = asNumber(inputs.a);
const t = Math.min(Math.max(asNumber(inputs.t), 0), 1);
const share = easedShare(easingOfParams(params), t, curvesOf(lookup));
return { outputs: { result: a + (asNumber(inputs.b) - a) * share } };
},
};