@motionscript/math 0.0.0-stage → 0.1.0-alpha.10

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 (335) hide show
  1. package/CHANGELOG.md +144 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +49 -0
  4. package/README.md +389 -2
  5. package/dist/annotate/angle-mark.d.ts +96 -0
  6. package/dist/annotate/angle-mark.d.ts.map +1 -0
  7. package/dist/annotate/angle-mark.js +97 -0
  8. package/dist/annotate/angle-mark.js.map +1 -0
  9. package/dist/annotate/curly-brace.d.ts +115 -0
  10. package/dist/annotate/curly-brace.d.ts.map +1 -0
  11. package/dist/annotate/curly-brace.js +99 -0
  12. package/dist/annotate/curly-brace.js.map +1 -0
  13. package/dist/annotate/emphasis-mark.d.ts +80 -0
  14. package/dist/annotate/emphasis-mark.d.ts.map +1 -0
  15. package/dist/annotate/emphasis-mark.js +80 -0
  16. package/dist/annotate/emphasis-mark.js.map +1 -0
  17. package/dist/browser/THIRD_PARTY_LICENSES.txt +420 -0
  18. package/dist/browser/chunks/chunk-IRZCG6PM.js +2 -0
  19. package/dist/browser/chunks/chunk-IRZCG6PM.js.map +7 -0
  20. package/dist/browser/chunks/chunk-WMVW6ZIV.js +2 -0
  21. package/dist/browser/chunks/chunk-WMVW6ZIV.js.map +7 -0
  22. package/dist/browser/chunks/mathjax-WV55AC2P.js +61 -0
  23. package/dist/browser/chunks/mathjax-WV55AC2P.js.map +7 -0
  24. package/dist/browser/index.js +2 -0
  25. package/dist/browser/index.js.map +7 -0
  26. package/dist/browser/kit.js +2 -0
  27. package/dist/browser/kit.js.map +7 -0
  28. package/dist/browser/manifest.json +30 -0
  29. package/dist/browser/tex.js +2 -0
  30. package/dist/browser/tex.js.map +7 -0
  31. package/dist/engine.d.ts +71 -0
  32. package/dist/engine.d.ts.map +1 -0
  33. package/dist/engine.js +45 -0
  34. package/dist/engine.js.map +1 -0
  35. package/dist/index.d.ts +30 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +30 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/kit/brace.d.ts +8 -0
  40. package/dist/kit/brace.d.ts.map +1 -0
  41. package/dist/kit/brace.js +36 -0
  42. package/dist/kit/brace.js.map +1 -0
  43. package/dist/kit/cache.d.ts +30 -0
  44. package/dist/kit/cache.d.ts.map +1 -0
  45. package/dist/kit/cache.js +53 -0
  46. package/dist/kit/cache.js.map +1 -0
  47. package/dist/kit/component.d.ts +51 -0
  48. package/dist/kit/component.d.ts.map +1 -0
  49. package/dist/kit/component.js +30 -0
  50. package/dist/kit/component.js.map +1 -0
  51. package/dist/kit/contour.d.ts +8 -0
  52. package/dist/kit/contour.d.ts.map +1 -0
  53. package/dist/kit/contour.js +93 -0
  54. package/dist/kit/contour.js.map +1 -0
  55. package/dist/kit/coords.d.ts +69 -0
  56. package/dist/kit/coords.d.ts.map +1 -0
  57. package/dist/kit/coords.js +224 -0
  58. package/dist/kit/coords.js.map +1 -0
  59. package/dist/kit/curve.d.ts +28 -0
  60. package/dist/kit/curve.d.ts.map +1 -0
  61. package/dist/kit/curve.js +29 -0
  62. package/dist/kit/curve.js.map +1 -0
  63. package/dist/kit/equation.d.ts +61 -0
  64. package/dist/kit/equation.d.ts.map +1 -0
  65. package/dist/kit/equation.js +168 -0
  66. package/dist/kit/equation.js.map +1 -0
  67. package/dist/kit/equation3d.d.ts +50 -0
  68. package/dist/kit/equation3d.d.ts.map +1 -0
  69. package/dist/kit/equation3d.js +103 -0
  70. package/dist/kit/equation3d.js.map +1 -0
  71. package/dist/kit/expression.d.ts +35 -0
  72. package/dist/kit/expression.d.ts.map +1 -0
  73. package/dist/kit/expression.js +124 -0
  74. package/dist/kit/expression.js.map +1 -0
  75. package/dist/kit/field-mark.d.ts +79 -0
  76. package/dist/kit/field-mark.d.ts.map +1 -0
  77. package/dist/kit/field-mark.js +109 -0
  78. package/dist/kit/field-mark.js.map +1 -0
  79. package/dist/kit/field.d.ts +14 -0
  80. package/dist/kit/field.d.ts.map +1 -0
  81. package/dist/kit/field.js +46 -0
  82. package/dist/kit/field.js.map +1 -0
  83. package/dist/kit/follow.d.ts +109 -0
  84. package/dist/kit/follow.d.ts.map +1 -0
  85. package/dist/kit/follow.js +163 -0
  86. package/dist/kit/follow.js.map +1 -0
  87. package/dist/kit/furniture.d.ts +32 -0
  88. package/dist/kit/furniture.d.ts.map +1 -0
  89. package/dist/kit/furniture.js +92 -0
  90. package/dist/kit/furniture.js.map +1 -0
  91. package/dist/kit/geometry.d.ts +13 -0
  92. package/dist/kit/geometry.d.ts.map +1 -0
  93. package/dist/kit/geometry.js +54 -0
  94. package/dist/kit/geometry.js.map +1 -0
  95. package/dist/kit/graph.d.ts +46 -0
  96. package/dist/kit/graph.d.ts.map +1 -0
  97. package/dist/kit/graph.js +90 -0
  98. package/dist/kit/graph.js.map +1 -0
  99. package/dist/kit/mark.d.ts +72 -0
  100. package/dist/kit/mark.d.ts.map +1 -0
  101. package/dist/kit/mark.js +87 -0
  102. package/dist/kit/mark.js.map +1 -0
  103. package/dist/kit/part-fills.d.ts +23 -0
  104. package/dist/kit/part-fills.d.ts.map +1 -0
  105. package/dist/kit/part-fills.js +46 -0
  106. package/dist/kit/part-fills.js.map +1 -0
  107. package/dist/kit/place.d.ts +20 -0
  108. package/dist/kit/place.d.ts.map +1 -0
  109. package/dist/kit/place.js +66 -0
  110. package/dist/kit/place.js.map +1 -0
  111. package/dist/kit/sampler.d.ts +17 -0
  112. package/dist/kit/sampler.d.ts.map +1 -0
  113. package/dist/kit/sampler.js +250 -0
  114. package/dist/kit/sampler.js.map +1 -0
  115. package/dist/kit/scale.d.ts +12 -0
  116. package/dist/kit/scale.d.ts.map +1 -0
  117. package/dist/kit/scale.js +37 -0
  118. package/dist/kit/scale.js.map +1 -0
  119. package/dist/kit/source.d.ts +22 -0
  120. package/dist/kit/source.d.ts.map +1 -0
  121. package/dist/kit/source.js +45 -0
  122. package/dist/kit/source.js.map +1 -0
  123. package/dist/kit/system.d.ts +31 -0
  124. package/dist/kit/system.d.ts.map +1 -0
  125. package/dist/kit/system.js +71 -0
  126. package/dist/kit/system.js.map +1 -0
  127. package/dist/kit/ticks.d.ts +19 -0
  128. package/dist/kit/ticks.d.ts.map +1 -0
  129. package/dist/kit/ticks.js +78 -0
  130. package/dist/kit/ticks.js.map +1 -0
  131. package/dist/kit/withdrawn.d.ts +9 -0
  132. package/dist/kit/withdrawn.d.ts.map +1 -0
  133. package/dist/kit/withdrawn.js +9 -0
  134. package/dist/kit/withdrawn.js.map +1 -0
  135. package/dist/marks/curve-area.d.ts +51 -0
  136. package/dist/marks/curve-area.d.ts.map +1 -0
  137. package/dist/marks/curve-area.js +59 -0
  138. package/dist/marks/curve-area.js.map +1 -0
  139. package/dist/marks/drop-lines.d.ts +57 -0
  140. package/dist/marks/drop-lines.d.ts.map +1 -0
  141. package/dist/marks/drop-lines.js +43 -0
  142. package/dist/marks/drop-lines.js.map +1 -0
  143. package/dist/marks/plot-point.d.ts +71 -0
  144. package/dist/marks/plot-point.d.ts.map +1 -0
  145. package/dist/marks/plot-point.js +71 -0
  146. package/dist/marks/plot-point.js.map +1 -0
  147. package/dist/marks/riemann-sum.d.ts +58 -0
  148. package/dist/marks/riemann-sum.d.ts.map +1 -0
  149. package/dist/marks/riemann-sum.js +63 -0
  150. package/dist/marks/riemann-sum.js.map +1 -0
  151. package/dist/marks/tangent-line.d.ts +71 -0
  152. package/dist/marks/tangent-line.d.ts.map +1 -0
  153. package/dist/marks/tangent-line.js +89 -0
  154. package/dist/marks/tangent-line.js.map +1 -0
  155. package/dist/marks/vector-arrow.d.ts +60 -0
  156. package/dist/marks/vector-arrow.d.ts.map +1 -0
  157. package/dist/marks/vector-arrow.js +67 -0
  158. package/dist/marks/vector-arrow.js.map +1 -0
  159. package/dist/nodes.d.ts +43 -0
  160. package/dist/nodes.d.ts.map +1 -0
  161. package/dist/nodes.js +57 -0
  162. package/dist/nodes.js.map +1 -0
  163. package/dist/plots/function-plot.d.ts +159 -0
  164. package/dist/plots/function-plot.d.ts.map +1 -0
  165. package/dist/plots/function-plot.js +184 -0
  166. package/dist/plots/function-plot.js.map +1 -0
  167. package/dist/plots/points-plot.d.ts +64 -0
  168. package/dist/plots/points-plot.d.ts.map +1 -0
  169. package/dist/plots/points-plot.js +72 -0
  170. package/dist/plots/points-plot.js.map +1 -0
  171. package/dist/plots/stream-lines.d.ts +76 -0
  172. package/dist/plots/stream-lines.d.ts.map +1 -0
  173. package/dist/plots/stream-lines.js +122 -0
  174. package/dist/plots/stream-lines.js.map +1 -0
  175. package/dist/plots/traced-path.d.ts +70 -0
  176. package/dist/plots/traced-path.d.ts.map +1 -0
  177. package/dist/plots/traced-path.js +41 -0
  178. package/dist/plots/traced-path.js.map +1 -0
  179. package/dist/plots/vector-field.d.ts +60 -0
  180. package/dist/plots/vector-field.d.ts.map +1 -0
  181. package/dist/plots/vector-field.js +77 -0
  182. package/dist/plots/vector-field.js.map +1 -0
  183. package/dist/structures/graph-layout.d.ts +11 -0
  184. package/dist/structures/graph-layout.d.ts.map +1 -0
  185. package/dist/structures/graph-layout.js +135 -0
  186. package/dist/structures/graph-layout.js.map +1 -0
  187. package/dist/structures/network-graph.d.ts +174 -0
  188. package/dist/structures/network-graph.d.ts.map +1 -0
  189. package/dist/structures/network-graph.js +240 -0
  190. package/dist/structures/network-graph.js.map +1 -0
  191. package/dist/structures/sample-space.d.ts +114 -0
  192. package/dist/structures/sample-space.d.ts.map +1 -0
  193. package/dist/structures/sample-space.js +161 -0
  194. package/dist/structures/sample-space.js.map +1 -0
  195. package/dist/systems/axes2d.d.ts +197 -0
  196. package/dist/systems/axes2d.d.ts.map +1 -0
  197. package/dist/systems/axes2d.js +157 -0
  198. package/dist/systems/axes2d.js.map +1 -0
  199. package/dist/systems/number-line.d.ts +101 -0
  200. package/dist/systems/number-line.d.ts.map +1 -0
  201. package/dist/systems/number-line.js +91 -0
  202. package/dist/systems/number-line.js.map +1 -0
  203. package/dist/systems/number-plane.d.ts +168 -0
  204. package/dist/systems/number-plane.d.ts.map +1 -0
  205. package/dist/systems/number-plane.js +186 -0
  206. package/dist/systems/number-plane.js.map +1 -0
  207. package/dist/systems/polar-plane.d.ts +98 -0
  208. package/dist/systems/polar-plane.d.ts.map +1 -0
  209. package/dist/systems/polar-plane.js +139 -0
  210. package/dist/systems/polar-plane.js.map +1 -0
  211. package/dist/tex/geometry.d.ts +85 -0
  212. package/dist/tex/geometry.d.ts.map +1 -0
  213. package/dist/tex/geometry.js +632 -0
  214. package/dist/tex/geometry.js.map +1 -0
  215. package/dist/tex/index.d.ts +11 -0
  216. package/dist/tex/index.d.ts.map +1 -0
  217. package/dist/tex/index.js +10 -0
  218. package/dist/tex/index.js.map +1 -0
  219. package/dist/tex/mathjax.d.ts +33 -0
  220. package/dist/tex/mathjax.d.ts.map +1 -0
  221. package/dist/tex/mathjax.js +74 -0
  222. package/dist/tex/mathjax.js.map +1 -0
  223. package/dist/tex/matrix.d.ts +101 -0
  224. package/dist/tex/matrix.d.ts.map +1 -0
  225. package/dist/tex/matrix.js +56 -0
  226. package/dist/tex/matrix.js.map +1 -0
  227. package/dist/tex/node.d.ts +98 -0
  228. package/dist/tex/node.d.ts.map +1 -0
  229. package/dist/tex/node.js +25 -0
  230. package/dist/tex/node.js.map +1 -0
  231. package/dist/tex/tween.d.ts +50 -0
  232. package/dist/tex/tween.d.ts.map +1 -0
  233. package/dist/tex/tween.js +253 -0
  234. package/dist/tex/tween.js.map +1 -0
  235. package/dist/tex/typeset.d.ts +133 -0
  236. package/dist/tex/typeset.d.ts.map +1 -0
  237. package/dist/tex/typeset.js +403 -0
  238. package/dist/tex/typeset.js.map +1 -0
  239. package/dist/three/axes3d.d.ts +247 -0
  240. package/dist/three/axes3d.d.ts.map +1 -0
  241. package/dist/three/axes3d.js +187 -0
  242. package/dist/three/axes3d.js.map +1 -0
  243. package/dist/three/curve-plot3d.d.ts +126 -0
  244. package/dist/three/curve-plot3d.d.ts.map +1 -0
  245. package/dist/three/curve-plot3d.js +109 -0
  246. package/dist/three/curve-plot3d.js.map +1 -0
  247. package/dist/three/entries.d.ts +17 -0
  248. package/dist/three/entries.d.ts.map +1 -0
  249. package/dist/three/entries.js +15 -0
  250. package/dist/three/entries.js.map +1 -0
  251. package/dist/three/label3d.d.ts +11 -0
  252. package/dist/three/label3d.d.ts.map +1 -0
  253. package/dist/three/label3d.js +42 -0
  254. package/dist/three/label3d.js.map +1 -0
  255. package/dist/three/plot-point3d.d.ts +99 -0
  256. package/dist/three/plot-point3d.d.ts.map +1 -0
  257. package/dist/three/plot-point3d.js +34 -0
  258. package/dist/three/plot-point3d.js.map +1 -0
  259. package/dist/three/space.d.ts +43 -0
  260. package/dist/three/space.d.ts.map +1 -0
  261. package/dist/three/space.js +58 -0
  262. package/dist/three/space.js.map +1 -0
  263. package/dist/three/surface-plot3d.d.ts +207 -0
  264. package/dist/three/surface-plot3d.d.ts.map +1 -0
  265. package/dist/three/surface-plot3d.js +261 -0
  266. package/dist/three/surface-plot3d.js.map +1 -0
  267. package/dist/three/vector-arrow3d.d.ts +96 -0
  268. package/dist/three/vector-arrow3d.d.ts.map +1 -0
  269. package/dist/three/vector-arrow3d.js +53 -0
  270. package/dist/three/vector-arrow3d.js.map +1 -0
  271. package/package.json +80 -3
  272. package/registry.json +251 -0
  273. package/src/annotate/angle-mark.ts +137 -0
  274. package/src/annotate/curly-brace.ts +148 -0
  275. package/src/annotate/emphasis-mark.ts +118 -0
  276. package/src/engine.ts +86 -0
  277. package/src/index.ts +29 -0
  278. package/src/kit/brace.ts +37 -0
  279. package/src/kit/cache.ts +61 -0
  280. package/src/kit/component.ts +57 -0
  281. package/src/kit/contour.ts +94 -0
  282. package/src/kit/coords.ts +278 -0
  283. package/src/kit/curve.ts +47 -0
  284. package/src/kit/equation.ts +181 -0
  285. package/src/kit/equation3d.ts +137 -0
  286. package/src/kit/expression.ts +159 -0
  287. package/src/kit/field-mark.ts +171 -0
  288. package/src/kit/field.ts +50 -0
  289. package/src/kit/follow.ts +229 -0
  290. package/src/kit/furniture.ts +113 -0
  291. package/src/kit/geometry.ts +49 -0
  292. package/src/kit/graph.ts +116 -0
  293. package/src/kit/mark.ts +152 -0
  294. package/src/kit/part-fills.ts +61 -0
  295. package/src/kit/place.ts +77 -0
  296. package/src/kit/sampler.ts +281 -0
  297. package/src/kit/scale.ts +39 -0
  298. package/src/kit/source.ts +57 -0
  299. package/src/kit/system.ts +105 -0
  300. package/src/kit/ticks.ts +85 -0
  301. package/src/kit/withdrawn.ts +8 -0
  302. package/src/marks/curve-area.ts +89 -0
  303. package/src/marks/drop-lines.ts +71 -0
  304. package/src/marks/plot-point.ts +102 -0
  305. package/src/marks/riemann-sum.ts +99 -0
  306. package/src/marks/tangent-line.ts +119 -0
  307. package/src/marks/vector-arrow.ts +98 -0
  308. package/src/nodes.ts +99 -0
  309. package/src/plots/function-plot.ts +220 -0
  310. package/src/plots/points-plot.ts +103 -0
  311. package/src/plots/stream-lines.ts +160 -0
  312. package/src/plots/traced-path.ts +70 -0
  313. package/src/plots/vector-field.ts +107 -0
  314. package/src/structures/graph-layout.ts +145 -0
  315. package/src/structures/network-graph.ts +291 -0
  316. package/src/structures/sample-space.ts +210 -0
  317. package/src/systems/axes2d.ts +226 -0
  318. package/src/systems/number-line.ts +130 -0
  319. package/src/systems/number-plane.ts +232 -0
  320. package/src/systems/polar-plane.ts +177 -0
  321. package/src/tex/geometry.ts +703 -0
  322. package/src/tex/index.ts +15 -0
  323. package/src/tex/mathjax.ts +82 -0
  324. package/src/tex/matrix.ts +97 -0
  325. package/src/tex/node.ts +74 -0
  326. package/src/tex/tween.ts +308 -0
  327. package/src/tex/typeset.ts +461 -0
  328. package/src/three/axes3d.ts +267 -0
  329. package/src/three/curve-plot3d.ts +146 -0
  330. package/src/three/entries.ts +42 -0
  331. package/src/three/label3d.ts +52 -0
  332. package/src/three/plot-point3d.ts +63 -0
  333. package/src/three/space.ts +92 -0
  334. package/src/three/surface-plot3d.ts +318 -0
  335. package/src/three/vector-arrow3d.ts +88 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"curve-plot3d.d.ts","sourceRoot":"","sources":["../../src/three/curve-plot3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,MAAM,EAIX,KAAK,OAAO,IAAI,QAAQ,EACxB,KAAK,KAAK,IAAI,MAAM,EACpB,KAAK,OAAO,IAAI,QAAQ,EACxB,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,UAAU,IAAI,WAAW,EAC9B,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,eAAe,IAAI,gBAAgB,EACxC,KAAK,SAAS,IAAI,UAAU,EAC5B,KAAK,SAAS,IAAI,UAAU,EAC/B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,EAAgD,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAI9F,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACjD,UAAU,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IACjC,MAAM,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AAwBD,iFAAiF;AACjF,eAAO,MAAM,WAAW;;IAhBpB,2DAA2D;;;IAG3D,kDAAkD;;IAElD,8CAA8C;;IAE9C,2EAA2E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAP3E,2DAA2D;;;IAG3D,kDAAkD;;IAElD,8CAA8C;;IAE9C,2EAA2E;;;;;;;;;;;;;;;;;;;;;;;;;;IAP3E,2DAA2D;;;IAG3D,kDAAkD;;IAElD,8CAA8C;;IAE9C,2EAA2E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAyB7E,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC"}
@@ -0,0 +1,109 @@
1
+ import { component3d, Geo, Graphics3D, Material, Types, } from "@motionscript/sdk";
2
+ import { parseSpaceCurve, spaceCurveParams } from "../kit/equation3d.js";
3
+ import { PLOT_COLOR } from "../kit/furniture.js";
4
+ import { clamp } from "../kit/geometry.js";
5
+ import { lerpParams, lerpSource, readSource, scopeFor } from "../kit/source.js";
6
+ import { domainEntry, meshEntries } from "./entries.js";
7
+ import { graphEntry, graphOf } from "./space.js";
8
+ const state = {
9
+ ...meshEntries,
10
+ expression: Types.custom("", {
11
+ resolve: readSource,
12
+ lerp: lerpSource,
13
+ kind: "spaceCurveEquation",
14
+ }),
15
+ /** The span of `t` that is drawn; 0 to 1 when left out. */
16
+ domain: domainEntry(0, 1),
17
+ params: Types.custom({}, { lerp: lerpParams }),
18
+ /** How many points the curve is drawn through. */
19
+ samples: Types.number(160, { min: 2, max: 2000, step: 1, animatable: false }),
20
+ /** The radius of the line, in scene units. */
21
+ thickness: Types.number(0.04, { min: 0.001, step: 0.005 }),
22
+ /** The part of the curve that is drawn, as shares of its length in `t`. */
23
+ start: Types.number(0, { min: 0, max: 1, step: 0.01 }),
24
+ end: Types.number(1, { min: 0, max: 1, step: 0.01 }),
25
+ graph: graphEntry(),
26
+ };
27
+ /** A curve through a 3D graph, three parts in `t`: `(cos(t), sin(t), t / 4)`. */
28
+ export const CurvePlot3d = component3d({
29
+ key: "curvePlot3d",
30
+ state,
31
+ defaults: { fill: PLOT_COLOR },
32
+ commands: {
33
+ /** Change the equation, the curve bending from the one into the other. */
34
+ morphTo: { args: ["expression"] },
35
+ /** Animate the equation's named values. */
36
+ paramsTo: { args: ["params"] },
37
+ /** Animate the span of `t` that is drawn. */
38
+ domainTo: { args: ["domain"] },
39
+ /** Draw the curve on, or wipe it off: animates `start` and `end`. */
40
+ progressTo: { args: ["start", "end"] },
41
+ },
42
+ // Declaring, its paint on a stand-in: only a material loads, and the curve's points are not sampled.
43
+ render: (ctx, s) => ctx.draw(ctx.declaring ? new Graphics3D().plane(Material.shorthand(s)) : Material.mesh(s, curveGeometry(s))),
44
+ });
45
+ function curveGeometry(s) {
46
+ const space = graphOf(s);
47
+ if (!space)
48
+ return undefined;
49
+ const points = pointsOf(s, space);
50
+ if (points.length < 2)
51
+ return undefined;
52
+ return Geo.tube({ points, radius: s.thickness, segments: [points.length - 1, 8] });
53
+ }
54
+ /** The last run drawn for each curve, kept while what it is drawn from is unchanged. */
55
+ const runs = new WeakMap();
56
+ function pointsOf(s, space) {
57
+ const { source, blend } = s.expression;
58
+ const start = clamp(s.start, 0, 1);
59
+ const end = clamp(s.end, 0, 1);
60
+ const samples = Math.max(2, Math.round(s.samples));
61
+ const key = [source, blend?.from, blend?.t, space.revision, s.domain, JSON.stringify(s.params), start, end, samples].join("|");
62
+ const kept = runs.get(s);
63
+ if (kept?.key === key)
64
+ return kept.run;
65
+ const run = [];
66
+ runs.set(s, { key, run });
67
+ const to = curveOf(s, source);
68
+ if (!to || !(end > start))
69
+ return run;
70
+ const from = blend ? curveOf(s, blend.from) : null;
71
+ const steps = Math.max(1, Math.round(samples * (end - start)));
72
+ const a = { x: 0, y: 0, z: 0 };
73
+ const b = { x: 0, y: 0, z: 0 };
74
+ for (let i = 0; i <= steps; i++) {
75
+ const u = start + ((end - start) * i) / steps;
76
+ if (!to(u, b))
77
+ continue;
78
+ if (from && blend) {
79
+ if (!from(u, a))
80
+ continue;
81
+ b.x = a.x + (b.x - a.x) * blend.t;
82
+ b.y = a.y + (b.y - a.y) * blend.t;
83
+ b.z = a.z + (b.z - a.z) * blend.t;
84
+ }
85
+ run.push(space.offset(b.x, b.y, b.z));
86
+ }
87
+ return run;
88
+ }
89
+ /** `source` as a graph point for a share `u` of its span, or `false` where it has none. */
90
+ function curveOf(s, source) {
91
+ const equation = equationOf(source);
92
+ if (!equation)
93
+ return null;
94
+ const params = scopeFor(spaceCurveParams(source), s.params);
95
+ const [t0, t1] = s.domain ?? [0, 1];
96
+ const { x, y, z } = equation;
97
+ return (u, out) => {
98
+ const t = t0 + (t1 - t0) * u;
99
+ out.x = x(t, 0, params);
100
+ out.y = y(t, 0, params);
101
+ out.z = z(t, 0, params);
102
+ return Number.isFinite(out.x) && Number.isFinite(out.y) && Number.isFinite(out.z);
103
+ };
104
+ }
105
+ function equationOf(source) {
106
+ const equation = parseSpaceCurve(source, spaceCurveParams(source));
107
+ return equation instanceof Error ? null : equation;
108
+ }
109
+ //# sourceMappingURL=curve-plot3d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"curve-plot3d.js","sourceRoot":"","sources":["../../src/three/curve-plot3d.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,GAAG,EACH,UAAU,EACV,QAAQ,EACR,KAAK,GAiBR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAA2B,MAAM,mBAAmB,CAAC;AAE/F,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAmB,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAmB,MAAM,SAAS,CAAC;AAY/D,MAAM,KAAK,GAAG;IACV,GAAG,WAAW;IACd,UAAU,EAAE,KAAK,CAAC,MAAM,CAAkC,EAAE,EAAE;QAC1D,OAAO,EAAE,UAAU;QACnB,IAAI,EAAE,UAAU;QAChB,I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B,MAAM,MAAM,GAAG,QAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IAC5D,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACpC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC;IAC7B,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE;QACd,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QAC7B,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;QACxB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;QACxB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;QACxB,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACtF,CAAC,CAAC;AACN,CAAC;AAED,SAAS,UAAU,CAAC,MAAc;IAC9B,MAAM,QAAQ,GAAG,eAAe,CAAC,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;IACnE,OAAO,QAAQ,YAAY,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;AACvD,CAAC","sourcesContent":["import {\n component3d,\n Geo,\n Graphics3D,\n Material,\n Types,\n type Geometry3D,\n type Mesh3DProps,\n type NodeOf,\n type Values,\n type Vector3,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Blend3D as _Blend3D,\n type Color as _Color,\n type Faces3D as _Faces3D,\n type Fill3D as _Fill3D,\n type Material3D as _Material3D,\n type Node3D as _Node3D,\n type Node3DProps as _Node3DProps,\n type NormalizedColor as _NormalizedColor,\n type Shading3D as _Shading3D,\n type Texture3D as _Texture3D,\n} from \"@motionscript/sdk\";\nimport type { Interval } from \"../kit/coords\";\nimport { parseSpaceCurve, spaceCurveParams, type SpaceCurveEquation } from \"../kit/equation3d\";\nimport type { ExpressionScope } from \"../kit/expression\";\nimport { PLOT_COLOR } from \"../kit/furniture\";\nimport { clamp } from \"../kit/geometry\";\nimport { lerpParams, lerpSource, readSource, scopeFor, type PlotSource } from \"../kit/source\";\nimport { domainEntry, meshEntries } from \"./entries\";\nimport { graphEntry, graphOf, type GraphSpace } from \"./space\";\n\nexport interface CurvePlot3dProps extends Mesh3DProps {\n expression?: string | PlotSource;\n domain?: Interval | null;\n params?: ExpressionScope;\n samples?: number;\n thickness?: number;\n start?: number;\n end?: number;\n}\n\nconst state = {\n ...meshEntries,\n expression: Types.custom<string | PlotSource, PlotSource>(\"\", {\n resolve: readSource,\n lerp: lerpSource,\n kind: \"spaceCurveEquation\",\n }),\n /** The span of `t` that is drawn; 0 to 1 when left out. */\n domain: domainEntry(0, 1),\n params: Types.custom<ExpressionScope>({}, { lerp: lerpParams }),\n /** How many points the curve is drawn through. */\n samples: Types.number(160, { min: 2, max: 2000, step: 1, animatable: false }),\n /** The radius of the line, in scene units. */\n thickness: Types.number(0.04, { min: 0.001, step: 0.005 }),\n /** The part of the curve that is drawn, as shares of its length in `t`. */\n start: Types.number(0, { min: 0, max: 1, step: 0.01 }),\n end: Types.number(1, { min: 0, max: 1, step: 0.01 }),\n graph: graphEntry(),\n};\n\ntype CurveValues = Values<typeof state>;\n\n/** A curve through a 3D graph, three parts in `t`: `(cos(t), sin(t), t / 4)`. */\nexport const CurvePlot3d = component3d({\n key: \"curvePlot3d\",\n state,\n defaults: { fill: PLOT_COLOR },\n commands: {\n /** Change the equation, the curve bending from the one into the other. */\n morphTo: { args: [\"expression\"] },\n /** Animate the equation's named values. */\n paramsTo: { args: [\"params\"] },\n /** Animate the span of `t` that is drawn. */\n domainTo: { args: [\"domain\"] },\n /** Draw the curve on, or wipe it off: animates `start` and `end`. */\n progressTo: { args: [\"start\", \"end\"] },\n },\n // Declaring, its paint on a stand-in: only a material loads, and the curve's points are not sampled.\n render: (ctx, s) => ctx.draw(ctx.declaring ? new Graphics3D().plane(Material.shorthand(s)) : Material.mesh(s, curveGeometry(s))),\n});\n\nexport type CurvePlot3d = NodeOf<typeof CurvePlot3d>;\n\nfunction curveGeometry(s: CurveValues): Geometry3D | undefined {\n const space = graphOf(s);\n if (!space) return undefined;\n const points = pointsOf(s, space);\n if (points.length < 2) return undefined;\n return Geo.tube({ points, radius: s.thickness, segments: [points.length - 1, 8] });\n}\n\n/** The last run drawn for each curve, kept while what it is drawn from is unchanged. */\nconst runs = new WeakMap<object, { readonly key: string; readonly run: Vector3[] }>();\n\nfunction pointsOf(s: CurveValues, space: GraphSpace): Vector3[] {\n const { source, blend } = s.expression;\n const start = clamp(s.start, 0, 1);\n const end = clamp(s.end, 0, 1);\n const samples = Math.max(2, Math.round(s.samples));\n const key = [source, blend?.from, blend?.t, space.revision, s.domain, JSON.stringify(s.params), start, end, samples].join(\"|\");\n const kept = runs.get(s);\n if (kept?.key === key) return kept.run;\n const run: Vector3[] = [];\n runs.set(s, { key, run });\n const to = curveOf(s, source);\n if (!to || !(end > start)) return run;\n const from = blend ? curveOf(s, blend.from) : null;\n const steps = Math.max(1, Math.round(samples * (end - start)));\n const a: Vector3 = { x: 0, y: 0, z: 0 };\n const b: Vector3 = { x: 0, y: 0, z: 0 };\n for (let i = 0; i <= steps; i++) {\n const u = start + ((end - start) * i) / steps;\n if (!to(u, b)) continue;\n if (from && blend) {\n if (!from(u, a)) continue;\n b.x = a.x + (b.x - a.x) * blend.t;\n b.y = a.y + (b.y - a.y) * blend.t;\n b.z = a.z + (b.z - a.z) * blend.t;\n }\n run.push(space.offset(b.x, b.y, b.z));\n }\n return run;\n}\n\n/** `source` as a graph point for a share `u` of its span, or `false` where it has none. */\nfunction curveOf(s: CurveValues, source: string): ((u: number, out: Vector3) => boolean) | null {\n const equation = equationOf(source);\n if (!equation) return null;\n const params = scopeFor(spaceCurveParams(source), s.params);\n const [t0, t1] = s.domain ?? [0, 1];\n const { x, y, z } = equation;\n return (u, out) => {\n const t = t0 + (t1 - t0) * u;\n out.x = x(t, 0, params);\n out.y = y(t, 0, params);\n out.z = z(t, 0, params);\n return Number.isFinite(out.x) && Number.isFinite(out.y) && Number.isFinite(out.z);\n };\n}\n\nfunction equationOf(source: string): SpaceCurveEquation | null {\n const equation = parseSpaceCurve(source, spaceCurveParams(source));\n return equation instanceof Error ? null : equation;\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import { Material, type Geometry3D, type Type } from "@motionscript/sdk";
2
+ import type { Interval } from "../kit/coords.js";
3
+ type MeshState = {
4
+ readonly geometry: Type<Geometry3D | undefined>;
5
+ } & typeof Material.state;
6
+ type Restated<T> = {
7
+ [K in Extract<keyof T, string>]: T[K];
8
+ };
9
+ /**
10
+ * A mesh's entries, as a 3D mark draws with them: its surface, and the
11
+ * `geometry` a mesh takes, which a mark builds itself and never reads.
12
+ */
13
+ export declare const meshEntries: Restated<MeshState>;
14
+ /** A span of a variable, unset until given: what a host offers as a range from `defaultMin` to `defaultMax`. */
15
+ export declare function domainEntry(defaultMin: number, defaultMax: number): Type<Interval | null>;
16
+ export {};
17
+ //# sourceMappingURL=entries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../src/three/entries.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EAGR,KAAK,UAAU,EACf,KAAK,IAAI,EAUZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C,KAAK,SAAS,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,CAAA;CAAE,GAAG,OAAO,QAAQ,CAAC,KAAK,CAAC;AAG7F,KAAK,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,SAAS,CAG3C,CAAC;AAOF,gHAAgH;AAChH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,CAEzF"}
@@ -0,0 +1,15 @@
1
+ import { Material, Types, } from "@motionscript/sdk";
2
+ import { lerpDomain } from "../kit/source.js";
3
+ /**
4
+ * A mesh's entries, as a 3D mark draws with them: its surface, and the
5
+ * `geometry` a mesh takes, which a mark builds itself and never reads.
6
+ */
7
+ export const meshEntries = {
8
+ geometry: Types.custom(undefined),
9
+ ...Material.state,
10
+ };
11
+ /** A span of a variable, unset until given: what a host offers as a range from `defaultMin` to `defaultMax`. */
12
+ export function domainEntry(defaultMin, defaultMax) {
13
+ return Types.custom(null, { lerp: lerpDomain, kind: "range", defaultMin, defaultMax });
14
+ }
15
+ //# sourceMappingURL=entries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries.js","sourceRoot":"","sources":["../../src/three/entries.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EACR,KAAK,GAaR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAO3C;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAwB;IAC5C,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAyB,SAAS,CAAC;IACzD,GAAG,QAAQ,CAAC,KAAK;CACpB,CAAC;AAOF,gHAAgH;AAChH,MAAM,UAAU,WAAW,CAAC,UAAkB,EAAE,UAAkB;IAC9D,OAAO,KAAK,CAAC,MAAM,CAA+C,IAAI,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;AACzI,CAAC","sourcesContent":["import {\n Material,\n Types,\n type EntryOptions,\n type Geometry3D,\n type Type,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Blend3D as _Blend3D,\n type Color as _Color,\n type Faces3D as _Faces3D,\n type Fill3D as _Fill3D,\n type Material3D as _Material3D,\n type NormalizedColor as _NormalizedColor,\n type Shading3D as _Shading3D,\n type Texture3D as _Texture3D,\n} from \"@motionscript/sdk\";\nimport type { Interval } from \"../kit/coords\";\nimport { lerpDomain } from \"../kit/source\";\n\ntype MeshState = { readonly geometry: Type<Geometry3D | undefined> } & typeof Material.state;\n// Restated key by key, so a mark spreading these names each entry's type through the sdk: spread\n// as inferred, a mark's declaration copied `emission`'s colour types from core's own.\ntype Restated<T> = { [K in Extract<keyof T, string>]: T[K] };\n\n/**\n * A mesh's entries, as a 3D mark draws with them: its surface, and the\n * `geometry` a mesh takes, which a mark builds itself and never reads.\n */\nexport const meshEntries: Restated<MeshState> = {\n geometry: Types.custom<Geometry3D | undefined>(undefined),\n ...Material.state,\n};\n\ninterface RangeHints extends EntryOptions {\n readonly defaultMin: number;\n readonly defaultMax: number;\n}\n\n/** A span of a variable, unset until given: what a host offers as a range from `defaultMin` to `defaultMax`. */\nexport function domainEntry(defaultMin: number, defaultMax: number): Type<Interval | null> {\n return Types.custom<Interval | null, Interval | null, RangeHints>(null, { lerp: lerpDomain, kind: \"range\", defaultMin, defaultMax });\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { type Color, type Graphics3D, type Vector3 } from "@motionscript/sdk";
2
+ /** Text in a 3D graph: a camera-facing card, so a number reads square-on from wherever the scene is seen. */
3
+ export interface LabelStyle3D {
4
+ /** The height of the text's em, in scene units. */
5
+ size: number;
6
+ color: Color;
7
+ fontFamily: string;
8
+ }
9
+ /** Draw `text` centred on `at`, a local point. */
10
+ export declare function drawLabel3D(g3: Graphics3D, text: string, at: Vector3, style: LabelStyle3D): void;
11
+ //# sourceMappingURL=label3d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label3d.d.ts","sourceRoot":"","sources":["../../src/three/label3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,KAAK,EAAE,KAAK,UAAU,EAAyB,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGlI,6GAA6G;AAE7G,MAAM,WAAW,YAAY;IACzB,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACtB;AA+BD,kDAAkD;AAClD,wBAAgB,WAAW,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,CAShG"}
@@ -0,0 +1,42 @@
1
+ import { Fills, Graphics2D, Mat, Tex } from "@motionscript/sdk";
2
+ import { createBoundedCache } from "../kit/cache.js";
3
+ /** The em the text is rasterized at, in buffer pixels, and the card's height around it. */
4
+ const EM = 64;
5
+ const CARD_HEIGHT = 96;
6
+ // A texture's identity is its source object, so one text in one style is one source for as long as it is asked for.
7
+ const cards = createBoundedCache(256);
8
+ function card(text, style) {
9
+ const key = `${style.fontFamily}|${JSON.stringify(style.color)}|${text}`;
10
+ const hit = cards.get(key);
11
+ if (hit)
12
+ return hit;
13
+ const width = Math.min(1024, Math.max(128, Math.ceil((text.length * EM * 0.62 + EM) / 32) * 32));
14
+ const source = new Graphics2D()
15
+ .text({
16
+ text,
17
+ fontSize: EM,
18
+ ...(style.fontFamily === "" ? {} : { fontFamily: style.fontFamily }),
19
+ wrap: false,
20
+ width,
21
+ textAlign: "center",
22
+ })
23
+ .fill(Fills.color(style.color));
24
+ // Its pixels never change, so the renderer rasterizes it once rather than every frame.
25
+ const texture = { ...Tex.surface(source, { width, height: CARD_HEIGHT }), static: true, identity: `label3d:${key}` };
26
+ const made = { texture, width };
27
+ cards.set(key, made);
28
+ return made;
29
+ }
30
+ /** Draw `text` centred on `at`, a local point. */
31
+ export function drawLabel3D(g3, text, at, style) {
32
+ if (text === "" || !(style.size > 0))
33
+ return;
34
+ const { texture, width } = card(text, style);
35
+ const height = (style.size * CARD_HEIGHT) / EM;
36
+ g3.sprite({
37
+ material: Mat.sprite({ map: texture, transparent: true, depthWrite: false }),
38
+ position: at,
39
+ scale: [(height * width) / CARD_HEIGHT, height, 1],
40
+ });
41
+ }
42
+ //# sourceMappingURL=label3d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label3d.js","sourceRoot":"","sources":["../../src/three/label3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAoE,MAAM,mBAAmB,CAAC;AAClI,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAWlD,2FAA2F;AAC3F,MAAM,EAAE,GAAG,EAAE,CAAC;AACd,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB,oHAAoH;AACpH,MAAM,KAAK,GAAG,kBAAkB,CAA+C,GAAG,CAAC,CAAC;AAEpF,SAAS,IAAI,CAAC,IAAY,EAAE,KAAmB;IAC3C,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,UAAU,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;IACzE,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,GAAG;QAAE,OAAO,GAAG,CAAC;IACpB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,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AG,EAAE,CAAC;IAC/C,EAAE,CAAC,MAAM,CAAC;QACN,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;QAC5E,QAAQ,EAAE,EAAE;QACZ,KAAK,EAAE,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC,GAAG,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;KACrD,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { Fills, Graphics2D, Mat, Tex, type Color, type Graphics3D, type SurfaceTexture3D, type Vector3 } from \"@motionscript/sdk\";\nimport { createBoundedCache } from \"../kit/cache\";\n\n/** Text in a 3D graph: a camera-facing card, so a number reads square-on from wherever the scene is seen. */\n\nexport interface LabelStyle3D {\n /** The height of the text's em, in scene units. */\n size: number;\n color: Color;\n fontFamily: string;\n}\n\n/** The em the text is rasterized at, in buffer pixels, and the card's height around it. */\nconst EM = 64;\nconst CARD_HEIGHT = 96;\n\n// A texture's identity is its source object, so one text in one style is one source for as long as it is asked for.\nconst cards = createBoundedCache<{ texture: SurfaceTexture3D; width: number }>(256);\n\nfunction card(text: string, style: LabelStyle3D): { texture: SurfaceTexture3D; width: number } {\n const key = `${style.fontFamily}|${JSON.stringify(style.color)}|${text}`;\n const hit = cards.get(key);\n if (hit) return hit;\n const width = Math.min(1024, Math.max(128, Math.ceil((text.length * EM * 0.62 + EM) / 32) * 32));\n const source = new Graphics2D()\n .text({\n text,\n fontSize: EM,\n ...(style.fontFamily === \"\" ? {} : { fontFamily: style.fontFamily }),\n wrap: false,\n width,\n textAlign: \"center\",\n })\n .fill(Fills.color(style.color));\n // Its pixels never change, so the renderer rasterizes it once rather than every frame.\n const texture: SurfaceTexture3D = { ...Tex.surface(source, { width, height: CARD_HEIGHT }), static: true, identity: `label3d:${key}` };\n const made = { texture, width };\n cards.set(key, made);\n return made;\n}\n\n/** Draw `text` centred on `at`, a local point. */\nexport function drawLabel3D(g3: Graphics3D, text: string, at: Vector3, style: LabelStyle3D): void {\n if (text === \"\" || !(style.size > 0)) return;\n const { texture, width } = card(text, style);\n const height = (style.size * CARD_HEIGHT) / EM;\n g3.sprite({\n material: Mat.sprite({ map: texture, transparent: true, depthWrite: false }),\n position: at,\n scale: [(height * width) / CARD_HEIGHT, height, 1],\n });\n}\n"]}
@@ -0,0 +1,99 @@
1
+ import { type Color, type Mesh3DProps, type NodeOf, type Blend3D as _Blend3D, type Faces3D as _Faces3D, type Fill3D as _Fill3D, type Geometry3D as _Geometry3D, type Material3D as _Material3D, type Node3D as _Node3D, type Node3DProps as _Node3DProps, type NormalizedColor as _NormalizedColor, type Shading3D as _Shading3D, type Texture3D as _Texture3D } from "@motionscript/sdk";
2
+ export interface PlotPoint3dProps extends Mesh3DProps {
3
+ radius?: number;
4
+ label?: string;
5
+ labelSize?: number;
6
+ labelColor?: Color;
7
+ fontFamily?: string;
8
+ }
9
+ /**
10
+ * A dot at graph coordinates in a 3D graph, with an optional label. Put inside
11
+ * a surface it rides it: its `x` and `y` say where, and its height is the surface's.
12
+ */
13
+ export declare const PlotPoint3d: import("@motionscript/sdk").Component<"plotPoint3d", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Transform3DState, {
14
+ /** In scene units, so a point is the same size whatever the axes show. */
15
+ readonly radius: import("@motionscript/sdk").Type<number, number, false>;
16
+ readonly label: import("@motionscript/sdk").Type<string, string, false>;
17
+ /** The height of the label's text, in scene units. */
18
+ readonly labelSize: import("@motionscript/sdk").Type<number, number, false>;
19
+ readonly labelColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
20
+ readonly fontFamily: import("@motionscript/sdk").Type<string, string, false>;
21
+ readonly fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
22
+ readonly blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
23
+ readonly opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
24
+ readonly geometry: import("@motionscript/sdk").Type<_Geometry3D | undefined, _Geometry3D | undefined, false>;
25
+ readonly material: import("@motionscript/sdk").Type<_Material3D | readonly _Material3D[] | undefined, _Material3D | readonly _Material3D[] | undefined, false>;
26
+ readonly roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
27
+ readonly metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
28
+ readonly emission: import("@motionscript/sdk").Type<Color | undefined, _NormalizedColor | undefined, false>;
29
+ readonly emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
30
+ readonly normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
31
+ readonly roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
32
+ readonly metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
33
+ readonly aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
34
+ readonly alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
35
+ readonly envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
36
+ readonly wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
37
+ readonly shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
38
+ readonly faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
39
+ readonly vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
40
+ readonly unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
41
+ }>, {}, null, _Node3D<_Node3DProps>, import("@motionscript/sdk").CallProps3D<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Transform3DState, {
42
+ /** In scene units, so a point is the same size whatever the axes show. */
43
+ readonly radius: import("@motionscript/sdk").Type<number, number, false>;
44
+ readonly label: import("@motionscript/sdk").Type<string, string, false>;
45
+ /** The height of the label's text, in scene units. */
46
+ readonly labelSize: import("@motionscript/sdk").Type<number, number, false>;
47
+ readonly labelColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
48
+ readonly fontFamily: import("@motionscript/sdk").Type<string, string, false>;
49
+ readonly fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
50
+ readonly blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
51
+ readonly opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
52
+ readonly geometry: import("@motionscript/sdk").Type<_Geometry3D | undefined, _Geometry3D | undefined, false>;
53
+ readonly material: import("@motionscript/sdk").Type<_Material3D | readonly _Material3D[] | undefined, _Material3D | readonly _Material3D[] | undefined, false>;
54
+ readonly roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
55
+ readonly metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
56
+ readonly emission: import("@motionscript/sdk").Type<Color | undefined, _NormalizedColor | undefined, false>;
57
+ readonly emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
58
+ readonly normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
59
+ readonly roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
60
+ readonly metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
61
+ readonly aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
62
+ readonly alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
63
+ readonly envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
64
+ readonly wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
65
+ readonly shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
66
+ readonly faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
67
+ readonly vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
68
+ readonly unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
69
+ }>, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Transform3DState, {
70
+ /** In scene units, so a point is the same size whatever the axes show. */
71
+ readonly radius: import("@motionscript/sdk").Type<number, number, false>;
72
+ readonly label: import("@motionscript/sdk").Type<string, string, false>;
73
+ /** The height of the label's text, in scene units. */
74
+ readonly labelSize: import("@motionscript/sdk").Type<number, number, false>;
75
+ readonly labelColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
76
+ readonly fontFamily: import("@motionscript/sdk").Type<string, string, false>;
77
+ readonly fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
78
+ readonly blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
79
+ readonly opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
80
+ readonly geometry: import("@motionscript/sdk").Type<_Geometry3D | undefined, _Geometry3D | undefined, false>;
81
+ readonly material: import("@motionscript/sdk").Type<_Material3D | readonly _Material3D[] | undefined, _Material3D | readonly _Material3D[] | undefined, false>;
82
+ readonly roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
83
+ readonly metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
84
+ readonly emission: import("@motionscript/sdk").Type<Color | undefined, _NormalizedColor | undefined, false>;
85
+ readonly emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
86
+ readonly normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
87
+ readonly roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
88
+ readonly metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
89
+ readonly aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
90
+ readonly alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
91
+ readonly envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
92
+ readonly wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
93
+ readonly shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
94
+ readonly faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
95
+ readonly vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
96
+ readonly unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
97
+ }>, {}, _Node3D<_Node3DProps>>>>;
98
+ export type PlotPoint3d = NodeOf<typeof PlotPoint3d>;
99
+ //# sourceMappingURL=plot-point3d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plot-point3d.d.ts","sourceRoot":"","sources":["../../src/three/plot-point3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,KAAK,KAAK,EACV,KAAK,WAAW,EAChB,KAAK,MAAM,EAEX,KAAK,OAAO,IAAI,QAAQ,EAExB,KAAK,OAAO,IAAI,QAAQ,EACxB,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,UAAU,IAAI,WAAW,EAC9B,KAAK,UAAU,IAAI,WAAW,EAC9B,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,eAAe,IAAI,gBAAgB,EACxC,KAAK,SAAS,IAAI,UAAU,EAC5B,KAAK,SAAS,IAAI,UAAU,EAC/B,MAAM,mBAAmB,CAAC;AAI3B,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW;IAIhB,0EAA0E;;;IAG1E,sDAAsD;;;;;;;;;;;;;;;;;;;;;;;;;IAHtD,0EAA0E;;;IAG1E,sDAAsD;;;;;;;;;;;;;;;;;;;;;;;;;IAHtD,0EAA0E;;;IAG1E,sDAAsD;;;;;;;;;;;;;;;;;;;;;;;;gCAiB5D,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { component3d, Geo, Material, Types, } from "@motionscript/sdk";
2
+ import { meshEntries } from "./entries.js";
3
+ import { drawLabel3D } from "./label3d.js";
4
+ /**
5
+ * A dot at graph coordinates in a 3D graph, with an optional label. Put inside
6
+ * a surface it rides it: its `x` and `y` say where, and its height is the surface's.
7
+ */
8
+ export const PlotPoint3d = component3d({
9
+ key: "plotPoint3d",
10
+ state: {
11
+ ...meshEntries,
12
+ /** In scene units, so a point is the same size whatever the axes show. */
13
+ radius: Types.number(0.1, { min: 0, step: 0.01 }),
14
+ label: Types.text("", { animatable: false }),
15
+ /** The height of the label's text, in scene units. */
16
+ labelSize: Types.number(0.26, { min: 0.01, step: 0.01 }),
17
+ labelColor: Types.color("#e5e7eb"),
18
+ fontFamily: Types.text("", { animatable: false }),
19
+ },
20
+ load: (loader, s) => {
21
+ if (s.fontFamily !== "")
22
+ loader.font(s.fontFamily);
23
+ },
24
+ render: (ctx, s) => {
25
+ const g3 = Material.mesh(s, s.radius > 0 ? Geo.sphere({ radius: s.radius, segments: [24, 16] }) : undefined);
26
+ drawLabel3D(g3, s.label, { x: 0, y: s.radius + s.labelSize * 0.85, z: 0 }, {
27
+ size: s.labelSize,
28
+ color: s.labelColor,
29
+ fontFamily: s.fontFamily,
30
+ });
31
+ ctx.draw(g3);
32
+ },
33
+ });
34
+ //# sourceMappingURL=plot-point3d.js.map
@@ -0,0 +1 @@
1
+ {"version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AM,EAAE,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAC7G,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,SAAS,GAAG,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE;YACvE,IAAI,EAAE,CAAC,CAAC,SAAS;YACjB,KAAK,EAAE,CAAC,CAAC,UAAU;YACnB,UAAU,EAAE,CAAC,CAAC,UAAU;SAC3B,CAAC,CAAC;QACH,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;CACJ,CAAC,CAAC","sourcesContent":["import {\n component3d,\n Geo,\n Material,\n Types,\n type Color,\n type Mesh3DProps,\n type NodeOf,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Blend3D as _Blend3D,\n type Color as _Color,\n type Faces3D as _Faces3D,\n type Fill3D as _Fill3D,\n type Geometry3D as _Geometry3D,\n type Material3D as _Material3D,\n type Node3D as _Node3D,\n type Node3DProps as _Node3DProps,\n type NormalizedColor as _NormalizedColor,\n type Shading3D as _Shading3D,\n type Texture3D as _Texture3D,\n} from \"@motionscript/sdk\";\nimport { meshEntries } from \"./entries\";\nimport { drawLabel3D } from \"./label3d\";\n\nexport interface PlotPoint3dProps extends Mesh3DProps {\n radius?: number;\n label?: string;\n labelSize?: number;\n labelColor?: Color;\n fontFamily?: string;\n}\n\n/**\n * A dot at graph coordinates in a 3D graph, with an optional label. Put inside\n * a surface it rides it: its `x` and `y` say where, and its height is the surface's.\n */\nexport const PlotPoint3d = component3d({\n key: \"plotPoint3d\",\n state: {\n ...meshEntries,\n /** In scene units, so a point is the same size whatever the axes show. */\n radius: Types.number(0.1, { min: 0, step: 0.01 }),\n label: Types.text(\"\", { animatable: false }),\n /** The height of the label's text, in scene units. */\n labelSize: Types.number(0.26, { min: 0.01, step: 0.01 }),\n labelColor: Types.color(\"#e5e7eb\"),\n fontFamily: Types.text(\"\", { animatable: false }),\n },\n load: (loader, s) => {\n if (s.fontFamily !== \"\") loader.font(s.fontFamily);\n },\n render: (ctx, s) => {\n const g3 = Material.mesh(s, s.radius > 0 ? Geo.sphere({ radius: s.radius, segments: [24, 16] }) : undefined);\n drawLabel3D(g3, s.label, { x: 0, y: s.radius + s.labelSize * 0.85, z: 0 }, {\n size: s.labelSize,\n color: s.labelColor,\n fontFamily: s.fontFamily,\n });\n ctx.draw(g3);\n },\n});\n\nexport type PlotPoint3d = NodeOf<typeof PlotPoint3d>;\n"]}
@@ -0,0 +1,43 @@
1
+ import { type ChildSpace3D, type Node3D, type Type, type Vector3, type Context as _Context } from "@motionscript/sdk";
2
+ import type { Interval } from "../kit/coords.js";
3
+ /**
4
+ * A 3D graph's coordinates, as its axes' local space sees them. A graph is
5
+ * right-handed with z up, and the scene has y up, so graph x, y and z run along
6
+ * the scene's z, x and y: looked at head-on, y is to the right and z is up.
7
+ */
8
+ export interface GraphSpace extends ChildSpace3D {
9
+ readonly xRange: Interval;
10
+ readonly yRange: Interval;
11
+ readonly zRange: Interval;
12
+ /** Changes exactly when the mapping does: what a mark's geometry is cached under. */
13
+ readonly revision: string;
14
+ /** A step from one graph point to another, as the local one: what a mark's own geometry is drawn in. */
15
+ offset(x: number, y: number, z: number): Vector3;
16
+ }
17
+ /** The space of a box `lengths` on a side, in scene units, showing the three ranges, centred on its node. */
18
+ export declare function graphSpace(xRange: Interval, yRange: Interval, zRange: Interval, lengths: Vector3): GraphSpace;
19
+ /** A 3D graph, as the marks inside it see it: its coordinates as they stand now. */
20
+ export interface Graph3D {
21
+ space(): GraphSpace;
22
+ }
23
+ /** The graph a mark is inside: `axes3d` provides itself to everything in it. */
24
+ export declare const GRAPH_3D: _Context<Graph3D | null>;
25
+ /**
26
+ * The entry a mark reads the graph it is drawn in through, set from the nearest
27
+ * `axes3d` above it, through any 3D node between; `null` outside one.
28
+ */
29
+ export declare function graphEntry(): Type<Graph3D | null, Graph3D | null, true>;
30
+ /** The graph space a mark with a {@link graphEntry} is drawn in, or `null` outside a graph. */
31
+ export declare function graphOf(mark: {
32
+ readonly graph: Graph3D | null;
33
+ }): GraphSpace | null;
34
+ /** The graph a 3D node is drawn in: what the nearest `axes3d` above it provides, once it is in the tree. */
35
+ export declare function spaceOf(mark: Node3D): GraphSpace | null;
36
+ /** A unit quaternion turning the scene's +y, the way a cylinder or a cone points, onto `direction`. */
37
+ export declare function aim(direction: Vector3): {
38
+ x: number;
39
+ y: number;
40
+ z: number;
41
+ w: number;
42
+ };
43
+ //# sourceMappingURL=space.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space.d.ts","sourceRoot":"","sources":["../../src/three/space.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,YAAY,EACjB,KAAK,MAAM,EACX,KAAK,IAAI,EACT,KAAK,OAAO,EAEZ,KAAK,OAAO,IAAI,QAAQ,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;GAIG;AACH,MAAM,WAAW,UAAW,SAAQ,YAAY;IAC5C,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,qFAAqF;IACrF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,wGAAwG;IACxG,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACpD;AAED,6GAA6G;AAC7G,wBAAgB,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,UAAU,CAe7G;AAOD,oFAAoF;AACpF,MAAM,WAAW,OAAO;IACpB,KAAK,IAAI,UAAU,CAAC;CACvB;AAED,gFAAgF;AAChF,eAAO,MAAM,QAAQ,0BAAsD,CAAC;AAE5E;;;GAGG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,OAAO,GAAG,IAAI,EAAE,IAAI,CAAC,CAKvE;AAED,+FAA+F;AAC/F,wBAAgB,OAAO,CAAC,IAAI,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,GAAG,UAAU,GAAG,IAAI,CAEnF;AAED,4GAA4G;AAC5G,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAEvD;AAED,uGAAuG;AACvG,wBAAgB,GAAG,CAAC,SAAS,EAAE,OAAO,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAWtF"}
@@ -0,0 +1,58 @@
1
+ import { createContext, Types, } from "@motionscript/sdk";
2
+ /** The space of a box `lengths` on a side, in scene units, showing the three ranges, centred on its node. */
3
+ export function graphSpace(xRange, yRange, zRange, lengths) {
4
+ const ux = unit(xRange, lengths.x);
5
+ const uy = unit(yRange, lengths.y);
6
+ const uz = unit(zRange, lengths.z);
7
+ const cx = (xRange[0] + xRange[1]) / 2;
8
+ const cy = (yRange[0] + yRange[1]) / 2;
9
+ const cz = (zRange[0] + zRange[1]) / 2;
10
+ return {
11
+ xRange,
12
+ yRange,
13
+ zRange,
14
+ revision: [xRange, yRange, zRange, lengths.x, lengths.y, lengths.z].join("|"),
15
+ toLocal: (x, y, z) => ({ x: (y - cy) * uy, y: (z - cz) * uz, z: (x - cx) * ux }),
16
+ offset: (x, y, z) => ({ x: y * uy, y: z * uz, z: x * ux }),
17
+ };
18
+ }
19
+ function unit([min, max], length) {
20
+ const span = max - min;
21
+ return span > 0 ? length / span : 0;
22
+ }
23
+ /** The graph a mark is inside: `axes3d` provides itself to everything in it. */
24
+ export const GRAPH_3D = createContext(null, "math:graph3d");
25
+ /**
26
+ * The entry a mark reads the graph it is drawn in through, set from the nearest
27
+ * `axes3d` above it, through any 3D node between; `null` outside one.
28
+ */
29
+ export function graphEntry() {
30
+ return Types.custom(null, {
31
+ private: true,
32
+ inherit: (use) => use(GRAPH_3D),
33
+ });
34
+ }
35
+ /** The graph space a mark with a {@link graphEntry} is drawn in, or `null` outside a graph. */
36
+ export function graphOf(mark) {
37
+ return mark.graph?.space() ?? null;
38
+ }
39
+ /** The graph a 3D node is drawn in: what the nearest `axes3d` above it provides, once it is in the tree. */
40
+ export function spaceOf(mark) {
41
+ return mark.useContext(GRAPH_3D)?.space() ?? null;
42
+ }
43
+ /** A unit quaternion turning the scene's +y, the way a cylinder or a cone points, onto `direction`. */
44
+ export function aim(direction) {
45
+ const length = Math.hypot(direction.x, direction.y, direction.z);
46
+ if (!(length > 0))
47
+ return { x: 0, y: 0, z: 0, w: 1 };
48
+ const dx = direction.x / length;
49
+ const dy = direction.y / length;
50
+ const dz = direction.z / length;
51
+ // Straight down is the one turn with no single axis: any in the ground plane will do.
52
+ if (dy < -1 + 1e-9)
53
+ return { x: 1, y: 0, z: 0, w: 0 };
54
+ const w = 1 + dy;
55
+ const norm = Math.hypot(dz, dx, w);
56
+ return { x: dz / norm, y: 0, z: -dx / norm, w: w / norm };
57
+ }
58
+ //# sourceMappingURL=space.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space.js","sourceRoot":"","sources":["../../src/three/space.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EACb,KAAK,GAOR,MAAM,mBAAmB,CAAC;AAkB3B,6GAA6G;AAC7G,MAAM,UAAU,UAAU,CAAC,MAAgB,EAAE,MAAgB,EAAE,MAAgB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AC,CAAC,GAAG,MAAM,CAAC;IAChC,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,GAAG,MAAM,CAAC;IAChC,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,GAAG,MAAM,CAAC;IAChC,sFAAsF;IACtF,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI;QAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IACtD,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;IACjB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IACnC,OAAO,EAAE,CAAC,EAAE,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC;AAC9D,CAAC","sourcesContent":["import {\n createContext,\n Types,\n type ChildSpace3D,\n type Node3D,\n type Type,\n type Vector3,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Context as _Context,\n} from \"@motionscript/sdk\";\nimport type { Interval } from \"../kit/coords\";\n\n/**\n * A 3D graph's coordinates, as its axes' local space sees them. A graph is\n * right-handed with z up, and the scene has y up, so graph x, y and z run along\n * the scene's z, x and y: looked at head-on, y is to the right and z is up.\n */\nexport interface GraphSpace extends ChildSpace3D {\n readonly xRange: Interval;\n readonly yRange: Interval;\n readonly zRange: Interval;\n /** Changes exactly when the mapping does: what a mark's geometry is cached under. */\n readonly revision: string;\n /** A step from one graph point to another, as the local one: what a mark's own geometry is drawn in. */\n offset(x: number, y: number, z: number): Vector3;\n}\n\n/** The space of a box `lengths` on a side, in scene units, showing the three ranges, centred on its node. */\nexport function graphSpace(xRange: Interval, yRange: Interval, zRange: Interval, lengths: Vector3): GraphSpace {\n const ux = unit(xRange, lengths.x);\n const uy = unit(yRange, lengths.y);\n const uz = unit(zRange, lengths.z);\n const cx = (xRange[0] + xRange[1]) / 2;\n const cy = (yRange[0] + yRange[1]) / 2;\n const cz = (zRange[0] + zRange[1]) / 2;\n return {\n xRange,\n yRange,\n zRange,\n revision: [xRange, yRange, zRange, lengths.x, lengths.y, lengths.z].join(\"|\"),\n toLocal: (x, y, z) => ({ x: (y - cy) * uy, y: (z - cz) * uz, z: (x - cx) * ux }),\n offset: (x, y, z) => ({ x: y * uy, y: z * uz, z: x * ux }),\n };\n}\n\nfunction unit([min, max]: Interval, length: number): number {\n const span = max - min;\n return span > 0 ? length / span : 0;\n}\n\n/** A 3D graph, as the marks inside it see it: its coordinates as they stand now. */\nexport interface Graph3D {\n space(): GraphSpace;\n}\n\n/** The graph a mark is inside: `axes3d` provides itself to everything in it. */\nexport const GRAPH_3D = createContext<Graph3D | null>(null, \"math:graph3d\");\n\n/**\n * The entry a mark reads the graph it is drawn in through, set from the nearest\n * `axes3d` above it, through any 3D node between; `null` outside one.\n */\nexport function graphEntry(): Type<Graph3D | null, Graph3D | null, true> {\n return Types.custom<Graph3D | null, Graph3D | null, { readonly private: true }>(null, {\n private: true,\n inherit: (use) => use(GRAPH_3D),\n });\n}\n\n/** The graph space a mark with a {@link graphEntry} is drawn in, or `null` outside a graph. */\nexport function graphOf(mark: { readonly graph: Graph3D | null }): GraphSpace | null {\n return mark.graph?.space() ?? null;\n}\n\n/** The graph a 3D node is drawn in: what the nearest `axes3d` above it provides, once it is in the tree. */\nexport function spaceOf(mark: Node3D): GraphSpace | null {\n return mark.useContext(GRAPH_3D)?.space() ?? null;\n}\n\n/** A unit quaternion turning the scene's +y, the way a cylinder or a cone points, onto `direction`. */\nexport function aim(direction: Vector3): { x: number; y: number; z: number; w: number } {\n const length = Math.hypot(direction.x, direction.y, direction.z);\n if (!(length > 0)) return { x: 0, y: 0, z: 0, w: 1 };\n const dx = direction.x / length;\n const dy = direction.y / length;\n const dz = direction.z / length;\n // Straight down is the one turn with no single axis: any in the ground plane will do.\n if (dy < -1 + 1e-9) return { x: 1, y: 0, z: 0, w: 0 };\n const w = 1 + dy;\n const norm = Math.hypot(dz, dx, w);\n return { x: dz / norm, y: 0, z: -dx / norm, w: w / norm };\n}\n"]}