@usemosio/cli-linux-x64 1.0.0-next.1 → 1.0.0-next.2

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.
Files changed (163) hide show
  1. package/THIRD_PARTY_NOTICES.md +22 -0
  2. package/apps/studio/dist/assets/Workspace-DsbQ04kb.js +34 -0
  3. package/apps/studio/dist/assets/{agent-panel-CqJuv5Sn.js → agent-panel-DUWPbpew.js} +5 -5
  4. package/apps/studio/dist/assets/{boundary-bK2S8z05.js → boundary-DuK3AiqM.js} +1 -1
  5. package/apps/studio/dist/assets/{feedback-BqzXUdVd.js → feedback-x6ZumR_x.js} +1 -1
  6. package/apps/studio/dist/assets/index-CjDBKmB_.css +2 -0
  7. package/apps/studio/dist/assets/index-DPLtb0kT.js +1905 -0
  8. package/apps/studio/dist/assets/inspector3d-B8pkZTye.js +1 -0
  9. package/apps/studio/dist/index.html +4 -3
  10. package/apps/studio/dist-host/studio-host.mjs +262 -3
  11. package/bin/mosio +0 -0
  12. package/bin/mosio-agent +0 -0
  13. package/crates/mosio/src/adapters/mosio-three.js +111 -7
  14. package/crates/mosio/src/adapters/room-env-pmrem.json +1 -0
  15. package/crates/mosio/src/runtime.js +126 -6
  16. package/fixtures/camera-inspect/mosio.json +56 -0
  17. package/fixtures/camera-inspect/scenes/behind.html +22 -0
  18. package/fixtures/camera-inspect/scenes/cut.html +18 -0
  19. package/fixtures/camera-inspect/scenes/edges.html +18 -0
  20. package/fixtures/camera-inspect/scenes/good.html +23 -0
  21. package/fixtures/camera-inspect/scenes/read.html +22 -0
  22. package/fixtures/camera-inspect/scenes/shake.html +23 -0
  23. package/fixtures/camera-inspect/scenes/speed.html +18 -0
  24. package/fixtures/camera-inspect-vertical/mosio.json +31 -0
  25. package/fixtures/camera-inspect-vertical/scenes/good.html +20 -0
  26. package/fixtures/camera-inspect-vertical/scenes/safe.html +18 -0
  27. package/fixtures/inspect-physics/expect.json +18 -0
  28. package/fixtures/inspect-physics/mosio.json +29 -0
  29. package/fixtures/inspect-physics/scenes/calm.html +46 -0
  30. package/fixtures/inspect-physics/scenes/physics.html +47 -0
  31. package/package.json +1 -1
  32. package/primitives/README.md +23 -2
  33. package/primitives/example/shared/mosio-prims.js +349 -1
  34. package/primitives/impact-burst/golden/f030.png +0 -0
  35. package/primitives/impact-burst/golden/f032.png +0 -0
  36. package/primitives/impact-burst/golden/f036.png +0 -0
  37. package/primitives/impact-burst/impact-burst.js +51 -0
  38. package/primitives/impact-burst/primitive.json +130 -0
  39. package/primitives/impact-burst/scene.html +24 -0
  40. package/primitives/stick-figure/golden/f030.png +0 -0
  41. package/primitives/stick-figure/golden/f092.png +0 -0
  42. package/primitives/stick-figure/golden/f140.png +0 -0
  43. package/primitives/stick-figure/primitive.json +179 -0
  44. package/primitives/stick-figure/scene.html +40 -0
  45. package/primitives/stick-figure/stick-figure.js +297 -0
  46. package/primitives/zoom-through/primitive.json +7 -2
  47. package/primitives/zoom-through/zoom-through.js +6 -5
  48. package/scripts/3d-acceptance.sh +8 -1
  49. package/scripts/3d-attach-bench.mjs +119 -0
  50. package/scripts/3d-bake-room-env.mjs +74 -0
  51. package/scripts/3d-e2b-job.sh +1 -0
  52. package/scripts/3d-gen-heavy-fixture.py +65 -0
  53. package/scripts/3d-trace-summary.py +14 -0
  54. package/scripts/acceptance/camera-inspect.sh +49 -0
  55. package/scripts/acceptance/export.sh +5 -3
  56. package/scripts/acceptance/hardening.sh +37 -6
  57. package/scripts/acceptance/hub.sh +208 -0
  58. package/scripts/acceptance/inspect.sh +21 -2
  59. package/scripts/acceptance/revisions-git.sh +137 -0
  60. package/scripts/acceptance/revisions-sync.sh +323 -0
  61. package/scripts/acceptance/revisions.sh +118 -4
  62. package/scripts/acceptance/segcache.sh +100 -0
  63. package/scripts/acceptance/split.sh +78 -0
  64. package/scripts/bootstrap.sh +20 -1
  65. package/scripts/check-error-codes.py +8 -0
  66. package/scripts/check-file-size.sh +49 -0
  67. package/scripts/ci.sh +4 -4
  68. package/scripts/dedupe-report.sh +47 -0
  69. package/scripts/e2b/template/provision.sh +1 -1
  70. package/scripts/fastpath/cdp.mjs +25 -0
  71. package/scripts/fastpath/dbg.mjs +11 -0
  72. package/scripts/fastpath/e2b.mjs +40 -0
  73. package/scripts/fastpath/features/gen.py +109 -0
  74. package/scripts/fastpath/features/mosio.json +100 -0
  75. package/scripts/fastpath/features/scenes/backdrop.html +11 -0
  76. package/scripts/fastpath/features/scenes/blend.html +11 -0
  77. package/scripts/fastpath/features/scenes/canvas2d.html +11 -0
  78. package/scripts/fastpath/features/scenes/filter.html +11 -0
  79. package/scripts/fastpath/features/scenes/gradient.html +11 -0
  80. package/scripts/fastpath/features/scenes/iframe.html +11 -0
  81. package/scripts/fastpath/features/scenes/image.html +11 -0
  82. package/scripts/fastpath/features/scenes/svg.html +11 -0
  83. package/scripts/fastpath/features/scenes/text.html +11 -0
  84. package/scripts/fastpath/features/scenes/typo.html +11 -0
  85. package/scripts/fastpath/features/scenes/video.html +11 -0
  86. package/scripts/fastpath/features/scenes/video2.html +11 -0
  87. package/scripts/fastpath/features-xfade/mosio.json +49 -0
  88. package/scripts/fastpath/features-xfade/scenes/image.html +11 -0
  89. package/scripts/fastpath/features-xfade/scenes/video.html +11 -0
  90. package/scripts/fastpath/fixtures/gen_layout.py +80 -0
  91. package/scripts/fastpath/fixtures/l12-no-reset/assets/img/photo-1015.jpg +0 -0
  92. package/scripts/fastpath/fixtures/l12-no-reset/mosio.json +34 -0
  93. package/scripts/fastpath/fixtures/l12-no-reset/scenes/main.html +20 -0
  94. package/scripts/fastpath/fp.mjs +91 -0
  95. package/scripts/fastpath/inpage.js +68 -0
  96. package/scripts/fastpath/recipes.py +49 -0
  97. package/scripts/fastpath/sandbox.sh +68 -0
  98. package/scripts/fastpath/sandbox10.sh +57 -0
  99. package/scripts/fastpath/sandbox11.sh +18 -0
  100. package/scripts/fastpath/sandbox12.sh +30 -0
  101. package/scripts/fastpath/sandbox13.sh +16 -0
  102. package/scripts/fastpath/sandbox14.sh +28 -0
  103. package/scripts/fastpath/sandbox15.sh +36 -0
  104. package/scripts/fastpath/sandbox16.sh +60 -0
  105. package/scripts/fastpath/sandbox17.sh +34 -0
  106. package/scripts/fastpath/sandbox18.sh +59 -0
  107. package/scripts/fastpath/sandbox19.sh +67 -0
  108. package/scripts/fastpath/sandbox2.sh +41 -0
  109. package/scripts/fastpath/sandbox20.sh +34 -0
  110. package/scripts/fastpath/sandbox21.sh +22 -0
  111. package/scripts/fastpath/sandbox22.sh +22 -0
  112. package/scripts/fastpath/sandbox23.sh +21 -0
  113. package/scripts/fastpath/sandbox3.sh +151 -0
  114. package/scripts/fastpath/sandbox4.sh +161 -0
  115. package/scripts/fastpath/sandbox5.sh +69 -0
  116. package/scripts/fastpath/sandbox6.sh +85 -0
  117. package/scripts/fastpath/sandbox7.sh +81 -0
  118. package/scripts/fastpath/sandbox8.sh +62 -0
  119. package/scripts/fastpath/sandbox9.sh +130 -0
  120. package/scripts/fastpath/srv.mjs +15 -0
  121. package/scripts/fastpath/www/probe.html +1 -0
  122. package/scripts/hpbench/make-bench-fixtures.sh +43 -0
  123. package/scripts/hpbench/render-cgroup.sh +56 -0
  124. package/scripts/install.sh +2 -1
  125. package/scripts/npm-clean-install-proof-win.sh +64 -0
  126. package/scripts/platform-smoke.sh +67 -0
  127. package/scripts/prim.mjs +31 -13
  128. package/skills/mosio-3d/SKILL.md +1 -1
  129. package/skills/mosio-brief/SKILL.md +80 -0
  130. package/skills/mosio-brief/references/brief.md +141 -0
  131. package/skills/mosio-brief/references/copy.md +99 -0
  132. package/skills/mosio-brief/references/narration.md +61 -0
  133. package/skills/mosio-brief/references/storyboard.md +98 -0
  134. package/skills/mosio-collab/SKILL.md +104 -0
  135. package/skills/mosio-collab/references/hub.md +62 -0
  136. package/skills/mosio-engine/SKILL.md +44 -13
  137. package/skills/mosio-engine/references/camera.md +12 -2
  138. package/skills/mosio-engine/references/character.md +88 -0
  139. package/skills/mosio-engine/references/checks.md +10 -3
  140. package/skills/mosio-engine/references/delivery.md +29 -2
  141. package/skills/mosio-engine/references/kit-primitives.md +8 -4
  142. package/skills/mosio-engine/references/layout.md +8 -0
  143. package/skills/mosio-engine/references/plan.md +3 -1
  144. package/skills/mosio-engine/references/project.md +3 -3
  145. package/skills/mosio-engine/references/publish.md +79 -0
  146. package/skills/mosio-engine/references/registry.md +27 -15
  147. package/skills/mosio-engine/references/timeline.md +18 -0
  148. package/skills/mosio-engine/references/timing.md +2 -1
  149. package/skills/mosio-import/SKILL.md +1 -1
  150. package/skills/mosio-import/references/from-hyperframes.md +1 -1
  151. package/skills/mosio-import/references/from-remotion.md +1 -1
  152. package/skills/mosio-media/SKILL.md +16 -4
  153. package/skills/mosio-media/references/audio.md +29 -11
  154. package/skills/mosio-media/references/captions.md +22 -4
  155. package/skills/mosio-media/references/editing.md +70 -0
  156. package/skills/mosio-media/references/footage.md +40 -8
  157. package/skills/mosio-media/references/voice.md +52 -7
  158. package/skills/mosio-replicate/references/mosio.md +1 -1
  159. package/toolchain.lock.json +151 -4
  160. package/apps/studio/dist/assets/Workspace-KSOFeEgc.js +0 -32
  161. package/apps/studio/dist/assets/index-B-uuTqe9.js +0 -1785
  162. package/apps/studio/dist/assets/index-CajSh04l.css +0 -2
  163. package/apps/studio/dist/assets/inspector3d-vDz97X99.js +0 -1
@@ -13,6 +13,7 @@ so they render the same on every machine: no randomness, no endless repeats, no
13
13
  | Transition | `iris` `zoom-through` `blur-swap` `dip-to-color` `whip-pan` `shape-wipe` `split-screen` `glitch-cut` |
14
14
  | Commerce | `receipt-print` `voucher-ticket` `qr-pay-scan` `order-tracker` `product-callouts` `rating-summary` `price-drop` `review-card-stack` `loyalty-stamp-card` `bundle-builder` `product-grid-reveal` `variant-picker` `store-location-pin` `open-sign-flip` `payment-methods-row` `scroll-menu-phone` `glass-price-card` `before-after-wipe` `split-screen-compare` `step-explainer` `chat-review-typed` `flash-sale-burst` `menu-price-board` (see below) |
15
15
  | Particles | `confetti-burst` `confetti-rain` `sparks` `snow` `dust-drift` `smoke-puff` (canvas 2D, closed form; see below) |
16
+ | Character | `stick-figure` `impact-burst` (see below) |
16
17
 
17
18
  Rules for picking and tuning them (ease per role, stagger, exit, hold formula): [`skills/mosio-engine/references/timing.md`](../skills/mosio-engine/references/timing.md).
18
19
 
@@ -32,8 +33,9 @@ node scripts/prim.mjs install my-video rise,pop # copies shared/{mosio-prims.js
32
33
  __mosio.timeline(tl);
33
34
  </script>
34
35
  ```
35
- Every call returns `{ at, end, entrance_end, exit_at, hold_s }`, so the next primitive can start where the last one ends. `prim.css` declares Inter
36
- from `/assets/fonts/Inter-{Regular,Bold,ExtraBold}.otf`: add those files to `assets` or change the `@font-face` rules.
36
+ Every call returns `{ at, end, entrance_end, exit_at, hold_s }`, so the next primitive can start where the last one ends. `install` sizes
37
+ `tokens.css` for the project's canvas, and copies and declares Inter when it finds it (`--fonts-from DIR`, `$MOSIO_FONT_DIR`);
38
+ without it `prim.css` carries no `@font-face`, so set `--font-display` / `--font-body` to the project's fonts.
37
39
 
38
40
  ## Reels, stacks and maps
39
41
  `slot-machine-roll` turns the characters of `[data-mp=value]` into vertical reels (`charset`: `digits`, `letters`, `alnum` or your own list) that start together, stop `stagger` apart and settle with a small overshoot; characters outside the charset stay still. `notification-stack` slides phone-style cards in from the top (pass `items`, or write `.mp-notif` cards in the HTML), `interval` apart, and compresses the older ones behind the newest (`maxVisible`); `clear` slides the stack back out at the end. `indonesia-map` draws the 33 provinces from simplified Natural Earth shapes and lights the provinces of `highlight` (ISO 3166-2:ID codes) in turn, with optional pins and `values`. Source, version and the simplification: [`indonesia-map/README.md`](indonesia-map/README.md). All three are closed form on the frame clock: no randomness, no wall clock.
@@ -76,6 +78,25 @@ Typed vars (see `node scripts/prim.mjs show snow`): `seed`, `count`, `colors` (t
76
78
  with the canvas. Caps: `count` above 4000 (150 for `smoke-puff`) throws `E_PRIM_VAR`; `mosio check` warns (`W_PARTICLES_BUDGET`) when the effects of one scene add
77
79
  up to more than 2000. Details, the model and the performance budget: [`docs/PARTICLES.md`](../docs/PARTICLES.md).
78
80
 
81
+ ## Characters
82
+ `stick-figure` is a rigged stickman driven by timed acts: `run`/`walk` arrive at `until`, a `jump` takes off at `at` and lands at
83
+ `until`, a `strike` (`punch`, `kick`, `uppercut`) makes contact at `at`, `hit`, `block`, `roll`, `fall`, `get_up`, named poses and faces.
84
+ The craft is built in: a wind-up or crouch before the action, a two-frame snap into contact and a short hold, head and arms trailing
85
+ the body by `overlap` frames, squash on landing and stretch on take-off, the lower foot kept on the floor, a contact shadow, and the far
86
+ limbs drawn dimmer for depth. Joint angles live on `rig.state`, so a custom move is a GSAP tween of those numbers. `impact-burst` is the
87
+ contact frame of a hit: put it, the sound and the camera shake on the `contact` time a strike returns in `times`. Lengths are 1080p design
88
+ px (the shorter side of the box is 1080), so the same acts fit any output size. Directing them: `skills/mosio-engine/references/character.md`.
89
+ ```html
90
+ <div class="stage" data-mosio-id="fight/hero"></div><div class="stage" data-mosio-id="fight/fx"></div>
91
+ <script>
92
+ const tl = gsap.timeline({ paused: true });
93
+ const hero = MosioPrims.stickFigure(tl, '[data-mosio-id="fight/hero"]', { x: 200, ground: 860, acts: [
94
+ { at: 0.2, run: { to: 620, until: 1.1 } }, { at: 1.6, strike: 'punch', lunge: 40 } ] });
95
+ MosioPrims.impactBurst(tl, '[data-mosio-id="fight/fx"]', { at: hero.times[1].contact, point: [52, 55] });
96
+ __mosio.timeline(tl);
97
+ </script>
98
+ ```
99
+
79
100
  ## Layout of a primitive
80
101
  ```text
81
102
  primitives/<id>/primitive.json manifest (mosio.primitive/1): typed vars + defaults, parts, timing, tokens, use_when, avoid_when, pairs_with, usage, golden frames
@@ -1,4 +1,4 @@
1
- /* mosio-prims bundle: arrow-draw, bar-chart-reveal, before-after-wipe, blur-in, blur-swap, bundle-builder, chat-review-typed, clip-reveal, confetti-burst, confetti-rain, count-up, cta-lockup, cursor-click, device-frame, dip-to-color, dust-drift, fade, flash-sale-burst, focus-box, glass-price-card, glitch-cut, highlight-sweep, hud-viewfinder, indonesia-map, iris, ken-burns, letter-cascade, line-draw, lower-third, loyalty-stamp-card, mask-reveal, menu-price-board, nested-zoom-words, notification-stack, open-sign-flip, order-tracker, payment-methods-row, per-word-rise, pop, price-drop, product-callouts, product-grid-reveal, qr-pay-scan, rating-summary, receipt-print, review-card-stack, ring-progress, rise, scroll-menu-phone, shape-wipe, slide, slot-machine-roll, smoke-puff, snow, sparks, split-reveal, split-screen, split-screen-compare, stat-counter, step-explainer, store-location-pin, title-card, typewriter, underline-draw, variant-picker, voucher-ticket, whip-pan, word-swap, zoom-through, zoom-to */
1
+ /* mosio-prims bundle: arrow-draw, bar-chart-reveal, before-after-wipe, blur-in, blur-swap, bundle-builder, chat-review-typed, clip-reveal, confetti-burst, confetti-rain, count-up, cta-lockup, cursor-click, device-frame, dip-to-color, dust-drift, fade, flash-sale-burst, focus-box, glass-price-card, glitch-cut, highlight-sweep, hud-viewfinder, impact-burst, indonesia-map, iris, ken-burns, letter-cascade, line-draw, lower-third, loyalty-stamp-card, mask-reveal, menu-price-board, nested-zoom-words, notification-stack, open-sign-flip, order-tracker, payment-methods-row, per-word-rise, pop, price-drop, product-callouts, product-grid-reveal, qr-pay-scan, rating-summary, receipt-print, review-card-stack, ring-progress, rise, scroll-menu-phone, shape-wipe, slide, slot-machine-roll, smoke-puff, snow, sparks, split-reveal, split-screen, split-screen-compare, stat-counter, step-explainer, stick-figure, store-location-pin, title-card, typewriter, underline-draw, variant-picker, voucher-ticket, whip-pan, word-swap, zoom-through, zoom-to */
2
2
  /* Mosio motion primitives: core. Loaded before any primitive. Needs GSAP (/_lib/gsap@3.15.1/gsap.min.js) in the page.
3
3
  Every primitive is MosioPrims.<name>(tl, target, vars) and adds tweens to YOUR paused timeline; you register it with
4
4
  __mosio.timeline(tl). All times are seconds on that timeline, snapped to whole frames. No randomness, no repeat, no
@@ -1186,6 +1186,57 @@
1186
1186
  });
1187
1187
  function q(t) { return P.q(t); }
1188
1188
  })(window.MosioPrims);
1189
+ (function (P) {
1190
+ "use strict";
1191
+ // The contact frame of a hit, a landing or a stamp: a one-frame flash, a ring that bursts out, radial speed lines and a
1192
+ // jagged star that pops and fades. Everything is placed from `at` in whole frames, so it lands exactly on the frame the
1193
+ // sound and the camera shake use. Angles and lengths come from a seeded generator: same seed, same burst.
1194
+ P.define("impact-burst", Object.assign({}, P.COMMON_DEFAULTS, {
1195
+ point: [50, 50], on: null, size: 1, lines: 10, color: "--text", accent: "--accent", flash: true, star: true, seed: 1,
1196
+ }), (tl, target, v) => {
1197
+ const id = "impact-burst", root = P.one(target, id), F = P.frames;
1198
+ P.num(id, "size", v.size, 0.2, 5); P.int(id, "lines", v.lines, 0, 32); P.int(id, "seed", v.seed, 0, 1e9);
1199
+ const col = (c) => (c && c.startsWith("--") ? "var(" + c + ")" : c);
1200
+ if (getComputedStyle(root).position === "static") root.style.position = "absolute";
1201
+ // lengths are 1080p design px: the shorter side of the box is 1080, so the same numbers fit any output size
1202
+ const BW = root.offsetWidth || 1080, BH = root.offsetHeight || 1920, K = 1080 / Math.min(BW, BH), W = BW * K, H = BH * K;
1203
+ const svg = P.svg("svg", { viewBox: "0 0 " + W.toFixed(2) + " " + H.toFixed(2), width: BW, height: BH, style: "position:absolute;left:0;top:0;overflow:visible;pointer-events:none" }, root);
1204
+ P.tagId(svg, root, "burst");
1205
+ const g = P.svg("g", { opacity: 0 }, svg);
1206
+ const p = P.plan(v, 0.4, { noExit: true, hold: 0 });
1207
+ const t = p.at, s = v.size, rnd = P.rng(v.seed);
1208
+ const place = () => {
1209
+ let x = (P.pair(id, "point", v.point)[0] / 100) * W, y = (v.point[1] / 100) * H;
1210
+ if (v.on) { const b = P.boxAt(tl, P.one(v.on, id + " on"), root, t); x = (b.x + b.w / 2) * K; y = (b.y + b.h / 2) * K; }
1211
+ g.setAttribute("transform", "translate(" + x.toFixed(1) + " " + y.toFixed(1) + ")");
1212
+ };
1213
+ if (v.on) P.afterFonts(place); else place();
1214
+ const flash = v.flash ? P.svg("circle", { r: 95 * s, fill: col(v.color) }, g) : null;
1215
+ const ring = P.svg("circle", { r: 60 * s, fill: "none", stroke: col(v.color), "stroke-width": 10 * s }, g);
1216
+ let star = null;
1217
+ if (v.star) {
1218
+ const pts = []; const n = 9;
1219
+ for (let i = 0; i < n * 2; i++) { const a = (i / (n * 2)) * Math.PI * 2 + rnd() * 0.2, r = (i % 2 ? 48 : 120 + rnd() * 50) * s; pts.push((Math.cos(a) * r).toFixed(1) + "," + (Math.sin(a) * r).toFixed(1)); }
1220
+ star = P.svg("polygon", { points: pts.join(" "), fill: col(v.accent), stroke: col(v.color), "stroke-width": 6 * s, "stroke-linejoin": "round" }, g);
1221
+ }
1222
+ const lines = [];
1223
+ for (let i = 0; i < v.lines; i++) {
1224
+ const a = (i / v.lines) * Math.PI * 2 + (rnd() - 0.5) * 0.5, r0 = (130 + rnd() * 40) * s, len = (90 + rnd() * 110) * s;
1225
+ const ln = P.svg("line", { x1: (Math.cos(a) * r0).toFixed(1), y1: (Math.sin(a) * r0).toFixed(1), x2: (Math.cos(a) * (r0 + len)).toFixed(1), y2: (Math.sin(a) * (r0 + len)).toFixed(1), stroke: col(v.color), "stroke-width": (7 + rnd() * 5) * s, "stroke-linecap": "round", "stroke-dasharray": len.toFixed(1), "stroke-dashoffset": len.toFixed(1) }, g);
1226
+ lines.push([ln, len]);
1227
+ }
1228
+ P.setAt(tl, g, { opacity: 1 }, t);
1229
+ if (flash) { P.setAt(tl, flash, { opacity: 1 }, t); P.setAt(tl, flash, { opacity: 0 }, t + F(2)); }
1230
+ tl.fromTo(ring, { attr: { r: 60 * s }, opacity: 1 }, { attr: { r: 250 * s }, opacity: 0, duration: F(8), ease: "power3.out", immediateRender: false }, t);
1231
+ if (star) {
1232
+ tl.fromTo(star, { scale: 1.35, rotation: -8, transformOrigin: "0 0" }, { scale: 1, rotation: 0, duration: F(4), ease: "power3.out", immediateRender: false }, t);
1233
+ tl.to(star, { scale: 0.6, opacity: 0, duration: F(5), ease: "power2.in" }, t + F(7));
1234
+ }
1235
+ for (const [ln, len] of lines) tl.fromTo(ln, { attr: { "stroke-dashoffset": len }, opacity: 1 }, { attr: { "stroke-dashoffset": -len }, opacity: 0.2, duration: F(7), ease: "power3.out", immediateRender: false }, t);
1236
+ P.setAt(tl, g, { opacity: 0 }, t + F(12));
1237
+ return Object.assign({}, p.result, { contact: t, end: P.q(t + F(12)) });
1238
+ });
1239
+ })(window.MosioPrims);
1189
1240
  (function (P) {
1190
1241
  "use strict";
1191
1242
  const C = P.COMMON_DEFAULTS, E = P.EASE;
@@ -2482,6 +2533,303 @@
2482
2533
  return p.result;
2483
2534
  });
2484
2535
  })(window.MosioPrims);
2536
+ (function (P) {
2537
+ "use strict";
2538
+ // A rigged stickman. Joint angles are plain numbers on `rig.state`, so GSAP tweens them like any other value and the
2539
+ // figure is redrawn from that state on every seek: the same frame always gives the same pose. Acts (pose, run, jump,
2540
+ // strike, hit, roll, fall) are scheduled at build time and carry the animation craft a hand-written rig forgets:
2541
+ // anticipation before a strike or a jump, a fast contact on the given time, a hit-stop hold, overlap (arms and head
2542
+ // trail the body by a frame or two), squash on landing, stretch on take-off, feet kept on the ground, and a shadow.
2543
+ //
2544
+ // Angles are degrees from hanging straight down; positive turns toward the way the figure faces. `1` limbs are the
2545
+ // near ones (drawn in front, full colour), `2` the far ones (behind, dimmer): a stick figure reads in depth only so.
2546
+ const FACES = ["calm", "happy", "grin", "angry", "shock", "hurt", "sad", "determined", "smug", "panic", "dizzy", "blink"];
2547
+ const POSES = {
2548
+ idle: { lean: 2, head: 0, a1s: 8, a1e: 12, a2s: -8, a2e: 14, l1h: 6, l1k: 4, l2h: -6, l2k: 4 },
2549
+ stand: { lean: 0, head: 0, a1s: 4, a1e: 6, a2s: -4, a2e: 6, l1h: 3, l1k: 2, l2h: -3, l2k: 2 },
2550
+ guard: { lean: 8, head: 4, a1s: 48, a1e: 96, a2s: 34, a2e: 108, l1h: 24, l1k: 22, l2h: -20, l2k: 16 },
2551
+ punch_wind: { lean: -6, head: 2, a1s: 28, a1e: 135, a2s: 72, a2e: 100, l1h: 20, l1k: 26, l2h: -26, l2k: 20 },
2552
+ punch: { lean: 20, head: 6, a1s: 90, a1e: 0, a2s: 18, a2e: 125, l1h: 34, l1k: 22, l2h: -32, l2k: 4 },
2553
+ uppercut_wind: { lean: 26, head: 6, a1s: -10, a1e: 120, a2s: 60, a2e: 110, l1h: 44, l1k: 60, l2h: -10, l2k: 50 },
2554
+ uppercut: { lean: -8, head: -10, a1s: 160, a1e: 25, a2s: 30, a2e: 110, l1h: 10, l1k: 6, l2h: -24, l2k: 8 },
2555
+ kick_wind: { lean: -12, head: 0, a1s: 40, a1e: 80, a2s: -30, a2e: 40, l1h: 72, l1k: 115, l2h: -4, l2k: 12 },
2556
+ kick: { lean: -26, head: -4, a1s: 62, a1e: 30, a2s: -52, a2e: 20, l1h: 96, l1k: 0, l2h: -8, l2k: 6 },
2557
+ block: { lean: -6, head: -6, a1s: 118, a1e: 128, a2s: 98, a2e: 140, l1h: 18, l1k: 22, l2h: -24, l2k: 14 },
2558
+ dodge: { lean: -30, head: -14, a1s: 50, a1e: 90, a2s: 20, a2e: 100, l1h: 10, l1k: 36, l2h: -40, l2k: 24 },
2559
+ hurt: { lean: -24, head: -26, a1s: -34, a1e: 34, a2s: 44, a2e: 22, l1h: 16, l1k: 12, l2h: -22, l2k: 6 },
2560
+ crouch: { lean: 28, head: -6, a1s: 26, a1e: 40, a2s: -14, a2e: 50, l1h: 74, l1k: 124, l2h: 44, l2k: 112 },
2561
+ stretch: { lean: 4, head: -8, a1s: 168, a1e: 8, a2s: 158, a2e: 14, l1h: -6, l1k: 8, l2h: -16, l2k: 18 },
2562
+ tuck: { lean: 24, head: 10, a1s: 64, a1e: 92, a2s: 52, a2e: 96, l1h: 104, l1k: 132, l2h: 84, l2k: 124 },
2563
+ land: { lean: 22, head: 4, a1s: 54, a1e: 18, a2s: 76, a2e: 22, l1h: 58, l1k: 104, l2h: 26, l2k: 84 },
2564
+ cheer: { lean: -4, head: -12, a1s: 166, a1e: 14, a2s: 156, a2e: 26, l1h: 6, l1k: 4, l2h: -8, l2k: 4 },
2565
+ point: { lean: 4, head: 2, a1s: 86, a1e: 2, a2s: -6, a2e: 14, l1h: 8, l1k: 4, l2h: -8, l2k: 4 },
2566
+ wave: { lean: 0, head: -4, a1s: 150, a1e: 44, a2s: -6, a2e: 14, l1h: 6, l1k: 4, l2h: -6, l2k: 4 },
2567
+ think: { lean: 4, head: 12, a1s: 32, a1e: 150, a2s: 30, a2e: 96, l1h: 6, l1k: 4, l2h: -6, l2k: 4 },
2568
+ shock: { lean: -12, head: -8, a1s: 122, a1e: 60, a2s: 112, a2e: 70, l1h: 10, l1k: 8, l2h: -12, l2k: 6 },
2569
+ sad: { lean: 14, head: 26, a1s: 2, a1e: 4, a2s: -2, a2e: 6, l1h: 4, l1k: 6, l2h: -4, l2k: 6 },
2570
+ stumble: { lean: 46, head: -18, a1s: 124, a1e: 20, a2s: -62, a2e: 30, l1h: 42, l1k: 30, l2h: -52, l2k: 62 },
2571
+ carry: { lean: 6, head: 0, a1s: 70, a1e: 64, a2s: 64, a2e: 70, l1h: 6, l1k: 4, l2h: -6, l2k: 4 },
2572
+ give: { lean: 10, head: 4, a1s: 80, a1e: 14, a2s: 74, a2e: 18, l1h: 10, l1k: 6, l2h: -8, l2k: 4 },
2573
+ sit: { lean: 2, head: 0, a1s: 30, a1e: 50, a2s: 24, a2e: 56, l1h: 90, l1k: 90, l2h: 84, l2k: 90 },
2574
+ lie: { lean: 0, head: -6, a1s: 150, a1e: 10, a2s: 30, a2e: 20, l1h: 8, l1k: 4, l2h: -14, l2k: 18 },
2575
+ bow: { lean: 50, head: 10, a1s: 4, a1e: 6, a2s: -4, a2e: 6, l1h: 4, l1k: 2, l2h: -4, l2k: 2 },
2576
+ sit_floor: { lean: 8, head: 6, a1s: 26, a1e: 30, a2s: 14, a2e: 40, l1h: 88, l1k: 6, l2h: 80, l2k: 30 },
2577
+ slump: { lean: 38, head: 34, a1s: 6, a1e: 10, a2s: -4, a2e: 14, l1h: 86, l1k: 10, l2h: 76, l2k: 40 },
2578
+ };
2579
+ const JOINTS = ["hand1", "hand2", "head", "hip", "chest"];
2580
+ const KEYS = ["lean", "head", "a1s", "a1e", "a2s", "a2e", "l1h", "l1k", "l2h", "l2k"];
2581
+ const BODY = ["lean", "l1h", "l1k", "l2h", "l2k"], LIMBS = ["head", "a1s", "a1e", "a2s", "a2e"];
2582
+ const STRIKES = { punch: "punch_wind", kick: "kick_wind", uppercut: "uppercut_wind" };
2583
+ const rad = (d) => (d * Math.PI) / 180;
2584
+
2585
+ function poseOf(id, p) {
2586
+ if (typeof p === "string") { if (!POSES[p]) throw new Error("E_PRIM_VAR " + id + ": unknown pose '" + p + "' (known: " + Object.keys(POSES).join(", ") + ")"); return POSES[p]; }
2587
+ if (p && typeof p === "object") { for (const k of Object.keys(p)) if (KEYS.indexOf(k) < 0) throw new Error("E_PRIM_VAR " + id + ": pose key '" + k + "' (known: " + KEYS.join(", ") + ")"); return p; }
2588
+ throw new Error("E_PRIM_VAR " + id + ": a pose is a name or an object of joint angles");
2589
+ }
2590
+ const pick = (o, ks) => { const r = {}; for (const k of ks) if (k in o) r[k] = o[k]; return r; };
2591
+
2592
+ P.define("stick-figure", Object.assign({}, P.COMMON_DEFAULTS, {
2593
+ x: 540, ground: 1500, facing: 1, scale: 1, pose: "idle", face: "calm", color: "--text", far: 0.55, width: 14,
2594
+ head_fill: null, shadow: true, shadow_color: null, overlap: 2, acts: [], props: [],
2595
+ }), (tl, target, v) => {
2596
+ const id = "stick-figure", root = P.one(target, id), F = P.frames;
2597
+ P.num(id, "scale", v.scale, 0.2, 4); P.num(id, "width", v.width, 2, 40); P.num(id, "far", v.far, 0, 1);
2598
+ P.int(id, "overlap", v.overlap, 0, 6); P.oneOf(id, "facing", v.facing, [1, -1]); P.oneOf(id, "face", v.face, FACES);
2599
+ if (!Array.isArray(v.acts)) throw new Error("E_PRIM_VAR " + id + ": acts must be a list");
2600
+ const col = (c) => (c && c.startsWith("--") ? "var(" + c + ")" : c);
2601
+ const S = v.scale, L = { r: 34 * S, neck: 8 * S, torso: 112 * S, ua: 70 * S, fa: 66 * S, th: 88 * S, sh: 86 * S, foot: 22 * S };
2602
+
2603
+ // ---- drawing ----
2604
+ if (getComputedStyle(root).position === "static") root.style.position = "absolute";
2605
+ // lengths are 1080p design px: the shorter side of the box is 1080, so the same numbers fit any output size
2606
+ const BW = root.offsetWidth || 1080, BH = root.offsetHeight || 1920, K = 1080 / Math.min(BW, BH), W = BW * K, H = BH * K;
2607
+ const svg = P.svg("svg", { viewBox: "0 0 " + W.toFixed(2) + " " + H.toFixed(2), width: BW, height: BH, style: "position:absolute;left:0;top:0;overflow:visible" }, root);
2608
+ const stroke = { fill: "none", stroke: col(v.color), "stroke-width": v.width * S, "stroke-linecap": "round", "stroke-linejoin": "round" };
2609
+ const shadow = v.shadow ? P.svg("ellipse", { rx: 70 * S, ry: 12 * S, fill: v.shadow_color ? col(v.shadow_color) : "color-mix(in srgb, var(--bg), black 75%)", opacity: 0.22 }, svg) : null;
2610
+ const body = P.svg("g", {}, svg);
2611
+ const farG = P.svg("g", { opacity: v.far }, body);
2612
+ const arm2 = P.svg("path", stroke, farG), leg2 = P.svg("path", stroke, farG);
2613
+ const leg1 = P.svg("path", stroke, body), torso = P.svg("path", stroke, body);
2614
+ const headG = P.svg("g", {}, body);
2615
+ P.svg("circle", Object.assign({}, stroke, { r: L.r, fill: v.head_fill ? col(v.head_fill) : "none" }), headG);
2616
+ const faceG = P.svg("g", { fill: "none", stroke: col(v.color), "stroke-width": 5 * S, "stroke-linecap": "round" }, headG);
2617
+ const brow = P.svg("path", {}, faceG), eyes = P.svg("path", { "stroke-width": 9 * S }, faceG), mouth = P.svg("path", {}, faceG);
2618
+ const arm1 = P.svg("path", stroke, body);
2619
+ P.tagId(svg, root, "rig");
2620
+ const props = (v.props || []).map((p) => {
2621
+ const el = P.one(p.el, id + " props");
2622
+ // a prop that turns or flips does so about the joint (its top-left corner sits on the joint)
2623
+ if (p.rotate || p.mirror) el.style.transformOrigin = "0 0";
2624
+ return { el, joint: P.oneOf(id, "props.joint", p.joint || "hand1", JOINTS), dx: p.dx || 0, dy: p.dy || 0, rotate: !!p.rotate, mirror: !!p.mirror };
2625
+ });
2626
+
2627
+ // face shapes in head space (r = 34, facing right; mirrored for facing -1)
2628
+ const FACE = {
2629
+ calm: ["M2 -16 l12 0 M20 -16 l12 0", "M8 -4 l0 1 M26 -4 l0 1", "M10 14 q8 5 16 0"],
2630
+ happy: ["M2 -18 q6 -4 12 0 M20 -18 q6 -4 12 0", "M8 -4 l0 1 M26 -4 l0 1", "M6 10 q11 14 24 0"],
2631
+ grin: ["M2 -18 q6 -4 12 0 M20 -18 q6 -4 12 0", "M5 -4 q3 -4 6 0 M23 -4 q3 -4 6 0", "M4 9 q13 18 26 0 z"],
2632
+ angry: ["M2 -20 l12 6 M32 -20 l-12 6", "M8 -4 l0 1 M26 -4 l0 1", "M8 16 q9 -6 18 0"],
2633
+ shock: ["M2 -22 q6 -5 12 0 M20 -22 q6 -5 12 0", "M8 -6 l0 4 M26 -6 l0 4", "M12 12 q5 -6 10 0 q-5 8 -10 0"],
2634
+ hurt: ["M2 -14 l12 -5 M32 -14 l-12 -5", "M4 -6 l8 6 M12 -6 l-8 6 M22 -6 l8 6 M30 -6 l-8 6", "M8 16 q4 -4 8 0 q4 4 8 0 q4 -4 8 0"],
2635
+ sad: ["M2 -14 l12 -5 M32 -14 l-12 -5", "M8 -3 l0 1 M26 -3 l0 1", "M9 18 q9 -8 18 0"],
2636
+ determined: ["M2 -18 l12 4 M32 -18 l-12 4", "M8 -4 l0 1 M26 -4 l0 1", "M9 14 l18 0"],
2637
+ smug: ["M2 -16 l12 -2 M20 -20 l12 4", "M6 -4 l6 0 M24 -4 l6 0", "M8 12 q10 6 20 -4"],
2638
+ panic: ["M2 -22 l12 -4 M32 -22 l-12 -4", "M8 -7 l0 5 M26 -7 l0 5", "M8 10 q10 12 20 0 q-10 -4 -20 0"],
2639
+ dizzy: ["", "M4 -8 l8 8 M12 -8 l-8 8 M22 -8 l8 8 M30 -8 l-8 8", "M8 14 q5 4 10 0 q5 -4 10 0"],
2640
+ blink: ["M2 -16 l12 0 M20 -16 l12 0", "M4 -3 l8 0 M22 -3 l8 0", "M10 14 q8 5 16 0"],
2641
+ };
2642
+
2643
+ const st = Object.assign({ x: v.x, air: 0, rot: 0, pv: 1, sq: 1, facing: v.facing, loco: 0, phase: 0, gait: 0, face: v.face }, POSES.idle, poseOf(id, v.pose));
2644
+ const fmt = (n) => n.toFixed(1);
2645
+ const seg = (a, b, c) => "M" + fmt(a[0]) + " " + fmt(a[1]) + " L" + fmt(b[0]) + " " + fmt(b[1]) + " L" + fmt(c[0]) + " " + fmt(c[1]);
2646
+ const at = (o, ang, len, f) => [o[0] + f * Math.sin(rad(ang)) * len, o[1] + Math.cos(rad(ang)) * len];
2647
+ // locomotion cycle (run when gait = 1, walk when 0) at phase p, blended over the pose by `loco`
2648
+ function cycle(p, gait) {
2649
+ const th = 2 * Math.PI * p, A = 22 + 18 * gait, K = 10 + 70 * gait, s = Math.sin(th), c = Math.cos(th);
2650
+ const kn = (cc) => 6 + K * Math.max(0, cc);
2651
+ return { lean: 3 + 13 * gait, head: -2 * gait, l1h: A * s, l1k: kn(c), l2h: -A * s, l2k: kn(-c),
2652
+ a1s: -(16 + 30 * gait) * s, a1e: 14 + 76 * gait, a2s: (16 + 30 * gait) * s, a2e: 14 + 76 * gait, bob: (4 + 10 * gait) * Math.abs(Math.cos(th)) };
2653
+ }
2654
+ let joints = null;
2655
+ function draw() {
2656
+ const f = st.facing, q = {};
2657
+ const cy = st.loco > 0 ? cycle(st.phase, st.gait) : null;
2658
+ for (const k of KEYS) q[k] = cy ? st[k] + (cy[k] - st[k]) * st.loco : st[k];
2659
+ // the lower foot stands on the ground: hip height comes from the legs, so a crouch lowers the body by itself
2660
+ const drop = Math.max(L.th * Math.cos(rad(q.l1h)) + L.sh * Math.cos(rad(q.l1h - q.l1k)), L.th * Math.cos(rad(q.l2h)) + L.sh * Math.cos(rad(q.l2h - q.l2k)));
2661
+ const bob = cy ? cy.bob * st.loco : 0;
2662
+ const hip = [st.x, v.ground - st.air - drop - bob];
2663
+ const up = [f * Math.sin(rad(q.lean)), -Math.cos(rad(q.lean))];
2664
+ const chest = [hip[0] + up[0] * L.torso, hip[1] + up[1] * L.torso];
2665
+ const sho = [hip[0] + up[0] * (L.torso - 10 * S), hip[1] + up[1] * (L.torso - 10 * S)];
2666
+ const hang = 180 + q.lean + q.head * 0.4;
2667
+ const headC = [chest[0] + f * Math.sin(rad(q.lean + q.head * 0.4)) * (L.neck + L.r), chest[1] - Math.cos(rad(q.lean + q.head * 0.4)) * (L.neck + L.r)];
2668
+ const limb = (o, a1, a2, l1, l2) => { const m = at(o, a1, l1, f), e = at(m, a2, l2, f); return [o, m, e]; };
2669
+ const A1 = limb(sho, q.a1s + q.lean, q.a1s + q.lean + q.a1e, L.ua, L.fa), A2 = limb(sho, q.a2s + q.lean, q.a2s + q.lean + q.a2e, L.ua, L.fa);
2670
+ const G1 = limb(hip, q.l1h, q.l1h - q.l1k, L.th, L.sh), G2 = limb(hip, q.l2h, q.l2h - q.l2k, L.th, L.sh);
2671
+ const foot = (g) => " L" + fmt(g[2][0] + f * L.foot) + " " + fmt(g[2][1] + 2 * S);
2672
+ arm1.setAttribute("d", seg(A1[0], A1[1], A1[2])); arm2.setAttribute("d", seg(A2[0], A2[1], A2[2]));
2673
+ leg1.setAttribute("d", seg(G1[0], G1[1], G1[2]) + foot(G1)); leg2.setAttribute("d", seg(G2[0], G2[1], G2[2]) + foot(G2));
2674
+ torso.setAttribute("d", "M" + fmt(hip[0]) + " " + fmt(hip[1]) + " L" + fmt(chest[0]) + " " + fmt(chest[1]));
2675
+ headG.setAttribute("transform", "translate(" + fmt(headC[0]) + " " + fmt(headC[1]) + ") rotate(" + fmt(f * (q.lean * 0.5 + q.head)) + ")");
2676
+ const fc = FACE[st.face] || FACE.calm;
2677
+ faceG.setAttribute("transform", "scale(" + f * S + " " + S + ") translate(-12 0)");
2678
+ brow.setAttribute("d", fc[0] || "M0 0"); eyes.setAttribute("d", fc[1]); mouth.setAttribute("d", fc[2]);
2679
+ // squash and stretch about the feet, spin about the belly; volume is kept (x scales by 1 / sqrt(y))
2680
+ const sy = st.sq, sx = 1 / Math.sqrt(sy), pivot = [hip[0], v.ground - st.air - (drop * 0.9 + bob) * st.pv];
2681
+ body.setAttribute("transform", "rotate(" + fmt(f * st.rot) + " " + fmt(pivot[0]) + " " + fmt(pivot[1]) + ") translate(" + fmt(st.x) + " " + fmt(v.ground) + ") scale(" + sx.toFixed(4) + " " + sy.toFixed(4) + ") translate(" + fmt(-st.x) + " " + fmt(-v.ground) + ")");
2682
+ if (shadow) { const k = Math.max(0.35, 1 - st.air / (400 * S)); shadow.setAttribute("cx", fmt(st.x)); shadow.setAttribute("cy", fmt(v.ground + 4 * S)); shadow.setAttribute("rx", fmt(70 * S * k * sx)); shadow.setAttribute("opacity", (0.22 * k).toFixed(3)); }
2683
+ // joints where they are drawn: through the body's squash and spin, so a held prop stays in the hand in a roll
2684
+ const ca = Math.cos(rad(f * st.rot)), sa = Math.sin(rad(f * st.rot));
2685
+ const world = (p) => {
2686
+ const x = st.x + (p[0] - st.x) * sx - pivot[0], y = v.ground + (p[1] - v.ground) * sy - pivot[1];
2687
+ return [pivot[0] + x * ca - y * sa, pivot[1] + x * sa + y * ca];
2688
+ };
2689
+ const dir = (a, b) => (Math.atan2(b[1] - a[1], b[0] - a[0]) * 180) / Math.PI;
2690
+ // the angle a prop turns by with its joint: the head's tilt, the torso's lean, a hand along its forearm
2691
+ const turn = { head: f * (q.lean * 0.5 + q.head), hip: f * q.lean, chest: f * q.lean, hand1: dir(A1[1], A1[2]) - (f > 0 ? 0 : 180), hand2: dir(A2[1], A2[2]) - (f > 0 ? 0 : 180) };
2692
+ joints = { hand1: world(A1[2]), hand2: world(A2[2]), head: world(headC), hip: world(hip), chest: world(chest) };
2693
+ for (const p of props) {
2694
+ const j = joints[p.joint];
2695
+ if (!p.rotate && !p.mirror) { p.el.style.transform = "translate(" + fmt((j[0] + f * p.dx) / K) + "px," + fmt((j[1] + p.dy) / K) + "px)"; continue; }
2696
+ const a = p.rotate ? turn[p.joint] + f * st.rot : 0, m = p.mirror ? f : 1, ox = p.mirror ? p.dx : f * p.dx;
2697
+ p.el.style.transform = "translate(" + fmt(j[0] / K) + "px," + fmt(j[1] / K) + "px) rotate(" + fmt(a) + "deg) scale(" + m + ",1) translate(" + fmt(ox / K) + "px," + fmt(p.dy / K) + "px)";
2698
+ }
2699
+ }
2700
+
2701
+ // ---- acts ----
2702
+ const cur = { x: v.x, facing: v.facing, pose: Object.assign({}, pick(st, KEYS)) };
2703
+ const lag = F(v.overlap);
2704
+ const set = (t, props) => { if (P.q(t) <= 0) Object.assign(st, props); else tl.set(st, props, P.tick(t)); };
2705
+ // pose change with overlap: body first, head and arms trail by `overlap` frames and settle with a little follow-through
2706
+ function poseTo(t, pose, dur, ease, follow) {
2707
+ const target = Object.assign({}, cur.pose, pose);
2708
+ const b = pick(target, BODY), l = pick(target, LIMBS);
2709
+ tl.to(st, Object.assign(b, { duration: dur, ease: ease || P.EASE.move }), P.q(t));
2710
+ tl.to(st, Object.assign(l, { duration: dur + lag, ease: follow ? "back.out(1.6)" : ease || P.EASE.move }), P.q(t + (follow ? lag : 0)));
2711
+ cur.pose = target;
2712
+ }
2713
+ let end = P.q(v.at), times = [];
2714
+ for (const a of v.acts) {
2715
+ let t = P.q(a.at != null ? a.at : end);
2716
+ // an act that starts within one frame of the previous end (times rounded to frames) starts on that end
2717
+ if (t < end && t >= end - F(1) - 1e-6 && !a.face && !a.with) t = end;
2718
+ if (t < end - 1e-6 && !a.face && !a.with) throw new Error("E_PRIM_VAR " + id + ": acts must be in time order (act at " + t + " starts before the previous ends at " + end + ")");
2719
+ if (a.face) { P.oneOf(id, "face", a.face, FACES); set(t, { face: a.face }); if (Object.keys(a).length === 2) { times.push({ face: a.face, at: t }); continue; } }
2720
+ if (a.facing) { P.oneOf(id, "facing", a.facing, [1, -1]); set(t, { facing: a.facing }); cur.facing = a.facing; }
2721
+ if (a.pose) {
2722
+ const d = a.dur != null ? a.dur : 0.3;
2723
+ poseTo(t, poseOf(id, a.pose), d, a.ease, a.follow !== false);
2724
+ if (a.x != null) { tl.fromTo(st, { x: cur.x }, { x: a.x, duration: d, ease: a.ease || P.EASE.move, immediateRender: false }, t); cur.x = a.x; }
2725
+ end = P.q(t + d); times.push({ pose: a.pose, at: t, end }); continue;
2726
+ }
2727
+ if (a.run || a.walk) {
2728
+ const o = a.run || a.walk, gait = a.run ? 1 : 0, until = P.q(P.num(id, "until", o.until, t + 0.1, 1e4));
2729
+ const dx = o.to - cur.x, dir = dx < 0 ? -1 : 1, cyc = (gait ? 430 : 290) * S;
2730
+ set(t, { facing: dir, gait }); cur.facing = dir;
2731
+ const ph = { d: 0 }, x0 = cur.x;
2732
+ tl.to(st, { loco: 1, duration: F(4), ease: "power1.out" }, t);
2733
+ tl.fromTo(ph, { d: 0 }, { d: Math.abs(dx), duration: until - t, ease: o.ease || "power1.inOut", immediateRender: false, onUpdate: () => { st.x = x0 + dir * ph.d; st.phase = ph.d / cyc; } }, t);
2734
+ tl.to(st, { loco: 0, duration: F(5), ease: "power2.out" }, until - F(3));
2735
+ if (o.face) set(t, { face: o.face });
2736
+ cur.x = o.to; end = until; times.push({ [gait ? "run" : "walk"]: o.to, at: t, arrive: until }); continue;
2737
+ }
2738
+ if (a.jump) {
2739
+ // anticipation crouch before `at` (take-off), stretch on the way up, tuck at the top, land with a squash at `until`
2740
+ const o = a.jump, until = P.q(P.num(id, "until", o.until, t + 0.2, 1e4)), h = (o.height != null ? o.height : 220) * S, to = o.to != null ? o.to : cur.x;
2741
+ const pre = F(5), air = until - t, prev = Object.assign({}, cur.pose);
2742
+ poseTo(t - pre, POSES.crouch, pre, "power2.out", false); tl.to(st, { sq: 0.86, duration: pre, ease: "power2.out" }, t - pre);
2743
+ poseTo(t, POSES.stretch, F(4), "power3.out", false); tl.to(st, { sq: 1.12, duration: F(3), ease: "power2.out" }, t);
2744
+ tl.to(st, { sq: 1, duration: F(5), ease: "power2.inOut" }, t + F(3));
2745
+ poseTo(t + air * 0.3, a.jump.pose ? poseOf(id, a.jump.pose) : POSES.tuck, air * 0.4, "power2.inOut", true);
2746
+ const ar = { u: 0 };
2747
+ const jx = cur.x;
2748
+ tl.fromTo(ar, { u: 0 }, { u: 1, duration: air, ease: "none", immediateRender: false, onUpdate: () => { st.air = 4 * h * ar.u * (1 - ar.u); st.x = jx + (to - jx) * ar.u; } }, t);
2749
+ poseTo(until - F(3), POSES.land, F(3), "power2.in", false);
2750
+ tl.to(st, { sq: 0.8, duration: F(2), ease: "power2.out" }, until); tl.to(st, { sq: 1, duration: F(8), ease: "back.out(2)" }, until + F(2));
2751
+ poseTo(until + F(4), o.end ? poseOf(id, o.end) : prev, 0.3, "power2.out", true);
2752
+ cur.x = to; end = P.q(until + F(4) + 0.3); times.push({ jump: to, takeoff: t, land: until }); continue;
2753
+ }
2754
+ if (a.strike) {
2755
+ // `at` is the contact frame (put the hit sound there): wind-up before it, a 2-frame snap, a hold, recover to guard
2756
+ const k = P.oneOf(id, "strike", a.strike, ["punch", "kick", "uppercut"]), wind = F(a.wind != null ? Math.round(a.wind * P.fps()) : 6), hold = F(a.hold != null ? a.hold : 3);
2757
+ poseTo(t - wind - F(2), POSES[STRIKES[k]], wind, "power2.out", false);
2758
+ poseTo(t - F(2), POSES[k], F(2), "power4.in", false);
2759
+ if (a.lunge) { tl.fromTo(st, { x: cur.x }, { x: cur.x + cur.facing * a.lunge, duration: F(4), ease: "power3.out", immediateRender: false }, t - F(2)); cur.x += cur.facing * a.lunge; }
2760
+ poseTo(t + hold, POSES.guard, 0.3, "power2.out", true);
2761
+ end = P.q(t + hold + 0.3); times.push({ strike: k, contact: t }); continue;
2762
+ }
2763
+ if (a.hit || a.block) {
2764
+ const o = a.hit || a.block, power = o.power != null ? o.power : 1;
2765
+ const back = -cur.facing * (a.hit ? 70 : 24) * power * S, rec = a.hit ? 0.45 : 0.25;
2766
+ poseTo(t, a.hit ? POSES.hurt : POSES.block, F(2), "power4.out", false);
2767
+ tl.fromTo(st, { x: cur.x }, { x: cur.x + back, duration: 0.3, ease: "power3.out", immediateRender: false }, t); cur.x += back;
2768
+ if (a.hit) set(t, { face: o.face || "hurt" });
2769
+ if (!o.stay) poseTo(t + F(4), POSES.guard, rec, "power2.inOut", true);
2770
+ end = P.q(t + (o.stay ? F(2) : F(4) + rec)); times.push({ [a.hit ? "hit" : "block"]: t }); continue;
2771
+ }
2772
+ if (a.roll) {
2773
+ const o = a.roll, until = P.q(P.num(id, "until", o.until, t + 0.2, 1e4)), prev = Object.assign({}, cur.pose);
2774
+ poseTo(t, POSES.tuck, F(4), "power2.out", false);
2775
+ tl.to(st, { rot: "+=360", duration: until - t, ease: "power1.inOut" }, t);
2776
+ tl.fromTo(st, { x: cur.x }, { x: o.to, duration: until - t, ease: "power1.inOut", immediateRender: false }, t);
2777
+ poseTo(until - F(2), o.pose ? poseOf(id, o.pose) : POSES.land, F(3), "power2.out", false);
2778
+ poseTo(until + F(3), o.end ? poseOf(id, o.end) : prev, 0.3, "power2.out", true);
2779
+ cur.x = o.to; end = P.q(until + F(3) + 0.3); times.push({ roll: o.to, at: t, until }); continue;
2780
+ }
2781
+ if (a.fall) {
2782
+ // fall flat: tip over the feet, hit the ground on `until` with a small bounce
2783
+ const o = a.fall, until = P.q(P.num(id, "until", o.until, t + 0.15, 1e4));
2784
+ P.oneOf(id, "fall.dir", o.dir || "back", ["back", "forward", "down"]);
2785
+ if (o.dir === "down") {
2786
+ // collapse in place (vertical frames): knees give, the hips reach the floor on `until`, a small settle
2787
+ poseTo(t, POSES.crouch, (until - t) * 0.5, "power2.in", false);
2788
+ poseTo(t + (until - t) * 0.5, POSES.slump, (until - t) * 0.5, "power2.in", true);
2789
+ tl.to(st, { sq: 0.9, duration: F(2), ease: "power2.out" }, until); tl.to(st, { sq: 1, duration: F(6), ease: "power2.out" }, until + F(2));
2790
+ if (o.face) set(t, { face: o.face });
2791
+ end = P.q(until + F(8)); times.push({ fall: "down", land: until }); continue;
2792
+ }
2793
+ const dir = o.dir === "forward" ? 1 : -1;
2794
+ set(t, { pv: 0 });
2795
+ poseTo(t, dir > 0 ? POSES.stumble : POSES.hurt, (until - t) * 0.6, "power2.in", false);
2796
+ poseTo(until - F(2), POSES.lie, F(6), "power2.out", true);
2797
+ tl.to(st, { rot: dir * 84, duration: until - t, ease: "power2.in" }, t);
2798
+ tl.to(st, { rot: dir * 78, duration: F(3), ease: "power2.out" }, until); tl.to(st, { rot: dir * 84, duration: F(4), ease: "power2.in" }, until + F(3));
2799
+ if (o.face) set(t, { face: o.face });
2800
+ end = P.q(until + F(7)); times.push({ fall: o.dir || "back", land: until }); continue;
2801
+ }
2802
+ if (a.get_up) {
2803
+ const d = a.get_up.dur || 0.6;
2804
+ tl.to(st, { rot: 0, duration: d, ease: "power2.inOut" }, t); set(t + d, { pv: 1 });
2805
+ poseTo(t, POSES.crouch, d * 0.6, "power2.out", false); poseTo(t + d * 0.6, POSES.guard, d * 0.4, "power2.out", true);
2806
+ end = P.q(t + d); times.push({ get_up: t }); continue;
2807
+ }
2808
+ if (a.blink) { set(t, { face: "blink" }); set(t + F(3), { face: a.blink === true ? st.face : a.blink }); continue; }
2809
+ throw new Error("E_PRIM_VAR " + id + ": unknown act " + JSON.stringify(Object.keys(a)) + " (pose, run, walk, jump, strike, hit, block, roll, fall, get_up, face, blink)");
2810
+ }
2811
+
2812
+ // redraw from state on every seek (and on GSAP updates outside Mosio, for the gallery)
2813
+ if (P.q(end) > tl.duration()) tl.to({}, { duration: 0 }, P.q(end));
2814
+ tl.eventCallback("onUpdate", ((prev) => function () { draw(); if (prev) prev.apply(this, arguments); })(tl.eventCallback("onUpdate")));
2815
+ if (window.__mosio && typeof window.__mosio.onSeek === "function") window.__mosio.onSeek(() => draw()); else draw();
2816
+ draw();
2817
+ // where a joint is at time t, in 1080p design px (to throw a prop from the hand, aim a burst at a foot of a kick):
2818
+ // seeks the timeline there and back, so call it after every act is scheduled and before playback
2819
+ const jointAt = (name, t) => {
2820
+ P.oneOf(id, "jointAt", name, JOINTS);
2821
+ const was = tl.time();
2822
+ // events on: a run moves x in its onUpdate, which a default (silent) seek skips
2823
+ tl.seek(t, false); draw();
2824
+ const j = joints[name].slice();
2825
+ tl.seek(was, false); draw();
2826
+ return j;
2827
+ };
2828
+ const rig = { state: st, poses: POSES, faces: FACES, draw, joints: () => joints, jointAt, poseTo };
2829
+ return { at: P.q(v.at), end, entrance_end: P.q(v.at), exit_at: null, hold_s: 0, times, rig };
2830
+ });
2831
+ P.STICK_POSES = POSES;
2832
+ })(window.MosioPrims);
2485
2833
  (function (P) {
2486
2834
  "use strict";
2487
2835
  const C = P.COMMON_DEFAULTS, E = P.EASE;
@@ -0,0 +1,51 @@
1
+ (function (P) {
2
+ "use strict";
3
+ // The contact frame of a hit, a landing or a stamp: a one-frame flash, a ring that bursts out, radial speed lines and a
4
+ // jagged star that pops and fades. Everything is placed from `at` in whole frames, so it lands exactly on the frame the
5
+ // sound and the camera shake use. Angles and lengths come from a seeded generator: same seed, same burst.
6
+ P.define("impact-burst", Object.assign({}, P.COMMON_DEFAULTS, {
7
+ point: [50, 50], on: null, size: 1, lines: 10, color: "--text", accent: "--accent", flash: true, star: true, seed: 1,
8
+ }), (tl, target, v) => {
9
+ const id = "impact-burst", root = P.one(target, id), F = P.frames;
10
+ P.num(id, "size", v.size, 0.2, 5); P.int(id, "lines", v.lines, 0, 32); P.int(id, "seed", v.seed, 0, 1e9);
11
+ const col = (c) => (c && c.startsWith("--") ? "var(" + c + ")" : c);
12
+ if (getComputedStyle(root).position === "static") root.style.position = "absolute";
13
+ // lengths are 1080p design px: the shorter side of the box is 1080, so the same numbers fit any output size
14
+ const BW = root.offsetWidth || 1080, BH = root.offsetHeight || 1920, K = 1080 / Math.min(BW, BH), W = BW * K, H = BH * K;
15
+ const svg = P.svg("svg", { viewBox: "0 0 " + W.toFixed(2) + " " + H.toFixed(2), width: BW, height: BH, style: "position:absolute;left:0;top:0;overflow:visible;pointer-events:none" }, root);
16
+ P.tagId(svg, root, "burst");
17
+ const g = P.svg("g", { opacity: 0 }, svg);
18
+ const p = P.plan(v, 0.4, { noExit: true, hold: 0 });
19
+ const t = p.at, s = v.size, rnd = P.rng(v.seed);
20
+ const place = () => {
21
+ let x = (P.pair(id, "point", v.point)[0] / 100) * W, y = (v.point[1] / 100) * H;
22
+ if (v.on) { const b = P.boxAt(tl, P.one(v.on, id + " on"), root, t); x = (b.x + b.w / 2) * K; y = (b.y + b.h / 2) * K; }
23
+ g.setAttribute("transform", "translate(" + x.toFixed(1) + " " + y.toFixed(1) + ")");
24
+ };
25
+ if (v.on) P.afterFonts(place); else place();
26
+ const flash = v.flash ? P.svg("circle", { r: 95 * s, fill: col(v.color) }, g) : null;
27
+ const ring = P.svg("circle", { r: 60 * s, fill: "none", stroke: col(v.color), "stroke-width": 10 * s }, g);
28
+ let star = null;
29
+ if (v.star) {
30
+ const pts = []; const n = 9;
31
+ for (let i = 0; i < n * 2; i++) { const a = (i / (n * 2)) * Math.PI * 2 + rnd() * 0.2, r = (i % 2 ? 48 : 120 + rnd() * 50) * s; pts.push((Math.cos(a) * r).toFixed(1) + "," + (Math.sin(a) * r).toFixed(1)); }
32
+ star = P.svg("polygon", { points: pts.join(" "), fill: col(v.accent), stroke: col(v.color), "stroke-width": 6 * s, "stroke-linejoin": "round" }, g);
33
+ }
34
+ const lines = [];
35
+ for (let i = 0; i < v.lines; i++) {
36
+ const a = (i / v.lines) * Math.PI * 2 + (rnd() - 0.5) * 0.5, r0 = (130 + rnd() * 40) * s, len = (90 + rnd() * 110) * s;
37
+ const ln = P.svg("line", { x1: (Math.cos(a) * r0).toFixed(1), y1: (Math.sin(a) * r0).toFixed(1), x2: (Math.cos(a) * (r0 + len)).toFixed(1), y2: (Math.sin(a) * (r0 + len)).toFixed(1), stroke: col(v.color), "stroke-width": (7 + rnd() * 5) * s, "stroke-linecap": "round", "stroke-dasharray": len.toFixed(1), "stroke-dashoffset": len.toFixed(1) }, g);
38
+ lines.push([ln, len]);
39
+ }
40
+ P.setAt(tl, g, { opacity: 1 }, t);
41
+ if (flash) { P.setAt(tl, flash, { opacity: 1 }, t); P.setAt(tl, flash, { opacity: 0 }, t + F(2)); }
42
+ tl.fromTo(ring, { attr: { r: 60 * s }, opacity: 1 }, { attr: { r: 250 * s }, opacity: 0, duration: F(8), ease: "power3.out", immediateRender: false }, t);
43
+ if (star) {
44
+ tl.fromTo(star, { scale: 1.35, rotation: -8, transformOrigin: "0 0" }, { scale: 1, rotation: 0, duration: F(4), ease: "power3.out", immediateRender: false }, t);
45
+ tl.to(star, { scale: 0.6, opacity: 0, duration: F(5), ease: "power2.in" }, t + F(7));
46
+ }
47
+ for (const [ln, len] of lines) tl.fromTo(ln, { attr: { "stroke-dashoffset": len }, opacity: 1 }, { attr: { "stroke-dashoffset": -len }, opacity: 0.2, duration: F(7), ease: "power3.out", immediateRender: false }, t);
48
+ P.setAt(tl, g, { opacity: 0 }, t + F(12));
49
+ return Object.assign({}, p.result, { contact: t, end: P.q(t + F(12)) });
50
+ });
51
+ })(window.MosioPrims);
@@ -0,0 +1,130 @@
1
+ {
2
+ "schema": "mosio.primitive/1",
3
+ "id": "impact-burst",
4
+ "title": "Impact burst",
5
+ "kind": "motion",
6
+ "version": "0.1.0",
7
+ "summary": "The contact frame of a hit or a landing: a two-frame flash, a ring bursting out, radial speed lines and a jagged star that pops and fades in 12 frames.",
8
+ "api": "MosioPrims.impactBurst(tl, target, vars)",
9
+ "target": "One empty, positioned element covering the stage (above the characters).",
10
+ "parts": [],
11
+ "vars": {
12
+ "at": {
13
+ "type": "number",
14
+ "default": 0,
15
+ "min": 0,
16
+ "description": "The contact frame, seconds (a strike's `contact`, a landing, a stamp)."
17
+ },
18
+ "duration": {
19
+ "type": "number|null",
20
+ "default": null,
21
+ "description": "Unused (the burst is 12 frames); kept for the common API."
22
+ },
23
+ "motion": {
24
+ "type": "number|null",
25
+ "default": null,
26
+ "description": "Unused; kept for the common API."
27
+ },
28
+ "exit": {
29
+ "type": "boolean",
30
+ "default": false,
31
+ "description": "Unused; the burst always clears itself."
32
+ },
33
+ "point": {
34
+ "type": "number[2]",
35
+ "default": [
36
+ 50,
37
+ 50
38
+ ],
39
+ "description": "Centre [x, y], percent of the target box."
40
+ },
41
+ "on": {
42
+ "type": "string|null",
43
+ "default": null,
44
+ "description": "Selector of an element to centre on instead (measured at the contact time)."
45
+ },
46
+ "size": {
47
+ "type": "number",
48
+ "default": 1,
49
+ "min": 0.2,
50
+ "max": 5,
51
+ "description": "Scale: 1 is about 500 px across at its widest."
52
+ },
53
+ "lines": {
54
+ "type": "integer",
55
+ "default": 10,
56
+ "min": 0,
57
+ "max": 32,
58
+ "description": "Radial speed lines."
59
+ },
60
+ "color": {
61
+ "type": "string",
62
+ "default": "--text",
63
+ "description": "Flash, ring and line colour (token or CSS colour)."
64
+ },
65
+ "accent": {
66
+ "type": "string",
67
+ "default": "--accent",
68
+ "description": "Star fill."
69
+ },
70
+ "flash": {
71
+ "type": "boolean",
72
+ "default": true,
73
+ "description": "A two-frame solid disc on contact."
74
+ },
75
+ "star": {
76
+ "type": "boolean",
77
+ "default": true,
78
+ "description": "The jagged comic star."
79
+ },
80
+ "seed": {
81
+ "type": "integer",
82
+ "default": 1,
83
+ "min": 0,
84
+ "description": "Seed of the line angles and star points."
85
+ }
86
+ },
87
+ "timing": {
88
+ "natural_s": 0.4,
89
+ "elastic": true,
90
+ "rule": "Fixed length: 2 frames of flash, ring and lines over 7 to 8 frames, gone after 12. Put it on the exact contact frame, with the hit sound and the camera shake."
91
+ },
92
+ "eases": "power3.out bursts, power2.in fade of the star",
93
+ "tokens": [
94
+ "text",
95
+ "accent"
96
+ ],
97
+ "use_when": [
98
+ "a punch, kick or collision lands",
99
+ "a heavy landing or a stamp that needs weight",
100
+ "a reveal that should hit like an impact (once or twice a film)"
101
+ ],
102
+ "avoid_when": [
103
+ "soft or calm films",
104
+ "more than about one burst per two seconds (it stops reading as an event)"
105
+ ],
106
+ "pairs_with": [
107
+ "stick-figure",
108
+ "sparks",
109
+ "headline-slam"
110
+ ],
111
+ "usage": "MosioPrims.impactBurst(tl, '#fx', { at: hero.times[0].contact, point: [55, 48] })",
112
+ "example": "scene.html",
113
+ "golden": {
114
+ "scene_frames": 60,
115
+ "frames": [
116
+ 30,
117
+ 32,
118
+ 36
119
+ ],
120
+ "size": [
121
+ 640,
122
+ 360
123
+ ],
124
+ "tolerance": {
125
+ "mean_abs": 2.0,
126
+ "outlier_share": 0.005
127
+ }
128
+ },
129
+ "licence": "Own work; uses GSAP (pinned in the project libraries)."
130
+ }