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>
This commit is contained in:
1 parent
e7a360db73
commit
297fca3e94
8 files changed
+50
-12
No files matched your search
@@ -113,6 +113,11 @@ export interface NodeDef {
|
||||
* still offers them. Without it a switched-off repeat is two rows of "0" on every key node.
|
||||
*/
|
||||
hiddenParams?(params: PropertyBag): string[];
|
||||
/**
|
||||
* Settings that do nothing at this value set, so neither the node body nor the inspector shows
|
||||
* them – like the Direction of a linear key. Unlike `hiddenParams`, nothing is left to pick there.
|
||||
*/
|
||||
idleParams?(params: PropertyBag): string[];
|
||||
/**
|
||||
* Which side the ports this node declares for itself (`GraphNode.ports`) appear on. Setting it
|
||||
* is what gives a node the port editor in the inspector. `both`: every port is an output, and an
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { NodeDef } from '../../NodeRegistry';
|
||||
import { asNumber } from '../../values';
|
||||
import { curvesOf, easingOfParams, easingParams, hiddenEasing } from '../easing';
|
||||
import { curvesOf, easingOfParams, easingParams, idleEasing } from '../easing';
|
||||
import { exec, num } from '../shared';
|
||||
import { fxParamsOf } from './PlaySound';
|
||||
|
||||
@@ -30,7 +30,7 @@ export const SetSoundFxParameters: NodeDef = {
|
||||
],
|
||||
outputs: [exec()],
|
||||
params: easingParams(),
|
||||
hiddenParams: hiddenEasing,
|
||||
idleParams: idleEasing,
|
||||
run: (ctx, inputs, params, _def, _entry, lookup) => {
|
||||
const voice = asNumber(inputs.voice);
|
||||
const time = asNumber(inputs.time);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { NodeDef } from '../../NodeRegistry';
|
||||
import { asNumber } from '../../values';
|
||||
import { curvesOf, easingOfParams, easingParams, hiddenEasing } from '../easing';
|
||||
import { curvesOf, easingOfParams, easingParams, idleEasing } from '../easing';
|
||||
import { num, withDefault } from '../shared';
|
||||
|
||||
import { easedShare } from '../../../model/animation';
|
||||
@@ -17,7 +17,7 @@ export const Lerp: NodeDef = {
|
||||
inputs: [withDefault(num('a'), 0), withDefault(num('b'), 1), withDefault(num('t'), 0)],
|
||||
outputs: [num('result')],
|
||||
params: easingParams(),
|
||||
hiddenParams: hiddenEasing,
|
||||
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);
|
||||
|
||||
@@ -39,8 +39,8 @@ export function easingOfParams(params: PropertyBag): KeyInterpolation {
|
||||
return easingValue(shape, direction, textOf(params[LERP_CURVE] ?? ''));
|
||||
}
|
||||
|
||||
/** The settings that say nothing for this easing, for `hiddenParams`. */
|
||||
export function hiddenEasing(params: PropertyBag): string[] {
|
||||
/** The settings that do nothing for this easing, for `idleParams` – what a key leaves out, too. */
|
||||
export function idleEasing(params: PropertyBag): string[] {
|
||||
const { shape, direction } = easingOf(easingOfParams(params));
|
||||
return [...(direction ? [] : [DIRECTION]), ...(shape === 'curve' ? [] : [LERP_CURVE])];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user