@bydiorama/motion 0.0.0-stage → 0.4.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.
Files changed (354) hide show
  1. package/CREDITS.md +62 -0
  2. package/LICENSE +21 -0
  3. package/README.md +142 -2
  4. package/catalog.json +4697 -0
  5. package/dist/npm/brief/brief.d.ts +28 -0
  6. package/dist/npm/brief/brief.js +159 -0
  7. package/dist/npm/brief/types.d.ts +75 -0
  8. package/dist/npm/brief/types.js +2 -0
  9. package/dist/npm/browser/motion.js +1039 -0
  10. package/dist/npm/browser/page.js +4821 -0
  11. package/dist/npm/browser/wizard.js +1511 -0
  12. package/dist/npm/build/design.d.ts +54 -0
  13. package/dist/npm/build/design.js +91 -0
  14. package/dist/npm/build/index.d.ts +39 -0
  15. package/dist/npm/build/index.js +66 -0
  16. package/dist/npm/build/iso.d.ts +41 -0
  17. package/dist/npm/build/iso.js +71 -0
  18. package/dist/npm/catalog.d.ts +24 -0
  19. package/dist/npm/catalog.js +23 -0
  20. package/dist/npm/cli/browser.d.ts +26 -0
  21. package/dist/npm/cli/browser.js +66 -0
  22. package/dist/npm/cli/capture.d.ts +26 -0
  23. package/dist/npm/cli/capture.js +94 -0
  24. package/dist/npm/cli/files.d.ts +14 -0
  25. package/dist/npm/cli/files.js +87 -0
  26. package/dist/npm/cli/frames.d.ts +27 -0
  27. package/dist/npm/cli/frames.js +125 -0
  28. package/dist/npm/cli/guard.d.ts +23 -0
  29. package/dist/npm/cli/guard.js +158 -0
  30. package/dist/npm/cli/library.d.ts +2 -0
  31. package/dist/npm/cli/library.js +55 -0
  32. package/dist/npm/cli/main.d.ts +17 -0
  33. package/dist/npm/cli/main.js +964 -0
  34. package/dist/npm/cli/motion.d.ts +2 -0
  35. package/dist/npm/cli/motion.js +6 -0
  36. package/dist/npm/cli/record.d.ts +36 -0
  37. package/dist/npm/cli/record.js +142 -0
  38. package/dist/npm/cli/review.d.ts +45 -0
  39. package/dist/npm/cli/review.js +139 -0
  40. package/dist/npm/cli/schema.d.ts +852 -0
  41. package/dist/npm/cli/schema.js +120 -0
  42. package/dist/npm/cli/server.d.ts +17 -0
  43. package/dist/npm/cli/server.js +135 -0
  44. package/dist/npm/core/ease.d.ts +39 -0
  45. package/dist/npm/core/ease.js +176 -0
  46. package/dist/npm/core/frame.d.ts +52 -0
  47. package/dist/npm/core/frame.js +60 -0
  48. package/dist/npm/core/shapes.d.ts +8 -0
  49. package/dist/npm/core/shapes.js +88 -0
  50. package/dist/npm/core/stagger.d.ts +19 -0
  51. package/dist/npm/core/stagger.js +77 -0
  52. package/dist/npm/core/tap.d.ts +19 -0
  53. package/dist/npm/core/tap.js +42 -0
  54. package/dist/npm/core/track.d.ts +4 -0
  55. package/dist/npm/core/track.js +23 -0
  56. package/dist/npm/dom/mount.d.ts +127 -0
  57. package/dist/npm/dom/mount.js +950 -0
  58. package/dist/npm/dom/page.d.ts +37 -0
  59. package/dist/npm/dom/page.js +77 -0
  60. package/dist/npm/dom/soundtrack.d.ts +13 -0
  61. package/dist/npm/dom/soundtrack.js +37 -0
  62. package/dist/npm/dom/stage.css.d.ts +1 -0
  63. package/dist/npm/dom/stage.css.js +44 -0
  64. package/dist/npm/dom/tokens.d.ts +10 -0
  65. package/dist/npm/dom/tokens.js +38 -0
  66. package/dist/npm/dom/ui-themes.css.d.ts +8 -0
  67. package/dist/npm/dom/ui-themes.css.js +9 -0
  68. package/dist/npm/film/beats.d.ts +64 -0
  69. package/dist/npm/film/beats.js +282 -0
  70. package/dist/npm/film/pace.d.ts +94 -0
  71. package/dist/npm/film/pace.js +396 -0
  72. package/dist/npm/film/resolve.d.ts +16 -0
  73. package/dist/npm/film/resolve.js +997 -0
  74. package/dist/npm/film/tempo.d.ts +19 -0
  75. package/dist/npm/film/tempo.js +34 -0
  76. package/dist/npm/film/tune.d.ts +17 -0
  77. package/dist/npm/film/tune.js +68 -0
  78. package/dist/npm/film/types.d.ts +416 -0
  79. package/dist/npm/film/types.js +16 -0
  80. package/dist/npm/index.d.ts +18 -0
  81. package/dist/npm/index.js +11 -0
  82. package/dist/npm/primitives/blur.d.ts +14 -0
  83. package/dist/npm/primitives/blur.js +59 -0
  84. package/dist/npm/primitives/canvas.d.ts +5 -0
  85. package/dist/npm/primitives/canvas.js +13 -0
  86. package/dist/npm/primitives/el/box.d.ts +2 -0
  87. package/dist/npm/primitives/el/box.js +24 -0
  88. package/dist/npm/primitives/el/frames.d.ts +15 -0
  89. package/dist/npm/primitives/el/frames.js +71 -0
  90. package/dist/npm/primitives/el/html.d.ts +2 -0
  91. package/dist/npm/primitives/el/html.js +14 -0
  92. package/dist/npm/primitives/el/image.d.ts +2 -0
  93. package/dist/npm/primitives/el/image.js +43 -0
  94. package/dist/npm/primitives/el/slot.d.ts +2 -0
  95. package/dist/npm/primitives/el/slot.js +25 -0
  96. package/dist/npm/primitives/el/text.d.ts +2 -0
  97. package/dist/npm/primitives/el/text.js +13 -0
  98. package/dist/npm/primitives/el/video.d.ts +6 -0
  99. package/dist/npm/primitives/el/video.js +179 -0
  100. package/dist/npm/primitives/fx/counter-roll.d.ts +2 -0
  101. package/dist/npm/primitives/fx/counter-roll.js +32 -0
  102. package/dist/npm/primitives/fx/depth-drift.d.ts +2 -0
  103. package/dist/npm/primitives/fx/depth-drift.js +44 -0
  104. package/dist/npm/primitives/fx/grid-ripple.d.ts +2 -0
  105. package/dist/npm/primitives/fx/grid-ripple.js +59 -0
  106. package/dist/npm/primitives/fx/odometer.d.ts +2 -0
  107. package/dist/npm/primitives/fx/odometer.js +80 -0
  108. package/dist/npm/primitives/fx/pan-across.d.ts +17 -0
  109. package/dist/npm/primitives/fx/pan-across.js +76 -0
  110. package/dist/npm/primitives/fx/path-draw.d.ts +2 -0
  111. package/dist/npm/primitives/fx/path-draw.js +105 -0
  112. package/dist/npm/primitives/fx/pin-drop.d.ts +2 -0
  113. package/dist/npm/primitives/fx/pin-drop.js +92 -0
  114. package/dist/npm/primitives/fx/shape-morph.d.ts +2 -0
  115. package/dist/npm/primitives/fx/shape-morph.js +65 -0
  116. package/dist/npm/primitives/fx/slow-push.d.ts +13 -0
  117. package/dist/npm/primitives/fx/slow-push.js +56 -0
  118. package/dist/npm/primitives/fx/stagger-fill.d.ts +2 -0
  119. package/dist/npm/primitives/fx/stagger-fill.js +33 -0
  120. package/dist/npm/primitives/index.d.ts +4 -0
  121. package/dist/npm/primitives/index.js +78 -0
  122. package/dist/npm/primitives/rig/browser-window.d.ts +2 -0
  123. package/dist/npm/primitives/rig/browser-window.js +142 -0
  124. package/dist/npm/primitives/rig/camera.d.ts +36 -0
  125. package/dist/npm/primitives/rig/camera.js +81 -0
  126. package/dist/npm/primitives/rig/footage-plane.d.ts +27 -0
  127. package/dist/npm/primitives/rig/footage-plane.js +257 -0
  128. package/dist/npm/primitives/rig/layer-stack.d.ts +39 -0
  129. package/dist/npm/primitives/rig/layer-stack.js +276 -0
  130. package/dist/npm/primitives/rig/orbit-ring.d.ts +2 -0
  131. package/dist/npm/primitives/rig/orbit-ring.js +59 -0
  132. package/dist/npm/primitives/rig/tab-stack.d.ts +9 -0
  133. package/dist/npm/primitives/rig/tab-stack.js +143 -0
  134. package/dist/npm/primitives/scene/bar-chart.d.ts +2 -0
  135. package/dist/npm/primitives/scene/bar-chart.js +83 -0
  136. package/dist/npm/primitives/scene/bento-grid.d.ts +49 -0
  137. package/dist/npm/primitives/scene/bento-grid.js +293 -0
  138. package/dist/npm/primitives/scene/grid-wall.d.ts +18 -0
  139. package/dist/npm/primitives/scene/grid-wall.js +110 -0
  140. package/dist/npm/primitives/scene/line-chart.d.ts +2 -0
  141. package/dist/npm/primitives/scene/line-chart.js +121 -0
  142. package/dist/npm/primitives/scene/logo-reveal.d.ts +2 -0
  143. package/dist/npm/primitives/scene/logo-reveal.js +117 -0
  144. package/dist/npm/primitives/scene/marquee-wall.d.ts +2 -0
  145. package/dist/npm/primitives/scene/marquee-wall.js +82 -0
  146. package/dist/npm/primitives/scene/post-carousel.d.ts +16 -0
  147. package/dist/npm/primitives/scene/post-carousel.js +195 -0
  148. package/dist/npm/primitives/scene/strip-cycle.d.ts +49 -0
  149. package/dist/npm/primitives/scene/strip-cycle.js +237 -0
  150. package/dist/npm/primitives/split.d.ts +34 -0
  151. package/dist/npm/primitives/split.js +105 -0
  152. package/dist/npm/primitives/texture/beat-field.d.ts +13 -0
  153. package/dist/npm/primitives/texture/beat-field.js +113 -0
  154. package/dist/npm/primitives/texture/gradient-drift.d.ts +2 -0
  155. package/dist/npm/primitives/texture/gradient-drift.js +56 -0
  156. package/dist/npm/primitives/texture/grain.d.ts +2 -0
  157. package/dist/npm/primitives/texture/grain.js +54 -0
  158. package/dist/npm/primitives/texture/halftone-field.d.ts +2 -0
  159. package/dist/npm/primitives/texture/halftone-field.js +36 -0
  160. package/dist/npm/primitives/texture/signal-field.d.ts +4 -0
  161. package/dist/npm/primitives/texture/signal-field.js +107 -0
  162. package/dist/npm/primitives/texture/vignette.d.ts +2 -0
  163. package/dist/npm/primitives/texture/vignette.js +23 -0
  164. package/dist/npm/primitives/transition/band-sweep.d.ts +22 -0
  165. package/dist/npm/primitives/transition/band-sweep.js +111 -0
  166. package/dist/npm/primitives/transition/beat-cut.d.ts +2 -0
  167. package/dist/npm/primitives/transition/beat-cut.js +10 -0
  168. package/dist/npm/primitives/transition/blur-dissolve.d.ts +2 -0
  169. package/dist/npm/primitives/transition/blur-dissolve.js +28 -0
  170. package/dist/npm/primitives/transition/camera-travel.d.ts +2 -0
  171. package/dist/npm/primitives/transition/camera-travel.js +69 -0
  172. package/dist/npm/primitives/transition/cover-reveal.d.ts +2 -0
  173. package/dist/npm/primitives/transition/cover-reveal.js +52 -0
  174. package/dist/npm/primitives/transition/curtain.d.ts +2 -0
  175. package/dist/npm/primitives/transition/curtain.js +40 -0
  176. package/dist/npm/primitives/transition/dive-in.d.ts +2 -0
  177. package/dist/npm/primitives/transition/dive-in.js +52 -0
  178. package/dist/npm/primitives/transition/fly-past.d.ts +2 -0
  179. package/dist/npm/primitives/transition/fly-past.js +87 -0
  180. package/dist/npm/primitives/transition/iris.d.ts +2 -0
  181. package/dist/npm/primitives/transition/iris.js +38 -0
  182. package/dist/npm/primitives/transition/overlay.d.ts +4 -0
  183. package/dist/npm/primitives/transition/overlay.js +24 -0
  184. package/dist/npm/primitives/transition/push.d.ts +2 -0
  185. package/dist/npm/primitives/transition/push.js +35 -0
  186. package/dist/npm/primitives/transition/signal-wipe.d.ts +2 -0
  187. package/dist/npm/primitives/transition/signal-wipe.js +67 -0
  188. package/dist/npm/primitives/transition/slant-wipe.d.ts +2 -0
  189. package/dist/npm/primitives/transition/slant-wipe.js +30 -0
  190. package/dist/npm/primitives/transition/stack-over.d.ts +2 -0
  191. package/dist/npm/primitives/transition/stack-over.js +38 -0
  192. package/dist/npm/primitives/transition/step-wipe.d.ts +2 -0
  193. package/dist/npm/primitives/transition/step-wipe.js +29 -0
  194. package/dist/npm/primitives/transition/strip-wipe.d.ts +40 -0
  195. package/dist/npm/primitives/transition/strip-wipe.js +121 -0
  196. package/dist/npm/primitives/transition/whip-pan.d.ts +2 -0
  197. package/dist/npm/primitives/transition/whip-pan.js +45 -0
  198. package/dist/npm/primitives/type/block-reveal.d.ts +2 -0
  199. package/dist/npm/primitives/type/block-reveal.js +61 -0
  200. package/dist/npm/primitives/type/char-cascade.d.ts +2 -0
  201. package/dist/npm/primitives/type/char-cascade.js +45 -0
  202. package/dist/npm/primitives/type/echo.d.ts +2 -0
  203. package/dist/npm/primitives/type/echo.js +57 -0
  204. package/dist/npm/primitives/type/fill-text.d.ts +14 -0
  205. package/dist/npm/primitives/type/fill-text.js +82 -0
  206. package/dist/npm/primitives/type/mask-reveal.d.ts +2 -0
  207. package/dist/npm/primitives/type/mask-reveal.js +58 -0
  208. package/dist/npm/primitives/type/scramble.d.ts +2 -0
  209. package/dist/npm/primitives/type/scramble.js +34 -0
  210. package/dist/npm/primitives/type/scribble-highlight.d.ts +2 -0
  211. package/dist/npm/primitives/type/scribble-highlight.js +84 -0
  212. package/dist/npm/primitives/type/shimmer.d.ts +2 -0
  213. package/dist/npm/primitives/type/shimmer.js +35 -0
  214. package/dist/npm/primitives/type/tracking-in.d.ts +2 -0
  215. package/dist/npm/primitives/type/tracking-in.js +37 -0
  216. package/dist/npm/primitives/type/typed-title.d.ts +2 -0
  217. package/dist/npm/primitives/type/typed-title.js +33 -0
  218. package/dist/npm/primitives/type/word-build.d.ts +2 -0
  219. package/dist/npm/primitives/type/word-build.js +44 -0
  220. package/dist/npm/primitives/type/word-roller.d.ts +2 -0
  221. package/dist/npm/primitives/type/word-roller.js +80 -0
  222. package/dist/npm/primitives/types.d.ts +183 -0
  223. package/dist/npm/primitives/types.js +5 -0
  224. package/dist/npm/primitives/ui/cursor-click.d.ts +4 -0
  225. package/dist/npm/primitives/ui/cursor-click.js +68 -0
  226. package/dist/npm/primitives/ui/page-scroll.d.ts +17 -0
  227. package/dist/npm/primitives/ui/page-scroll.js +98 -0
  228. package/dist/npm/review/fft.d.ts +4 -0
  229. package/dist/npm/review/fft.js +71 -0
  230. package/dist/npm/review/measure.d.ts +170 -0
  231. package/dist/npm/review/measure.js +577 -0
  232. package/dist/npm/tokens.d.ts +50 -0
  233. package/dist/npm/tokens.js +49 -0
  234. package/dist/npm/version.d.ts +1 -0
  235. package/dist/npm/version.js +1 -0
  236. package/examples/builder.film.mjs +18 -0
  237. package/films/feature-announcement.film.json +70 -0
  238. package/library/narratives/app-demo.md +64 -0
  239. package/library/narratives/brand-identity.md +78 -0
  240. package/library/narratives/capability-through-type.md +53 -0
  241. package/library/narratives/data-story.md +59 -0
  242. package/library/narratives/explainer.md +64 -0
  243. package/library/narratives/feature-announcement.md +68 -0
  244. package/library/narratives/infinite-loop.md +28 -0
  245. package/library/narratives/platform-launch.md +81 -0
  246. package/library/narratives/social-teaser.md +45 -0
  247. package/library/narratives/title-sequence.md +55 -0
  248. package/library/narratives/website-launch.md +65 -0
  249. package/library/primitives/fx/card-arrangements.md +26 -0
  250. package/library/primitives/fx/counter-roll.md +27 -0
  251. package/library/primitives/fx/depth-drift.md +32 -0
  252. package/library/primitives/fx/grid-ripple.md +58 -0
  253. package/library/primitives/fx/letter-interleave.md +26 -0
  254. package/library/primitives/fx/marquee-highlight.md +27 -0
  255. package/library/primitives/fx/mosaic-fill.md +23 -0
  256. package/library/primitives/fx/odometer.md +44 -0
  257. package/library/primitives/fx/pan-across.md +63 -0
  258. package/library/primitives/fx/path-draw.md +54 -0
  259. package/library/primitives/fx/pin-drop.md +51 -0
  260. package/library/primitives/fx/radial-burst.md +33 -0
  261. package/library/primitives/fx/shape-morph.md +45 -0
  262. package/library/primitives/fx/slow-push.md +63 -0
  263. package/library/primitives/fx/stagger-fill.md +28 -0
  264. package/library/primitives/rig/browser-window.md +113 -0
  265. package/library/primitives/rig/flip-ticker.md +26 -0
  266. package/library/primitives/rig/footage-plane.md +90 -0
  267. package/library/primitives/rig/layer-stack.md +168 -0
  268. package/library/primitives/rig/orbit-ring.md +43 -0
  269. package/library/primitives/rig/rolodex.md +31 -0
  270. package/library/primitives/rig/tab-stack.md +116 -0
  271. package/library/primitives/rig/tumbling-object.md +27 -0
  272. package/library/primitives/scene/bar-chart.md +49 -0
  273. package/library/primitives/scene/bento-grid.md +74 -0
  274. package/library/primitives/scene/end-card.md +28 -0
  275. package/library/primitives/scene/grid-wall.md +61 -0
  276. package/library/primitives/scene/hero-object.md +33 -0
  277. package/library/primitives/scene/kinetic-headline.md +34 -0
  278. package/library/primitives/scene/line-chart.md +47 -0
  279. package/library/primitives/scene/logo-reveal.md +53 -0
  280. package/library/primitives/scene/marquee-wall.md +33 -0
  281. package/library/primitives/scene/mosaic.md +28 -0
  282. package/library/primitives/scene/post-carousel.md +68 -0
  283. package/library/primitives/scene/specimen-grid.md +28 -0
  284. package/library/primitives/scene/stat-with-evidence.md +34 -0
  285. package/library/primitives/scene/strip-cycle.md +122 -0
  286. package/library/primitives/scene/zoomed-ui.md +29 -0
  287. package/library/primitives/texture/ascii.md +22 -0
  288. package/library/primitives/texture/beat-field.md +85 -0
  289. package/library/primitives/texture/depth-fade.md +23 -0
  290. package/library/primitives/texture/dither.md +27 -0
  291. package/library/primitives/texture/gradient-drift.md +50 -0
  292. package/library/primitives/texture/grain.md +39 -0
  293. package/library/primitives/texture/halftone-field.md +26 -0
  294. package/library/primitives/texture/signal-field.md +61 -0
  295. package/library/primitives/texture/vignette.md +53 -0
  296. package/library/primitives/transition/band-sweep.md +63 -0
  297. package/library/primitives/transition/beat-cut.md +27 -0
  298. package/library/primitives/transition/blur-dissolve.md +36 -0
  299. package/library/primitives/transition/camera-travel.md +57 -0
  300. package/library/primitives/transition/collapse-to-anchor.md +27 -0
  301. package/library/primitives/transition/cover-reveal.md +47 -0
  302. package/library/primitives/transition/curtain.md +42 -0
  303. package/library/primitives/transition/dive-in.md +51 -0
  304. package/library/primitives/transition/fly-past.md +51 -0
  305. package/library/primitives/transition/iris.md +49 -0
  306. package/library/primitives/transition/layout-locked-swap.md +28 -0
  307. package/library/primitives/transition/light-dark-flip.md +27 -0
  308. package/library/primitives/transition/push.md +47 -0
  309. package/library/primitives/transition/signal-wipe.md +52 -0
  310. package/library/primitives/transition/slant-wipe.md +44 -0
  311. package/library/primitives/transition/stack-over.md +51 -0
  312. package/library/primitives/transition/step-wipe.md +32 -0
  313. package/library/primitives/transition/strip-wipe.md +80 -0
  314. package/library/primitives/transition/torn-edge.md +26 -0
  315. package/library/primitives/transition/whip-pan.md +47 -0
  316. package/library/primitives/transition/zoom-through-letter.md +27 -0
  317. package/library/primitives/type/accent-number.md +22 -0
  318. package/library/primitives/type/block-reveal.md +41 -0
  319. package/library/primitives/type/char-cascade.md +65 -0
  320. package/library/primitives/type/echo.md +44 -0
  321. package/library/primitives/type/fill-text.md +63 -0
  322. package/library/primitives/type/focus-blur.md +22 -0
  323. package/library/primitives/type/inline-chips.md +27 -0
  324. package/library/primitives/type/mask-reveal.md +65 -0
  325. package/library/primitives/type/parting.md +23 -0
  326. package/library/primitives/type/per-word-restyle.md +28 -0
  327. package/library/primitives/type/scramble.md +26 -0
  328. package/library/primitives/type/scribble-highlight.md +47 -0
  329. package/library/primitives/type/shimmer.md +39 -0
  330. package/library/primitives/type/split-flap.md +26 -0
  331. package/library/primitives/type/style-multiply.md +23 -0
  332. package/library/primitives/type/tracking-in.md +40 -0
  333. package/library/primitives/type/typed-title.md +27 -0
  334. package/library/primitives/type/word-build.md +37 -0
  335. package/library/primitives/type/word-roller.md +52 -0
  336. package/library/primitives/type/writing-ticker.md +27 -0
  337. package/library/primitives/ui/collab-cursors.md +27 -0
  338. package/library/primitives/ui/cursor-click.md +61 -0
  339. package/library/primitives/ui/page-scroll.md +58 -0
  340. package/library/primitives/ui/prompt-typing.md +29 -0
  341. package/library/primitives/ui/streamed-result.md +23 -0
  342. package/library/primitives/ui/tour-hold.md +27 -0
  343. package/library/styles/brand-system.md +49 -0
  344. package/library/styles/clean-explainer.md +42 -0
  345. package/library/styles/dark-showcase.md +48 -0
  346. package/library/styles/editorial-type.md +37 -0
  347. package/library/styles/kinetic-poster.md +54 -0
  348. package/library/styles/product-ui.md +44 -0
  349. package/library/styles/studio-loop.md +41 -0
  350. package/library.json +1467 -0
  351. package/package.json +64 -4
  352. package/schema/film.schema.json +1316 -0
  353. package/showcase/vendor/DIALKIT-LICENSE +21 -0
  354. package/src/studio/theme/fonts/OFL.txt +94 -0
@@ -0,0 +1,78 @@
1
+ // The registry: every primitive the runtime can draw, by slug.
2
+ import { box } from "./el/box.js";
3
+ import { frames } from "./el/frames.js";
4
+ import { html } from "./el/html.js";
5
+ import { image } from "./el/image.js";
6
+ import { slot } from "./el/slot.js";
7
+ import { text } from "./el/text.js";
8
+ import { video } from "./el/video.js";
9
+ import { counterRoll } from "./fx/counter-roll.js";
10
+ import { depthDrift } from "./fx/depth-drift.js";
11
+ import { staggerFill } from "./fx/stagger-fill.js";
12
+ import { orbitRing } from "./rig/orbit-ring.js";
13
+ import { marqueeWall } from "./scene/marquee-wall.js";
14
+ import { gridWall } from "./scene/grid-wall.js";
15
+ import { bentoGrid } from "./scene/bento-grid.js";
16
+ import { postCarousel } from "./scene/post-carousel.js";
17
+ import { halftoneField } from "./texture/halftone-field.js";
18
+ import { beatCut } from "./transition/beat-cut.js";
19
+ import { blurDissolve } from "./transition/blur-dissolve.js";
20
+ import { stepWipe } from "./transition/step-wipe.js";
21
+ import { scramble } from "./type/scramble.js";
22
+ import { typedTitle } from "./type/typed-title.js";
23
+ import { wordBuild } from "./type/word-build.js";
24
+ import { gridRipple } from "./fx/grid-ripple.js";
25
+ import { odometer } from "./fx/odometer.js";
26
+ import { pathDraw } from "./fx/path-draw.js";
27
+ import { shapeMorph } from "./fx/shape-morph.js";
28
+ import { barChart } from "./scene/bar-chart.js";
29
+ import { lineChart } from "./scene/line-chart.js";
30
+ import { logoReveal } from "./scene/logo-reveal.js";
31
+ import { gradientDrift } from "./texture/gradient-drift.js";
32
+ import { grain } from "./texture/grain.js";
33
+ import { vignette } from "./texture/vignette.js";
34
+ import { beatField } from "./texture/beat-field.js";
35
+ import { footagePlane } from "./rig/footage-plane.js";
36
+ import { coverReveal } from "./transition/cover-reveal.js";
37
+ import { curtain } from "./transition/curtain.js";
38
+ import { diveIn } from "./transition/dive-in.js";
39
+ import { iris } from "./transition/iris.js";
40
+ import { push } from "./transition/push.js";
41
+ import { slantWipe } from "./transition/slant-wipe.js";
42
+ import { stackOver } from "./transition/stack-over.js";
43
+ import { blockReveal } from "./type/block-reveal.js";
44
+ import { charCascade } from "./type/char-cascade.js";
45
+ import { echo } from "./type/echo.js";
46
+ import { maskReveal } from "./type/mask-reveal.js";
47
+ import { scribbleHighlight } from "./type/scribble-highlight.js";
48
+ import { shimmer } from "./type/shimmer.js";
49
+ import { trackingIn } from "./type/tracking-in.js";
50
+ import { wordRoller } from "./type/word-roller.js";
51
+ import { cursorClick } from "./ui/cursor-click.js";
52
+ import { pinDrop } from "./fx/pin-drop.js";
53
+ import { browserWindow } from "./rig/browser-window.js";
54
+ import { layerStack } from "./rig/layer-stack.js";
55
+ import { tabStack } from "./rig/tab-stack.js";
56
+ import { signalField } from "./texture/signal-field.js";
57
+ import { cameraTravel } from "./transition/camera-travel.js";
58
+ import { flyPast } from "./transition/fly-past.js";
59
+ import { signalWipe } from "./transition/signal-wipe.js";
60
+ import { whipPan } from "./transition/whip-pan.js";
61
+ import { fillText } from "./type/fill-text.js";
62
+ import { slowPush } from "./fx/slow-push.js";
63
+ import { panAcross } from "./fx/pan-across.js";
64
+ import { pageScroll } from "./ui/page-scroll.js";
65
+ import { stripCycle } from "./scene/strip-cycle.js";
66
+ import { bandSweep } from "./transition/band-sweep.js";
67
+ import { stripWipe } from "./transition/strip-wipe.js";
68
+ const byslug = (items) => Object.fromEntries(items.map((p) => [p.slug, p]));
69
+ export const PRIMITIVES = byslug([
70
+ text, box, image, frames, video, html, slot, wordBuild, typedTitle, scramble, counterRoll, staggerFill, depthDrift, marqueeWall, orbitRing, halftoneField,
71
+ maskReveal, charCascade, blockReveal, wordRoller, trackingIn, shimmer, echo, scribbleHighlight,
72
+ odometer, pathDraw, shapeMorph, gridRipple, logoReveal, barChart, lineChart, gradientDrift, grain, vignette, beatField, footagePlane, cursorClick,
73
+ fillText, signalField, browserWindow, tabStack, layerStack, pinDrop, gridWall, slowPush, panAcross, pageScroll, bentoGrid, postCarousel, stripCycle,
74
+ ]);
75
+ export const TRANSITIONS = byslug([
76
+ beatCut, blurDissolve, stepWipe, push, iris, coverReveal, diveIn, curtain, stackOver, slantWipe,
77
+ cameraTravel, whipPan, signalWipe, flyPast, bandSweep, stripWipe,
78
+ ]);
@@ -0,0 +1,2 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const browserWindow: Primitive;
@@ -0,0 +1,142 @@
1
+ // rig/browser-window. See library/primitives/rig/browser-window.md.
2
+ //
3
+ // A page in a browser window, seen by the rigs' shared camera (./camera.ts):
4
+ // by default it turns from square-on into perspective, then lifts one part of
5
+ // itself off the page towards the camera. The lifted part is the page's own
6
+ // picture, cropped: the same image (or the same drawn page) painted twice, so
7
+ // nothing is retyped and nothing is out of step. Its shadow grows with its
8
+ // height, and the page darkens beneath it. Once the camera has arrived it keeps
9
+ // drifting slowly, so the hold is never dead still.
10
+ import { clamp } from "../../core/ease.js";
11
+ import { nums, num, str } from "../types.js";
12
+ import { cameraAt, cameraEnd, cameraParams, cameraTransform } from "./camera.js";
13
+ const hairline = (pct) => `color-mix(in srgb, var(--m-text-primary) ${pct}%, transparent)`;
14
+ /** A placeholder page drawn from the theme, for films without a screenshot. All in % of the screen. */
15
+ function paintSkeleton(box, radius) {
16
+ const doc = box.ownerDocument;
17
+ const add = (css) => { const d = doc.createElement('div'); d.style.cssText = `position:absolute;${css}`; box.appendChild(d); return d; };
18
+ box.style.background = 'var(--m-bg-base)';
19
+ const bar = (x, y, w, h, a, r = 999) => add(`left:${x}%;top:${y}%;width:${w}%;height:${h}%;border-radius:${r}px;background:${hairline(a)}`);
20
+ // nav
21
+ bar(5, 6, 9, 3.6, 34);
22
+ [52, 61, 70].forEach((x) => bar(x, 7, 6, 2, 18));
23
+ add('left:82%;top:5.4%;width:13%;height:5%;border-radius:999px;background:var(--m-bg-inverse)');
24
+ // headline, two lines and a sub line
25
+ bar(22, 22, 56, 6.4, 30);
26
+ bar(30, 31.5, 40, 6.4, 30);
27
+ bar(33, 42, 34, 2.4, 14);
28
+ // three cards: the middle one carries the accent
29
+ [[6, 'var(--m-bg-surface)'], [36, 'color-mix(in srgb, var(--m-accent) 22%, var(--m-bg-surface))'], [66, 'var(--m-bg-surface)']].forEach(([x, bg]) => {
30
+ const c = add(`left:${x}%;top:54%;width:28%;height:38%;border-radius:${radius}px;background:${bg};box-shadow:inset 0 0 0 1px ${hairline(8)}`);
31
+ const inner = (y, w, a) => { const d = doc.createElement('div'); d.style.cssText = `position:absolute;left:9%;top:${y}%;width:${w}%;height:6%;border-radius:999px;background:${hairline(a)}`; c.appendChild(d); };
32
+ inner(64, 70, 30);
33
+ inner(76, 46, 16);
34
+ const dot = doc.createElement('div');
35
+ dot.style.cssText = `position:absolute;left:9%;top:12%;width:14%;aspect-ratio:1;border-radius:50%;background:${x === 36 ? 'var(--m-accent)' : hairline(20)}`;
36
+ c.appendChild(dot);
37
+ });
38
+ }
39
+ export const browserWindow = {
40
+ slug: 'rig/browser-window',
41
+ summary: 'A page in a browser window turns into perspective, then lifts one of its parts.',
42
+ props: {
43
+ src: { type: 'string', default: '', label: 'Screenshot of the page (path or URL). Left out, a placeholder page is drawn' },
44
+ url: { type: 'string', default: 'example.com', label: 'Address shown in the bar' },
45
+ lift: { type: 'number[]', default: [], label: 'Part to lift: [x, y, width, height] in % of the page' },
46
+ },
47
+ params: {
48
+ width: { type: 'number', default: 80, min: 40, max: 100, step: 1, unit: '% of stage width', label: 'Width of the window' },
49
+ aspect: { type: 'number', default: 0.625, min: 0.4, max: 1.4, step: 0.005, unit: 'height / width', label: 'Shape of the page' },
50
+ lift: { type: 'number', default: 140, min: 0, max: 320, step: 5, unit: 'px', label: 'How far the part rises off the page' },
51
+ lift_at: { type: 'number', default: 0.8, min: 0, max: 6, step: 0.05, unit: 's', label: 'When the part starts to rise (it takes 0.8 s)' },
52
+ ...cameraParams({ path: 'in', tilt: -24, pitch: 10, roll: -2.4, zoom: 0.92, move: 1.0 }),
53
+ },
54
+ // The camera's moves and the lift, whichever ends last.
55
+ duration: (props, p) => Math.max(cameraEnd(p), nums(props.lift).length === 4 && num(p.lift) > 0 ? num(p.lift_at) + 0.8 : 0),
56
+ build(el, props, p, ctx) {
57
+ const doc = el.ownerDocument;
58
+ const [W] = ctx.size, u = W / 1080;
59
+ const winW = (num(p.width) / 100) * W, barH = Math.round(40 * u * (winW / (W * 0.8))), pageH = winW * num(p.aspect);
60
+ const winH = pageH + barH, R = 16 * u, P = winW * 2.2;
61
+ const src = str(props.src);
62
+ const wrap = doc.createElement('div');
63
+ wrap.style.cssText = `position:relative;width:${winW}px;height:${winH}px;perspective:${P}px`;
64
+ const win = doc.createElement('div');
65
+ win.style.cssText = 'position:absolute;inset:0;transform-style:preserve-3d;transform-origin:50% 50%';
66
+ const body = doc.createElement('div');
67
+ body.style.cssText = `position:absolute;inset:0;overflow:hidden;border-radius:${R}px;background:var(--m-bg-sunken);`
68
+ + `box-shadow:0 0 0 1px ${hairline(9)},0 ${60 * u}px ${120 * u}px rgba(0,0,0,.55),0 ${20 * u}px ${40 * u}px rgba(0,0,0,.35)`;
69
+ // The bar: three lights and the address.
70
+ const bar = doc.createElement('div');
71
+ bar.style.cssText = `position:absolute;left:0;top:0;right:0;height:${barH}px;display:flex;align-items:center;gap:${8 * u}px;padding:0 ${16 * u}px;`
72
+ + `background:var(--m-bg-surface);border-bottom:1px solid ${hairline(6)}`;
73
+ for (let i = 0; i < 3; i++) {
74
+ const dot = doc.createElement('i');
75
+ dot.style.cssText = `display:block;width:${11 * u}px;height:${11 * u}px;border-radius:50%;background:${hairline(16)}`;
76
+ bar.appendChild(dot);
77
+ }
78
+ const address = doc.createElement('b');
79
+ address.textContent = str(props.url);
80
+ address.style.cssText = `position:absolute;left:50%;top:50%;translate:-50% -50%;height:${barH * 0.55}px;min-width:${winW * 0.28}px;padding:0 ${12 * u}px;`
81
+ + `border-radius:${6 * u}px;background:${hairline(7)};color:var(--m-text-muted);font:500 ${barH * 0.3}px/${barH * 0.55}px var(--m-font-body);text-align:center;letter-spacing:0.01em;white-space:nowrap`;
82
+ bar.appendChild(address);
83
+ const paint = (box) => {
84
+ if (src) {
85
+ const img = doc.createElement('img');
86
+ img.src = src;
87
+ img.alt = '';
88
+ img.decoding = 'sync';
89
+ img.style.cssText = 'position:absolute;inset:0;width:100%;height:100%;object-fit:cover;object-position:top';
90
+ box.appendChild(img);
91
+ }
92
+ else
93
+ paintSkeleton(box, 12 * u);
94
+ };
95
+ const page = doc.createElement('div');
96
+ page.style.cssText = `position:absolute;left:0;top:${barH}px;width:${winW}px;height:${pageH}px;overflow:hidden`;
97
+ paint(page);
98
+ // A soft sheen across the glass and a highlight on its top edge.
99
+ const sheen = doc.createElement('div');
100
+ sheen.style.cssText = `position:absolute;inset:0;border-radius:inherit;pointer-events:none;background:linear-gradient(135deg,rgba(255,255,255,.06),transparent 38%);box-shadow:inset 0 1px 0 rgba(255,255,255,.1)`;
101
+ body.append(bar, page);
102
+ // The lifted part: the page again, cropped to the rect and pushed along z.
103
+ const rect = nums(props.lift);
104
+ let lift;
105
+ if (rect.length === 4) {
106
+ const [lx, ly, lw, lh] = [rect[0] / 100 * winW, rect[1] / 100 * pageH, rect[2] / 100 * winW, rect[3] / 100 * pageH];
107
+ const dim = doc.createElement('div');
108
+ // Beneath the part, the page darkens softly: the lifted part's own shadow on it.
109
+ dim.style.cssText = `position:absolute;left:${lx}px;top:${ly + barH}px;width:${lw}px;height:${lh}px;border-radius:${12 * u}px;background:#000;opacity:0;filter:blur(${14 * u}px)`;
110
+ body.appendChild(dim);
111
+ const box = doc.createElement('div');
112
+ box.style.cssText = `position:absolute;left:${lx}px;top:${ly + barH}px;width:${lw}px;height:${lh}px;overflow:hidden;border-radius:${12 * u}px;transform-origin:50% 50%;visibility:hidden`;
113
+ const copy = doc.createElement('div');
114
+ copy.style.cssText = `position:absolute;left:${-lx}px;top:${-ly}px;width:${winW}px;height:${pageH}px`;
115
+ paint(copy);
116
+ box.appendChild(copy);
117
+ lift = { box, dim };
118
+ }
119
+ body.appendChild(sheen);
120
+ win.appendChild(body);
121
+ if (lift)
122
+ win.appendChild(lift.box);
123
+ wrap.appendChild(win);
124
+ el.appendChild(wrap);
125
+ const ease = ctx.ease(p.ease), rise = ctx.ease('expo.out');
126
+ const liftZ = num(p.lift) * u, liftAt = num(p.lift_at);
127
+ return {
128
+ seek(t) {
129
+ win.style.transform = cameraTransform(cameraAt(t, p, ease), P, winW, winH);
130
+ if (!lift)
131
+ return;
132
+ const k = rise(clamp((t - liftAt) / 0.8));
133
+ const z = liftZ * k, sh = clamp(z / (140 * u));
134
+ lift.box.style.visibility = k > 0 ? 'inherit' : 'hidden';
135
+ lift.box.style.transform = `translateZ(${z.toFixed(2)}px) scale(${(1 + 0.04 * k).toFixed(4)})`;
136
+ // The shadow grows with the height: flush, it casts nothing.
137
+ lift.box.style.boxShadow = `0 0 0 1px rgba(255,255,255,${(0.08 * sh).toFixed(3)}),0 ${40 * u * sh}px ${90 * u * sh}px rgba(0,0,0,${(0.6 * sh).toFixed(3)}),0 ${12 * u * sh}px ${28 * u * sh}px rgba(0,0,0,${(0.35 * sh).toFixed(3)})`;
138
+ lift.dim.style.opacity = (0.3 * k).toFixed(3);
139
+ },
140
+ };
141
+ },
142
+ };
@@ -0,0 +1,36 @@
1
+ import { type ParamSpec } from '../types.ts';
2
+ export declare const CAMERA_PATHS: readonly ["in", "out", "in-out", "hold"];
3
+ export type CameraPath = (typeof CAMERA_PATHS)[number];
4
+ export interface CameraDefaults {
5
+ tilt: number;
6
+ pitch: number;
7
+ roll: number;
8
+ zoom: number;
9
+ path: CameraPath;
10
+ move: number;
11
+ }
12
+ /** The camera's params, with a rig's own defaults. Tilt and pitch share one pad, and so do the two pan axes. */
13
+ export declare function cameraParams(d: CameraDefaults): Record<string, ParamSpec>;
14
+ export interface CameraPose {
15
+ /** Degrees. */
16
+ rx: number;
17
+ ry: number;
18
+ rz: number;
19
+ /** Apparent scale: 1 is square-on at rest. */
20
+ zoom: number;
21
+ /** Point looked at, as a share of the rig's width and height from its centre. */
22
+ x: number;
23
+ y: number;
24
+ }
25
+ /** When the camera stops moving, in seconds from the start. */
26
+ export declare function cameraEnd(p: Record<string, unknown>): number;
27
+ /** How far into the pose the camera is at time t: 0 square-on, 1 in the pose. */
28
+ export declare function cameraWeight(t: number, p: Record<string, unknown>, ease: (x: number) => number): number;
29
+ /** The camera at time t. */
30
+ export declare function cameraAt(t: number, p: Record<string, unknown>, ease: (x: number) => number): CameraPose;
31
+ /**
32
+ * The transform for the rig's world, inside an element with `perspective: P`.
33
+ * Zoom is a distance along z, so it keeps the perspective true; the rig turns
34
+ * about the point it looks at, so that point stays in the middle of the frame.
35
+ */
36
+ export declare function cameraTransform(c: CameraPose, P: number, w: number, h: number): string;
@@ -0,0 +1,81 @@
1
+ // The camera shared by the 3D rigs (rig/browser-window, rig/tab-stack, rig/layer-stack).
2
+ //
3
+ // An orbit camera around the rig: it looks at a point (pan), stands further back
4
+ // or closer (zoom, as perspective-correct distance), and turns (tilt about the
5
+ // vertical axis, pitch about the horizontal one, roll about the view). A path
6
+ // says how it moves between square-on and that pose over time; a slow drift
7
+ // keeps it alive once it has arrived.
8
+ //
9
+ // Every rig that uses it takes the same params with the same names, so a person
10
+ // learns the dials once and an agent writes them the same way everywhere.
11
+ import { clamp, lerp } from "../../core/ease.js";
12
+ import { num, str } from "../types.js";
13
+ export const CAMERA_PATHS = ['in', 'out', 'in-out', 'hold'];
14
+ /** The camera's params, with a rig's own defaults. Tilt and pitch share one pad, and so do the two pan axes. */
15
+ export function cameraParams(d) {
16
+ return {
17
+ path: { type: 'choice', default: d.path, options: CAMERA_PATHS, label: 'Camera path: in turns from square-on to the pose, out from the pose to square-on, in-out goes and comes back, hold stays in the pose' },
18
+ tilt: { type: 'number', default: d.tilt, min: -40, max: 40, step: 1, unit: 'deg, negative faces left', label: 'Turn', pad: { name: 'angle', axis: 'x' } },
19
+ pitch: { type: 'number', default: d.pitch, min: -15, max: 30, step: 1, unit: 'deg', label: 'Lean', pad: { name: 'angle', axis: 'y' } },
20
+ roll: { type: 'number', default: d.roll, min: -12, max: 12, step: 0.5, unit: 'deg', label: 'Camera roll' },
21
+ zoom: { type: 'number', default: d.zoom, min: 0.5, max: 1.8, step: 0.01, unit: 'x', label: 'Camera zoom in the pose (below 1 stands back)' },
22
+ pan_x: { type: 'number', default: 0, min: -50, max: 50, step: 0.5, unit: '% of the rig', label: 'Across', pad: { name: 'look', axis: 'x' } },
23
+ pan_y: { type: 'number', default: 0, min: -50, max: 50, step: 0.5, unit: '% of the rig', label: 'Down', pad: { name: 'look', axis: 'y' } },
24
+ move: { type: 'number', default: d.move, min: 0.4, max: 3, step: 0.05, unit: 's', label: 'Time the camera takes for each move' },
25
+ hold: { type: 'number', default: 1, min: 0, max: 6, step: 0.05, unit: 's', label: 'For in-out: time in the pose before it comes back' },
26
+ ease: { type: 'ease', default: 'cubic.inOut', label: 'Curve of each camera move' },
27
+ drift: { type: 'number', default: 1.2, min: 0, max: 4, step: 0.1, unit: 'deg/s', label: 'Slow drift once the camera has arrived' },
28
+ };
29
+ }
30
+ /** When the camera stops moving, in seconds from the start. */
31
+ export function cameraEnd(p) {
32
+ const path = str(p.path), move = num(p.move);
33
+ return path === 'hold' ? 0 : path === 'in-out' ? 2 * move + num(p.hold) : move;
34
+ }
35
+ /** How far into the pose the camera is at time t: 0 square-on, 1 in the pose. */
36
+ export function cameraWeight(t, p, ease) {
37
+ const path = str(p.path), move = Math.max(0.01, num(p.move));
38
+ if (path === 'hold')
39
+ return 1;
40
+ if (path === 'out')
41
+ return 1 - ease(clamp(t / move));
42
+ if (path === 'in-out') {
43
+ if (t < move)
44
+ return ease(clamp(t / move));
45
+ if (t < move + num(p.hold))
46
+ return 1;
47
+ return 1 - ease(clamp((t - move - num(p.hold)) / move));
48
+ }
49
+ return ease(clamp(t / move));
50
+ }
51
+ /** The camera at time t. */
52
+ export function cameraAt(t, p, ease) {
53
+ const w = cameraWeight(t, p, ease);
54
+ const tilt = num(p.tilt), pitch = num(p.pitch);
55
+ const pose = {
56
+ rx: pitch * w, ry: tilt * w, rz: num(p.roll) * w,
57
+ zoom: lerp(1, num(p.zoom), w), x: (num(p.pan_x) / 100) * w, y: (num(p.pan_y) / 100) * w,
58
+ };
59
+ // Two clocks: once the camera has arrived, a slow linear drift under the hold.
60
+ // In a pose it relaxes back towards square-on (never more than half way);
61
+ // square-on it creeps in a little.
62
+ const after = Math.max(0, t - cameraEnd(p)), drift = num(p.drift);
63
+ if (after > 0 && drift > 0) {
64
+ if (w > 0.5) {
65
+ pose.ry -= Math.sign(tilt) * Math.min(Math.abs(tilt) * 0.5, drift * after);
66
+ pose.rx -= Math.sign(pitch) * Math.min(Math.abs(pitch) * 0.5, drift * 0.4 * after);
67
+ }
68
+ else
69
+ pose.zoom *= 1 + Math.min(0.06, 0.015 * drift * after);
70
+ }
71
+ return pose;
72
+ }
73
+ /**
74
+ * The transform for the rig's world, inside an element with `perspective: P`.
75
+ * Zoom is a distance along z, so it keeps the perspective true; the rig turns
76
+ * about the point it looks at, so that point stays in the middle of the frame.
77
+ */
78
+ export function cameraTransform(c, P, w, h) {
79
+ const dz = P * (1 - 1 / Math.max(0.05, c.zoom));
80
+ return `translateZ(${dz.toFixed(2)}px) rotateX(${c.rx.toFixed(3)}deg) rotateY(${c.ry.toFixed(3)}deg) rotateZ(${c.rz.toFixed(3)}deg) translate(${(-c.x * w).toFixed(2)}px, ${(-c.y * h).toFixed(2)}px)`;
81
+ }
@@ -0,0 +1,27 @@
1
+ import { type Primitive } from '../types.ts';
2
+ type Box = [number, number, number, number];
3
+ /** A still picture rather than footage: shown as it is, with no frames to pull. */
4
+ export declare const isPicture: (src: string) => boolean;
5
+ /**
6
+ * A mark's box at source frame `i`, held from the nearest frame that has one: before the element
7
+ * appears it is framed where it first shows, after it is gone where it was last seen.
8
+ */
9
+ export declare function markBox(list: readonly (Box | null)[] | undefined, i: number): Box | undefined;
10
+ /**
11
+ * Which copy of the footage to draw: a fractional level, 0 for the largest. Each copy is half
12
+ * the one before; the level is the one whose width is nearest what the screen shows.
13
+ */
14
+ export declare function mipLevel(widths: readonly number[], shownPx: number): number;
15
+ /**
16
+ * The depth-of-field mask for a w × h plane tilted by rx, ry degrees and focused at (fx, fy):
17
+ * a linear gradient whose alpha is how far each point is from the focal plane, over `dof` px.
18
+ * Opaque where the blurred copy shows. Flat, it is fully clear.
19
+ */
20
+ export declare function focusMask(w: number, h: number, rx: number, ry: number, fx: number, fy: number, dof: number): string;
21
+ /**
22
+ * How much more or less light the tilted plane catches than it does flat, -1..1, for a light
23
+ * coming from `angle` degrees on the screen (0 from the right, 90 from below) at 45° above it.
24
+ */
25
+ export declare function lightOn(rx: number, ry: number, angle: number): number;
26
+ export declare const footagePlane: Primitive;
27
+ export {};
@@ -0,0 +1,257 @@
1
+ // rig/footage-plane. See library/primitives/rig/footage-plane.md.
2
+ //
3
+ // The traditional pipeline: a screen is recorded flat, once, then laid on a plane
4
+ // in a scene where the camera, the depth of field and the light move. The page is
5
+ // never re-laid out to move the camera, so nothing in it can wiggle or re-wrap;
6
+ // all the motion is one rigid picture under one camera, and it stays coherent.
7
+ //
8
+ // The plane reacts to the scene's camera: tilted, it falls out of focus away from
9
+ // the focus point and catches the light on one side; zoomed out, it is drawn from a
10
+ // smaller copy of the footage so fine type does not shimmer; zoomed in, from the
11
+ // full-size one, pulled large enough for the deepest zoom. Marks recorded with the
12
+ // footage (`motion record --marks`) let camera keys and taps aim at a button in it.
13
+ import { clamp } from "../../core/ease.js";
14
+ import { sourceTime } from "../el/video.js";
15
+ import { frameUrl, num, str } from "../types.js";
16
+ /** A still picture rather than footage: shown as it is, with no frames to pull. */
17
+ export const isPicture = (src) => /^data:image\/|\.(png|jpe?g|webp|avif|gif|svg)(\?|#|$)/i.test(src);
18
+ /**
19
+ * A mark's box at source frame `i`, held from the nearest frame that has one: before the element
20
+ * appears it is framed where it first shows, after it is gone where it was last seen.
21
+ */
22
+ export function markBox(list, i) {
23
+ if (!list?.length)
24
+ return undefined;
25
+ const at = Math.min(list.length - 1, Math.max(0, i));
26
+ for (let d = 0; d < list.length; d++) {
27
+ const back = list[at - d], fwd = list[at + d];
28
+ if (back)
29
+ return back;
30
+ if (fwd)
31
+ return fwd;
32
+ }
33
+ return undefined;
34
+ }
35
+ /**
36
+ * Which copy of the footage to draw: a fractional level, 0 for the largest. Each copy is half
37
+ * the one before; the level is the one whose width is nearest what the screen shows.
38
+ */
39
+ export function mipLevel(widths, shownPx) {
40
+ if (widths.length < 2 || !(shownPx > 0))
41
+ return 0;
42
+ return clamp(Math.log2(widths[0] / shownPx), 0, widths.length - 1);
43
+ }
44
+ /**
45
+ * The depth-of-field mask for a w × h plane tilted by rx, ry degrees and focused at (fx, fy):
46
+ * a linear gradient whose alpha is how far each point is from the focal plane, over `dof` px.
47
+ * Opaque where the blurred copy shows. Flat, it is fully clear.
48
+ */
49
+ export function focusMask(w, h, rx, ry, fx, fy, dof) {
50
+ const sx = Math.sin((ry * Math.PI) / 180), sy = Math.sin((rx * Math.PI) / 180);
51
+ const g = Math.hypot(sx, sy);
52
+ if (g < 1e-4 || dof <= 0)
53
+ return 'linear-gradient(transparent, transparent)';
54
+ const ux = sx / g, uy = sy / g;
55
+ // CSS angles: 0deg points up, 90deg right.
56
+ const angle = (Math.atan2(ux, -uy) * 180) / Math.PI;
57
+ const L = Math.abs(w * ux) + Math.abs(h * uy);
58
+ const tf = ((fx - w / 2) * ux + (fy - h / 2) * uy) / L + 0.5;
59
+ const alpha = (t) => Math.min(1, (Math.abs(t - tf) * L * g) / dof);
60
+ const stops = [[0, alpha(0)]];
61
+ // Where the blur reaches full strength either side of the focus.
62
+ const reach = dof / (L * g);
63
+ if (tf - reach > 0)
64
+ stops.push([tf - reach, 1]);
65
+ if (tf > 0 && tf < 1)
66
+ stops.push([tf, 0]);
67
+ if (tf + reach < 1)
68
+ stops.push([tf + reach, 1]);
69
+ stops.push([1, alpha(1)]);
70
+ return `linear-gradient(${angle.toFixed(2)}deg, ${stops.map(([t, a]) => `rgba(0,0,0,${a.toFixed(3)}) ${(t * 100).toFixed(2)}%`).join(', ')})`;
71
+ }
72
+ /**
73
+ * How much more or less light the tilted plane catches than it does flat, -1..1, for a light
74
+ * coming from `angle` degrees on the screen (0 from the right, 90 from below) at 45° above it.
75
+ */
76
+ export function lightOn(rx, ry, angle) {
77
+ const r = Math.PI / 180, a = angle * r, e = Math.PI / 4;
78
+ const n = [Math.sin(ry * r), -Math.sin(rx * r) * Math.cos(ry * r), Math.cos(rx * r) * Math.cos(ry * r)];
79
+ const l = [Math.cos(a) * Math.cos(e), Math.sin(a) * Math.cos(e), Math.sin(e)];
80
+ return (n[0] * l[0] + n[1] * l[1] + n[2] * l[2]) - Math.sin(e);
81
+ }
82
+ export const footagePlane = {
83
+ slug: 'rig/footage-plane',
84
+ summary: 'Flat screen footage on a plane the camera moves over, with depth of field and light.',
85
+ props: {
86
+ src: { type: 'string', required: true, label: 'Video recorded flat (motion record), or a still picture of a screen' },
87
+ from: { type: 'number', default: 0, label: 'Source time the plane opens on, in seconds' },
88
+ to: { type: 'number', default: 0, label: 'Source time it ends on; 0 plays on until the scene ends' },
89
+ marks: { type: 'string', default: '', label: 'The marks file motion record --marks wrote, for camera keys ("plane#mark") and taps to aim at' },
90
+ focus: { type: 'string', default: '', label: 'The mark the lens focuses on; the middle of the picture when empty' },
91
+ },
92
+ params: {
93
+ width: { type: 'number', default: 1080, min: 100, max: 8000, step: 1, unit: 'px', label: 'Width of the plane on the stage at zoom 1' },
94
+ radius: { type: 'number', default: 0, min: 0, max: 200, step: 1, unit: 'px', label: 'Corner radius' },
95
+ rate: { type: 'number', default: 1, min: 0.1, max: 4, step: 0.05, unit: '×', label: 'Playback speed' },
96
+ loop: { type: 'boolean', default: false, label: 'Wrap from "to" back to "from" until the scene ends' },
97
+ aperture: { type: 'number', default: 6, min: 0, max: 24, step: 0.5, unit: 'px', label: 'Blur where the tilted plane is furthest out of focus (0: all sharp)' },
98
+ depth: { type: 'number', default: 260, min: 40, max: 2000, step: 10, unit: 'px', label: 'Depth from the focal plane at which the blur is full' },
99
+ light: { type: 'number', default: 235, min: 0, max: 360, step: 5, unit: 'deg', label: 'Where the light comes from, on the screen (0 right, 90 below, 270 above)' },
100
+ shade: { type: 'number', default: 0.5, min: 0, max: 1, step: 0.05, unit: 'ratio', label: 'How much the tilt lights and darkens the plane' },
101
+ sheen: { type: 'number', default: 0.06, min: 0, max: 0.3, step: 0.01, unit: 'opacity', label: 'A soft band of reflected light that slides as the plane turns' },
102
+ shadow: { type: 'number', default: 0.35, min: 0, max: 1, step: 0.05, unit: 'opacity', label: 'The plane\'s shadow on what is behind it' },
103
+ },
104
+ // Footage plays for as long as the scene; its own motion is not a move.
105
+ cues: () => [],
106
+ duration: (props, p) => {
107
+ const from = num(props.from), to = num(props.to);
108
+ return p.loop === true || !(to > from) ? 0 : (to - from) / num(p.rate, 1);
109
+ },
110
+ check(props, p) {
111
+ const out = [];
112
+ const from = num(props.from), to = num(props.to);
113
+ if (from < 0)
114
+ out.push({ path: 'props.from', message: 'from is a source time in seconds, zero or more.' });
115
+ if (to !== 0 && to <= from)
116
+ out.push({ path: 'props.to', message: `to (${to} s) must come after from (${from} s).` });
117
+ if (p.loop === true && !(to > from))
118
+ out.push({ path: 'params.loop', message: 'A loop needs both ends: set props.to after props.from.' });
119
+ if (str(props.focus) && !str(props.marks))
120
+ out.push({ path: 'props.focus', message: 'focus names a mark, so the plane needs its marks file.', hint: 'Record with motion record --marks and set props.marks.' });
121
+ return out;
122
+ },
123
+ build(el, props, p, ctx) {
124
+ const doc = el.ownerDocument;
125
+ const W = num(p.width), radius = num(p.radius);
126
+ const levels = ctx.frames ? [ctx.frames, ...(ctx.mips ?? [])] : [];
127
+ const marks = ctx.frames?.marks;
128
+ const aspect = ctx.frames ? ctx.frames.height / ctx.frames.width : marks ? marks.size[1] / marks.size[0] : 16 / 9;
129
+ const H = W * aspect;
130
+ el.style.cssText += ';max-width:none';
131
+ const plane = doc.createElement('div');
132
+ plane.style.cssText = `position:relative;width:${W}px;height:${H}px;border-radius:${radius}px;overflow:hidden;background:#000`;
133
+ el.appendChild(plane);
134
+ el.style.borderRadius = `${radius}px`;
135
+ const fill = 'position:absolute;inset:0;width:100%;height:100%;display:block;object-fit:fill';
136
+ // The picture: a stack of copies, the nearest one to the size on screen on top of the next larger.
137
+ let request = 0, waiting = Promise.resolve();
138
+ const imgs = levels.map(() => {
139
+ const img = doc.createElement('img');
140
+ img.decoding = 'sync';
141
+ img.alt = '';
142
+ img.style.cssText = `${fill};opacity:0`;
143
+ plane.appendChild(img);
144
+ return img;
145
+ });
146
+ const load = (img, url) => {
147
+ if (img.getAttribute('src') === url)
148
+ return;
149
+ img.src = url;
150
+ const id = ++request;
151
+ waiting = Promise.all([waiting, img.decode().catch(() => {
152
+ if (id !== request || (img.complete && img.naturalWidth > 0))
153
+ return;
154
+ return new Promise((resolve, reject) => {
155
+ img.addEventListener('load', () => resolve(), { once: true });
156
+ img.addEventListener('error', () => reject(new Error(`Footage frame did not load: ${url}`)), { once: true });
157
+ });
158
+ })]).then(() => undefined);
159
+ };
160
+ // A still picture is shown as it is.
161
+ if (!levels.length && isPicture(str(props.src))) {
162
+ const img = doc.createElement('img');
163
+ img.decoding = 'sync';
164
+ img.alt = '';
165
+ img.src = str(props.src);
166
+ img.style.cssText = fill;
167
+ plane.appendChild(img);
168
+ }
169
+ // Without pulled frames (the studio), a video element plays the footage.
170
+ let vid;
171
+ if (!levels.length && !isPicture(str(props.src))) {
172
+ vid = doc.createElement('video');
173
+ vid.muted = true;
174
+ vid.playsInline = true;
175
+ vid.preload = 'auto';
176
+ vid.src = str(props.src);
177
+ vid.style.cssText = fill;
178
+ plane.appendChild(vid);
179
+ }
180
+ // Depth of field: a blurred copy, from a small copy of the footage, shown where the plane is out of focus.
181
+ const blurred = levels.length ? doc.createElement('img') : undefined;
182
+ if (blurred) {
183
+ blurred.decoding = 'sync';
184
+ blurred.alt = '';
185
+ blurred.style.cssText = `${fill};opacity:0;filter:blur(${num(p.aperture)}px);transform:scale(1.02)`;
186
+ plane.appendChild(blurred);
187
+ }
188
+ // Light: a wash that lights or shades the whole plane with its tilt, and a sliding sheen.
189
+ const wash = doc.createElement('div');
190
+ wash.style.cssText = `${fill};pointer-events:none`;
191
+ const sheen = doc.createElement('div');
192
+ sheen.style.cssText = `${fill};pointer-events:none;mix-blend-mode:screen`;
193
+ plane.append(wash, sheen);
194
+ const fps = marks?.fps ?? 60, k = marks ? W / marks.size[0] : 1;
195
+ const markAt = (name, t) => {
196
+ // A mark is named by its selector; "send" finds "#send" and "card" finds ".card".
197
+ const list = marks?.marks[name] ?? marks?.marks[`#${name}`] ?? marks?.marks[`.${name}`];
198
+ const b = markBox(list, Math.round(sourceTime(t, props, p) * fps));
199
+ return b ? [b[0] * k, b[1] * k, b[2] * k, b[3] * k] : undefined;
200
+ };
201
+ const dpr = typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1;
202
+ const aperture = num(p.aperture), dof = num(p.depth), shade = num(p.shade), shine = num(p.sheen), shadow = num(p.shadow), lightAt = num(p.light);
203
+ const focus = str(props.focus);
204
+ const widths = levels.map((l) => l.width);
205
+ return {
206
+ seek(t) {
207
+ const cam = ctx.cameraPose?.() ?? { scale: 1, rotateX: 0, rotateY: 0 };
208
+ const s = sourceTime(t, props, p);
209
+ if (levels.length) {
210
+ // The copy nearest the size on screen, cross-faded into the next larger one.
211
+ const lv = mipLevel(widths, W * cam.scale * dpr), lo = Math.floor(lv), hi = Math.min(levels.length - 1, lo + 1), f = lv - lo;
212
+ imgs.forEach((img, i) => {
213
+ const on = i === lo || (i === hi && f > 0.001);
214
+ img.style.opacity = !on ? '0' : i === lo ? '1' : f.toFixed(3);
215
+ img.style.zIndex = i === hi && i !== lo ? '1' : '0';
216
+ if (on) {
217
+ const seq = levels[i];
218
+ load(img, frameUrl(seq, Math.round((s - seq.start) * seq.rate + 1e-6)));
219
+ }
220
+ });
221
+ if (blurred) {
222
+ const tilt = Math.hypot(cam.rotateX, cam.rotateY);
223
+ if (aperture > 0 && tilt > 0.05) {
224
+ const seq = levels[Math.min(levels.length - 1, hi + 1)];
225
+ load(blurred, frameUrl(seq, Math.round((s - seq.start) * seq.rate + 1e-6)));
226
+ const fb = focus ? markAt(focus, t) : undefined;
227
+ const [fx, fy] = fb ? [fb[0] + fb[2] / 2, fb[1] + fb[3] / 2] : [W / 2, H / 2];
228
+ const mask = focusMask(W, H, cam.rotateX, cam.rotateY, fx, fy, dof);
229
+ blurred.style.maskImage = mask;
230
+ blurred.style.opacity = '1';
231
+ blurred.style.zIndex = '2';
232
+ }
233
+ else
234
+ blurred.style.opacity = '0';
235
+ }
236
+ }
237
+ else if (vid && Math.abs(vid.currentTime - s) > 0.5 / ctx.fps)
238
+ vid.currentTime = s;
239
+ // The light: brighter turned towards it, darker turned away, and a band that slides with the turn.
240
+ const lit = lightOn(cam.rotateX, cam.rotateY, lightAt) * shade * 2;
241
+ wash.style.background = lit >= 0 ? `rgba(255,255,255,${clamp(lit * 0.5).toFixed(3)})` : `rgba(0,0,0,${clamp(-lit).toFixed(3)})`;
242
+ wash.style.zIndex = '3';
243
+ const slide = 50 + cam.rotateY * 3 - cam.rotateX * 3;
244
+ sheen.style.background = shine > 0
245
+ ? `linear-gradient(${(lightAt + 90).toFixed(0)}deg, transparent ${(slide - 22).toFixed(1)}%, rgba(255,255,255,${shine}) ${slide.toFixed(1)}%, transparent ${(slide + 22).toFixed(1)}%)`
246
+ : '';
247
+ sheen.style.zIndex = '4';
248
+ // The shadow grows as the plane lifts away from what is behind it.
249
+ const tilt = Math.hypot(cam.rotateX, cam.rotateY);
250
+ plane.style.boxShadow = shadow > 0 ? `0 ${(10 + tilt * 1.6).toFixed(1)}px ${(30 + tilt * 3).toFixed(1)}px rgba(0,0,0,${shadow})` : '';
251
+ plane.style.overflow = 'hidden';
252
+ },
253
+ pending: () => waiting,
254
+ markAt,
255
+ };
256
+ },
257
+ };