@pixerate/editor 0.68.0 → 0.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation-editor/index.cjs +230 -46
- package/dist/animation-editor/index.cjs.map +1 -1
- package/dist/animation-editor/index.d.cts +66 -3
- package/dist/animation-editor/index.d.ts +66 -3
- package/dist/animation-editor/index.js +186 -2
- package/dist/animation-editor/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -56,6 +56,7 @@ import {
|
|
|
56
56
|
|
|
57
57
|
// src/animation-editor/types.ts
|
|
58
58
|
var MOTION_TRIGGERS = ["click", "hover", "press", "scroll"];
|
|
59
|
+
var MOTION_CLIP_TARGET = "$";
|
|
59
60
|
var MOTION_COMMAND_TYPES = [
|
|
60
61
|
"enter",
|
|
61
62
|
"exit",
|
|
@@ -67,6 +68,7 @@ var MOTION_COMMAND_TYPES = [
|
|
|
67
68
|
"style",
|
|
68
69
|
"morph",
|
|
69
70
|
"match",
|
|
71
|
+
"play",
|
|
70
72
|
"follow",
|
|
71
73
|
"pulse",
|
|
72
74
|
"shake",
|
|
@@ -94,6 +96,8 @@ var MOTION_DEFAULT_DURATIONS = {
|
|
|
94
96
|
style: 500,
|
|
95
97
|
morph: 900,
|
|
96
98
|
match: 900,
|
|
99
|
+
/** A clip's length comes from its commands (this is only a fallback). */
|
|
100
|
+
play: 600,
|
|
97
101
|
follow: 1400,
|
|
98
102
|
pulse: 600,
|
|
99
103
|
shake: 500,
|
|
@@ -137,6 +141,7 @@ var MOTION_ISSUE_CODES = {
|
|
|
137
141
|
"unknown-path": { severity: "error", wording: "A follow command names a path the artwork does not have." },
|
|
138
142
|
"not-a-path": { severity: "error", wording: "A follow path must be a path node, not a group." },
|
|
139
143
|
"reveal-no-box": { severity: "warning", wording: "A wipe, iris or split cannot clip a node with no width or height (a lone straight line), so it fades instead." },
|
|
144
|
+
"unknown-clip": { severity: "error", wording: "A play command names a clip the scene does not have." },
|
|
140
145
|
"unknown-shape": { severity: "error", wording: "A morph names a shape the artwork does not have." },
|
|
141
146
|
"match-self": { severity: "error", wording: "A match turns a group into itself or into a group it holds (or that holds it)." },
|
|
142
147
|
"match-unpaired": { severity: "note", wording: `Parts of a match's "into" group have no partner in the target, so they do not appear.` },
|
|
@@ -214,7 +219,7 @@ ${problems.map((p) => `- ${p}`).join("\n")}`);
|
|
|
214
219
|
this.problems = problems;
|
|
215
220
|
}
|
|
216
221
|
};
|
|
217
|
-
var SCENE_KEYS = ["version", "name", "description", "artwork", "shots", "loop", "trigger", "fps", "steps", "beat", "narration", "target", "controls", "presets"];
|
|
222
|
+
var SCENE_KEYS = ["version", "name", "description", "artwork", "shots", "clips", "loop", "trigger", "fps", "steps", "beat", "narration", "target", "controls", "presets"];
|
|
218
223
|
var SHOT_KEYS = ["id", "label", "camera", "at", "run", "hold", "speed"];
|
|
219
224
|
var CAMERA_KEYS = ["x", "y", "width", "height", "frame", "padding", "ease", "ms", "geometric"];
|
|
220
225
|
var BASE_KEYS = ["type", "targets", "duration", "delay", "stagger", "with", "ease", "note", "repeat", "repeatMode", "steps"];
|
|
@@ -229,6 +234,7 @@ var COMMAND_KEYS = {
|
|
|
229
234
|
style: [...BASE_KEYS, "fill", "stroke", "strokeWidth"],
|
|
230
235
|
morph: [...BASE_KEYS, "into"],
|
|
231
236
|
match: [...BASE_KEYS, "into"],
|
|
237
|
+
play: ["type", "targets", "delay", "stagger", "with", "note", "clip", "speed"],
|
|
232
238
|
follow: [...BASE_KEYS, "path", "rotate", "from", "to"],
|
|
233
239
|
pulse: [...BASE_KEYS, "amount", "count", "blend"],
|
|
234
240
|
shake: [...BASE_KEYS, "amount", "count", "axis", "blend"],
|
|
@@ -326,6 +332,10 @@ function commandShapeProblems(command2, where) {
|
|
|
326
332
|
if (command2.stroke !== void 0 && typeof command2.stroke !== "string") p(`"stroke" must be a CSS colour.`);
|
|
327
333
|
if (command2.strokeWidth !== void 0 && !(isNum(command2.strokeWidth) && command2.strokeWidth >= 0)) p(`"strokeWidth" must be a number \u2265 0.`);
|
|
328
334
|
break;
|
|
335
|
+
case "play":
|
|
336
|
+
if (typeof command2.clip !== "string" || !command2.clip) p(`"clip" must be the name of one of the scene's clips.`);
|
|
337
|
+
if (command2.speed !== void 0 && !(isNum(command2.speed) && command2.speed >= 0.05 && command2.speed <= 20)) p(`"speed" must be a number from 0.05 to 20 (2 plays the clip twice as fast).`);
|
|
338
|
+
break;
|
|
329
339
|
case "morph":
|
|
330
340
|
case "match":
|
|
331
341
|
if (typeof command2.into !== "string" || !command2.into) p(`"into" must be the id of a ${type === "match" ? "group to become" : "node whose shape to take"}.`);
|
|
@@ -363,6 +373,25 @@ function commandShapeProblems(command2, where) {
|
|
|
363
373
|
}
|
|
364
374
|
return problems;
|
|
365
375
|
}
|
|
376
|
+
function clipsShapeProblems(clips) {
|
|
377
|
+
if (!isObject(clips)) return ['Scene: "clips" must be an object of named clips { "pop": { "run": [ \u2026 ] } }.'];
|
|
378
|
+
const problems = [];
|
|
379
|
+
for (const [name, clip] of Object.entries(clips)) {
|
|
380
|
+
const where = `Clip "${name}"`;
|
|
381
|
+
if (!/^[A-Za-z_][\w-]*$/.test(name)) problems.push(`${where}: a clip name is letters, digits, "_" or "-" (e.g. "pop-in").`);
|
|
382
|
+
if (!isObject(clip) || !Array.isArray(clip.run)) {
|
|
383
|
+
problems.push(`${where} must be { "description"?, "run": [commands] }.`);
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
unknownKeys(clip, ["description", "run"], where, problems);
|
|
387
|
+
if (clip.description !== void 0 && typeof clip.description !== "string") problems.push(`${where}: "description" must be a string.`);
|
|
388
|
+
clip.run.forEach((command2, i) => {
|
|
389
|
+
if (isObject(command2) && command2.type === "play") problems.push(`${where}, command ${i + 1}: a clip cannot play another clip; copy its commands in instead.`);
|
|
390
|
+
else problems.push(...commandShapeProblems(command2, `${where}, command ${i + 1}`));
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
return problems;
|
|
394
|
+
}
|
|
366
395
|
function shotShapeProblems(shot, where) {
|
|
367
396
|
if (!isObject(shot)) return [`${where} must be an object.`];
|
|
368
397
|
const problems = [];
|
|
@@ -410,6 +439,7 @@ function motionSceneShapeProblems(input) {
|
|
|
410
439
|
const art = input.artwork;
|
|
411
440
|
if (!isObject(art) || !isNum(art.width) || !isNum(art.height) || !(art.width > 0) || !(art.height > 0) || !Array.isArray(art.nodes))
|
|
412
441
|
problems.push('Scene: "artwork" must be a vector document { width, height, nodes }.');
|
|
442
|
+
if (input.clips !== void 0) problems.push(...clipsShapeProblems(input.clips));
|
|
413
443
|
if (input.trigger !== void 0 && !MOTION_TRIGGERS.includes(input.trigger)) problems.push(`Scene: "trigger" must be one of ${MOTION_TRIGGERS.join(", ")}.`);
|
|
414
444
|
if (input.loop !== void 0 && !["none", "loop", "ping-pong"].includes(input.loop)) problems.push('Scene: "loop" must be "none", "loop" or "ping-pong".');
|
|
415
445
|
if (input.fps !== void 0 && !(isNum(input.fps) && input.fps > 0 && input.fps <= 120)) problems.push('Scene: "fps" must be a number from 1 to 120.');
|
|
@@ -793,8 +823,38 @@ function motionCommandRepeat(command2) {
|
|
|
793
823
|
function motionCommandDuration(command2, scene, target) {
|
|
794
824
|
return motionCycleDuration(command2, scene, target) * motionCommandRepeat(command2);
|
|
795
825
|
}
|
|
826
|
+
function motionClipLayout(scene, clip, target, speed = 1) {
|
|
827
|
+
const run = scene.clips?.[clip]?.run;
|
|
828
|
+
if (!run) return { items: [], length: 0 };
|
|
829
|
+
const f = speed > 0 && Number.isFinite(speed) ? 1 / speed : 1;
|
|
830
|
+
const items = [];
|
|
831
|
+
let runEnd = 0;
|
|
832
|
+
let prevStart = 0;
|
|
833
|
+
run.forEach((raw, i) => {
|
|
834
|
+
const base = raw.with === "previous" && i > 0 ? prevStart : runEnd;
|
|
835
|
+
if (raw.type === "wait") {
|
|
836
|
+
prevStart = base;
|
|
837
|
+
runEnd = Math.max(runEnd, base + raw.duration * f);
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
if (raw.type === "play") return;
|
|
841
|
+
const command2 = { ...raw, targets: raw.targets.map((t) => t === MOTION_CLIP_TARGET ? target : t) };
|
|
842
|
+
const begin = base + (command2.delay ?? 0) * f;
|
|
843
|
+
let end = begin;
|
|
844
|
+
command2.targets.forEach((t, k) => {
|
|
845
|
+
const cycle = motionCycleDuration(command2, scene, t) * f;
|
|
846
|
+
const s = begin + k * (command2.stagger ?? 0) * f;
|
|
847
|
+
items.push({ command: command2, target: t, start: s, cycle });
|
|
848
|
+
end = Math.max(end, s + cycle * motionCommandRepeat(command2));
|
|
849
|
+
});
|
|
850
|
+
prevStart = begin;
|
|
851
|
+
runEnd = Math.max(runEnd, end);
|
|
852
|
+
});
|
|
853
|
+
return { items, length: runEnd };
|
|
854
|
+
}
|
|
796
855
|
function motionCycleDuration(command2, scene, target) {
|
|
797
856
|
if (command2.type === "wait") return command2.duration;
|
|
857
|
+
if (command2.type === "play") return motionClipLayout(scene, command2.clip, target ?? MOTION_CLIP_TARGET, command2.speed).length;
|
|
798
858
|
if (command2.duration !== void 0) return command2.duration;
|
|
799
859
|
if (command2.ease !== void 0) {
|
|
800
860
|
const ease = resolveEasing(command2.ease);
|
|
@@ -884,6 +944,19 @@ function compileMotionScene(scene) {
|
|
|
884
944
|
const shot = scene.shots[timing.shotIndex];
|
|
885
945
|
const command2 = shot.run[timing.command];
|
|
886
946
|
if (command2.type === "wait") continue;
|
|
947
|
+
if (command2.type === "play") {
|
|
948
|
+
const f = motionShotTimeScale(shot);
|
|
949
|
+
command2.targets.forEach((target, k) => {
|
|
950
|
+
if (!nodes.has(target)) return;
|
|
951
|
+
const at = timing.start + k * (command2.stagger ?? 0) * f;
|
|
952
|
+
for (const item of motionClipLayout(scene, command2.clip, target, (command2.speed ?? 1) / f).items) {
|
|
953
|
+
const entry = nodes.get(item.target);
|
|
954
|
+
if (!entry) continue;
|
|
955
|
+
jobs.push({ start: at + item.start, order: order++, run: () => compileRepeated(item.command, item.target, entry, at + item.start, item.cycle, timing) });
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
continue;
|
|
959
|
+
}
|
|
887
960
|
command2.targets.forEach((target, k) => {
|
|
888
961
|
const entry = nodes.get(target);
|
|
889
962
|
if (!entry) return;
|
|
@@ -1483,6 +1556,8 @@ function checkMotionScene(scene) {
|
|
|
1483
1556
|
if (command2.type === "follow" && known(command2.path, "unknown-path", "path", where) && nodes.get(command2.path).node.type !== "path")
|
|
1484
1557
|
issues.push(motionIssue("not-a-path", `"${command2.path}" is a group; follow a single path node.`, { ...where, ids: [command2.path] }));
|
|
1485
1558
|
if (command2.type === "morph") known(command2.into, "unknown-shape", "shape", where);
|
|
1559
|
+
if (command2.type === "play" && !scene.clips?.[command2.clip])
|
|
1560
|
+
issues.push(motionIssue("unknown-clip", `There is no clip ${namedWithSuggestion(command2.clip, Object.keys(scene.clips ?? {}))}; define it with set_animation_clip.`, where));
|
|
1486
1561
|
if (command2.type === "match" && known(command2.into, "unknown-shape", "group", where)) {
|
|
1487
1562
|
const into = nodes.get(command2.into);
|
|
1488
1563
|
for (const id of targets) {
|
|
@@ -1555,6 +1630,12 @@ function checkMotionScene(scene) {
|
|
|
1555
1630
|
}
|
|
1556
1631
|
});
|
|
1557
1632
|
});
|
|
1633
|
+
for (const [name, clip] of Object.entries(scene.clips ?? {}))
|
|
1634
|
+
for (const command2 of clip.run)
|
|
1635
|
+
if (command2.type !== "wait") {
|
|
1636
|
+
for (const id of command2.targets)
|
|
1637
|
+
if (id !== MOTION_CLIP_TARGET && !nodes.has(id)) issues.push(motionIssue("unknown-target", `Clip "${name}" names ${namedWithSuggestion(id, [...nodes.keys()])}, which the artwork does not have; use "$" for the node the clip is played on.`, { ids: [id] }));
|
|
1638
|
+
}
|
|
1558
1639
|
if (scene.trigger) {
|
|
1559
1640
|
if ((scene.loop ?? "none") !== "none") issues.push(motionIssue("trigger-loop", `The scene plays on ${scene.trigger}, so its "${scene.loop}" loop does not apply; set loop to "none" or remove the trigger.`, {}));
|
|
1560
1641
|
if (scene.trigger === "click") {
|
|
@@ -1638,6 +1719,7 @@ var MOTION_EDIT_OPS = [
|
|
|
1638
1719
|
"move_command",
|
|
1639
1720
|
"set_artwork",
|
|
1640
1721
|
"set_controls",
|
|
1722
|
+
"set_clip",
|
|
1641
1723
|
"replace_scene"
|
|
1642
1724
|
];
|
|
1643
1725
|
var EditError = class extends Error {
|
|
@@ -1694,6 +1776,23 @@ function applyOne(scene, edit) {
|
|
|
1694
1776
|
else if (edit.target !== void 0) next.target = edit.target;
|
|
1695
1777
|
return next;
|
|
1696
1778
|
}
|
|
1779
|
+
case "set_clip": {
|
|
1780
|
+
if (typeof edit.name !== "string" || !edit.name) fail('Give the clip a "name".');
|
|
1781
|
+
const clips = { ...scene.clips ?? {} };
|
|
1782
|
+
if (edit.clip === null) {
|
|
1783
|
+
if (!clips[edit.name]) fail(`There is no clip ${namedWithSuggestion(edit.name, Object.keys(clips))} to delete.`);
|
|
1784
|
+
const playing = scene.shots.filter((s) => s.run.some((c) => c.type === "play" && c.clip === edit.name)).map((s) => `"${s.id}"`);
|
|
1785
|
+
if (playing.length) fail(`Clip "${edit.name}" is played in shot${playing.length > 1 ? "s" : ""} ${playing.join(", ")}; remove those play commands first.`);
|
|
1786
|
+
delete clips[edit.name];
|
|
1787
|
+
} else {
|
|
1788
|
+
const problems = clipsShapeProblems({ [edit.name]: edit.clip });
|
|
1789
|
+
if (problems.length) fail(problems.join(" "));
|
|
1790
|
+
clips[edit.name] = edit.clip;
|
|
1791
|
+
}
|
|
1792
|
+
const next = { ...scene, clips };
|
|
1793
|
+
if (!Object.keys(clips).length) delete next.clips;
|
|
1794
|
+
return next;
|
|
1795
|
+
}
|
|
1697
1796
|
case "insert_shots": {
|
|
1698
1797
|
if (!edit.shots.length) fail("Give at least one shot.");
|
|
1699
1798
|
edit.shots.forEach((shot, i) => {
|
|
@@ -3003,6 +3102,20 @@ var MOTION_COMMAND_SCHEMA = {
|
|
|
3003
3102
|
stroke: { type: "string", description: "CSS colour (hex, rgb(), rgba())." },
|
|
3004
3103
|
strokeWidth: { type: "number", minimum: 0, description: "Document units." }
|
|
3005
3104
|
}),
|
|
3105
|
+
object(
|
|
3106
|
+
{
|
|
3107
|
+
type: { const: "play", description: 'Plays a clip (set_animation_clip) on the targets: its commands, with "$" standing for each target, timed as in a shot.' },
|
|
3108
|
+
targets: NODE_IDS,
|
|
3109
|
+
clip: { type: "string", minLength: 1, description: "The clip's name (get_animation lists them)." },
|
|
3110
|
+
speed: { type: "number", minimum: 0.05, maximum: 20, description: "Play it this many times as fast (default 1)." },
|
|
3111
|
+
delay: BASE.delay,
|
|
3112
|
+
stagger: BASE.stagger,
|
|
3113
|
+
with: BASE.with,
|
|
3114
|
+
note: BASE.note
|
|
3115
|
+
},
|
|
3116
|
+
["type", "targets", "clip"],
|
|
3117
|
+
"Plays a clip on the targets."
|
|
3118
|
+
),
|
|
3006
3119
|
command("match", `Smart Animate: tweens a group into another group (usually hidden), part by part. Parts pair by name, then by id with the group ids taken out (card-a-title \u2194 card-b-title), then by kind in order; each takes its partner's shape, paint and place. Unpaired parts fade out; parts of "into" with no partner do not appear (check_animation lists them).`, { into: { type: "string", minLength: 1, description: "Id of the group to become." } }, ["into"]),
|
|
3007
3120
|
command("morph", "Morphs each target into the shape (and paint) of another node, which usually stays hidden.", { into: { type: "string", minLength: 1, description: "Id of the node whose shape to take." } }, ["into"]),
|
|
3008
3121
|
command("follow", "Moves targets along a path node, centre on the path.", {
|
|
@@ -3211,6 +3324,7 @@ function createAnimationEditorToolProvider(controller, options = {}) {
|
|
|
3211
3324
|
...s.target ? { target: s.target } : {},
|
|
3212
3325
|
...includeElements ? { elements: describeMotionElements(s) } : {},
|
|
3213
3326
|
shots: describeMotionShots(s),
|
|
3327
|
+
...s.clips ? { clips: Object.fromEntries(Object.entries(s.clips).map(([name, c]) => [name, { ...c.description ? { description: c.description } : {}, commands: c.run.length, length: Math.round(motionClipLayout(s, name, "$").length) }])) } : {},
|
|
3214
3328
|
...s.controls ? { controls: s.controls } : {},
|
|
3215
3329
|
...s.presets ? { presets: s.presets } : {},
|
|
3216
3330
|
issues: issueSummary(controller.getState().issues),
|
|
@@ -3456,6 +3570,68 @@ function createAnimationEditorToolProvider(controller, options = {}) {
|
|
|
3456
3570
|
return apply(edits, "Fit to length", () => report);
|
|
3457
3571
|
}
|
|
3458
3572
|
};
|
|
3573
|
+
const setClip = {
|
|
3574
|
+
name: "set_animation_clip",
|
|
3575
|
+
title: "Define a reusable clip",
|
|
3576
|
+
description: `Defines, replaces or (with clip null) deletes a named clip: commands written against the target "$" that a play command plays on any node, e.g. a "pop-settle" or "attention" used many times. One undo step. Returns the clip's length and the timing.`,
|
|
3577
|
+
inputSchema: object(
|
|
3578
|
+
{
|
|
3579
|
+
name: { type: "string", pattern: "^[A-Za-z_][\\w-]*$", description: 'Clip name, e.g. "pop-settle".' },
|
|
3580
|
+
clip: {
|
|
3581
|
+
anyOf: [object({ description: { type: "string", description: "What it does, in a few words." }, run: { type: "array", items: MOTION_COMMAND_SCHEMA, minItems: 1, description: 'Commands, timed as in a shot; target "$" for the node it is played on. Clips cannot play clips.' } }, ["run"]), { type: "null" }],
|
|
3582
|
+
description: "The clip, or null to delete it (refused while a play command uses it)."
|
|
3583
|
+
}
|
|
3584
|
+
},
|
|
3585
|
+
["name", "clip"]
|
|
3586
|
+
),
|
|
3587
|
+
annotations: { title: "Define a reusable clip", ...WRITE_IDEMPOTENT },
|
|
3588
|
+
handler: ({ name, clip }) => apply({ op: "set_clip", name, clip }, clip === null ? "Delete clip" : "Set clip", (s) => clip === null ? { deleted: name } : { clip: name, length: Math.round(motionClipLayout(s, name, "$").length) })
|
|
3589
|
+
};
|
|
3590
|
+
const copyAnimation = {
|
|
3591
|
+
name: "copy_animation",
|
|
3592
|
+
title: "Copy one node's animation to others",
|
|
3593
|
+
description: 'Copies every command that animates "from" (in all shots, or the ones given) so it also animates "to": each copy goes right after its original and starts with it. One undo step. Returns how many commands were copied per shot. For motion you will reuse often, a clip (set_animation_clip + play) is tidier.',
|
|
3594
|
+
inputSchema: object(
|
|
3595
|
+
{
|
|
3596
|
+
from: { type: "string", minLength: 1, description: "Element id whose commands to copy." },
|
|
3597
|
+
to: { type: "array", items: { type: "string", minLength: 1 }, minItems: 1, description: "Element ids to give the same motion." },
|
|
3598
|
+
shots: { type: "array", items: SHOT_ID, description: "Only these shots (default all)." },
|
|
3599
|
+
stagger: MS("Start each copy this much after the one before (default 0)")
|
|
3600
|
+
},
|
|
3601
|
+
["from", "to"]
|
|
3602
|
+
),
|
|
3603
|
+
annotations: { title: "Copy one node's animation to others", ...WRITE },
|
|
3604
|
+
handler: ({ from, to, shots, stagger }) => {
|
|
3605
|
+
const s = scene();
|
|
3606
|
+
const ids = describeMotionElements(s).map((e) => e.id);
|
|
3607
|
+
for (const id of [from, ...to]) if (!ids.includes(id)) throw new Error(`There is no element ${namedWithSuggestion(id, ids)}. Nothing was changed.`);
|
|
3608
|
+
if (to.includes(from)) throw new Error(`"to" includes "${from}" itself; give other elements. Nothing was changed.`);
|
|
3609
|
+
const only = shots ? new Set(shots) : null;
|
|
3610
|
+
if (only) {
|
|
3611
|
+
for (const id of only) if (!s.shots.some((x) => x.id === id)) throw new Error(`There is no shot ${namedWithSuggestion(id, s.shots.map((x) => x.id))}. Nothing was changed.`);
|
|
3612
|
+
}
|
|
3613
|
+
const copied = {};
|
|
3614
|
+
const edits = [];
|
|
3615
|
+
for (const shot of s.shots) {
|
|
3616
|
+
if (only && !only.has(shot.id)) continue;
|
|
3617
|
+
const run = [];
|
|
3618
|
+
let n = 0;
|
|
3619
|
+
for (const c of shot.run) {
|
|
3620
|
+
run.push(c);
|
|
3621
|
+
if (c.type === "wait" || !c.targets.includes(from)) continue;
|
|
3622
|
+
const { delay: _delay, ...rest } = c;
|
|
3623
|
+
run.push({ ...rest, targets: to, with: "previous", ...stagger ? { stagger } : {} });
|
|
3624
|
+
n++;
|
|
3625
|
+
}
|
|
3626
|
+
if (n) {
|
|
3627
|
+
copied[shot.id] = n;
|
|
3628
|
+
edits.push({ op: "update_shot", shot: shot.id, set: { run } });
|
|
3629
|
+
}
|
|
3630
|
+
}
|
|
3631
|
+
if (!edits.length) throw new Error(`No command animates "${from}"${only ? " in those shots" : ""}; nothing to copy.`);
|
|
3632
|
+
return apply(edits, "Copy animation", () => ({ copied }));
|
|
3633
|
+
}
|
|
3634
|
+
};
|
|
3459
3635
|
const insertShots = {
|
|
3460
3636
|
name: "insert_shots",
|
|
3461
3637
|
title: "Add shots",
|
|
@@ -3632,7 +3808,7 @@ function createAnimationEditorToolProvider(controller, options = {}) {
|
|
|
3632
3808
|
}
|
|
3633
3809
|
};
|
|
3634
3810
|
const reads = [getAnimation, getShot, findElements, getMotionPath, getTimingGrid, checkAnimation, renderFrame, exportFlairMotion, exportFlairEffect, exportLottie, seekAnimation];
|
|
3635
|
-
const writes = [setArtworkSvg, fitAnimation, importFlairEffect, insertShots, updateShot, deleteShots, moveShot, addCommands, updateCommand, deleteCommands, moveCommand, setSettings, setControls, editAnimation, writeAnimation, undo, redo];
|
|
3811
|
+
const writes = [setArtworkSvg, setClip, copyAnimation, fitAnimation, importFlairEffect, insertShots, updateShot, deleteShots, moveShot, addCommands, updateCommand, deleteCommands, moveCommand, setSettings, setControls, editAnimation, writeAnimation, undo, redo];
|
|
3636
3812
|
return {
|
|
3637
3813
|
id: options.id ?? "animation",
|
|
3638
3814
|
namespace: options.namespace,
|
|
@@ -3664,6 +3840,7 @@ Commands
|
|
|
3664
3840
|
- enter (fade, pop, grow, slide, draw) and exit (fade, shrink, slide, undraw) bring things in and out.
|
|
3665
3841
|
- enter also reveals through a clip over the target's box: wipe (behind an edge travelling "direction", default right), iris (from the centre; "shape": circle or box) and split (from a line through the middle; "orientation": horizontal or vertical). exit wipe hides the same way. Reveals need a width and a height: use draw / undraw for a straight line.
|
|
3666
3842
|
- draw draws strokes on to a fraction; move, rotate, scale and fade change the pose (about the centre); style blends solid colours and stroke width.
|
|
3843
|
+
- Reuse motion: set_animation_clip defines a clip (commands targeting "$"), and { "type": "play", "clip": name, "targets": [...] } plays it on any nodes (with stagger and speed). copy_animation gives other nodes one node's motion.
|
|
3667
3844
|
- move takes "via" waypoints for a curved, smooth path that passes exactly through each point (steady speed by default); use it instead of chaining moves, which stop at each point.
|
|
3668
3845
|
- enter also has zoom (settles from larger) and rise (rises a short way, overshooting a touch); pop and zoom take a starting "scale".
|
|
3669
3846
|
- morph turns a shape into another node's shape (keep the target hidden); match does the same for a whole group, part by part (Smart Animate: draw the end state as a second, hidden group whose parts share names with the first); follow moves along a path node (with "rotate", moves made meanwhile turn with the path).
|
|
@@ -3803,6 +3980,10 @@ function defaultMotionCommand(type, targets, scene) {
|
|
|
3803
3980
|
const into = other((e) => e.node.type === "group" && e.node.visible === false) ?? other((e) => e.node.type === "group");
|
|
3804
3981
|
return into ? { type, ...base, into } : { error: "Match needs another group to become; group the end state (it can stay hidden)." };
|
|
3805
3982
|
}
|
|
3983
|
+
case "play": {
|
|
3984
|
+
const clip = Object.keys(scene.clips ?? {})[0];
|
|
3985
|
+
return clip ? { type, ...base, clip } : { error: 'Play needs a clip; define one first (set_animation_clip), with "$" as its target.' };
|
|
3986
|
+
}
|
|
3806
3987
|
case "follow": {
|
|
3807
3988
|
const path = other((e) => e.node.type === "path" && e.node.visible === false) ?? other((e) => e.node.type === "path");
|
|
3808
3989
|
return path ? { type, ...base, path } : { error: "Follow needs a path to travel along; draw one (it can stay hidden)." };
|
|
@@ -3966,6 +4147,7 @@ export {
|
|
|
3966
4147
|
MOTION_ADDITIVE_PROPERTIES,
|
|
3967
4148
|
MOTION_BLENDS,
|
|
3968
4149
|
MOTION_CAMERA_MS,
|
|
4150
|
+
MOTION_CLIP_TARGET,
|
|
3969
4151
|
MOTION_COMMAND_SCHEMA,
|
|
3970
4152
|
MOTION_COMMAND_TYPES,
|
|
3971
4153
|
MOTION_DEFAULT_DURATIONS,
|
|
@@ -3992,6 +4174,7 @@ export {
|
|
|
3992
4174
|
applyMotionControlValues,
|
|
3993
4175
|
applyMotionEdits,
|
|
3994
4176
|
checkMotionScene,
|
|
4177
|
+
clipsShapeProblems,
|
|
3995
4178
|
commandShapeProblems,
|
|
3996
4179
|
compileMotionScene,
|
|
3997
4180
|
createAnimationEditorToolProvider,
|
|
@@ -4020,6 +4203,7 @@ export {
|
|
|
4020
4203
|
motionBeatAt,
|
|
4021
4204
|
motionBeatTime,
|
|
4022
4205
|
motionClipAttrs,
|
|
4206
|
+
motionClipLayout,
|
|
4023
4207
|
motionCommandDuration,
|
|
4024
4208
|
motionCommandFields,
|
|
4025
4209
|
motionCommandRepeat,
|