motionary 10.3.0 → 10.5.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 (421) hide show
  1. package/AGENTS.md +4 -0
  2. package/CHANGELOG.md +31 -0
  3. package/README.md +72 -0
  4. package/bin/motionary-mcp.mjs +265 -0
  5. package/dist/chunks/anim-image-BlNPv4JG.js +166 -0
  6. package/dist/chunks/anim-image-BlNPv4JG.js.map +1 -0
  7. package/dist/chunks/anim-image-DuxvYhq6.cjs +174 -0
  8. package/dist/chunks/anim-image-DuxvYhq6.cjs.map +1 -0
  9. package/dist/chunks/audio-BpU-A1m1.cjs.map +1 -1
  10. package/dist/chunks/{audio-D95jwlOh.js → audio-CWt1xdZB.js} +3 -3
  11. package/dist/chunks/{audio-D95jwlOh.js.map → audio-CWt1xdZB.js.map} +1 -1
  12. package/dist/chunks/{base-BnRyfuyM.js → base-BTev8qxg.js} +2 -2
  13. package/dist/chunks/{base-BnRyfuyM.js.map → base-BTev8qxg.js.map} +1 -1
  14. package/dist/chunks/base-DBheNxJu.cjs.map +1 -1
  15. package/dist/chunks/bind-B_CTL6Qn.js.map +1 -1
  16. package/dist/chunks/bind-Ui43-n2d.cjs.map +1 -1
  17. package/dist/chunks/builtins-CKKZNR95.cjs.map +1 -1
  18. package/dist/chunks/{builtins-CqIq1zBv.js → builtins-CPmS6aDB.js} +3 -3
  19. package/dist/chunks/{builtins-CqIq1zBv.js.map → builtins-CPmS6aDB.js.map} +1 -1
  20. package/dist/chunks/core-B5T0dhFH.cjs.map +1 -1
  21. package/dist/chunks/{core-DsGoL9EY.js → core-BviA7nFa.js} +2 -2
  22. package/dist/chunks/{core-DsGoL9EY.js.map → core-BviA7nFa.js.map} +1 -1
  23. package/dist/chunks/core-D74Fz-dL.cjs.map +1 -1
  24. package/dist/chunks/core-D7cVumUu.js.map +1 -1
  25. package/dist/chunks/{core-XA2yhn1b.js → core-KiM7MXjL.js} +2 -2
  26. package/dist/chunks/{core-XA2yhn1b.js.map → core-KiM7MXjL.js.map} +1 -1
  27. package/dist/chunks/core-MQlXZKUG.cjs.map +1 -1
  28. package/dist/chunks/ease-HwYZnZat.cjs +94 -0
  29. package/dist/chunks/ease-HwYZnZat.cjs.map +1 -0
  30. package/dist/chunks/ease-XN8_0sXu.js +89 -0
  31. package/dist/chunks/ease-XN8_0sXu.js.map +1 -0
  32. package/dist/chunks/fx-B_pbhpDp.cjs.map +1 -1
  33. package/dist/chunks/{fx-CtnrFEg9.js → fx-CgWKqVsn.js} +2 -2
  34. package/dist/chunks/{fx-CtnrFEg9.js.map → fx-CgWKqVsn.js.map} +1 -1
  35. package/dist/chunks/generative-2LhxG5BJ.js.map +1 -1
  36. package/dist/chunks/generative-BHIj-NU0.cjs.map +1 -1
  37. package/dist/chunks/{gpu-CDcXiNA8.js → gpu-BWfgYWMY.js} +2 -2
  38. package/dist/chunks/{gpu-CDcXiNA8.js.map → gpu-BWfgYWMY.js.map} +1 -1
  39. package/dist/chunks/gpu-cUixt7kT.cjs.map +1 -1
  40. package/dist/chunks/index-tags-B-JBecYg.js.map +1 -1
  41. package/dist/chunks/index-tags-hLIF2Clq.cjs.map +1 -1
  42. package/dist/chunks/{keyframes-DVAC5sQI.js → keyframes-B8ITIAVa.js} +3 -2
  43. package/dist/chunks/keyframes-B8ITIAVa.js.map +1 -0
  44. package/dist/chunks/{keyframes-Dw9zwVQa.cjs → keyframes-Ce1s05n3.cjs} +4 -3
  45. package/dist/chunks/keyframes-Ce1s05n3.cjs.map +1 -0
  46. package/dist/chunks/{manifest-D58HXVY-.js → manifest-BHx5yPN6.js} +2 -2
  47. package/dist/chunks/{manifest-D58HXVY-.js.map → manifest-BHx5yPN6.js.map} +1 -1
  48. package/dist/chunks/manifest-PaF9B8Vt.cjs.map +1 -1
  49. package/dist/chunks/{player-48Zy_NBG.js → player-BfHMNtiM.js} +4 -4
  50. package/dist/chunks/{player-48Zy_NBG.js.map → player-BfHMNtiM.js.map} +1 -1
  51. package/dist/chunks/player-C4y4jXSv.cjs.map +1 -1
  52. package/dist/chunks/presets-BYBVJVeP.js.map +1 -1
  53. package/dist/chunks/presets-CUHys3sK.cjs.map +1 -1
  54. package/dist/chunks/{registry-gFJRpPES.js → registry-BKzyg1JV.js} +2 -2
  55. package/dist/chunks/{registry-gFJRpPES.js.map → registry-BKzyg1JV.js.map} +1 -1
  56. package/dist/chunks/{registry-46AAzyeC.js → registry-DXdFb2fJ.js} +3 -3
  57. package/dist/chunks/{registry-46AAzyeC.js.map → registry-DXdFb2fJ.js.map} +1 -1
  58. package/dist/chunks/{registry-CSVil2qJ.cjs → registry-VhfPSI0v.cjs} +2 -2
  59. package/dist/chunks/{registry-CSVil2qJ.cjs.map → registry-VhfPSI0v.cjs.map} +1 -1
  60. package/dist/chunks/registry-xQZnSqqV.cjs.map +1 -1
  61. package/dist/chunks/shared-CkKHWrtJ.js.map +1 -1
  62. package/dist/chunks/shared-jkgRH-Hx.cjs.map +1 -1
  63. package/dist/chunks/{spring-CZDNyqWp.js → spring-BHuP55DR.js} +2 -2
  64. package/dist/chunks/{spring-CZDNyqWp.js.map → spring-BHuP55DR.js.map} +1 -1
  65. package/dist/chunks/spring-BlTQD2AV.cjs.map +1 -1
  66. package/dist/chunks/stagger-CCFyhzSw.cjs.map +1 -1
  67. package/dist/chunks/stagger-DtMKo2SK.js.map +1 -1
  68. package/dist/chunks/{ticker-COOYAyQy.js → ticker-C5RMHMW7.js} +2 -2
  69. package/dist/chunks/{ticker-COOYAyQy.js.map → ticker-C5RMHMW7.js.map} +1 -1
  70. package/dist/chunks/{ticker-gHv6pNfx.cjs → ticker-DvmC6WLS.cjs} +2 -2
  71. package/dist/chunks/{ticker-gHv6pNfx.cjs.map → ticker-DvmC6WLS.cjs.map} +1 -1
  72. package/dist/chunks/{tween-CGyolmzB.js → tween-CPtm-EdT.js} +4 -90
  73. package/dist/chunks/tween-CPtm-EdT.js.map +1 -0
  74. package/dist/chunks/{tween-CFN0WcOb.cjs → tween-_BGIl6hK.cjs} +4 -94
  75. package/dist/chunks/tween-_BGIl6hK.cjs.map +1 -0
  76. package/dist/chunks/variants-CrDDJoYK.cjs.map +1 -1
  77. package/dist/chunks/{variants-GU3yIL4F.js → variants-CsRGUIyA.js} +2 -2
  78. package/dist/chunks/{variants-GU3yIL4F.js.map → variants-CsRGUIyA.js.map} +1 -1
  79. package/dist/components/a11y.cjs.map +1 -1
  80. package/dist/components/a11y.js +2 -2
  81. package/dist/components/a11y.js.map +1 -1
  82. package/dist/components/angular.cjs.map +1 -1
  83. package/dist/components/angular.js +8 -8
  84. package/dist/components/angular.js.map +1 -1
  85. package/dist/components/background.cjs.map +1 -1
  86. package/dist/components/background.js +2 -2
  87. package/dist/components/background.js.map +1 -1
  88. package/dist/components/bridge.cjs.map +1 -1
  89. package/dist/components/bridge.js +1 -1
  90. package/dist/components/bridge.js.map +1 -1
  91. package/dist/components/cards.cjs.map +1 -1
  92. package/dist/components/cards.js +2 -2
  93. package/dist/components/cards.js.map +1 -1
  94. package/dist/components/click.cjs.map +1 -1
  95. package/dist/components/click.js +3 -3
  96. package/dist/components/click.js.map +1 -1
  97. package/dist/components/core.cjs.map +1 -1
  98. package/dist/components/core.js.map +1 -1
  99. package/dist/components/depth.cjs.map +1 -1
  100. package/dist/components/depth.js +3 -3
  101. package/dist/components/depth.js.map +1 -1
  102. package/dist/components/design.cjs.map +1 -1
  103. package/dist/components/design.js +3 -3
  104. package/dist/components/design.js.map +1 -1
  105. package/dist/components/dsl.cjs.map +1 -1
  106. package/dist/components/dsl.js +2 -2
  107. package/dist/components/dsl.js.map +1 -1
  108. package/dist/components/effects.cjs.map +1 -1
  109. package/dist/components/effects.js +9 -9
  110. package/dist/components/effects.js.map +1 -1
  111. package/dist/components/engine.cjs.map +1 -1
  112. package/dist/components/engine.js +2 -2
  113. package/dist/components/engine.js.map +1 -1
  114. package/dist/components/feedback.cjs.map +1 -1
  115. package/dist/components/feedback.js +1 -1
  116. package/dist/components/feedback.js.map +1 -1
  117. package/dist/components/fx-3d.cjs.map +1 -1
  118. package/dist/components/fx-3d.js +2 -2
  119. package/dist/components/fx-3d.js.map +1 -1
  120. package/dist/components/fx-ai.cjs.map +1 -1
  121. package/dist/components/fx-ai.js +2 -2
  122. package/dist/components/fx-ai.js.map +1 -1
  123. package/dist/components/fx-chart.cjs.map +1 -1
  124. package/dist/components/fx-chart.js +2 -2
  125. package/dist/components/fx-chart.js.map +1 -1
  126. package/dist/components/fx-cinema.cjs.map +1 -1
  127. package/dist/components/fx-cinema.js +2 -2
  128. package/dist/components/fx-cinema.js.map +1 -1
  129. package/dist/components/fx-cyber.cjs.map +1 -1
  130. package/dist/components/fx-cyber.js +2 -2
  131. package/dist/components/fx-cyber.js.map +1 -1
  132. package/dist/components/fx-festival.cjs.map +1 -1
  133. package/dist/components/fx-festival.js +2 -2
  134. package/dist/components/fx-festival.js.map +1 -1
  135. package/dist/components/fx-focus.cjs.map +1 -1
  136. package/dist/components/fx-focus.js +2 -2
  137. package/dist/components/fx-focus.js.map +1 -1
  138. package/dist/components/fx-form.cjs.map +1 -1
  139. package/dist/components/fx-form.js +2 -2
  140. package/dist/components/fx-form.js.map +1 -1
  141. package/dist/components/fx-game.cjs.map +1 -1
  142. package/dist/components/fx-game.js +2 -2
  143. package/dist/components/fx-game.js.map +1 -1
  144. package/dist/components/fx-genart.cjs.map +1 -1
  145. package/dist/components/fx-genart.js +2 -2
  146. package/dist/components/fx-genart.js.map +1 -1
  147. package/dist/components/fx-geo.cjs.map +1 -1
  148. package/dist/components/fx-geo.js +2 -2
  149. package/dist/components/fx-geo.js.map +1 -1
  150. package/dist/components/fx-gesture.cjs.map +1 -1
  151. package/dist/components/fx-gesture.js +2 -2
  152. package/dist/components/fx-gesture.js.map +1 -1
  153. package/dist/components/fx-gpu.js +3 -3
  154. package/dist/components/fx-light.cjs.map +1 -1
  155. package/dist/components/fx-light.js +2 -2
  156. package/dist/components/fx-light.js.map +1 -1
  157. package/dist/components/fx-lottie.cjs.map +1 -1
  158. package/dist/components/fx-lottie.js +2 -2
  159. package/dist/components/fx-lottie.js.map +1 -1
  160. package/dist/components/fx-morph.cjs.map +1 -1
  161. package/dist/components/fx-morph.js +2 -2
  162. package/dist/components/fx-morph.js.map +1 -1
  163. package/dist/components/fx-music.cjs.map +1 -1
  164. package/dist/components/fx-music.js +3 -3
  165. package/dist/components/fx-music.js.map +1 -1
  166. package/dist/components/fx-organic.cjs.map +1 -1
  167. package/dist/components/fx-organic.js +2 -2
  168. package/dist/components/fx-organic.js.map +1 -1
  169. package/dist/components/fx-paper.cjs.map +1 -1
  170. package/dist/components/fx-paper.js +2 -2
  171. package/dist/components/fx-paper.js.map +1 -1
  172. package/dist/components/fx-perf.cjs.map +1 -1
  173. package/dist/components/fx-perf.js +2 -2
  174. package/dist/components/fx-perf.js.map +1 -1
  175. package/dist/components/fx-physics.cjs.map +1 -1
  176. package/dist/components/fx-physics.js +2 -2
  177. package/dist/components/fx-physics.js.map +1 -1
  178. package/dist/components/fx-retro.cjs.map +1 -1
  179. package/dist/components/fx-retro.js +2 -2
  180. package/dist/components/fx-retro.js.map +1 -1
  181. package/dist/components/fx-safe.cjs.map +1 -1
  182. package/dist/components/fx-safe.js +2 -2
  183. package/dist/components/fx-safe.js.map +1 -1
  184. package/dist/components/fx-shop.cjs.map +1 -1
  185. package/dist/components/fx-shop.js +2 -2
  186. package/dist/components/fx-shop.js.map +1 -1
  187. package/dist/components/fx-social.cjs.map +1 -1
  188. package/dist/components/fx-social.js +2 -2
  189. package/dist/components/fx-social.js.map +1 -1
  190. package/dist/components/fx-spatial.cjs.map +1 -1
  191. package/dist/components/fx-spatial.js +2 -2
  192. package/dist/components/fx-spatial.js.map +1 -1
  193. package/dist/components/fx-surface.cjs.map +1 -1
  194. package/dist/components/fx-surface.js +2 -2
  195. package/dist/components/fx-surface.js.map +1 -1
  196. package/dist/components/fx-text.cjs.map +1 -1
  197. package/dist/components/fx-text.js +2 -2
  198. package/dist/components/fx-text.js.map +1 -1
  199. package/dist/components/fx-transitions.cjs.map +1 -1
  200. package/dist/components/fx-transitions.js +3 -3
  201. package/dist/components/fx-transitions.js.map +1 -1
  202. package/dist/components/fx-video.cjs.map +1 -1
  203. package/dist/components/fx-video.js +2 -2
  204. package/dist/components/fx-video.js.map +1 -1
  205. package/dist/components/fx-weather.cjs.map +1 -1
  206. package/dist/components/fx-weather.js +2 -2
  207. package/dist/components/fx-weather.js.map +1 -1
  208. package/dist/components/fx.cjs.map +1 -1
  209. package/dist/components/fx.js +6 -6
  210. package/dist/components/fx.js.map +1 -1
  211. package/dist/components/fx2.cjs.map +1 -1
  212. package/dist/components/fx2.js +6 -6
  213. package/dist/components/fx2.js.map +1 -1
  214. package/dist/components/gesture.cjs.map +1 -1
  215. package/dist/components/gesture.js +4 -4
  216. package/dist/components/gesture.js.map +1 -1
  217. package/dist/components/interaction.cjs.map +1 -1
  218. package/dist/components/interaction.js +1 -1
  219. package/dist/components/interaction.js.map +1 -1
  220. package/dist/components/layout.cjs.map +1 -1
  221. package/dist/components/layout.js +1 -1
  222. package/dist/components/layout.js.map +1 -1
  223. package/dist/components/lazy.cjs.map +1 -1
  224. package/dist/components/lazy.js.map +1 -1
  225. package/dist/components/lite.cjs.map +1 -1
  226. package/dist/components/lite.js.map +1 -1
  227. package/dist/components/marketplace.cjs.map +1 -1
  228. package/dist/components/marketplace.js +4 -4
  229. package/dist/components/marketplace.js.map +1 -1
  230. package/dist/components/native.cjs.map +1 -1
  231. package/dist/components/native.js +3 -3
  232. package/dist/components/native.js.map +1 -1
  233. package/dist/components/packs.cjs.map +1 -1
  234. package/dist/components/packs.js +1 -1
  235. package/dist/components/packs.js.map +1 -1
  236. package/dist/components/page.cjs.map +1 -1
  237. package/dist/components/page.js +3 -3
  238. package/dist/components/page.js.map +1 -1
  239. package/dist/components/perf.cjs.map +1 -1
  240. package/dist/components/perf.js +2 -2
  241. package/dist/components/perf.js.map +1 -1
  242. package/dist/components/physics.cjs.map +1 -1
  243. package/dist/components/physics.js +3 -3
  244. package/dist/components/physics.js.map +1 -1
  245. package/dist/components/plugins.cjs.map +1 -1
  246. package/dist/components/plugins.js +4 -4
  247. package/dist/components/plugins.js.map +1 -1
  248. package/dist/components/react.cjs.map +1 -1
  249. package/dist/components/react.js.map +1 -1
  250. package/dist/components/reveal.cjs.map +1 -1
  251. package/dist/components/reveal.js +1 -1
  252. package/dist/components/reveal.js.map +1 -1
  253. package/dist/components/solid.cjs.map +1 -1
  254. package/dist/components/solid.js +8 -8
  255. package/dist/components/solid.js.map +1 -1
  256. package/dist/components/svelte.cjs.map +1 -1
  257. package/dist/components/svelte.js +8 -8
  258. package/dist/components/svelte.js.map +1 -1
  259. package/dist/components/svg.cjs.map +1 -1
  260. package/dist/components/svg.js +1 -1
  261. package/dist/components/svg.js.map +1 -1
  262. package/dist/components/text.cjs.map +1 -1
  263. package/dist/components/text.js +2 -2
  264. package/dist/components/text.js.map +1 -1
  265. package/dist/components/timeline.cjs.map +1 -1
  266. package/dist/components/timeline.js +3 -3
  267. package/dist/components/timeline.js.map +1 -1
  268. package/dist/components/tokens.cjs.map +1 -1
  269. package/dist/components/tokens.js.map +1 -1
  270. package/dist/components/transitions.cjs.map +1 -1
  271. package/dist/components/transitions.js +1 -1
  272. package/dist/components/transitions.js.map +1 -1
  273. package/dist/components/ui.cjs.map +1 -1
  274. package/dist/components/ui.js +4 -4
  275. package/dist/components/ui.js.map +1 -1
  276. package/dist/components/vue.cjs.map +1 -1
  277. package/dist/components/vue.js +8 -8
  278. package/dist/components/vue.js.map +1 -1
  279. package/dist/components/webgl.cjs.map +1 -1
  280. package/dist/components/webgl.js +1 -1
  281. package/dist/components/webgl.js.map +1 -1
  282. package/dist/components/widgets.cjs +1102 -216
  283. package/dist/components/widgets.cjs.map +1 -1
  284. package/dist/components/widgets.d.cts +367 -2
  285. package/dist/components/widgets.d.ts +367 -2
  286. package/dist/components/widgets.js +1100 -225
  287. package/dist/components/widgets.js.map +1 -1
  288. package/dist/components.cjs.map +1 -1
  289. package/dist/components.js +10 -10
  290. package/dist/components.js.map +1 -1
  291. package/dist/element.cjs.map +1 -1
  292. package/dist/element.js.map +1 -1
  293. package/dist/index.cjs.map +1 -1
  294. package/dist/index.js +2 -2
  295. package/dist/index.js.map +1 -1
  296. package/dist/llms-full.txt +303 -1
  297. package/dist/llms.txt +16 -2
  298. package/dist/manifest.json +806 -1
  299. package/dist/presets/extended.cjs.map +1 -1
  300. package/dist/presets/extended.js.map +1 -1
  301. package/dist/react.cjs.map +1 -1
  302. package/dist/react.js.map +1 -1
  303. package/dist/runtime/format-apng.cjs +131 -0
  304. package/dist/runtime/format-apng.cjs.map +1 -0
  305. package/dist/runtime/format-apng.d.cts +250 -0
  306. package/dist/runtime/format-apng.d.ts +250 -0
  307. package/dist/runtime/format-apng.iife.js +2 -0
  308. package/dist/runtime/format-apng.iife.js.map +1 -0
  309. package/dist/runtime/format-apng.js +123 -0
  310. package/dist/runtime/format-apng.js.map +1 -0
  311. package/dist/runtime/format-css.cjs +5 -4
  312. package/dist/runtime/format-css.cjs.map +1 -1
  313. package/dist/runtime/format-css.js +5 -4
  314. package/dist/runtime/format-css.js.map +1 -1
  315. package/dist/runtime/format-gif.cjs +206 -0
  316. package/dist/runtime/format-gif.cjs.map +1 -0
  317. package/dist/runtime/format-gif.d.cts +223 -0
  318. package/dist/runtime/format-gif.d.ts +223 -0
  319. package/dist/runtime/format-gif.iife.js +2 -0
  320. package/dist/runtime/format-gif.iife.js.map +1 -0
  321. package/dist/runtime/format-gif.js +199 -0
  322. package/dist/runtime/format-gif.js.map +1 -0
  323. package/dist/runtime/format-gltf.cjs +207 -0
  324. package/dist/runtime/format-gltf.cjs.map +1 -0
  325. package/dist/runtime/format-gltf.d.cts +251 -0
  326. package/dist/runtime/format-gltf.d.ts +251 -0
  327. package/dist/runtime/format-gltf.iife.js +2 -0
  328. package/dist/runtime/format-gltf.iife.js.map +1 -0
  329. package/dist/runtime/format-gltf.js +200 -0
  330. package/dist/runtime/format-gltf.js.map +1 -0
  331. package/dist/runtime/format-motion.cjs +9 -8
  332. package/dist/runtime/format-motion.cjs.map +1 -1
  333. package/dist/runtime/format-motion.js +5 -4
  334. package/dist/runtime/format-motion.js.map +1 -1
  335. package/dist/runtime/format-obj.cjs +181 -0
  336. package/dist/runtime/format-obj.cjs.map +1 -0
  337. package/dist/runtime/format-obj.d.cts +176 -0
  338. package/dist/runtime/format-obj.d.ts +176 -0
  339. package/dist/runtime/format-obj.iife.js +2 -0
  340. package/dist/runtime/format-obj.iife.js.map +1 -0
  341. package/dist/runtime/format-obj.js +174 -0
  342. package/dist/runtime/format-obj.js.map +1 -0
  343. package/dist/runtime/format-sprite.cjs +4 -3
  344. package/dist/runtime/format-sprite.cjs.map +1 -1
  345. package/dist/runtime/format-sprite.js +4 -3
  346. package/dist/runtime/format-sprite.js.map +1 -1
  347. package/dist/runtime/format-svg.cjs +5 -4
  348. package/dist/runtime/format-svg.cjs.map +1 -1
  349. package/dist/runtime/format-svg.js +4 -3
  350. package/dist/runtime/format-svg.js.map +1 -1
  351. package/dist/runtime/format-webp.cjs +123 -0
  352. package/dist/runtime/format-webp.cjs.map +1 -0
  353. package/dist/runtime/format-webp.d.cts +245 -0
  354. package/dist/runtime/format-webp.d.ts +245 -0
  355. package/dist/runtime/format-webp.iife.js +2 -0
  356. package/dist/runtime/format-webp.iife.js.map +1 -0
  357. package/dist/runtime/format-webp.js +115 -0
  358. package/dist/runtime/format-webp.js.map +1 -0
  359. package/dist/runtime/gl.cjs +763 -0
  360. package/dist/runtime/gl.cjs.map +1 -0
  361. package/dist/runtime/gl.d.cts +260 -0
  362. package/dist/runtime/gl.d.ts +260 -0
  363. package/dist/runtime/gl.iife.js +2 -0
  364. package/dist/runtime/gl.iife.js.map +1 -0
  365. package/dist/runtime/gl.js +739 -0
  366. package/dist/runtime/gl.js.map +1 -0
  367. package/dist/runtime/scroll.cjs +2 -2
  368. package/dist/runtime/scroll.cjs.map +1 -1
  369. package/dist/runtime/scroll.js +2 -2
  370. package/dist/runtime/scroll.js.map +1 -1
  371. package/dist/runtime/smooth.cjs +284 -0
  372. package/dist/runtime/smooth.cjs.map +1 -0
  373. package/dist/runtime/smooth.d.cts +137 -0
  374. package/dist/runtime/smooth.d.ts +137 -0
  375. package/dist/runtime/smooth.iife.js +2 -0
  376. package/dist/runtime/smooth.iife.js.map +1 -0
  377. package/dist/runtime/smooth.js +279 -0
  378. package/dist/runtime/smooth.js.map +1 -0
  379. package/dist/runtime/text.cjs +1 -1
  380. package/dist/runtime/text.cjs.map +1 -1
  381. package/dist/runtime/text.js +1 -1
  382. package/dist/runtime/text.js.map +1 -1
  383. package/dist/runtime.cjs +9 -8
  384. package/dist/runtime.cjs.map +1 -1
  385. package/dist/runtime.d.cts +1 -1
  386. package/dist/runtime.d.ts +1 -1
  387. package/dist/runtime.iife.js +1 -1
  388. package/dist/runtime.iife.js.map +1 -1
  389. package/dist/runtime.js +6 -5
  390. package/dist/runtime.js.map +1 -1
  391. package/dist/solid.cjs.map +1 -1
  392. package/dist/solid.js.map +1 -1
  393. package/dist/svelte.cjs.map +1 -1
  394. package/dist/svelte.js.map +1 -1
  395. package/dist/vue.cjs.map +1 -1
  396. package/dist/vue.js.map +1 -1
  397. package/dist/widgets.umd.js +1 -1
  398. package/dist/widgets.umd.js.map +1 -1
  399. package/docs/ROADMAP.md +2 -2
  400. package/docs/components/README.md +17 -7
  401. package/docs/components/usa-gl-scene.md +66 -0
  402. package/docs/components/usa-gpu-particles.md +32 -0
  403. package/docs/components/usa-parallax-layers.md +38 -0
  404. package/docs/components/usa-scroll-ring.md +32 -0
  405. package/docs/components/usa-shader-backdrop.md +36 -0
  406. package/docs/components/usa-smooth-scroll.md +60 -0
  407. package/docs/components/usa-three-scene.md +20 -0
  408. package/docs/components.md +97 -0
  409. package/docs/mcp.md +50 -0
  410. package/docs/runtime/format-apng.md +59 -0
  411. package/docs/runtime/format-gif.md +60 -0
  412. package/docs/runtime/format-gltf.md +63 -0
  413. package/docs/runtime/format-obj.md +59 -0
  414. package/docs/runtime/format-webp.md +58 -0
  415. package/docs/runtime/gl.md +62 -0
  416. package/docs/runtime/smooth.md +60 -0
  417. package/package.json +75 -3
  418. package/dist/chunks/keyframes-DVAC5sQI.js.map +0 -1
  419. package/dist/chunks/keyframes-Dw9zwVQa.cjs.map +0 -1
  420. package/dist/chunks/tween-CFN0WcOb.cjs.map +0 -1
  421. package/dist/chunks/tween-CGyolmzB.js.map +0 -1
@@ -0,0 +1,739 @@
1
+ import { R as RUNTIME_VERSION } from '../chunks/registry-DXdFb2fJ.js';
2
+
3
+ /**
4
+ * `motionary/runtime/gl` (10.5) — a small WebGL2 scene renderer written for
5
+ * Motionary (not a Three.js clone; own API, own shaders):
6
+ *
7
+ * - **math** (`mat4`, quaternions — column-major `Float32Array`s), pure;
8
+ * - **scene graph**: `GlNode` (position / rotation quaternion / scale,
9
+ * children, optional mesh), `Camera` (perspective, `lookAt`), lights
10
+ * (`ambient`, up to 4 directional / point), `bounds()` + `frameNode()`;
11
+ * - **geometry** builders (`box`, `plane`, `sphere`, `torus`) and custom
12
+ * geometry from typed arrays (indexed 16 / 32-bit or not);
13
+ * - **materials**: `standard` (metallic-roughness PBR approximation, base
14
+ * colour texture, emissive, ACES-free Reinhard tone mapping, sRGB),
15
+ * `unlit`, and `shader` (your GLSL ES 3.00 fragment with the standard
16
+ * varyings + your uniforms);
17
+ * - **textures** from images, canvases, bitmaps and **videos** (updated per
18
+ * decoded frame with `requestVideoFrameCallback`; `scrubVideo()` seeks a
19
+ * video from a 0–1 progress, e.g. a scroll scene);
20
+ * - `orbitControls()` — drag / wheel / pinch / arrow keys, damping, optional
21
+ * auto-rotate (off under reduced motion).
22
+ *
23
+ * Math, geometry and the scene graph are pure (SSR / workers); rendering
24
+ * needs WebGL2 (`createRenderer()` throws a clear error without it). Model
25
+ * loaders live in `motionary/runtime/format-gltf` and `format-obj`.
26
+ */
27
+ const mat4 = {
28
+ identity: () => new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]),
29
+ multiply(a, b, out = new Float32Array(16)) {
30
+ for (let c = 0; c < 4; c++)
31
+ for (let r = 0; r < 4; r++)
32
+ out[c * 4 + r] = a[r] * b[c * 4] + a[4 + r] * b[c * 4 + 1] + a[8 + r] * b[c * 4 + 2] + a[12 + r] * b[c * 4 + 3];
33
+ return out;
34
+ },
35
+ perspective(fovy, aspect, near, far) {
36
+ const f = 1 / Math.tan(fovy / 2), nf = 1 / (near - far);
37
+ return new Float32Array([f / aspect, 0, 0, 0, 0, f, 0, 0, 0, 0, (far + near) * nf, -1, 0, 0, 2 * far * near * nf, 0]);
38
+ },
39
+ lookAt(eye, target, up = [0, 1, 0]) {
40
+ let z = sub(eye, target);
41
+ z = norm(z.some((v) => v) ? z : [0, 0, 1]);
42
+ let x = cross(up, z);
43
+ if (!x.some((v) => Math.abs(v) > 1e-9))
44
+ x = cross([0, 0, 1], z);
45
+ x = norm(x);
46
+ const y = cross(z, x);
47
+ return new Float32Array([x[0], y[0], z[0], 0, x[1], y[1], z[1], 0, x[2], y[2], z[2], 0, -dot(x, eye), -dot(y, eye), -dot(z, eye), 1]);
48
+ },
49
+ /** Translation · rotation (quaternion) · scale. */
50
+ compose(t, q, s) {
51
+ const [x, y, z, w] = q, x2 = x + x, y2 = y + y, z2 = z + z;
52
+ const xx = x * x2, xy = x * y2, xz = x * z2, yy = y * y2, yz = y * z2, zz = z * z2, wx = w * x2, wy = w * y2, wz = w * z2;
53
+ return new Float32Array([(1 - (yy + zz)) * s[0], (xy + wz) * s[0], (xz - wy) * s[0], 0, (xy - wz) * s[1], (1 - (xx + zz)) * s[1], (yz + wx) * s[1], 0, (xz + wy) * s[2], (yz - wx) * s[2], (1 - (xx + yy)) * s[2], 0, t[0], t[1], t[2], 1]);
54
+ },
55
+ invert(m) {
56
+ const o = new Float32Array(16);
57
+ const [a00, a01, a02, a03, a10, a11, a12, a13, a20, a21, a22, a23, a30, a31, a32, a33] = m;
58
+ const b00 = a00 * a11 - a01 * a10, b01 = a00 * a12 - a02 * a10, b02 = a00 * a13 - a03 * a10, b03 = a01 * a12 - a02 * a11, b04 = a01 * a13 - a03 * a11, b05 = a02 * a13 - a03 * a12;
59
+ const b06 = a20 * a31 - a21 * a30, b07 = a20 * a32 - a22 * a30, b08 = a20 * a33 - a23 * a30, b09 = a21 * a32 - a22 * a31, b10 = a21 * a33 - a23 * a31, b11 = a22 * a33 - a23 * a32;
60
+ let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
61
+ if (!det)
62
+ return null;
63
+ det = 1 / det;
64
+ o[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
65
+ o[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
66
+ o[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
67
+ o[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
68
+ o[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
69
+ o[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
70
+ o[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
71
+ o[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
72
+ o[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
73
+ o[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
74
+ o[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
75
+ o[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
76
+ o[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
77
+ o[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
78
+ o[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
79
+ o[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
80
+ return o;
81
+ },
82
+ /** Inverse-transpose of the upper 3×3 (normal matrix), as a mat3. */
83
+ normal(m) {
84
+ const i = mat4.invert(m) || mat4.identity();
85
+ return new Float32Array([i[0], i[4], i[8], i[1], i[5], i[9], i[2], i[6], i[10]]);
86
+ },
87
+ transformPoint(m, p) {
88
+ const w = m[3] * p[0] + m[7] * p[1] + m[11] * p[2] + m[15] || 1;
89
+ return [(m[0] * p[0] + m[4] * p[1] + m[8] * p[2] + m[12]) / w, (m[1] * p[0] + m[5] * p[1] + m[9] * p[2] + m[13]) / w, (m[2] * p[0] + m[6] * p[1] + m[10] * p[2] + m[14]) / w];
90
+ },
91
+ };
92
+ const sub = (a, b) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
93
+ const dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
94
+ const cross = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
95
+ const norm = (a) => {
96
+ const l = Math.hypot(a[0], a[1], a[2]) || 1;
97
+ return [a[0] / l, a[1] / l, a[2] / l];
98
+ };
99
+ /** Quaternion from Euler angles (radians, XYZ order). */
100
+ function quatFromEuler(x, y, z) {
101
+ const cx = Math.cos(x / 2), sx = Math.sin(x / 2), cy = Math.cos(y / 2), sy = Math.sin(y / 2), cz = Math.cos(z / 2), sz = Math.sin(z / 2);
102
+ return [sx * cy * cz + cx * sy * sz, cx * sy * cz - sx * cy * sz, cx * cy * sz + sx * sy * cz, cx * cy * cz - sx * sy * sz];
103
+ }
104
+ /** Hamilton product a·b. */
105
+ function quatMultiply(a, b) {
106
+ return [a[3] * b[0] + a[0] * b[3] + a[1] * b[2] - a[2] * b[1], a[3] * b[1] - a[0] * b[2] + a[1] * b[3] + a[2] * b[0], a[3] * b[2] + a[0] * b[1] - a[1] * b[0] + a[2] * b[3], a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2]];
107
+ }
108
+ /** Spherical interpolation. */
109
+ function quatSlerp(a, b, t) {
110
+ let d = a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
111
+ const bb = d < 0 ? b.map((v) => -v) : b;
112
+ d = Math.abs(d);
113
+ if (d > 0.9995) {
114
+ const r = a.map((v, i) => v + (bb[i] - v) * t);
115
+ const l = Math.hypot(...r) || 1;
116
+ return r.map((v) => v / l);
117
+ }
118
+ const th = Math.acos(d), s = Math.sin(th), wa = Math.sin((1 - t) * th) / s, wb = Math.sin(t * th) / s;
119
+ return a.map((v, i) => v * wa + bb[i] * wb);
120
+ }
121
+ const geo = (p, n, uv, idx) => ({ positions: new Float32Array(p), normals: new Float32Array(n), uvs: new Float32Array(uv), indices: p.length / 3 > 65535 ? new Uint32Array(idx) : new Uint16Array(idx) });
122
+ /** Axis-aligned box centred on the origin. */
123
+ function box(w = 1, h = 1, d = 1) {
124
+ const p = [], n = [], uv = [], idx = [];
125
+ const faces = [[[1, 0, 0], [0, 0, -1], [0, 1, 0]], [[-1, 0, 0], [0, 0, 1], [0, 1, 0]], [[0, 1, 0], [1, 0, 0], [0, 0, -1]], [[0, -1, 0], [1, 0, 0], [0, 0, 1]], [[0, 0, 1], [1, 0, 0], [0, 1, 0]], [[0, 0, -1], [-1, 0, 0], [0, 1, 0]]];
126
+ const half = [w / 2, h / 2, d / 2];
127
+ for (const [nn, u, v] of faces) {
128
+ const b = p.length / 3;
129
+ for (const [su, sv] of [[-1, -1], [1, -1], [1, 1], [-1, 1]]) {
130
+ for (let k = 0; k < 3; k++)
131
+ p.push((nn[k] + u[k] * su + v[k] * sv) * half[k]);
132
+ n.push(...nn);
133
+ uv.push((su + 1) / 2, (1 - sv) / 2);
134
+ }
135
+ idx.push(b, b + 1, b + 2, b, b + 2, b + 3);
136
+ }
137
+ return geo(p, n, uv, idx);
138
+ }
139
+ /** XY plane facing +Z. */
140
+ function plane(w = 1, h = 1, sx = 1, sy = 1) {
141
+ const p = [], n = [], uv = [], idx = [];
142
+ for (let j = 0; j <= sy; j++)
143
+ for (let i = 0; i <= sx; i++) {
144
+ p.push((i / sx - 0.5) * w, (j / sy - 0.5) * h, 0);
145
+ n.push(0, 0, 1);
146
+ uv.push(i / sx, 1 - j / sy);
147
+ }
148
+ for (let j = 0; j < sy; j++)
149
+ for (let i = 0; i < sx; i++) {
150
+ const a = j * (sx + 1) + i, b = a + 1, c = a + sx + 1, d = c + 1;
151
+ idx.push(a, b, d, a, d, c);
152
+ }
153
+ return geo(p, n, uv, idx);
154
+ }
155
+ /** UV sphere. */
156
+ function sphere(r = 0.5, ws = 32, hs = 16) {
157
+ const p = [], n = [], uv = [], idx = [];
158
+ for (let j = 0; j <= hs; j++) {
159
+ const v = j / hs, th = v * Math.PI;
160
+ for (let i = 0; i <= ws; i++) {
161
+ const u = i / ws, ph = u * Math.PI * 2;
162
+ const x = -Math.cos(ph) * Math.sin(th), y = Math.cos(th), z = Math.sin(ph) * Math.sin(th);
163
+ p.push(x * r, y * r, z * r);
164
+ n.push(x, y, z);
165
+ uv.push(u, v);
166
+ }
167
+ }
168
+ for (let j = 0; j < hs; j++)
169
+ for (let i = 0; i < ws; i++) {
170
+ const a = j * (ws + 1) + i, b = a + ws + 1;
171
+ if (j)
172
+ idx.push(a, b, a + 1);
173
+ if (j < hs - 1)
174
+ idx.push(a + 1, b, b + 1);
175
+ }
176
+ return geo(p, n, uv, idx);
177
+ }
178
+ /** Torus in the XY plane. */
179
+ function torus(R = 0.5, r = 0.18, rs = 48, ts = 16) {
180
+ const p = [], n = [], uv = [], idx = [];
181
+ for (let j = 0; j <= ts; j++)
182
+ for (let i = 0; i <= rs; i++) {
183
+ const u = (i / rs) * Math.PI * 2, v = (j / ts) * Math.PI * 2;
184
+ const cx = R * Math.cos(u), cy = R * Math.sin(u);
185
+ const x = (R + r * Math.cos(v)) * Math.cos(u), y = (R + r * Math.cos(v)) * Math.sin(u), z = r * Math.sin(v);
186
+ p.push(x, y, z);
187
+ const nn = norm([x - cx, y - cy, z]);
188
+ n.push(...nn);
189
+ uv.push(i / rs, j / ts);
190
+ }
191
+ for (let j = 1; j <= ts; j++)
192
+ for (let i = 1; i <= rs; i++) {
193
+ const a = (rs + 1) * j + i - 1, b = (rs + 1) * (j - 1) + i - 1, c = (rs + 1) * (j - 1) + i, d = (rs + 1) * j + i;
194
+ idx.push(a, b, d, b, c, d);
195
+ }
196
+ return geo(p, n, uv, idx);
197
+ }
198
+ /** Flat normals for a geometry without them (per triangle; un-indexes the mesh). */
199
+ function computeNormals(g) {
200
+ const P = g.positions, I = g.indices;
201
+ const count = I ? I.length : P.length / 3;
202
+ const pos = new Float32Array(count * 3), nrm = new Float32Array(count * 3), uvs = g.uvs ? new Float32Array(count * 2) : undefined;
203
+ for (let t = 0; t < count; t += 3) {
204
+ const v = [0, 1, 2].map((k) => (I ? I[t + k] : t + k));
205
+ const a = [P[v[0] * 3], P[v[0] * 3 + 1], P[v[0] * 3 + 2]], b = [P[v[1] * 3], P[v[1] * 3 + 1], P[v[1] * 3 + 2]], c = [P[v[2] * 3], P[v[2] * 3 + 1], P[v[2] * 3 + 2]];
206
+ const nn = norm(cross(sub(b, a), sub(c, a)));
207
+ v.forEach((vi, k) => {
208
+ pos.set(P.subarray(vi * 3, vi * 3 + 3), (t + k) * 3);
209
+ nrm.set(nn, (t + k) * 3);
210
+ if (uvs && g.uvs)
211
+ uvs.set(g.uvs.subarray(vi * 2, vi * 2 + 2), (t + k) * 2);
212
+ });
213
+ }
214
+ return { positions: pos, normals: nrm, uvs, mode: g.mode };
215
+ }
216
+ function standardMaterial(o = {}) {
217
+ return { type: 'standard', color: [1, 1, 1, 1], metallic: 0, roughness: 0.6, emissive: [0, 0, 0], ...o };
218
+ }
219
+ function unlitMaterial(o = {}) {
220
+ return { ...standardMaterial(o), type: 'unlit' };
221
+ }
222
+ /**
223
+ * Custom fragment shader: `fragment` is GLSL ES 3.00 code defining
224
+ * `vec4 shade()`; available: `v_pos` (world), `v_nrm`, `v_uv`, `u_time`,
225
+ * `u_camPos`, `u_res` and your `uniforms` (float, vec2–4, sampler2D).
226
+ */
227
+ function shaderMaterial(fragment, uniforms = {}, o = {}) {
228
+ return { ...standardMaterial(o), type: 'shader', fragment, uniforms };
229
+ }
230
+ /** '#ff8800' / 'rgb(…)' / [r, g, b] → linear-ready [r, g, b, a] (sRGB values 0–1; the shader linearises). */
231
+ function color(c, a = 1) {
232
+ if (Array.isArray(c))
233
+ return [c[0], c[1], c[2], c[3] ?? a];
234
+ const h = /^#([0-9a-f]{3,8})$/i.exec(c.trim());
235
+ if (h) {
236
+ let s = h[1];
237
+ if (s.length <= 4)
238
+ s = s.split('').map((x) => x + x).join('');
239
+ const v = parseInt(s.slice(0, 6), 16);
240
+ return [((v >> 16) & 255) / 255, ((v >> 8) & 255) / 255, (v & 255) / 255, s.length === 8 ? parseInt(s.slice(6), 16) / 255 : a];
241
+ }
242
+ const m = /rgba?\(([^)]+)\)/.exec(c);
243
+ if (m) {
244
+ const p = m[1].split(/[\s,/]+/).filter(Boolean).map(Number);
245
+ return [p[0] / 255, p[1] / 255, p[2] / 255, p[3] ?? a];
246
+ }
247
+ return [1, 1, 1, a];
248
+ }
249
+ function texture(source, o = {}) {
250
+ const isVideo = typeof HTMLVideoElement !== 'undefined' && source instanceof HTMLVideoElement;
251
+ return { source, srgb: true, repeat: true, flipY: false, video: isVideo, needsUpdate: true, ...o };
252
+ }
253
+ class GlNode {
254
+ constructor(name = '', mesh = null) {
255
+ this.name = '';
256
+ this.position = [0, 0, 0];
257
+ this.rotation = [0, 0, 0, 1];
258
+ this.scale = [1, 1, 1];
259
+ /** Set to use a fixed local matrix instead of position / rotation / scale (glTF `matrix`). */
260
+ this.matrix = null;
261
+ this.children = [];
262
+ this.parent = null;
263
+ this.mesh = null;
264
+ this.visible = true;
265
+ /** Free-form data (loaders put source info here). */
266
+ this.extras = {};
267
+ this.world = mat4.identity();
268
+ this.name = name;
269
+ this.mesh = mesh;
270
+ }
271
+ add(...nodes) {
272
+ for (const n of nodes) {
273
+ n.parent?.remove(n);
274
+ n.parent = this;
275
+ this.children.push(n);
276
+ }
277
+ return this;
278
+ }
279
+ remove(n) {
280
+ const i = this.children.indexOf(n);
281
+ if (i >= 0)
282
+ this.children.splice(i, 1);
283
+ n.parent = null;
284
+ }
285
+ setEuler(x, y, z) {
286
+ this.rotation = quatFromEuler(x, y, z);
287
+ return this;
288
+ }
289
+ local() {
290
+ return this.matrix || mat4.compose(this.position, this.rotation, this.scale);
291
+ }
292
+ /** Recompute world matrices of this subtree. */
293
+ updateWorld(parent) {
294
+ const m = parent ? mat4.multiply(parent, this.local()) : this.local();
295
+ this.world.set(m);
296
+ for (const c of this.children)
297
+ c.updateWorld(this.world);
298
+ }
299
+ traverse(fn) {
300
+ fn(this);
301
+ for (const c of this.children)
302
+ c.traverse(fn);
303
+ }
304
+ find(name) {
305
+ let hit = null;
306
+ this.traverse((n) => {
307
+ if (!hit && n.name === name)
308
+ hit = n;
309
+ });
310
+ return hit;
311
+ }
312
+ }
313
+ class Camera extends GlNode {
314
+ constructor(o = {}) {
315
+ super('camera');
316
+ this.fov = (45 * Math.PI) / 180;
317
+ this.near = 0.05;
318
+ this.far = 500;
319
+ this.aspect = 1;
320
+ this.target = [0, 0, 0];
321
+ this.up = [0, 1, 0];
322
+ if (o.fov)
323
+ this.fov = (o.fov * Math.PI) / 180;
324
+ if (o.near)
325
+ this.near = o.near;
326
+ if (o.far)
327
+ this.far = o.far;
328
+ if (o.position)
329
+ this.position = [...o.position];
330
+ if (o.target)
331
+ this.target = [...o.target];
332
+ }
333
+ view() {
334
+ return mat4.lookAt(this.position, this.target, this.up);
335
+ }
336
+ projection() {
337
+ return mat4.perspective(this.fov, this.aspect, this.near, this.far);
338
+ }
339
+ }
340
+ class Scene {
341
+ constructor() {
342
+ this.root = new GlNode('scene');
343
+ this.ambient = [0.35, 0.35, 0.4];
344
+ this.lights = [{ type: 'directional', vector: [-0.4, -1, -0.6], color: [1, 1, 1], intensity: 2.2 }];
345
+ /** Clear colour (sRGB, 0–1) or null for transparent. */
346
+ this.background = null;
347
+ this.exposure = 1;
348
+ }
349
+ add(...n) {
350
+ this.root.add(...n);
351
+ return this;
352
+ }
353
+ }
354
+ /** World-space bounding box of a subtree's meshes. */
355
+ function bounds(node) {
356
+ node.updateWorld(node.parent ? node.parent.world : undefined);
357
+ const min = [Infinity, Infinity, Infinity], max = [-Infinity, -Infinity, -Infinity];
358
+ node.traverse((n) => {
359
+ const meshes = n.mesh ? (Array.isArray(n.mesh) ? n.mesh : [n.mesh]) : [];
360
+ for (const m of meshes) {
361
+ const P = m.geometry.positions;
362
+ for (let i = 0; i < P.length; i += 3) {
363
+ const q = mat4.transformPoint(n.world, [P[i], P[i + 1], P[i + 2]]);
364
+ for (let k = 0; k < 3; k++) {
365
+ if (q[k] < min[k])
366
+ min[k] = q[k];
367
+ if (q[k] > max[k])
368
+ max[k] = q[k];
369
+ }
370
+ }
371
+ }
372
+ });
373
+ if (min[0] === Infinity)
374
+ return { min: [0, 0, 0], max: [0, 0, 0], center: [0, 0, 0], radius: 0 };
375
+ const center = [(min[0] + max[0]) / 2, (min[1] + max[1]) / 2, (min[2] + max[2]) / 2];
376
+ return { min, max, center, radius: Math.hypot(max[0] - center[0], max[1] - center[1], max[2] - center[2]) };
377
+ }
378
+ /** Point the camera at a subtree so it fills the view. */
379
+ function frameNode(camera, node, padding = 1.25) {
380
+ const b = bounds(node);
381
+ const dist = ((b.radius || 1) * padding) / Math.sin(camera.fov / 2);
382
+ const dir = norm(sub(camera.position, camera.target).some((v) => v) ? sub(camera.position, camera.target) : [0.6, 0.4, 1]);
383
+ camera.target = b.center;
384
+ camera.position = [b.center[0] + dir[0] * dist, b.center[1] + dir[1] * dist, b.center[2] + dir[2] * dist];
385
+ camera.near = Math.max(0.01, dist / 100);
386
+ camera.far = dist * 10 + b.radius * 2;
387
+ }
388
+ // ------------------------------------------------------------------ video
389
+ /** Seek a video from a 0–1 progress (scroll-scrubbed video). Pauses it. */
390
+ function scrubVideo(video, progress) {
391
+ if (!video.duration || !isFinite(video.duration))
392
+ return;
393
+ video.pause();
394
+ const t = Math.min(video.duration - 0.001, Math.max(0, progress * video.duration));
395
+ if ('fastSeek' in video && Math.abs(video.currentTime - t) > 1)
396
+ video.fastSeek(t);
397
+ else
398
+ video.currentTime = t;
399
+ }
400
+ // ------------------------------------------------------------------ renderer
401
+ const VS = `#version 300 es
402
+ layout(location=0) in vec3 a_pos;layout(location=1) in vec3 a_nrm;layout(location=2) in vec2 a_uv;
403
+ uniform mat4 u_model,u_view,u_proj;uniform mat3 u_nmat;out vec3 v_pos,v_nrm;out vec2 v_uv;
404
+ void main(){vec4 w=u_model*vec4(a_pos,1.0);v_pos=w.xyz;v_nrm=normalize(u_nmat*a_nrm);v_uv=a_uv;gl_Position=u_proj*u_view*w;gl_PointSize=2.0;}`;
405
+ const FS_HEAD = `#version 300 es
406
+ precision highp float;in vec3 v_pos,v_nrm;in vec2 v_uv;out vec4 o;
407
+ uniform vec4 u_color;uniform vec3 u_emissive,u_camPos,u_ambient;uniform float u_metal,u_rough,u_exposure,u_time;uniform vec2 u_res;
408
+ uniform sampler2D u_map;uniform int u_hasMap,u_nl,u_unlit;uniform vec4 u_lvec[4];uniform vec3 u_lcol[4];
409
+ vec3 lin(vec3 c){return pow(c,vec3(2.2));}vec3 srgb(vec3 c){return pow(c,vec3(1.0/2.2));}
410
+ `;
411
+ const FS_STD = `${FS_HEAD}void main(){vec4 base=vec4(lin(u_color.rgb),u_color.a);if(u_hasMap==1){vec4 t=texture(u_map,v_uv);base*=vec4(lin(t.rgb),t.a);}
412
+ if(u_unlit==1){o=vec4(srgb(base.rgb),base.a);return;}
413
+ vec3 N=normalize(v_nrm);if(!gl_FrontFacing)N=-N;vec3 V=normalize(u_camPos-v_pos);float r=clamp(u_rough,0.04,1.0),m=clamp(u_metal,0.0,1.0);
414
+ vec3 F0=mix(vec3(0.04),base.rgb,m);vec3 c=u_ambient*base.rgb*(1.0-0.6*m)+u_ambient*F0*0.4;
415
+ for(int i=0;i<4;i++){if(i>=u_nl)break;vec3 L;float at=1.0;if(u_lvec[i].w>0.5){vec3 d=u_lvec[i].xyz-v_pos;float l=length(d);L=d/l;at=1.0/(1.0+0.09*l*l);}else L=normalize(-u_lvec[i].xyz);
416
+ vec3 H=normalize(L+V);float NL=max(dot(N,L),0.0),NH=max(dot(N,H),0.0),NV=max(dot(N,V),1e-3),a=r*r,a2=a*a,dd=NH*NH*(a2-1.0)+1.0,D=a2/(3.14159*dd*dd),k=(r+1.0)*(r+1.0)/8.0;
417
+ float G=NL/(NL*(1.0-k)+k)*NV/(NV*(1.0-k)+k);vec3 F=F0+(1.0-F0)*pow(1.0-max(dot(H,V),0.0),5.0);vec3 S=D*G*F/(4.0*NL*NV+1e-3);
418
+ c+=((1.0-F)*(1.0-m)*base.rgb/3.14159+S)*u_lcol[i]*NL*at;}
419
+ c=(c+u_emissive)*u_exposure;c=c/(c+1.0);o=vec4(srgb(c),base.a);}`;
420
+ /** Create a WebGL2 renderer on a canvas (throws a clear error when WebGL2 is unavailable). */
421
+ function createRenderer(canvas, o = {}) {
422
+ const gl = canvas.getContext('webgl2', { alpha: o.alpha ?? true, antialias: o.antialias ?? true, premultipliedAlpha: false, preserveDrawingBuffer: !!o.preserveDrawingBuffer });
423
+ if (!gl)
424
+ throw new Error('[motionary] runtime/gl: WebGL2 is not available in this browser / context');
425
+ const programs = new Map();
426
+ const owned = [];
427
+ let draws = 0;
428
+ const compile = (key, fs) => {
429
+ let pr = programs.get(key);
430
+ if (pr)
431
+ return pr;
432
+ const sh = (type, src) => {
433
+ const s = gl.createShader(type);
434
+ gl.shaderSource(s, src);
435
+ gl.compileShader(s);
436
+ if (!gl.getShaderParameter(s, gl.COMPILE_STATUS))
437
+ throw new Error('[motionary] runtime/gl shader: ' + gl.getShaderInfoLog(s));
438
+ return s;
439
+ };
440
+ const p = gl.createProgram();
441
+ gl.attachShader(p, sh(gl.VERTEX_SHADER, VS));
442
+ gl.attachShader(p, sh(gl.FRAGMENT_SHADER, fs));
443
+ gl.linkProgram(p);
444
+ if (!gl.getProgramParameter(p, gl.LINK_STATUS))
445
+ throw new Error('[motionary] runtime/gl link: ' + gl.getProgramInfoLog(p));
446
+ pr = { p, u: new Map() };
447
+ programs.set(key, pr);
448
+ owned.push({ del: () => gl.deleteProgram(p) });
449
+ return pr;
450
+ };
451
+ const loc = (pr, n) => {
452
+ if (!pr.u.has(n))
453
+ pr.u.set(n, gl.getUniformLocation(pr.p, n));
454
+ return pr.u.get(n);
455
+ };
456
+ const uploadGeo = (g) => {
457
+ if (g._gpu)
458
+ return g._gpu;
459
+ const vao = gl.createVertexArray();
460
+ gl.bindVertexArray(vao);
461
+ const attr = (i, data, size, fallback) => {
462
+ if (!data) {
463
+ gl.disableVertexAttribArray(i);
464
+ if (size === 3)
465
+ gl.vertexAttrib3f(i, fallback[0], fallback[1], fallback[2]);
466
+ else
467
+ gl.vertexAttrib2f(i, fallback[0], fallback[1]);
468
+ return;
469
+ }
470
+ const b = gl.createBuffer();
471
+ owned.push({ del: () => gl.deleteBuffer(b) });
472
+ gl.bindBuffer(gl.ARRAY_BUFFER, b);
473
+ gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
474
+ gl.enableVertexAttribArray(i);
475
+ gl.vertexAttribPointer(i, size, gl.FLOAT, false, 0, 0);
476
+ };
477
+ attr(0, g.positions, 3, [0, 0, 0]);
478
+ attr(1, g.normals, 3, [0, 0, 1]);
479
+ attr(2, g.uvs, 2, [0, 0]);
480
+ let count = g.positions.length / 3, type = 0;
481
+ if (g.indices) {
482
+ const b = gl.createBuffer();
483
+ owned.push({ del: () => gl.deleteBuffer(b) });
484
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, b);
485
+ gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, g.indices, gl.STATIC_DRAW);
486
+ count = g.indices.length;
487
+ type = g.indices instanceof Uint32Array ? gl.UNSIGNED_INT : gl.UNSIGNED_SHORT;
488
+ }
489
+ gl.bindVertexArray(null);
490
+ owned.push({ del: () => gl.deleteVertexArray(vao) });
491
+ return (g._gpu = { vao, count, type, indexed: !!g.indices });
492
+ };
493
+ const uploadTex = (t, unit) => {
494
+ let tex = t._gpu;
495
+ gl.activeTexture(gl.TEXTURE0 + unit);
496
+ if (!tex) {
497
+ tex = gl.createTexture();
498
+ t._gpu = tex;
499
+ owned.push({ del: () => gl.deleteTexture(tex) });
500
+ t.needsUpdate = true;
501
+ if (t.video) {
502
+ const v = t.source;
503
+ const mark = () => {
504
+ t.needsUpdate = true;
505
+ v.requestVideoFrameCallback?.(mark);
506
+ };
507
+ if (v.requestVideoFrameCallback)
508
+ v.requestVideoFrameCallback(mark);
509
+ }
510
+ }
511
+ gl.bindTexture(gl.TEXTURE_2D, tex);
512
+ const v = t.video ? t.source : null;
513
+ const videoReady = !v || v.readyState >= 2;
514
+ if ((t.needsUpdate || (v && !v.requestVideoFrameCallback && !v.paused)) && videoReady) {
515
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, !!t.flipY);
516
+ const s = t.source;
517
+ if (s && s.data && !(s instanceof ImageData))
518
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, s.width, s.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array(s.data.buffer, s.data.byteOffset, s.data.byteLength));
519
+ else
520
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, s);
521
+ const pot = (n) => (n & (n - 1)) === 0;
522
+ const w = s.videoWidth || s.naturalWidth || s.width, h = s.videoHeight || s.naturalHeight || s.height;
523
+ const mip = !v && pot(w) && pot(h);
524
+ if (mip)
525
+ gl.generateMipmap(gl.TEXTURE_2D);
526
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, mip ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
527
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
528
+ const wrap = t.repeat && pot(w) && pot(h) ? gl.REPEAT : gl.CLAMP_TO_EDGE;
529
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrap);
530
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrap);
531
+ t.needsUpdate = false;
532
+ }
533
+ };
534
+ const r = {
535
+ gl,
536
+ canvas,
537
+ get drawCalls() {
538
+ return draws;
539
+ },
540
+ resize(w, h) {
541
+ const c = canvas;
542
+ const dpr = Math.min(o.maxDpr ?? 2, (typeof devicePixelRatio === 'number' && devicePixelRatio) || 1);
543
+ const W = Math.max(1, Math.round((w ?? c.clientWidth ?? c.width) * dpr)), H = Math.max(1, Math.round((h ?? c.clientHeight ?? c.height) * dpr));
544
+ if (c.width === W && c.height === H)
545
+ return false;
546
+ c.width = W;
547
+ c.height = H;
548
+ return true;
549
+ },
550
+ render(scene, camera, time = 0) {
551
+ draws = 0;
552
+ const W = gl.drawingBufferWidth, H = gl.drawingBufferHeight;
553
+ gl.viewport(0, 0, W, H);
554
+ camera.aspect = W / H || 1;
555
+ const bg = scene.background;
556
+ gl.clearColor(bg ? bg[0] : 0, bg ? bg[1] : 0, bg ? bg[2] : 0, bg ? bg[3] : 0);
557
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
558
+ gl.enable(gl.DEPTH_TEST);
559
+ scene.root.updateWorld();
560
+ const view = camera.view(), proj = camera.projection();
561
+ const lv = new Float32Array(16), lc = new Float32Array(12);
562
+ scene.lights.slice(0, 4).forEach((l, i) => {
563
+ lv.set([...l.vector, l.type === 'point' ? 1 : 0], i * 4);
564
+ lc.set(l.color.map((c) => c * l.intensity), i * 3);
565
+ });
566
+ const opaque = [], blend = [];
567
+ scene.root.traverse((n) => {
568
+ if (!n.visible || !n.mesh)
569
+ return;
570
+ for (const m of Array.isArray(n.mesh) ? n.mesh : [n.mesh])
571
+ (m.material.transparent || m.material.color[3] < 1 ? blend : opaque).push([n, m]);
572
+ });
573
+ for (const [n, m] of [...opaque, ...blend]) {
574
+ const mat = m.material;
575
+ const key = mat.type === 'shader' ? 'shader:' + mat.fragment : 'std';
576
+ const pr = compile(key, mat.type === 'shader' ? `${FS_HEAD}${Object.entries(mat.uniforms || {}).map(([k, v]) => `uniform ${typeof v === 'number' ? 'float' : v.source ? 'sampler2D' : `vec${v.length}`} ${k};`).join('')}\n${mat.fragment}\nvoid main(){o=shade();}` : FS_STD);
577
+ gl.useProgram(pr.p);
578
+ const U = (nm) => loc(pr, nm);
579
+ gl.uniformMatrix4fv(U('u_model'), false, n.world);
580
+ gl.uniformMatrix4fv(U('u_view'), false, view);
581
+ gl.uniformMatrix4fv(U('u_proj'), false, proj);
582
+ gl.uniformMatrix3fv(U('u_nmat'), false, mat4.normal(n.world));
583
+ gl.uniform4fv(U('u_color'), mat.color);
584
+ gl.uniform3fv(U('u_emissive'), mat.emissive);
585
+ gl.uniform3fv(U('u_camPos'), camera.position);
586
+ gl.uniform3fv(U('u_ambient'), scene.ambient);
587
+ gl.uniform1f(U('u_metal'), mat.metallic);
588
+ gl.uniform1f(U('u_rough'), mat.roughness);
589
+ gl.uniform1f(U('u_exposure'), scene.exposure);
590
+ gl.uniform1f(U('u_time'), time / 1000);
591
+ gl.uniform2f(U('u_res'), W, H);
592
+ gl.uniform1i(U('u_unlit'), mat.type === 'unlit' ? 1 : 0);
593
+ gl.uniform1i(U('u_nl'), Math.min(4, scene.lights.length));
594
+ gl.uniform4fv(U('u_lvec'), lv);
595
+ gl.uniform3fv(U('u_lcol'), lc);
596
+ let unit = 0;
597
+ if (mat.map) {
598
+ uploadTex(mat.map, unit);
599
+ gl.uniform1i(U('u_map'), unit++);
600
+ }
601
+ gl.uniform1i(U('u_hasMap'), mat.map ? 1 : 0);
602
+ for (const [k, v] of Object.entries(mat.uniforms || {})) {
603
+ if (typeof v === 'number')
604
+ gl.uniform1f(U(k), v);
605
+ else if (v.source) {
606
+ uploadTex(v, unit);
607
+ gl.uniform1i(U(k), unit++);
608
+ }
609
+ else {
610
+ const a = v;
611
+ (a.length === 2 ? gl.uniform2fv : a.length === 3 ? gl.uniform3fv : gl.uniform4fv).call(gl, U(k), a);
612
+ }
613
+ }
614
+ if (mat.doubleSided)
615
+ gl.disable(gl.CULL_FACE);
616
+ else
617
+ gl.enable(gl.CULL_FACE);
618
+ if (mat.transparent || mat.color[3] < 1) {
619
+ gl.enable(gl.BLEND);
620
+ gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
621
+ gl.depthMask(false);
622
+ }
623
+ else {
624
+ gl.disable(gl.BLEND);
625
+ gl.depthMask(true);
626
+ }
627
+ const g = uploadGeo(m.geometry);
628
+ gl.bindVertexArray(g.vao);
629
+ const mode = m.geometry.mode === 'lines' || mat.wireframe ? gl.LINES : m.geometry.mode === 'points' ? gl.POINTS : gl.TRIANGLES;
630
+ if (g.indexed)
631
+ gl.drawElements(mode, g.count, g.type, 0);
632
+ else
633
+ gl.drawArrays(mode, 0, g.count);
634
+ draws++;
635
+ }
636
+ gl.bindVertexArray(null);
637
+ gl.depthMask(true);
638
+ },
639
+ dispose() {
640
+ owned.splice(0).forEach((x) => x.del());
641
+ programs.clear();
642
+ },
643
+ };
644
+ return r;
645
+ }
646
+ /** Drag to orbit, wheel / pinch to zoom, arrow keys (when the element has focus). Call `update(dt)` per frame. */
647
+ function orbitControls(camera, el, o = {}) {
648
+ const off = sub(camera.position, camera.target);
649
+ let dist = Math.hypot(...off), theta = Math.atan2(off[0], off[2]), phi = Math.acos(Math.min(1, Math.max(-1, off[1] / (dist || 1))));
650
+ let vt = 0, vp = 0, vz = 0, drag = false, lx = 0, ly = 0;
651
+ const pts = new Map();
652
+ let pinch = 0;
653
+ const damp = o.damping ?? 0.12;
654
+ const reduce = typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
655
+ const ctl = { autoRotate: reduce ? 0 : o.autoRotate ?? 0, update, dispose };
656
+ const on = (t, ty, f, opt) => {
657
+ t.addEventListener(ty, f, opt);
658
+ return () => t.removeEventListener(ty, f, opt);
659
+ };
660
+ const offs = [
661
+ on(el, 'pointerdown', (e) => {
662
+ pts.set(e.pointerId, [e.clientX, e.clientY]);
663
+ drag = true;
664
+ lx = e.clientX;
665
+ ly = e.clientY;
666
+ el.setPointerCapture?.(e.pointerId);
667
+ }),
668
+ on(el, 'pointermove', (e) => {
669
+ if (!pts.has(e.pointerId))
670
+ return;
671
+ pts.set(e.pointerId, [e.clientX, e.clientY]);
672
+ if (pts.size === 2 && o.zoom !== false) {
673
+ const [a, b] = Array.from(pts.values());
674
+ const d = Math.hypot(a[0] - b[0], a[1] - b[1]);
675
+ if (pinch)
676
+ vz += (pinch - d) * 0.004;
677
+ pinch = d;
678
+ return;
679
+ }
680
+ if (!drag)
681
+ return;
682
+ vt -= (e.clientX - lx) * 0.005;
683
+ vp -= (e.clientY - ly) * 0.005;
684
+ lx = e.clientX;
685
+ ly = e.clientY;
686
+ }),
687
+ on(el, 'pointerup', (e) => {
688
+ pts.delete(e.pointerId);
689
+ pinch = 0;
690
+ drag = pts.size > 0;
691
+ }),
692
+ on(el, 'pointercancel', (e) => {
693
+ pts.delete(e.pointerId);
694
+ drag = false;
695
+ }),
696
+ on(el, 'wheel', (e) => {
697
+ if (o.zoom === false)
698
+ return;
699
+ e.preventDefault();
700
+ vz += Math.sign(e.deltaY) * 0.08;
701
+ }, { passive: false }),
702
+ on(el, 'keydown', (e) => {
703
+ const k = { ArrowLeft: [0.1, 0, 0], ArrowRight: [-0.1, 0, 0], ArrowUp: [0, 0.1, 0], ArrowDown: [0, -0.1, 0], '+': [0, 0, -0.1], '-': [0, 0, 0.1] }[e.key];
704
+ if (!k)
705
+ return;
706
+ e.preventDefault();
707
+ vt += k[0];
708
+ vp += k[1];
709
+ vz += k[2];
710
+ }),
711
+ ];
712
+ function update(dt) {
713
+ const moving = Math.abs(vt) + Math.abs(vp) + Math.abs(vz) > 1e-5 || ctl.autoRotate;
714
+ theta += vt + (ctl.autoRotate && !drag ? (ctl.autoRotate * dt) / 1000 : 0);
715
+ phi = Math.min(Math.PI - 0.05, Math.max(0.05, phi + vp));
716
+ dist = Math.min(o.maxDistance ?? Infinity, Math.max(o.minDistance ?? 0.01, dist * (1 + vz)));
717
+ const k = Math.pow(1 - damp, dt / 16.7);
718
+ vt *= k;
719
+ vp *= k;
720
+ vz *= k;
721
+ const t = camera.target;
722
+ camera.position = [t[0] + dist * Math.sin(phi) * Math.sin(theta), t[1] + dist * Math.cos(phi), t[2] + dist * Math.sin(phi) * Math.cos(theta)];
723
+ return !!moving;
724
+ }
725
+ function dispose() {
726
+ offs.forEach((f) => f());
727
+ }
728
+ return ctl;
729
+ }
730
+ /** The module object for `use(gl)`. */
731
+ const gl = {
732
+ id: 'gl',
733
+ version: RUNTIME_VERSION,
734
+ requires: ['core'],
735
+ api: { mat4, quatFromEuler, quatMultiply, quatSlerp, box, plane, sphere, torus, computeNormals, standardMaterial, unlitMaterial, shaderMaterial, color, texture, GlNode, Camera, Scene, bounds, frameNode, scrubVideo, createRenderer, orbitControls },
736
+ };
737
+
738
+ export { Camera, GlNode, Scene, bounds, box, color, computeNormals, createRenderer, frameNode, gl, mat4, orbitControls, plane, quatFromEuler, quatMultiply, quatSlerp, scrubVideo, shaderMaterial, sphere, standardMaterial, texture, torus, unlitMaterial };
739
+ //# sourceMappingURL=gl.js.map