Add nodes that ask whether an animation still runs (#233)
A graph could start, pause and stop an animation and hear it finish, but it could not ask in between whether one runs or how far it is. Two data nodes answer that now. - Animation playing takes an object and an animation and gives playing, progress and time left (s). It answers at the moment it is read: right after Play animation in the same pass it says on, and in the frame On animation finished fires it says off. - With Animation at None it answers for the running animation started last on the object. - Animation length gives the seconds of one pass, from the timeline and the frame rate alone. - The rule is a pure function in src/core/model/animation.ts (playerStatus, leadingPlayer). The nodes reach an animation's length through a new field animation on GraphLookup. - animationPort is exported so both nodes show the same picker as Play animation. Decided in the issue: a Once (reset) counts as running while it blends out, and progress and time left also hold for Loop and Ping-pong, at the place of the playhead. On Ping-pong progress falls again on the way back and time left counts to the next turn. Decided here, the issue says nothing on it: - A paused animation does not count as running. Progress and time left stand still. - One that Stop animation fades out does not count as running, and its time left is 0. - Time left of a Once (reset) includes its blend out. While it blends out progress is 1 and time left is the rest of the fade. Finding, not fixed: on the node the name of the chosen animation overlaps the output label progress in the same row. That comes from the fixed node width in NodeView and was seen in the Fit view only. Tests: - Gate: 198 files, 2903 tests (2891 + 12), exit 0 - e2e 1-6: 282 checks passed, 06 has +2 for block 6z-ix - Nine unit counter-probes fail, 1 to 4 tests each - The browser counter-probe fails 6z-ix with ["false","false"] - e2e total 1615 is computed, not measured in a full run. The smokes were not run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
26cc6324af
commit
c1cc80bb45
11 files changed
+437
-4
No files matched your search
@@ -100,6 +100,23 @@ const at = (name: string, x: number, y: number) => ({ ...fakeEntity(name), x, y
|
||||
const emitTarget = fakeEntity('Sparks');
|
||||
/** Their own entity each: the animation nodes leave players on the object they are handed. */
|
||||
const dancer = fakeEntity('Dancer');
|
||||
/** An object whose once-reset "swing" has run out and blends back over half a second (#233). */
|
||||
const swinging = {
|
||||
...fakeEntity('Fighter'),
|
||||
animations: [
|
||||
{
|
||||
animationId: 'swing',
|
||||
time: 1,
|
||||
playing: true,
|
||||
order: 1,
|
||||
fade: { seconds: 0.5, elapsed: 0, ended: true },
|
||||
},
|
||||
],
|
||||
};
|
||||
const swingLookup: GraphLookup = {
|
||||
...NO_LOOKUP,
|
||||
animation: (id) => (id === 'swing' ? { frames: 10, fps: 10, playback: 'once-reset' } : null),
|
||||
};
|
||||
const packed = fakeEntity('Player');
|
||||
const painted = fakeHandle({ width: 100, text: '' });
|
||||
|
||||
@@ -278,6 +295,41 @@ const CASES: Record<string, Case[]> = {
|
||||
outputs: { width: 0, height: 0 },
|
||||
},
|
||||
],
|
||||
AnimationPlaying: [
|
||||
{
|
||||
name: 'a once-reset pass blending out still runs, for as long as its blend out lasts (#233)',
|
||||
inputs: { object: swinging, animation: 'swing' },
|
||||
lookup: swingLookup,
|
||||
outputs: { playing: true, progress: 1, timeLeft: 0.5 },
|
||||
},
|
||||
{
|
||||
name: 'with no animation named answers for what runs on the object',
|
||||
inputs: { object: swinging, animation: '' },
|
||||
lookup: swingLookup,
|
||||
outputs: { playing: true, progress: 1, timeLeft: 0.5 },
|
||||
},
|
||||
{
|
||||
name: 'another animation is not playing',
|
||||
inputs: { object: swinging, animation: 'walk' },
|
||||
lookup: swingLookup,
|
||||
outputs: { playing: false, progress: 0, timeLeft: 0 },
|
||||
},
|
||||
{
|
||||
name: 'no object plays nothing',
|
||||
inputs: { object: null, animation: '' },
|
||||
lookup: swingLookup,
|
||||
outputs: { playing: false, progress: 0, timeLeft: 0 },
|
||||
},
|
||||
],
|
||||
AnimationLength: [
|
||||
{
|
||||
name: 'one pass in seconds: ten frames at 10 fps',
|
||||
inputs: { animation: 'swing' },
|
||||
lookup: swingLookup,
|
||||
outputs: { seconds: 1 },
|
||||
},
|
||||
{ name: 'no animation is 0', inputs: { animation: '' }, outputs: { seconds: 0 } },
|
||||
],
|
||||
CurrentState: [
|
||||
{
|
||||
name: 'names the state the machine is in, and hands out its id as well',
|
||||
|
||||
Reference in new issue
Block a user