Play animation can blend into the new animation over a number of frames (#106)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
beeea355d9
commit
04dc254b3d
4 files changed
+177
-14
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { pauseAnimation, playAnimation, stopAnimation } from '../../../model/animation';
|
||||
import type { NodeDef, PortDef } from '../../NodeRegistry';
|
||||
import { asEntity, asString } from '../../values';
|
||||
import { exec, obj } from '../shared';
|
||||
import { asEntity, asNumber, asString } from '../../values';
|
||||
import { exec, num, obj, withDefault } from '../shared';
|
||||
|
||||
/**
|
||||
* The `animation` input of the three animation nodes; unconnected it shows the animation picker, the
|
||||
@@ -21,14 +21,15 @@ export const PlayAnimation: NodeDef = {
|
||||
description:
|
||||
'Plays an animation on an object: its rows reach the object and what is placed inside it, so every ' +
|
||||
'instance plays on its own. A paused one runs on from where it stands; one already running keeps its ' +
|
||||
'frame but wins again over the others on the object.',
|
||||
inputs: [exec(), obj('object'), animationPort()],
|
||||
'frame but wins again over the others on the object. Blend fades numbers and colours over that many ' +
|
||||
'of its frames from what they held when it took over; everything else switches at once.',
|
||||
inputs: [exec(), obj('object'), animationPort(), withDefault(num('blend', 'blend (frames)'), 0)],
|
||||
outputs: [exec()],
|
||||
params: [],
|
||||
run: (_ctx, inputs) => {
|
||||
const target = asEntity(inputs.object);
|
||||
const animation = asString(inputs.animation);
|
||||
if (target && animation) playAnimation(target, animation);
|
||||
if (target && animation) playAnimation(target, animation, Math.max(0, asNumber(inputs.blend)));
|
||||
return { next: 'exec' };
|
||||
},
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user