@motionscript/core 0.1.0-alpha.8 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (817) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +201 -201
  3. package/NOTICE +49 -49
  4. package/README.md +91 -91
  5. package/dist/assets/asset-index.js.map +1 -1
  6. package/dist/assets/catalog.js.map +1 -1
  7. package/dist/assets/errors.js.map +1 -1
  8. package/dist/assets/index.js.map +1 -1
  9. package/dist/assets/manager.js.map +1 -1
  10. package/dist/assets/manifest.js.map +1 -1
  11. package/dist/assets/record.js.map +1 -1
  12. package/dist/assets/scope.js.map +1 -1
  13. package/dist/attributes/audio/effects/chain.js.map +1 -1
  14. package/dist/attributes/audio/effects/implementations/echo.js.map +1 -1
  15. package/dist/attributes/audio/effects/implementations/gain.js.map +1 -1
  16. package/dist/attributes/audio/effects/implementations/highpass.js.map +1 -1
  17. package/dist/attributes/audio/effects/implementations/lowpass.js.map +1 -1
  18. package/dist/attributes/audio/effects/implementations/tremolo.js.map +1 -1
  19. package/dist/attributes/audio/effects/index.js.map +1 -1
  20. package/dist/attributes/audio/effects/registry.js.map +1 -1
  21. package/dist/attributes/audio/effects/union.js.map +1 -1
  22. package/dist/attributes/audio/ramp.js.map +1 -1
  23. package/dist/attributes/audio/request.js.map +1 -1
  24. package/dist/attributes/audio/schedule.js.map +1 -1
  25. package/dist/attributes/audio/sound.js.map +1 -1
  26. package/dist/attributes/audio/transition.js.map +1 -1
  27. package/dist/attributes/index.js.map +1 -1
  28. package/dist/attributes/layout/alignment.js.map +1 -1
  29. package/dist/attributes/layout/index.js.map +1 -1
  30. package/dist/attributes/layout/insets.js.map +1 -1
  31. package/dist/attributes/layout/matrix2d.js.map +1 -1
  32. package/dist/attributes/layout/size.js.map +1 -1
  33. package/dist/attributes/layout/space3d.js.map +1 -1
  34. package/dist/attributes/layout/transform3d.js.map +1 -1
  35. package/dist/attributes/layout/vector2.js.map +1 -1
  36. package/dist/attributes/layout/world-transform.js.map +1 -1
  37. package/dist/attributes/mask/boolean.js.map +1 -1
  38. package/dist/attributes/mask/mask.js.map +1 -1
  39. package/dist/attributes/properties/decorator.js.map +1 -1
  40. package/dist/attributes/properties/inputs.js.map +1 -1
  41. package/dist/attributes/properties/typed.js.map +1 -1
  42. package/dist/attributes/render3d/orbit.js.map +1 -1
  43. package/dist/attributes/shape/corners/corner-radius.js.map +1 -1
  44. package/dist/attributes/shape/corners/corner-style.js.map +1 -1
  45. package/dist/attributes/shape/corners/corners.js.map +1 -1
  46. package/dist/attributes/shape/corners/index.js.map +1 -1
  47. package/dist/attributes/shape/effects/backdrop.js.map +1 -1
  48. package/dist/attributes/shape/effects/chain.js.map +1 -1
  49. package/dist/attributes/shape/effects/effect-data.js.map +1 -1
  50. package/dist/attributes/shape/effects/implementations/ascii.js.map +1 -1
  51. package/dist/attributes/shape/effects/implementations/bit-crush.js.map +1 -1
  52. package/dist/attributes/shape/effects/implementations/block-displace.js.map +1 -1
  53. package/dist/attributes/shape/effects/implementations/bloom.js.map +1 -1
  54. package/dist/attributes/shape/effects/implementations/blur.js.map +1 -1
  55. package/dist/attributes/shape/effects/implementations/bulge.js.map +1 -1
  56. package/dist/attributes/shape/effects/implementations/chromatic-aberration.js.map +1 -1
  57. package/dist/attributes/shape/effects/implementations/color-adjustment.js.map +1 -1
  58. package/dist/attributes/shape/effects/implementations/curves.d.ts +2 -2
  59. package/dist/attributes/shape/effects/implementations/curves.js.map +1 -1
  60. package/dist/attributes/shape/effects/implementations/directional-blur.js.map +1 -1
  61. package/dist/attributes/shape/effects/implementations/dither.d.ts +2 -2
  62. package/dist/attributes/shape/effects/implementations/dither.js.map +1 -1
  63. package/dist/attributes/shape/effects/implementations/drop-shadow.js.map +1 -1
  64. package/dist/attributes/shape/effects/implementations/duotone.js.map +1 -1
  65. package/dist/attributes/shape/effects/implementations/edges.js.map +1 -1
  66. package/dist/attributes/shape/effects/implementations/glass.js.map +1 -1
  67. package/dist/attributes/shape/effects/implementations/glow.d.ts +4 -4
  68. package/dist/attributes/shape/effects/implementations/glow.js.map +1 -1
  69. package/dist/attributes/shape/effects/implementations/grain.js.map +1 -1
  70. package/dist/attributes/shape/effects/implementations/grayscale.js.map +1 -1
  71. package/dist/attributes/shape/effects/implementations/halftone.js.map +1 -1
  72. package/dist/attributes/shape/effects/implementations/invert.d.ts +2 -2
  73. package/dist/attributes/shape/effects/implementations/invert.js.map +1 -1
  74. package/dist/attributes/shape/effects/implementations/kaleidoscope.js.map +1 -1
  75. package/dist/attributes/shape/effects/implementations/lut.js.map +1 -1
  76. package/dist/attributes/shape/effects/implementations/magnify.js.map +1 -1
  77. package/dist/attributes/shape/effects/implementations/motion-blur.js.map +1 -1
  78. package/dist/attributes/shape/effects/implementations/oil-paint.js.map +1 -1
  79. package/dist/attributes/shape/effects/implementations/outline.js.map +1 -1
  80. package/dist/attributes/shape/effects/implementations/pixelate.js.map +1 -1
  81. package/dist/attributes/shape/effects/implementations/posterize.js.map +1 -1
  82. package/dist/attributes/shape/effects/implementations/progressive-blur.js.map +1 -1
  83. package/dist/attributes/shape/effects/implementations/radial-blur.js.map +1 -1
  84. package/dist/attributes/shape/effects/implementations/rgb-shift.js.map +1 -1
  85. package/dist/attributes/shape/effects/implementations/scanlines.js.map +1 -1
  86. package/dist/attributes/shape/effects/implementations/scatter.js.map +1 -1
  87. package/dist/attributes/shape/effects/implementations/shader.d.ts +2 -2
  88. package/dist/attributes/shape/effects/implementations/shader.js.map +1 -1
  89. package/dist/attributes/shape/effects/implementations/sharpen.js.map +1 -1
  90. package/dist/attributes/shape/effects/implementations/streak.js.map +1 -1
  91. package/dist/attributes/shape/effects/implementations/threshold.js.map +1 -1
  92. package/dist/attributes/shape/effects/implementations/twirl.js.map +1 -1
  93. package/dist/attributes/shape/effects/implementations/vignette.js.map +1 -1
  94. package/dist/attributes/shape/effects/implementations/vintage.js.map +1 -1
  95. package/dist/attributes/shape/effects/implementations/wave.js.map +1 -1
  96. package/dist/attributes/shape/effects/index.js.map +1 -1
  97. package/dist/attributes/shape/effects/registry.js.map +1 -1
  98. package/dist/attributes/shape/effects/spec.js.map +1 -1
  99. package/dist/attributes/shape/effects/union.js.map +1 -1
  100. package/dist/attributes/shape/fill/blend.js.map +1 -1
  101. package/dist/attributes/shape/fill/chain.js.map +1 -1
  102. package/dist/attributes/shape/fill/coerce.js.map +1 -1
  103. package/dist/attributes/shape/fill/color/constants.js.map +1 -1
  104. package/dist/attributes/shape/fill/color/parser.d.ts.map +1 -1
  105. package/dist/attributes/shape/fill/color/parser.js +20 -5
  106. package/dist/attributes/shape/fill/color/parser.js.map +1 -1
  107. package/dist/attributes/shape/fill/gradient-stops.js.map +1 -1
  108. package/dist/attributes/shape/fill/implementations/canvas3d.js.map +1 -1
  109. package/dist/attributes/shape/fill/implementations/color.js.map +1 -1
  110. package/dist/attributes/shape/fill/implementations/conic-gradient.js.map +1 -1
  111. package/dist/attributes/shape/fill/implementations/dot-grid.js.map +1 -1
  112. package/dist/attributes/shape/fill/implementations/fractal-noise.js.map +1 -1
  113. package/dist/attributes/shape/fill/implementations/grid.js.map +1 -1
  114. package/dist/attributes/shape/fill/implementations/image.js.map +1 -1
  115. package/dist/attributes/shape/fill/implementations/linear-gradient.js.map +1 -1
  116. package/dist/attributes/shape/fill/implementations/noise.js.map +1 -1
  117. package/dist/attributes/shape/fill/implementations/radial-gradient.js.map +1 -1
  118. package/dist/attributes/shape/fill/implementations/shader.js.map +1 -1
  119. package/dist/attributes/shape/fill/implementations/stripe.js.map +1 -1
  120. package/dist/attributes/shape/fill/implementations/video.js.map +1 -1
  121. package/dist/attributes/shape/fill/index.js.map +1 -1
  122. package/dist/attributes/shape/fill/lerp.js.map +1 -1
  123. package/dist/attributes/shape/fill/media-preset.js.map +1 -1
  124. package/dist/attributes/shape/fill/registry.js.map +1 -1
  125. package/dist/attributes/shape/fill/union.js.map +1 -1
  126. package/dist/attributes/shape/filters/chain.js.map +1 -1
  127. package/dist/attributes/shape/filters/implementations/alpha.js.map +1 -1
  128. package/dist/attributes/shape/filters/implementations/blur.js.map +1 -1
  129. package/dist/attributes/shape/filters/implementations/color-adjustment.js.map +1 -1
  130. package/dist/attributes/shape/filters/implementations/color-matrix.js.map +1 -1
  131. package/dist/attributes/shape/filters/implementations/curves.js.map +1 -1
  132. package/dist/attributes/shape/filters/implementations/echo.js.map +1 -1
  133. package/dist/attributes/shape/filters/implementations/exposure.js.map +1 -1
  134. package/dist/attributes/shape/filters/implementations/grayscale.js.map +1 -1
  135. package/dist/attributes/shape/filters/implementations/posterize-time.js.map +1 -1
  136. package/dist/attributes/shape/filters/index.js.map +1 -1
  137. package/dist/attributes/shape/filters/registry.js.map +1 -1
  138. package/dist/attributes/shape/filters/union.js.map +1 -1
  139. package/dist/attributes/shape/path/anchors.js.map +1 -1
  140. package/dist/attributes/shape/path/bezier.js.map +1 -1
  141. package/dist/attributes/shape/path/index.js.map +1 -1
  142. package/dist/attributes/shape/path/measure.js.map +1 -1
  143. package/dist/attributes/shape/path/morph.js.map +1 -1
  144. package/dist/attributes/shape/path/ops.js.map +1 -1
  145. package/dist/attributes/shape/path/types.js.map +1 -1
  146. package/dist/attributes/shape/path/walk.js.map +1 -1
  147. package/dist/attributes/shape/shaders/index.js.map +1 -1
  148. package/dist/attributes/shape/shaders/language.js.map +1 -1
  149. package/dist/attributes/shape/shaders/pack.js.map +1 -1
  150. package/dist/attributes/shape/shaders/resolve.js.map +1 -1
  151. package/dist/attributes/shape/shadow/index.js.map +1 -1
  152. package/dist/attributes/shape/shadow/shadow.js.map +1 -1
  153. package/dist/attributes/shape/stroke/index.js.map +1 -1
  154. package/dist/attributes/shape/stroke/stroke.js.map +1 -1
  155. package/dist/attributes/shared/operators.js.map +1 -1
  156. package/dist/attributes/text/index.js.map +1 -1
  157. package/dist/attributes/text/ops.js.map +1 -1
  158. package/dist/attributes/text/types.js.map +1 -1
  159. package/dist/browser/chunks/{chunk-LKUYVFU3.js → chunk-4BDLFEOC.js} +1 -1
  160. package/dist/browser/chunks/chunk-4BDLFEOC.js.map +7 -0
  161. package/dist/browser/chunks/chunk-CCGVIR4F.js +3 -0
  162. package/dist/browser/chunks/chunk-CCGVIR4F.js.map +7 -0
  163. package/dist/browser/chunks/chunk-N4WSN5WY.js +13 -0
  164. package/dist/browser/chunks/chunk-N4WSN5WY.js.map +7 -0
  165. package/dist/browser/chunks/chunk-WZSI3GSK.js +6 -0
  166. package/dist/browser/chunks/chunk-WZSI3GSK.js.map +7 -0
  167. package/dist/browser/component.js +1 -1
  168. package/dist/browser/experimental.js +1 -1
  169. package/dist/browser/experimental.js.map +1 -1
  170. package/dist/browser/index.js +1 -1
  171. package/dist/browser/index.js.map +1 -1
  172. package/dist/browser/manifest.json +1 -1
  173. package/dist/browser/sdk.js +1 -1
  174. package/dist/component.js.map +1 -1
  175. package/dist/components/builtins/audio/audio.js.map +1 -1
  176. package/dist/components/builtins/geometry/composite.js.map +1 -1
  177. package/dist/components/builtins/geometry/geometry.js.map +1 -1
  178. package/dist/components/builtins/geometry/shape-outline.js.map +1 -1
  179. package/dist/components/builtins/layout/layout.js.map +1 -1
  180. package/dist/components/builtins/media/media.js.map +1 -1
  181. package/dist/components/builtins/providers/providers.js.map +1 -1
  182. package/dist/components/builtins/text/number-format.js.map +1 -1
  183. package/dist/components/builtins/text/number-pattern.js.map +1 -1
  184. package/dist/components/builtins/text/text-defaults.js.map +1 -1
  185. package/dist/components/builtins/text/text-layout.js.map +1 -1
  186. package/dist/components/builtins/text/text.d.ts +9 -9
  187. package/dist/components/builtins/text/text.js.map +1 -1
  188. package/dist/components/builtins/three/canvas3d.js.map +1 -1
  189. package/dist/components/builtins/three/grid-geometry3d.js.map +1 -1
  190. package/dist/components/builtins/three/three.js.map +1 -1
  191. package/dist/components/factory/api.js.map +1 -1
  192. package/dist/components/factory/clip-of.js.map +1 -1
  193. package/dist/components/factory/commands-for.js.map +1 -1
  194. package/dist/components/factory/component-audio.js.map +1 -1
  195. package/dist/components/factory/component2d.js.map +1 -1
  196. package/dist/components/factory/component3d.js.map +1 -1
  197. package/dist/components/factory/factory.js.map +1 -1
  198. package/dist/components/factory/timeline.js.map +1 -1
  199. package/dist/components/factory/type-def.js.map +1 -1
  200. package/dist/components/factory/types.js.map +1 -1
  201. package/dist/components/factory/views.d.ts.map +1 -1
  202. package/dist/components/factory/views.js +41 -1
  203. package/dist/components/factory/views.js.map +1 -1
  204. package/dist/components/modules/aim.js.map +1 -1
  205. package/dist/components/modules/corners.js.map +1 -1
  206. package/dist/components/modules/flow.js.map +1 -1
  207. package/dist/components/modules/material.js.map +1 -1
  208. package/dist/components/modules/paint.js.map +1 -1
  209. package/dist/components/modules/shapes.js.map +1 -1
  210. package/dist/components/modules/text-layout.js.map +1 -1
  211. package/dist/components/modules/text-style.d.ts +1 -1
  212. package/dist/components/modules/text-style.js.map +1 -1
  213. package/dist/components/modules/three-entries.js.map +1 -1
  214. package/dist/components/modules/view3d.js.map +1 -1
  215. package/dist/components/trees/2d/group-bounds.js.map +1 -1
  216. package/dist/components/trees/2d/node-lifecycle.js.map +1 -1
  217. package/dist/components/trees/2d/node-motion.js.map +1 -1
  218. package/dist/components/trees/2d/node-render.js.map +1 -1
  219. package/dist/components/trees/2d/node-space.js.map +1 -1
  220. package/dist/components/trees/2d/node-transform.js.map +1 -1
  221. package/dist/components/trees/2d/node2d.js.map +1 -1
  222. package/dist/components/trees/audio/index.js.map +1 -1
  223. package/dist/components/trees/audio/node-audio.js.map +1 -1
  224. package/dist/components/trees/index.js.map +1 -1
  225. package/dist/components/trees/node/node-editor-state.js.map +1 -1
  226. package/dist/components/trees/node/node-reactive.d.ts +3 -4
  227. package/dist/components/trees/node/node-reactive.d.ts.map +1 -1
  228. package/dist/components/trees/node/node-reactive.js +13 -10
  229. package/dist/components/trees/node/node-reactive.js.map +1 -1
  230. package/dist/components/trees/node/node-time.js.map +1 -1
  231. package/dist/components/trees/node/node-walk.js.map +1 -1
  232. package/dist/components/trees/node/node.js.map +1 -1
  233. package/dist/components/trees/root/canvas2d-node.js.map +1 -1
  234. package/dist/components/trees/three/node3d.js.map +1 -1
  235. package/dist/document/audio.js.map +1 -1
  236. package/dist/document/builtins.js.map +1 -1
  237. package/dist/document/command-traits.d.ts +8 -0
  238. package/dist/document/command-traits.d.ts.map +1 -1
  239. package/dist/document/command-traits.js +17 -0
  240. package/dist/document/command-traits.js.map +1 -1
  241. package/dist/document/deny-globals.js.map +1 -1
  242. package/dist/document/diff.js.map +1 -1
  243. package/dist/document/doc-index.js.map +1 -1
  244. package/dist/document/expression/compile.js.map +1 -1
  245. package/dist/document/expression/index.js.map +1 -1
  246. package/dist/document/expression/ops.js.map +1 -1
  247. package/dist/document/expression/parse.js.map +1 -1
  248. package/dist/document/expression/refs.js.map +1 -1
  249. package/dist/document/expression/types.js.map +1 -1
  250. package/dist/document/expression/walk.js.map +1 -1
  251. package/dist/document/index.js.map +1 -1
  252. package/dist/document/migrate.js.map +1 -1
  253. package/dist/document/missing-node.js.map +1 -1
  254. package/dist/document/node-decorator.js.map +1 -1
  255. package/dist/document/node-descriptor.js.map +1 -1
  256. package/dist/document/placement.js.map +1 -1
  257. package/dist/document/project.js.map +1 -1
  258. package/dist/document/prop-evolution.js.map +1 -1
  259. package/dist/document/registry.js.map +1 -1
  260. package/dist/document/settled-index.d.ts +6 -0
  261. package/dist/document/settled-index.d.ts.map +1 -1
  262. package/dist/document/settled-index.js +18 -1
  263. package/dist/document/settled-index.js.map +1 -1
  264. package/dist/document/timeline-patch.js.map +1 -1
  265. package/dist/document/timeline.d.ts.map +1 -1
  266. package/dist/document/timeline.js +26 -6
  267. package/dist/document/timeline.js.map +1 -1
  268. package/dist/document/types.js.map +1 -1
  269. package/dist/document/validate.js.map +1 -1
  270. package/dist/document/vocabulary.js.map +1 -1
  271. package/dist/experimental.d.ts.map +1 -1
  272. package/dist/experimental.js.map +1 -1
  273. package/dist/index.js.map +1 -1
  274. package/dist/layout/bounds.js.map +1 -1
  275. package/dist/layout/constraints.js.map +1 -1
  276. package/dist/layout/flex.js.map +1 -1
  277. package/dist/layout/freeform.js.map +1 -1
  278. package/dist/layout/grid.js.map +1 -1
  279. package/dist/layout/index.js.map +1 -1
  280. package/dist/layout/item.js.map +1 -1
  281. package/dist/layout/ops.js.map +1 -1
  282. package/dist/layout/types.js.map +1 -1
  283. package/dist/platform/audio-sink.js.map +1 -1
  284. package/dist/platform/exporter.js.map +1 -1
  285. package/dist/platform/index.js.map +1 -1
  286. package/dist/platform/stepped-clock.js.map +1 -1
  287. package/dist/platform/storage-adapter.js.map +1 -1
  288. package/dist/platform/ticker.js.map +1 -1
  289. package/dist/project/config.js.map +1 -1
  290. package/dist/project/index.js.map +1 -1
  291. package/dist/project/tree.js.map +1 -1
  292. package/dist/props/host.d.ts +5 -0
  293. package/dist/props/host.d.ts.map +1 -1
  294. package/dist/props/host.js +3 -1
  295. package/dist/props/host.js.map +1 -1
  296. package/dist/props/index.js.map +1 -1
  297. package/dist/props/layout.d.ts +29 -0
  298. package/dist/props/layout.d.ts.map +1 -0
  299. package/dist/props/layout.js +84 -0
  300. package/dist/props/layout.js.map +1 -0
  301. package/dist/props/observer.js.map +1 -1
  302. package/dist/props/slot.js.map +1 -1
  303. package/dist/renamed-scene-names.js.map +1 -1
  304. package/dist/render/canvas-render-context2d.js.map +1 -1
  305. package/dist/render/clip-contains.js.map +1 -1
  306. package/dist/render/clip.js.map +1 -1
  307. package/dist/render/descriptors/ellipse.js.map +1 -1
  308. package/dist/render/descriptors/line.js.map +1 -1
  309. package/dist/render/descriptors/path-builder.js.map +1 -1
  310. package/dist/render/descriptors/path.js.map +1 -1
  311. package/dist/render/descriptors/polygon.js.map +1 -1
  312. package/dist/render/descriptors/polygram.js.map +1 -1
  313. package/dist/render/descriptors/rect.js.map +1 -1
  314. package/dist/render/descriptors/richtext.js.map +1 -1
  315. package/dist/render/descriptors/shape.js.map +1 -1
  316. package/dist/render/descriptors/text.js.map +1 -1
  317. package/dist/render/descriptors/transform.js.map +1 -1
  318. package/dist/render/graphics2d.js.map +1 -1
  319. package/dist/render/index.js.map +1 -1
  320. package/dist/render/measure-context.js.map +1 -1
  321. package/dist/render/null-render-context.js.map +1 -1
  322. package/dist/render/render-context2d.js.map +1 -1
  323. package/dist/render/render-issue.js.map +1 -1
  324. package/dist/render/surface.js.map +1 -1
  325. package/dist/render/text-defaults.js.map +1 -1
  326. package/dist/render/text-layout.js.map +1 -1
  327. package/dist/render3d/bounds3d.js.map +1 -1
  328. package/dist/render3d/builders.js.map +1 -1
  329. package/dist/render3d/camera.js.map +1 -1
  330. package/dist/render3d/fill3d.js.map +1 -1
  331. package/dist/render3d/geometry.js.map +1 -1
  332. package/dist/render3d/graphics3d.js.map +1 -1
  333. package/dist/render3d/index.js.map +1 -1
  334. package/dist/render3d/inert.js.map +1 -1
  335. package/dist/render3d/light.js.map +1 -1
  336. package/dist/render3d/material.js.map +1 -1
  337. package/dist/render3d/matrix4.js.map +1 -1
  338. package/dist/render3d/render-context3d.js.map +1 -1
  339. package/dist/render3d/resources.js.map +1 -1
  340. package/dist/render3d/rounded-box.js.map +1 -1
  341. package/dist/render3d/scene-settings.js.map +1 -1
  342. package/dist/render3d/scene3d.js.map +1 -1
  343. package/dist/render3d/segments.js.map +1 -1
  344. package/dist/render3d/texture.js.map +1 -1
  345. package/dist/render3d/tracking.js.map +1 -1
  346. package/dist/render3d/transform.js.map +1 -1
  347. package/dist/render3d/vector3.js.map +1 -1
  348. package/dist/render3d/walk.js.map +1 -1
  349. package/dist/runtime/asset-refine.js.map +1 -1
  350. package/dist/runtime/asset-timeline.js.map +1 -1
  351. package/dist/runtime/asset-update.js.map +1 -1
  352. package/dist/runtime/audio-index.js.map +1 -1
  353. package/dist/runtime/builtin-context.js.map +1 -1
  354. package/dist/runtime/clip-instance.js.map +1 -1
  355. package/dist/runtime/clip-store.js.map +1 -1
  356. package/dist/runtime/engine.js.map +1 -1
  357. package/dist/runtime/frame-time.js.map +1 -1
  358. package/dist/runtime/index.js.map +1 -1
  359. package/dist/runtime/node-picking.js.map +1 -1
  360. package/dist/runtime/node-picking3d.js.map +1 -1
  361. package/dist/runtime/placement.js.map +1 -1
  362. package/dist/runtime/playback-controller.js.map +1 -1
  363. package/dist/runtime/playback.js.map +1 -1
  364. package/dist/runtime/precompisition.js.map +1 -1
  365. package/dist/runtime/project-assets.js.map +1 -1
  366. package/dist/runtime/session.js.map +1 -1
  367. package/dist/runtime/settle.js.map +1 -1
  368. package/dist/runtime/state-evaluator.js.map +1 -1
  369. package/dist/runtime/text-geometry.js.map +1 -1
  370. package/dist/sdk/index.js.map +1 -1
  371. package/dist/tween/command-decorator.js.map +1 -1
  372. package/dist/tween/command.js.map +1 -1
  373. package/dist/tween/ease/constants.js.map +1 -1
  374. package/dist/tween/ease/curve.js.map +1 -1
  375. package/dist/tween/ease/describe.js.map +1 -1
  376. package/dist/tween/ease/spec.js.map +1 -1
  377. package/dist/tween/ease/type.js.map +1 -1
  378. package/dist/tween/index.js.map +1 -1
  379. package/dist/tween/inert.js.map +1 -1
  380. package/dist/tween/lerp.js.map +1 -1
  381. package/dist/tween/loop.js.map +1 -1
  382. package/dist/tween/prepare.js.map +1 -1
  383. package/dist/tween/stepper.js.map +1 -1
  384. package/dist/tween/to-command.js.map +1 -1
  385. package/dist/util/clamp.js.map +1 -1
  386. package/dist/util/context.js.map +1 -1
  387. package/dist/util/csv.js.map +1 -1
  388. package/dist/util/generateList.js.map +1 -1
  389. package/dist/util/index.js.map +1 -1
  390. package/dist/util/metrics.js.map +1 -1
  391. package/dist/util/random.js.map +1 -1
  392. package/dist/util/reference.js.map +1 -1
  393. package/dist/util/scheduler.js.map +1 -1
  394. package/package.json +1 -1
  395. package/dist/attributes/audio/filters/chain.d.ts +0 -113
  396. package/dist/attributes/audio/filters/chain.d.ts.map +0 -1
  397. package/dist/attributes/audio/filters/chain.js +0 -104
  398. package/dist/attributes/audio/filters/chain.js.map +0 -1
  399. package/dist/attributes/audio/filters/curve.d.ts +0 -152
  400. package/dist/attributes/audio/filters/curve.d.ts.map +0 -1
  401. package/dist/attributes/audio/filters/curve.js +0 -250
  402. package/dist/attributes/audio/filters/curve.js.map +0 -1
  403. package/dist/attributes/audio/filters/implementations/echo.d.ts +0 -14
  404. package/dist/attributes/audio/filters/implementations/echo.d.ts.map +0 -1
  405. package/dist/attributes/audio/filters/implementations/echo.js +0 -11
  406. package/dist/attributes/audio/filters/implementations/echo.js.map +0 -1
  407. package/dist/attributes/audio/filters/implementations/gain.d.ts +0 -10
  408. package/dist/attributes/audio/filters/implementations/gain.d.ts.map +0 -1
  409. package/dist/attributes/audio/filters/implementations/gain.js +0 -6
  410. package/dist/attributes/audio/filters/implementations/gain.js.map +0 -1
  411. package/dist/attributes/audio/filters/implementations/highpass.d.ts +0 -12
  412. package/dist/attributes/audio/filters/implementations/highpass.d.ts.map +0 -1
  413. package/dist/attributes/audio/filters/implementations/highpass.js +0 -10
  414. package/dist/attributes/audio/filters/implementations/highpass.js.map +0 -1
  415. package/dist/attributes/audio/filters/implementations/lowpass.d.ts +0 -12
  416. package/dist/attributes/audio/filters/implementations/lowpass.d.ts.map +0 -1
  417. package/dist/attributes/audio/filters/implementations/lowpass.js +0 -10
  418. package/dist/attributes/audio/filters/implementations/lowpass.js.map +0 -1
  419. package/dist/attributes/audio/filters/implementations/speed.d.ts +0 -18
  420. package/dist/attributes/audio/filters/implementations/speed.d.ts.map +0 -1
  421. package/dist/attributes/audio/filters/implementations/speed.js +0 -6
  422. package/dist/attributes/audio/filters/implementations/speed.js.map +0 -1
  423. package/dist/attributes/audio/filters/implementations/tremolo.d.ts +0 -12
  424. package/dist/attributes/audio/filters/implementations/tremolo.d.ts.map +0 -1
  425. package/dist/attributes/audio/filters/implementations/tremolo.js +0 -10
  426. package/dist/attributes/audio/filters/implementations/tremolo.js.map +0 -1
  427. package/dist/attributes/audio/filters/index.d.ts +0 -22
  428. package/dist/attributes/audio/filters/index.d.ts.map +0 -1
  429. package/dist/attributes/audio/filters/index.js +0 -8
  430. package/dist/attributes/audio/filters/index.js.map +0 -1
  431. package/dist/attributes/audio/filters/registry.d.ts +0 -36
  432. package/dist/attributes/audio/filters/registry.d.ts.map +0 -1
  433. package/dist/attributes/audio/filters/registry.js +0 -82
  434. package/dist/attributes/audio/filters/registry.js.map +0 -1
  435. package/dist/attributes/audio/filters/union.d.ts +0 -18
  436. package/dist/attributes/audio/filters/union.d.ts.map +0 -1
  437. package/dist/attributes/audio/filters/union.js +0 -28
  438. package/dist/attributes/audio/filters/union.js.map +0 -1
  439. package/dist/attributes/shape/sksl-uniforms.d.ts +0 -146
  440. package/dist/attributes/shape/sksl-uniforms.d.ts.map +0 -1
  441. package/dist/attributes/shape/sksl-uniforms.js +0 -0
  442. package/dist/attributes/shape/sksl-uniforms.js.map +0 -1
  443. package/dist/browser/chunks/chunk-AOT33LMS.js +0 -13
  444. package/dist/browser/chunks/chunk-AOT33LMS.js.map +0 -7
  445. package/dist/browser/chunks/chunk-GKM6UZJR.js +0 -6
  446. package/dist/browser/chunks/chunk-GKM6UZJR.js.map +0 -7
  447. package/dist/browser/chunks/chunk-LKUYVFU3.js.map +0 -7
  448. package/dist/browser/chunks/chunk-ZRPZPWZU.js +0 -3
  449. package/dist/browser/chunks/chunk-ZRPZPWZU.js.map +0 -7
  450. package/dist/component/api.d.ts +0 -508
  451. package/dist/component/api.d.ts.map +0 -1
  452. package/dist/component/api.js +0 -4
  453. package/dist/component/api.js.map +0 -1
  454. package/dist/component/builtins/audio.d.ts +0 -26
  455. package/dist/component/builtins/audio.d.ts.map +0 -1
  456. package/dist/component/builtins/audio.js +0 -41
  457. package/dist/component/builtins/audio.js.map +0 -1
  458. package/dist/component/builtins/canvas3d.d.ts +0 -98
  459. package/dist/component/builtins/canvas3d.d.ts.map +0 -1
  460. package/dist/component/builtins/canvas3d.js +0 -21
  461. package/dist/component/builtins/canvas3d.js.map +0 -1
  462. package/dist/component/builtins/composite.d.ts +0 -56
  463. package/dist/component/builtins/composite.d.ts.map +0 -1
  464. package/dist/component/builtins/composite.js +0 -25
  465. package/dist/component/builtins/composite.js.map +0 -1
  466. package/dist/component/builtins/geometry.d.ts +0 -505
  467. package/dist/component/builtins/geometry.d.ts.map +0 -1
  468. package/dist/component/builtins/geometry.js +0 -107
  469. package/dist/component/builtins/geometry.js.map +0 -1
  470. package/dist/component/builtins/layout.d.ts +0 -88
  471. package/dist/component/builtins/layout.d.ts.map +0 -1
  472. package/dist/component/builtins/layout.js +0 -84
  473. package/dist/component/builtins/layout.js.map +0 -1
  474. package/dist/component/builtins/media.d.ts +0 -95
  475. package/dist/component/builtins/media.d.ts.map +0 -1
  476. package/dist/component/builtins/media.js +0 -149
  477. package/dist/component/builtins/media.js.map +0 -1
  478. package/dist/component/builtins/providers.d.ts +0 -23
  479. package/dist/component/builtins/providers.d.ts.map +0 -1
  480. package/dist/component/builtins/providers.js +0 -30
  481. package/dist/component/builtins/providers.js.map +0 -1
  482. package/dist/component/builtins/text.d.ts +0 -193
  483. package/dist/component/builtins/text.d.ts.map +0 -1
  484. package/dist/component/builtins/text.js +0 -113
  485. package/dist/component/builtins/text.js.map +0 -1
  486. package/dist/component/builtins/three.d.ts +0 -1085
  487. package/dist/component/builtins/three.d.ts.map +0 -1
  488. package/dist/component/builtins/three.js +0 -265
  489. package/dist/component/builtins/three.js.map +0 -1
  490. package/dist/component/clip-of.d.ts +0 -5
  491. package/dist/component/clip-of.d.ts.map +0 -1
  492. package/dist/component/clip-of.js +0 -33
  493. package/dist/component/clip-of.js.map +0 -1
  494. package/dist/component/commands-for.d.ts +0 -19
  495. package/dist/component/commands-for.d.ts.map +0 -1
  496. package/dist/component/commands-for.js +0 -5
  497. package/dist/component/commands-for.js.map +0 -1
  498. package/dist/component/component-audio.d.ts +0 -9
  499. package/dist/component/component-audio.d.ts.map +0 -1
  500. package/dist/component/component-audio.js +0 -18
  501. package/dist/component/component-audio.js.map +0 -1
  502. package/dist/component/component2d.d.ts +0 -9
  503. package/dist/component/component2d.d.ts.map +0 -1
  504. package/dist/component/component2d.js +0 -239
  505. package/dist/component/component2d.js.map +0 -1
  506. package/dist/component/component3d.d.ts +0 -9
  507. package/dist/component/component3d.d.ts.map +0 -1
  508. package/dist/component/component3d.js +0 -99
  509. package/dist/component/component3d.js.map +0 -1
  510. package/dist/component/factory.d.ts +0 -63
  511. package/dist/component/factory.d.ts.map +0 -1
  512. package/dist/component/factory.js +0 -313
  513. package/dist/component/factory.js.map +0 -1
  514. package/dist/component/modules/aim.d.ts +0 -30
  515. package/dist/component/modules/aim.d.ts.map +0 -1
  516. package/dist/component/modules/aim.js +0 -39
  517. package/dist/component/modules/aim.js.map +0 -1
  518. package/dist/component/modules/corners.d.ts +0 -13
  519. package/dist/component/modules/corners.d.ts.map +0 -1
  520. package/dist/component/modules/corners.js +0 -12
  521. package/dist/component/modules/corners.js.map +0 -1
  522. package/dist/component/modules/flow.d.ts +0 -26
  523. package/dist/component/modules/flow.d.ts.map +0 -1
  524. package/dist/component/modules/flow.js +0 -55
  525. package/dist/component/modules/flow.js.map +0 -1
  526. package/dist/component/modules/material.d.ts +0 -40
  527. package/dist/component/modules/material.d.ts.map +0 -1
  528. package/dist/component/modules/material.js +0 -75
  529. package/dist/component/modules/material.js.map +0 -1
  530. package/dist/component/modules/paint.d.ts +0 -71
  531. package/dist/component/modules/paint.d.ts.map +0 -1
  532. package/dist/component/modules/paint.js +0 -106
  533. package/dist/component/modules/paint.js.map +0 -1
  534. package/dist/component/modules/shapes.d.ts +0 -31
  535. package/dist/component/modules/shapes.d.ts.map +0 -1
  536. package/dist/component/modules/shapes.js +0 -43
  537. package/dist/component/modules/shapes.js.map +0 -1
  538. package/dist/component/modules/text-layout.d.ts +0 -26
  539. package/dist/component/modules/text-layout.d.ts.map +0 -1
  540. package/dist/component/modules/text-layout.js +0 -57
  541. package/dist/component/modules/text-layout.js.map +0 -1
  542. package/dist/component/modules/text-style.d.ts +0 -48
  543. package/dist/component/modules/text-style.d.ts.map +0 -1
  544. package/dist/component/modules/text-style.js +0 -63
  545. package/dist/component/modules/text-style.js.map +0 -1
  546. package/dist/component/modules/three-entries.d.ts +0 -23
  547. package/dist/component/modules/three-entries.d.ts.map +0 -1
  548. package/dist/component/modules/three-entries.js +0 -41
  549. package/dist/component/modules/three-entries.js.map +0 -1
  550. package/dist/component/modules/view3d.d.ts +0 -55
  551. package/dist/component/modules/view3d.d.ts.map +0 -1
  552. package/dist/component/modules/view3d.js +0 -160
  553. package/dist/component/modules/view3d.js.map +0 -1
  554. package/dist/component/timeline.d.ts +0 -22
  555. package/dist/component/timeline.d.ts.map +0 -1
  556. package/dist/component/timeline.js +0 -128
  557. package/dist/component/timeline.js.map +0 -1
  558. package/dist/component/type-def.d.ts +0 -26
  559. package/dist/component/type-def.d.ts.map +0 -1
  560. package/dist/component/type-def.js +0 -16
  561. package/dist/component/type-def.js.map +0 -1
  562. package/dist/component/types.d.ts +0 -91
  563. package/dist/component/types.d.ts.map +0 -1
  564. package/dist/component/types.js +0 -88
  565. package/dist/component/types.js.map +0 -1
  566. package/dist/component/views.d.ts +0 -121
  567. package/dist/component/views.d.ts.map +0 -1
  568. package/dist/component/views.js +0 -413
  569. package/dist/component/views.js.map +0 -1
  570. package/dist/document/withdraw.d.ts +0 -28
  571. package/dist/document/withdraw.d.ts.map +0 -1
  572. package/dist/document/withdraw.js +0 -61
  573. package/dist/document/withdraw.js.map +0 -1
  574. package/dist/jsx/jsx-dev-runtime.d.ts +0 -3
  575. package/dist/jsx/jsx-dev-runtime.d.ts.map +0 -1
  576. package/dist/jsx/jsx-dev-runtime.js +0 -3
  577. package/dist/jsx/jsx-dev-runtime.js.map +0 -1
  578. package/dist/jsx/jsx-runtime.d.ts +0 -27
  579. package/dist/jsx/jsx-runtime.d.ts.map +0 -1
  580. package/dist/jsx/jsx-runtime.js +0 -26
  581. package/dist/jsx/jsx-runtime.js.map +0 -1
  582. package/dist/nodes/2d/node-lifecycle.d.ts +0 -46
  583. package/dist/nodes/2d/node-lifecycle.d.ts.map +0 -1
  584. package/dist/nodes/2d/node-lifecycle.js +0 -264
  585. package/dist/nodes/2d/node-lifecycle.js.map +0 -1
  586. package/dist/nodes/2d/node-motion.d.ts +0 -56
  587. package/dist/nodes/2d/node-motion.d.ts.map +0 -1
  588. package/dist/nodes/2d/node-motion.js +0 -86
  589. package/dist/nodes/2d/node-motion.js.map +0 -1
  590. package/dist/nodes/2d/node-render.d.ts +0 -44
  591. package/dist/nodes/2d/node-render.d.ts.map +0 -1
  592. package/dist/nodes/2d/node-render.js +0 -80
  593. package/dist/nodes/2d/node-render.js.map +0 -1
  594. package/dist/nodes/2d/node-space.d.ts +0 -63
  595. package/dist/nodes/2d/node-space.d.ts.map +0 -1
  596. package/dist/nodes/2d/node-space.js +0 -131
  597. package/dist/nodes/2d/node-space.js.map +0 -1
  598. package/dist/nodes/2d/node-transform.d.ts +0 -55
  599. package/dist/nodes/2d/node-transform.d.ts.map +0 -1
  600. package/dist/nodes/2d/node-transform.js +0 -73
  601. package/dist/nodes/2d/node-transform.js.map +0 -1
  602. package/dist/nodes/2d/node2d.d.ts +0 -1111
  603. package/dist/nodes/2d/node2d.d.ts.map +0 -1
  604. package/dist/nodes/2d/node2d.js +0 -1665
  605. package/dist/nodes/2d/node2d.js.map +0 -1
  606. package/dist/nodes/2d/paint-node.d.ts +0 -142
  607. package/dist/nodes/2d/paint-node.d.ts.map +0 -1
  608. package/dist/nodes/2d/paint-node.js +0 -232
  609. package/dist/nodes/2d/paint-node.js.map +0 -1
  610. package/dist/nodes/audio/audio-bus.d.ts +0 -28
  611. package/dist/nodes/audio/audio-bus.d.ts.map +0 -1
  612. package/dist/nodes/audio/audio-bus.js +0 -33
  613. package/dist/nodes/audio/audio-bus.js.map +0 -1
  614. package/dist/nodes/audio/index.d.ts +0 -4
  615. package/dist/nodes/audio/index.d.ts.map +0 -1
  616. package/dist/nodes/audio/index.js +0 -2
  617. package/dist/nodes/audio/index.js.map +0 -1
  618. package/dist/nodes/audio/node-audio.d.ts +0 -107
  619. package/dist/nodes/audio/node-audio.d.ts.map +0 -1
  620. package/dist/nodes/audio/node-audio.js +0 -179
  621. package/dist/nodes/audio/node-audio.js.map +0 -1
  622. package/dist/nodes/audio/sound-node.d.ts +0 -41
  623. package/dist/nodes/audio/sound-node.d.ts.map +0 -1
  624. package/dist/nodes/audio/sound-node.js +0 -71
  625. package/dist/nodes/audio/sound-node.js.map +0 -1
  626. package/dist/nodes/geometry/boolean-node.d.ts +0 -28
  627. package/dist/nodes/geometry/boolean-node.d.ts.map +0 -1
  628. package/dist/nodes/geometry/boolean-node.js +0 -81
  629. package/dist/nodes/geometry/boolean-node.js.map +0 -1
  630. package/dist/nodes/geometry/bounds-shape-node.d.ts +0 -149
  631. package/dist/nodes/geometry/bounds-shape-node.d.ts.map +0 -1
  632. package/dist/nodes/geometry/bounds-shape-node.js +0 -181
  633. package/dist/nodes/geometry/bounds-shape-node.js.map +0 -1
  634. package/dist/nodes/geometry/box-path-node.d.ts +0 -89
  635. package/dist/nodes/geometry/box-path-node.d.ts.map +0 -1
  636. package/dist/nodes/geometry/box-path-node.js +0 -116
  637. package/dist/nodes/geometry/box-path-node.js.map +0 -1
  638. package/dist/nodes/geometry/ellipse-node.d.ts +0 -18
  639. package/dist/nodes/geometry/ellipse-node.d.ts.map +0 -1
  640. package/dist/nodes/geometry/ellipse-node.js +0 -45
  641. package/dist/nodes/geometry/ellipse-node.js.map +0 -1
  642. package/dist/nodes/geometry/group-bounds.d.ts +0 -56
  643. package/dist/nodes/geometry/group-bounds.d.ts.map +0 -1
  644. package/dist/nodes/geometry/group-bounds.js +0 -87
  645. package/dist/nodes/geometry/group-bounds.js.map +0 -1
  646. package/dist/nodes/geometry/mask-node.d.ts +0 -33
  647. package/dist/nodes/geometry/mask-node.d.ts.map +0 -1
  648. package/dist/nodes/geometry/mask-node.js +0 -66
  649. package/dist/nodes/geometry/mask-node.js.map +0 -1
  650. package/dist/nodes/geometry/path-node.d.ts +0 -26
  651. package/dist/nodes/geometry/path-node.d.ts.map +0 -1
  652. package/dist/nodes/geometry/path-node.js +0 -58
  653. package/dist/nodes/geometry/path-node.js.map +0 -1
  654. package/dist/nodes/geometry/polygon-node.d.ts +0 -26
  655. package/dist/nodes/geometry/polygon-node.d.ts.map +0 -1
  656. package/dist/nodes/geometry/polygon-node.js +0 -47
  657. package/dist/nodes/geometry/polygon-node.js.map +0 -1
  658. package/dist/nodes/geometry/polygram-node.d.ts +0 -33
  659. package/dist/nodes/geometry/polygram-node.d.ts.map +0 -1
  660. package/dist/nodes/geometry/polygram-node.js +0 -52
  661. package/dist/nodes/geometry/polygram-node.js.map +0 -1
  662. package/dist/nodes/geometry/rect-node.d.ts +0 -38
  663. package/dist/nodes/geometry/rect-node.d.ts.map +0 -1
  664. package/dist/nodes/geometry/rect-node.js +0 -56
  665. package/dist/nodes/geometry/rect-node.js.map +0 -1
  666. package/dist/nodes/geometry/shape-node.d.ts +0 -71
  667. package/dist/nodes/geometry/shape-node.d.ts.map +0 -1
  668. package/dist/nodes/geometry/shape-node.js +0 -140
  669. package/dist/nodes/geometry/shape-node.js.map +0 -1
  670. package/dist/nodes/geometry/shape-outline.d.ts +0 -93
  671. package/dist/nodes/geometry/shape-outline.d.ts.map +0 -1
  672. package/dist/nodes/geometry/shape-outline.js +0 -470
  673. package/dist/nodes/geometry/shape-outline.js.map +0 -1
  674. package/dist/nodes/index.d.ts +0 -53
  675. package/dist/nodes/index.d.ts.map +0 -1
  676. package/dist/nodes/index.js +0 -35
  677. package/dist/nodes/index.js.map +0 -1
  678. package/dist/nodes/layout/camera-node.d.ts +0 -80
  679. package/dist/nodes/layout/camera-node.d.ts.map +0 -1
  680. package/dist/nodes/layout/camera-node.js +0 -153
  681. package/dist/nodes/layout/camera-node.js.map +0 -1
  682. package/dist/nodes/layout/orbit-camera-node.d.ts +0 -80
  683. package/dist/nodes/layout/orbit-camera-node.d.ts.map +0 -1
  684. package/dist/nodes/layout/orbit-camera-node.js +0 -118
  685. package/dist/nodes/layout/orbit-camera-node.js.map +0 -1
  686. package/dist/nodes/layout/rotated-box.d.ts +0 -20
  687. package/dist/nodes/layout/rotated-box.d.ts.map +0 -1
  688. package/dist/nodes/layout/rotated-box.js +0 -76
  689. package/dist/nodes/layout/rotated-box.js.map +0 -1
  690. package/dist/nodes/media/video-node.d.ts +0 -229
  691. package/dist/nodes/media/video-node.d.ts.map +0 -1
  692. package/dist/nodes/media/video-node.js +0 -350
  693. package/dist/nodes/media/video-node.js.map +0 -1
  694. package/dist/nodes/node/declare-paints.d.ts +0 -19
  695. package/dist/nodes/node/declare-paints.d.ts.map +0 -1
  696. package/dist/nodes/node/declare-paints.js +0 -27
  697. package/dist/nodes/node/declare-paints.js.map +0 -1
  698. package/dist/nodes/node/node-editor-state.d.ts +0 -53
  699. package/dist/nodes/node/node-editor-state.d.ts.map +0 -1
  700. package/dist/nodes/node/node-editor-state.js +0 -23
  701. package/dist/nodes/node/node-editor-state.js.map +0 -1
  702. package/dist/nodes/node/node-reactive.d.ts +0 -89
  703. package/dist/nodes/node/node-reactive.d.ts.map +0 -1
  704. package/dist/nodes/node/node-reactive.js +0 -135
  705. package/dist/nodes/node/node-reactive.js.map +0 -1
  706. package/dist/nodes/node/node-time.d.ts +0 -39
  707. package/dist/nodes/node/node-time.d.ts.map +0 -1
  708. package/dist/nodes/node/node-time.js +0 -14
  709. package/dist/nodes/node/node-time.js.map +0 -1
  710. package/dist/nodes/node/node-walk.d.ts +0 -46
  711. package/dist/nodes/node/node-walk.d.ts.map +0 -1
  712. package/dist/nodes/node/node-walk.js +0 -74
  713. package/dist/nodes/node/node-walk.js.map +0 -1
  714. package/dist/nodes/node/node.d.ts +0 -445
  715. package/dist/nodes/node/node.d.ts.map +0 -1
  716. package/dist/nodes/node/node.js +0 -745
  717. package/dist/nodes/node/node.js.map +0 -1
  718. package/dist/nodes/node/text-defaults.d.ts +0 -32
  719. package/dist/nodes/node/text-defaults.d.ts.map +0 -1
  720. package/dist/nodes/node/text-defaults.js +0 -37
  721. package/dist/nodes/node/text-defaults.js.map +0 -1
  722. package/dist/nodes/root/canvas2d-node.d.ts +0 -163
  723. package/dist/nodes/root/canvas2d-node.d.ts.map +0 -1
  724. package/dist/nodes/root/canvas2d-node.js +0 -264
  725. package/dist/nodes/root/canvas2d-node.js.map +0 -1
  726. package/dist/nodes/root/provider-node.d.ts +0 -47
  727. package/dist/nodes/root/provider-node.d.ts.map +0 -1
  728. package/dist/nodes/root/provider-node.js +0 -63
  729. package/dist/nodes/root/provider-node.js.map +0 -1
  730. package/dist/nodes/root/theme-provider-node.d.ts +0 -29
  731. package/dist/nodes/root/theme-provider-node.d.ts.map +0 -1
  732. package/dist/nodes/root/theme-provider-node.js +0 -43
  733. package/dist/nodes/root/theme-provider-node.js.map +0 -1
  734. package/dist/nodes/text/default-text-style-node.d.ts +0 -103
  735. package/dist/nodes/text/default-text-style-node.d.ts.map +0 -1
  736. package/dist/nodes/text/default-text-style-node.js +0 -146
  737. package/dist/nodes/text/default-text-style-node.js.map +0 -1
  738. package/dist/nodes/text/number-format.d.ts +0 -66
  739. package/dist/nodes/text/number-format.d.ts.map +0 -1
  740. package/dist/nodes/text/number-format.js +0 -227
  741. package/dist/nodes/text/number-format.js.map +0 -1
  742. package/dist/nodes/text/number-node.d.ts +0 -94
  743. package/dist/nodes/text/number-node.d.ts.map +0 -1
  744. package/dist/nodes/text/number-node.js +0 -86
  745. package/dist/nodes/text/number-node.js.map +0 -1
  746. package/dist/nodes/text/number-pattern.d.ts +0 -51
  747. package/dist/nodes/text/number-pattern.d.ts.map +0 -1
  748. package/dist/nodes/text/number-pattern.js +0 -77
  749. package/dist/nodes/text/number-pattern.js.map +0 -1
  750. package/dist/nodes/text/richtext-node.d.ts +0 -68
  751. package/dist/nodes/text/richtext-node.d.ts.map +0 -1
  752. package/dist/nodes/text/richtext-node.js +0 -78
  753. package/dist/nodes/text/richtext-node.js.map +0 -1
  754. package/dist/nodes/text/text-base.d.ts +0 -118
  755. package/dist/nodes/text/text-base.d.ts.map +0 -1
  756. package/dist/nodes/text/text-base.js +0 -153
  757. package/dist/nodes/text/text-base.js.map +0 -1
  758. package/dist/nodes/text/text-layout.d.ts +0 -87
  759. package/dist/nodes/text/text-layout.d.ts.map +0 -1
  760. package/dist/nodes/text/text-layout.js +0 -368
  761. package/dist/nodes/text/text-layout.js.map +0 -1
  762. package/dist/nodes/text/text-node.d.ts +0 -84
  763. package/dist/nodes/text/text-node.d.ts.map +0 -1
  764. package/dist/nodes/text/text-node.js +0 -188
  765. package/dist/nodes/text/text-node.js.map +0 -1
  766. package/dist/nodes/text/text-selection.d.ts +0 -125
  767. package/dist/nodes/text/text-selection.d.ts.map +0 -1
  768. package/dist/nodes/text/text-selection.js +0 -209
  769. package/dist/nodes/text/text-selection.js.map +0 -1
  770. package/dist/nodes/three/camera-nodes.d.ts +0 -109
  771. package/dist/nodes/three/camera-nodes.d.ts.map +0 -1
  772. package/dist/nodes/three/camera-nodes.js +0 -112
  773. package/dist/nodes/three/camera-nodes.js.map +0 -1
  774. package/dist/nodes/three/canvas3d-node.d.ts +0 -295
  775. package/dist/nodes/three/canvas3d-node.d.ts.map +0 -1
  776. package/dist/nodes/three/canvas3d-node.js +0 -486
  777. package/dist/nodes/three/canvas3d-node.js.map +0 -1
  778. package/dist/nodes/three/drawable-nodes.d.ts +0 -173
  779. package/dist/nodes/three/drawable-nodes.d.ts.map +0 -1
  780. package/dist/nodes/three/drawable-nodes.js +0 -284
  781. package/dist/nodes/three/drawable-nodes.js.map +0 -1
  782. package/dist/nodes/three/environment-nodes.d.ts +0 -106
  783. package/dist/nodes/three/environment-nodes.d.ts.map +0 -1
  784. package/dist/nodes/three/environment-nodes.js +0 -134
  785. package/dist/nodes/three/environment-nodes.js.map +0 -1
  786. package/dist/nodes/three/geometry-nodes.d.ts +0 -197
  787. package/dist/nodes/three/geometry-nodes.d.ts.map +0 -1
  788. package/dist/nodes/three/geometry-nodes.js +0 -322
  789. package/dist/nodes/three/geometry-nodes.js.map +0 -1
  790. package/dist/nodes/three/grid-geometry3d.d.ts +0 -62
  791. package/dist/nodes/three/grid-geometry3d.d.ts.map +0 -1
  792. package/dist/nodes/three/grid-geometry3d.js +0 -114
  793. package/dist/nodes/three/grid-geometry3d.js.map +0 -1
  794. package/dist/nodes/three/group3d.d.ts +0 -23
  795. package/dist/nodes/three/group3d.d.ts.map +0 -1
  796. package/dist/nodes/three/group3d.js +0 -21
  797. package/dist/nodes/three/group3d.js.map +0 -1
  798. package/dist/nodes/three/light-nodes.d.ts +0 -120
  799. package/dist/nodes/three/light-nodes.d.ts.map +0 -1
  800. package/dist/nodes/three/light-nodes.js +0 -173
  801. package/dist/nodes/three/light-nodes.js.map +0 -1
  802. package/dist/nodes/three/mesh3d.d.ts +0 -117
  803. package/dist/nodes/three/mesh3d.d.ts.map +0 -1
  804. package/dist/nodes/three/mesh3d.js +0 -147
  805. package/dist/nodes/three/mesh3d.js.map +0 -1
  806. package/dist/nodes/three/node3d.d.ts +0 -230
  807. package/dist/nodes/three/node3d.d.ts.map +0 -1
  808. package/dist/nodes/three/node3d.js +0 -337
  809. package/dist/nodes/three/node3d.js.map +0 -1
  810. package/dist/render/descriptors/latex.d.ts +0 -6
  811. package/dist/render/descriptors/latex.d.ts.map +0 -1
  812. package/dist/render/descriptors/latex.js +0 -2
  813. package/dist/render/descriptors/latex.js.map +0 -1
  814. package/dist/tween/seekable.d.ts +0 -81
  815. package/dist/tween/seekable.d.ts.map +0 -1
  816. package/dist/tween/seekable.js +0 -137
  817. package/dist/tween/seekable.js.map +0 -1
@@ -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. 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
+ {"version":3,"file":"surface.js","sourceRoot":"","sources":["../../src/render/surface.ts"],"names":[],"mappings":"","sourcesContent":["import { Size2D } from \"@/attributes/layout/size\";\n\n/**\n * The host-facing half of a render context: where pixels land, and how the\n * preview frames them.\n *\n * Split out from `CanvasRenderContext2D` because a *node* never touches any of\n * it — a node draws, and the host decides what it is drawing into. A `Session`\n * owns one of these; a node is handed a `RenderContext2D`.\n *\n * **`mount` takes `unknown`, not `HTMLCanvasElement`.** `packages/core` compiles\n * with `lib: [\"ES2022\"]` and no DOM, deliberately, so this layer cannot name a\n * canvas — and it does not need to: a browser backend takes a canvas, a headless\n * one takes a size. Each narrows the argument at its own `mount`, where the\n * relevant types exist. A backend's context satisfies this structurally, so it\n * never imports it.\n */\nexport interface RenderSurface {\n mount(target: unknown): void;\n unmount(): void;\n /** Device pixels per viewport unit. Rasterization, not zoom — see {@link view}. */\n pixelRatio: number;\n /** Preview pan/zoom over the frame. Costs a repaint, never a surface rebuild. */\n view: { zoom: number; x: number; y: number };\n /** The frame's own size when the surface is a window onto it, else `null`. */\n frame: Size2D | null;\n clipToFrame: boolean;\n /**\n * What the frame's backdrop is painted with. `\"transparent\"` lets whatever\n * is behind the canvas show through where nothing was drawn.\n */\n frameBackground: \"black\" | \"transparent\";\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"text-defaults.js","sourceRoot":"","sources":["../../src/render/text-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AASrF;;;;;GAKG;AACH,MAAM,SAAS,GAAG;IACd,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe;CAC1B,CAAC;AAE/C,2EAA2E;AAC3E,MAAM,mBAAmB,GAAG;IACxB,YAAY,EAAE,WAAW;CACiB,CAAC;AAE/C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAAoB,EAAE,KAAgB;IAC5E,oEAAoE;IACpE,6EAA6E;IAC7E,mEAAmE;IACnE,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAErE,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC;IAC3B,IAAI,IAAI,GAAwB,IAAI,CAAC;IACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QAClB,IAAI,EAAE,CAAC,IAAI,KAAK,MAAM,IAAI,EAAE,CAAC,IAAI,KAAK,UAAU;YAAE,SAAS;QAC3D,MAAM,SAAS,GAAG,cAAc,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5D,IAAI,CAAC,kBAAkB,CAAC,SAAS,C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AAc,EAAE,KAAgB,EAAE,IAA+B;IAChF,MAAM,OAAO,GAAG,MAAiC,CAAC;IAClD,IAAI,GAAG,GAAmC,IAAI,CAAC;IAC/C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,SAAS;QACzC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,CAAC,GAAG,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC1C,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["import { EMPTY_TEXT_STYLE, TEXT_SHAPING_KEYS, textOps } from \"@/attributes/text/ops\";\r\nimport type { ResolvedTextSpan, TextShapingKey, TextStyle } from \"@/attributes/text/types\";\r\nimport { Graphics2D, type GraphicsOp, type GraphicsShapeOp } from \"./graphics2d\";\r\n\r\n/** The recorded `text` op, state and all. */\r\ntype TextOp = Extract<GraphicsShapeOp, { kind: \"text\" }>;\r\n/** The recorded `richText` op, state and all. */\r\ntype RichTextOp = Extract<GraphicsShapeOp, { kind: \"richText\" }>;\r\n\r\n/**\r\n * The span-level half of {@link TEXT_SHAPING_KEYS}. A `richText` op carries its\r\n * typography per span rather than on the shape, so a default has to be filled in\r\n * span by span — except `lineHeight`/`textAlign`, which lay the block out as a\r\n * whole and so live on the op itself.\r\n */\r\nconst SPAN_KEYS = [\r\n 'fontFamily', 'fontSize', 'fontWeight', 'fontStyle', 'letterSpacing',\r\n] as const satisfies readonly TextShapingKey[];\r\n\r\n/** The `richText` op's own layout keys — the ones that aren't per-span. */\r\nconst RICHTEXT_BLOCK_KEYS = [\r\n 'lineHeight', 'textAlign',\r\n] as const satisfies readonly TextShapingKey[];\r\n\r\n/**\r\n * `graphics` with `style` filled into every `text`/`richText` op that left a\r\n * shaping field unset — the drawn-text half of `<DefaultTextStyle>`.\r\n *\r\n * A `Text` node inherits defaults through the context channel, once, at bind\r\n * time (`applyTextDefaults`); a raw `Graphics2D` has no node to bind, so it\r\n * inherits here instead, at draw time, from the scope it is drawn in. Called\r\n * from `RenderContext2D.draw`, so a custom node's `ctx.draw(...)`, an offscreen\r\n * rasterization and the precomp pass's asset walk all see the same resolved op\r\n * list — which is what makes an inherited font actually *load* rather than\r\n * merely be asked for.\r\n *\r\n * A key counts as unset only when it is `undefined`: an op that names a value\r\n * always wins, exactly as an author-set prop beats an inherited one on a node.\r\n * Returns `graphics` itself when nothing changes, which is the common case (the\r\n * scene sets no defaults, or every op already names its own).\r\n */\r\nexport function applyGraphicsTextDefaults(graphics: Graphics2D, style: TextStyle): Graphics2D {\r\n // Not gated on `style` alone any more: an op naming a `variant` has\r\n // something to inherit even in a scope that sets nothing, so the walk has to\r\n // happen either way. The lazy copy below is what keeps that cheap.\r\n const ambient = hasShapingDefaults(style) ? style : EMPTY_TEXT_STYLE;\r\n\r\n const ops = graphics.ops();\r\n let next: GraphicsOp[] | null = null;\r\n for (let i = 0; i < ops.length; i++) {\r\n const op = ops[i];\r\n if (op.kind !== \"text\" && op.kind !== \"richText\") continue;\r\n const effective = effectiveStyle(op.state.variant, ambient);\r\n if (!hasShapingDefaults(effective)) continue;\r\n const patched = op.kind === \"text\"\r\n ? patchText(op, effective)\r\n : patchRichText(op, effective);\r\n if (!patched) continue;\r\n // Copy lazily: an op list with nothing to fill in keeps its identity, so\r\n // a fully-specified Text node allocates nothing on the way through.\r\n if (!next) next = ops.slice();\r\n next[i] = patched;\r\n }\r\n return next ? graphics._withOps(next) : graphics;\r\n}\r\n\r\n/**\r\n * The defaults one op inherits: its `variant`'s preset laid over the enclosing\r\n * scope's.\r\n *\r\n * That order is the node ladder one level down — an explicit value beats a\r\n * variant beats an inherited `<DefaultTextStyle>` — and it is why the merge is\r\n * here rather than in the caller: the ambient scope is per *subtree* while a\r\n * variant is per *op*, so they cannot be flattened before the walk.\r\n */\r\nfunction effectiveStyle(variant: string | undefined, ambient: TextStyle): TextStyle {\r\n return textOps.mergeStyle(ambient, variant ? textOps.preset(variant) : undefined);\r\n}\r\n\r\n/** Does `style` set anything a drawn text op could inherit? */\r\nfunction hasShapingDefaults(style: TextStyle): boolean {\r\n for (const key of TEXT_SHAPING_KEYS) {\r\n if (style[key] !== undefined) return true;\r\n }\r\n return false;\r\n}\r\n\r\nfunction patchText(op: TextOp, style: TextStyle): TextOp | null {\r\n const state = fillUnset(op.state, style, TEXT_SHAPING_KEYS);\r\n return state ? { kind: \"text\", state: state as TextOp[\"state\"] } : null;\r\n}\r\n\r\nfunction patchRichText(op: RichTextOp, style: TextStyle): RichTextOp | null {\r\n let state = fillUnset(op.state, style, RICHTEXT_BLOCK_KEYS);\r\n const spans = patchSpans(op.state.spans, style);\r\n if (spans) state = { ...(state ?? op.state), spans };\r\n return state ? { kind: \"richText\", state: state as RichTextOp[\"state\"] } : null;\r\n}\r\n\r\n/** The spans with defaults filled in, or `null` when none needed any. */\r\nfunction patchSpans(\r\n spans: ResolvedTextSpan[] | undefined,\r\n style: TextStyle,\r\n): ResolvedTextSpan[] | null {\r\n if (!spans || spans.length === 0) return null;\r\n // A span has no autofit mode — it is a run inside a block, sized by the\r\n // block — so an inherited `'autofit'` is skipped rather than written through\r\n // as a bad number.\r\n const spanStyle = style.fontSize === \"autofit\" ? { ...style, fontSize: undefined } : style;\r\n let next: ResolvedTextSpan[] | null = null;\r\n for (let i = 0; i < spans.length; i++) {\r\n const patched = fillUnset(spans[i], spanStyle, SPAN_KEYS);\r\n if (patched) (next ??= spans.slice())[i] = patched as unknown as ResolvedTextSpan;\r\n }\r\n return next;\r\n}\r\n\r\n/** A copy of `target` with each of `keys` it leaves `undefined` taken from `style`, or `null` when none needed filling. */\r\nfunction fillUnset(target: object, style: TextStyle, keys: readonly TextShapingKey[]): Record<string, unknown> | null {\r\n const current = target as Record<string, unknown>;\r\n let out: Record<string, unknown> | null = null;\r\n for (const key of keys) {\r\n if (current[key] !== undefined) continue;\r\n const value = style[key];\r\n if (value === undefined) continue;\r\n (out ??= { ...current })[key] = value;\r\n }\r\n return out;\r\n}\r\n"]}
1
+ {"version":3,"file":"text-defaults.js","sourceRoot":"","sources":["../../src/render/text-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AASrF;;;;;GAKG;AACH,MAAM,SAAS,GAAG;IACd,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe;CAC1B,CAAC;AAE/C,2EAA2E;AAC3E,MAAM,mBAAmB,GAAG;IACxB,YAAY,EAAE,WAAW;CACiB,CAAC;AAE/C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAAoB,EAAE,KAAgB;IAC5E,oEAAoE;IACpE,6EAA6E;IAC7E,mEAAmE;IACnE,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAErE,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC;IAC3B,IAAI,IAAI,GAAwB,IAAI,CAAC;IACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QAClB,IAAI,EAAE,CAAC,IAAI,KAAK,MAAM,IAAI,EAAE,CAAC,IAAI,KAAK,UAAU;YAAE,SAAS;QAC3D,MAAM,SAAS,GAAG,cAAc,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5D,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC;YAAE,SAAS;QAC7C,MAAM,OAAO,GAAG,EAAE,CAAC,IAA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AiC,CAAC;IAClD,IAAI,GAAG,GAAmC,IAAI,CAAC;IAC/C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,SAAS;QACzC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,CAAC,GAAG,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC1C,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["import { EMPTY_TEXT_STYLE, TEXT_SHAPING_KEYS, textOps } from \"@/attributes/text/ops\";\nimport type { ResolvedTextSpan, TextShapingKey, TextStyle } from \"@/attributes/text/types\";\nimport { Graphics2D, type GraphicsOp, type GraphicsShapeOp } from \"./graphics2d\";\n\n/** The recorded `text` op, state and all. */\ntype TextOp = Extract<GraphicsShapeOp, { kind: \"text\" }>;\n/** The recorded `richText` op, state and all. */\ntype RichTextOp = Extract<GraphicsShapeOp, { kind: \"richText\" }>;\n\n/**\n * The span-level half of {@link TEXT_SHAPING_KEYS}. A `richText` op carries its\n * typography per span rather than on the shape, so a default has to be filled in\n * span by span — except `lineHeight`/`textAlign`, which lay the block out as a\n * whole and so live on the op itself.\n */\nconst SPAN_KEYS = [\n 'fontFamily', 'fontSize', 'fontWeight', 'fontStyle', 'letterSpacing',\n] as const satisfies readonly TextShapingKey[];\n\n/** The `richText` op's own layout keys — the ones that aren't per-span. */\nconst RICHTEXT_BLOCK_KEYS = [\n 'lineHeight', 'textAlign',\n] as const satisfies readonly TextShapingKey[];\n\n/**\n * `graphics` with `style` filled into every `text`/`richText` op that left a\n * shaping field unset — the drawn-text half of `<DefaultTextStyle>`.\n *\n * A `Text` node inherits defaults through the context channel, once, at bind\n * time (`applyTextDefaults`); a raw `Graphics2D` has no node to bind, so it\n * inherits here instead, at draw time, from the scope it is drawn in. Called\n * from `RenderContext2D.draw`, so a custom node's `ctx.draw(...)`, an offscreen\n * rasterization and the precomp pass's asset walk all see the same resolved op\n * list — which is what makes an inherited font actually *load* rather than\n * merely be asked for.\n *\n * A key counts as unset only when it is `undefined`: an op that names a value\n * always wins, exactly as an author-set prop beats an inherited one on a node.\n * Returns `graphics` itself when nothing changes, which is the common case (the\n * scene sets no defaults, or every op already names its own).\n */\nexport function applyGraphicsTextDefaults(graphics: Graphics2D, style: TextStyle): Graphics2D {\n // Not gated on `style` alone any more: an op naming a `variant` has\n // something to inherit even in a scope that sets nothing, so the walk has to\n // happen either way. The lazy copy below is what keeps that cheap.\n const ambient = hasShapingDefaults(style) ? style : EMPTY_TEXT_STYLE;\n\n const ops = graphics.ops();\n let next: GraphicsOp[] | null = null;\n for (let i = 0; i < ops.length; i++) {\n const op = ops[i];\n if (op.kind !== \"text\" && op.kind !== \"richText\") continue;\n const effective = effectiveStyle(op.state.variant, ambient);\n if (!hasShapingDefaults(effective)) continue;\n const patched = op.kind === \"text\"\n ? patchText(op, effective)\n : patchRichText(op, effective);\n if (!patched) continue;\n // Copy lazily: an op list with nothing to fill in keeps its identity, so\n // a fully-specified Text node allocates nothing on the way through.\n if (!next) next = ops.slice();\n next[i] = patched;\n }\n return next ? graphics._withOps(next) : graphics;\n}\n\n/**\n * The defaults one op inherits: its `variant`'s preset laid over the enclosing\n * scope's.\n *\n * That order is the node ladder one level down — an explicit value beats a\n * variant beats an inherited `<DefaultTextStyle>` — and it is why the merge is\n * here rather than in the caller: the ambient scope is per *subtree* while a\n * variant is per *op*, so they cannot be flattened before the walk.\n */\nfunction effectiveStyle(variant: string | undefined, ambient: TextStyle): TextStyle {\n return textOps.mergeStyle(ambient, variant ? textOps.preset(variant) : undefined);\n}\n\n/** Does `style` set anything a drawn text op could inherit? */\nfunction hasShapingDefaults(style: TextStyle): boolean {\n for (const key of TEXT_SHAPING_KEYS) {\n if (style[key] !== undefined) return true;\n }\n return false;\n}\n\nfunction patchText(op: TextOp, style: TextStyle): TextOp | null {\n const state = fillUnset(op.state, style, TEXT_SHAPING_KEYS);\n return state ? { kind: \"text\", state: state as TextOp[\"state\"] } : null;\n}\n\nfunction patchRichText(op: RichTextOp, style: TextStyle): RichTextOp | null {\n let state = fillUnset(op.state, style, RICHTEXT_BLOCK_KEYS);\n const spans = patchSpans(op.state.spans, style);\n if (spans) state = { ...(state ?? op.state), spans };\n return state ? { kind: \"richText\", state: state as RichTextOp[\"state\"] } : null;\n}\n\n/** The spans with defaults filled in, or `null` when none needed any. */\nfunction patchSpans(\n spans: ResolvedTextSpan[] | undefined,\n style: TextStyle,\n): ResolvedTextSpan[] | null {\n if (!spans || spans.length === 0) return null;\n // A span has no autofit mode — it is a run inside a block, sized by the\n // block — so an inherited `'autofit'` is skipped rather than written through\n // as a bad number.\n const spanStyle = style.fontSize === \"autofit\" ? { ...style, fontSize: undefined } : style;\n let next: ResolvedTextSpan[] | null = null;\n for (let i = 0; i < spans.length; i++) {\n const patched = fillUnset(spans[i], spanStyle, SPAN_KEYS);\n if (patched) (next ??= spans.slice())[i] = patched as unknown as ResolvedTextSpan;\n }\n return next;\n}\n\n/** A copy of `target` with each of `keys` it leaves `undefined` taken from `style`, or `null` when none needed filling. */\nfunction fillUnset(target: object, style: TextStyle, keys: readonly TextShapingKey[]): Record<string, unknown> | null {\n const current = target as Record<string, unknown>;\n let out: Record<string, unknown> | null = null;\n for (const key of keys) {\n if (current[key] !== undefined) continue;\n const value = style[key];\n if (value === undefined) continue;\n (out ??= { ...current })[key] = value;\n }\n return out;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"text-layout.js","sourceRoot":"","sources":["../../src/render/text-layout.ts"],"names":[],"mappings":"AAoDA;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,MAAuB;IAC9C,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAcD;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC5C,OAAO,OAAQ,KAAgC,EAAE,eAAe,KAAK,UAAU;QAC3E,CAAC,CAAC,KAAwB;QAC1B,CAAC,CAAC,IAAI,CAAC;AACf,CAAC","sourcesContent":["import type { TextState } from \"./descriptors/text\";\r\n\r\n/**\r\n * Where a laid-out run of text put its characters — the measurement an editor\r\n * needs in order to draw its own caret and selection over rendered glyphs.\r\n *\r\n * **Space.** Block-local canvas pixels: origin at the centre of the text block,\r\n * **y down**, before the node's own transform. That is exactly the space the\r\n * backend shapes into when handed origin `(0, 0)`, so a caret at x = 0 sits on\r\n * the block's centre line and nothing here has to know where the node is.\r\n * {@link nodeTextLayout} is what lifts it into viewport space.\r\n *\r\n * **Why carets rather than glyph boxes.** A text cursor lives *between*\r\n * characters, so a run of n characters has n + 1 positions — and the two extra\r\n * facts an editor needs (where the run starts, where it ends) are precisely the\r\n * ones a list of glyph boxes leaves implicit. Reporting the slots directly also\r\n * means the host never has to reason about advance widths, kerning or trailing\r\n * whitespace to place a cursor.\r\n */\r\n\r\n/** One laid-out line of a text block. */\r\nexport interface TextBlockLine {\r\n /**\r\n * Character range this line covers, `[start, end)`, as offsets into the\r\n * block's whole string. A hard line break is *not* part of either line.\r\n */\r\n start: number;\r\n end: number;\r\n /** Top and bottom of the line box, block-local. */\r\n top: number;\r\n bottom: number;\r\n /**\r\n * The x of every caret slot on this line, block-local, in offset order:\r\n * `carets[i]` is the slot at character `start + i`, so there are\r\n * `end - start + 1` of them — one before each character plus one after the\r\n * last. Ordered left-to-right; bidirectional text is not modelled in v1.\r\n */\r\n carets: number[];\r\n}\r\n\r\n/**\r\n * A shaped text block: its lines, and the size the shaping produced.\r\n *\r\n * `width`/`height` are the block's own extent, which is what a hugging node\r\n * measures to — not the box it may have been aligned within.\r\n */\r\nexport interface TextBlockLayout {\r\n lines: TextBlockLine[];\r\n width: number;\r\n height: number;\r\n}\r\n\r\n/**\r\n * The caret slot count implied by a layout — i.e. one past the last character.\r\n *\r\n * Lines exclude their line break, so summing their slots would count the breaks\r\n * twice and lose the final position; this reads it off the last line instead.\r\n */\r\nexport function caretCount(layout: TextBlockLayout): number {\r\n const last = layout.lines[layout.lines.length - 1];\r\n return last ? last.end + 1 : 1;\r\n}\r\n\r\n/**\r\n * Something that can report where a shaped text block put its characters.\r\n *\r\n * Narrower than {@link RenderContext2D}, which is the only real implementation:\r\n * `nodeTextLayout` needs exactly this one call, and typing it against the whole\r\n * render context would make a caret measurement look like it required a\r\n * renderer. It does not — it requires a shaper.\r\n */\r\nexport interface TextBlockSource {\r\n layoutTextBlock(state: Partial<TextState>): TextBlockLayout | null;\r\n}\r\n\r\n/**\r\n * Narrow `value` to a {@link TextBlockSource}, or `null` when it cannot report\r\n * glyph positions.\r\n *\r\n * A capability check rather than a cast, because it really is one: a\r\n * {@link MeasureContext2D} answers how *wide* text comes out, which every backend can\r\n * do, while reporting where each character *landed* needs a shaper that keeps\r\n * its line boxes. A host handed a measurer that has no such shaper should get\r\n * \"no caret model here\", not a crash.\r\n */\r\nexport function asTextBlockSource(value: unknown): TextBlockSource | null {\r\n return typeof (value as TextBlockSource | null)?.layoutTextBlock === \"function\"\r\n ? value as TextBlockSource\r\n : null;\r\n}\r\n"]}
1
+ {"version":3,"file":"text-layout.js","sourceRoot":"","sources":["../../src/render/text-layout.ts"],"names":[],"mappings":"AAoDA;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,MAAuB;IAC9C,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAcD;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC5C,OAAO,OAAQ,KAAgC,EAAE,eAAe,KAAK,UAAU;QAC3E,CAAC,CAAC,KAAwB;QAC1B,CAAC,CAAC,IAAI,CAAC;AACf,CAAC","sourcesContent":["import type { TextState } from \"./descriptors/text\";\n\n/**\n * Where a laid-out run of text put its characters — the measurement an editor\n * needs in order to draw its own caret and selection over rendered glyphs.\n *\n * **Space.** Block-local canvas pixels: origin at the centre of the text block,\n * **y down**, before the node's own transform. That is exactly the space the\n * backend shapes into when handed origin `(0, 0)`, so a caret at x = 0 sits on\n * the block's centre line and nothing here has to know where the node is.\n * {@link nodeTextLayout} is what lifts it into viewport space.\n *\n * **Why carets rather than glyph boxes.** A text cursor lives *between*\n * characters, so a run of n characters has n + 1 positions — and the two extra\n * facts an editor needs (where the run starts, where it ends) are precisely the\n * ones a list of glyph boxes leaves implicit. Reporting the slots directly also\n * means the host never has to reason about advance widths, kerning or trailing\n * whitespace to place a cursor.\n */\n\n/** One laid-out line of a text block. */\nexport interface TextBlockLine {\n /**\n * Character range this line covers, `[start, end)`, as offsets into the\n * block's whole string. A hard line break is *not* part of either line.\n */\n start: number;\n end: number;\n /** Top and bottom of the line box, block-local. */\n top: number;\n bottom: number;\n /**\n * The x of every caret slot on this line, block-local, in offset order:\n * `carets[i]` is the slot at character `start + i`, so there are\n * `end - start + 1` of them — one before each character plus one after the\n * last. Ordered left-to-right; bidirectional text is not modelled in v1.\n */\n carets: number[];\n}\n\n/**\n * A shaped text block: its lines, and the size the shaping produced.\n *\n * `width`/`height` are the block's own extent, which is what a hugging node\n * measures to — not the box it may have been aligned within.\n */\nexport interface TextBlockLayout {\n lines: TextBlockLine[];\n width: number;\n height: number;\n}\n\n/**\n * The caret slot count implied by a layout — i.e. one past the last character.\n *\n * Lines exclude their line break, so summing their slots would count the breaks\n * twice and lose the final position; this reads it off the last line instead.\n */\nexport function caretCount(layout: TextBlockLayout): number {\n const last = layout.lines[layout.lines.length - 1];\n return last ? last.end + 1 : 1;\n}\n\n/**\n * Something that can report where a shaped text block put its characters.\n *\n * Narrower than {@link RenderContext2D}, which is the only real implementation:\n * `nodeTextLayout` needs exactly this one call, and typing it against the whole\n * render context would make a caret measurement look like it required a\n * renderer. It does not — it requires a shaper.\n */\nexport interface TextBlockSource {\n layoutTextBlock(state: Partial<TextState>): TextBlockLayout | null;\n}\n\n/**\n * Narrow `value` to a {@link TextBlockSource}, or `null` when it cannot report\n * glyph positions.\n *\n * A capability check rather than a cast, because it really is one: a\n * {@link MeasureContext2D} answers how *wide* text comes out, which every backend can\n * do, while reporting where each character *landed* needs a shaper that keeps\n * its line boxes. A host handed a measurer that has no such shaper should get\n * \"no caret model here\", not a crash.\n */\nexport function asTextBlockSource(value: unknown): TextBlockSource | null {\n return typeof (value as TextBlockSource | null)?.layoutTextBlock === \"function\"\n ? value as TextBlockSource\n : null;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"bounds3d.js","sourceRoot":"","sources":["../../src/render3d/bounds3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAmB,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAgB,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,cAAc,EAAgB,MAAM,WAAW,CAAC;AAkCzD,yEAAyE;AACzE,MAAM,UAAU,YAAY,CAAC,EAAU,EAAE,EAAU,EAAE,EAAU;IAC3D,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC;AAC7E,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,SAAS,CAAC,CAAc,EAAE,CAAc;IACpD,IAAI,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C,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;AACtF,CAAC;AAED,yCAAyC;AACzC,SAAS,UAAU,CAAC,GAAS,EAAE,EAAU;IACrC,OAAO;QACH,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QAChE,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;KACnE,CAAC;AACN,CAAC","sourcesContent":["import { cylinderRadii, type Geometry3D } from \"./geometry\";\r\nimport { applyMatrix4, type Matrix4 } from \"./matrix4\";\r\nimport { resolveVector3, type Vector3 } from \"./vector3\";\r\n\r\n/**\r\n * Axis-aligned bounds for the 3D descriptors — the \"how big is it, and where\" an\r\n * editor needs in order to put a box round a mesh it did not build.\r\n *\r\n * **Analytic, not sampled.** Every primitive's extent falls straight out of its\r\n * parameters, so this is a table of formulas rather than a walk over vertices,\r\n * and it costs nothing to ask per pointer move. The defaults each one falls back\r\n * to are *three's* defaults, not invented here, because a descriptor that omits\r\n * `radius` renders at three's 1 and a box drawn round a different number would\r\n * be a box in the wrong place — see the note on each.\r\n *\r\n * **Conservative where it is not exact.** A partial sweep (`thetaLength` on a\r\n * sphere, `arc` on a torus) is bounded by the full figure rather than by the\r\n * wedge actually drawn: the exact answer is an arc-endpoint problem per shape\r\n * per axis, and the cost of getting it wrong is a selection box that *cuts\r\n * through* the mesh, where the cost of over-reporting is one that sits a little\r\n * loose. Over-reporting is the safe direction, and it is the direction taken\r\n * everywhere here.\r\n *\r\n * **`null` means \"no answer\", not \"empty\".** Three descriptors genuinely cannot\r\n * be measured without something this package does not have: a loaded model file,\r\n * a rasterized path, or a user callback that may read the frame clock. A caller\r\n * that gets `null` draws no box, which is the honest outcome — a wrong box is\r\n * worse than none.\r\n */\r\n\r\n/** An axis-aligned box. `min` is corner-wise minimum, not a point on the mesh. */\r\nexport interface Box3 {\r\n min: Vector3;\r\n max: Vector3;\r\n}\r\n\r\n/** @internal A box centred on the origin with the given half-extents. */\r\nexport function centeredBox3(hx: number, hy: number, hz: number): Box3 {\r\n return { min: { x: -hx, y: -hy, z: -hz }, max: { x: hx, y: hy, z: hz } };\r\n}\r\n\r\n/** @internal The union of two boxes; either may be `null`. */\r\nexport function unionBox3(a: Box3 | null, b: Box3 | null): Box3 | null {\r\n if (!a) return b;\r\n if (!b) return a;\r\n return {\r\n min: { x: Math.min(a.min.x, b.min.x), y: Math.min(a.min.y, b.min.y), z: Math.min(a.min.z, b.min.z) },\r\n max: { x: Math.max(a.max.x, b.max.x), y: Math.max(a.max.y, b.max.y), z: Math.max(a.max.z, b.max.z) },\r\n };\r\n}\r\n\r\n/** @internal The box's eight corners, in no particular order. */\r\nexport function corners3(box: Box3): Vector3[] {\r\n const { min, max } = box;\r\n return [\r\n { x: min.x, y: min.y, z: min.z },\r\n { x: max.x, y: min.y, z: min.z },\r\n { x: min.x, y: max.y, z: min.z },\r\n { x: max.x, y: max.y, z: min.z },\r\n { x: min.x, y: min.y, z: max.z },\r\n { x: max.x, y: min.y, z: max.z },\r\n { x: min.x, y: max.y, z: max.z },\r\n { x: max.x, y: max.y, z: max.z },\r\n ];\r\n}\r\n\r\n/**\r\n * `box` mapped through `m` and re-bounded — the AABB of the transformed AABB.\r\n *\r\n * Not the AABB of the transformed *mesh*: a rotated box's corner-bounds are\r\n * larger than the shape inside them. That slack is the price of not carrying\r\n * vertex data around, and it errs in the safe direction (see the module note).\r\n */\r\n/** @internal */\r\nexport function transformBox3(box: Box3, m: Matrix4): Box3 {\r\n let minX = Infinity, minY = Infinity, minZ = Infinity;\r\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\r\n for (const corner of corners3(box)) {\r\n const p = applyMatrix4(m, corner);\r\n if (p.x < minX) minX = p.x;\r\n if (p.y < minY) minY = p.y;\r\n if (p.z < minZ) minZ = p.z;\r\n if (p.x > maxX) maxX = p.x;\r\n if (p.y > maxY) maxY = p.y;\r\n if (p.z > maxZ) maxZ = p.z;\r\n }\r\n return { min: { x: minX, y: minY, z: minZ }, max: { x: maxX, y: maxY, z: maxZ } };\r\n}\r\n\r\n/**\r\n * The local-space bounds of a geometry descriptor, or `null` when it cannot be\r\n * measured from the descriptor alone. See the module note for both halves of\r\n * that sentence.\r\n */\r\nexport function geometryBounds3D(geometry: Geometry3D | undefined): Box3 | null {\r\n if (!geometry) return null;\r\n\r\n switch (geometry.type) {\r\n // three centres a box on its origin; the defaults are 1 on every axis.\r\n case \"box\":\r\n return centeredBox3(\r\n (geometry.width ?? 1) / 2,\r\n (geometry.height ?? 1) / 2,\r\n (geometry.depth ?? 1) / 2,\r\n );\r\n\r\n // Full sphere even for a wedge — see the module note on partial sweeps.\r\n case \"sphere\":\r\n return centeredBox3(geometry.radius ?? 1, geometry.radius ?? 1, geometry.radius ?? 1);\r\n\r\n // Flat in XY, facing +Z. Zero depth is correct rather than degenerate:\r\n // the projected box of a plane seen edge-on genuinely is a line.\r\n case \"plane\":\r\n return centeredBox3((geometry.width ?? 1) / 2, (geometry.height ?? 1) / 2, 0);\r\n\r\n // A cone is a cylinder with one radius zeroed, and three models it as its\r\n // own type — so the two share nothing here but the shape of the answer.\r\n case \"cylinder\": {\r\n const [top, bottom] = cylinderRadii(geometry.radius);\r\n const radius = Math.max(top, bottom);\r\n return centeredBox3(radius, (geometry.height ?? 1) / 2, radius);\r\n }\r\n case \"cone\": {\r\n const radius = geometry.radius ?? 1;\r\n return centeredBox3(radius, (geometry.height ?? 1) / 2, radius);\r\n }\r\n\r\n // The ring lies in XY and the tube swells it in Z by its own radius.\r\n case \"torus\": {\r\n const radius = geometry.radius ?? 1;\r\n const tube = geometry.thickness ?? 0.4;\r\n return centeredBox3(radius + tube, radius + tube, tube);\r\n }\r\n\r\n // three's knot curve is `radius * (2 + cos(qu/p)) / 2` in XY and\r\n // `radius * sin(qu/p) / 2` in Z, so it reaches 1.5·radius across and\r\n // 0.5·radius deep before the tube is added.\r\n case \"torusKnot\": {\r\n const radius = geometry.radius ?? 1;\r\n const tube = geometry.thickness ?? 0.4;\r\n return centeredBox3(radius * 1.5 + tube, radius * 1.5 + tube, radius * 0.5 + tube);\r\n }\r\n\r\n case \"circle\":\r\n return centeredBox3(geometry.radius ?? 1, geometry.radius ?? 1, 0);\r\n\r\n case \"ring\": {\r\n const outer = geometry.radius ?? 1;\r\n return centeredBox3(outer, outer, 0);\r\n }\r\n\r\n // `height` is the straight mid-section only, so the caps add a radius at\r\n // each end — the one place three's naming would mislead a reader here. Its\r\n // default radius is 0.5, not three's 1: the renderer builds core's default,\r\n // so a box drawn round three's would be twice too wide.\r\n case \"capsule\": {\r\n const radius = geometry.radius ?? 0.5;\r\n return centeredBox3(radius, (geometry.height ?? 1) / 2 + radius, radius);\r\n }\r\n\r\n // Every platonic solid is inscribed in its radius, so the sphere bounds\r\n // it — loosely for a tetrahedron, exactly for a subdivided icosahedron.\r\n case \"polyhedron\": {\r\n const radius = geometry.radius ?? 1;\r\n return centeredBox3(radius, radius, radius);\r\n }\r\n\r\n // A profile revolved about Y: the widest |x| becomes the radius in both\r\n // ground axes, and the profile's own y range carries straight over.\r\n case \"lathe\": {\r\n let radius = 0;\r\n let minY = Infinity;\r\n let maxY = -Infinity;\r\n for (const point of geometry.points) {\r\n const p = resolveVector3(point);\r\n radius = Math.max(radius, Math.abs(p.x));\r\n minY = Math.min(minY, p.y);\r\n maxY = Math.max(maxY, p.y);\r\n }\r\n if (!Number.isFinite(minY)) return null;\r\n return { min: { x: -radius, y: minY, z: -radius }, max: { x: radius, y: maxY, z: radius } };\r\n }\r\n\r\n // The path's own extent, swollen by the tube radius on every axis. The\r\n // curve bulges outside its control points, so this is a lower bound made\r\n // safe by the radius rather than an exact one.\r\n case \"tube\": {\r\n const points = geometry.points.map((point) => resolveVector3(point));\r\n const box = pointsBounds3(points);\r\n if (!box) return null;\r\n return expandBox3(box, geometry.radius ?? 1);\r\n }\r\n\r\n // Raw vertex data — the one case that is a walk, because there is nothing\r\n // else to read it off.\r\n case \"buffer\":\r\n return positionBounds3(geometry.position);\r\n\r\n // A derived geometry has its source's extent: an outline of a shape is\r\n // the same size as the shape.\r\n case \"edges\":\r\n case \"wireframe\":\r\n return geometryBounds3D(geometry.source);\r\n\r\n // Three that need what this package hasn't got: a rasterized 2D path, a\r\n // callback that may read the clock, and a file off the network.\r\n case \"extrude\":\r\n case \"parametric\":\r\n case \"modelGeometry\":\r\n default:\r\n return null;\r\n }\r\n}\r\n\r\n/** Bounds of a point list, or `null` when it is empty. */\r\nfunction pointsBounds3(points: readonly Vector3[]): Box3 | null {\r\n if (points.length === 0) return null;\r\n let minX = Infinity, minY = Infinity, minZ = Infinity;\r\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\r\n for (const p of points) {\r\n if (p.x < minX) minX = p.x;\r\n if (p.y < minY) minY = p.y;\r\n if (p.z < minZ) minZ = p.z;\r\n if (p.x > maxX) maxX = p.x;\r\n if (p.y > maxY) maxY = p.y;\r\n if (p.z > maxZ) maxZ = p.z;\r\n }\r\n return { min: { x: minX, y: minY, z: minZ }, max: { x: maxX, y: maxY, z: maxZ } };\r\n}\r\n\r\n/** Bounds of a flat `[x, y, z, …]` position buffer. */\r\nfunction positionBounds3(position: ArrayLike<number>): Box3 | null {\r\n if (position.length < 3) return null;\r\n let minX = Infinity, minY = Infinity, minZ = Infinity;\r\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\r\n for (let i = 0; i + 2 < position.length; i += 3) {\r\n const x = position[i], y = position[i + 1], z = position[i + 2];\r\n if (x < minX) minX = x;\r\n if (y < minY) minY = y;\r\n if (z < minZ) minZ = z;\r\n if (x > maxX) maxX = x;\r\n if (y > maxY) maxY = y;\r\n if (z > maxZ) maxZ = z;\r\n }\r\n return { min: { x: minX, y: minY, z: minZ }, max: { x: maxX, y: maxY, z: maxZ } };\r\n}\r\n\r\n/** `box` grown by `by` on every axis. */\r\nfunction expandBox3(box: Box3, by: number): Box3 {\r\n return {\r\n min: { x: box.min.x - by, y: box.min.y - by, z: box.min.z - by },\r\n max: { x: box.max.x + by, y: box.max.y + by, z: box.max.z + by },\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"bounds3d.js","sourceRoot":"","sources":["../../src/render3d/bounds3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAmB,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAgB,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,cAAc,EAAgB,MAAM,WAAW,CAAC;AAkCzD,yEAAyE;AACzE,MAAM,UAAU,YAAY,CAAC,EAAU,EAAE,EAAU,EAAE,EAAU;IAC3D,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC;AAC7E,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,SAAS,CAAC,CAAc,EAAE,CAAc;IACpD,IAAI,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACjB,IAAI,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACjB,OAAO;QACH,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,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AG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QAChE,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;KACnE,CAAC;AACN,CAAC","sourcesContent":["import { cylinderRadii, type Geometry3D } from \"./geometry\";\nimport { applyMatrix4, type Matrix4 } from \"./matrix4\";\nimport { resolveVector3, type Vector3 } from \"./vector3\";\n\n/**\n * Axis-aligned bounds for the 3D descriptors — the \"how big is it, and where\" an\n * editor needs in order to put a box round a mesh it did not build.\n *\n * **Analytic, not sampled.** Every primitive's extent falls straight out of its\n * parameters, so this is a table of formulas rather than a walk over vertices,\n * and it costs nothing to ask per pointer move. The defaults each one falls back\n * to are *three's* defaults, not invented here, because a descriptor that omits\n * `radius` renders at three's 1 and a box drawn round a different number would\n * be a box in the wrong place — see the note on each.\n *\n * **Conservative where it is not exact.** A partial sweep (`thetaLength` on a\n * sphere, `arc` on a torus) is bounded by the full figure rather than by the\n * wedge actually drawn: the exact answer is an arc-endpoint problem per shape\n * per axis, and the cost of getting it wrong is a selection box that *cuts\n * through* the mesh, where the cost of over-reporting is one that sits a little\n * loose. Over-reporting is the safe direction, and it is the direction taken\n * everywhere here.\n *\n * **`null` means \"no answer\", not \"empty\".** Three descriptors genuinely cannot\n * be measured without something this package does not have: a loaded model file,\n * a rasterized path, or a user callback that may read the frame clock. A caller\n * that gets `null` draws no box, which is the honest outcome — a wrong box is\n * worse than none.\n */\n\n/** An axis-aligned box. `min` is corner-wise minimum, not a point on the mesh. */\nexport interface Box3 {\n min: Vector3;\n max: Vector3;\n}\n\n/** @internal A box centred on the origin with the given half-extents. */\nexport function centeredBox3(hx: number, hy: number, hz: number): Box3 {\n return { min: { x: -hx, y: -hy, z: -hz }, max: { x: hx, y: hy, z: hz } };\n}\n\n/** @internal The union of two boxes; either may be `null`. */\nexport function unionBox3(a: Box3 | null, b: Box3 | null): Box3 | null {\n if (!a) return b;\n if (!b) return a;\n return {\n min: { x: Math.min(a.min.x, b.min.x), y: Math.min(a.min.y, b.min.y), z: Math.min(a.min.z, b.min.z) },\n max: { x: Math.max(a.max.x, b.max.x), y: Math.max(a.max.y, b.max.y), z: Math.max(a.max.z, b.max.z) },\n };\n}\n\n/** @internal The box's eight corners, in no particular order. */\nexport function corners3(box: Box3): Vector3[] {\n const { min, max } = box;\n return [\n { x: min.x, y: min.y, z: min.z },\n { x: max.x, y: min.y, z: min.z },\n { x: min.x, y: max.y, z: min.z },\n { x: max.x, y: max.y, z: min.z },\n { x: min.x, y: min.y, z: max.z },\n { x: max.x, y: min.y, z: max.z },\n { x: min.x, y: max.y, z: max.z },\n { x: max.x, y: max.y, z: max.z },\n ];\n}\n\n/**\n * `box` mapped through `m` and re-bounded — the AABB of the transformed AABB.\n *\n * Not the AABB of the transformed *mesh*: a rotated box's corner-bounds are\n * larger than the shape inside them. That slack is the price of not carrying\n * vertex data around, and it errs in the safe direction (see the module note).\n */\n/** @internal */\nexport function transformBox3(box: Box3, m: Matrix4): Box3 {\n let minX = Infinity, minY = Infinity, minZ = Infinity;\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\n for (const corner of corners3(box)) {\n const p = applyMatrix4(m, corner);\n if (p.x < minX) minX = p.x;\n if (p.y < minY) minY = p.y;\n if (p.z < minZ) minZ = p.z;\n if (p.x > maxX) maxX = p.x;\n if (p.y > maxY) maxY = p.y;\n if (p.z > maxZ) maxZ = p.z;\n }\n return { min: { x: minX, y: minY, z: minZ }, max: { x: maxX, y: maxY, z: maxZ } };\n}\n\n/**\n * The local-space bounds of a geometry descriptor, or `null` when it cannot be\n * measured from the descriptor alone. See the module note for both halves of\n * that sentence.\n */\nexport function geometryBounds3D(geometry: Geometry3D | undefined): Box3 | null {\n if (!geometry) return null;\n\n switch (geometry.type) {\n // three centres a box on its origin; the defaults are 1 on every axis.\n case \"box\":\n return centeredBox3(\n (geometry.width ?? 1) / 2,\n (geometry.height ?? 1) / 2,\n (geometry.depth ?? 1) / 2,\n );\n\n // Full sphere even for a wedge — see the module note on partial sweeps.\n case \"sphere\":\n return centeredBox3(geometry.radius ?? 1, geometry.radius ?? 1, geometry.radius ?? 1);\n\n // Flat in XY, facing +Z. Zero depth is correct rather than degenerate:\n // the projected box of a plane seen edge-on genuinely is a line.\n case \"plane\":\n return centeredBox3((geometry.width ?? 1) / 2, (geometry.height ?? 1) / 2, 0);\n\n // A cone is a cylinder with one radius zeroed, and three models it as its\n // own type — so the two share nothing here but the shape of the answer.\n case \"cylinder\": {\n const [top, bottom] = cylinderRadii(geometry.radius);\n const radius = Math.max(top, bottom);\n return centeredBox3(radius, (geometry.height ?? 1) / 2, radius);\n }\n case \"cone\": {\n const radius = geometry.radius ?? 1;\n return centeredBox3(radius, (geometry.height ?? 1) / 2, radius);\n }\n\n // The ring lies in XY and the tube swells it in Z by its own radius.\n case \"torus\": {\n const radius = geometry.radius ?? 1;\n const tube = geometry.thickness ?? 0.4;\n return centeredBox3(radius + tube, radius + tube, tube);\n }\n\n // three's knot curve is `radius * (2 + cos(qu/p)) / 2` in XY and\n // `radius * sin(qu/p) / 2` in Z, so it reaches 1.5·radius across and\n // 0.5·radius deep before the tube is added.\n case \"torusKnot\": {\n const radius = geometry.radius ?? 1;\n const tube = geometry.thickness ?? 0.4;\n return centeredBox3(radius * 1.5 + tube, radius * 1.5 + tube, radius * 0.5 + tube);\n }\n\n case \"circle\":\n return centeredBox3(geometry.radius ?? 1, geometry.radius ?? 1, 0);\n\n case \"ring\": {\n const outer = geometry.radius ?? 1;\n return centeredBox3(outer, outer, 0);\n }\n\n // `height` is the straight mid-section only, so the caps add a radius at\n // each end — the one place three's naming would mislead a reader here. Its\n // default radius is 0.5, not three's 1: the renderer builds core's default,\n // so a box drawn round three's would be twice too wide.\n case \"capsule\": {\n const radius = geometry.radius ?? 0.5;\n return centeredBox3(radius, (geometry.height ?? 1) / 2 + radius, radius);\n }\n\n // Every platonic solid is inscribed in its radius, so the sphere bounds\n // it — loosely for a tetrahedron, exactly for a subdivided icosahedron.\n case \"polyhedron\": {\n const radius = geometry.radius ?? 1;\n return centeredBox3(radius, radius, radius);\n }\n\n // A profile revolved about Y: the widest |x| becomes the radius in both\n // ground axes, and the profile's own y range carries straight over.\n case \"lathe\": {\n let radius = 0;\n let minY = Infinity;\n let maxY = -Infinity;\n for (const point of geometry.points) {\n const p = resolveVector3(point);\n radius = Math.max(radius, Math.abs(p.x));\n minY = Math.min(minY, p.y);\n maxY = Math.max(maxY, p.y);\n }\n if (!Number.isFinite(minY)) return null;\n return { min: { x: -radius, y: minY, z: -radius }, max: { x: radius, y: maxY, z: radius } };\n }\n\n // The path's own extent, swollen by the tube radius on every axis. The\n // curve bulges outside its control points, so this is a lower bound made\n // safe by the radius rather than an exact one.\n case \"tube\": {\n const points = geometry.points.map((point) => resolveVector3(point));\n const box = pointsBounds3(points);\n if (!box) return null;\n return expandBox3(box, geometry.radius ?? 1);\n }\n\n // Raw vertex data — the one case that is a walk, because there is nothing\n // else to read it off.\n case \"buffer\":\n return positionBounds3(geometry.position);\n\n // A derived geometry has its source's extent: an outline of a shape is\n // the same size as the shape.\n case \"edges\":\n case \"wireframe\":\n return geometryBounds3D(geometry.source);\n\n // Three that need what this package hasn't got: a rasterized 2D path, a\n // callback that may read the clock, and a file off the network.\n case \"extrude\":\n case \"parametric\":\n case \"modelGeometry\":\n default:\n return null;\n }\n}\n\n/** Bounds of a point list, or `null` when it is empty. */\nfunction pointsBounds3(points: readonly Vector3[]): Box3 | null {\n if (points.length === 0) return null;\n let minX = Infinity, minY = Infinity, minZ = Infinity;\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\n for (const p of points) {\n if (p.x < minX) minX = p.x;\n if (p.y < minY) minY = p.y;\n if (p.z < minZ) minZ = p.z;\n if (p.x > maxX) maxX = p.x;\n if (p.y > maxY) maxY = p.y;\n if (p.z > maxZ) maxZ = p.z;\n }\n return { min: { x: minX, y: minY, z: minZ }, max: { x: maxX, y: maxY, z: maxZ } };\n}\n\n/** Bounds of a flat `[x, y, z, …]` position buffer. */\nfunction positionBounds3(position: ArrayLike<number>): Box3 | null {\n if (position.length < 3) return null;\n let minX = Infinity, minY = Infinity, minZ = Infinity;\n let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;\n for (let i = 0; i + 2 < position.length; i += 3) {\n const x = position[i], y = position[i + 1], z = position[i + 2];\n if (x < minX) minX = x;\n if (y < minY) minY = y;\n if (z < minZ) minZ = z;\n if (x > maxX) maxX = x;\n if (y > maxY) maxY = y;\n if (z > maxZ) maxZ = z;\n }\n return { min: { x: minX, y: minY, z: minZ }, max: { x: maxX, y: maxY, z: maxZ } };\n}\n\n/** `box` grown by `by` on every axis. */\nfunction expandBox3(box: Box3, by: number): Box3 {\n return {\n min: { x: box.min.x - by, y: box.min.y - by, z: box.min.z - by },\n max: { x: box.max.x + by, y: box.max.y + by, z: box.max.z + by },\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"builders.js","sourceRoot":"","sources":["../../src/render3d/builders.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG;IACf,GAAG,EAAE,CAAC,CAA2B,EAAiB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;IAC5E,MAAM,EAAE,CAAC,CAA8B,EAAoB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;IACxF,KAAK,EAAE,CAAC,CAA6B,EAAmB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;IACpF,QAAQ,EAAE,CA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ACxG,MAAM,EAAE,CAAC,CAA8B,EAAoB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;IACxF,MAAM,EAAE,CAAC,CAA8B,EAAoB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;IACxF,gFAAgF;IAChF,MAAM,EAAE,CAAC,CAA6B,EAAoB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;CACjF,CAAC;AAEX;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG;IACf,KAAK,EAAE,CAAC,GAAW,EAAE,CAAoB,EAAkB,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;IAC7E,uEAAuE;IACvE,IAAI,EAAE,CACF,IAAuB,EACvB,KAAa,EACb,MAAc,EACd,CAA4C,EAC/B,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IACnD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,OAAO,EAAE,CACL,MAAuB,EACvB,CAAkF,EAClE,EAAE,CAAC,CAAC;QACpB,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;QACX,GAAG,CAAC;QACJ,MAAM;KACT,CAAC;CACI,CAAC","sourcesContent":["import type {\r\n BoxGeometry3D, BufferGeometry3D, CapsuleGeometry3D, CircleGeometry3D,\r\n ConeGeometry3D, CylinderGeometry3D, EdgesGeometry3D, ExtrudeGeometry3D,\r\n Geometry3D, LatheGeometry3D, ModelGeometry3D, ParametricGeometry3D,\r\n PlaneGeometry3D, PolyhedronGeometry3D, RingGeometry3D, SphereGeometry3D,\r\n TorusGeometry3D, TorusKnotGeometry3D, TubeGeometry3D, WireframeGeometry3D,\r\n} from \"./geometry\";\r\nimport type {\r\n BasicMaterial3D, DepthMaterial3D, LambertMaterial3D, LineBasicMaterial3D,\r\n LineDashedMaterial3D, MatcapMaterial3D, NormalMaterial3D, PhongMaterial3D,\r\n PhysicalMaterial3D, PointsMaterial3D, ShaderMaterial3D, ShadowMaterial3D,\r\n SpriteMaterial3D, StandardMaterial3D, ToonMaterial3D,\r\n} from \"./material\";\r\nimport type { DataTexture3D, ImageTexture3D, SurfaceSource3D, SurfaceTexture3D, TextureOptions3D } from \"./texture\";\r\n\r\n/** A descriptor's own params, with the `type` discriminant removed. */\r\ntype ParamsOf<T> = Omit<T, \"type\">;\r\n\r\n/**\r\n * Geometry descriptors.\r\n *\r\n * These are plain values, so hoist one out of the builder and share it across\r\n * meshes — the renderer dedupes by identity, so a shared geometry is uploaded to\r\n * the GPU once no matter how many meshes reference it.\r\n *\r\n * const brick = Geo.box({ width: 1, height: 0.5, depth: 0.5 });\r\n * g.mesh(brick, red, { position: [0, 0, 0] })\r\n * .mesh(brick, red, { position: [1, 0, 0] }); // same GPU buffer\r\n */\r\nexport const Geo = {\r\n box: (o?: ParamsOf<BoxGeometry3D>): BoxGeometry3D => ({ type: \"box\", ...o }),\r\n sphere: (o?: ParamsOf<SphereGeometry3D>): SphereGeometry3D => ({ type: \"sphere\", ...o }),\r\n plane: (o?: ParamsOf<PlaneGeometry3D>): PlaneGeometry3D => ({ type: \"plane\", ...o }),\r\n cylinder: (o?: ParamsOf<CylinderGeometry3D>): CylinderGeometry3D => ({ type: \"cylinder\", ...o }),\r\n cone: (o?: ParamsOf<ConeGeometry3D>): ConeGeometry3D => ({ type: \"cone\", ...o }),\r\n torus: (o?: ParamsOf<TorusGeometry3D>): TorusGeometry3D => ({ type: \"torus\", ...o }),\r\n torusKnot: (o?: ParamsOf<TorusKnotGeometry3D>): TorusKnotGeometry3D => ({ type: \"torusKnot\", ...o }),\r\n circle: (o?: ParamsOf<CircleGeometry3D>): CircleGeometry3D => ({ type: \"circle\", ...o }),\r\n ring: (o?: ParamsOf<RingGeometry3D>): RingGeometry3D => ({ type: \"ring\", ...o }),\r\n capsule: (o?: ParamsOf<CapsuleGeometry3D>): CapsuleGeometry3D => ({ type: \"capsule\", ...o }),\r\n\r\n tetrahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\r\n ({ type: \"polyhedron\", shape: \"tetrahedron\", ...o }),\r\n octahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\r\n ({ type: \"polyhedron\", shape: \"octahedron\", ...o }),\r\n icosahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\r\n ({ type: \"polyhedron\", shape: \"icosahedron\", ...o }),\r\n dodecahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\r\n ({ type: \"polyhedron\", shape: \"dodecahedron\", ...o }),\r\n\r\n extrude: (o: ParamsOf<ExtrudeGeometry3D>): ExtrudeGeometry3D => ({ type: \"extrude\", ...o }),\r\n lathe: (o: ParamsOf<LatheGeometry3D>): LatheGeometry3D => ({ type: \"lathe\", ...o }),\r\n tube: (o: ParamsOf<TubeGeometry3D>): TubeGeometry3D => ({ type: \"tube\", ...o }),\r\n\r\n /** Raw vertex buffers — any mesh you can compute. */\r\n buffer: (o: ParamsOf<BufferGeometry3D>): BufferGeometry3D => ({ type: \"buffer\", ...o }),\r\n /** A surface sampled over a `[0,1]²` grid. Sugar over {@link Geo.buffer}. */\r\n parametric: (o: ParamsOf<ParametricGeometry3D>): ParametricGeometry3D => ({ type: \"parametric\", ...o }),\r\n\r\n /** The hard edges of another geometry — a clean outline, no triangulation diagonals. */\r\n edges: (source: Geometry3D, o?: Omit<ParamsOf<EdgesGeometry3D>, \"source\">): EdgesGeometry3D =>\r\n ({ type: \"edges\", source, ...o }),\r\n /** Every triangle edge of another geometry. */\r\n wireframe: (source: Geometry3D): WireframeGeometry3D => ({ type: \"wireframe\", source }),\r\n\r\n model: (src: string, o?: Omit<ParamsOf<ModelGeometry3D>, \"src\">): ModelGeometry3D =>\r\n ({ type: \"modelGeometry\", src, ...o }),\r\n} as const;\r\n\r\n/**\r\n * Material descriptors.\r\n *\r\n * Like geometries these are shareable values — one hoisted material across many\r\n * meshes compiles one shader program instead of N.\r\n *\r\n * Reach for {@link Mat.standard} by default; {@link Mat.physical} only when a\r\n * surface actually needs clearcoat, transmission, sheen or iridescence, since\r\n * those cost more per pixel. {@link Mat.shader} is the full-control escape hatch.\r\n */\r\nexport const Mat = {\r\n basic: (o?: ParamsOf<BasicMaterial3D>): BasicMaterial3D => ({ type: \"basic\", ...o }),\r\n standard: (o?: ParamsOf<StandardMaterial3D>): StandardMaterial3D => ({ type: \"standard\", ...o }),\r\n physical: (o?: ParamsOf<PhysicalMaterial3D>): PhysicalMaterial3D => ({ type: \"physical\", ...o }),\r\n phong: (o?: ParamsOf<PhongMaterial3D>): PhongMaterial3D => ({ type: \"phong\", ...o }),\r\n lambert: (o?: ParamsOf<LambertMaterial3D>): LambertMaterial3D => ({ type: \"lambert\", ...o }),\r\n toon: (o?: ParamsOf<ToonMaterial3D>): ToonMaterial3D => ({ type: \"toon\", ...o }),\r\n normal: (o?: ParamsOf<NormalMaterial3D>): NormalMaterial3D => ({ type: \"normal\", ...o }),\r\n depth: (o?: ParamsOf<DepthMaterial3D>): DepthMaterial3D => ({ type: \"depth\", ...o }),\r\n matcap: (o?: ParamsOf<MatcapMaterial3D>): MatcapMaterial3D => ({ type: \"matcap\", ...o }),\r\n points: (o?: ParamsOf<PointsMaterial3D>): PointsMaterial3D => ({ type: \"points\", ...o }),\r\n lineBasic: (o?: ParamsOf<LineBasicMaterial3D>): LineBasicMaterial3D => ({ type: \"lineBasic\", ...o }),\r\n lineDashed: (o?: ParamsOf<LineDashedMaterial3D>): LineDashedMaterial3D => ({ type: \"lineDashed\", ...o }),\r\n sprite: (o?: ParamsOf<SpriteMaterial3D>): SpriteMaterial3D => ({ type: \"sprite\", ...o }),\r\n shadow: (o?: ParamsOf<ShadowMaterial3D>): ShadowMaterial3D => ({ type: \"shadow\", ...o }),\r\n /** Raw GLSL. Uniform *values* are free to animate; source changes recompile. */\r\n shader: (o: ParamsOf<ShaderMaterial3D>): ShaderMaterial3D => ({ type: \"shader\", ...o }),\r\n} as const;\r\n\r\n/**\r\n * Texture descriptors.\r\n *\r\n * {@link Tex.image} takes a manifest path and is loaded through core's ordinary\r\n * image pipeline, so the pixels are resident before the frame that needs them\r\n * draws. A bare string works anywhere a texture is expected, so `Tex.image` is\r\n * only needed when passing sampler options.\r\n */\r\nexport const Tex = {\r\n image: (src: string, o?: TextureOptions3D): ImageTexture3D => ({ src, ...o }),\r\n /** A texture from raw RGBA8888 bytes — gradient ramps, noise, LUTs. */\r\n data: (\r\n data: ArrayLike<number>,\r\n width: number,\r\n height: number,\r\n o?: TextureOptions3D & { revision?: number },\r\n ): DataTexture3D => ({ data, width, height, ...o }),\r\n /**\r\n * A texture painted from Motion Script's own 2D output — the bridge from 2D\r\n * onto 3D geometry.\r\n *\r\n * `source` is a **value**: a built `Graphics2D` command list, or a `Node2D`\r\n * subtree for anything needing real layout, shaped `Text` or a loaded\r\n * `Image`. Both are passed directly; there is no name to match and nothing\r\n * has to be mounted anywhere in particular.\r\n *\r\n * const scope = new Graphics2D().line({ points: trace(phase()) }).stroke(…);\r\n * g3.plane({ fill: scope }); // sized for you\r\n *\r\n * const stats = new Rect({ flow: \"vertical\", padding: 48, children: [Text({ text: \"CPU\" })] });\r\n * g3.plane({ fill: Tex.surface(stats, { width: 1024, height: 640 }) });\r\n *\r\n * `width`/`height` are the buffer's resolution and default to 512. A source\r\n * handed straight to `fill` gets exactly this treatment with those defaults,\r\n * so the builder is only needed to pin a resolution or a sampler option.\r\n * **Hoist the source** rather than rebuilding it each frame — see\r\n * {@link SurfaceTexture3D}.\r\n */\r\n surface: (\r\n source: SurfaceSource3D,\r\n o?: TextureOptions3D & { width?: number; height?: number; maxPixelRatio?: number },\r\n ): SurfaceTexture3D => ({\r\n width: 512,\r\n height: 512,\r\n ...o,\r\n source,\r\n }),\r\n} as const;\r\n"]}
1
+ {"version":3,"file":"builders.js","sourceRoot":"","sources":["../../src/render3d/builders.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG;IACf,GAAG,EAAE,CAAC,CAA2B,EAAiB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;IAC5E,MAAM,EAAE,CAAC,CAA8B,EAAoB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;IACxF,KAAK,EAAE,CAAC,CAA6B,EAAmB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;IACpF,QAAQ,EAAE,CAAC,CAAgC,EAAsB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,CAAC;IAChG,IAAI,EAAE,CAAC,CAA4B,EAAkB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IAChF,KAAK,EAAE,CAAC,CAA6B,EAAmB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;IACpF,SAAS,EAAE,CAAC,CAAiC,EAAuB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,CAAC;IACpG,MAAM,EAAE,CAAC,CAA8B,EAAoB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;IACxF,IAAI,EAAE,CAAC,CAA4B,EAAkB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IAChF,OAAO,EAAE,CAA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EAAE,GAAG,CAAC,EAAE,CAAC;IACnD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,OAAO,EAAE,CACL,MAAuB,EACvB,CAAkF,EAClE,EAAE,CAAC,CAAC;QACpB,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;QACX,GAAG,CAAC;QACJ,MAAM;KACT,CAAC;CACI,CAAC","sourcesContent":["import type {\n BoxGeometry3D, BufferGeometry3D, CapsuleGeometry3D, CircleGeometry3D,\n ConeGeometry3D, CylinderGeometry3D, EdgesGeometry3D, ExtrudeGeometry3D,\n Geometry3D, LatheGeometry3D, ModelGeometry3D, ParametricGeometry3D,\n PlaneGeometry3D, PolyhedronGeometry3D, RingGeometry3D, SphereGeometry3D,\n TorusGeometry3D, TorusKnotGeometry3D, TubeGeometry3D, WireframeGeometry3D,\n} from \"./geometry\";\nimport type {\n BasicMaterial3D, DepthMaterial3D, LambertMaterial3D, LineBasicMaterial3D,\n LineDashedMaterial3D, MatcapMaterial3D, NormalMaterial3D, PhongMaterial3D,\n PhysicalMaterial3D, PointsMaterial3D, ShaderMaterial3D, ShadowMaterial3D,\n SpriteMaterial3D, StandardMaterial3D, ToonMaterial3D,\n} from \"./material\";\nimport type { DataTexture3D, ImageTexture3D, SurfaceSource3D, SurfaceTexture3D, TextureOptions3D } from \"./texture\";\n\n/** A descriptor's own params, with the `type` discriminant removed. */\ntype ParamsOf<T> = Omit<T, \"type\">;\n\n/**\n * Geometry descriptors.\n *\n * These are plain values, so hoist one out of the builder and share it across\n * meshes — the renderer dedupes by identity, so a shared geometry is uploaded to\n * the GPU once no matter how many meshes reference it.\n *\n * const brick = Geo.box({ width: 1, height: 0.5, depth: 0.5 });\n * g.mesh(brick, red, { position: [0, 0, 0] })\n * .mesh(brick, red, { position: [1, 0, 0] }); // same GPU buffer\n */\nexport const Geo = {\n box: (o?: ParamsOf<BoxGeometry3D>): BoxGeometry3D => ({ type: \"box\", ...o }),\n sphere: (o?: ParamsOf<SphereGeometry3D>): SphereGeometry3D => ({ type: \"sphere\", ...o }),\n plane: (o?: ParamsOf<PlaneGeometry3D>): PlaneGeometry3D => ({ type: \"plane\", ...o }),\n cylinder: (o?: ParamsOf<CylinderGeometry3D>): CylinderGeometry3D => ({ type: \"cylinder\", ...o }),\n cone: (o?: ParamsOf<ConeGeometry3D>): ConeGeometry3D => ({ type: \"cone\", ...o }),\n torus: (o?: ParamsOf<TorusGeometry3D>): TorusGeometry3D => ({ type: \"torus\", ...o }),\n torusKnot: (o?: ParamsOf<TorusKnotGeometry3D>): TorusKnotGeometry3D => ({ type: \"torusKnot\", ...o }),\n circle: (o?: ParamsOf<CircleGeometry3D>): CircleGeometry3D => ({ type: \"circle\", ...o }),\n ring: (o?: ParamsOf<RingGeometry3D>): RingGeometry3D => ({ type: \"ring\", ...o }),\n capsule: (o?: ParamsOf<CapsuleGeometry3D>): CapsuleGeometry3D => ({ type: \"capsule\", ...o }),\n\n tetrahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\n ({ type: \"polyhedron\", shape: \"tetrahedron\", ...o }),\n octahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\n ({ type: \"polyhedron\", shape: \"octahedron\", ...o }),\n icosahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\n ({ type: \"polyhedron\", shape: \"icosahedron\", ...o }),\n dodecahedron: (o?: Omit<ParamsOf<PolyhedronGeometry3D>, \"shape\">): PolyhedronGeometry3D =>\n ({ type: \"polyhedron\", shape: \"dodecahedron\", ...o }),\n\n extrude: (o: ParamsOf<ExtrudeGeometry3D>): ExtrudeGeometry3D => ({ type: \"extrude\", ...o }),\n lathe: (o: ParamsOf<LatheGeometry3D>): LatheGeometry3D => ({ type: \"lathe\", ...o }),\n tube: (o: ParamsOf<TubeGeometry3D>): TubeGeometry3D => ({ type: \"tube\", ...o }),\n\n /** Raw vertex buffers — any mesh you can compute. */\n buffer: (o: ParamsOf<BufferGeometry3D>): BufferGeometry3D => ({ type: \"buffer\", ...o }),\n /** A surface sampled over a `[0,1]²` grid. Sugar over {@link Geo.buffer}. */\n parametric: (o: ParamsOf<ParametricGeometry3D>): ParametricGeometry3D => ({ type: \"parametric\", ...o }),\n\n /** The hard edges of another geometry — a clean outline, no triangulation diagonals. */\n edges: (source: Geometry3D, o?: Omit<ParamsOf<EdgesGeometry3D>, \"source\">): EdgesGeometry3D =>\n ({ type: \"edges\", source, ...o }),\n /** Every triangle edge of another geometry. */\n wireframe: (source: Geometry3D): WireframeGeometry3D => ({ type: \"wireframe\", source }),\n\n model: (src: string, o?: Omit<ParamsOf<ModelGeometry3D>, \"src\">): ModelGeometry3D =>\n ({ type: \"modelGeometry\", src, ...o }),\n} as const;\n\n/**\n * Material descriptors.\n *\n * Like geometries these are shareable values — one hoisted material across many\n * meshes compiles one shader program instead of N.\n *\n * Reach for {@link Mat.standard} by default; {@link Mat.physical} only when a\n * surface actually needs clearcoat, transmission, sheen or iridescence, since\n * those cost more per pixel. {@link Mat.shader} is the full-control escape hatch.\n */\nexport const Mat = {\n basic: (o?: ParamsOf<BasicMaterial3D>): BasicMaterial3D => ({ type: \"basic\", ...o }),\n standard: (o?: ParamsOf<StandardMaterial3D>): StandardMaterial3D => ({ type: \"standard\", ...o }),\n physical: (o?: ParamsOf<PhysicalMaterial3D>): PhysicalMaterial3D => ({ type: \"physical\", ...o }),\n phong: (o?: ParamsOf<PhongMaterial3D>): PhongMaterial3D => ({ type: \"phong\", ...o }),\n lambert: (o?: ParamsOf<LambertMaterial3D>): LambertMaterial3D => ({ type: \"lambert\", ...o }),\n toon: (o?: ParamsOf<ToonMaterial3D>): ToonMaterial3D => ({ type: \"toon\", ...o }),\n normal: (o?: ParamsOf<NormalMaterial3D>): NormalMaterial3D => ({ type: \"normal\", ...o }),\n depth: (o?: ParamsOf<DepthMaterial3D>): DepthMaterial3D => ({ type: \"depth\", ...o }),\n matcap: (o?: ParamsOf<MatcapMaterial3D>): MatcapMaterial3D => ({ type: \"matcap\", ...o }),\n points: (o?: ParamsOf<PointsMaterial3D>): PointsMaterial3D => ({ type: \"points\", ...o }),\n lineBasic: (o?: ParamsOf<LineBasicMaterial3D>): LineBasicMaterial3D => ({ type: \"lineBasic\", ...o }),\n lineDashed: (o?: ParamsOf<LineDashedMaterial3D>): LineDashedMaterial3D => ({ type: \"lineDashed\", ...o }),\n sprite: (o?: ParamsOf<SpriteMaterial3D>): SpriteMaterial3D => ({ type: \"sprite\", ...o }),\n shadow: (o?: ParamsOf<ShadowMaterial3D>): ShadowMaterial3D => ({ type: \"shadow\", ...o }),\n /** Raw GLSL. Uniform *values* are free to animate; source changes recompile. */\n shader: (o: ParamsOf<ShaderMaterial3D>): ShaderMaterial3D => ({ type: \"shader\", ...o }),\n} as const;\n\n/**\n * Texture descriptors.\n *\n * {@link Tex.image} takes a manifest path and is loaded through core's ordinary\n * image pipeline, so the pixels are resident before the frame that needs them\n * draws. A bare string works anywhere a texture is expected, so `Tex.image` is\n * only needed when passing sampler options.\n */\nexport const Tex = {\n image: (src: string, o?: TextureOptions3D): ImageTexture3D => ({ src, ...o }),\n /** A texture from raw RGBA8888 bytes — gradient ramps, noise, LUTs. */\n data: (\n data: ArrayLike<number>,\n width: number,\n height: number,\n o?: TextureOptions3D & { revision?: number },\n ): DataTexture3D => ({ data, width, height, ...o }),\n /**\n * A texture painted from Motion Script's own 2D output — the bridge from 2D\n * onto 3D geometry.\n *\n * `source` is a **value**: a built `Graphics2D` command list, or a `Node2D`\n * subtree for anything needing real layout, shaped `Text` or a loaded\n * `Image`. Both are passed directly; there is no name to match and nothing\n * has to be mounted anywhere in particular.\n *\n * const scope = new Graphics2D().line({ points: trace(phase()) }).stroke(…);\n * g3.plane({ fill: scope }); // sized for you\n *\n * const stats = new Rect({ flow: \"vertical\", padding: 48, children: [Text({ text: \"CPU\" })] });\n * g3.plane({ fill: Tex.surface(stats, { width: 1024, height: 640 }) });\n *\n * `width`/`height` are the buffer's resolution and default to 512. A source\n * handed straight to `fill` gets exactly this treatment with those defaults,\n * so the builder is only needed to pin a resolution or a sampler option.\n * **Hoist the source** rather than rebuilding it each frame — see\n * {@link SurfaceTexture3D}.\n */\n surface: (\n source: SurfaceSource3D,\n o?: TextureOptions3D & { width?: number; height?: number; maxPixelRatio?: number },\n ): SurfaceTexture3D => ({\n width: 512,\n height: 512,\n ...o,\n source,\n }),\n} as const;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"camera.js","sourceRoot":"","sources":["../../src/render3d/camera.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAmC,MAAM,WAAW,CAAC;AAuE5E;;;;;;;;GAQG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAW,CAAC;AAEvF,MAAM,UAAU,eAAe,CAAC,MAAoB;IAChD,OAAO,MAAM,CAAC,KAAK,KAAK,SAAS;WAC1B,MAAM,CAAC,SAAS,KAAK,SAAS;WAC9B,MAAM,CAAC,QAAQ,KAAK,SAAS,CAAC;AACzC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAoB;IAIvD,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IAElD,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,uEAAuE;QACvE,yEAAyE;QACzE,wDAAwD;QACxD,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC;QAC3C,OAAO;YACH,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC;YAC9C,MAAM,EAAE,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC;SAC9D,CAAC;IACN,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,qBAAqB,CAAC,QAAQ,CAAC;IACnE,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,qBAAqB,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IAChF,4EAA4E;IAC5E,4EAA4E;IAC5E,yDAAyD;IACzD,MAAM,SAAS,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,IAAI,qBAAqB,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IAE5G,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;IAElD,OAAO;QACH,QAAQ,EAAE;YACN,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,UAAU;YAC5C,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,QAAQ;YAC5C,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,UAAU;SAC/C;QACD,MAAM,EAAE,MAAM;KACjB,CAAC;AACN,CAAC;AAED,SAAS,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,IAAY;IACnD,OAAO,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AAC3D,CAAC","sourcesContent":["import type { Passthrough3D } from \"./geometry\";\r\nimport type { Transform3D } from \"./transform\";\r\nimport { resolveVector3, type Vector3, type Vector3Input } from \"./vector3\";\r\n\r\n/**\r\n * What every camera has, whatever it projects with.\r\n *\r\n * A camera can be placed two ways and they are not redundant. The\r\n * {@link Transform3D} half — `position` plus `lookAt` — is right when the shot is\r\n * pinned to something, and it is what a camera inside a moving rig uses. The\r\n * polar half — {@link target}, {@link orbit}, {@link elevation},\r\n * {@link distance} — is right when the shot is *about* the subject, which is\r\n * most of the time, and it is the only one of the two that animates cleanly:\r\n *\r\n * cam().to({ data: { orbit: 160, elevation: 30 }, duration: 4 });\r\n *\r\n * Writing that same move through `position` means composing sines by hand every\r\n * frame, which is what every scene did before this existed.\r\n *\r\n * Setting any polar field derives `position` and `lookAt`, so the two halves are\r\n * never in force at once. See {@link resolveCameraPlacement}.\r\n */\r\nexport interface CameraCommon3D extends Transform3D, Passthrough3D {\r\n /** The point the camera looks at, and orbits around. Default origin. */\r\n target?: Vector3Input;\r\n /** Azimuth around {@link target}, in **degrees**. 0 looks down −Z. */\r\n orbit?: number;\r\n /** Angle above the horizon, in **degrees**. Clamped just short of vertical. */\r\n elevation?: number;\r\n /** Distance from {@link target}. */\r\n distance?: number;\r\n\r\n /**\r\n * Near and far clip planes.\r\n *\r\n * Both are derived from the scene's own bounds when omitted, which is right\r\n * far more often than any constant: too near a `far` clips the back of the\r\n * scene, too far a `near` destroys depth precision. Set them only to override.\r\n */\r\n near?: number;\r\n far?: number;\r\n /** Zoom factor applied on top of the projection. */\r\n zoom?: number;\r\n}\r\n\r\n/**\r\n * A perspective camera — converging rays, so distant things shrink. What you want\r\n * unless you specifically need the flat look of an orthographic projection.\r\n */\r\nexport interface PerspectiveCameraData3D extends CameraCommon3D {\r\n type: \"perspective\";\r\n /** Vertical field of view in **degrees**. Default 50. */\r\n fov?: number;\r\n}\r\n\r\n/**\r\n * An orthographic camera — parallel rays, so size is independent of distance.\r\n * For isometric views, technical diagrams and 2.5D layouts.\r\n *\r\n * {@link frustumHeight} sets the visible world height and derives the width from\r\n * the node's aspect ratio. An asymmetric frustum is a `params` override rather\r\n * than four more fields, because four explicit edges is a projection-matrix\r\n * feature rather than a framing one.\r\n */\r\nexport interface OrthographicCameraData3D extends CameraCommon3D {\r\n type: \"orthographic\";\r\n /** Visible world-space height; width follows the node's aspect. Default 10. */\r\n frustumHeight?: number;\r\n}\r\n\r\n/** Every camera a scene can be viewed through. Discriminated on `type`. */\r\nexport type CameraData3D = PerspectiveCameraData3D | OrthographicCameraData3D;\r\n\r\n/**\r\n * True when the camera is placed polar-ly.\r\n *\r\n * `target` is deliberately not part of this. It answers \"what am I looking at\",\r\n * which is meaningful on its own — it is `lookAt` under a name that reads right\r\n * beside `orbit` — and only becomes a *placement* once one of the three fields\r\n * that orbit around it is set. Including it here would make every camera polar\r\n * the moment it named a subject, silently discarding its `position`.\r\n */\r\n/** What an unset polar field of an orbiting camera reads as. */\r\nexport const ORBIT_CAMERA_DEFAULTS = { orbit: 0, elevation: 0, distance: 10 } as const;\r\n\r\nexport function isOrbitCamera3D(camera: CameraData3D): boolean {\r\n return camera.orbit !== undefined\r\n || camera.elevation !== undefined\r\n || camera.distance !== undefined;\r\n}\r\n\r\n/**\r\n * A camera's effective position and aim.\r\n *\r\n * One definition, shared by the renderer and by the editor's picking geometry —\r\n * two places computing \"where is the camera\" from the same descriptor is two\r\n * chances to disagree about what the author sees, and a gizmo drawn against a\r\n * camera nobody renders is worse than no gizmo.\r\n *\r\n * The polar fields win over `position`/`lookAt` when any of them is set, so the\r\n * two placements can never both be half-applied.\r\n */\r\nexport function resolveCameraPlacement(camera: CameraData3D): {\r\n position: Vector3;\r\n lookAt: Vector3 | undefined;\r\n} {\r\n const target = resolveVector3(camera.target ?? 0);\r\n\r\n if (!isOrbitCamera3D(camera)) {\r\n // `target` is the subject either way, so a camera placed by `position`\r\n // still aims at it — which is what makes `target` one idea rather than a\r\n // polar-only field with `lookAt` as its non-polar twin.\r\n const aim = camera.lookAt ?? camera.target;\r\n return {\r\n position: resolveVector3(camera.position ?? 0),\r\n lookAt: aim === undefined ? undefined : resolveVector3(aim),\r\n };\r\n }\r\n\r\n const distance = camera.distance ?? ORBIT_CAMERA_DEFAULTS.distance;\r\n const azimuth = ((camera.orbit ?? ORBIT_CAMERA_DEFAULTS.orbit) * Math.PI) / 180;\r\n // Just short of the pole: at exactly ±90° the view direction is parallel to\r\n // the up vector and the look-at basis is undefined, which reads as the shot\r\n // snapping to an arbitrary roll on the frame it crosses.\r\n const elevation = (clamp(camera.elevation ?? ORBIT_CAMERA_DEFAULTS.elevation, -89.9, 89.9) * Math.PI) / 180;\r\n\r\n const horizontal = Math.cos(elevation) * distance;\r\n\r\n return {\r\n position: {\r\n x: target.x + Math.sin(azimuth) * horizontal,\r\n y: target.y + Math.sin(elevation) * distance,\r\n z: target.z + Math.cos(azimuth) * horizontal,\r\n },\r\n lookAt: target,\r\n };\r\n}\r\n\r\nfunction clamp(value: number, low: number, high: number): number {\r\n return value < low ? low : value > high ? high : value;\r\n}\r\n"]}
1
+ {"version":3,"file":"camera.js","sourceRoot":"","sources":["../../src/render3d/camera.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAmC,MAAM,WAAW,CAAC;AAuE5E;;;;;;;;GAQG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAW,CAAC;AAEvF,MAAM,UAAU,eAAe,CAAC,MAAoB;IAChD,OAAO,MAAM,CAAC,KAAK,KAAK,SAAS;WAC1B,MAAM,CAAC,SAAS,KAAK,SAAS;WAC9B,MAAM,CAAC,QAAQ,KAAK,SAAS,CAAC;AACzC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAoB;IAIvD,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IAElD,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,uEAAuE;QACvE,yEA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AK,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AAC3D,CAAC","sourcesContent":["import type { Passthrough3D } from \"./geometry\";\nimport type { Transform3D } from \"./transform\";\nimport { resolveVector3, type Vector3, type Vector3Input } from \"./vector3\";\n\n/**\n * What every camera has, whatever it projects with.\n *\n * A camera can be placed two ways and they are not redundant. The\n * {@link Transform3D} half — `position` plus `lookAt` — is right when the shot is\n * pinned to something, and it is what a camera inside a moving rig uses. The\n * polar half — {@link target}, {@link orbit}, {@link elevation},\n * {@link distance} — is right when the shot is *about* the subject, which is\n * most of the time, and it is the only one of the two that animates cleanly:\n *\n * cam().to({ data: { orbit: 160, elevation: 30 }, duration: 4 });\n *\n * Writing that same move through `position` means composing sines by hand every\n * frame, which is what every scene did before this existed.\n *\n * Setting any polar field derives `position` and `lookAt`, so the two halves are\n * never in force at once. See {@link resolveCameraPlacement}.\n */\nexport interface CameraCommon3D extends Transform3D, Passthrough3D {\n /** The point the camera looks at, and orbits around. Default origin. */\n target?: Vector3Input;\n /** Azimuth around {@link target}, in **degrees**. 0 looks down −Z. */\n orbit?: number;\n /** Angle above the horizon, in **degrees**. Clamped just short of vertical. */\n elevation?: number;\n /** Distance from {@link target}. */\n distance?: number;\n\n /**\n * Near and far clip planes.\n *\n * Both are derived from the scene's own bounds when omitted, which is right\n * far more often than any constant: too near a `far` clips the back of the\n * scene, too far a `near` destroys depth precision. Set them only to override.\n */\n near?: number;\n far?: number;\n /** Zoom factor applied on top of the projection. */\n zoom?: number;\n}\n\n/**\n * A perspective camera — converging rays, so distant things shrink. What you want\n * unless you specifically need the flat look of an orthographic projection.\n */\nexport interface PerspectiveCameraData3D extends CameraCommon3D {\n type: \"perspective\";\n /** Vertical field of view in **degrees**. Default 50. */\n fov?: number;\n}\n\n/**\n * An orthographic camera — parallel rays, so size is independent of distance.\n * For isometric views, technical diagrams and 2.5D layouts.\n *\n * {@link frustumHeight} sets the visible world height and derives the width from\n * the node's aspect ratio. An asymmetric frustum is a `params` override rather\n * than four more fields, because four explicit edges is a projection-matrix\n * feature rather than a framing one.\n */\nexport interface OrthographicCameraData3D extends CameraCommon3D {\n type: \"orthographic\";\n /** Visible world-space height; width follows the node's aspect. Default 10. */\n frustumHeight?: number;\n}\n\n/** Every camera a scene can be viewed through. Discriminated on `type`. */\nexport type CameraData3D = PerspectiveCameraData3D | OrthographicCameraData3D;\n\n/**\n * True when the camera is placed polar-ly.\n *\n * `target` is deliberately not part of this. It answers \"what am I looking at\",\n * which is meaningful on its own — it is `lookAt` under a name that reads right\n * beside `orbit` — and only becomes a *placement* once one of the three fields\n * that orbit around it is set. Including it here would make every camera polar\n * the moment it named a subject, silently discarding its `position`.\n */\n/** What an unset polar field of an orbiting camera reads as. */\nexport const ORBIT_CAMERA_DEFAULTS = { orbit: 0, elevation: 0, distance: 10 } as const;\n\nexport function isOrbitCamera3D(camera: CameraData3D): boolean {\n return camera.orbit !== undefined\n || camera.elevation !== undefined\n || camera.distance !== undefined;\n}\n\n/**\n * A camera's effective position and aim.\n *\n * One definition, shared by the renderer and by the editor's picking geometry —\n * two places computing \"where is the camera\" from the same descriptor is two\n * chances to disagree about what the author sees, and a gizmo drawn against a\n * camera nobody renders is worse than no gizmo.\n *\n * The polar fields win over `position`/`lookAt` when any of them is set, so the\n * two placements can never both be half-applied.\n */\nexport function resolveCameraPlacement(camera: CameraData3D): {\n position: Vector3;\n lookAt: Vector3 | undefined;\n} {\n const target = resolveVector3(camera.target ?? 0);\n\n if (!isOrbitCamera3D(camera)) {\n // `target` is the subject either way, so a camera placed by `position`\n // still aims at it — which is what makes `target` one idea rather than a\n // polar-only field with `lookAt` as its non-polar twin.\n const aim = camera.lookAt ?? camera.target;\n return {\n position: resolveVector3(camera.position ?? 0),\n lookAt: aim === undefined ? undefined : resolveVector3(aim),\n };\n }\n\n const distance = camera.distance ?? ORBIT_CAMERA_DEFAULTS.distance;\n const azimuth = ((camera.orbit ?? ORBIT_CAMERA_DEFAULTS.orbit) * Math.PI) / 180;\n // Just short of the pole: at exactly ±90° the view direction is parallel to\n // the up vector and the look-at basis is undefined, which reads as the shot\n // snapping to an arbitrary roll on the frame it crosses.\n const elevation = (clamp(camera.elevation ?? ORBIT_CAMERA_DEFAULTS.elevation, -89.9, 89.9) * Math.PI) / 180;\n\n const horizontal = Math.cos(elevation) * distance;\n\n return {\n position: {\n x: target.x + Math.sin(azimuth) * horizontal,\n y: target.y + Math.sin(elevation) * distance,\n z: target.z + Math.cos(azimuth) * horizontal,\n },\n lookAt: target,\n };\n}\n\nfunction clamp(value: number, low: number, high: number): number {\n return value < low ? low : value > high ? high : value;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fill3d.js","sourceRoot":"","sources":["../../src/render3d/fill3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,UAAU,EAAE,MAAM,sCAAsC,CAAC;AACpG,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,iFAAiF;AACjF,qEAAqE;AACrE,8EAA8E;AAC9E,uDAAuD;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAG/C,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAgC9B,MAAM,YAAY,GAAG,GAAG,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,aAAa,CACzB,IAAwB,EACxB,UAAyB,EAAE;IAE3B,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IAEnD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC3B,0EAA0E;QAC1E,0EAA0E;QAC1E,uEAAuE;QACvE,8CAA8C;QAC9C,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAA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ACrG,CAAC","sourcesContent":["import { type Color, type NormalizedColor, parseColor } from \"@/attributes/shape/fill/color/parser\";\r\nimport { lerpColor } from \"@/attributes/shape/fill/lerp\";\r\nimport type { Fill } from \"@/attributes/shape/fill/chain\";\r\n// A value import, unlike the type-only ones in `texture.ts`: building the rect a\r\n// fill chain is painted into needs the recorder itself. Safe because\r\n// `render/graphics2d` reaches only the *effects* chain at runtime, never back\r\n// into `render3d` — see the note on `SurfaceSource3D`.\r\nimport { Graphics2D } from \"@/render/graphics2d\";\r\nimport { looksLikeAssetPath } from \"./texture\";\r\nimport type { SurfaceSource3D, Texture3D } from \"./texture\";\r\n\r\nexport { looksLikeAssetPath };\r\n\r\n/**\r\n * What a surface is made of.\r\n *\r\n * The same value a 2D `fill` takes, so a mesh and a rect are described with one\r\n * vocabulary: a colour, a gradient, an image, a video, a noise field, a whole\r\n * stack of blended layers — and, because a `Node2D` subtree and a built\r\n * `Graphics2D` are fills too, any 2D content at all.\r\n *\r\n * This is the 3D counterpart of Spline's material *stack*, built on the fill\r\n * chain that already exists rather than on a second set of layer types. What it\r\n * replaces is a flat `color` plus five separate texture slots (`map`,\r\n * `emissiveMap`, `alphaMap`, `envMap`, `lightMap`), each of which was a fill\r\n * wearing a different name.\r\n */\r\nexport type Fill3D = Color | Fill | Texture3D | SurfaceSource3D;\r\n\r\n/** What a {@link Fill3D} contributes to a material descriptor. */\r\nexport interface ResolvedFill3D {\r\n color?: Color;\r\n map?: Texture3D;\r\n}\r\n\r\n/** Sizing for the buffer a rich fill is rasterized into. */\r\nexport interface Fill3DOptions {\r\n /** Default 512. */\r\n width?: number;\r\n /** Default 512. */\r\n height?: number;\r\n}\r\n\r\nconst DEFAULT_SIZE = 512;\r\n\r\n/**\r\n * Resolve a {@link Fill3D} into the material fields it describes.\r\n *\r\n * Three outcomes, and which one applies is decided by what the fill *is* rather\r\n * than by an author picking a slot:\r\n *\r\n * - **A colour** stays a colour. `fill=\"tomato\"` writes `material.color`, costs\r\n * nothing, and is by far the common case — so it must not be the one that\r\n * allocates a texture.\r\n * - **A texture** (an asset path, or any `Texture3D` descriptor) becomes `map`.\r\n * - **Anything richer** — a gradient, a layer stack, a `Node2D` subtree, a built\r\n * `Graphics2D`, a nested `Scene3D` — is painted into an offscreen buffer and\r\n * bound as `map`, through exactly the `Tex.surface` machinery that already\r\n * existed for putting 2D content on geometry.\r\n *\r\n * That last arm is what makes the 2D and 3D fill vocabularies genuinely one\r\n * thing: `Fills.canvas3D(scene)` inside a chain renders 3D into a layer of a\r\n * material on a mesh, with no new code path, because the 2D fill renderer was\r\n * already able to do it.\r\n */\r\nexport function resolveFill3D(\r\n fill: Fill3D | undefined,\r\n options: Fill3DOptions = {},\r\n): ResolvedFill3D {\r\n if (fill === undefined || fill === null) return {};\r\n\r\n if (typeof fill === \"string\") {\r\n // A bare string is ambiguous between a colour and an asset path, and both\r\n // are things authors write. Resolved the way the material handler already\r\n // resolved a `color` that looked like a file — so this is the existing\r\n // rule moved somewhere it can be stated once.\r\n return looksLikeAssetPath(fill) ? { map: fill } : { color: fill };\r\n }\r\n\r\n if (Array.isArray(fill)) {\r\n // A `Color` is also an array — of numbers. A fill chain is an array of\r\n // layers, which are strings or objects.\r\n if (fill.every((entry) => typeof entry === \"number\")) {\r\n return { color: fill as unknown as Color };\r\n }\r\n return { map: rasterized(fill as Fill, options) };\r\n }\r\n\r\n if (typeof fill === \"object\") {\r\n if (isSurfaceSourceValue(fill)) return { map: surfaceFor(fill as SurfaceSource3D, options) };\r\n if (isTextureDescriptor(fill)) return { map: fill as Texture3D };\r\n if (isSolidLayer(fill)) return { color: (fill as { color: Color }).color };\r\n }\r\n\r\n return { map: rasterized(fill as Fill, options) };\r\n}\r\n\r\n/**\r\n * A surface texture painting `source` directly.\r\n *\r\n * Identity comes from the source object, which the `Tex.surface` contract already\r\n * requires to be hoisted — so nothing has to be written by hand and a source that\r\n * goes out of scope stops being cached.\r\n */\r\nfunction surfaceFor(source: SurfaceSource3D, options: Fill3DOptions): Texture3D {\r\n return {\r\n source,\r\n width: options.width ?? DEFAULT_SIZE,\r\n height: options.height ?? DEFAULT_SIZE,\r\n };\r\n}\r\n\r\n/**\r\n * A surface texture painting a fill chain into a rect that fills the buffer.\r\n *\r\n * Marked `static` and given a derived identity, because a fill chain describes\r\n * the *same* pixels every frame unless one of its own values moved. Without both\r\n * of those a gradient on a cube would re-rasterize a 512² offscreen buffer and\r\n * re-upload it sixty times a second to produce an identical image — which is\r\n * exactly the trap that makes \"just render it to a texture\" a bad idea in\r\n * general, and is worth the small amount of bookkeeping to avoid.\r\n *\r\n * A chain holding something genuinely live (a video layer, a `Fills.canvas3D`) is\r\n * still re-rasterized: those carry object identity, which `fillIdentity` folds in\r\n * and which changes when the content does.\r\n */\r\nfunction rasterized(fill: Fill, options: Fill3DOptions): Texture3D {\r\n const width = options.width ?? DEFAULT_SIZE;\r\n const height = options.height ?? DEFAULT_SIZE;\r\n return {\r\n source: new Graphics2D().rect({ width, height }).fill(fill),\r\n width,\r\n height,\r\n static: true,\r\n identity: `fill:${fillIdentity(fill)}:${width}x${height}`,\r\n };\r\n}\r\n\r\n/** True for a `Texture3D` descriptor object (not a source value). */\r\nfunction isTextureDescriptor(value: object): boolean {\r\n return \"src\" in value || \"data\" in value || (\"source\" in value && \"width\" in value);\r\n}\r\n\r\n/**\r\n * True for a value that is 2D content to be painted, rather than a descriptor.\r\n *\r\n * Structural, like `resolveSurfaceSource`, and for the same reason: an\r\n * `instanceof` here would need value imports of `Node2D` and close a real module\r\n * cycle. A `Scene3D` also exposes `ops()`, so it is excluded explicitly — it is a\r\n * fill *layer* (`Fills.canvas3D`) rather than a 2D source, and routing it through\r\n * the chain arm is what gets it composited with the rest of the stack.\r\n */\r\nfunction isSurfaceSourceValue(value: object): boolean {\r\n const bag = value as Record<string, unknown>;\r\n if (typeof bag.cameraDescriptor === \"function\") return false;\r\n if (typeof bag.ops === \"function\") return true;\r\n return typeof bag.id === \"string\" && typeof bag.attach === \"function\";\r\n}\r\n\r\n/** True for a single solid-colour fill layer, which needs no texture. */\r\nfunction isSolidLayer(value: object): boolean {\r\n const bag = value as Record<string, unknown>;\r\n if (bag.type !== \"solid\" || bag.color === undefined) return false;\r\n // Anything beyond the colour — a per-layer opacity, a blend mode, a\r\n // reference space — is a composite the colour slot cannot express.\r\n return bag.opacity === undefined && bag.blend === undefined && bag.space === undefined;\r\n}\r\n\r\n/**\r\n * Interpolate two fills.\r\n *\r\n * Colours interpolate — that is the overwhelmingly common tween and it must not\r\n * snap. Anything else holds the start value and swaps at the end, because there\r\n * is no meaningful halfway between a gradient and a photograph; cross-fading two\r\n * surfaces is a *stack* (`fill={[a, b]}` with the second layer's opacity tweened),\r\n * which is how it is expressed in 2D too.\r\n *\r\n * The colour test is deliberately cheap and allocation-free: resolving a rich\r\n * fill builds a `Graphics2D` and a texture descriptor, and doing that twice per\r\n * frame for a tween that is going to snap anyway would be pure waste.\r\n */\r\nexport function lerpFill3D(from: Fill3D, to: Fill3D, t: number): Fill3D {\r\n const start = asPlainColor(from);\r\n const end = asPlainColor(to);\r\n if (start !== null && end !== null) {\r\n return lerpColor(normalize(start), normalize(end), t) as unknown as Fill3D;\r\n }\r\n return t < 1 ? from : to;\r\n}\r\n\r\n/** The colour a fill *is*, or `null` when it is anything richer. No allocation. */\r\nfunction asPlainColor(fill: Fill3D | undefined): Color | null {\r\n if (fill === undefined || fill === null) return null;\r\n if (typeof fill === \"string\") return looksLikeAssetPath(fill) ? null : fill;\r\n if (Array.isArray(fill)) {\r\n return fill.every((entry) => typeof entry === \"number\") ? (fill as unknown as Color) : null;\r\n }\r\n if (typeof fill === \"object\" && isSolidLayer(fill)) return (fill as { color: Color }).color;\r\n return null;\r\n}\r\n\r\nfunction normalize(color: Color): NormalizedColor {\r\n return Array.isArray(color) ? (color as NormalizedColor) : parseColor(color);\r\n}\r\n\r\nconst objectIds = new WeakMap<object, string>();\r\nlet objectCounter = 0;\r\n\r\n/**\r\n * A stable key for a fill value.\r\n *\r\n * Plain data is walked and sorted; anything with a prototype of its own — a\r\n * `Scene3D`, a `Graphics2D`, a video source — is keyed by object identity, which\r\n * is both cheaper than serialising it and the honest answer, since two different\r\n * instances describe two different things whatever their fields say. A\r\n * `FillChain` is unwrapped to its list first, so building one inline still\r\n * produces the same key for the same layers.\r\n */\r\nfunction fillIdentity(value: unknown): string {\r\n if (value === null || typeof value !== \"object\") return String(value);\r\n if (Array.isArray(value)) return `[${value.map(fillIdentity).join(\",\")}]`;\r\n\r\n const list = (value as { list?: unknown }).list;\r\n if (Array.isArray(list)) return fillIdentity(list);\r\n\r\n const prototype = Object.getPrototypeOf(value);\r\n if (prototype !== Object.prototype && prototype !== null) {\r\n let id = objectIds.get(value);\r\n if (id === undefined) {\r\n id = `@${objectCounter++}`;\r\n objectIds.set(value, id);\r\n }\r\n return id;\r\n }\r\n\r\n const bag = value as Record<string, unknown>;\r\n return `{${Object.keys(bag).sort().map((key) => `${key}:${fillIdentity(bag[key])}`).join(\",\")}}`;\r\n}\r\n"]}
1
+ {"version":3,"file":"fill3d.js","sourceRoot":"","sources":["../../src/render3d/fill3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,UAAU,EAAE,MAAM,sCAAsC,CAAC;AACpG,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,iFAAiF;AACjF,qEAAqE;AACrE,8EAA8E;AAC9E,uDAAuD;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAG/C,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAgC9B,MAAM,YAAY,GAAG,GAAG,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,aAAa,CACzB,IAAwB,EACxB,UAAyB,EAAE;IAE3B,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IAEnD,IAAI,OAAO,IAA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AAG,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AACrG,CAAC","sourcesContent":["import { type Color, type NormalizedColor, parseColor } from \"@/attributes/shape/fill/color/parser\";\nimport { lerpColor } from \"@/attributes/shape/fill/lerp\";\nimport type { Fill } from \"@/attributes/shape/fill/chain\";\n// A value import, unlike the type-only ones in `texture.ts`: building the rect a\n// fill chain is painted into needs the recorder itself. Safe because\n// `render/graphics2d` reaches only the *effects* chain at runtime, never back\n// into `render3d` — see the note on `SurfaceSource3D`.\nimport { Graphics2D } from \"@/render/graphics2d\";\nimport { looksLikeAssetPath } from \"./texture\";\nimport type { SurfaceSource3D, Texture3D } from \"./texture\";\n\nexport { looksLikeAssetPath };\n\n/**\n * What a surface is made of.\n *\n * The same value a 2D `fill` takes, so a mesh and a rect are described with one\n * vocabulary: a colour, a gradient, an image, a video, a noise field, a whole\n * stack of blended layers — and, because a `Node2D` subtree and a built\n * `Graphics2D` are fills too, any 2D content at all.\n *\n * This is the 3D counterpart of Spline's material *stack*, built on the fill\n * chain that already exists rather than on a second set of layer types. What it\n * replaces is a flat `color` plus five separate texture slots (`map`,\n * `emissiveMap`, `alphaMap`, `envMap`, `lightMap`), each of which was a fill\n * wearing a different name.\n */\nexport type Fill3D = Color | Fill | Texture3D | SurfaceSource3D;\n\n/** What a {@link Fill3D} contributes to a material descriptor. */\nexport interface ResolvedFill3D {\n color?: Color;\n map?: Texture3D;\n}\n\n/** Sizing for the buffer a rich fill is rasterized into. */\nexport interface Fill3DOptions {\n /** Default 512. */\n width?: number;\n /** Default 512. */\n height?: number;\n}\n\nconst DEFAULT_SIZE = 512;\n\n/**\n * Resolve a {@link Fill3D} into the material fields it describes.\n *\n * Three outcomes, and which one applies is decided by what the fill *is* rather\n * than by an author picking a slot:\n *\n * - **A colour** stays a colour. `fill=\"tomato\"` writes `material.color`, costs\n * nothing, and is by far the common case — so it must not be the one that\n * allocates a texture.\n * - **A texture** (an asset path, or any `Texture3D` descriptor) becomes `map`.\n * - **Anything richer** — a gradient, a layer stack, a `Node2D` subtree, a built\n * `Graphics2D`, a nested `Scene3D` — is painted into an offscreen buffer and\n * bound as `map`, through exactly the `Tex.surface` machinery that already\n * existed for putting 2D content on geometry.\n *\n * That last arm is what makes the 2D and 3D fill vocabularies genuinely one\n * thing: `Fills.canvas3D(scene)` inside a chain renders 3D into a layer of a\n * material on a mesh, with no new code path, because the 2D fill renderer was\n * already able to do it.\n */\nexport function resolveFill3D(\n fill: Fill3D | undefined,\n options: Fill3DOptions = {},\n): ResolvedFill3D {\n if (fill === undefined || fill === null) return {};\n\n if (typeof fill === \"string\") {\n // A bare string is ambiguous between a colour and an asset path, and both\n // are things authors write. Resolved the way the material handler already\n // resolved a `color` that looked like a file — so this is the existing\n // rule moved somewhere it can be stated once.\n return looksLikeAssetPath(fill) ? { map: fill } : { color: fill };\n }\n\n if (Array.isArray(fill)) {\n // A `Color` is also an array — of numbers. A fill chain is an array of\n // layers, which are strings or objects.\n if (fill.every((entry) => typeof entry === \"number\")) {\n return { color: fill as unknown as Color };\n }\n return { map: rasterized(fill as Fill, options) };\n }\n\n if (typeof fill === \"object\") {\n if (isSurfaceSourceValue(fill)) return { map: surfaceFor(fill as SurfaceSource3D, options) };\n if (isTextureDescriptor(fill)) return { map: fill as Texture3D };\n if (isSolidLayer(fill)) return { color: (fill as { color: Color }).color };\n }\n\n return { map: rasterized(fill as Fill, options) };\n}\n\n/**\n * A surface texture painting `source` directly.\n *\n * Identity comes from the source object, which the `Tex.surface` contract already\n * requires to be hoisted — so nothing has to be written by hand and a source that\n * goes out of scope stops being cached.\n */\nfunction surfaceFor(source: SurfaceSource3D, options: Fill3DOptions): Texture3D {\n return {\n source,\n width: options.width ?? DEFAULT_SIZE,\n height: options.height ?? DEFAULT_SIZE,\n };\n}\n\n/**\n * A surface texture painting a fill chain into a rect that fills the buffer.\n *\n * Marked `static` and given a derived identity, because a fill chain describes\n * the *same* pixels every frame unless one of its own values moved. Without both\n * of those a gradient on a cube would re-rasterize a 512² offscreen buffer and\n * re-upload it sixty times a second to produce an identical image — which is\n * exactly the trap that makes \"just render it to a texture\" a bad idea in\n * general, and is worth the small amount of bookkeeping to avoid.\n *\n * A chain holding something genuinely live (a video layer, a `Fills.canvas3D`) is\n * still re-rasterized: those carry object identity, which `fillIdentity` folds in\n * and which changes when the content does.\n */\nfunction rasterized(fill: Fill, options: Fill3DOptions): Texture3D {\n const width = options.width ?? DEFAULT_SIZE;\n const height = options.height ?? DEFAULT_SIZE;\n return {\n source: new Graphics2D().rect({ width, height }).fill(fill),\n width,\n height,\n static: true,\n identity: `fill:${fillIdentity(fill)}:${width}x${height}`,\n };\n}\n\n/** True for a `Texture3D` descriptor object (not a source value). */\nfunction isTextureDescriptor(value: object): boolean {\n return \"src\" in value || \"data\" in value || (\"source\" in value && \"width\" in value);\n}\n\n/**\n * True for a value that is 2D content to be painted, rather than a descriptor.\n *\n * Structural, like `resolveSurfaceSource`, and for the same reason: an\n * `instanceof` here would need value imports of `Node2D` and close a real module\n * cycle. A `Scene3D` also exposes `ops()`, so it is excluded explicitly — it is a\n * fill *layer* (`Fills.canvas3D`) rather than a 2D source, and routing it through\n * the chain arm is what gets it composited with the rest of the stack.\n */\nfunction isSurfaceSourceValue(value: object): boolean {\n const bag = value as Record<string, unknown>;\n if (typeof bag.cameraDescriptor === \"function\") return false;\n if (typeof bag.ops === \"function\") return true;\n return typeof bag.id === \"string\" && typeof bag.attach === \"function\";\n}\n\n/** True for a single solid-colour fill layer, which needs no texture. */\nfunction isSolidLayer(value: object): boolean {\n const bag = value as Record<string, unknown>;\n if (bag.type !== \"solid\" || bag.color === undefined) return false;\n // Anything beyond the colour — a per-layer opacity, a blend mode, a\n // reference space — is a composite the colour slot cannot express.\n return bag.opacity === undefined && bag.blend === undefined && bag.space === undefined;\n}\n\n/**\n * Interpolate two fills.\n *\n * Colours interpolate — that is the overwhelmingly common tween and it must not\n * snap. Anything else holds the start value and swaps at the end, because there\n * is no meaningful halfway between a gradient and a photograph; cross-fading two\n * surfaces is a *stack* (`fill={[a, b]}` with the second layer's opacity tweened),\n * which is how it is expressed in 2D too.\n *\n * The colour test is deliberately cheap and allocation-free: resolving a rich\n * fill builds a `Graphics2D` and a texture descriptor, and doing that twice per\n * frame for a tween that is going to snap anyway would be pure waste.\n */\nexport function lerpFill3D(from: Fill3D, to: Fill3D, t: number): Fill3D {\n const start = asPlainColor(from);\n const end = asPlainColor(to);\n if (start !== null && end !== null) {\n return lerpColor(normalize(start), normalize(end), t) as unknown as Fill3D;\n }\n return t < 1 ? from : to;\n}\n\n/** The colour a fill *is*, or `null` when it is anything richer. No allocation. */\nfunction asPlainColor(fill: Fill3D | undefined): Color | null {\n if (fill === undefined || fill === null) return null;\n if (typeof fill === \"string\") return looksLikeAssetPath(fill) ? null : fill;\n if (Array.isArray(fill)) {\n return fill.every((entry) => typeof entry === \"number\") ? (fill as unknown as Color) : null;\n }\n if (typeof fill === \"object\" && isSolidLayer(fill)) return (fill as { color: Color }).color;\n return null;\n}\n\nfunction normalize(color: Color): NormalizedColor {\n return Array.isArray(color) ? (color as NormalizedColor) : parseColor(color);\n}\n\nconst objectIds = new WeakMap<object, string>();\nlet objectCounter = 0;\n\n/**\n * A stable key for a fill value.\n *\n * Plain data is walked and sorted; anything with a prototype of its own — a\n * `Scene3D`, a `Graphics2D`, a video source — is keyed by object identity, which\n * is both cheaper than serialising it and the honest answer, since two different\n * instances describe two different things whatever their fields say. A\n * `FillChain` is unwrapped to its list first, so building one inline still\n * produces the same key for the same layers.\n */\nfunction fillIdentity(value: unknown): string {\n if (value === null || typeof value !== \"object\") return String(value);\n if (Array.isArray(value)) return `[${value.map(fillIdentity).join(\",\")}]`;\n\n const list = (value as { list?: unknown }).list;\n if (Array.isArray(list)) return fillIdentity(list);\n\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n let id = objectIds.get(value);\n if (id === undefined) {\n id = `@${objectCounter++}`;\n objectIds.set(value, id);\n }\n return id;\n }\n\n const bag = value as Record<string, unknown>;\n return `{${Object.keys(bag).sort().map((key) => `${key}:${fillIdentity(bag[key])}`).join(\",\")}}`;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/render3d/geometry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,UAAU,EAAE,MAAM,sCAAsC,CAAC;AA0U9E,+EAA+E;AAC/E,MAAM,UAAU,aAAa,CACzB,MAAsD;IAEtD,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxC,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxD,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,cAAc,CAAC,KAAmC;IAC9D,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACrC,MAAM,OAAO,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACpE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,GAAG,CAAC;IACjC,OAAO;QACH,IAAI;QACJ,2EAA2E;QAC3E,mEAAmE;QACnE,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,IAAI,GAAG,CAAC;QACxC,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,CAAC;QAC3B,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,CAAC;KAClC,CAAC;AACN,CAAC;AAED;;;;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GAAG,CAAC,CAAC;YAAC,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;QAClE,CAAC;IACL,CAAC;IAED,OAAO;QACH,IAAI,EAAE,QAAQ;QACd,QAAQ;QACR,EAAE;QACF,KAAK;QACL,KAAK;QACL,cAAc,EAAE,QAAQ,CAAC,cAAc;QACvC,MAAM,EAAE,QAAQ,CAAC,MAAM;KAC1B,CAAC;AACN,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,gBAAgB,CAAC,KAAY;IAClC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACxE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,mEAAmE;AACnE,SAAS,YAAY,CAAC,OAAe;IACjC,OAAO,OAAO,IAAI,OAAO;QACrB,CAAC,CAAC,OAAO,GAAG,KAAK;QACjB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,GAAG,KAAK,CAAC,GAAG,KAAK,EAAE,GAAG,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import type { PathData } from \"@/render/descriptors/path\";\r\nimport type { PathBuilder } from \"@/render/descriptors/path-builder\";\r\nimport { type Color, parseColor } from \"@/attributes/shape/fill/color/parser\";\r\nimport type { Vector3, Vector3Input } from \"./vector3\";\r\nimport type { Segments3D } from \"./segments\";\r\n\r\n/**\r\n * Anything not modelled by a named field, assigned straight onto the constructed\r\n * object. The documented last resort — unsafe by construction (it bypasses the\r\n * type system, and the renderer treats any change to it as a full rebuild since\r\n * it cannot know what a given key affects), but it means no author is ever\r\n * blocked waiting for a field to be modelled here.\r\n *\r\n * **Where it is applied**: materials, lights (and a light's `shadow`) and\r\n * cameras. **Where it is not**: geometries, the environment and post effects. A\r\n * `params` there is recorded and nothing reads it (probe: `box({ params: { name:\r\n * \"x\" } })` leaves the built geometry's `name` empty), and in development the\r\n * first one warns. Set a geometry's own fields instead.\r\n */\r\nexport interface Passthrough3D {\r\n params?: Record<string, unknown>;\r\n}\r\n\r\n/**\r\n * A partial revolution, shared by every shape that has one.\r\n *\r\n * `Ellipse` has said `startAngle` / `sweep` in degrees since the beginning, so 3D\r\n * says it too. It replaces three's five spellings of the same idea —\r\n * `thetaStart`, `thetaLength`, `phiStart`, `phiLength` and `arc` — which differ\r\n * per shape for reasons that are about three's own history rather than about\r\n * anything an author is trying to draw.\r\n */\r\nexport interface Sweep3D {\r\n /** Where the revolution begins, in **degrees**. Default 0. */\r\n startAngle?: number;\r\n /** How far it runs, in **degrees**. Default 360 (or 180 for a half sweep). */\r\n sweep?: number;\r\n}\r\n\r\n// ─── Primitives ──────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * A box.\r\n *\r\n * `cornerRadius` is the same control `Rect` carries in 2D and rounds all twelve\r\n * edges; it is most of the difference between a scene that reads as designed and\r\n * one that reads as a renderer test. See `evaluateRoundedBox` for how the\r\n * surface is built.\r\n */\r\nexport interface BoxGeometry3D extends Passthrough3D {\r\n type: \"box\";\r\n width?: number;\r\n height?: number;\r\n depth?: number;\r\n /** Rounds every edge and corner. Clamped to the smallest half-extent. */\r\n cornerRadius?: number;\r\n /** Face subdivision, as `[x, y, z]`. Default 1. */\r\n segments?: Segments3D;\r\n}\r\n\r\n/** A sphere, or a wedge/band of one via {@link Sweep3D} and the latitude pair. */\r\nexport interface SphereGeometry3D extends Passthrough3D, Sweep3D {\r\n type: \"sphere\";\r\n radius?: number;\r\n /** `[longitude, latitude]`. Default `[32, 16]`. */\r\n segments?: Segments3D;\r\n /** Vertical band start, in **degrees** from the north pole. Default 0. */\r\n startLatitude?: number;\r\n /** Vertical band extent, in **degrees**. Default 180 (pole to pole). */\r\n latitudeSweep?: number;\r\n}\r\n\r\nexport interface PlaneGeometry3D extends Passthrough3D {\r\n type: \"plane\";\r\n width?: number;\r\n height?: number;\r\n /** `[width, height]`. Raise to subdivide for per-vertex displacement. */\r\n segments?: Segments3D;\r\n}\r\n\r\n/**\r\n * A cylinder, or any tapered tube.\r\n *\r\n * `radius` takes `[top, bottom]` for a taper, which is what `radiusTop` and\r\n * `radiusBottom` were — one field, and the pair reads as the thing it describes.\r\n */\r\nexport interface CylinderGeometry3D extends Passthrough3D, Sweep3D {\r\n type: \"cylinder\";\r\n /** A scalar, or `[top, bottom]` to taper. Default 1. */\r\n radius?: number | readonly [number, number];\r\n height?: number;\r\n /** `[radial, height]`. Default `[32, 1]`. */\r\n segments?: Segments3D;\r\n /** Draw the end caps. Default true. */\r\n capped?: boolean;\r\n}\r\n\r\nexport interface ConeGeometry3D extends Passthrough3D, Sweep3D {\r\n type: \"cone\";\r\n radius?: number;\r\n height?: number;\r\n /** `[radial, height]`. Default `[32, 1]`. */\r\n segments?: Segments3D;\r\n /** Draw the base cap. Default true. */\r\n capped?: boolean;\r\n}\r\n\r\nexport interface TorusGeometry3D extends Passthrough3D, Sweep3D {\r\n type: \"torus\";\r\n /** Distance from the centre to the middle of the ring. */\r\n radius?: number;\r\n /** Thickness of the ring itself. Default 0.4. */\r\n thickness?: number;\r\n /** `[radial, tubular]`. Default `[16, 48]`. */\r\n segments?: Segments3D;\r\n}\r\n\r\nexport interface TorusKnotGeometry3D extends Passthrough3D {\r\n type: \"torusKnot\";\r\n radius?: number;\r\n /** Thickness of the strand. Default 0.4. */\r\n thickness?: number;\r\n /** `[tubular, radial]`. Default `[64, 8]`. */\r\n segments?: Segments3D;\r\n /** Winding counts as `[around the axis, around the torus]`. Default `[2, 3]`. */\r\n windings?: readonly [number, number];\r\n}\r\n\r\nexport interface CircleGeometry3D extends Passthrough3D, Sweep3D {\r\n type: \"circle\";\r\n radius?: number;\r\n /** Default 32. */\r\n segments?: Segments3D;\r\n}\r\n\r\n/** A flat annulus — a disc with a hole. */\r\nexport interface RingGeometry3D extends Passthrough3D, Sweep3D {\r\n type: \"ring\";\r\n /** Outer radius. Default 1. */\r\n radius?: number;\r\n /** Inner radius — the size of the hole. Default 0.5. */\r\n innerRadius?: number;\r\n /** `[around, radial]`. Default `[32, 1]`. */\r\n segments?: Segments3D;\r\n}\r\n\r\nexport interface CapsuleGeometry3D extends Passthrough3D {\r\n type: \"capsule\";\r\n /** Default 0.5. */\r\n radius?: number;\r\n /** Length of the straight mid-section, excluding the caps. Default 1. */\r\n height?: number;\r\n /** `[radial, cap]`. Default `[16, 8]`. */\r\n segments?: Segments3D;\r\n}\r\n\r\nexport interface PolyhedronGeometry3D extends Passthrough3D {\r\n type: \"polyhedron\";\r\n shape: \"tetrahedron\" | \"octahedron\" | \"icosahedron\" | \"dodecahedron\";\r\n radius?: number;\r\n /** Subdivision. Raising this on an icosahedron approximates a sphere. */\r\n segments?: Segments3D;\r\n}\r\n\r\n// ─── Path-derived (reuses core's own 2D path vocabulary) ─────────────────────\r\n\r\n/** How an extrusion's edge is chamfered. A bare number is the bevel's size. */\r\nexport interface Bevel3D {\r\n size?: number;\r\n thickness?: number;\r\n offset?: number;\r\n segments?: number;\r\n}\r\n\r\n/**\r\n * A 2D outline swept into a solid. `path` accepts the same `PathData` (SVG\r\n * string or command list) or {@link PathBuilder} the 2D `Path` node takes — same\r\n * name, same value — so an existing 2D outline becomes an extruded solid with no\r\n * new vocabulary.\r\n */\r\nexport interface ExtrudeGeometry3D extends Passthrough3D {\r\n type: \"extrude\";\r\n path: PathData | PathBuilder;\r\n depth?: number;\r\n /** Curve flattening resolution. Default 12. */\r\n segments?: Segments3D;\r\n /** A number is the bevel size; an object tunes the rest. Omit for no bevel. */\r\n bevel?: number | Bevel3D;\r\n}\r\n\r\n/** A profile revolved about the Y axis — vases, bowls, turned shapes. */\r\nexport interface LatheGeometry3D extends Passthrough3D, Sweep3D {\r\n type: \"lathe\";\r\n /** Profile points in the XY plane; `x` is the radius, `y` the height. */\r\n points: readonly Vector3Input[];\r\n /** Default 12. */\r\n segments?: Segments3D;\r\n}\r\n\r\n/** A circular cross-section swept along a 3D curve. */\r\nexport interface TubeGeometry3D extends Passthrough3D {\r\n type: \"tube\";\r\n points: readonly Vector3Input[];\r\n radius?: number;\r\n /** `[along the curve, around it]`. Default `[64, 8]`. */\r\n segments?: Segments3D;\r\n closed?: boolean;\r\n}\r\n\r\n// ─── Arbitrary vertex data ───────────────────────────────────────────────────\r\n\r\n/**\r\n * Raw vertex buffers — the general escape hatch that makes *any* computable mesh\r\n * expressible without leaving pure data.\r\n *\r\n * `position` is required and holds `[x, y, z, x, y, z, …]`. `index` lets vertices\r\n * be shared between faces. Omit `normal` and set {@link computeNormals} to have\r\n * them derived.\r\n */\r\nexport interface BufferGeometry3D extends Passthrough3D {\r\n type: \"buffer\";\r\n /** Flat `xyz` triples. */\r\n position: ArrayLike<number>;\r\n /** Flat `xyz` triples. Omit and set {@link computeNormals} to derive them. */\r\n normal?: ArrayLike<number>;\r\n /** Flat `uv` pairs. */\r\n uv?: ArrayLike<number>;\r\n /** Flat linear `rgb` triples. Needs `vertexColors: true` on the material. */\r\n color?: ArrayLike<number>;\r\n /** Triangle indices into the arrays above. */\r\n index?: ArrayLike<number>;\r\n /** Derive vertex normals after upload — needed for correct lighting. */\r\n computeNormals?: boolean;\r\n /**\r\n * Bump after mutating an array **in place** to force a re-upload.\r\n *\r\n * Reusing one `Float32Array` across frames and writing into it is the fast\r\n * way to animate a mesh, but it defeats identity comparison — the renderer\r\n * sees the same array object and cannot tell the contents changed. Bumping\r\n * `revision` tells it explicitly.\r\n *\r\n * With `revision` omitted the renderer re-uploads every frame, which is\r\n * correct-by-default for a buffer you built deliberately. Set\r\n * {@link staticData} once the data stops changing.\r\n */\r\n revision?: number;\r\n /**\r\n * Declare the arrays immutable, so the renderer compares by identity alone\r\n * and skips the per-frame re-upload. Only safe when you never mutate in place.\r\n */\r\n staticData?: boolean;\r\n}\r\n\r\n/** One evaluated vertex of a {@link ParametricGeometry3D} surface. */\r\nexport type ParametricVertex3D = Vector3 | readonly [number, number, number];\r\n\r\n/**\r\n * A surface sampled over a `[0,1] × [0,1]` grid — the ergonomic form of\r\n * {@link BufferGeometry3D} for procedural meshes (waves, terrain, ribbons).\r\n *\r\n * Core evaluates the callbacks into vertex buffers at record time, so the\r\n * descriptor handed to the renderer is still plain data. Re-evaluated every\r\n * frame, so read the node's props and the frame time inside `vertex`.\r\n *\r\n * Geo.parametric({\r\n * segments: [70, 70],\r\n * vertex: (u, v) => ({ x: (u - 0.5) * 20, y: wave(u, v, t), z: (v - 0.5) * 20 }),\r\n * computeNormals: true,\r\n * })\r\n */\r\nexport interface ParametricGeometry3D extends Passthrough3D {\r\n type: \"parametric\";\r\n /** Grid resolution as `[u, v]`, or one number for both. */\r\n segments: Segments3D;\r\n /** Position for grid coordinate `(u, v)`, both in `[0, 1]`. */\r\n vertex: (u: number, v: number) => ParametricVertex3D;\r\n /** Optional per-vertex colour. Needs `vertexColors: true` on the material. */\r\n color?: (u: number, v: number, position: Vector3) => Color;\r\n /** Derive vertex normals. Almost always wanted for a lit surface. */\r\n computeNormals?: boolean;\r\n /**\r\n * A value that changes exactly when {@link vertex} would return something\r\n * different — supply it and the surface is re-evaluated only when it moves.\r\n *\r\n * Omitted (the default) the surface is re-evaluated **every frame**, which is\r\n * what makes the `read the node's props and the frame time inside vertex` contract\r\n * above work without any bookkeeping. It is also expensive: `segments: 80` is\r\n * ~6.6k calls to `vertex`, plus normals and a full buffer re-upload, and a\r\n * frame draws for any reason at all — an unrelated node being dragged, the\r\n * camera orbiting, a tween elsewhere in the scene. A surface whose shape did\r\n * not change pays all of that for an identical result.\r\n *\r\n * `vertex` is a closure, so the renderer cannot inspect what it captured;\r\n * only the author knows. Derive this from exactly those captures — the\r\n * domain, the amplitude, the identity of the function being plotted — and\r\n * leave it out for a surface that genuinely varies with time.\r\n *\r\n * Same name and same role as {@link BufferGeometry3D.revision}: the explicit\r\n * \"this is what changed\" marker. `segments` needs no help here, being plain\r\n * data the renderer already compares.\r\n */\r\n revision?: number;\r\n}\r\n\r\n// ─── Derived ─────────────────────────────────────────────────────────────────\r\n\r\n/**\r\n * The hard edges of another geometry, as line segments — a clean wireframe\r\n * outline without the diagonals of a triangulated one. Draw it with\r\n * `Graphics3D.line({ segments: true })`.\r\n */\r\nexport interface EdgesGeometry3D extends Passthrough3D {\r\n type: \"edges\";\r\n source: Geometry3D;\r\n /** Minimum dihedral angle in **degrees** for an edge to count. Default 1. */\r\n thresholdAngle?: number;\r\n}\r\n\r\n/** Every triangle edge of another geometry, as line segments. */\r\nexport interface WireframeGeometry3D extends Passthrough3D {\r\n type: \"wireframe\";\r\n source: Geometry3D;\r\n}\r\n\r\n/** Geometry taken from a loaded model file, by node name. */\r\nexport interface ModelGeometry3D extends Passthrough3D {\r\n type: \"modelGeometry\";\r\n src: string;\r\n /** Which node of the model to take. Defaults to the first mesh found. */\r\n node?: string;\r\n}\r\n\r\n/** Normalize {@link CylinderGeometry3D.radius} to its `[top, bottom]` pair. */\r\nexport function cylinderRadii(\r\n radius: number | readonly [number, number] | undefined,\r\n): [number, number] {\r\n if (radius === undefined) return [1, 1];\r\n if (typeof radius === \"number\") return [radius, radius];\r\n return [radius[0] ?? 1, radius[1] ?? radius[0] ?? 1];\r\n}\r\n\r\n/** Normalize {@link ExtrudeGeometry3D.bevel} to its full option set, or `null`. */\r\nexport function resolveBevel3D(bevel: number | Bevel3D | undefined): Required<Bevel3D> | null {\r\n if (bevel === undefined) return null;\r\n const options = typeof bevel === \"number\" ? { size: bevel } : bevel;\r\n const size = options.size ?? 0.1;\r\n return {\r\n size,\r\n // Scaled off `size` rather than defaulted independently, so the one-number\r\n // form produces a bevel with sane proportions instead of a sliver.\r\n thickness: options.thickness ?? size * 2,\r\n offset: options.offset ?? 0,\r\n segments: options.segments ?? 3,\r\n };\r\n}\r\n\r\n/**\r\n * Evaluate a {@link ParametricGeometry3D} into concrete vertex buffers.\r\n *\r\n * Lives in core rather than the renderer so the grid/winding maths is\r\n * backend-agnostic and unit-testable without a GPU. Called by the renderer at\r\n * draw time (not at record time) so the cost is only paid when the frame is\r\n * actually rasterized, and never during the asset-tracking replay.\r\n *\r\n * The grid is `(segments + 1)²` vertices wound counter-clockwise, so front faces\r\n * point along +Y for a surface authored in the XZ plane.\r\n */\r\nexport function evaluateParametric(geometry: ParametricGeometry3D): BufferGeometry3D {\r\n const resolved = geometry.segments;\r\n const [uSegments, vSegments] = typeof resolved === \"number\"\r\n ? [resolved, resolved]\r\n : [resolved[0] ?? 1, resolved[1] ?? resolved[0] ?? 1];\r\n\r\n const uCount = Math.max(1, Math.floor(uSegments)) + 1;\r\n const vCount = Math.max(1, Math.floor(vSegments)) + 1;\r\n\r\n const position = new Float32Array(uCount * vCount * 3);\r\n const uv = new Float32Array(uCount * vCount * 2);\r\n const color = geometry.color ? new Float32Array(uCount * vCount * 3) : undefined;\r\n\r\n const scratch: Vector3 = { x: 0, y: 0, z: 0 };\r\n\r\n for (let vi = 0; vi < vCount; vi++) {\r\n const v = vi / (vCount - 1);\r\n for (let ui = 0; ui < uCount; ui++) {\r\n const u = ui / (uCount - 1);\r\n const index = vi * uCount + ui;\r\n\r\n const vertex = geometry.vertex(u, v);\r\n if (Array.isArray(vertex)) {\r\n scratch.x = vertex[0]; scratch.y = vertex[1]; scratch.z = vertex[2];\r\n } else {\r\n const p = vertex as Vector3;\r\n scratch.x = p.x; scratch.y = p.y; scratch.z = p.z;\r\n }\r\n\r\n position[index * 3] = scratch.x;\r\n position[index * 3 + 1] = scratch.y;\r\n position[index * 3 + 2] = scratch.z;\r\n\r\n uv[index * 2] = u;\r\n uv[index * 2 + 1] = v;\r\n\r\n if (color && geometry.color) {\r\n const rgba = resolveLinearRgb(geometry.color(u, v, scratch));\r\n color[index * 3] = rgba[0];\r\n color[index * 3 + 1] = rgba[1];\r\n color[index * 3 + 2] = rgba[2];\r\n }\r\n }\r\n }\r\n\r\n // Two triangles per cell. Uint32 because a 256² grid already exceeds Uint16.\r\n const index = new Uint32Array((uCount - 1) * (vCount - 1) * 6);\r\n let cursor = 0;\r\n for (let vi = 0; vi < vCount - 1; vi++) {\r\n for (let ui = 0; ui < uCount - 1; ui++) {\r\n const a = vi * uCount + ui;\r\n const b = a + 1;\r\n const c = a + uCount;\r\n const d = c + 1;\r\n index[cursor++] = a; index[cursor++] = c; index[cursor++] = b;\r\n index[cursor++] = b; index[cursor++] = c; index[cursor++] = d;\r\n }\r\n }\r\n\r\n return {\r\n type: \"buffer\",\r\n position,\r\n uv,\r\n color,\r\n index,\r\n computeNormals: geometry.computeNormals,\r\n params: geometry.params,\r\n };\r\n}\r\n\r\n/**\r\n * A {@link Color} as **linear-light** RGB, which is what a vertex-colour buffer\r\n * must hold: a renderer samples that attribute directly into its linear working\r\n * space, with no decode step of its own.\r\n *\r\n * `parseColor` returns gamma-encoded sRGB (hex is `byte / 255`), so the sRGB\r\n * transfer function has to be inverted here. Skipping this renders vertex-coloured\r\n * surfaces visibly washed out.\r\n */\r\nfunction resolveLinearRgb(color: Color): readonly [number, number, number] {\r\n const [r, g, b] = typeof color === \"string\" ? parseColor(color) : color;\r\n return [srgbToLinear(r), srgbToLinear(g), srgbToLinear(b)];\r\n}\r\n\r\n/** Inverse sRGB transfer function (IEC 61966-2-1), per channel. */\r\nfunction srgbToLinear(channel: number): number {\r\n return channel <= 0.04045\r\n ? channel / 12.92\r\n : Math.pow((channel + 0.055) / 1.055, 2.4);\r\n}\r\n\r\n/**\r\n * Every geometry a mesh can be built from. Discriminated on `type`, so new\r\n * shapes are additive.\r\n */\r\nexport type Geometry3D =\r\n | BoxGeometry3D\r\n | SphereGeometry3D\r\n | PlaneGeometry3D\r\n | CylinderGeometry3D\r\n | ConeGeometry3D\r\n | TorusGeometry3D\r\n | TorusKnotGeometry3D\r\n | CircleGeometry3D\r\n | RingGeometry3D\r\n | CapsuleGeometry3D\r\n | PolyhedronGeometry3D\r\n | ExtrudeGeometry3D\r\n | LatheGeometry3D\r\n | TubeGeometry3D\r\n | BufferGeometry3D\r\n | ParametricGeometry3D\r\n | EdgesGeometry3D\r\n | WireframeGeometry3D\r\n | ModelGeometry3D;\r\n"]}
1
+ {"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/render3d/geometry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,UAAU,EAAE,MAAM,sCAAsC,CAAC;AA0U9E,+EAA+E;AAC/E,MAAM,UAAU,aAAa,CACzB,MAAsD;IAEtD,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxC,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxD,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,cAAc,CAAC,KAAmC;IAC9D,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACrC,MAAM,OAAO,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACpE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,GAAG,CAAC;IACjC,OAAO;QACH,IAAI;QACJ,2EAA2E;QAC3E,mEAAmE;QACnE,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,IAAI,GAAG,CAAC;QACxC,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,CAAC;QAC3B,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,CAAC;KAClC,CAAC;AACN,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAA8B;IAC7D,MAAM,QAAQ,GAAG,QAAQ,CA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,CAAC;IAED,OAAO;QACH,IAAI,EAAE,QAAQ;QACd,QAAQ;QACR,EAAE;QACF,KAAK;QACL,KAAK;QACL,cAAc,EAAE,QAAQ,CAAC,cAAc;QACvC,MAAM,EAAE,QAAQ,CAAC,MAAM;KAC1B,CAAC;AACN,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,gBAAgB,CAAC,KAAY;IAClC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACxE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,mEAAmE;AACnE,SAAS,YAAY,CAAC,OAAe;IACjC,OAAO,OAAO,IAAI,OAAO;QACrB,CAAC,CAAC,OAAO,GAAG,KAAK;QACjB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,GAAG,KAAK,CAAC,GAAG,KAAK,EAAE,GAAG,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import type { PathData } from \"@/render/descriptors/path\";\nimport type { PathBuilder } from \"@/render/descriptors/path-builder\";\nimport { type Color, parseColor } from \"@/attributes/shape/fill/color/parser\";\nimport type { Vector3, Vector3Input } from \"./vector3\";\nimport type { Segments3D } from \"./segments\";\n\n/**\n * Anything not modelled by a named field, assigned straight onto the constructed\n * object. The documented last resort — unsafe by construction (it bypasses the\n * type system, and the renderer treats any change to it as a full rebuild since\n * it cannot know what a given key affects), but it means no author is ever\n * blocked waiting for a field to be modelled here.\n *\n * **Where it is applied**: materials, lights (and a light's `shadow`) and\n * cameras. **Where it is not**: geometries, the environment and post effects. A\n * `params` there is recorded and nothing reads it (probe: `box({ params: { name:\n * \"x\" } })` leaves the built geometry's `name` empty), and in development the\n * first one warns. Set a geometry's own fields instead.\n */\nexport interface Passthrough3D {\n params?: Record<string, unknown>;\n}\n\n/**\n * A partial revolution, shared by every shape that has one.\n *\n * `Ellipse` has said `startAngle` / `sweep` in degrees since the beginning, so 3D\n * says it too. It replaces three's five spellings of the same idea —\n * `thetaStart`, `thetaLength`, `phiStart`, `phiLength` and `arc` — which differ\n * per shape for reasons that are about three's own history rather than about\n * anything an author is trying to draw.\n */\nexport interface Sweep3D {\n /** Where the revolution begins, in **degrees**. Default 0. */\n startAngle?: number;\n /** How far it runs, in **degrees**. Default 360 (or 180 for a half sweep). */\n sweep?: number;\n}\n\n// ─── Primitives ──────────────────────────────────────────────────────────────\n\n/**\n * A box.\n *\n * `cornerRadius` is the same control `Rect` carries in 2D and rounds all twelve\n * edges; it is most of the difference between a scene that reads as designed and\n * one that reads as a renderer test. See `evaluateRoundedBox` for how the\n * surface is built.\n */\nexport interface BoxGeometry3D extends Passthrough3D {\n type: \"box\";\n width?: number;\n height?: number;\n depth?: number;\n /** Rounds every edge and corner. Clamped to the smallest half-extent. */\n cornerRadius?: number;\n /** Face subdivision, as `[x, y, z]`. Default 1. */\n segments?: Segments3D;\n}\n\n/** A sphere, or a wedge/band of one via {@link Sweep3D} and the latitude pair. */\nexport interface SphereGeometry3D extends Passthrough3D, Sweep3D {\n type: \"sphere\";\n radius?: number;\n /** `[longitude, latitude]`. Default `[32, 16]`. */\n segments?: Segments3D;\n /** Vertical band start, in **degrees** from the north pole. Default 0. */\n startLatitude?: number;\n /** Vertical band extent, in **degrees**. Default 180 (pole to pole). */\n latitudeSweep?: number;\n}\n\nexport interface PlaneGeometry3D extends Passthrough3D {\n type: \"plane\";\n width?: number;\n height?: number;\n /** `[width, height]`. Raise to subdivide for per-vertex displacement. */\n segments?: Segments3D;\n}\n\n/**\n * A cylinder, or any tapered tube.\n *\n * `radius` takes `[top, bottom]` for a taper, which is what `radiusTop` and\n * `radiusBottom` were — one field, and the pair reads as the thing it describes.\n */\nexport interface CylinderGeometry3D extends Passthrough3D, Sweep3D {\n type: \"cylinder\";\n /** A scalar, or `[top, bottom]` to taper. Default 1. */\n radius?: number | readonly [number, number];\n height?: number;\n /** `[radial, height]`. Default `[32, 1]`. */\n segments?: Segments3D;\n /** Draw the end caps. Default true. */\n capped?: boolean;\n}\n\nexport interface ConeGeometry3D extends Passthrough3D, Sweep3D {\n type: \"cone\";\n radius?: number;\n height?: number;\n /** `[radial, height]`. Default `[32, 1]`. */\n segments?: Segments3D;\n /** Draw the base cap. Default true. */\n capped?: boolean;\n}\n\nexport interface TorusGeometry3D extends Passthrough3D, Sweep3D {\n type: \"torus\";\n /** Distance from the centre to the middle of the ring. */\n radius?: number;\n /** Thickness of the ring itself. Default 0.4. */\n thickness?: number;\n /** `[radial, tubular]`. Default `[16, 48]`. */\n segments?: Segments3D;\n}\n\nexport interface TorusKnotGeometry3D extends Passthrough3D {\n type: \"torusKnot\";\n radius?: number;\n /** Thickness of the strand. Default 0.4. */\n thickness?: number;\n /** `[tubular, radial]`. Default `[64, 8]`. */\n segments?: Segments3D;\n /** Winding counts as `[around the axis, around the torus]`. Default `[2, 3]`. */\n windings?: readonly [number, number];\n}\n\nexport interface CircleGeometry3D extends Passthrough3D, Sweep3D {\n type: \"circle\";\n radius?: number;\n /** Default 32. */\n segments?: Segments3D;\n}\n\n/** A flat annulus — a disc with a hole. */\nexport interface RingGeometry3D extends Passthrough3D, Sweep3D {\n type: \"ring\";\n /** Outer radius. Default 1. */\n radius?: number;\n /** Inner radius — the size of the hole. Default 0.5. */\n innerRadius?: number;\n /** `[around, radial]`. Default `[32, 1]`. */\n segments?: Segments3D;\n}\n\nexport interface CapsuleGeometry3D extends Passthrough3D {\n type: \"capsule\";\n /** Default 0.5. */\n radius?: number;\n /** Length of the straight mid-section, excluding the caps. Default 1. */\n height?: number;\n /** `[radial, cap]`. Default `[16, 8]`. */\n segments?: Segments3D;\n}\n\nexport interface PolyhedronGeometry3D extends Passthrough3D {\n type: \"polyhedron\";\n shape: \"tetrahedron\" | \"octahedron\" | \"icosahedron\" | \"dodecahedron\";\n radius?: number;\n /** Subdivision. Raising this on an icosahedron approximates a sphere. */\n segments?: Segments3D;\n}\n\n// ─── Path-derived (reuses core's own 2D path vocabulary) ─────────────────────\n\n/** How an extrusion's edge is chamfered. A bare number is the bevel's size. */\nexport interface Bevel3D {\n size?: number;\n thickness?: number;\n offset?: number;\n segments?: number;\n}\n\n/**\n * A 2D outline swept into a solid. `path` accepts the same `PathData` (SVG\n * string or command list) or {@link PathBuilder} the 2D `Path` node takes — same\n * name, same value — so an existing 2D outline becomes an extruded solid with no\n * new vocabulary.\n */\nexport interface ExtrudeGeometry3D extends Passthrough3D {\n type: \"extrude\";\n path: PathData | PathBuilder;\n depth?: number;\n /** Curve flattening resolution. Default 12. */\n segments?: Segments3D;\n /** A number is the bevel size; an object tunes the rest. Omit for no bevel. */\n bevel?: number | Bevel3D;\n}\n\n/** A profile revolved about the Y axis — vases, bowls, turned shapes. */\nexport interface LatheGeometry3D extends Passthrough3D, Sweep3D {\n type: \"lathe\";\n /** Profile points in the XY plane; `x` is the radius, `y` the height. */\n points: readonly Vector3Input[];\n /** Default 12. */\n segments?: Segments3D;\n}\n\n/** A circular cross-section swept along a 3D curve. */\nexport interface TubeGeometry3D extends Passthrough3D {\n type: \"tube\";\n points: readonly Vector3Input[];\n radius?: number;\n /** `[along the curve, around it]`. Default `[64, 8]`. */\n segments?: Segments3D;\n closed?: boolean;\n}\n\n// ─── Arbitrary vertex data ───────────────────────────────────────────────────\n\n/**\n * Raw vertex buffers — the general escape hatch that makes *any* computable mesh\n * expressible without leaving pure data.\n *\n * `position` is required and holds `[x, y, z, x, y, z, …]`. `index` lets vertices\n * be shared between faces. Omit `normal` and set {@link computeNormals} to have\n * them derived.\n */\nexport interface BufferGeometry3D extends Passthrough3D {\n type: \"buffer\";\n /** Flat `xyz` triples. */\n position: ArrayLike<number>;\n /** Flat `xyz` triples. Omit and set {@link computeNormals} to derive them. */\n normal?: ArrayLike<number>;\n /** Flat `uv` pairs. */\n uv?: ArrayLike<number>;\n /** Flat linear `rgb` triples. Needs `vertexColors: true` on the material. */\n color?: ArrayLike<number>;\n /** Triangle indices into the arrays above. */\n index?: ArrayLike<number>;\n /** Derive vertex normals after upload — needed for correct lighting. */\n computeNormals?: boolean;\n /**\n * Bump after mutating an array **in place** to force a re-upload.\n *\n * Reusing one `Float32Array` across frames and writing into it is the fast\n * way to animate a mesh, but it defeats identity comparison — the renderer\n * sees the same array object and cannot tell the contents changed. Bumping\n * `revision` tells it explicitly.\n *\n * With `revision` omitted the renderer re-uploads every frame, which is\n * correct-by-default for a buffer you built deliberately. Set\n * {@link staticData} once the data stops changing.\n */\n revision?: number;\n /**\n * Declare the arrays immutable, so the renderer compares by identity alone\n * and skips the per-frame re-upload. Only safe when you never mutate in place.\n */\n staticData?: boolean;\n}\n\n/** One evaluated vertex of a {@link ParametricGeometry3D} surface. */\nexport type ParametricVertex3D = Vector3 | readonly [number, number, number];\n\n/**\n * A surface sampled over a `[0,1] × [0,1]` grid — the ergonomic form of\n * {@link BufferGeometry3D} for procedural meshes (waves, terrain, ribbons).\n *\n * Core evaluates the callbacks into vertex buffers at record time, so the\n * descriptor handed to the renderer is still plain data. Re-evaluated every\n * frame, so read the node's props and the frame time inside `vertex`.\n *\n * Geo.parametric({\n * segments: [70, 70],\n * vertex: (u, v) => ({ x: (u - 0.5) * 20, y: wave(u, v, t), z: (v - 0.5) * 20 }),\n * computeNormals: true,\n * })\n */\nexport interface ParametricGeometry3D extends Passthrough3D {\n type: \"parametric\";\n /** Grid resolution as `[u, v]`, or one number for both. */\n segments: Segments3D;\n /** Position for grid coordinate `(u, v)`, both in `[0, 1]`. */\n vertex: (u: number, v: number) => ParametricVertex3D;\n /** Optional per-vertex colour. Needs `vertexColors: true` on the material. */\n color?: (u: number, v: number, position: Vector3) => Color;\n /** Derive vertex normals. Almost always wanted for a lit surface. */\n computeNormals?: boolean;\n /**\n * A value that changes exactly when {@link vertex} would return something\n * different — supply it and the surface is re-evaluated only when it moves.\n *\n * Omitted (the default) the surface is re-evaluated **every frame**, which is\n * what makes the `read the node's props and the frame time inside vertex` contract\n * above work without any bookkeeping. It is also expensive: `segments: 80` is\n * ~6.6k calls to `vertex`, plus normals and a full buffer re-upload, and a\n * frame draws for any reason at all — an unrelated node being dragged, the\n * camera orbiting, a tween elsewhere in the scene. A surface whose shape did\n * not change pays all of that for an identical result.\n *\n * `vertex` is a closure, so the renderer cannot inspect what it captured;\n * only the author knows. Derive this from exactly those captures — the\n * domain, the amplitude, the identity of the function being plotted — and\n * leave it out for a surface that genuinely varies with time.\n *\n * Same name and same role as {@link BufferGeometry3D.revision}: the explicit\n * \"this is what changed\" marker. `segments` needs no help here, being plain\n * data the renderer already compares.\n */\n revision?: number;\n}\n\n// ─── Derived ─────────────────────────────────────────────────────────────────\n\n/**\n * The hard edges of another geometry, as line segments — a clean wireframe\n * outline without the diagonals of a triangulated one. Draw it with\n * `Graphics3D.line({ segments: true })`.\n */\nexport interface EdgesGeometry3D extends Passthrough3D {\n type: \"edges\";\n source: Geometry3D;\n /** Minimum dihedral angle in **degrees** for an edge to count. Default 1. */\n thresholdAngle?: number;\n}\n\n/** Every triangle edge of another geometry, as line segments. */\nexport interface WireframeGeometry3D extends Passthrough3D {\n type: \"wireframe\";\n source: Geometry3D;\n}\n\n/** Geometry taken from a loaded model file, by node name. */\nexport interface ModelGeometry3D extends Passthrough3D {\n type: \"modelGeometry\";\n src: string;\n /** Which node of the model to take. Defaults to the first mesh found. */\n node?: string;\n}\n\n/** Normalize {@link CylinderGeometry3D.radius} to its `[top, bottom]` pair. */\nexport function cylinderRadii(\n radius: number | readonly [number, number] | undefined,\n): [number, number] {\n if (radius === undefined) return [1, 1];\n if (typeof radius === \"number\") return [radius, radius];\n return [radius[0] ?? 1, radius[1] ?? radius[0] ?? 1];\n}\n\n/** Normalize {@link ExtrudeGeometry3D.bevel} to its full option set, or `null`. */\nexport function resolveBevel3D(bevel: number | Bevel3D | undefined): Required<Bevel3D> | null {\n if (bevel === undefined) return null;\n const options = typeof bevel === \"number\" ? { size: bevel } : bevel;\n const size = options.size ?? 0.1;\n return {\n size,\n // Scaled off `size` rather than defaulted independently, so the one-number\n // form produces a bevel with sane proportions instead of a sliver.\n thickness: options.thickness ?? size * 2,\n offset: options.offset ?? 0,\n segments: options.segments ?? 3,\n };\n}\n\n/**\n * Evaluate a {@link ParametricGeometry3D} into concrete vertex buffers.\n *\n * Lives in core rather than the renderer so the grid/winding maths is\n * backend-agnostic and unit-testable without a GPU. Called by the renderer at\n * draw time (not at record time) so the cost is only paid when the frame is\n * actually rasterized, and never during the asset-tracking replay.\n *\n * The grid is `(segments + 1)²` vertices wound counter-clockwise, so front faces\n * point along +Y for a surface authored in the XZ plane.\n */\nexport function evaluateParametric(geometry: ParametricGeometry3D): BufferGeometry3D {\n const resolved = geometry.segments;\n const [uSegments, vSegments] = typeof resolved === \"number\"\n ? [resolved, resolved]\n : [resolved[0] ?? 1, resolved[1] ?? resolved[0] ?? 1];\n\n const uCount = Math.max(1, Math.floor(uSegments)) + 1;\n const vCount = Math.max(1, Math.floor(vSegments)) + 1;\n\n const position = new Float32Array(uCount * vCount * 3);\n const uv = new Float32Array(uCount * vCount * 2);\n const color = geometry.color ? new Float32Array(uCount * vCount * 3) : undefined;\n\n const scratch: Vector3 = { x: 0, y: 0, z: 0 };\n\n for (let vi = 0; vi < vCount; vi++) {\n const v = vi / (vCount - 1);\n for (let ui = 0; ui < uCount; ui++) {\n const u = ui / (uCount - 1);\n const index = vi * uCount + ui;\n\n const vertex = geometry.vertex(u, v);\n if (Array.isArray(vertex)) {\n scratch.x = vertex[0]; scratch.y = vertex[1]; scratch.z = vertex[2];\n } else {\n const p = vertex as Vector3;\n scratch.x = p.x; scratch.y = p.y; scratch.z = p.z;\n }\n\n position[index * 3] = scratch.x;\n position[index * 3 + 1] = scratch.y;\n position[index * 3 + 2] = scratch.z;\n\n uv[index * 2] = u;\n uv[index * 2 + 1] = v;\n\n if (color && geometry.color) {\n const rgba = resolveLinearRgb(geometry.color(u, v, scratch));\n color[index * 3] = rgba[0];\n color[index * 3 + 1] = rgba[1];\n color[index * 3 + 2] = rgba[2];\n }\n }\n }\n\n // Two triangles per cell. Uint32 because a 256² grid already exceeds Uint16.\n const index = new Uint32Array((uCount - 1) * (vCount - 1) * 6);\n let cursor = 0;\n for (let vi = 0; vi < vCount - 1; vi++) {\n for (let ui = 0; ui < uCount - 1; ui++) {\n const a = vi * uCount + ui;\n const b = a + 1;\n const c = a + uCount;\n const d = c + 1;\n index[cursor++] = a; index[cursor++] = c; index[cursor++] = b;\n index[cursor++] = b; index[cursor++] = c; index[cursor++] = d;\n }\n }\n\n return {\n type: \"buffer\",\n position,\n uv,\n color,\n index,\n computeNormals: geometry.computeNormals,\n params: geometry.params,\n };\n}\n\n/**\n * A {@link Color} as **linear-light** RGB, which is what a vertex-colour buffer\n * must hold: a renderer samples that attribute directly into its linear working\n * space, with no decode step of its own.\n *\n * `parseColor` returns gamma-encoded sRGB (hex is `byte / 255`), so the sRGB\n * transfer function has to be inverted here. Skipping this renders vertex-coloured\n * surfaces visibly washed out.\n */\nfunction resolveLinearRgb(color: Color): readonly [number, number, number] {\n const [r, g, b] = typeof color === \"string\" ? parseColor(color) : color;\n return [srgbToLinear(r), srgbToLinear(g), srgbToLinear(b)];\n}\n\n/** Inverse sRGB transfer function (IEC 61966-2-1), per channel. */\nfunction srgbToLinear(channel: number): number {\n return channel <= 0.04045\n ? channel / 12.92\n : Math.pow((channel + 0.055) / 1.055, 2.4);\n}\n\n/**\n * Every geometry a mesh can be built from. Discriminated on `type`, so new\n * shapes are additive.\n */\nexport type Geometry3D =\n | BoxGeometry3D\n | SphereGeometry3D\n | PlaneGeometry3D\n | CylinderGeometry3D\n | ConeGeometry3D\n | TorusGeometry3D\n | TorusKnotGeometry3D\n | CircleGeometry3D\n | RingGeometry3D\n | CapsuleGeometry3D\n | PolyhedronGeometry3D\n | ExtrudeGeometry3D\n | LatheGeometry3D\n | TubeGeometry3D\n | BufferGeometry3D\n | ParametricGeometry3D\n | EdgesGeometry3D\n | WireframeGeometry3D\n | ModelGeometry3D;\n"]}