@motionscript/core 0.1.0-alpha.7 → 0.1.0-alpha.8

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 (498) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/NOTICE +15 -14
  3. package/README.md +4 -4
  4. package/dist/assets/manager.d.ts.map +1 -1
  5. package/dist/assets/manager.js +7 -5
  6. package/dist/assets/manager.js.map +1 -1
  7. package/dist/attributes/audio/effects/chain.d.ts +73 -0
  8. package/dist/attributes/audio/effects/chain.d.ts.map +1 -0
  9. package/dist/attributes/audio/effects/chain.js +67 -0
  10. package/dist/attributes/audio/effects/chain.js.map +1 -0
  11. package/dist/attributes/audio/effects/implementations/echo.d.ts +14 -0
  12. package/dist/attributes/audio/effects/implementations/echo.d.ts.map +1 -0
  13. package/dist/attributes/audio/effects/implementations/echo.js +11 -0
  14. package/dist/attributes/audio/effects/implementations/echo.js.map +1 -0
  15. package/dist/attributes/audio/effects/implementations/gain.d.ts +10 -0
  16. package/dist/attributes/audio/effects/implementations/gain.d.ts.map +1 -0
  17. package/dist/attributes/audio/effects/implementations/gain.js +6 -0
  18. package/dist/attributes/audio/effects/implementations/gain.js.map +1 -0
  19. package/dist/attributes/audio/effects/implementations/highpass.d.ts +12 -0
  20. package/dist/attributes/audio/effects/implementations/highpass.d.ts.map +1 -0
  21. package/dist/attributes/audio/effects/implementations/highpass.js +10 -0
  22. package/dist/attributes/audio/effects/implementations/highpass.js.map +1 -0
  23. package/dist/attributes/audio/effects/implementations/lowpass.d.ts +12 -0
  24. package/dist/attributes/audio/effects/implementations/lowpass.d.ts.map +1 -0
  25. package/dist/attributes/audio/effects/implementations/lowpass.js +10 -0
  26. package/dist/attributes/audio/effects/implementations/lowpass.js.map +1 -0
  27. package/dist/attributes/audio/effects/implementations/tremolo.d.ts +12 -0
  28. package/dist/attributes/audio/effects/implementations/tremolo.d.ts.map +1 -0
  29. package/dist/attributes/audio/effects/implementations/tremolo.js +10 -0
  30. package/dist/attributes/audio/effects/implementations/tremolo.js.map +1 -0
  31. package/dist/attributes/audio/effects/index.d.ts +12 -0
  32. package/dist/attributes/audio/effects/index.d.ts.map +1 -0
  33. package/dist/attributes/audio/effects/index.js +4 -0
  34. package/dist/attributes/audio/effects/index.js.map +1 -0
  35. package/dist/attributes/audio/effects/registry.d.ts +36 -0
  36. package/dist/attributes/audio/effects/registry.d.ts.map +1 -0
  37. package/dist/attributes/audio/effects/registry.js +80 -0
  38. package/dist/attributes/audio/effects/registry.js.map +1 -0
  39. package/dist/attributes/audio/effects/union.d.ts +14 -0
  40. package/dist/attributes/audio/effects/union.d.ts.map +1 -0
  41. package/dist/attributes/audio/effects/union.js +24 -0
  42. package/dist/attributes/audio/effects/union.js.map +1 -0
  43. package/dist/attributes/audio/ramp.d.ts +103 -0
  44. package/dist/attributes/audio/ramp.d.ts.map +1 -0
  45. package/dist/attributes/audio/ramp.js +246 -0
  46. package/dist/attributes/audio/ramp.js.map +1 -0
  47. package/dist/attributes/audio/request.d.ts +24 -13
  48. package/dist/attributes/audio/request.d.ts.map +1 -1
  49. package/dist/attributes/audio/request.js +4 -3
  50. package/dist/attributes/audio/request.js.map +1 -1
  51. package/dist/attributes/audio/schedule.d.ts +21 -13
  52. package/dist/attributes/audio/schedule.d.ts.map +1 -1
  53. package/dist/attributes/audio/schedule.js +42 -28
  54. package/dist/attributes/audio/schedule.js.map +1 -1
  55. package/dist/attributes/audio/sound.d.ts +15 -12
  56. package/dist/attributes/audio/sound.d.ts.map +1 -1
  57. package/dist/attributes/audio/sound.js +8 -10
  58. package/dist/attributes/audio/sound.js.map +1 -1
  59. package/dist/attributes/audio/transition.d.ts +33 -0
  60. package/dist/attributes/audio/transition.d.ts.map +1 -0
  61. package/dist/attributes/audio/transition.js +48 -0
  62. package/dist/attributes/audio/transition.js.map +1 -0
  63. package/dist/attributes/index.d.ts +4 -3
  64. package/dist/attributes/index.d.ts.map +1 -1
  65. package/dist/attributes/index.js +4 -7
  66. package/dist/attributes/index.js.map +1 -1
  67. package/dist/attributes/layout/matrix2d.d.ts +2 -2
  68. package/dist/attributes/layout/matrix2d.js.map +1 -1
  69. package/dist/attributes/layout/space3d.js +1 -1
  70. package/dist/attributes/layout/space3d.js.map +1 -1
  71. package/dist/attributes/properties/typed.d.ts +7 -7
  72. package/dist/attributes/properties/typed.d.ts.map +1 -1
  73. package/dist/attributes/properties/typed.js +6 -6
  74. package/dist/attributes/properties/typed.js.map +1 -1
  75. package/dist/attributes/shape/corners/corner-radius.d.ts +1 -2
  76. package/dist/attributes/shape/corners/corner-radius.d.ts.map +1 -1
  77. package/dist/attributes/shape/corners/corner-radius.js +1 -2
  78. package/dist/attributes/shape/corners/corner-radius.js.map +1 -1
  79. package/dist/attributes/shape/effects/chain.d.ts +96 -409
  80. package/dist/attributes/shape/effects/chain.d.ts.map +1 -1
  81. package/dist/attributes/shape/effects/chain.js +93 -283
  82. package/dist/attributes/shape/effects/chain.js.map +1 -1
  83. package/dist/attributes/shape/effects/effect-data.d.ts +1 -1
  84. package/dist/attributes/shape/effects/effect-data.js.map +1 -1
  85. package/dist/attributes/shape/effects/implementations/ascii.d.ts +45 -13
  86. package/dist/attributes/shape/effects/implementations/ascii.d.ts.map +1 -1
  87. package/dist/attributes/shape/effects/implementations/ascii.js +29 -23
  88. package/dist/attributes/shape/effects/implementations/ascii.js.map +1 -1
  89. package/dist/attributes/shape/effects/implementations/bit-crush.d.ts +32 -7
  90. package/dist/attributes/shape/effects/implementations/bit-crush.d.ts.map +1 -1
  91. package/dist/attributes/shape/effects/implementations/bit-crush.js +17 -15
  92. package/dist/attributes/shape/effects/implementations/bit-crush.js.map +1 -1
  93. package/dist/attributes/shape/effects/implementations/block-displace.d.ts +46 -10
  94. package/dist/attributes/shape/effects/implementations/block-displace.d.ts.map +1 -1
  95. package/dist/attributes/shape/effects/implementations/block-displace.js +21 -19
  96. package/dist/attributes/shape/effects/implementations/block-displace.js.map +1 -1
  97. package/dist/attributes/shape/effects/implementations/bloom.d.ts +32 -7
  98. package/dist/attributes/shape/effects/implementations/bloom.d.ts.map +1 -1
  99. package/dist/attributes/shape/effects/implementations/bloom.js +17 -11
  100. package/dist/attributes/shape/effects/implementations/bloom.js.map +1 -1
  101. package/dist/attributes/shape/effects/implementations/blur.d.ts +16 -3
  102. package/dist/attributes/shape/effects/implementations/blur.d.ts.map +1 -1
  103. package/dist/attributes/shape/effects/implementations/blur.js +13 -5
  104. package/dist/attributes/shape/effects/implementations/blur.js.map +1 -1
  105. package/dist/attributes/shape/effects/implementations/bulge.d.ts +28 -9
  106. package/dist/attributes/shape/effects/implementations/bulge.d.ts.map +1 -1
  107. package/dist/attributes/shape/effects/implementations/bulge.js +15 -14
  108. package/dist/attributes/shape/effects/implementations/bulge.js.map +1 -1
  109. package/dist/attributes/shape/effects/implementations/chromatic-aberration.d.ts +21 -5
  110. package/dist/attributes/shape/effects/implementations/chromatic-aberration.d.ts.map +1 -1
  111. package/dist/attributes/shape/effects/implementations/chromatic-aberration.js +15 -10
  112. package/dist/attributes/shape/effects/implementations/chromatic-aberration.js.map +1 -1
  113. package/dist/attributes/shape/effects/implementations/color-adjustment.d.ts +96 -26
  114. package/dist/attributes/shape/effects/implementations/color-adjustment.d.ts.map +1 -1
  115. package/dist/attributes/shape/effects/implementations/color-adjustment.js +29 -26
  116. package/dist/attributes/shape/effects/implementations/color-adjustment.js.map +1 -1
  117. package/dist/attributes/shape/effects/implementations/curves.d.ts +20 -6
  118. package/dist/attributes/shape/effects/implementations/curves.d.ts.map +1 -1
  119. package/dist/attributes/shape/effects/implementations/curves.js +26 -23
  120. package/dist/attributes/shape/effects/implementations/curves.js.map +1 -1
  121. package/dist/attributes/shape/effects/implementations/directional-blur.d.ts +26 -5
  122. package/dist/attributes/shape/effects/implementations/directional-blur.d.ts.map +1 -1
  123. package/dist/attributes/shape/effects/implementations/directional-blur.js +15 -10
  124. package/dist/attributes/shape/effects/implementations/directional-blur.js.map +1 -1
  125. package/dist/attributes/shape/effects/implementations/dither.d.ts +58 -11
  126. package/dist/attributes/shape/effects/implementations/dither.d.ts.map +1 -1
  127. package/dist/attributes/shape/effects/implementations/dither.js +26 -20
  128. package/dist/attributes/shape/effects/implementations/dither.js.map +1 -1
  129. package/dist/attributes/shape/effects/implementations/drop-shadow.d.ts +46 -14
  130. package/dist/attributes/shape/effects/implementations/drop-shadow.d.ts.map +1 -1
  131. package/dist/attributes/shape/effects/implementations/drop-shadow.js +24 -29
  132. package/dist/attributes/shape/effects/implementations/drop-shadow.js.map +1 -1
  133. package/dist/attributes/shape/effects/implementations/duotone.d.ts +26 -7
  134. package/dist/attributes/shape/effects/implementations/duotone.d.ts.map +1 -1
  135. package/dist/attributes/shape/effects/implementations/duotone.js +17 -16
  136. package/dist/attributes/shape/effects/implementations/duotone.js.map +1 -1
  137. package/dist/attributes/shape/effects/implementations/edges.d.ts +29 -7
  138. package/dist/attributes/shape/effects/implementations/edges.d.ts.map +1 -1
  139. package/dist/attributes/shape/effects/implementations/edges.js +17 -14
  140. package/dist/attributes/shape/effects/implementations/edges.js.map +1 -1
  141. package/dist/attributes/shape/effects/implementations/glass.d.ts +76 -19
  142. package/dist/attributes/shape/effects/implementations/glass.d.ts.map +1 -1
  143. package/dist/attributes/shape/effects/implementations/glass.js +28 -22
  144. package/dist/attributes/shape/effects/implementations/glass.js.map +1 -1
  145. package/dist/attributes/shape/effects/implementations/glow.d.ts +149 -42
  146. package/dist/attributes/shape/effects/implementations/glow.d.ts.map +1 -1
  147. package/dist/attributes/shape/effects/implementations/glow.js +74 -72
  148. package/dist/attributes/shape/effects/implementations/glow.js.map +1 -1
  149. package/dist/attributes/shape/effects/implementations/grain.d.ts +43 -11
  150. package/dist/attributes/shape/effects/implementations/grain.d.ts.map +1 -1
  151. package/dist/attributes/shape/effects/implementations/grain.js +21 -18
  152. package/dist/attributes/shape/effects/implementations/grain.js.map +1 -1
  153. package/dist/attributes/shape/effects/implementations/grayscale.d.ts +17 -3
  154. package/dist/attributes/shape/effects/implementations/grayscale.d.ts.map +1 -1
  155. package/dist/attributes/shape/effects/implementations/grayscale.js +13 -5
  156. package/dist/attributes/shape/effects/implementations/grayscale.js.map +1 -1
  157. package/dist/attributes/shape/effects/implementations/halftone.d.ts +40 -9
  158. package/dist/attributes/shape/effects/implementations/halftone.d.ts.map +1 -1
  159. package/dist/attributes/shape/effects/implementations/halftone.js +20 -16
  160. package/dist/attributes/shape/effects/implementations/halftone.js.map +1 -1
  161. package/dist/attributes/shape/effects/implementations/invert.d.ts +23 -5
  162. package/dist/attributes/shape/effects/implementations/invert.d.ts.map +1 -1
  163. package/dist/attributes/shape/effects/implementations/invert.js +15 -10
  164. package/dist/attributes/shape/effects/implementations/invert.js.map +1 -1
  165. package/dist/attributes/shape/effects/implementations/kaleidoscope.d.ts +57 -18
  166. package/dist/attributes/shape/effects/implementations/kaleidoscope.d.ts.map +1 -1
  167. package/dist/attributes/shape/effects/implementations/kaleidoscope.js +25 -22
  168. package/dist/attributes/shape/effects/implementations/kaleidoscope.js.map +1 -1
  169. package/dist/attributes/shape/effects/implementations/lut.d.ts +34 -7
  170. package/dist/attributes/shape/effects/implementations/lut.d.ts.map +1 -1
  171. package/dist/attributes/shape/effects/implementations/lut.js +20 -16
  172. package/dist/attributes/shape/effects/implementations/lut.js.map +1 -1
  173. package/dist/attributes/shape/effects/implementations/magnify.d.ts +27 -9
  174. package/dist/attributes/shape/effects/implementations/magnify.d.ts.map +1 -1
  175. package/dist/attributes/shape/effects/implementations/magnify.js +17 -14
  176. package/dist/attributes/shape/effects/implementations/magnify.js.map +1 -1
  177. package/dist/attributes/shape/effects/implementations/motion-blur.d.ts +54 -19
  178. package/dist/attributes/shape/effects/implementations/motion-blur.d.ts.map +1 -1
  179. package/dist/attributes/shape/effects/implementations/motion-blur.js +42 -20
  180. package/dist/attributes/shape/effects/implementations/motion-blur.js.map +1 -1
  181. package/dist/attributes/shape/effects/implementations/oil-paint.d.ts +17 -3
  182. package/dist/attributes/shape/effects/implementations/oil-paint.d.ts.map +1 -1
  183. package/dist/attributes/shape/effects/implementations/oil-paint.js +13 -9
  184. package/dist/attributes/shape/effects/implementations/oil-paint.js.map +1 -1
  185. package/dist/attributes/shape/effects/implementations/outline.d.ts +28 -8
  186. package/dist/attributes/shape/effects/implementations/outline.d.ts.map +1 -1
  187. package/dist/attributes/shape/effects/implementations/outline.js +18 -17
  188. package/dist/attributes/shape/effects/implementations/outline.js.map +1 -1
  189. package/dist/attributes/shape/effects/implementations/pixelate.d.ts +25 -6
  190. package/dist/attributes/shape/effects/implementations/pixelate.d.ts.map +1 -1
  191. package/dist/attributes/shape/effects/implementations/pixelate.js +16 -14
  192. package/dist/attributes/shape/effects/implementations/pixelate.js.map +1 -1
  193. package/dist/attributes/shape/effects/implementations/posterize.d.ts +14 -3
  194. package/dist/attributes/shape/effects/implementations/posterize.d.ts.map +1 -1
  195. package/dist/attributes/shape/effects/implementations/posterize.js +13 -9
  196. package/dist/attributes/shape/effects/implementations/posterize.js.map +1 -1
  197. package/dist/attributes/shape/effects/implementations/progressive-blur.d.ts +91 -26
  198. package/dist/attributes/shape/effects/implementations/progressive-blur.d.ts.map +1 -1
  199. package/dist/attributes/shape/effects/implementations/progressive-blur.js +27 -28
  200. package/dist/attributes/shape/effects/implementations/progressive-blur.js.map +1 -1
  201. package/dist/attributes/shape/effects/implementations/radial-blur.d.ts +49 -10
  202. package/dist/attributes/shape/effects/implementations/radial-blur.d.ts.map +1 -1
  203. package/dist/attributes/shape/effects/implementations/radial-blur.js +19 -20
  204. package/dist/attributes/shape/effects/implementations/radial-blur.js.map +1 -1
  205. package/dist/attributes/shape/effects/implementations/rgb-shift.d.ts +36 -6
  206. package/dist/attributes/shape/effects/implementations/rgb-shift.d.ts.map +1 -1
  207. package/dist/attributes/shape/effects/implementations/rgb-shift.js +16 -15
  208. package/dist/attributes/shape/effects/implementations/rgb-shift.js.map +1 -1
  209. package/dist/attributes/shape/effects/implementations/scanlines.d.ts +52 -11
  210. package/dist/attributes/shape/effects/implementations/scanlines.d.ts.map +1 -1
  211. package/dist/attributes/shape/effects/implementations/scanlines.js +21 -18
  212. package/dist/attributes/shape/effects/implementations/scanlines.js.map +1 -1
  213. package/dist/attributes/shape/effects/implementations/scatter.d.ts +23 -9
  214. package/dist/attributes/shape/effects/implementations/scatter.d.ts.map +1 -1
  215. package/dist/attributes/shape/effects/implementations/scatter.js +15 -12
  216. package/dist/attributes/shape/effects/implementations/scatter.js.map +1 -1
  217. package/dist/attributes/shape/effects/implementations/shader.d.ts +90 -34
  218. package/dist/attributes/shape/effects/implementations/shader.d.ts.map +1 -1
  219. package/dist/attributes/shape/effects/implementations/shader.js +42 -26
  220. package/dist/attributes/shape/effects/implementations/shader.js.map +1 -1
  221. package/dist/attributes/shape/effects/implementations/sharpen.d.ts +23 -5
  222. package/dist/attributes/shape/effects/implementations/sharpen.d.ts.map +1 -1
  223. package/dist/attributes/shape/effects/implementations/sharpen.js +16 -11
  224. package/dist/attributes/shape/effects/implementations/sharpen.js.map +1 -1
  225. package/dist/attributes/shape/effects/implementations/streak.d.ts +40 -9
  226. package/dist/attributes/shape/effects/implementations/streak.d.ts.map +1 -1
  227. package/dist/attributes/shape/effects/implementations/streak.js +19 -16
  228. package/dist/attributes/shape/effects/implementations/streak.js.map +1 -1
  229. package/dist/attributes/shape/effects/implementations/threshold.d.ts +24 -5
  230. package/dist/attributes/shape/effects/implementations/threshold.d.ts.map +1 -1
  231. package/dist/attributes/shape/effects/implementations/threshold.js +17 -11
  232. package/dist/attributes/shape/effects/implementations/threshold.js.map +1 -1
  233. package/dist/attributes/shape/effects/implementations/twirl.d.ts +35 -8
  234. package/dist/attributes/shape/effects/implementations/twirl.d.ts.map +1 -1
  235. package/dist/attributes/shape/effects/implementations/twirl.js +17 -16
  236. package/dist/attributes/shape/effects/implementations/twirl.js.map +1 -1
  237. package/dist/attributes/shape/effects/implementations/vignette.d.ts +37 -7
  238. package/dist/attributes/shape/effects/implementations/vignette.d.ts.map +1 -1
  239. package/dist/attributes/shape/effects/implementations/vignette.js +19 -18
  240. package/dist/attributes/shape/effects/implementations/vignette.js.map +1 -1
  241. package/dist/attributes/shape/effects/implementations/vintage.d.ts +24 -5
  242. package/dist/attributes/shape/effects/implementations/vintage.d.ts.map +1 -1
  243. package/dist/attributes/shape/effects/implementations/vintage.js +15 -10
  244. package/dist/attributes/shape/effects/implementations/vintage.js.map +1 -1
  245. package/dist/attributes/shape/effects/implementations/wave.d.ts +61 -14
  246. package/dist/attributes/shape/effects/implementations/wave.d.ts.map +1 -1
  247. package/dist/attributes/shape/effects/implementations/wave.js +26 -23
  248. package/dist/attributes/shape/effects/implementations/wave.js.map +1 -1
  249. package/dist/attributes/shape/effects/index.d.ts +4 -2
  250. package/dist/attributes/shape/effects/index.d.ts.map +1 -1
  251. package/dist/attributes/shape/effects/index.js +1 -1
  252. package/dist/attributes/shape/effects/index.js.map +1 -1
  253. package/dist/attributes/shape/effects/registry.d.ts +11 -0
  254. package/dist/attributes/shape/effects/registry.d.ts.map +1 -1
  255. package/dist/attributes/shape/effects/registry.js +113 -102
  256. package/dist/attributes/shape/effects/registry.js.map +1 -1
  257. package/dist/attributes/shape/effects/spec.d.ts +229 -0
  258. package/dist/attributes/shape/effects/spec.d.ts.map +1 -0
  259. package/dist/attributes/shape/effects/spec.js +178 -0
  260. package/dist/attributes/shape/effects/spec.js.map +1 -0
  261. package/dist/attributes/shape/fill/chain.d.ts +7 -9
  262. package/dist/attributes/shape/fill/chain.d.ts.map +1 -1
  263. package/dist/attributes/shape/fill/chain.js +9 -11
  264. package/dist/attributes/shape/fill/chain.js.map +1 -1
  265. package/dist/attributes/shape/fill/implementations/shader.d.ts +27 -26
  266. package/dist/attributes/shape/fill/implementations/shader.d.ts.map +1 -1
  267. package/dist/attributes/shape/fill/implementations/shader.js +20 -14
  268. package/dist/attributes/shape/fill/implementations/shader.js.map +1 -1
  269. package/dist/attributes/shape/fill/index.d.ts +1 -1
  270. package/dist/attributes/shape/fill/index.d.ts.map +1 -1
  271. package/dist/attributes/shape/fill/index.js.map +1 -1
  272. package/dist/attributes/shape/fill/registry.d.ts +1 -2
  273. package/dist/attributes/shape/fill/registry.d.ts.map +1 -1
  274. package/dist/attributes/shape/fill/registry.js +1 -2
  275. package/dist/attributes/shape/fill/registry.js.map +1 -1
  276. package/dist/attributes/shape/filters/chain.d.ts +2 -6
  277. package/dist/attributes/shape/filters/chain.d.ts.map +1 -1
  278. package/dist/attributes/shape/filters/chain.js +1 -5
  279. package/dist/attributes/shape/filters/chain.js.map +1 -1
  280. package/dist/attributes/shape/filters/implementations/color-matrix.d.ts +2 -2
  281. package/dist/attributes/shape/filters/implementations/color-matrix.d.ts.map +1 -1
  282. package/dist/attributes/shape/filters/implementations/color-matrix.js.map +1 -1
  283. package/dist/attributes/shape/filters/registry.d.ts +1 -1
  284. package/dist/attributes/shape/filters/registry.d.ts.map +1 -1
  285. package/dist/attributes/shape/filters/registry.js +3 -3
  286. package/dist/attributes/shape/filters/registry.js.map +1 -1
  287. package/dist/attributes/shape/filters/union.d.ts +2 -3
  288. package/dist/attributes/shape/filters/union.d.ts.map +1 -1
  289. package/dist/attributes/shape/filters/union.js.map +1 -1
  290. package/dist/attributes/shape/shaders/index.d.ts +2 -0
  291. package/dist/attributes/shape/shaders/index.d.ts.map +1 -1
  292. package/dist/attributes/shape/shaders/index.js +2 -0
  293. package/dist/attributes/shape/shaders/index.js.map +1 -1
  294. package/dist/attributes/shape/shaders/language.d.ts +26 -0
  295. package/dist/attributes/shape/shaders/language.d.ts.map +1 -0
  296. package/dist/attributes/shape/shaders/language.js +20 -0
  297. package/dist/attributes/shape/shaders/language.js.map +1 -0
  298. package/dist/attributes/shape/shaders/pack.d.ts +25 -11
  299. package/dist/attributes/shape/shaders/pack.d.ts.map +1 -1
  300. package/dist/attributes/shape/shaders/pack.js +9 -4
  301. package/dist/attributes/shape/shaders/pack.js.map +1 -1
  302. package/dist/attributes/shape/shaders/resolve.d.ts +4 -5
  303. package/dist/attributes/shape/shaders/resolve.d.ts.map +1 -1
  304. package/dist/attributes/shape/shaders/resolve.js +3 -6
  305. package/dist/attributes/shape/shaders/resolve.js.map +1 -1
  306. package/dist/attributes/shape/shaders/uniforms.d.ts +41 -0
  307. package/dist/attributes/shape/shaders/uniforms.d.ts.map +1 -0
  308. package/dist/attributes/shape/shaders/uniforms.js +0 -0
  309. package/dist/attributes/shape/shaders/uniforms.js.map +1 -0
  310. package/dist/browser/chunks/chunk-AOT33LMS.js +13 -0
  311. package/dist/browser/chunks/chunk-AOT33LMS.js.map +7 -0
  312. package/dist/browser/chunks/chunk-GKM6UZJR.js +6 -0
  313. package/dist/browser/chunks/chunk-GKM6UZJR.js.map +7 -0
  314. package/dist/browser/experimental.js +1 -1
  315. package/dist/browser/experimental.js.map +4 -4
  316. package/dist/browser/index.js +1 -1
  317. package/dist/browser/index.js.map +2 -2
  318. package/dist/browser/manifest.json +1 -1
  319. package/dist/browser/sdk.js +1 -1
  320. package/dist/components/builtins/audio/audio.d.ts +14 -5
  321. package/dist/components/builtins/audio/audio.d.ts.map +1 -1
  322. package/dist/components/builtins/audio/audio.js +10 -13
  323. package/dist/components/builtins/audio/audio.js.map +1 -1
  324. package/dist/components/builtins/geometry/composite.d.ts +3 -3
  325. package/dist/components/builtins/media/media.d.ts +7 -7
  326. package/dist/components/builtins/media/media.d.ts.map +1 -1
  327. package/dist/components/builtins/media/media.js +4 -10
  328. package/dist/components/builtins/media/media.js.map +1 -1
  329. package/dist/components/builtins/text/text.d.ts +12 -12
  330. package/dist/components/builtins/text/text.d.ts.map +1 -1
  331. package/dist/components/builtins/text/text.js +3 -0
  332. package/dist/components/builtins/text/text.js.map +1 -1
  333. package/dist/components/factory/api.d.ts +38 -11
  334. package/dist/components/factory/api.d.ts.map +1 -1
  335. package/dist/components/factory/api.js.map +1 -1
  336. package/dist/components/factory/component3d.d.ts.map +1 -1
  337. package/dist/components/factory/component3d.js +11 -3
  338. package/dist/components/factory/component3d.js.map +1 -1
  339. package/dist/components/factory/factory.d.ts +3 -0
  340. package/dist/components/factory/factory.d.ts.map +1 -1
  341. package/dist/components/factory/factory.js +39 -5
  342. package/dist/components/factory/factory.js.map +1 -1
  343. package/dist/components/modules/text-style.d.ts +1 -1
  344. package/dist/components/trees/2d/node-render.d.ts +1 -1
  345. package/dist/components/trees/2d/node-render.js +1 -1
  346. package/dist/components/trees/2d/node-render.js.map +1 -1
  347. package/dist/components/trees/2d/node2d.d.ts +1 -1
  348. package/dist/components/trees/2d/node2d.js +1 -1
  349. package/dist/components/trees/2d/node2d.js.map +1 -1
  350. package/dist/components/trees/audio/node-audio.d.ts +16 -9
  351. package/dist/components/trees/audio/node-audio.d.ts.map +1 -1
  352. package/dist/components/trees/audio/node-audio.js +15 -11
  353. package/dist/components/trees/audio/node-audio.js.map +1 -1
  354. package/dist/document/command-traits.d.ts +12 -2
  355. package/dist/document/command-traits.d.ts.map +1 -1
  356. package/dist/document/command-traits.js +34 -6
  357. package/dist/document/command-traits.js.map +1 -1
  358. package/dist/document/index.d.ts +8 -0
  359. package/dist/document/index.d.ts.map +1 -1
  360. package/dist/document/index.js +4 -0
  361. package/dist/document/index.js.map +1 -1
  362. package/dist/document/migrate.d.ts +70 -0
  363. package/dist/document/migrate.d.ts.map +1 -0
  364. package/dist/document/migrate.js +202 -0
  365. package/dist/document/migrate.js.map +1 -0
  366. package/dist/document/missing-node.d.ts +27 -0
  367. package/dist/document/missing-node.d.ts.map +1 -0
  368. package/dist/document/missing-node.js +48 -0
  369. package/dist/document/missing-node.js.map +1 -0
  370. package/dist/document/node-descriptor.d.ts +4 -0
  371. package/dist/document/node-descriptor.d.ts.map +1 -1
  372. package/dist/document/node-descriptor.js.map +1 -1
  373. package/dist/document/placement.d.ts +2 -1
  374. package/dist/document/placement.d.ts.map +1 -1
  375. package/dist/document/placement.js.map +1 -1
  376. package/dist/document/project.d.ts +2 -0
  377. package/dist/document/project.d.ts.map +1 -1
  378. package/dist/document/project.js +1 -0
  379. package/dist/document/project.js.map +1 -1
  380. package/dist/document/prop-evolution.d.ts +51 -0
  381. package/dist/document/prop-evolution.d.ts.map +1 -0
  382. package/dist/document/prop-evolution.js +83 -0
  383. package/dist/document/prop-evolution.js.map +1 -0
  384. package/dist/document/registry.d.ts +16 -0
  385. package/dist/document/registry.d.ts.map +1 -1
  386. package/dist/document/registry.js +30 -4
  387. package/dist/document/registry.js.map +1 -1
  388. package/dist/document/settled-index.d.ts +2 -0
  389. package/dist/document/settled-index.d.ts.map +1 -1
  390. package/dist/document/settled-index.js +5 -5
  391. package/dist/document/settled-index.js.map +1 -1
  392. package/dist/document/timeline-patch.d.ts +4 -0
  393. package/dist/document/timeline-patch.d.ts.map +1 -1
  394. package/dist/document/timeline-patch.js +28 -3
  395. package/dist/document/timeline-patch.js.map +1 -1
  396. package/dist/document/timeline.d.ts +45 -1
  397. package/dist/document/timeline.d.ts.map +1 -1
  398. package/dist/document/timeline.js +172 -42
  399. package/dist/document/timeline.js.map +1 -1
  400. package/dist/document/types.d.ts +14 -28
  401. package/dist/document/types.d.ts.map +1 -1
  402. package/dist/document/types.js.map +1 -1
  403. package/dist/document/validate.d.ts +17 -5
  404. package/dist/document/validate.d.ts.map +1 -1
  405. package/dist/document/validate.js +158 -21
  406. package/dist/document/validate.js.map +1 -1
  407. package/dist/document/vocabulary.d.ts +28 -0
  408. package/dist/document/vocabulary.d.ts.map +1 -0
  409. package/dist/document/vocabulary.js +42 -0
  410. package/dist/document/vocabulary.js.map +1 -0
  411. package/dist/experimental.d.ts +68 -8
  412. package/dist/experimental.d.ts.map +1 -1
  413. package/dist/experimental.js +22 -8
  414. package/dist/experimental.js.map +1 -1
  415. package/dist/platform/exporter.d.ts +13 -0
  416. package/dist/platform/exporter.d.ts.map +1 -1
  417. package/dist/platform/exporter.js.map +1 -1
  418. package/dist/renamed-scene-names.d.ts +1 -1
  419. package/dist/renamed-scene-names.d.ts.map +1 -1
  420. package/dist/renamed-scene-names.js +1 -1
  421. package/dist/renamed-scene-names.js.map +1 -1
  422. package/dist/render/canvas-render-context2d.d.ts +9 -0
  423. package/dist/render/canvas-render-context2d.d.ts.map +1 -1
  424. package/dist/render/canvas-render-context2d.js +10 -0
  425. package/dist/render/canvas-render-context2d.js.map +1 -1
  426. package/dist/render/clip-contains.js +1 -1
  427. package/dist/render/clip-contains.js.map +1 -1
  428. package/dist/render/descriptors/text.d.ts +2 -2
  429. package/dist/render/descriptors/text.js +2 -2
  430. package/dist/render/descriptors/text.js.map +1 -1
  431. package/dist/render/index.d.ts +2 -0
  432. package/dist/render/index.d.ts.map +1 -1
  433. package/dist/render/index.js +1 -0
  434. package/dist/render/index.js.map +1 -1
  435. package/dist/render/render-context2d.d.ts +1 -1
  436. package/dist/render/render-context2d.js.map +1 -1
  437. package/dist/render/render-issue.d.ts +39 -0
  438. package/dist/render/render-issue.d.ts.map +1 -0
  439. package/dist/render/render-issue.js +29 -0
  440. package/dist/render/render-issue.js.map +1 -0
  441. package/dist/render/surface.d.ts +2 -2
  442. package/dist/render/surface.js.map +1 -1
  443. package/dist/render3d/graphics3d.d.ts.map +1 -1
  444. package/dist/render3d/graphics3d.js +54 -5
  445. package/dist/render3d/graphics3d.js.map +1 -1
  446. package/dist/runtime/asset-refine.js +2 -1
  447. package/dist/runtime/asset-refine.js.map +1 -1
  448. package/dist/runtime/asset-timeline.d.ts +10 -0
  449. package/dist/runtime/asset-timeline.d.ts.map +1 -1
  450. package/dist/runtime/asset-timeline.js.map +1 -1
  451. package/dist/runtime/asset-update.d.ts.map +1 -1
  452. package/dist/runtime/asset-update.js +7 -0
  453. package/dist/runtime/asset-update.js.map +1 -1
  454. package/dist/runtime/clip-instance.d.ts +3 -1
  455. package/dist/runtime/clip-instance.d.ts.map +1 -1
  456. package/dist/runtime/clip-instance.js +4 -0
  457. package/dist/runtime/clip-instance.js.map +1 -1
  458. package/dist/runtime/clip-store.d.ts.map +1 -1
  459. package/dist/runtime/clip-store.js +17 -2
  460. package/dist/runtime/clip-store.js.map +1 -1
  461. package/dist/runtime/engine.d.ts +5 -3
  462. package/dist/runtime/engine.d.ts.map +1 -1
  463. package/dist/runtime/engine.js +2 -1
  464. package/dist/runtime/engine.js.map +1 -1
  465. package/dist/runtime/playback-controller.d.ts.map +1 -1
  466. package/dist/runtime/playback-controller.js +14 -4
  467. package/dist/runtime/playback-controller.js.map +1 -1
  468. package/dist/runtime/session.d.ts +7 -3
  469. package/dist/runtime/session.d.ts.map +1 -1
  470. package/dist/runtime/session.js +11 -4
  471. package/dist/runtime/session.js.map +1 -1
  472. package/dist/runtime/text-geometry.d.ts +1 -1
  473. package/dist/runtime/text-geometry.js.map +1 -1
  474. package/dist/sdk/index.d.ts +8 -6
  475. package/dist/sdk/index.d.ts.map +1 -1
  476. package/dist/sdk/index.js +10 -3
  477. package/dist/sdk/index.js.map +1 -1
  478. package/dist/tween/command-decorator.d.ts +7 -0
  479. package/dist/tween/command-decorator.d.ts.map +1 -1
  480. package/dist/tween/command-decorator.js +1 -0
  481. package/dist/tween/command-decorator.js.map +1 -1
  482. package/dist/tween/ease/describe.d.ts +2 -0
  483. package/dist/tween/ease/describe.d.ts.map +1 -1
  484. package/dist/tween/ease/describe.js +4 -0
  485. package/dist/tween/ease/describe.js.map +1 -1
  486. package/dist/tween/ease/spec.d.ts +31 -0
  487. package/dist/tween/ease/spec.d.ts.map +1 -0
  488. package/dist/tween/ease/spec.js +51 -0
  489. package/dist/tween/ease/spec.js.map +1 -0
  490. package/dist/tween/index.d.ts +1 -0
  491. package/dist/tween/index.d.ts.map +1 -1
  492. package/dist/tween/index.js +1 -0
  493. package/dist/tween/index.js.map +1 -1
  494. package/package.json +2 -2
  495. package/dist/browser/chunks/chunk-D4FSTPML.js +0 -14
  496. package/dist/browser/chunks/chunk-D4FSTPML.js.map +0 -7
  497. package/dist/browser/chunks/chunk-RTNATFWX.js +0 -5
  498. package/dist/browser/chunks/chunk-RTNATFWX.js.map +0 -7
@@ -1 +1 @@
1
- {"version":3,"file":"render-context2d.js","sourceRoot":"","sources":["../../src/render/render-context2d.ts"],"names":[],"mappings":"","sourcesContent":["import type { FontStyle, TextStyle } from \"@/attributes/text/types\";\r\nimport type { TransformState } from \"./descriptors/transform\";\r\nimport type { MeasureContext2D } from \"./measure-context\";\r\nimport type { TextState } from \"./descriptors/text\";\r\nimport type { TextBlockLayout } from \"./text-layout\";\r\nimport type { Graphics2D } from \"./graphics2d\";\r\nimport type { Clip } from \"./clip\";\r\nimport type { Vector2 } from \"@/attributes/layout/vector2\";\r\nimport type { MaskOptions } from \"@/attributes/mask/mask\";\r\nimport type { BooleanOperation } from \"@/attributes/mask/boolean\";\r\nimport type { NodeEffect } from \"@/attributes/shape/effects/union\";\r\nimport type { Size2D } from \"@/attributes/layout/size\";\r\n\r\n/**\r\n * Where an effect scope draws: `'foreground'` warps/filters the node's *own*\r\n * content (its fill, stroke and children), `'backdrop'` warps/filters the canvas\r\n * content already painted *beneath* the node (clipped to its silhouette). See\r\n * {@link RenderContext2D.beginEffects}.\r\n */\r\nexport type EffectTarget = \"foreground\" | \"backdrop\";\r\n\r\n/**\r\n * Pixels produced by {@link RenderContext2D.rasterize}: RGBA8888,\r\n * unpremultiplied, top-down (canvas row order). `width`/`height` are **device**\r\n * px, so they reflect the pixel ratio the renderer actually used rather than the\r\n * logical size that was asked for.\r\n */\r\nexport interface RasterizedSurface {\r\n pixels: Uint8Array;\r\n width: number;\r\n height: number;\r\n}\r\n\r\n/**\r\n * A bounding box in the current node's local space (origin = the node's\r\n * layout-cell centre, the same space shapes are drawn in). `left/top` use the\r\n * canvas convention (y down).\r\n */\r\nexport interface SpaceRect {\r\n left: number;\r\n top: number;\r\n right: number;\r\n bottom: number;\r\n}\r\n\r\n/**\r\n * Reference rects a fill can resolve against, supplied per-node at `begin()`.\r\n * `local` is derived from the drawn shapes themselves and `global` (the\r\n * viewport) is computed by the renderer from the surface size, so only the\r\n * parent frame is passed here.\r\n */\r\nexport interface SpaceRects {\r\n /** The parent node's content rect, in this node's local space. */\r\n parent?: SpaceRect;\r\n}\r\n\r\n/**\r\n * Per-node state supplied to {@link RenderContext2D.begin} for the duration of a\r\n * node's draw scope. Carries the node identity and gradient-space `rects` plus\r\n * the node's per-frame motion, sampled at render time. Motion-driven effects\r\n * (e.g. motion blur) read the current node's `velocity` from this state instead\r\n * of being authored with a fixed direction.\r\n *\r\n * Velocity fields are `0`/`{0,0}` when the motion is unknown — the first frame a\r\n * node renders, or after a time discontinuity (scrub/seek) where no trustworthy\r\n * delta exists.\r\n */\r\nexport interface NodeRenderState {\r\n /** Stable node identifier. */\r\n id: string;\r\n /** Parent / viewport rects in this node's local space. */\r\n rects: SpaceRects;\r\n /** How long this node has existed, in seconds (`NodeTime.elapsed`). */\r\n elapsed: number;\r\n /** The frame delta, in seconds, used to derive displacement from velocity. */\r\n dt: number;\r\n /** Translational velocity in px/sec, world space (y-down). `{0,0}` when unknown. */\r\n velocity: Vector2;\r\n /** Heading of `velocity` in degrees (`atan2(vy, vx)`). `0` when unknown. */\r\n direction: number;\r\n /** Magnitude of `velocity` in px/sec. `0` when unknown. */\r\n speed: number;\r\n /** Rotational velocity in degrees/sec. `0` when unknown. Reserved for radial motion blur. */\r\n angularVelocity: number;\r\n /** Scale velocity in scale-units/sec. `0` when unknown. Reserved for zoom motion blur. */\r\n scaleVelocity: number;\r\n}\r\n\r\n/**\r\n * The drawing surface a `Node2D` paints into — **the whole of what a node may\r\n * ask of a renderer, and nothing else.**\r\n *\r\n * Shapes are never declared directly on the context: they are built with a\r\n * {@link Graphics2D} command list and submitted via {@link draw}. Multiple\r\n * shapes chained on one `Graphics2D` before a paint call are combined into a\r\n * single surface and painted together:\r\n *\r\n * ctx.draw(new Graphics2D().ellipse(...).rect(...).fill(...)); // shared surface\r\n *\r\n * On top of that it carries text measurement — it extends {@link MeasureContext2D}, so\r\n * a node measures and draws through one object — and the higher-level scoping\r\n * operations: transforms, masks, clips, camera, boolean ops, effect scopes.\r\n * `begin(state)` / `end()` bracket each node's draw call so the context can\r\n * track which node is active.\r\n *\r\n * **An interface, with `CanvasRenderContext2D` as its one base class.** What a\r\n * node calls and what a *host* calls are different lists: `execute`,\r\n * `screenshot`, `unmount` and `dispose` drive a render pass and have no business\r\n * being reachable from inside one. Splitting them is what keeps this surface\r\n * the size it is. Every real backend still extends the class, which preserves\r\n * the `draw` to `drawGraphics` invariant that gives them all one implementation\r\n * of text-default resolution.\r\n *\r\n * `RenderContext3D` is its sibling, not its subclass: the two share no members,\r\n * because a 3D scene is described with lights, a camera and meshes rather than\r\n * with paths and paint.\r\n */\r\nexport interface RenderContext2D extends MeasureContext2D {\r\n measureText(\r\n text: string,\r\n fontSize: number,\r\n fontFamily: string,\r\n fontWeight?: number,\r\n letterSpacing?: number,\r\n fontStyle?: FontStyle,\r\n ): Size2D;\r\n\r\n // ---- Inherited text-style defaults ------------------------------------\r\n // `<DefaultTextStyle>` reaches a `Text`/`RichText` node through the context\r\n // map, applied once when the node binds. A raw `Graphics2D` has no node to\r\n // bind, so it inherits the same defaults here instead — pushed around a\r\n // subtree's draw scope, and folded into each `text`/`richText` op by\r\n // `draw()`. Same vocabulary (`TextStyle`), same precedence, two channels.\r\n\r\n /**\r\n * Set text-style defaults for everything drawn until the matching\r\n * {@link popTextStyle} — the drawn-graphics half of `<DefaultTextStyle>`.\r\n *\r\n * `style` is **merged** onto the defaults already in effect, per key, so\r\n * nesting accumulates the way the node channel does: an outer scope's\r\n * `fontFamily` and an inner scope's `fontSize` both apply, and a key set by\r\n * both takes the inner value. Values are resolved (a tweened `fontSize`\r\n * arrives as this frame's number), not callbacks.\r\n *\r\n * Pass `null` to open a scope that inherits **nothing** — not the enclosing\r\n * defaults and not the project's `theme.typography.default`. That is for a\r\n * node whose text is its own vocabulary rather than the document's: `Code`\r\n * does it so a scene-wide serif face doesn't reflow a monospaced code block.\r\n *\r\n * Always pair with `popTextStyle()` in a `finally`; the stack is shared with\r\n * every sibling drawn afterwards.\r\n */\r\n pushTextStyle(style: TextStyle | null): void;\r\n\r\n /** Close the innermost scope opened by {@link pushTextStyle}. */\r\n popTextStyle(): void;\r\n\r\n /**\r\n * The text-style defaults in effect right now: the innermost\r\n * {@link pushTextStyle} scope, or the project's `theme.typography.default`\r\n * when no scope is open — the same preset a `Text` node falls back to, so a\r\n * drawn label and a node label agree on the project's base typography.\r\n */\r\n readonly defaultTextStyle: TextStyle;\r\n\r\n /**\r\n * Replay a built `Graphics2D` against this context.\r\n *\r\n * Resolves the ambient text defaults onto the op list before handing it to\r\n * the backend, which is what keeps the real renderer and the precomp asset\r\n * walk agreeing on which font an under-specified `text` op shapes with: a\r\n * family that one resolves and the other does not is a font that never loads\r\n * and glyphs that never paint.\r\n */\r\n draw(graphics: Graphics2D): void;\r\n\r\n /**\r\n * Lay `state` out the way it would be drawn and report where every character\r\n * landed — see {@link TextBlockLayout} for the space and the caret model.\r\n *\r\n * This is what makes on-canvas text editing possible: glyph positions live\r\n * in the backend's shaper, so a host drawing its own caret and selection has\r\n * no way to compute them, and anything it approximates in the DOM disagrees\r\n * with the render as soon as the font, the line height or the wrapping does.\r\n *\r\n * Takes the whole {@link TextState} rather than a handful of font fields\r\n * because the resolution a caret has to agree with lives in the backend:\r\n * `'autofit'` picks a size from the box, `wrap` turns the width into a wrap\r\n * limit, and `textAlign` places the lines within it. Handing over the same\r\n * descriptor that gets drawn is what keeps the two from drifting apart.\r\n *\r\n * Returns `null` when the backend cannot measure this — the default, so a\r\n * backend that never needed glyph positions keeps working, and for cases no\r\n * caret model fits: text-on-path (glyphs follow a curve, not a line box) and\r\n * a block drawn in styled segments.\r\n */\r\n layoutTextBlock(state: Partial<TextState>): TextBlockLayout | null;\r\n\r\n /**\r\n * Push a transform (position, rotation, scale, opacity, …) and return the\r\n * context so subsequent draw calls are issued in the transformed space. The\r\n * transform is popped when `end()` is called for the node that pushed it.\r\n */\r\n transform(state: Partial<TransformState>): RenderContext2D;\r\n\r\n /**\r\n * Open a boolean-path collection scope. Shapes drawn until `endBoolean()`\r\n * are gathered (fills/strokes suppressed) and combined with `op`. After\r\n * `endBoolean()` the merged path is left as the active surface, so a\r\n * paint-only `Graphics2D` (`new Graphics2D().fill(...).stroke(...)`)\r\n * submitted via `draw()` styles the combined result.\r\n */\r\n beginBoolean(op: BooleanOperation): void;\r\n endBoolean(): void;\r\n\r\n // Mask scope (imperative) — used by MaskGroup and other node-level callers\r\n // that manage the scope with explicit begin/apply/end:\r\n //\r\n // beginMask({ mode, inverted })\r\n // <render mask child> // child draws its own Graphics2D\r\n // applyMask()\r\n // <render content children> // children draw their own Graphics2D\r\n // endMask()\r\n //\r\n // The chain-friendly form lives on `Graphics2D` (`.mask().applyMask().endMask()`)\r\n // for inline use within a single `draw()`.\r\n //\r\n // For `vector` mode the mask child's path is collected and used as a\r\n // clipPath; fills/strokes are suppressed. For `alpha` and `luminance`\r\n // the mask is rendered into an offscreen layer and combined with content\r\n // via blend modes.\r\n beginMask(options?: MaskOptions): void;\r\n applyMask(): void;\r\n endMask(): void;\r\n\r\n /**\r\n * Push a clip region built from a {@link Clip} command list. The clip's\r\n * shapes are unioned (with `cut()`s subtracted) into a single path and\r\n * intersected with the active clip, so children are confined to that\r\n * compound outline — any silhouette, not just a rect or ellipse. Used both\r\n * for a node's `clip` boundary and to confine backdrop effects (blur,\r\n * magnify) to the node's exact shape. Paired with `endClip()`.\r\n */\r\n beginClip(clip: Clip): void;\r\n /** Pop the most-recently pushed clip region. */\r\n endClip(): void;\r\n\r\n /**\r\n * Open an effect scope over the node, applying `effects` to either the node's\r\n * own content or the content beneath it. Paired with {@link endEffects}.\r\n *\r\n * `target`:\r\n * - `'foreground'` — warps/filters the node's *own* drawing (its fill, stroke\r\n * and children captured between begin/end), like blur. Used for bulge and\r\n * foreground posterize.\r\n * - `'backdrop'` — warps/filters the canvas content already painted *beneath*\r\n * the node, clipped to the active silhouette clip, so the node's own edges\r\n * stay sharp (Figma-style). Used for backdrop-flagged filters (blur,\r\n * grayscale, pixelate, …), magnify, backdrop posterize, and backdrop SkSL.\r\n *\r\n * The renderer decides per effect whether to compose it as an `ImageFilter`\r\n * or run it as a snapshot/redraw shader — callers never route by effect type.\r\n * `width`/`height` are the node's logical size, for size-relative effects\r\n * (e.g. pixelate) and shader lens boxes.\r\n */\r\n beginEffects(effects: NodeEffect[], target: EffectTarget, width: number, height: number): void;\r\n endEffects(): void;\r\n\r\n /**\r\n * Draw `draw` into an offscreen buffer instead of onto the canvas, and hand\r\n * back its pixels. The buffer is `width` × `height` **logical** px with its\r\n * origin at the centre, matching the space a node draws in — so `draw` can be\r\n * an ordinary `render()` call on a node subtree and needs no special casing.\r\n *\r\n * This is what backs `Tex.surface`: `Canvas3D` rasterizes each of its 2D\r\n * sources through here, then hands the pixels to the 3D backend as a texture.\r\n * It runs *inside* the frame that consumes it, so a scrubbed frame is\r\n * identical to a played one.\r\n *\r\n * Returns `null` when the backend cannot rasterize offscreen — the material\r\n * then renders without that map. `pixelRatio` is a ceiling on the buffer's\r\n * device-pixel scale, not a guarantee; the renderer may clamp it.\r\n */\r\n rasterize(\r\n width: number,\r\n height: number,\r\n draw: () => void,\r\n pixelRatio?: number,\r\n ): RasterizedSurface | null;\r\n\r\n /**\r\n * Push a camera viewport. Clips to `viewport` (canvas-space, centred\r\n * coords) and applies the inverse camera transform so children render as\r\n * seen through the lens. `heading` rotates the world counter to the camera\r\n * angle. Paired with `endCamera()`.\r\n *\r\n * @param viewport Bounding rect of the camera node in canvas space.\r\n * @param lookAt World-space point the camera looks at.\r\n * @param zoom Uniform scale applied around `lookAt`.\r\n * @param heading Camera rotation in degrees.\r\n */\r\n beginCamera(viewport: { x: number; y: number; width: number; height: number }, lookAt: Vector2, zoom: number, heading: number): void;\r\n endCamera(): void;\r\n\r\n /**\r\n * Whether this context ever reads `NodeRenderState.rects`.\r\n *\r\n * True for anything that actually paints, since a fill with `space:'parent'`\r\n * resolves against them. A context that only inspects *what* would be drawn\r\n * never looks at them, and computing them costs an object allocation per node\r\n * per frame. Nodes check this before doing that work; see `Node2D.renderState`.\r\n */\r\n readonly readsSpaceRects: boolean;\r\n\r\n /**\r\n * Whether this context only cares about *visible* output.\r\n *\r\n * True for anything that paints: a subtree at zero opacity contributes no\r\n * pixels, so walking it produces draw calls the rasterizer will discard.\r\n *\r\n * A context that inspects rather than paints sets this `false`, and that is\r\n * the whole reason this is a capability rather than an unconditional check:\r\n * such a walk exists to discover which images, videos, fonts and effects a\r\n * frame *references* — regardless of whether they can be seen. An invisible\r\n * node's font still has to load, because it may fade in two frames later and\r\n * glyphs that were never registered never paint. Skipping it there is not an\r\n * optimisation, it is a missing asset.\r\n *\r\n * Same shape and same reasoning as {@link readsSpaceRects}: the context\r\n * declares what it needs, and nodes check before doing work that would be\r\n * thrown away. See `Node2D.render`.\r\n */\r\n readonly drawsVisibleOnly: boolean;\r\n\r\n}\r\n\r\n/**\r\n * A render *pass*: a {@link RenderContext2D} plus the per-node scope bracket the\r\n * walk opens around each node.\r\n *\r\n * Split off from the drawing surface because the two have different callers.\r\n * `begin`/`end` are `Node2D.render`'s, once per node, and they push onto a stack\r\n * every fill with `space:'parent'` and every motion-driven effect reads back\r\n * from. A custom node's `renderSelf` calling one would open a scope nothing\r\n * closes — and since `renderSelf` is handed a {@link RenderContext2D}, it now\r\n * cannot.\r\n *\r\n * Every backend implements this; a host driving a render pass holds one.\r\n *\r\n * @internal\r\n */\r\nexport interface RenderPass2D extends RenderContext2D {\r\n /**\r\n * Open a node draw scope. Must be paired with `end()`, also when the scope\r\n * throws. Pushes the node's id and {@link NodeRenderState} (gradient-space\r\n * rects + per-frame motion) for the duration of the scope.\r\n */\r\n begin(state: NodeRenderState): void;\r\n\r\n /** Close the innermost node draw scope opened by `begin()`. */\r\n end(): void;\r\n}\r\n"]}
1
+ {"version":3,"file":"render-context2d.js","sourceRoot":"","sources":["../../src/render/render-context2d.ts"],"names":[],"mappings":"","sourcesContent":["import type { FontStyle, TextStyle } from \"@/attributes/text/types\";\r\nimport type { TransformState } from \"./descriptors/transform\";\r\nimport type { MeasureContext2D } from \"./measure-context\";\r\nimport type { TextState } from \"./descriptors/text\";\r\nimport type { TextBlockLayout } from \"./text-layout\";\r\nimport type { Graphics2D } from \"./graphics2d\";\r\nimport type { Clip } from \"./clip\";\r\nimport type { Vector2 } from \"@/attributes/layout/vector2\";\r\nimport type { MaskOptions } from \"@/attributes/mask/mask\";\r\nimport type { BooleanOperation } from \"@/attributes/mask/boolean\";\r\nimport type { NodeEffect } from \"@/attributes/shape/effects/union\";\r\nimport type { Size2D } from \"@/attributes/layout/size\";\r\n\r\n/**\r\n * Where an effect scope draws: `'foreground'` warps/filters the node's *own*\r\n * content (its fill, stroke and children), `'backdrop'` warps/filters the canvas\r\n * content already painted *beneath* the node (clipped to its silhouette). See\r\n * {@link RenderContext2D.beginEffects}.\r\n */\r\nexport type EffectTarget = \"foreground\" | \"backdrop\";\r\n\r\n/**\r\n * Pixels produced by {@link RenderContext2D.rasterize}: RGBA8888,\r\n * unpremultiplied, top-down (canvas row order). `width`/`height` are **device**\r\n * px, so they reflect the pixel ratio the renderer actually used rather than the\r\n * logical size that was asked for.\r\n */\r\nexport interface RasterizedSurface {\r\n pixels: Uint8Array;\r\n width: number;\r\n height: number;\r\n}\r\n\r\n/**\r\n * A bounding box in the current node's local space (origin = the node's\r\n * layout-cell centre, the same space shapes are drawn in). `left/top` use the\r\n * canvas convention (y down).\r\n */\r\nexport interface SpaceRect {\r\n left: number;\r\n top: number;\r\n right: number;\r\n bottom: number;\r\n}\r\n\r\n/**\r\n * Reference rects a fill can resolve against, supplied per-node at `begin()`.\r\n * `local` is derived from the drawn shapes themselves and `global` (the\r\n * viewport) is computed by the renderer from the surface size, so only the\r\n * parent frame is passed here.\r\n */\r\nexport interface SpaceRects {\r\n /** The parent node's content rect, in this node's local space. */\r\n parent?: SpaceRect;\r\n}\r\n\r\n/**\r\n * Per-node state supplied to {@link RenderContext2D.begin} for the duration of a\r\n * node's draw scope. Carries the node identity and gradient-space `rects` plus\r\n * the node's per-frame motion, sampled at render time. Motion-driven effects\r\n * (e.g. motion blur) read the current node's `velocity` from this state instead\r\n * of being authored with a fixed direction.\r\n *\r\n * Velocity fields are `0`/`{0,0}` when the motion is unknown — the first frame a\r\n * node renders, or after a time discontinuity (scrub/seek) where no trustworthy\r\n * delta exists.\r\n */\r\nexport interface NodeRenderState {\r\n /** Stable node identifier. */\r\n id: string;\r\n /** Parent / viewport rects in this node's local space. */\r\n rects: SpaceRects;\r\n /** How long this node has existed, in seconds (`NodeTime.elapsed`). */\r\n elapsed: number;\r\n /** The frame delta, in seconds, used to derive displacement from velocity. */\r\n dt: number;\r\n /** Translational velocity in px/sec, world space (y-down). `{0,0}` when unknown. */\r\n velocity: Vector2;\r\n /** Heading of `velocity` in degrees (`atan2(vy, vx)`). `0` when unknown. */\r\n direction: number;\r\n /** Magnitude of `velocity` in px/sec. `0` when unknown. */\r\n speed: number;\r\n /** Rotational velocity in degrees/sec. `0` when unknown. Reserved for radial motion blur. */\r\n angularVelocity: number;\r\n /** Scale velocity in scale-units/sec. `0` when unknown. Reserved for zoom motion blur. */\r\n scaleVelocity: number;\r\n}\r\n\r\n/**\r\n * The drawing surface a `Node2D` paints into — **the whole of what a node may\r\n * ask of a renderer, and nothing else.**\r\n *\r\n * Shapes are never declared directly on the context: they are built with a\r\n * {@link Graphics2D} command list and submitted via {@link draw}. Multiple\r\n * shapes chained on one `Graphics2D` before a paint call are combined into a\r\n * single surface and painted together:\r\n *\r\n * ctx.draw(new Graphics2D().ellipse(...).rect(...).fill(...)); // shared surface\r\n *\r\n * On top of that it carries text measurement — it extends {@link MeasureContext2D}, so\r\n * a node measures and draws through one object — and the higher-level scoping\r\n * operations: transforms, masks, clips, camera, boolean ops, effect scopes.\r\n * `begin(state)` / `end()` bracket each node's draw call so the context can\r\n * track which node is active.\r\n *\r\n * **An interface, with `CanvasRenderContext2D` as its one base class.** What a\r\n * node calls and what a *host* calls are different lists: `execute`,\r\n * `screenshot`, `unmount` and `dispose` drive a render pass and have no business\r\n * being reachable from inside one. Splitting them is what keeps this surface\r\n * the size it is. Every real backend still extends the class, which preserves\r\n * the `draw` to `drawGraphics` invariant that gives them all one implementation\r\n * of text-default resolution.\r\n *\r\n * `RenderContext3D` is its sibling, not its subclass: the two share no members,\r\n * because a 3D scene is described with lights, a camera and meshes rather than\r\n * with paths and paint.\r\n */\r\nexport interface RenderContext2D extends MeasureContext2D {\r\n measureText(\r\n text: string,\r\n fontSize: number,\r\n fontFamily: string,\r\n fontWeight?: number,\r\n letterSpacing?: number,\r\n fontStyle?: FontStyle,\r\n ): Size2D;\r\n\r\n // ---- Inherited text-style defaults ------------------------------------\r\n // `<DefaultTextStyle>` reaches a `Text`/`RichText` node through the context\r\n // map, applied once when the node binds. A raw `Graphics2D` has no node to\r\n // bind, so it inherits the same defaults here instead — pushed around a\r\n // subtree's draw scope, and folded into each `text`/`richText` op by\r\n // `draw()`. Same vocabulary (`TextStyle`), same precedence, two channels.\r\n\r\n /**\r\n * Set text-style defaults for everything drawn until the matching\r\n * {@link popTextStyle} — the drawn-graphics half of `<DefaultTextStyle>`.\r\n *\r\n * `style` is **merged** onto the defaults already in effect, per key, so\r\n * nesting accumulates the way the node channel does: an outer scope's\r\n * `fontFamily` and an inner scope's `fontSize` both apply, and a key set by\r\n * both takes the inner value. Values are resolved (a tweened `fontSize`\r\n * arrives as this frame's number), not callbacks.\r\n *\r\n * Pass `null` to open a scope that inherits **nothing** — not the enclosing\r\n * defaults and not the project's `theme.typography.default`. That is for a\r\n * node whose text is its own vocabulary rather than the document's: `Code`\r\n * does it so a scene-wide serif face doesn't reflow a monospaced code block.\r\n *\r\n * Always pair with `popTextStyle()` in a `finally`; the stack is shared with\r\n * every sibling drawn afterwards.\r\n */\r\n pushTextStyle(style: TextStyle | null): void;\r\n\r\n /** Close the innermost scope opened by {@link pushTextStyle}. */\r\n popTextStyle(): void;\r\n\r\n /**\r\n * The text-style defaults in effect right now: the innermost\r\n * {@link pushTextStyle} scope, or the project's `theme.typography.default`\r\n * when no scope is open — the same preset a `Text` node falls back to, so a\r\n * drawn label and a node label agree on the project's base typography.\r\n */\r\n readonly defaultTextStyle: TextStyle;\r\n\r\n /**\r\n * Replay a built `Graphics2D` against this context.\r\n *\r\n * Resolves the ambient text defaults onto the op list before handing it to\r\n * the backend, which is what keeps the real renderer and the precomp asset\r\n * walk agreeing on which font an under-specified `text` op shapes with: a\r\n * family that one resolves and the other does not is a font that never loads\r\n * and glyphs that never paint.\r\n */\r\n draw(graphics: Graphics2D): void;\r\n\r\n /**\r\n * Lay `state` out the way it would be drawn and report where every character\r\n * landed — see {@link TextBlockLayout} for the space and the caret model.\r\n *\r\n * This is what makes on-canvas text editing possible: glyph positions live\r\n * in the backend's shaper, so a host drawing its own caret and selection has\r\n * no way to compute them, and anything it approximates in the DOM disagrees\r\n * with the render as soon as the font, the line height or the wrapping does.\r\n *\r\n * Takes the whole {@link TextState} rather than a handful of font fields\r\n * because the resolution a caret has to agree with lives in the backend:\r\n * `'autofit'` picks a size from the box, `wrap` turns the width into a wrap\r\n * limit, and `textAlign` places the lines within it. Handing over the same\r\n * descriptor that gets drawn is what keeps the two from drifting apart.\r\n *\r\n * Returns `null` when the backend cannot measure this — the default, so a\r\n * backend that never needed glyph positions keeps working, and for cases no\r\n * caret model fits: text-on-path (glyphs follow a curve, not a line box) and\r\n * a block drawn in styled segments.\r\n */\r\n layoutTextBlock(state: Partial<TextState>): TextBlockLayout | null;\r\n\r\n /**\r\n * Push a transform (position, rotation, scale, opacity, …) and return the\r\n * context so subsequent draw calls are issued in the transformed space. The\r\n * transform is popped when `end()` is called for the node that pushed it.\r\n */\r\n transform(state: Partial<TransformState>): RenderContext2D;\r\n\r\n /**\r\n * Open a boolean-path collection scope. Shapes drawn until `endBoolean()`\r\n * are gathered (fills/strokes suppressed) and combined with `op`. After\r\n * `endBoolean()` the merged path is left as the active surface, so a\r\n * paint-only `Graphics2D` (`new Graphics2D().fill(...).stroke(...)`)\r\n * submitted via `draw()` styles the combined result.\r\n */\r\n beginBoolean(op: BooleanOperation): void;\r\n endBoolean(): void;\r\n\r\n // Mask scope (imperative) — used by MaskGroup and other node-level callers\r\n // that manage the scope with explicit begin/apply/end:\r\n //\r\n // beginMask({ mode, inverted })\r\n // <render mask child> // child draws its own Graphics2D\r\n // applyMask()\r\n // <render content children> // children draw their own Graphics2D\r\n // endMask()\r\n //\r\n // The chain-friendly form lives on `Graphics2D` (`.mask().applyMask().endMask()`)\r\n // for inline use within a single `draw()`.\r\n //\r\n // For `vector` mode the mask child's path is collected and used as a\r\n // clipPath; fills/strokes are suppressed. For `alpha` and `luminance`\r\n // the mask is rendered into an offscreen layer and combined with content\r\n // via blend modes.\r\n beginMask(options?: MaskOptions): void;\r\n applyMask(): void;\r\n endMask(): void;\r\n\r\n /**\r\n * Push a clip region built from a {@link Clip} command list. The clip's\r\n * shapes are unioned (with `cut()`s subtracted) into a single path and\r\n * intersected with the active clip, so children are confined to that\r\n * compound outline — any silhouette, not just a rect or ellipse. Used both\r\n * for a node's `clip` boundary and to confine backdrop effects (blur,\r\n * magnify) to the node's exact shape. Paired with `endClip()`.\r\n */\r\n beginClip(clip: Clip): void;\r\n /** Pop the most-recently pushed clip region. */\r\n endClip(): void;\r\n\r\n /**\r\n * Open an effect scope over the node, applying `effects` to either the node's\r\n * own content or the content beneath it. Paired with {@link endEffects}.\r\n *\r\n * `target`:\r\n * - `'foreground'` — warps/filters the node's *own* drawing (its fill, stroke\r\n * and children captured between begin/end), like blur. Used for bulge and\r\n * foreground posterize.\r\n * - `'backdrop'` — warps/filters the canvas content already painted *beneath*\r\n * the node, clipped to the active silhouette clip, so the node's own edges\r\n * stay sharp (Figma-style). Used for backdrop-flagged filters (blur,\r\n * grayscale, pixelate, …), magnify, backdrop posterize, and backdrop shader.\r\n *\r\n * The renderer decides per effect whether to compose it as an `ImageFilter`\r\n * or run it as a snapshot/redraw shader — callers never route by effect type.\r\n * `width`/`height` are the node's logical size, for size-relative effects\r\n * (e.g. pixelate) and shader lens boxes.\r\n */\r\n beginEffects(effects: NodeEffect[], target: EffectTarget, width: number, height: number): void;\r\n endEffects(): void;\r\n\r\n /**\r\n * Draw `draw` into an offscreen buffer instead of onto the canvas, and hand\r\n * back its pixels. The buffer is `width` × `height` **logical** px with its\r\n * origin at the centre, matching the space a node draws in — so `draw` can be\r\n * an ordinary `render()` call on a node subtree and needs no special casing.\r\n *\r\n * This is what backs `Tex.surface`: `Canvas3D` rasterizes each of its 2D\r\n * sources through here, then hands the pixels to the 3D backend as a texture.\r\n * It runs *inside* the frame that consumes it, so a scrubbed frame is\r\n * identical to a played one.\r\n *\r\n * Returns `null` when the backend cannot rasterize offscreen — the material\r\n * then renders without that map. `pixelRatio` is a ceiling on the buffer's\r\n * device-pixel scale, not a guarantee; the renderer may clamp it.\r\n */\r\n rasterize(\r\n width: number,\r\n height: number,\r\n draw: () => void,\r\n pixelRatio?: number,\r\n ): RasterizedSurface | null;\r\n\r\n /**\r\n * Push a camera viewport. Clips to `viewport` (canvas-space, centred\r\n * coords) and applies the inverse camera transform so children render as\r\n * seen through the lens. `heading` rotates the world counter to the camera\r\n * angle. Paired with `endCamera()`.\r\n *\r\n * @param viewport Bounding rect of the camera node in canvas space.\r\n * @param lookAt World-space point the camera looks at.\r\n * @param zoom Uniform scale applied around `lookAt`.\r\n * @param heading Camera rotation in degrees.\r\n */\r\n beginCamera(viewport: { x: number; y: number; width: number; height: number }, lookAt: Vector2, zoom: number, heading: number): void;\r\n endCamera(): void;\r\n\r\n /**\r\n * Whether this context ever reads `NodeRenderState.rects`.\r\n *\r\n * True for anything that actually paints, since a fill with `space:'parent'`\r\n * resolves against them. A context that only inspects *what* would be drawn\r\n * never looks at them, and computing them costs an object allocation per node\r\n * per frame. Nodes check this before doing that work; see `Node2D.renderState`.\r\n */\r\n readonly readsSpaceRects: boolean;\r\n\r\n /**\r\n * Whether this context only cares about *visible* output.\r\n *\r\n * True for anything that paints: a subtree at zero opacity contributes no\r\n * pixels, so walking it produces draw calls the rasterizer will discard.\r\n *\r\n * A context that inspects rather than paints sets this `false`, and that is\r\n * the whole reason this is a capability rather than an unconditional check:\r\n * such a walk exists to discover which images, videos, fonts and effects a\r\n * frame *references* — regardless of whether they can be seen. An invisible\r\n * node's font still has to load, because it may fade in two frames later and\r\n * glyphs that were never registered never paint. Skipping it there is not an\r\n * optimisation, it is a missing asset.\r\n *\r\n * Same shape and same reasoning as {@link readsSpaceRects}: the context\r\n * declares what it needs, and nodes check before doing work that would be\r\n * thrown away. See `Node2D.render`.\r\n */\r\n readonly drawsVisibleOnly: boolean;\r\n\r\n}\r\n\r\n/**\r\n * A render *pass*: a {@link RenderContext2D} plus the per-node scope bracket the\r\n * walk opens around each node.\r\n *\r\n * Split off from the drawing surface because the two have different callers.\r\n * `begin`/`end` are `Node2D.render`'s, once per node, and they push onto a stack\r\n * every fill with `space:'parent'` and every motion-driven effect reads back\r\n * from. A custom node's `renderSelf` calling one would open a scope nothing\r\n * closes — and since `renderSelf` is handed a {@link RenderContext2D}, it now\r\n * cannot.\r\n *\r\n * Every backend implements this; a host driving a render pass holds one.\r\n *\r\n * @internal\r\n */\r\nexport interface RenderPass2D extends RenderContext2D {\r\n /**\r\n * Open a node draw scope. Must be paired with `end()`, also when the scope\r\n * throws. Pushes the node's id and {@link NodeRenderState} (gradient-space\r\n * rects + per-frame motion) for the duration of the scope.\r\n */\r\n begin(state: NodeRenderState): void;\r\n\r\n /** Close the innermost node draw scope opened by `begin()`. */\r\n end(): void;\r\n}\r\n"]}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * What a render issue is about:
3
+ *
4
+ * - `missing`: a feature the backend does not draw (`feature` names it).
5
+ * - `shader`: a user shader that does not compile, or one that is not WGSL (an SkSL shader from an old document).
6
+ * - `params`: a shader's uniforms and its `struct Params` disagree (a value with no member, a member with no value).
7
+ * - `gpu`: a WebGPU validation or out-of-memory error.
8
+ * - `device-lost`: the GPU device was lost; the backend is drawing on a new one.
9
+ * - `crashed`: the backend itself failed and draws nothing more on this page.
10
+ */
11
+ export type RenderIssueKind = "missing" | "shader" | "params" | "gpu" | "device-lost" | "crashed";
12
+ /** Something a frame drew without throwing but not as the document says. */
13
+ export interface RenderIssue {
14
+ kind: RenderIssueKind;
15
+ message: string;
16
+ /** What is affected, as the backend names it (`blend:color-dodge`, `text:path`, `fill:shader`). */
17
+ feature?: string;
18
+ /** The node it was found on, when the backend knows. */
19
+ nodeId?: string;
20
+ }
21
+ /** A backend's issue as a typed one; a bare string is the shader message backends reported before issues were typed. */
22
+ export declare function toRenderIssue(issue: RenderIssue | string): RenderIssue;
23
+ /** One key per kind, feature and node: what an issue list is deduplicated by. */
24
+ export declare function renderIssueKey(issue: RenderIssue): string;
25
+ /**
26
+ * The backend lost what it draws with while a render was under way, so the
27
+ * frames already drawn cannot be trusted. Thrown by exports and stills on a
28
+ * `device-lost` or `crashed` issue; `retryable` says whether the same render
29
+ * can simply run again (the backend recovered on a new device).
30
+ */
31
+ export declare class RenderBackendError extends Error {
32
+ readonly issue: RenderIssue;
33
+ readonly name = "RenderBackendError";
34
+ readonly retryable: boolean;
35
+ constructor(issue: RenderIssue);
36
+ }
37
+ /** Whether an issue means the frames drawn around it are not to be trusted. */
38
+ export declare function isFatalRenderIssue(issue: RenderIssue): boolean;
39
+ //# sourceMappingURL=render-issue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-issue.d.ts","sourceRoot":"","sources":["../../src/render/render-issue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,aAAa,GAAG,SAAS,CAAC;AAElG,4EAA4E;AAC5E,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,mGAAmG;IACnG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wHAAwH;AACxH,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,WAAW,CAEtE;AAED,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAEzD;AAED;;;;;GAKG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAI7B,QAAQ,CAAC,KAAK,EAAE,WAAW;IAHvC,SAAkB,IAAI,wBAAwB;IAC9C,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;gBAEP,KAAK,EAAE,WAAW;CAI1C;AAED,+EAA+E;AAC/E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAE9D"}
@@ -0,0 +1,29 @@
1
+ /** A backend's issue as a typed one; a bare string is the shader message backends reported before issues were typed. */
2
+ export function toRenderIssue(issue) {
3
+ return typeof issue === "string" ? { kind: "shader", message: issue } : issue;
4
+ }
5
+ /** One key per kind, feature and node: what an issue list is deduplicated by. */
6
+ export function renderIssueKey(issue) {
7
+ return `${issue.kind}|${issue.feature ?? ""}|${issue.nodeId ?? ""}|${issue.feature ? "" : issue.message}`;
8
+ }
9
+ /**
10
+ * The backend lost what it draws with while a render was under way, so the
11
+ * frames already drawn cannot be trusted. Thrown by exports and stills on a
12
+ * `device-lost` or `crashed` issue; `retryable` says whether the same render
13
+ * can simply run again (the backend recovered on a new device).
14
+ */
15
+ export class RenderBackendError extends Error {
16
+ issue;
17
+ name = "RenderBackendError";
18
+ retryable;
19
+ constructor(issue) {
20
+ super(issue.message);
21
+ this.issue = issue;
22
+ this.retryable = issue.kind === "device-lost";
23
+ }
24
+ }
25
+ /** Whether an issue means the frames drawn around it are not to be trusted. */
26
+ export function isFatalRenderIssue(issue) {
27
+ return issue.kind === "device-lost" || issue.kind === "crashed";
28
+ }
29
+ //# sourceMappingURL=render-issue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-issue.js","sourceRoot":"","sources":["../../src/render/render-issue.ts"],"names":[],"mappings":"AAsBA,wHAAwH;AACxH,MAAM,UAAU,aAAa,CAAC,KAA2B;IACrD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AAClF,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,cAAc,CAAC,KAAkB;IAC7C,OAAO,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,IAAI,EAAE,IAAI,KAAK,CAAC,MAAM,IAAI,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;AAC9G,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAIpB;IAHH,IAAI,GAAG,oBAAoB,CAAC;IACrC,SAAS,CAAU;IAE5B,YAAqB,KAAkB;QACnC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QADJ,UAAK,GAAL,KAAK,CAAa;QAEnC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,IAAI,KAAK,aAAa,CAAC;IAClD,CAAC;CACJ;AAED,+EAA+E;AAC/E,MAAM,UAAU,kBAAkB,CAAC,KAAkB;IACjD,OAAO,KAAK,CAAC,IAAI,KAAK,aAAa,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC;AACpE,CAAC","sourcesContent":["/**\r\n * What a render issue is about:\r\n *\r\n * - `missing`: a feature the backend does not draw (`feature` names it).\r\n * - `shader`: a user shader that does not compile, or one that is not WGSL (an SkSL shader from an old document).\r\n * - `params`: a shader's uniforms and its `struct Params` disagree (a value with no member, a member with no value).\r\n * - `gpu`: a WebGPU validation or out-of-memory error.\r\n * - `device-lost`: the GPU device was lost; the backend is drawing on a new one.\r\n * - `crashed`: the backend itself failed and draws nothing more on this page.\r\n */\r\nexport type RenderIssueKind = \"missing\" | \"shader\" | \"params\" | \"gpu\" | \"device-lost\" | \"crashed\";\r\n\r\n/** Something a frame drew without throwing but not as the document says. */\r\nexport interface RenderIssue {\r\n kind: RenderIssueKind;\r\n message: string;\r\n /** What is affected, as the backend names it (`blend:color-dodge`, `text:path`, `fill:shader`). */\r\n feature?: string;\r\n /** The node it was found on, when the backend knows. */\r\n nodeId?: string;\r\n}\r\n\r\n/** A backend's issue as a typed one; a bare string is the shader message backends reported before issues were typed. */\r\nexport function toRenderIssue(issue: RenderIssue | string): RenderIssue {\r\n return typeof issue === \"string\" ? { kind: \"shader\", message: issue } : issue;\r\n}\r\n\r\n/** One key per kind, feature and node: what an issue list is deduplicated by. */\r\nexport function renderIssueKey(issue: RenderIssue): string {\r\n return `${issue.kind}|${issue.feature ?? \"\"}|${issue.nodeId ?? \"\"}|${issue.feature ? \"\" : issue.message}`;\r\n}\r\n\r\n/**\r\n * The backend lost what it draws with while a render was under way, so the\r\n * frames already drawn cannot be trusted. Thrown by exports and stills on a\r\n * `device-lost` or `crashed` issue; `retryable` says whether the same render\r\n * can simply run again (the backend recovered on a new device).\r\n */\r\nexport class RenderBackendError extends Error {\r\n override readonly name = \"RenderBackendError\";\r\n readonly retryable: boolean;\r\n\r\n constructor(readonly issue: RenderIssue) {\r\n super(issue.message);\r\n this.retryable = issue.kind === \"device-lost\";\r\n }\r\n}\r\n\r\n/** Whether an issue means the frames drawn around it are not to be trusted. */\r\nexport function isFatalRenderIssue(issue: RenderIssue): boolean {\r\n return issue.kind === \"device-lost\" || issue.kind === \"crashed\";\r\n}\r\n"]}
@@ -11,8 +11,8 @@ import { Size2D } from "../attributes/layout/size.js";
11
11
  * with `lib: ["ES2022"]` and no DOM, deliberately, so this layer cannot name a
12
12
  * canvas — and it does not need to: a browser backend takes a canvas, a headless
13
13
  * one takes a size. Each narrows the argument at its own `mount`, where the
14
- * relevant types exist. `SkiaRenderContext` satisfies this structurally, so
15
- * neither `skia-render` nor `web` imports it.
14
+ * relevant types exist. A backend's context satisfies this structurally, so it
15
+ * never imports it.
16
16
  */
17
17
  export interface RenderSurface {
18
18
  mount(target: unknown): void;
@@ -1 +1 @@
1
- {"version":3,"file":"surface.js","sourceRoot":"","sources":["../../src/render/surface.ts"],"names":[],"mappings":"","sourcesContent":["import { Size2D } from \"@/attributes/layout/size\";\r\n\r\n/**\r\n * The host-facing half of a render context: where pixels land, and how the\r\n * preview frames them.\r\n *\r\n * Split out from `CanvasRenderContext2D` because a *node* never touches any of\r\n * it — a node draws, and the host decides what it is drawing into. A `Session`\r\n * owns one of these; a node is handed a `RenderContext2D`.\r\n *\r\n * **`mount` takes `unknown`, not `HTMLCanvasElement`.** `packages/core` compiles\r\n * with `lib: [\"ES2022\"]` and no DOM, deliberately, so this layer cannot name a\r\n * canvas — and it does not need to: a browser backend takes a canvas, a headless\r\n * one takes a size. Each narrows the argument at its own `mount`, where the\r\n * relevant types exist. `SkiaRenderContext` satisfies this structurally, so\r\n * neither `skia-render` nor `web` imports it.\r\n */\r\nexport interface RenderSurface {\r\n mount(target: unknown): void;\r\n unmount(): void;\r\n /** Device pixels per viewport unit. Rasterization, not zoom — see {@link view}. */\r\n pixelRatio: number;\r\n /** Preview pan/zoom over the frame. Costs a repaint, never a surface rebuild. */\r\n view: { zoom: number; x: number; y: number };\r\n /** The frame's own size when the surface is a window onto it, else `null`. */\r\n frame: Size2D | null;\r\n clipToFrame: boolean;\r\n /**\r\n * What the frame's backdrop is painted with. `\"transparent\"` lets whatever\r\n * is behind the canvas show through where nothing was drawn.\r\n */\r\n frameBackground: \"black\" | \"transparent\";\r\n}\r\n"]}
1
+ {"version":3,"file":"surface.js","sourceRoot":"","sources":["../../src/render/surface.ts"],"names":[],"mappings":"","sourcesContent":["import { Size2D } from \"@/attributes/layout/size\";\r\n\r\n/**\r\n * The host-facing half of a render context: where pixels land, and how the\r\n * preview frames them.\r\n *\r\n * Split out from `CanvasRenderContext2D` because a *node* never touches any of\r\n * it — a node draws, and the host decides what it is drawing into. A `Session`\r\n * owns one of these; a node is handed a `RenderContext2D`.\r\n *\r\n * **`mount` takes `unknown`, not `HTMLCanvasElement`.** `packages/core` compiles\r\n * with `lib: [\"ES2022\"]` and no DOM, deliberately, so this layer cannot name a\r\n * canvas — and it does not need to: a browser backend takes a canvas, a headless\r\n * one takes a size. Each narrows the argument at its own `mount`, where the\r\n * relevant types exist. A backend's context satisfies this structurally, so it\r\n * never imports it.\r\n */\r\nexport interface RenderSurface {\r\n mount(target: unknown): void;\r\n unmount(): void;\r\n /** Device pixels per viewport unit. Rasterization, not zoom — see {@link view}. */\r\n pixelRatio: number;\r\n /** Preview pan/zoom over the frame. Costs a repaint, never a surface rebuild. */\r\n view: { zoom: number; x: number; y: number };\r\n /** The frame's own size when the surface is a window onto it, else `null`. */\r\n frame: Size2D | null;\r\n clipToFrame: boolean;\r\n /**\r\n * What the frame's backdrop is painted with. `\"transparent\"` lets whatever\r\n * is behind the canvas show through where nothing was drawn.\r\n */\r\n frameBackground: \"black\" | \"transparent\";\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"graphics3d.d.ts","sourceRoot":"","sources":["../../src/render3d/graphics3d.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAClE,OAAO,KAAK,EACR,aAAa,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,EAClE,kBAAkB,EAAE,iBAAiB,EAAE,UAAU,EAAE,eAAe,EAClE,eAAe,EAAE,oBAAoB,EAAE,cAAc,EAAE,gBAAgB,EACvE,eAAe,EAAE,mBAAmB,EAAE,cAAc,EACvD,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAEtD,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO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;IAC5C,IAAI,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrC"}
@@ -265,7 +265,7 @@ export class Graphics3D {
265
265
  };
266
266
  this.record({
267
267
  kind: "line",
268
- geometry: geometry ?? { type: "buffer", position: flattenPoints(points) },
268
+ geometry: geometry ?? lineBuffer(points),
269
269
  material: resolved,
270
270
  mode: segments ? "segments" : closed ? "loop" : "strip",
271
271
  transform: pickTransform(options),
@@ -320,21 +320,70 @@ export class Graphics3D {
320
320
  return this._ops.length === 0;
321
321
  }
322
322
  }
323
+ /** The buffer each points array was last flattened into, and the revision it was uploaded under. */
324
+ const lineBuffers = new WeakMap();
325
+ let lineRevision = 0;
326
+ /**
327
+ * `points` as a line's buffer. The same array holding the same values gets the
328
+ * same buffer and revision back, so a renderer uploads an unchanged line once,
329
+ * not every frame; the values are checked, so one changed in place still lands.
330
+ */
331
+ function lineBuffer(points) {
332
+ let kept = lineBuffers.get(points);
333
+ if (!kept || !holds(kept.position, points)) {
334
+ kept = { position: flattenPoints(points), revision: ++lineRevision };
335
+ lineBuffers.set(points, kept);
336
+ }
337
+ return { type: "buffer", position: kept.position, revision: kept.revision };
338
+ }
323
339
  /** Flatten `Vector3Input`s into the packed `[x, y, z, …]` a buffer wants. */
324
340
  function flattenPoints(points) {
325
- const out = [];
341
+ const out = new Float32Array(points.length * 3);
342
+ let i = 0;
326
343
  for (const point of points) {
327
344
  if (typeof point === "number") {
328
- out.push(point, point, point);
345
+ out[i] = out[i + 1] = out[i + 2] = point;
329
346
  }
330
347
  else if (Array.isArray(point)) {
331
- out.push(point[0] ?? 0, point[1] ?? 0, point[2] ?? 0);
348
+ out[i] = point[0] ?? 0;
349
+ out[i + 1] = point[1] ?? 0;
350
+ out[i + 2] = point[2] ?? 0;
332
351
  }
333
352
  else {
334
353
  const v = point;
335
- out.push(v.x ?? 0, v.y ?? 0, v.z ?? 0);
354
+ out[i] = v.x ?? 0;
355
+ out[i + 1] = v.y ?? 0;
356
+ out[i + 2] = v.z ?? 0;
336
357
  }
358
+ i += 3;
337
359
  }
338
360
  return out;
339
361
  }
362
+ /** Whether `buffer` is what flattening `points` would give. */
363
+ function holds(buffer, points) {
364
+ if (buffer.length !== points.length * 3)
365
+ return false;
366
+ let i = 0;
367
+ for (const point of points) {
368
+ let x, y, z;
369
+ if (typeof point === "number") {
370
+ x = y = z = point;
371
+ }
372
+ else if (Array.isArray(point)) {
373
+ x = point[0] ?? 0;
374
+ y = point[1] ?? 0;
375
+ z = point[2] ?? 0;
376
+ }
377
+ else {
378
+ const v = point;
379
+ x = v.x ?? 0;
380
+ y = v.y ?? 0;
381
+ z = v.z ?? 0;
382
+ }
383
+ if (buffer[i] !== Math.fround(x) || buffer[i + 1] !== Math.fround(y) || buffer[i + 2] !== Math.fround(z))
384
+ return false;
385
+ i += 3;
386
+ }
387
+ return true;
388
+ }
340
389
  //# sourceMappingURL=graphics3d.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"graphics3d.js","sourceRoot":"","sources":["../../src/render3d/graphics3d.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAe,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAoE5C;;;;;GAKG;AACH,gBAAgB;AAChB,MAAM,CAAC,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC;IACvD,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO;CACpE,CAAC,CAAC;AAkDH,MAAM,cAAc,GAAG;IACnB,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ;IACvD,SAAS,EAAE,QAAQ,EAAE,aAAa;CAC5B,CAAC;AAEX;;;;;GAKG;AACH,MAAM,uBAAuB,GAAG;IAC5B,SAAS,EAAE,WAAW,EAAE,WAAW;IACnC,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,cAAc;IAC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AC;IAChB,CAAC;IAED,4EAA4E;IAE5E,4DAA4D;IAC5D,GAAG;QACC,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,yCAAyC;IACzC,OAAO;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC;IAClC,CAAC;CACJ;AAkBD,6EAA6E;AAC7E,SAAS,aAAa,CAAC,MAA+B;IAClD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5B,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAClC,CAAC;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1D,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,GAAG,KAA4C,CAAC;YACvD,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3C,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["import type { Color } from \"@/attributes/shape/fill/color/parser\";\r\nimport type {\r\n BoxGeometry3D, CapsuleGeometry3D, CircleGeometry3D, ConeGeometry3D,\r\n CylinderGeometry3D, ExtrudeGeometry3D, Geometry3D, LatheGeometry3D,\r\n PlaneGeometry3D, PolyhedronGeometry3D, RingGeometry3D, SphereGeometry3D,\r\n TorusGeometry3D, TorusKnotGeometry3D, TubeGeometry3D,\r\n} from \"./geometry\";\r\nimport type { Material3D, Shading3D } from \"./material\";\r\nimport type { Texture3D } from \"./texture\";\r\nimport { resolveFill3D, type Fill3D } from \"./fill3d\";\r\nimport { inspectDrawable3D } from \"./inert\";\r\nimport { type Transform3D, type Blend3D, type Faces3D } from \"./transform\";\r\nimport type { Vector3Input } from \"./vector3\";\r\n\r\n// ─── Ops ─────────────────────────────────────────────────────────────────────\r\n\r\n/** One clip of a model's baked animation, sampled at an explicit time. */\r\nexport interface ModelAnimation3D {\r\n /** Clip name, or its index in the file. Defaults to the first clip. */\r\n clip?: string | number;\r\n /**\r\n * Seconds into the clip. **Explicit by design** — the renderer seeks to this\r\n * time rather than advancing by a delta, which is what keeps a model's\r\n * animation identical whether the frame was reached by playing forward or by\r\n * scrubbing backwards.\r\n */\r\n time: number;\r\n /** Blend weight, for cross-fading clips. Default 1. */\r\n weight?: number;\r\n}\r\n\r\n/**\r\n * How a `line` op connects its points: in order, or as disjoint start/end pairs,\r\n * or in order and closed back to the start.\r\n */\r\nexport type LineMode3D = \"strip\" | \"segments\" | \"loop\";\r\n\r\n/**\r\n * One recorded operation in a {@link Graphics3D} command list.\r\n *\r\n * Every op draws something. Hierarchy, lights and the camera are *scene*\r\n * concerns, recorded by the `Node3D` tree into a `Scene3D` — this is only ever\r\n * \"what one node paints\", which is exactly what a `Graphics2D` is in 2D.\r\n *\r\n * A drawable's geometry and material are *inline sub-descriptors*, not ops,\r\n * because in a 3D scene graph they are properties of an object rather than\r\n * children of it.\r\n */\r\nexport type Graphics3DOp =\r\n | { kind: \"mesh\"; geometry: Geometry3D; material: Material3D | readonly Material3D[]; transform?: Transform3D }\r\n | {\r\n kind: \"instances\";\r\n geometry: Geometry3D;\r\n material: Material3D;\r\n /** Per-instance placement. Length drives the instance count. */\r\n instances: readonly Transform3D[];\r\n /** Per-instance tint. Needs a material that reads instance colour. */\r\n colors?: readonly Color[];\r\n transform?: Transform3D;\r\n }\r\n | { kind: \"points\"; geometry: Geometry3D; material: Material3D; transform?: Transform3D }\r\n | {\r\n kind: \"line\";\r\n geometry: Geometry3D;\r\n material: Material3D;\r\n mode: LineMode3D;\r\n transform?: Transform3D;\r\n }\r\n | { kind: \"sprite\"; material: Material3D; transform?: Transform3D }\r\n | {\r\n kind: \"model\";\r\n src: string;\r\n animation?: readonly ModelAnimation3D[];\r\n /** Replace materials on the loaded graph, keyed by mesh or material name. */\r\n override?: Readonly<Record<string, Material3D>>;\r\n transform?: Transform3D;\r\n };\r\n\r\n/**\r\n * Op kinds that put something in the scene (as opposed to shaping the tree).\r\n *\r\n * Shared with `Scene3D`, whose op list is this one plus `push`/`pop`/`light`/\r\n * `camera` — so \"is anything actually drawn here\" has a single definition.\r\n */\r\n/** @internal */\r\nexport const DRAWABLE_KINDS: ReadonlySet<string> = new Set([\r\n \"mesh\", \"light\", \"instances\", \"points\", \"line\", \"sprite\", \"model\",\r\n]);\r\n\r\n// ─── Shorthand ───────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Material fields promoted onto the geometry sugar methods, so the common case is\r\n * one flat call: `.box({ width: 2, fill: \"red\", roughness: 0.3 })`.\r\n *\r\n * `fill` is the whole 2D fill vocabulary — see {@link Fill3D} — and is what a\r\n * flat `color` plus a `map` slot used to be. The rest is surface *response*\r\n * (how light behaves on it) rather than colour, which is the line Spline's\r\n * material panel draws too and the reason those stay separate fields.\r\n *\r\n * These desugar at record time into a full {@link Material3D} — `standard` by\r\n * default, `basic` when {@link unlit} is set — so the recorded op list stays\r\n * canonical. Pass {@link material} to bypass the shorthand entirely; every\r\n * renderer-level knob that is not a design decision (`depthWrite`, `alphaTest`,\r\n * `toneMapped`, `polygonOffset`, …) lives there and only there.\r\n */\r\nexport interface MaterialShorthand3D {\r\n /** A full descriptor (or an array, for multi-material). Wins over the rest. */\r\n material?: Material3D | readonly Material3D[];\r\n /** What the surface is made of: a colour, a texture, a gradient, 2D content. */\r\n fill?: Fill3D;\r\n opacity?: number;\r\n roughness?: number;\r\n metalness?: number;\r\n /** Self-illumination. Bloom in the post chain is what makes it glow. */\r\n emission?: Color;\r\n emissionStrength?: number;\r\n normalMap?: Texture3D;\r\n roughnessMap?: Texture3D;\r\n metalnessMap?: Texture3D;\r\n aoMap?: Texture3D;\r\n alphaMap?: Texture3D;\r\n envMapIntensity?: number;\r\n wireframe?: boolean;\r\n /** Facet or smooth shading. Default `\"smooth\"`. */\r\n shading?: Shading3D;\r\n /** Which faces to rasterize. Default `\"front\"`. */\r\n faces?: Faces3D;\r\n vertexColors?: boolean;\r\n blend?: Blend3D;\r\n /** Shade with an unlit `basic` material instead of `standard`. */\r\n unlit?: boolean;\r\n}\r\n\r\n/** Transform + material shorthand, accepted by every geometry sugar method. */\r\nexport type MeshShorthand3D = Transform3D & MaterialShorthand3D;\r\n\r\nconst TRANSFORM_KEYS = [\r\n \"position\", \"rotation\", \"quaternion\", \"scale\", \"lookAt\",\r\n \"visible\", \"shadow\", \"renderOrder\",\r\n] as const;\r\n\r\n/**\r\n * Shorthand keys copied straight onto the built descriptor.\r\n *\r\n * `fill` is deliberately absent: it resolves into `color` *and* `map` rather than\r\n * being one field, so it is handled on its own in {@link resolveMaterialShorthand3D}.\r\n */\r\nconst MATERIAL_SHORTHAND_KEYS = [\r\n \"opacity\", \"roughness\", \"metalness\",\r\n \"emission\", \"emissionStrength\", \"normalMap\", \"roughnessMap\",\r\n \"metalnessMap\", \"aoMap\", \"alphaMap\", \"envMapIntensity\", \"wireframe\",\r\n \"shading\", \"faces\", \"vertexColors\", \"blend\",\r\n] as const;\r\n\r\n/** Every key the shorthand owns, for stripping a geometry bag. */\r\nconst SHORTHAND_KEYS: readonly string[] = [...MATERIAL_SHORTHAND_KEYS, \"fill\", \"material\", \"unlit\"];\r\n\r\n/**\r\n * Pull the {@link Transform3D} fields out of a shorthand bag. Takes `object` so\r\n * the concrete option types at each call site pass without a cast, and returns\r\n * `undefined` rather than `{}` when there is nothing to apply — an absent\r\n * transform lets the renderer skip the matrix write entirely.\r\n */\r\nfunction pickTransform(source: object): Transform3D | undefined {\r\n const bag = source as Record<string, unknown>;\r\n let out: Record<string, unknown> | undefined;\r\n for (const key of TRANSFORM_KEYS) {\r\n if (bag[key] !== undefined) (out ??= {})[key] = bag[key];\r\n }\r\n return out as Transform3D | undefined;\r\n}\r\n\r\n/**\r\n * Build the material a shorthand bag describes. Always returns one, so a recorded\r\n * drawable op never has to be interpreted with \"…or the default\" in mind.\r\n *\r\n * Exported because `Mesh3D` desugars the identical bag from its own props: this\r\n * is where `fill` becomes `color`-or-`map`, and two copies of that decision is\r\n * two chances for a node and a builder call to paint differently.\r\n *\r\n * @internal\r\n */\r\nexport function resolveMaterialShorthand3D(source: MaterialShorthand3D): Material3D | readonly Material3D[] {\r\n if (source.material !== undefined) return source.material;\r\n\r\n const material: Record<string, unknown> = { type: source.unlit ? \"basic\" : \"standard\" };\r\n\r\n const fill = resolveFill3D(source.fill);\r\n if (fill.color !== undefined) material.color = fill.color;\r\n if (fill.map !== undefined) material.map = fill.map;\r\n\r\n for (const key of MATERIAL_SHORTHAND_KEYS) {\r\n const value = (source as Record<string, unknown>)[key];\r\n if (value !== undefined) material[key] = value;\r\n }\r\n return material as unknown as Material3D;\r\n}\r\n\r\n/** Drop the shorthand/transform keys, leaving only a geometry's own params. */\r\nfunction pickGeometry<T>(source: object, type: string): T {\r\n const bag = source as Record<string, unknown>;\r\n const out: Record<string, unknown> = { type };\r\n for (const key in bag) {\r\n if (SHORTHAND_KEYS.includes(key)) continue;\r\n if ((TRANSFORM_KEYS as readonly string[]).includes(key)) continue;\r\n if (bag[key] !== undefined) out[key] = bag[key];\r\n }\r\n return out as T;\r\n}\r\n\r\n/** Geometry params only, with `type` and the inherited passthrough removed. */\r\ntype ParamsOf<G> = Omit<G, \"type\">;\r\n\r\n// ─── Recorder ────────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * What one 3D node draws — the `Graphics2D` of 3D.\r\n *\r\n * Records an ordered list of drawables (meshes, instanced meshes, points, lines,\r\n * sprites, models), each with its own geometry, material and local transform.\r\n * That is the whole surface: it holds no camera, no lights and no hierarchy,\r\n * because those are properties of a *scene* rather than of a thing in one, and\r\n * the `Node3D` tree owns them. The exact division `Graphics2D` and\r\n * `RenderContext2D` already make in 2D.\r\n *\r\n * render: (ctx) => ctx.draw(new Graphics3D()\r\n * .box({ width: 2, cornerRadius: 0.15, fill: \"#e0533d\", roughness: 0.3 })),\r\n *\r\n * Nothing here touches a renderer: a built `Graphics3D` is handed to a\r\n * {@link RenderContext3D}, which splices its ops into the scene being recorded.\r\n *\r\n * ── One flat bag, deliberately ────────────────────────────────────────────────\r\n * `Graphics2D` paints with a *chained* `.rect(…).fill(…)`, and this does not,\r\n * which is the one place the two recorders diverge on purpose. In 2D a `fill` is\r\n * a **group-scoped op** covering the shapes recorded before it; in 3D a material\r\n * belongs to exactly one object, because a mesh *is* geometry plus material.\r\n * A chained `.box().fill()` would imply a group material that has nothing to\r\n * scope over, so the shape and what it is made of are stated together instead.\r\n *\r\n * ── Angles are DEGREES ────────────────────────────────────────────────────────\r\n * Every angle here — Euler rotations, sweep arcs, UV rotation — is in degrees,\r\n * matching the engine's 2D `rotation`. The renderer converts.\r\n *\r\n * ── Animation ─────────────────────────────────────────────────────────────────\r\n * A `Graphics3D` is rebuilt from scratch every frame, so animation is just\r\n * reading the node's own state while building:\r\n *\r\n * const Rig = component3d({\r\n * key: \"rig\",\r\n * state: { spin: 0, lift: Types.custom<Vector3>([0, 0, 0], { lerp: lerpVector3 }) },\r\n * render: (ctx, s) => ctx.draw(new Graphics3D()\r\n * .box({ rotation: [0, s.spin, 0], position: s.lift })),\r\n * });\r\n * // a `to` of { spin: 360 } over two seconds turns it\r\n *\r\n * Note the `lerp` on `lift`. An entry holding a non-number needs an explicit\r\n * tween (`lerpVector3`, `lerpEuler3`, `slerpQuaternion`) or `to()` has nothing\r\n * to interpolate it with and leaves it alone.\r\n *\r\n * ── Reconciliation identity ───────────────────────────────────────────────────\r\n * The renderer caches one live 3D object per op and mutates it between frames\r\n * rather than rebuilding. Identity is **derived**: it comes from the owning\r\n * `Node3D` plus a signature of what the op actually draws, so a builder that\r\n * emits ops conditionally reuses the right cache entry with nothing written by\r\n * hand. There is no `key` to set.\r\n *\r\n * ── What is cheap to animate ──────────────────────────────────────────────────\r\n * Transforms and most material values are in-place writes, so they cost nothing\r\n * per frame. **Geometry parameters are not** — three geometries are immutable, so\r\n * tweening `.box({ width: this.size })` reallocates the mesh every frame. Scale\r\n * the object instead: `.box({ width: 1, scale: [this.size, 1, 1] })`. The fields marked\r\n * \"structural\" on `MaterialCommon3D` recompile the shader program and should be\r\n * set once, not tweened.\r\n */\r\nexport class Graphics3D {\r\n private _ops: Graphics3DOp[] = [];\r\n\r\n /** Append one op, flagging (in development) inputs no renderer acts on. */\r\n private record(op: Graphics3DOp): void {\r\n inspectDrawable3D(op);\r\n this._ops.push(op);\r\n }\r\n\r\n // ─── Meshes ──────────────────────────────────────────────────────────────\r\n\r\n /**\r\n * Record a mesh from an explicit geometry and material. The geometry sugar\r\n * methods below all funnel here.\r\n */\r\n mesh(\r\n geometry: Geometry3D,\r\n material?: Material3D | readonly Material3D[],\r\n transform?: Transform3D,\r\n ): this {\r\n this.record({\r\n kind: \"mesh\",\r\n geometry,\r\n material: material ?? { type: \"standard\" },\r\n transform,\r\n });\r\n return this;\r\n }\r\n\r\n /** Record a mesh from a geometry `type` plus a flat shorthand bag. */\r\n private sugar(type: Geometry3D[\"type\"], options?: MeshShorthand3D): this {\r\n const source: MeshShorthand3D = options ?? {};\r\n return this.mesh(\r\n pickGeometry<Geometry3D>(source, type),\r\n resolveMaterialShorthand3D(source),\r\n pickTransform(source),\r\n );\r\n }\r\n\r\n box(options?: ParamsOf<BoxGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"box\", options);\r\n }\r\n sphere(options?: ParamsOf<SphereGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"sphere\", options);\r\n }\r\n plane(options?: ParamsOf<PlaneGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"plane\", options);\r\n }\r\n cylinder(options?: ParamsOf<CylinderGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"cylinder\", options);\r\n }\r\n cone(options?: ParamsOf<ConeGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"cone\", options);\r\n }\r\n torus(options?: ParamsOf<TorusGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"torus\", options);\r\n }\r\n torusKnot(options?: ParamsOf<TorusKnotGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"torusKnot\", options);\r\n }\r\n circle(options?: ParamsOf<CircleGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"circle\", options);\r\n }\r\n ring(options?: ParamsOf<RingGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"ring\", options);\r\n }\r\n capsule(options?: ParamsOf<CapsuleGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"capsule\", options);\r\n }\r\n polyhedron(options: ParamsOf<PolyhedronGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"polyhedron\", options);\r\n }\r\n extrude(options: ParamsOf<ExtrudeGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"extrude\", options);\r\n }\r\n lathe(options: ParamsOf<LatheGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"lathe\", options);\r\n }\r\n tube(options: ParamsOf<TubeGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"tube\", options);\r\n }\r\n\r\n // ─── Other drawables ─────────────────────────────────────────────────────\r\n\r\n /**\r\n * Record many copies of one geometry in a single draw call. The way to put\r\n * thousands of objects on screen — a plain `mesh` per copy would not keep up.\r\n *\r\n * g3.instances(Geo.box({ width: 0.2 }), Mat.standard({ color: \"cyan\" }),\r\n * positions.map(p => ({ position: p })))\r\n */\r\n instances(\r\n geometry: Geometry3D,\r\n material: Material3D,\r\n instances: readonly Transform3D[],\r\n options?: { colors?: readonly Color[]; transform?: Transform3D },\r\n ): this {\r\n this.record({\r\n kind: \"instances\",\r\n geometry,\r\n material,\r\n instances,\r\n colors: options?.colors,\r\n transform: options?.transform,\r\n });\r\n return this;\r\n }\r\n\r\n /** Record a point cloud — one sprite-like dot per vertex of `geometry`. */\r\n points(\r\n geometry: Geometry3D,\r\n material?: Material3D,\r\n transform?: Transform3D,\r\n ): this {\r\n this.record({\r\n kind: \"points\",\r\n geometry,\r\n material: material ?? { type: \"points\" },\r\n transform,\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Record a line. Give it either explicit `points` or a `geometry` (typically\r\n * `Geo.edges(...)` for a wireframe outline).\r\n *\r\n * `closed` joins the last point back to the first, as the 2D `line` op's\r\n * own field does. `segments` treats the points as disjoint start/end pairs\r\n * instead — the form `Geo.edges(...)` produces. (There is no subdivision to\r\n * confuse it with: a line is drawn from the points it is given.)\r\n */\r\n line(options: {\r\n points?: readonly Vector3Input[];\r\n geometry?: Geometry3D;\r\n material?: Material3D;\r\n /** Join the last point back to the first. */\r\n closed?: boolean;\r\n /** Treat the points as disjoint start/end pairs. */\r\n segments?: boolean;\r\n /** The line's paint. Cap and join have no meaning on a GL line. */\r\n stroke?: LineStroke3D;\r\n opacity?: number;\r\n transform?: Transform3D;\r\n } & Transform3D): this {\r\n const { points, geometry, material, closed, segments, stroke, opacity } = options;\r\n\r\n if (!points && !geometry) {\r\n throw new Error(\"Graphics3D.line() needs either `points` or `geometry`.\");\r\n }\r\n\r\n const resolved: Material3D = material ?? {\r\n type: stroke?.dash !== undefined ? \"lineDashed\" : \"lineBasic\",\r\n ...(stroke?.fill !== undefined ? { color: stroke.fill } : {}),\r\n ...(stroke?.weight !== undefined ? { width: stroke.weight } : {}),\r\n ...(stroke?.dash !== undefined\r\n ? { dashSize: stroke.dash[0], gapSize: stroke.dash[1] ?? stroke.dash[0] }\r\n : {}),\r\n ...(opacity !== undefined ? { opacity } : {}),\r\n } as Material3D;\r\n\r\n this.record({\r\n kind: \"line\",\r\n geometry: geometry ?? { type: \"buffer\", position: flattenPoints(points!) },\r\n material: resolved,\r\n mode: segments ? \"segments\" : closed ? \"loop\" : \"strip\",\r\n transform: pickTransform(options),\r\n });\r\n return this;\r\n }\r\n\r\n /** Record a camera-facing textured quad. */\r\n sprite(options: { fill?: Fill3D; material?: Material3D; opacity?: number } & Transform3D): this {\r\n const { fill, material, opacity } = options;\r\n const paint = resolveFill3D(fill);\r\n const resolved: Material3D = material ?? {\r\n type: \"sprite\",\r\n ...(paint.map !== undefined ? { map: paint.map } : {}),\r\n ...(paint.color !== undefined ? { color: paint.color } : {}),\r\n ...(opacity !== undefined ? { opacity } : {}),\r\n } as Material3D;\r\n this.record({\r\n kind: \"sprite\",\r\n material: resolved,\r\n transform: pickTransform(options),\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Record a loaded model. **glTF/GLB only**: any other format (an `.obj`, say)\r\n * resolves to an empty slot and draws nothing, and in development the first\r\n * one recorded warns.\r\n *\r\n * Baked animation is sampled by explicit `time`, never advanced by a delta, so\r\n * a model stays frame-identical under scrubbing.\r\n */\r\n model(options: {\r\n src: string;\r\n animation?: ModelAnimation3D | readonly ModelAnimation3D[];\r\n override?: Readonly<Record<string, Material3D>>;\r\n } & Transform3D): this {\r\n const { src, animation, override } = options;\r\n this.record({\r\n kind: \"model\",\r\n src,\r\n animation: animation === undefined\r\n ? undefined\r\n : Array.isArray(animation) ? animation : [animation as ModelAnimation3D],\r\n override,\r\n transform: pickTransform(options),\r\n });\r\n return this;\r\n }\r\n\r\n // ─── Consumption ─────────────────────────────────────────────────────────\r\n\r\n /** The recorded ops, in order. Replayed by the renderer. */\r\n ops(): readonly Graphics3DOp[] {\r\n return this._ops;\r\n }\r\n\r\n /** True when this node draws nothing. */\r\n isEmpty(): boolean {\r\n return this._ops.length === 0;\r\n }\r\n}\r\n\r\n/**\r\n * A 3D line's paint, named after the 2D `Stroke` it mirrors.\r\n *\r\n * `cap`, `join` and the rest of the 2D stroke vocabulary are deliberately absent:\r\n * they describe a stroked *path*, and a GL line has no outline to cap. Note that\r\n * `weight` above 1 is ignored by most WebGL implementations — for a genuinely\r\n * thick line, draw a `tube`.\r\n */\r\nexport interface LineStroke3D {\r\n /** The line's colour. Named `fill` to match the 2D `Stroke`. */\r\n fill?: Color;\r\n weight?: number;\r\n /** Dash and gap lengths, in world units. */\r\n dash?: readonly [number, number?];\r\n}\r\n\r\n/** Flatten `Vector3Input`s into the packed `[x, y, z, …]` a buffer wants. */\r\nfunction flattenPoints(points: readonly Vector3Input[]): number[] {\r\n const out: number[] = [];\r\n for (const point of points) {\r\n if (typeof point === \"number\") {\r\n out.push(point, point, point);\r\n } else if (Array.isArray(point)) {\r\n out.push(point[0] ?? 0, point[1] ?? 0, point[2] ?? 0);\r\n } else {\r\n const v = point as { x: number; y: number; z: number };\r\n out.push(v.x ?? 0, v.y ?? 0, v.z ?? 0);\r\n }\r\n }\r\n return out;\r\n}\r\n"]}
1
+ {"version":3,"file":"graphics3d.js","sourceRoot":"","sources":["../../src/render3d/graphics3d.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAe,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAoE5C;;;;;GAKG;AACH,gBAAgB;AAChB,MAAM,CAAC,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC;IACvD,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO;CACpE,CAAC,CAAC;AAkDH,MAAM,cAAc,GAAG;IACnB,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ;IACvD,SAAS,EAAE,QAAQ,EAAE,aAAa;CAC5B,CAAC;AAEX;;;;;GAKG;AACH,MAAM,uBAAuB,GAAG;IAC5B,SAAS,EAAE,WAAW,EAAE,WAAW;IACnC,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,cAAc;IAC3D,cAAc,EAAE,OAAO,EAAE,UAAU,E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KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,GAAG,KAA4C,CAAC;YACvD,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACb,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACb,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC;QACD,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;QACvH,CAAC,IAAI,CAAC,CAAC;IACX,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import type { Color } from \"@/attributes/shape/fill/color/parser\";\r\nimport type {\r\n BoxGeometry3D, BufferGeometry3D, CapsuleGeometry3D, CircleGeometry3D, ConeGeometry3D,\r\n CylinderGeometry3D, ExtrudeGeometry3D, Geometry3D, LatheGeometry3D,\r\n PlaneGeometry3D, PolyhedronGeometry3D, RingGeometry3D, SphereGeometry3D,\r\n TorusGeometry3D, TorusKnotGeometry3D, TubeGeometry3D,\r\n} from \"./geometry\";\r\nimport type { Material3D, Shading3D } from \"./material\";\r\nimport type { Texture3D } from \"./texture\";\r\nimport { resolveFill3D, type Fill3D } from \"./fill3d\";\r\nimport { inspectDrawable3D } from \"./inert\";\r\nimport { type Transform3D, type Blend3D, type Faces3D } from \"./transform\";\r\nimport type { Vector3Input } from \"./vector3\";\r\n\r\n// ─── Ops ─────────────────────────────────────────────────────────────────────\r\n\r\n/** One clip of a model's baked animation, sampled at an explicit time. */\r\nexport interface ModelAnimation3D {\r\n /** Clip name, or its index in the file. Defaults to the first clip. */\r\n clip?: string | number;\r\n /**\r\n * Seconds into the clip. **Explicit by design** — the renderer seeks to this\r\n * time rather than advancing by a delta, which is what keeps a model's\r\n * animation identical whether the frame was reached by playing forward or by\r\n * scrubbing backwards.\r\n */\r\n time: number;\r\n /** Blend weight, for cross-fading clips. Default 1. */\r\n weight?: number;\r\n}\r\n\r\n/**\r\n * How a `line` op connects its points: in order, or as disjoint start/end pairs,\r\n * or in order and closed back to the start.\r\n */\r\nexport type LineMode3D = \"strip\" | \"segments\" | \"loop\";\r\n\r\n/**\r\n * One recorded operation in a {@link Graphics3D} command list.\r\n *\r\n * Every op draws something. Hierarchy, lights and the camera are *scene*\r\n * concerns, recorded by the `Node3D` tree into a `Scene3D` — this is only ever\r\n * \"what one node paints\", which is exactly what a `Graphics2D` is in 2D.\r\n *\r\n * A drawable's geometry and material are *inline sub-descriptors*, not ops,\r\n * because in a 3D scene graph they are properties of an object rather than\r\n * children of it.\r\n */\r\nexport type Graphics3DOp =\r\n | { kind: \"mesh\"; geometry: Geometry3D; material: Material3D | readonly Material3D[]; transform?: Transform3D }\r\n | {\r\n kind: \"instances\";\r\n geometry: Geometry3D;\r\n material: Material3D;\r\n /** Per-instance placement. Length drives the instance count. */\r\n instances: readonly Transform3D[];\r\n /** Per-instance tint. Needs a material that reads instance colour. */\r\n colors?: readonly Color[];\r\n transform?: Transform3D;\r\n }\r\n | { kind: \"points\"; geometry: Geometry3D; material: Material3D; transform?: Transform3D }\r\n | {\r\n kind: \"line\";\r\n geometry: Geometry3D;\r\n material: Material3D;\r\n mode: LineMode3D;\r\n transform?: Transform3D;\r\n }\r\n | { kind: \"sprite\"; material: Material3D; transform?: Transform3D }\r\n | {\r\n kind: \"model\";\r\n src: string;\r\n animation?: readonly ModelAnimation3D[];\r\n /** Replace materials on the loaded graph, keyed by mesh or material name. */\r\n override?: Readonly<Record<string, Material3D>>;\r\n transform?: Transform3D;\r\n };\r\n\r\n/**\r\n * Op kinds that put something in the scene (as opposed to shaping the tree).\r\n *\r\n * Shared with `Scene3D`, whose op list is this one plus `push`/`pop`/`light`/\r\n * `camera` — so \"is anything actually drawn here\" has a single definition.\r\n */\r\n/** @internal */\r\nexport const DRAWABLE_KINDS: ReadonlySet<string> = new Set([\r\n \"mesh\", \"light\", \"instances\", \"points\", \"line\", \"sprite\", \"model\",\r\n]);\r\n\r\n// ─── Shorthand ───────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * Material fields promoted onto the geometry sugar methods, so the common case is\r\n * one flat call: `.box({ width: 2, fill: \"red\", roughness: 0.3 })`.\r\n *\r\n * `fill` is the whole 2D fill vocabulary — see {@link Fill3D} — and is what a\r\n * flat `color` plus a `map` slot used to be. The rest is surface *response*\r\n * (how light behaves on it) rather than colour, which is the line Spline's\r\n * material panel draws too and the reason those stay separate fields.\r\n *\r\n * These desugar at record time into a full {@link Material3D} — `standard` by\r\n * default, `basic` when {@link unlit} is set — so the recorded op list stays\r\n * canonical. Pass {@link material} to bypass the shorthand entirely; every\r\n * renderer-level knob that is not a design decision (`depthWrite`, `alphaTest`,\r\n * `toneMapped`, `polygonOffset`, …) lives there and only there.\r\n */\r\nexport interface MaterialShorthand3D {\r\n /** A full descriptor (or an array, for multi-material). Wins over the rest. */\r\n material?: Material3D | readonly Material3D[];\r\n /** What the surface is made of: a colour, a texture, a gradient, 2D content. */\r\n fill?: Fill3D;\r\n opacity?: number;\r\n roughness?: number;\r\n metalness?: number;\r\n /** Self-illumination. Bloom in the post chain is what makes it glow. */\r\n emission?: Color;\r\n emissionStrength?: number;\r\n normalMap?: Texture3D;\r\n roughnessMap?: Texture3D;\r\n metalnessMap?: Texture3D;\r\n aoMap?: Texture3D;\r\n alphaMap?: Texture3D;\r\n envMapIntensity?: number;\r\n wireframe?: boolean;\r\n /** Facet or smooth shading. Default `\"smooth\"`. */\r\n shading?: Shading3D;\r\n /** Which faces to rasterize. Default `\"front\"`. */\r\n faces?: Faces3D;\r\n vertexColors?: boolean;\r\n blend?: Blend3D;\r\n /** Shade with an unlit `basic` material instead of `standard`. */\r\n unlit?: boolean;\r\n}\r\n\r\n/** Transform + material shorthand, accepted by every geometry sugar method. */\r\nexport type MeshShorthand3D = Transform3D & MaterialShorthand3D;\r\n\r\nconst TRANSFORM_KEYS = [\r\n \"position\", \"rotation\", \"quaternion\", \"scale\", \"lookAt\",\r\n \"visible\", \"shadow\", \"renderOrder\",\r\n] as const;\r\n\r\n/**\r\n * Shorthand keys copied straight onto the built descriptor.\r\n *\r\n * `fill` is deliberately absent: it resolves into `color` *and* `map` rather than\r\n * being one field, so it is handled on its own in {@link resolveMaterialShorthand3D}.\r\n */\r\nconst MATERIAL_SHORTHAND_KEYS = [\r\n \"opacity\", \"roughness\", \"metalness\",\r\n \"emission\", \"emissionStrength\", \"normalMap\", \"roughnessMap\",\r\n \"metalnessMap\", \"aoMap\", \"alphaMap\", \"envMapIntensity\", \"wireframe\",\r\n \"shading\", \"faces\", \"vertexColors\", \"blend\",\r\n] as const;\r\n\r\n/** Every key the shorthand owns, for stripping a geometry bag. */\r\nconst SHORTHAND_KEYS: readonly string[] = [...MATERIAL_SHORTHAND_KEYS, \"fill\", \"material\", \"unlit\"];\r\n\r\n/**\r\n * Pull the {@link Transform3D} fields out of a shorthand bag. Takes `object` so\r\n * the concrete option types at each call site pass without a cast, and returns\r\n * `undefined` rather than `{}` when there is nothing to apply — an absent\r\n * transform lets the renderer skip the matrix write entirely.\r\n */\r\nfunction pickTransform(source: object): Transform3D | undefined {\r\n const bag = source as Record<string, unknown>;\r\n let out: Record<string, unknown> | undefined;\r\n for (const key of TRANSFORM_KEYS) {\r\n if (bag[key] !== undefined) (out ??= {})[key] = bag[key];\r\n }\r\n return out as Transform3D | undefined;\r\n}\r\n\r\n/**\r\n * Build the material a shorthand bag describes. Always returns one, so a recorded\r\n * drawable op never has to be interpreted with \"…or the default\" in mind.\r\n *\r\n * Exported because `Mesh3D` desugars the identical bag from its own props: this\r\n * is where `fill` becomes `color`-or-`map`, and two copies of that decision is\r\n * two chances for a node and a builder call to paint differently.\r\n *\r\n * @internal\r\n */\r\nexport function resolveMaterialShorthand3D(source: MaterialShorthand3D): Material3D | readonly Material3D[] {\r\n if (source.material !== undefined) return source.material;\r\n\r\n const material: Record<string, unknown> = { type: source.unlit ? \"basic\" : \"standard\" };\r\n\r\n const fill = resolveFill3D(source.fill);\r\n if (fill.color !== undefined) material.color = fill.color;\r\n if (fill.map !== undefined) material.map = fill.map;\r\n\r\n for (const key of MATERIAL_SHORTHAND_KEYS) {\r\n const value = (source as Record<string, unknown>)[key];\r\n if (value !== undefined) material[key] = value;\r\n }\r\n return material as unknown as Material3D;\r\n}\r\n\r\n/** Drop the shorthand/transform keys, leaving only a geometry's own params. */\r\nfunction pickGeometry<T>(source: object, type: string): T {\r\n const bag = source as Record<string, unknown>;\r\n const out: Record<string, unknown> = { type };\r\n for (const key in bag) {\r\n if (SHORTHAND_KEYS.includes(key)) continue;\r\n if ((TRANSFORM_KEYS as readonly string[]).includes(key)) continue;\r\n if (bag[key] !== undefined) out[key] = bag[key];\r\n }\r\n return out as T;\r\n}\r\n\r\n/** Geometry params only, with `type` and the inherited passthrough removed. */\r\ntype ParamsOf<G> = Omit<G, \"type\">;\r\n\r\n// ─── Recorder ────────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * What one 3D node draws — the `Graphics2D` of 3D.\r\n *\r\n * Records an ordered list of drawables (meshes, instanced meshes, points, lines,\r\n * sprites, models), each with its own geometry, material and local transform.\r\n * That is the whole surface: it holds no camera, no lights and no hierarchy,\r\n * because those are properties of a *scene* rather than of a thing in one, and\r\n * the `Node3D` tree owns them. The exact division `Graphics2D` and\r\n * `RenderContext2D` already make in 2D.\r\n *\r\n * render: (ctx) => ctx.draw(new Graphics3D()\r\n * .box({ width: 2, cornerRadius: 0.15, fill: \"#e0533d\", roughness: 0.3 })),\r\n *\r\n * Nothing here touches a renderer: a built `Graphics3D` is handed to a\r\n * {@link RenderContext3D}, which splices its ops into the scene being recorded.\r\n *\r\n * ── One flat bag, deliberately ────────────────────────────────────────────────\r\n * `Graphics2D` paints with a *chained* `.rect(…).fill(…)`, and this does not,\r\n * which is the one place the two recorders diverge on purpose. In 2D a `fill` is\r\n * a **group-scoped op** covering the shapes recorded before it; in 3D a material\r\n * belongs to exactly one object, because a mesh *is* geometry plus material.\r\n * A chained `.box().fill()` would imply a group material that has nothing to\r\n * scope over, so the shape and what it is made of are stated together instead.\r\n *\r\n * ── Angles are DEGREES ────────────────────────────────────────────────────────\r\n * Every angle here — Euler rotations, sweep arcs, UV rotation — is in degrees,\r\n * matching the engine's 2D `rotation`. The renderer converts.\r\n *\r\n * ── Animation ─────────────────────────────────────────────────────────────────\r\n * A `Graphics3D` is rebuilt from scratch every frame, so animation is just\r\n * reading the node's own state while building:\r\n *\r\n * const Rig = component3d({\r\n * key: \"rig\",\r\n * state: { spin: 0, lift: Types.custom<Vector3>([0, 0, 0], { lerp: lerpVector3 }) },\r\n * render: (ctx, s) => ctx.draw(new Graphics3D()\r\n * .box({ rotation: [0, s.spin, 0], position: s.lift })),\r\n * });\r\n * // a `to` of { spin: 360 } over two seconds turns it\r\n *\r\n * Note the `lerp` on `lift`. An entry holding a non-number needs an explicit\r\n * tween (`lerpVector3`, `lerpEuler3`, `slerpQuaternion`) or `to()` has nothing\r\n * to interpolate it with and leaves it alone.\r\n *\r\n * ── Reconciliation identity ───────────────────────────────────────────────────\r\n * The renderer caches one live 3D object per op and mutates it between frames\r\n * rather than rebuilding. Identity is **derived**: it comes from the owning\r\n * `Node3D` plus a signature of what the op actually draws, so a builder that\r\n * emits ops conditionally reuses the right cache entry with nothing written by\r\n * hand. There is no `key` to set.\r\n *\r\n * ── What is cheap to animate ──────────────────────────────────────────────────\r\n * Transforms and most material values are in-place writes, so they cost nothing\r\n * per frame. **Geometry parameters are not** — three geometries are immutable, so\r\n * tweening `.box({ width: this.size })` reallocates the mesh every frame. Scale\r\n * the object instead: `.box({ width: 1, scale: [this.size, 1, 1] })`. The fields marked\r\n * \"structural\" on `MaterialCommon3D` recompile the shader program and should be\r\n * set once, not tweened.\r\n */\r\nexport class Graphics3D {\r\n private _ops: Graphics3DOp[] = [];\r\n\r\n /** Append one op, flagging (in development) inputs no renderer acts on. */\r\n private record(op: Graphics3DOp): void {\r\n inspectDrawable3D(op);\r\n this._ops.push(op);\r\n }\r\n\r\n // ─── Meshes ──────────────────────────────────────────────────────────────\r\n\r\n /**\r\n * Record a mesh from an explicit geometry and material. The geometry sugar\r\n * methods below all funnel here.\r\n */\r\n mesh(\r\n geometry: Geometry3D,\r\n material?: Material3D | readonly Material3D[],\r\n transform?: Transform3D,\r\n ): this {\r\n this.record({\r\n kind: \"mesh\",\r\n geometry,\r\n material: material ?? { type: \"standard\" },\r\n transform,\r\n });\r\n return this;\r\n }\r\n\r\n /** Record a mesh from a geometry `type` plus a flat shorthand bag. */\r\n private sugar(type: Geometry3D[\"type\"], options?: MeshShorthand3D): this {\r\n const source: MeshShorthand3D = options ?? {};\r\n return this.mesh(\r\n pickGeometry<Geometry3D>(source, type),\r\n resolveMaterialShorthand3D(source),\r\n pickTransform(source),\r\n );\r\n }\r\n\r\n box(options?: ParamsOf<BoxGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"box\", options);\r\n }\r\n sphere(options?: ParamsOf<SphereGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"sphere\", options);\r\n }\r\n plane(options?: ParamsOf<PlaneGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"plane\", options);\r\n }\r\n cylinder(options?: ParamsOf<CylinderGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"cylinder\", options);\r\n }\r\n cone(options?: ParamsOf<ConeGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"cone\", options);\r\n }\r\n torus(options?: ParamsOf<TorusGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"torus\", options);\r\n }\r\n torusKnot(options?: ParamsOf<TorusKnotGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"torusKnot\", options);\r\n }\r\n circle(options?: ParamsOf<CircleGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"circle\", options);\r\n }\r\n ring(options?: ParamsOf<RingGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"ring\", options);\r\n }\r\n capsule(options?: ParamsOf<CapsuleGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"capsule\", options);\r\n }\r\n polyhedron(options: ParamsOf<PolyhedronGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"polyhedron\", options);\r\n }\r\n extrude(options: ParamsOf<ExtrudeGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"extrude\", options);\r\n }\r\n lathe(options: ParamsOf<LatheGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"lathe\", options);\r\n }\r\n tube(options: ParamsOf<TubeGeometry3D> & MeshShorthand3D): this {\r\n return this.sugar(\"tube\", options);\r\n }\r\n\r\n // ─── Other drawables ─────────────────────────────────────────────────────\r\n\r\n /**\r\n * Record many copies of one geometry in a single draw call. The way to put\r\n * thousands of objects on screen — a plain `mesh` per copy would not keep up.\r\n *\r\n * g3.instances(Geo.box({ width: 0.2 }), Mat.standard({ color: \"cyan\" }),\r\n * positions.map(p => ({ position: p })))\r\n */\r\n instances(\r\n geometry: Geometry3D,\r\n material: Material3D,\r\n instances: readonly Transform3D[],\r\n options?: { colors?: readonly Color[]; transform?: Transform3D },\r\n ): this {\r\n this.record({\r\n kind: \"instances\",\r\n geometry,\r\n material,\r\n instances,\r\n colors: options?.colors,\r\n transform: options?.transform,\r\n });\r\n return this;\r\n }\r\n\r\n /** Record a point cloud — one sprite-like dot per vertex of `geometry`. */\r\n points(\r\n geometry: Geometry3D,\r\n material?: Material3D,\r\n transform?: Transform3D,\r\n ): this {\r\n this.record({\r\n kind: \"points\",\r\n geometry,\r\n material: material ?? { type: \"points\" },\r\n transform,\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Record a line. Give it either explicit `points` or a `geometry` (typically\r\n * `Geo.edges(...)` for a wireframe outline).\r\n *\r\n * `closed` joins the last point back to the first, as the 2D `line` op's\r\n * own field does. `segments` treats the points as disjoint start/end pairs\r\n * instead — the form `Geo.edges(...)` produces. (There is no subdivision to\r\n * confuse it with: a line is drawn from the points it is given.)\r\n */\r\n line(options: {\r\n points?: readonly Vector3Input[];\r\n geometry?: Geometry3D;\r\n material?: Material3D;\r\n /** Join the last point back to the first. */\r\n closed?: boolean;\r\n /** Treat the points as disjoint start/end pairs. */\r\n segments?: boolean;\r\n /** The line's paint. Cap and join have no meaning on a GL line. */\r\n stroke?: LineStroke3D;\r\n opacity?: number;\r\n transform?: Transform3D;\r\n } & Transform3D): this {\r\n const { points, geometry, material, closed, segments, stroke, opacity } = options;\r\n\r\n if (!points && !geometry) {\r\n throw new Error(\"Graphics3D.line() needs either `points` or `geometry`.\");\r\n }\r\n\r\n const resolved: Material3D = material ?? {\r\n type: stroke?.dash !== undefined ? \"lineDashed\" : \"lineBasic\",\r\n ...(stroke?.fill !== undefined ? { color: stroke.fill } : {}),\r\n ...(stroke?.weight !== undefined ? { width: stroke.weight } : {}),\r\n ...(stroke?.dash !== undefined\r\n ? { dashSize: stroke.dash[0], gapSize: stroke.dash[1] ?? stroke.dash[0] }\r\n : {}),\r\n ...(opacity !== undefined ? { opacity } : {}),\r\n } as Material3D;\r\n\r\n this.record({\r\n kind: \"line\",\r\n geometry: geometry ?? lineBuffer(points!),\r\n material: resolved,\r\n mode: segments ? \"segments\" : closed ? \"loop\" : \"strip\",\r\n transform: pickTransform(options),\r\n });\r\n return this;\r\n }\r\n\r\n /** Record a camera-facing textured quad. */\r\n sprite(options: { fill?: Fill3D; material?: Material3D; opacity?: number } & Transform3D): this {\r\n const { fill, material, opacity } = options;\r\n const paint = resolveFill3D(fill);\r\n const resolved: Material3D = material ?? {\r\n type: \"sprite\",\r\n ...(paint.map !== undefined ? { map: paint.map } : {}),\r\n ...(paint.color !== undefined ? { color: paint.color } : {}),\r\n ...(opacity !== undefined ? { opacity } : {}),\r\n } as Material3D;\r\n this.record({\r\n kind: \"sprite\",\r\n material: resolved,\r\n transform: pickTransform(options),\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Record a loaded model. **glTF/GLB only**: any other format (an `.obj`, say)\r\n * resolves to an empty slot and draws nothing, and in development the first\r\n * one recorded warns.\r\n *\r\n * Baked animation is sampled by explicit `time`, never advanced by a delta, so\r\n * a model stays frame-identical under scrubbing.\r\n */\r\n model(options: {\r\n src: string;\r\n animation?: ModelAnimation3D | readonly ModelAnimation3D[];\r\n override?: Readonly<Record<string, Material3D>>;\r\n } & Transform3D): this {\r\n const { src, animation, override } = options;\r\n this.record({\r\n kind: \"model\",\r\n src,\r\n animation: animation === undefined\r\n ? undefined\r\n : Array.isArray(animation) ? animation : [animation as ModelAnimation3D],\r\n override,\r\n transform: pickTransform(options),\r\n });\r\n return this;\r\n }\r\n\r\n // ─── Consumption ─────────────────────────────────────────────────────────\r\n\r\n /** The recorded ops, in order. Replayed by the renderer. */\r\n ops(): readonly Graphics3DOp[] {\r\n return this._ops;\r\n }\r\n\r\n /** True when this node draws nothing. */\r\n isEmpty(): boolean {\r\n return this._ops.length === 0;\r\n }\r\n}\r\n\r\n/**\r\n * A 3D line's paint, named after the 2D `Stroke` it mirrors.\r\n *\r\n * `cap`, `join` and the rest of the 2D stroke vocabulary are deliberately absent:\r\n * they describe a stroked *path*, and a GL line has no outline to cap. Note that\r\n * `weight` above 1 is ignored by most WebGL implementations — for a genuinely\r\n * thick line, draw a `tube`.\r\n */\r\nexport interface LineStroke3D {\r\n /** The line's colour. Named `fill` to match the 2D `Stroke`. */\r\n fill?: Color;\r\n weight?: number;\r\n /** Dash and gap lengths, in world units. */\r\n dash?: readonly [number, number?];\r\n}\r\n\r\n/** The buffer each points array was last flattened into, and the revision it was uploaded under. */\r\nconst lineBuffers = new WeakMap<readonly Vector3Input[], { readonly position: Float32Array; readonly revision: number }>();\r\nlet lineRevision = 0;\r\n\r\n/**\r\n * `points` as a line's buffer. The same array holding the same values gets the\r\n * same buffer and revision back, so a renderer uploads an unchanged line once,\r\n * not every frame; the values are checked, so one changed in place still lands.\r\n */\r\nfunction lineBuffer(points: readonly Vector3Input[]): BufferGeometry3D {\r\n let kept = lineBuffers.get(points);\r\n if (!kept || !holds(kept.position, points)) {\r\n kept = { position: flattenPoints(points), revision: ++lineRevision };\r\n lineBuffers.set(points, kept);\r\n }\r\n return { type: \"buffer\", position: kept.position, revision: kept.revision };\r\n}\r\n\r\n/** Flatten `Vector3Input`s into the packed `[x, y, z, …]` a buffer wants. */\r\nfunction flattenPoints(points: readonly Vector3Input[]): Float32Array {\r\n const out = new Float32Array(points.length * 3);\r\n let i = 0;\r\n for (const point of points) {\r\n if (typeof point === \"number\") {\r\n out[i] = out[i + 1] = out[i + 2] = point;\r\n } else if (Array.isArray(point)) {\r\n out[i] = point[0] ?? 0;\r\n out[i + 1] = point[1] ?? 0;\r\n out[i + 2] = point[2] ?? 0;\r\n } else {\r\n const v = point as { x: number; y: number; z: number };\r\n out[i] = v.x ?? 0;\r\n out[i + 1] = v.y ?? 0;\r\n out[i + 2] = v.z ?? 0;\r\n }\r\n i += 3;\r\n }\r\n return out;\r\n}\r\n\r\n/** Whether `buffer` is what flattening `points` would give. */\r\nfunction holds(buffer: Float32Array, points: readonly Vector3Input[]): boolean {\r\n if (buffer.length !== points.length * 3) return false;\r\n let i = 0;\r\n for (const point of points) {\r\n let x: number, y: number, z: number;\r\n if (typeof point === \"number\") {\r\n x = y = z = point;\r\n } else if (Array.isArray(point)) {\r\n x = point[0] ?? 0;\r\n y = point[1] ?? 0;\r\n z = point[2] ?? 0;\r\n } else {\r\n const v = point as { x: number; y: number; z: number };\r\n x = v.x ?? 0;\r\n y = v.y ?? 0;\r\n z = v.z ?? 0;\r\n }\r\n if (buffer[i] !== Math.fround(x) || buffer[i + 1] !== Math.fround(y) || buffer[i + 2] !== Math.fround(z)) return false;\r\n i += 3;\r\n }\r\n return true;\r\n}\r\n"]}
@@ -45,7 +45,8 @@ class Sweep {
45
45
  this._walked = this._start - 1;
46
46
  this._placed = _instance.placedCommands().map((p) => ({
47
47
  id: p.spec.id,
48
- ...this._activeFrames(p.start, p.duration),
48
+ // An entrance writes its first frame from `holdFrom`, ahead of its start.
49
+ ...this._activeFrames(p.holdFrom, p.start - p.holdFrom + p.duration),
49
50
  writes: new Set(p.writes),
50
51
  }));
51
52
  for (let i = 0; i < this._placed.length; i++) {