@motionscript/math 0.1.0-alpha.5 → 0.1.0-alpha.7

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 (233) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +39 -33
  3. package/dist/annotate/angle-mark.d.ts +77 -27
  4. package/dist/annotate/angle-mark.d.ts.map +1 -1
  5. package/dist/annotate/angle-mark.js +80 -115
  6. package/dist/annotate/angle-mark.js.map +1 -1
  7. package/dist/annotate/curly-brace.d.ts +94 -25
  8. package/dist/annotate/curly-brace.d.ts.map +1 -1
  9. package/dist/annotate/curly-brace.js +85 -100
  10. package/dist/annotate/curly-brace.js.map +1 -1
  11. package/dist/annotate/emphasis-mark.d.ts +69 -9
  12. package/dist/annotate/emphasis-mark.d.ts.map +1 -1
  13. package/dist/annotate/emphasis-mark.js +33 -34
  14. package/dist/annotate/emphasis-mark.js.map +1 -1
  15. package/dist/browser/chunks/chunk-ABYBW64J.js +2 -0
  16. package/dist/browser/chunks/chunk-ABYBW64J.js.map +7 -0
  17. package/dist/browser/chunks/chunk-K77KLQX4.js +2 -0
  18. package/dist/browser/chunks/chunk-K77KLQX4.js.map +7 -0
  19. package/dist/browser/index.js +1 -1
  20. package/dist/browser/index.js.map +3 -3
  21. package/dist/browser/kit.js +1 -1
  22. package/dist/browser/manifest.json +1 -1
  23. package/dist/browser/tex.js +1 -1
  24. package/dist/browser/tex.js.map +2 -2
  25. package/dist/engine.d.ts +26 -19
  26. package/dist/engine.d.ts.map +1 -1
  27. package/dist/engine.js +17 -14
  28. package/dist/engine.js.map +1 -1
  29. package/dist/kit/component.d.ts +51 -0
  30. package/dist/kit/component.d.ts.map +1 -0
  31. package/dist/kit/component.js +30 -0
  32. package/dist/kit/component.js.map +1 -0
  33. package/dist/kit/curve.d.ts +22 -11
  34. package/dist/kit/curve.d.ts.map +1 -1
  35. package/dist/kit/curve.js +25 -18
  36. package/dist/kit/curve.js.map +1 -1
  37. package/dist/kit/field-mark.d.ts +56 -35
  38. package/dist/kit/field-mark.d.ts.map +1 -1
  39. package/dist/kit/field-mark.js +100 -120
  40. package/dist/kit/field-mark.js.map +1 -1
  41. package/dist/kit/follow.d.ts +67 -29
  42. package/dist/kit/follow.d.ts.map +1 -1
  43. package/dist/kit/follow.js +114 -110
  44. package/dist/kit/follow.js.map +1 -1
  45. package/dist/kit/furniture.d.ts +3 -1
  46. package/dist/kit/furniture.d.ts.map +1 -1
  47. package/dist/kit/furniture.js +5 -0
  48. package/dist/kit/furniture.js.map +1 -1
  49. package/dist/kit/graph.d.ts +46 -0
  50. package/dist/kit/graph.d.ts.map +1 -0
  51. package/dist/kit/graph.js +90 -0
  52. package/dist/kit/graph.js.map +1 -0
  53. package/dist/kit/mark.d.ts +64 -39
  54. package/dist/kit/mark.d.ts.map +1 -1
  55. package/dist/kit/mark.js +80 -96
  56. package/dist/kit/mark.js.map +1 -1
  57. package/dist/kit/place.d.ts +10 -8
  58. package/dist/kit/place.d.ts.map +1 -1
  59. package/dist/kit/place.js +28 -30
  60. package/dist/kit/place.js.map +1 -1
  61. package/dist/kit/system.d.ts +27 -29
  62. package/dist/kit/system.d.ts.map +1 -1
  63. package/dist/kit/system.js +62 -58
  64. package/dist/kit/system.js.map +1 -1
  65. package/dist/kit/withdrawn.d.ts +3 -3
  66. package/dist/kit/withdrawn.js +3 -3
  67. package/dist/kit/withdrawn.js.map +1 -1
  68. package/dist/marks/curve-area.d.ts +37 -18
  69. package/dist/marks/curve-area.d.ts.map +1 -1
  70. package/dist/marks/curve-area.js +50 -73
  71. package/dist/marks/curve-area.js.map +1 -1
  72. package/dist/marks/drop-lines.d.ts +45 -10
  73. package/dist/marks/drop-lines.d.ts.map +1 -1
  74. package/dist/marks/drop-lines.js +37 -52
  75. package/dist/marks/drop-lines.js.map +1 -1
  76. package/dist/marks/plot-point.d.ts +56 -20
  77. package/dist/marks/plot-point.d.ts.map +1 -1
  78. package/dist/marks/plot-point.js +65 -91
  79. package/dist/marks/plot-point.js.map +1 -1
  80. package/dist/marks/riemann-sum.d.ts +47 -26
  81. package/dist/marks/riemann-sum.d.ts.map +1 -1
  82. package/dist/marks/riemann-sum.js +57 -85
  83. package/dist/marks/riemann-sum.js.map +1 -1
  84. package/dist/marks/tangent-line.d.ts +58 -14
  85. package/dist/marks/tangent-line.d.ts.map +1 -1
  86. package/dist/marks/tangent-line.js +73 -87
  87. package/dist/marks/tangent-line.js.map +1 -1
  88. package/dist/marks/vector-arrow.d.ts +48 -20
  89. package/dist/marks/vector-arrow.d.ts.map +1 -1
  90. package/dist/marks/vector-arrow.js +58 -78
  91. package/dist/marks/vector-arrow.js.map +1 -1
  92. package/dist/nodes.d.ts +13 -5
  93. package/dist/nodes.d.ts.map +1 -1
  94. package/dist/nodes.js +0 -6
  95. package/dist/nodes.js.map +1 -1
  96. package/dist/plots/function-plot.d.ts +135 -43
  97. package/dist/plots/function-plot.d.ts.map +1 -1
  98. package/dist/plots/function-plot.js +146 -177
  99. package/dist/plots/function-plot.js.map +1 -1
  100. package/dist/plots/points-plot.d.ts +55 -19
  101. package/dist/plots/points-plot.d.ts.map +1 -1
  102. package/dist/plots/points-plot.js +31 -58
  103. package/dist/plots/points-plot.js.map +1 -1
  104. package/dist/plots/stream-lines.d.ts +60 -19
  105. package/dist/plots/stream-lines.d.ts.map +1 -1
  106. package/dist/plots/stream-lines.js +60 -79
  107. package/dist/plots/stream-lines.js.map +1 -1
  108. package/dist/plots/traced-path.d.ts +54 -15
  109. package/dist/plots/traced-path.d.ts.map +1 -1
  110. package/dist/plots/traced-path.js +33 -48
  111. package/dist/plots/traced-path.js.map +1 -1
  112. package/dist/plots/vector-field.d.ts +48 -11
  113. package/dist/plots/vector-field.d.ts.map +1 -1
  114. package/dist/plots/vector-field.js +50 -64
  115. package/dist/plots/vector-field.js.map +1 -1
  116. package/dist/structures/network-graph.d.ts +140 -49
  117. package/dist/structures/network-graph.d.ts.map +1 -1
  118. package/dist/structures/network-graph.js +168 -217
  119. package/dist/structures/network-graph.js.map +1 -1
  120. package/dist/structures/sample-space.d.ts +90 -38
  121. package/dist/structures/sample-space.d.ts.map +1 -1
  122. package/dist/structures/sample-space.js +132 -170
  123. package/dist/structures/sample-space.js.map +1 -1
  124. package/dist/systems/axes2d.d.ts +159 -37
  125. package/dist/systems/axes2d.d.ts.map +1 -1
  126. package/dist/systems/axes2d.js +147 -183
  127. package/dist/systems/axes2d.js.map +1 -1
  128. package/dist/systems/number-line.d.ts +80 -28
  129. package/dist/systems/number-line.d.ts.map +1 -1
  130. package/dist/systems/number-line.js +82 -118
  131. package/dist/systems/number-line.js.map +1 -1
  132. package/dist/systems/number-plane.d.ts +140 -31
  133. package/dist/systems/number-plane.d.ts.map +1 -1
  134. package/dist/systems/number-plane.js +142 -149
  135. package/dist/systems/number-plane.js.map +1 -1
  136. package/dist/systems/polar-plane.d.ts +76 -26
  137. package/dist/systems/polar-plane.d.ts.map +1 -1
  138. package/dist/systems/polar-plane.js +107 -133
  139. package/dist/systems/polar-plane.js.map +1 -1
  140. package/dist/tex/index.d.ts.map +1 -1
  141. package/dist/tex/index.js +1 -0
  142. package/dist/tex/index.js.map +1 -1
  143. package/dist/tex/matrix.d.ts +88 -18
  144. package/dist/tex/matrix.d.ts.map +1 -1
  145. package/dist/tex/matrix.js +33 -50
  146. package/dist/tex/matrix.js.map +1 -1
  147. package/dist/tex/node.d.ts +84 -201
  148. package/dist/tex/node.d.ts.map +1 -1
  149. package/dist/tex/node.js +23 -593
  150. package/dist/tex/node.js.map +1 -1
  151. package/dist/tex/typeset.d.ts +133 -0
  152. package/dist/tex/typeset.d.ts.map +1 -0
  153. package/dist/tex/typeset.js +403 -0
  154. package/dist/tex/typeset.js.map +1 -0
  155. package/dist/three/axes3d.d.ts +214 -54
  156. package/dist/three/axes3d.d.ts.map +1 -1
  157. package/dist/three/axes3d.js +163 -204
  158. package/dist/three/axes3d.js.map +1 -1
  159. package/dist/three/curve-plot3d.d.ts +108 -42
  160. package/dist/three/curve-plot3d.d.ts.map +1 -1
  161. package/dist/three/curve-plot3d.js +97 -132
  162. package/dist/three/curve-plot3d.js.map +1 -1
  163. package/dist/three/entries.d.ts +17 -0
  164. package/dist/three/entries.d.ts.map +1 -0
  165. package/dist/three/entries.js +15 -0
  166. package/dist/three/entries.js.map +1 -0
  167. package/dist/three/plot-point3d.d.ts +85 -12
  168. package/dist/three/plot-point3d.d.ts.map +1 -1
  169. package/dist/three/plot-point3d.js +27 -53
  170. package/dist/three/plot-point3d.js.map +1 -1
  171. package/dist/three/space.d.ts +17 -2
  172. package/dist/three/space.d.ts.map +1 -1
  173. package/dist/three/space.js +19 -8
  174. package/dist/three/space.js.map +1 -1
  175. package/dist/three/surface-plot3d.d.ts +176 -49
  176. package/dist/three/surface-plot3d.d.ts.map +1 -1
  177. package/dist/three/surface-plot3d.js +227 -261
  178. package/dist/three/surface-plot3d.js.map +1 -1
  179. package/dist/three/vector-arrow3d.d.ts +87 -16
  180. package/dist/three/vector-arrow3d.d.ts.map +1 -1
  181. package/dist/three/vector-arrow3d.js +48 -67
  182. package/dist/three/vector-arrow3d.js.map +1 -1
  183. package/package.json +4 -4
  184. package/src/annotate/angle-mark.ts +95 -105
  185. package/src/annotate/curly-brace.ts +107 -85
  186. package/src/annotate/emphasis-mark.ts +55 -26
  187. package/src/engine.ts +35 -21
  188. package/src/kit/component.ts +57 -0
  189. package/src/kit/curve.ts +38 -20
  190. package/src/kit/field-mark.ts +124 -108
  191. package/src/kit/follow.ts +146 -120
  192. package/src/kit/furniture.ts +6 -1
  193. package/src/kit/graph.ts +116 -0
  194. package/src/kit/mark.ts +135 -114
  195. package/src/kit/place.ts +32 -56
  196. package/src/kit/system.ts +77 -71
  197. package/src/kit/withdrawn.ts +3 -3
  198. package/src/marks/curve-area.ts +65 -65
  199. package/src/marks/drop-lines.ts +50 -42
  200. package/src/marks/plot-point.ts +77 -82
  201. package/src/marks/riemann-sum.ts +73 -72
  202. package/src/marks/tangent-line.ts +87 -71
  203. package/src/marks/vector-arrow.ts +73 -73
  204. package/src/nodes.ts +41 -5
  205. package/src/plots/function-plot.ts +155 -171
  206. package/src/plots/points-plot.ts +46 -50
  207. package/src/plots/stream-lines.ts +75 -66
  208. package/src/plots/traced-path.ts +51 -33
  209. package/src/plots/vector-field.ts +68 -49
  210. package/src/structures/network-graph.ts +168 -185
  211. package/src/structures/sample-space.ts +149 -148
  212. package/src/systems/axes2d.ts +165 -156
  213. package/src/systems/number-line.ts +91 -92
  214. package/src/systems/number-plane.ts +149 -120
  215. package/src/systems/polar-plane.ts +117 -116
  216. package/src/tex/index.ts +2 -1
  217. package/src/tex/matrix.ts +62 -40
  218. package/src/tex/node.ts +54 -621
  219. package/src/tex/typeset.ts +461 -0
  220. package/src/three/axes3d.ts +187 -160
  221. package/src/three/curve-plot3d.ts +107 -110
  222. package/src/three/entries.ts +42 -0
  223. package/src/three/plot-point3d.ts +42 -45
  224. package/src/three/space.ts +34 -9
  225. package/src/three/surface-plot3d.ts +312 -323
  226. package/src/three/vector-arrow3d.ts +65 -54
  227. package/dist/browser/chunks/chunk-3GJB6AVO.js +0 -2
  228. package/dist/browser/chunks/chunk-3GJB6AVO.js.map +0 -7
  229. package/dist/browser/chunks/chunk-D5WHCVBC.js +0 -2
  230. package/dist/browser/chunks/chunk-D5WHCVBC.js.map +0 -7
  231. package/dist/browser/chunks/chunk-WL4KEX7Y.js +0 -2
  232. package/dist/browser/chunks/chunk-WL4KEX7Y.js.map +0 -7
  233. package/src/kit/placement.ts +0 -8
@@ -1,4 +1,4 @@
1
- import { Mesh3D, type Command, type CommandArgs, type Geometry3D, type Mesh3DProps, type NodeConfig } from "@motionscript/sdk";
1
+ import { type Geometry3D, type Mesh3DProps, type NodeOf, type Blend3D as _Blend3D, type Color as _Color, type Faces3D as _Faces3D, type Fill3D as _Fill3D, 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
2
  import type { Interval } from "../kit/coords.js";
3
3
  import type { ExpressionScope } from "../kit/expression.js";
4
4
  import { type PlotSource } from "../kit/source.js";
@@ -12,49 +12,115 @@ export interface CurvePlot3dProps extends Mesh3DProps {
12
12
  end?: number;
13
13
  }
14
14
  /** A curve through a 3D graph, three parts in `t`: `(cos(t), sin(t), t / 4)`. */
15
- export declare class CurvePlot3d extends Mesh3D<CurvePlot3dProps> {
16
- expression: PlotSource;
15
+ export declare const CurvePlot3d: import("@motionscript/sdk").Component<"curvePlot3d", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Transform3DState, {
16
+ expression: import("@motionscript/sdk").Type<string | PlotSource, PlotSource, false>;
17
17
  /** The span of `t` that is drawn; 0 to 1 when left out. */
18
- domain: Interval | null;
19
- params: ExpressionScope;
18
+ domain: import("@motionscript/sdk").Type<Interval | null, Interval | null, false>;
19
+ params: import("@motionscript/sdk").Type<Readonly<Record<string, number>>, Readonly<Record<string, number>>, false>;
20
20
  /** How many points the curve is drawn through. */
21
- samples: number;
21
+ samples: import("@motionscript/sdk").Type<number, number, false>;
22
22
  /** The radius of the line, in scene units. */
23
- thickness: number;
23
+ thickness: import("@motionscript/sdk").Type<number, number, false>;
24
24
  /** The part of the curve that is drawn, as shares of its length in `t`. */
25
- start: number;
26
- end: number;
27
- constructor(props?: NodeConfig<CurvePlot3d, CurvePlot3dProps>);
28
- /** Change the equation, the curve bending from the one into the other. */
29
- morphTo(args: CommandArgs<{
30
- expression: string;
31
- }> & {
32
- duration: number;
33
- }): Command<CurvePlot3dProps>;
34
- /** Animate the equation's named values. */
35
- paramsTo(args: CommandArgs<{
36
- params: ExpressionScope;
37
- }> & {
38
- duration: number;
39
- }): Command<CurvePlot3dProps>;
40
- /** Animate the span of `t` that is drawn. */
41
- domainTo(args: CommandArgs<{
42
- domain: Interval | null;
43
- }> & {
44
- duration: number;
45
- }): Command<CurvePlot3dProps>;
46
- /** Draw the curve on, or wipe it off: animates `start` and `end`. */
47
- progressTo(args: CommandArgs<{
48
- start?: number;
49
- end?: number;
50
- }> & {
51
- duration: number;
52
- }): Command<CurvePlot3dProps>;
53
- protected buildGeometry(): Geometry3D | undefined;
54
- private _key;
55
- private _run;
56
- private _points;
57
- /** `source` as a graph point for a share `u` of its span, or `false` where it has none. */
58
- private _curve;
59
- }
25
+ start: import("@motionscript/sdk").Type<number, number, false>;
26
+ end: import("@motionscript/sdk").Type<number, number, false>;
27
+ graph: import("@motionscript/sdk").Type<import("./space.js").Graph3D | null, import("./space.js").Graph3D | null, true>;
28
+ opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
29
+ blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
30
+ fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
31
+ faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
32
+ wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
33
+ vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
34
+ alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
35
+ aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
36
+ normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
37
+ envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
38
+ geometry: import("@motionscript/sdk").Type<Geometry3D | undefined, Geometry3D | undefined, false>;
39
+ material: import("@motionscript/sdk").Type<_Material3D | readonly _Material3D[] | undefined, _Material3D | readonly _Material3D[] | undefined, false>;
40
+ roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
41
+ metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
42
+ emission: import("@motionscript/sdk").Type<_Color | undefined, _NormalizedColor | undefined, false>;
43
+ emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
44
+ roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
45
+ metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
46
+ shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
47
+ unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
48
+ }>, {
49
+ readonly morphTo: readonly ["expression"];
50
+ readonly paramsTo: readonly ["params"];
51
+ readonly domainTo: readonly ["domain"];
52
+ readonly progressTo: readonly ["start", "end"];
53
+ }, null, _Node3D<_Node3DProps>, import("@motionscript/sdk").CallProps3D<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Transform3DState, {
54
+ expression: import("@motionscript/sdk").Type<string | PlotSource, PlotSource, false>;
55
+ /** The span of `t` that is drawn; 0 to 1 when left out. */
56
+ domain: import("@motionscript/sdk").Type<Interval | null, Interval | null, false>;
57
+ params: import("@motionscript/sdk").Type<Readonly<Record<string, number>>, Readonly<Record<string, number>>, false>;
58
+ /** How many points the curve is drawn through. */
59
+ samples: import("@motionscript/sdk").Type<number, number, false>;
60
+ /** The radius of the line, in scene units. */
61
+ thickness: import("@motionscript/sdk").Type<number, number, false>;
62
+ /** The part of the curve that is drawn, as shares of its length in `t`. */
63
+ start: import("@motionscript/sdk").Type<number, number, false>;
64
+ end: import("@motionscript/sdk").Type<number, number, false>;
65
+ graph: import("@motionscript/sdk").Type<import("./space.js").Graph3D | null, import("./space.js").Graph3D | null, true>;
66
+ opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
67
+ blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
68
+ fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
69
+ faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
70
+ wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
71
+ vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
72
+ alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
73
+ aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
74
+ normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
75
+ envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
76
+ geometry: import("@motionscript/sdk").Type<Geometry3D | undefined, Geometry3D | undefined, false>;
77
+ material: import("@motionscript/sdk").Type<_Material3D | readonly _Material3D[] | undefined, _Material3D | readonly _Material3D[] | undefined, false>;
78
+ roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
79
+ metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
80
+ emission: import("@motionscript/sdk").Type<_Color | undefined, _NormalizedColor | undefined, false>;
81
+ emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
82
+ roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
83
+ metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
84
+ shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
85
+ unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
86
+ }>, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Transform3DState, {
87
+ expression: import("@motionscript/sdk").Type<string | PlotSource, PlotSource, false>;
88
+ /** The span of `t` that is drawn; 0 to 1 when left out. */
89
+ domain: import("@motionscript/sdk").Type<Interval | null, Interval | null, false>;
90
+ params: import("@motionscript/sdk").Type<Readonly<Record<string, number>>, Readonly<Record<string, number>>, false>;
91
+ /** How many points the curve is drawn through. */
92
+ samples: import("@motionscript/sdk").Type<number, number, false>;
93
+ /** The radius of the line, in scene units. */
94
+ thickness: import("@motionscript/sdk").Type<number, number, false>;
95
+ /** The part of the curve that is drawn, as shares of its length in `t`. */
96
+ start: import("@motionscript/sdk").Type<number, number, false>;
97
+ end: import("@motionscript/sdk").Type<number, number, false>;
98
+ graph: import("@motionscript/sdk").Type<import("./space.js").Graph3D | null, import("./space.js").Graph3D | null, true>;
99
+ opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
100
+ blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
101
+ fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
102
+ faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
103
+ wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
104
+ vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
105
+ alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
106
+ aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
107
+ normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
108
+ envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
109
+ geometry: import("@motionscript/sdk").Type<Geometry3D | undefined, Geometry3D | undefined, false>;
110
+ material: import("@motionscript/sdk").Type<_Material3D | readonly _Material3D[] | undefined, _Material3D | readonly _Material3D[] | undefined, false>;
111
+ roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
112
+ metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
113
+ emission: import("@motionscript/sdk").Type<_Color | undefined, _NormalizedColor | undefined, false>;
114
+ emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
115
+ roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
116
+ metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
117
+ shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
118
+ unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
119
+ }>, {
120
+ readonly morphTo: readonly ["expression"];
121
+ readonly paramsTo: readonly ["params"];
122
+ readonly domainTo: readonly ["domain"];
123
+ readonly progressTo: readonly ["start", "end"];
124
+ }, _Node3D<_Node3DProps>>>>;
125
+ export type CurvePlot3d = NodeOf<typeof CurvePlot3d>;
60
126
  //# sourceMappingURL=curve-plot3d.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"curve-plot3d.d.ts","sourceRoot":"","sources":["../../src/three/curve-plot3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,MAAM,EAGN,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,UAAU,EAElB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,EAA4D,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAG1G,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;AAED,iFAAiF;AACjF,qBAOa,WAAY,SAAQ,MAAM,CAAC,gBAAgB,CAAC;IAE7C,UAAU,EAAE,UAAU,CAAC;IAE/B,2DAA2D;IAC0C,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IAEvE,MAAM,EAAE,eAAe,CAAC;IAE9E,kDAAkD;IACiC,OAAO,EAAE,MAAM,CAA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EH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC"}
@@ -1,141 +1,106 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { command, Geo, Mesh3D, node, property, } from "@motionscript/sdk";
1
+ import { component3d, Geo, Material, Types, } from "@motionscript/sdk";
8
2
  import { parseSpaceCurve, spaceCurveParams } from "../kit/equation3d.js";
9
3
  import { PLOT_COLOR } from "../kit/furniture.js";
10
- import { clamp, stated } from "../kit/geometry.js";
11
- import { lerpDomain, lerpParams, lerpSource, readSource, scopeFor } from "../kit/source.js";
12
- import { spaceOf } from "./space.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
+ };
13
27
  /** A curve through a 3D graph, three parts in `t`: `(cos(t), sin(t), t / 4)`. */
14
- let CurvePlot3d = class CurvePlot3d extends Mesh3D {
15
- constructor(props) {
16
- super(props ?? {});
17
- if (props?.fill === undefined)
18
- this.applyProp("fill", PLOT_COLOR);
19
- }
20
- /** Change the equation, the curve bending from the one into the other. */
21
- morphTo(args) {
22
- return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });
23
- }
24
- /** Animate the equation's named values. */
25
- paramsTo(args) {
26
- return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });
27
- }
28
- /** Animate the span of `t` that is drawn. */
29
- domainTo(args) {
30
- return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });
31
- }
32
- /** Draw the curve on, or wipe it off: animates `start` and `end`. */
33
- progressTo(args) {
34
- return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });
35
- }
36
- buildGeometry() {
37
- const space = spaceOf(this);
38
- if (!space)
39
- return undefined;
40
- const points = this._points(space);
41
- if (points.length < 2)
42
- return undefined;
43
- return Geo.tube({ points, radius: this.thickness, segments: [points.length - 1, 8] });
44
- }
45
- _key = "";
46
- _run = [];
47
- _points(space) {
48
- const { source, blend } = this.expression;
49
- const start = clamp(this.start, 0, 1);
50
- const end = clamp(this.end, 0, 1);
51
- const samples = Math.max(2, Math.round(this.samples));
52
- const key = [source, blend?.from, blend?.t, space.revision, this.domain, JSON.stringify(this.params), start, end, samples].join("|");
53
- if (key === this._key)
54
- return this._run;
55
- this._key = key;
56
- this._run = [];
57
- const to = this._curve(source);
58
- if (!to || !(end > start))
59
- return this._run;
60
- const from = blend ? this._curve(blend.from) : null;
61
- const steps = Math.max(1, Math.round(samples * (end - start)));
62
- const a = { x: 0, y: 0, z: 0 };
63
- const b = { x: 0, y: 0, z: 0 };
64
- for (let i = 0; i <= steps; i++) {
65
- const u = start + ((end - start) * i) / steps;
66
- if (!to(u, b))
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
+ render: (ctx, s) => ctx.draw(Material.mesh(s, curveGeometry(s))),
43
+ });
44
+ function curveGeometry(s) {
45
+ const space = graphOf(s);
46
+ if (!space)
47
+ return undefined;
48
+ const points = pointsOf(s, space);
49
+ if (points.length < 2)
50
+ return undefined;
51
+ return Geo.tube({ points, radius: s.thickness, segments: [points.length - 1, 8] });
52
+ }
53
+ /** The last run drawn for each curve, kept while what it is drawn from is unchanged. */
54
+ const runs = new WeakMap();
55
+ function pointsOf(s, space) {
56
+ const { source, blend } = s.expression;
57
+ const start = clamp(s.start, 0, 1);
58
+ const end = clamp(s.end, 0, 1);
59
+ const samples = Math.max(2, Math.round(s.samples));
60
+ const key = [source, blend?.from, blend?.t, space.revision, s.domain, JSON.stringify(s.params), start, end, samples].join("|");
61
+ const kept = runs.get(s);
62
+ if (kept?.key === key)
63
+ return kept.run;
64
+ const run = [];
65
+ runs.set(s, { key, run });
66
+ const to = curveOf(s, source);
67
+ if (!to || !(end > start))
68
+ return run;
69
+ const from = blend ? curveOf(s, blend.from) : null;
70
+ const steps = Math.max(1, Math.round(samples * (end - start)));
71
+ const a = { x: 0, y: 0, z: 0 };
72
+ const b = { x: 0, y: 0, z: 0 };
73
+ for (let i = 0; i <= steps; i++) {
74
+ const u = start + ((end - start) * i) / steps;
75
+ if (!to(u, b))
76
+ continue;
77
+ if (from && blend) {
78
+ if (!from(u, a))
67
79
  continue;
68
- if (from && blend) {
69
- if (!from(u, a))
70
- continue;
71
- b.x = a.x + (b.x - a.x) * blend.t;
72
- b.y = a.y + (b.y - a.y) * blend.t;
73
- b.z = a.z + (b.z - a.z) * blend.t;
74
- }
75
- this._run.push(space.offset(b.x, b.y, b.z));
80
+ b.x = a.x + (b.x - a.x) * blend.t;
81
+ b.y = a.y + (b.y - a.y) * blend.t;
82
+ b.z = a.z + (b.z - a.z) * blend.t;
76
83
  }
77
- return this._run;
78
- }
79
- /** `source` as a graph point for a share `u` of its span, or `false` where it has none. */
80
- _curve(source) {
81
- const equation = equationOf(source);
82
- if (!equation)
83
- return null;
84
- const params = scopeFor(spaceCurveParams(source), this.params);
85
- const [t0, t1] = this.domain ?? [0, 1];
86
- const { x, y, z } = equation;
87
- return (u, out) => {
88
- const t = t0 + (t1 - t0) * u;
89
- out.x = x(t, 0, params);
90
- out.y = y(t, 0, params);
91
- out.z = z(t, 0, params);
92
- return Number.isFinite(out.x) && Number.isFinite(out.y) && Number.isFinite(out.z);
93
- };
84
+ run.push(space.offset(b.x, b.y, b.z));
94
85
  }
95
- };
96
- __decorate([
97
- property({ default: "", mapper: readSource, tween: lerpSource, kind: "spaceCurveEquation" })
98
- ], CurvePlot3d.prototype, "expression", void 0);
99
- __decorate([
100
- property({ default: null, tween: lerpDomain, kind: "range", defaultMin: 0, defaultMax: 1 })
101
- ], CurvePlot3d.prototype, "domain", void 0);
102
- __decorate([
103
- property({ default: {}, tween: lerpParams })
104
- ], CurvePlot3d.prototype, "params", void 0);
105
- __decorate([
106
- property({ default: 160, min: 2, max: 2000, step: 1, animatable: false })
107
- ], CurvePlot3d.prototype, "samples", void 0);
108
- __decorate([
109
- property({ default: 0.04, min: 0.001, step: 0.005 })
110
- ], CurvePlot3d.prototype, "thickness", void 0);
111
- __decorate([
112
- property({ default: 0, min: 0, max: 1, step: 0.01 })
113
- ], CurvePlot3d.prototype, "start", void 0);
114
- __decorate([
115
- property({ default: 1, min: 0, max: 1, step: 0.01 })
116
- ], CurvePlot3d.prototype, "end", void 0);
117
- __decorate([
118
- command({ args: ["expression"] })
119
- ], CurvePlot3d.prototype, "morphTo", null);
120
- __decorate([
121
- command({ args: ["params"] })
122
- ], CurvePlot3d.prototype, "paramsTo", null);
123
- __decorate([
124
- command({ args: ["domain"] })
125
- ], CurvePlot3d.prototype, "domainTo", null);
126
- __decorate([
127
- command({ args: ["start", "end"] })
128
- ], CurvePlot3d.prototype, "progressTo", null);
129
- CurvePlot3d = __decorate([
130
- node({
131
- key: "curvePlot3d",
132
- within: ["axes3d"],
133
- forkable: true,
134
- layout: { acceptsChildren: false },
135
- seed: { expression: "(2cos(t), 2sin(t), t / 4)", domain: [-6.28, 6.28], fill: PLOT_COLOR },
136
- })
137
- ], CurvePlot3d);
138
- export { CurvePlot3d };
86
+ return run;
87
+ }
88
+ /** `source` as a graph point for a share `u` of its span, or `false` where it has none. */
89
+ function curveOf(s, source) {
90
+ const equation = equationOf(source);
91
+ if (!equation)
92
+ return null;
93
+ const params = scopeFor(spaceCurveParams(source), s.params);
94
+ const [t0, t1] = s.domain ?? [0, 1];
95
+ const { x, y, z } = equation;
96
+ return (u, out) => {
97
+ const t = t0 + (t1 - t0) * u;
98
+ out.x = x(t, 0, params);
99
+ out.y = y(t, 0, params);
100
+ out.z = z(t, 0, params);
101
+ return Number.isFinite(out.x) && Number.isFinite(out.y) && Number.isFinite(out.z);
102
+ };
103
+ }
139
104
  function equationOf(source) {
140
105
  const equation = parseSpaceCurve(source, spaceCurveParams(source));
141
106
  return equation instanceof Error ? null : equation;
@@ -1 +1 @@
1
- {"version":3,"file":"curve-plot3d.js","sourceRoot":"","sources":["../../src/three/curve-plot3d.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACH,OAAO,EACP,GAAG,EACH,MAAM,EACN,IAAI,EACJ,QAAQ,GAOX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAA2B,MAAM,mBAAmB,CAAC;AAE/F,OAAO,EAAE,UAAU,EAAE,MAAM,kBA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s,\r\n type Geometry3D,\r\n type Mesh3DProps,\r\n type NodeConfig,\r\n type Vector3,\r\n} from \"@motionscript/sdk\";\r\nimport type { Interval } from \"../kit/coords\";\r\nimport { parseSpaceCurve, spaceCurveParams, type SpaceCurveEquation } from \"../kit/equation3d\";\r\nimport type { ExpressionScope } from \"../kit/expression\";\r\nimport { PLOT_COLOR } from \"../kit/furniture\";\r\nimport { clamp, stated } from \"../kit/geometry\";\r\nimport { lerpDomain, lerpParams, lerpSource, readSource, scopeFor, type PlotSource } from \"../kit/source\";\r\nimport { spaceOf, type GraphSpace } from \"./space\";\r\n\r\nexport interface CurvePlot3dProps extends Mesh3DProps {\r\n expression?: string | PlotSource;\r\n domain?: Interval | null;\r\n params?: ExpressionScope;\r\n samples?: number;\r\n thickness?: number;\r\n start?: number;\r\n end?: number;\r\n}\r\n\r\n/** A curve through a 3D graph, three parts in `t`: `(cos(t), sin(t), t / 4)`. */\r\n@node({\r\n key: \"curvePlot3d\",\r\n within: [\"axes3d\"],\r\n forkable: true,\r\n layout: { acceptsChildren: false },\r\n seed: { expression: \"(2cos(t), 2sin(t), t / 4)\", domain: [-6.28, 6.28], fill: PLOT_COLOR },\r\n})\r\nexport class CurvePlot3d extends Mesh3D<CurvePlot3dProps> {\r\n @property({ default: \"\", mapper: readSource, tween: lerpSource, kind: \"spaceCurveEquation\" })\r\n declare expression: PlotSource;\r\n\r\n /** The span of `t` that is drawn; 0 to 1 when left out. */\r\n @property({ default: null, tween: lerpDomain, kind: \"range\", defaultMin: 0, defaultMax: 1 }) declare domain: Interval | null;\r\n\r\n @property({ default: {}, tween: lerpParams }) declare params: ExpressionScope;\r\n\r\n /** How many points the curve is drawn through. */\r\n @property({ default: 160, min: 2, max: 2000, step: 1, animatable: false }) declare samples: number;\r\n /** The radius of the line, in scene units. */\r\n @property({ default: 0.04, min: 0.001, step: 0.005 }) declare thickness: number;\r\n\r\n /** The part of the curve that is drawn, as shares of its length in `t`. */\r\n @property({ default: 0, min: 0, max: 1, step: 0.01 }) declare start: number;\r\n @property({ default: 1, min: 0, max: 1, step: 0.01 }) declare end: number;\r\n\r\n constructor(props?: NodeConfig<CurvePlot3d, CurvePlot3dProps>) {\r\n super(props ?? {});\r\n if (props?.fill === undefined) this.applyProp(\"fill\", PLOT_COLOR);\r\n }\r\n\r\n /** Change the equation, the curve bending from the one into the other. */\r\n @command({ args: [\"expression\"] })\r\n morphTo(args: CommandArgs<{ expression: string }> & { duration: number }): Command<CurvePlot3dProps> {\r\n return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });\r\n }\r\n\r\n /** Animate the equation's named values. */\r\n @command({ args: [\"params\"] })\r\n paramsTo(args: CommandArgs<{ params: ExpressionScope }> & { duration: number }): Command<CurvePlot3dProps> {\r\n return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });\r\n }\r\n\r\n /** Animate the span of `t` that is drawn. */\r\n @command({ args: [\"domain\"] })\r\n domainTo(args: CommandArgs<{ domain: Interval | null }> & { duration: number }): Command<CurvePlot3dProps> {\r\n return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });\r\n }\r\n\r\n /** Draw the curve on, or wipe it off: animates `start` and `end`. */\r\n @command({ args: [\"start\", \"end\"] })\r\n progressTo(args: CommandArgs<{ start?: number; end?: number }> & { duration: number }): Command<CurvePlot3dProps> {\r\n return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });\r\n }\r\n\r\n protected override buildGeometry(): Geometry3D | undefined {\r\n const space = spaceOf(this);\r\n if (!space) return undefined;\r\n const points = this._points(space);\r\n if (points.length < 2) return undefined;\r\n return Geo.tube({ points, radius: this.thickness, segments: [points.length - 1, 8] });\r\n }\r\n\r\n private _key = \"\";\r\n private _run: Vector3[] = [];\r\n\r\n private _points(space: GraphSpace): Vector3[] {\r\n const { source, blend } = this.expression;\r\n const start = clamp(this.start, 0, 1);\r\n const end = clamp(this.end, 0, 1);\r\n const samples = Math.max(2, Math.round(this.samples));\r\n const key = [source, blend?.from, blend?.t, space.revision, this.domain, JSON.stringify(this.params), start, end, samples].join(\"|\");\r\n if (key === this._key) return this._run;\r\n this._key = key;\r\n this._run = [];\r\n const to = this._curve(source);\r\n if (!to || !(end > start)) return this._run;\r\n const from = blend ? this._curve(blend.from) : null;\r\n const steps = Math.max(1, Math.round(samples * (end - start)));\r\n const a: Vector3 = { x: 0, y: 0, z: 0 };\r\n const b: Vector3 = { x: 0, y: 0, z: 0 };\r\n for (let i = 0; i <= steps; i++) {\r\n const u = start + ((end - start) * i) / steps;\r\n if (!to(u, b)) continue;\r\n if (from && blend) {\r\n if (!from(u, a)) continue;\r\n b.x = a.x + (b.x - a.x) * blend.t;\r\n b.y = a.y + (b.y - a.y) * blend.t;\r\n b.z = a.z + (b.z - a.z) * blend.t;\r\n }\r\n this._run.push(space.offset(b.x, b.y, b.z));\r\n }\r\n return this._run;\r\n }\r\n\r\n /** `source` as a graph point for a share `u` of its span, or `false` where it has none. */\r\n private _curve(source: string): ((u: number, out: Vector3) => boolean) | null {\r\n const equation = equationOf(source);\r\n if (!equation) return null;\r\n const params = scopeFor(spaceCurveParams(source), this.params);\r\n const [t0, t1] = this.domain ?? [0, 1];\r\n const { x, y, z } = equation;\r\n return (u, out) => {\r\n const t = t0 + (t1 - t0) * u;\r\n out.x = x(t, 0, params);\r\n out.y = y(t, 0, params);\r\n out.z = z(t, 0, params);\r\n return Number.isFinite(out.x) && Number.isFinite(out.y) && Number.isFinite(out.z);\r\n };\r\n }\r\n}\r\n\r\nfunction equationOf(source: string): SpaceCurveEquation | null {\r\n const equation = parseSpaceCurve(source, spaceCurveParams(source));\r\n return equation instanceof Error ? null : equation;\r\n}\r\n"]}
1
+ {"version":3,"file":"curve-plot3d.js","sourceRoot":"","sources":["../../src/three/curve-plot3d.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,GAAG,EACH,QAAQ,EACR,KAAK,GAiBR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAA2B,MAA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Ac;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 {\r\n component3d,\r\n Geo,\r\n Material,\r\n Types,\r\n type Geometry3D,\r\n type Mesh3DProps,\r\n type NodeOf,\r\n type Values,\r\n type Vector3,\r\n // Named so the emitted declaration reaches these through the sdk, not core.\r\n type Blend3D as _Blend3D,\r\n type Color as _Color,\r\n type Faces3D as _Faces3D,\r\n type Fill3D as _Fill3D,\r\n type Material3D as _Material3D,\r\n type Node3D as _Node3D,\r\n type Node3DProps as _Node3DProps,\r\n type NormalizedColor as _NormalizedColor,\r\n type Shading3D as _Shading3D,\r\n type Texture3D as _Texture3D,\r\n} from \"@motionscript/sdk\";\r\nimport type { Interval } from \"../kit/coords\";\r\nimport { parseSpaceCurve, spaceCurveParams, type SpaceCurveEquation } from \"../kit/equation3d\";\r\nimport type { ExpressionScope } from \"../kit/expression\";\r\nimport { PLOT_COLOR } from \"../kit/furniture\";\r\nimport { clamp } from \"../kit/geometry\";\r\nimport { lerpParams, lerpSource, readSource, scopeFor, type PlotSource } from \"../kit/source\";\r\nimport { domainEntry, meshEntries } from \"./entries\";\r\nimport { graphEntry, graphOf, type GraphSpace } from \"./space\";\r\n\r\nexport interface CurvePlot3dProps extends Mesh3DProps {\r\n expression?: string | PlotSource;\r\n domain?: Interval | null;\r\n params?: ExpressionScope;\r\n samples?: number;\r\n thickness?: number;\r\n start?: number;\r\n end?: number;\r\n}\r\n\r\nconst state = {\r\n ...meshEntries,\r\n expression: Types.custom<string | PlotSource, PlotSource>(\"\", {\r\n resolve: readSource,\r\n lerp: lerpSource,\r\n kind: \"spaceCurveEquation\",\r\n }),\r\n /** The span of `t` that is drawn; 0 to 1 when left out. */\r\n domain: domainEntry(0, 1),\r\n params: Types.custom<ExpressionScope>({}, { lerp: lerpParams }),\r\n /** How many points the curve is drawn through. */\r\n samples: Types.number(160, { min: 2, max: 2000, step: 1, animatable: false }),\r\n /** The radius of the line, in scene units. */\r\n thickness: Types.number(0.04, { min: 0.001, step: 0.005 }),\r\n /** The part of the curve that is drawn, as shares of its length in `t`. */\r\n start: Types.number(0, { min: 0, max: 1, step: 0.01 }),\r\n end: Types.number(1, { min: 0, max: 1, step: 0.01 }),\r\n graph: graphEntry(),\r\n};\r\n\r\ntype CurveValues = Values<typeof state>;\r\n\r\n/** A curve through a 3D graph, three parts in `t`: `(cos(t), sin(t), t / 4)`. */\r\nexport const CurvePlot3d = component3d({\r\n key: \"curvePlot3d\",\r\n state,\r\n defaults: { fill: PLOT_COLOR },\r\n commands: {\r\n /** Change the equation, the curve bending from the one into the other. */\r\n morphTo: { args: [\"expression\"] },\r\n /** Animate the equation's named values. */\r\n paramsTo: { args: [\"params\"] },\r\n /** Animate the span of `t` that is drawn. */\r\n domainTo: { args: [\"domain\"] },\r\n /** Draw the curve on, or wipe it off: animates `start` and `end`. */\r\n progressTo: { args: [\"start\", \"end\"] },\r\n },\r\n render: (ctx, s) => ctx.draw(Material.mesh(s, curveGeometry(s))),\r\n});\r\n\r\nexport type CurvePlot3d = NodeOf<typeof CurvePlot3d>;\r\n\r\nfunction curveGeometry(s: CurveValues): Geometry3D | undefined {\r\n const space = graphOf(s);\r\n if (!space) return undefined;\r\n const points = pointsOf(s, space);\r\n if (points.length < 2) return undefined;\r\n return Geo.tube({ points, radius: s.thickness, segments: [points.length - 1, 8] });\r\n}\r\n\r\n/** The last run drawn for each curve, kept while what it is drawn from is unchanged. */\r\nconst runs = new WeakMap<object, { readonly key: string; readonly run: Vector3[] }>();\r\n\r\nfunction pointsOf(s: CurveValues, space: GraphSpace): Vector3[] {\r\n const { source, blend } = s.expression;\r\n const start = clamp(s.start, 0, 1);\r\n const end = clamp(s.end, 0, 1);\r\n const samples = Math.max(2, Math.round(s.samples));\r\n const key = [source, blend?.from, blend?.t, space.revision, s.domain, JSON.stringify(s.params), start, end, samples].join(\"|\");\r\n const kept = runs.get(s);\r\n if (kept?.key === key) return kept.run;\r\n const run: Vector3[] = [];\r\n runs.set(s, { key, run });\r\n const to = curveOf(s, source);\r\n if (!to || !(end > start)) return run;\r\n const from = blend ? curveOf(s, blend.from) : null;\r\n const steps = Math.max(1, Math.round(samples * (end - start)));\r\n const a: Vector3 = { x: 0, y: 0, z: 0 };\r\n const b: Vector3 = { x: 0, y: 0, z: 0 };\r\n for (let i = 0; i <= steps; i++) {\r\n const u = start + ((end - start) * i) / steps;\r\n if (!to(u, b)) continue;\r\n if (from && blend) {\r\n if (!from(u, a)) continue;\r\n b.x = a.x + (b.x - a.x) * blend.t;\r\n b.y = a.y + (b.y - a.y) * blend.t;\r\n b.z = a.z + (b.z - a.z) * blend.t;\r\n }\r\n run.push(space.offset(b.x, b.y, b.z));\r\n }\r\n return run;\r\n}\r\n\r\n/** `source` as a graph point for a share `u` of its span, or `false` where it has none. */\r\nfunction curveOf(s: CurveValues, source: string): ((u: number, out: Vector3) => boolean) | null {\r\n const equation = equationOf(source);\r\n if (!equation) return null;\r\n const params = scopeFor(spaceCurveParams(source), s.params);\r\n const [t0, t1] = s.domain ?? [0, 1];\r\n const { x, y, z } = equation;\r\n return (u, out) => {\r\n const t = t0 + (t1 - t0) * u;\r\n out.x = x(t, 0, params);\r\n out.y = y(t, 0, params);\r\n out.z = z(t, 0, params);\r\n return Number.isFinite(out.x) && Number.isFinite(out.y) && Number.isFinite(out.z);\r\n };\r\n}\r\n\r\nfunction equationOf(source: string): SpaceCurveEquation | null {\r\n const equation = parseSpaceCurve(source, spaceCurveParams(source));\r\n return equation instanceof Error ? null : equation;\r\n}\r\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 {\r\n Material,\r\n Types,\r\n type EntryOptions,\r\n type Geometry3D,\r\n type Type,\r\n // Named so the emitted declaration reaches these through the sdk, not core.\r\n type Blend3D as _Blend3D,\r\n type Color as _Color,\r\n type Faces3D as _Faces3D,\r\n type Fill3D as _Fill3D,\r\n type Material3D as _Material3D,\r\n type NormalizedColor as _NormalizedColor,\r\n type Shading3D as _Shading3D,\r\n type Texture3D as _Texture3D,\r\n} from \"@motionscript/sdk\";\r\nimport type { Interval } from \"../kit/coords\";\r\nimport { lerpDomain } from \"../kit/source\";\r\n\r\ntype MeshState = { readonly geometry: Type<Geometry3D | undefined> } & typeof Material.state;\r\n// Restated key by key, so a mark spreading these names each entry's type through the sdk: spread\r\n// as inferred, a mark's declaration copied `emission`'s colour types from core's own.\r\ntype Restated<T> = { [K in Extract<keyof T, string>]: T[K] };\r\n\r\n/**\r\n * A mesh's entries, as a 3D mark draws with them: its surface, and the\r\n * `geometry` a mesh takes, which a mark builds itself and never reads.\r\n */\r\nexport const meshEntries: Restated<MeshState> = {\r\n geometry: Types.custom<Geometry3D | undefined>(undefined),\r\n ...Material.state,\r\n};\r\n\r\ninterface RangeHints extends EntryOptions {\r\n readonly defaultMin: number;\r\n readonly defaultMax: number;\r\n}\r\n\r\n/** A span of a variable, unset until given: what a host offers as a range from `defaultMin` to `defaultMax`. */\r\nexport function domainEntry(defaultMin: number, defaultMax: number): Type<Interval | null> {\r\n return Types.custom<Interval | null, Interval | null, RangeHints>(null, { lerp: lerpDomain, kind: \"range\", defaultMin, defaultMax });\r\n}\r\n"]}