@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 +1 @@
1
- {"version":3,"file":"surface-plot3d.js","sourceRoot":"","sources":["../../src/three/surface-plot3d.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACH,QAAQ,EACR,OAAO,EACP,GAAG,EACH,UAAU,EACV,GAAG,EACH,MAAM,EACN,IAAI,EACJ,QAAQ,GAYX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,YAAY,EAAE,aAAa,EAAwB,MAAM,mBAAmB,CAAC;AAE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Ops,\n command,\n Geo,\n Graphics3D,\n Mat,\n Mesh3D,\n node,\n property,\n type ChildSpace3D,\n type Color,\n type Command,\n type CommandArgs,\n type Geometry3D,\n type Material3D,\n type MaterialShorthand3D,\n type Mesh3DProps,\n type NodeConfig,\n type NormalizedColor,\n type Vector3,\n} from \"@motionscript/sdk\";\nimport type { Interval } from \"../kit/coords\";\nimport { parseSurface, surfaceParams, type SurfaceEquation } from \"../kit/equation3d\";\nimport type { ExpressionScope } from \"../kit/expression\";\nimport { PLOT_COLOR } from \"../kit/furniture\";\nimport { clamp, stated } from \"../kit/geometry\";\nimport { colorAt, lerpScale, readScale } from \"../kit/scale\";\nimport { lerpDomain, lerpParams, lerpSource, readSource, revisionOf, scopeFor, type PlotSource } from \"../kit/source\";\nimport { spaceOf, type GraphSpace } from \"./space\";\n\nexport interface SurfacePlot3dProps extends Mesh3DProps {\n expression?: string | PlotSource;\n uDomain?: Interval | null;\n vDomain?: Interval | null;\n params?: ExpressionScope;\n segments?: number;\n colorScale?: Color[];\n meshLines?: number;\n meshColor?: Color;\n floorShadow?: number;\n}\n\n/** A graph point for grid coordinate `(u, v)`, both 0 to 1, written into `out`. */\ntype SurfaceSampler = (u: number, v: number, out: Vector3) => void;\n\n/**\n * A surface in a 3D graph: a height over x and y (`sin(x) * cos(y)`), or three\n * parts in u and v. A point put inside it rides it.\n */\n@node({\n key: \"surfacePlot3d\",\n within: [\"axes3d\"],\n closed: true,\n forkable: true,\n layout: { acceptsChildren: true },\n seed: { expression: \"sin(x) * cos(y)\", fill: PLOT_COLOR },\n})\nexport class SurfacePlot3d extends Mesh3D<SurfacePlot3dProps> {\n @property({ default: \"\", mapper: readSource, tween: lerpSource, kind: \"surfaceEquation\" })\n declare expression: PlotSource;\n\n /**\n * The span of each variable that is drawn: x and y for a height, which run\n * the width of the axes when left out, u and v for a parametric surface,\n * which run from 0 to 1.\n */\n @property({ default: null, tween: lerpDomain, kind: \"range\", defaultMin: -3, defaultMax: 3 }) declare uDomain: Interval | null;\n @property({ default: null, tween: lerpDomain, kind: \"range\", defaultMin: -3, defaultMax: 3 }) declare vDomain: Interval | null;\n\n /** The equation's named values: any name in it that is not a variable, a function or a constant. */\n @property({ default: {}, tween: lerpParams }) declare params: ExpressionScope;\n\n /** How finely the surface is sampled, each way. */\n @property({ default: 48, min: 2, max: 256, step: 1, animatable: false }) declare segments: number;\n\n /** Colours by height, lowest first, over the axes' z range. Empty paints the surface in its fill. */\n @property({ default: [], mapper: readScale, tween: lerpScale, kind: \"vector\" }) declare colorScale: Color[];\n\n /** How many lines are drawn across the surface each way; zero leaves it bare. */\n @property({ default: 12, min: 0, max: 64, step: 1, animatable: false }) declare meshLines: number;\n @property({ default: \"#0b1220\", kind: \"color\" }) declare meshColor: Color;\n\n /** The opacity of the surface's shadow, laid flat on the floor of the axes and coloured by height; zero draws none. */\n @property({ default: 0, min: 0, max: 1, step: 0.01 }) declare floorShadow: number;\n\n constructor(props?: NodeConfig<SurfacePlot3d, SurfacePlot3dProps>) {\n super(props ?? {});\n if (props?.fill === undefined) this.applyProp(\"fill\", PLOT_COLOR);\n }\n\n /** Change the equation, the surface bending from the one into the other. */\n @command({ args: [\"expression\"] })\n morphTo(args: CommandArgs<{ expression: string }> & { duration: number }): Command<SurfacePlot3dProps> {\n return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });\n }\n\n /** Animate the equation's named values. */\n @command({ args: [\"params\"] })\n paramsTo(args: CommandArgs<{ params: ExpressionScope }> & { duration: number }): Command<SurfacePlot3dProps> {\n return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });\n }\n\n /** Animate the spans that are drawn. */\n @command({ args: [\"uDomain\", \"vDomain\"] })\n domainTo(\n args: CommandArgs<{ uDomain?: Interval | null; vDomain?: Interval | null }> & { duration: number },\n ): Command<SurfacePlot3dProps> {\n return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });\n }\n\n /**\n * The surface's height above its own origin at graph `(x, y)`, or `NaN`\n * where it has none or is not a height. What a point riding it reads.\n */\n valueAt(x: number, y: number): number {\n const { source, blend } = this.expression;\n const value = this._heightOf(source, x, y);\n if (!blend) return value;\n const from = this._heightOf(blend.from, x, y);\n return from + (value - from) * blend.t;\n }\n\n /** @internal */\n override _spaceOf(): ChildSpace3D | null {\n const space = spaceOf(this);\n if (!space) return null;\n return {\n toLocal: (x, y, z) => {\n const height = this.valueAt(x, y);\n return space.offset(x, y, Number.isFinite(height) ? height : z);\n },\n };\n }\n\n protected override buildGeometry(): Geometry3D | undefined {\n const space = spaceOf(this);\n const sample = space && this._sampler(space);\n if (!space || !sample) return undefined;\n const scale = this.colorScale as unknown as NormalizedColor[];\n const point: Vector3 = { x: 0, y: 0, z: 0 };\n const low = space.offset(0, 0, space.zRange[0] - this.z).y;\n const high = space.offset(0, 0, space.zRange[1] - this.z).y;\n return Geo.parametric({\n segments: Math.max(2, Math.round(this.segments)),\n vertex: (u, v) => {\n sample(u, v, point);\n return space.offset(point.x, point.y, point.z);\n },\n ...(scale.length > 0\n ? { color: (_u, _v, position) => colorAt(scale, high > low ? (position.y - low) / (high - low) : 0) }\n : {}),\n computeNormals: true,\n revision: revisionOf(`${this._key(space)}|${JSON.stringify(scale)}`),\n });\n }\n\n protected override materialShorthand(): MaterialShorthand3D {\n const own = super.materialShorthand();\n const scaled = (this.colorScale as unknown as NormalizedColor[]).length > 0;\n // A surface is seen from both sides; a vertex colour multiplies the fill, so a scale is shown on white.\n return { faces: \"both\", ...own, ...(scaled ? { vertexColors: true, fill: \"white\" } : {}) };\n }\n\n protected override buildGraphics3D(): Graphics3D {\n const g3 = new Graphics3D();\n const space = spaceOf(this);\n const lines = space ? this._meshLines(space) : [];\n for (const op of super.buildGraphics3D().ops()) {\n if (op.kind !== \"mesh\") continue;\n g3.mesh(op.geometry, mapMaterials(op.material, (material) => ({\n ...material,\n // Pushed back a hair so the lines drawn on it are not fought for, and blended rather than a hole when faded.\n ...(lines.length > 0 ? { polygonOffset: true, polygonOffsetFactor: 1, polygonOffsetUnits: 1 } : {}),\n ...((this.opacity ?? 1) < 1 ? { depthWrite: false } : {}),\n } as Material3D)), op.transform);\n }\n if (lines.length > 0) {\n const color = colorOps.resolve(this.meshColor);\n g3.line({ points: lines, segments: true, stroke: { fill: color }, opacity: color[3] * (this.opacity ?? 1) });\n }\n const shadow = space && this.floorShadow > 0 ? this._floorShadow(space) : undefined;\n if (shadow) {\n const scaled = (this.colorScale as unknown as NormalizedColor[]).length > 0;\n g3.mesh(shadow, Mat.basic({\n color: scaled ? \"white\" : PLOT_COLOR,\n vertexColors: scaled,\n opacity: this.floorShadow * (this.opacity ?? 1),\n transparent: true,\n // Translucent and under everything: writing depth would hide the floor's grid lines behind it.\n depthWrite: false,\n faces: \"both\",\n }));\n }\n return g3;\n }\n\n private _linesKey = \"\";\n private _lines: Vector3[] = [];\n\n private _heightOf(source: string, x: number, y: number): number {\n const equation = equationOf(source);\n if (equation?.kind !== \"height\") return NaN;\n return equation.f(x, y, scopeFor(surfaceParams(source), this.params));\n }\n\n private _key(space: GraphSpace): string {\n const { source, blend } = this.expression;\n return [source, blend?.from, blend?.t, space.revision, this.uDomain, this.vDomain, JSON.stringify(this.params), this.x, this.y, this.z].join(\"|\");\n }\n\n private _sampler(space: GraphSpace): SurfaceSampler | null {\n const { source, blend } = this.expression;\n const to = this._surface(source, space);\n if (!to || !blend) return to;\n const from = this._surface(blend.from, space);\n if (!from) return to;\n const start: Vector3 = { x: 0, y: 0, z: 0 };\n return (u, v, out) => {\n from(u, v, start);\n to(u, v, out);\n out.x = start.x + (out.x - start.x) * blend.t;\n out.y = start.y + (out.y - start.y) * blend.t;\n out.z = start.z + (out.z - start.z) * blend.t;\n };\n }\n\n /** `source` as graph points, measured from this node's own position. */\n private _surface(source: string, space: GraphSpace): SurfaceSampler | null {\n const equation = equationOf(source);\n if (!equation) return null;\n const params = scopeFor(surfaceParams(source), this.params);\n if (equation.kind === \"parametric\") {\n const [u0, u1] = this.uDomain ?? [0, 1];\n const [v0, v1] = this.vDomain ?? [0, 1];\n const { x, y, z } = equation;\n return (u, v, out) => {\n const a = u0 + (u1 - u0) * u;\n const b = v0 + (v1 - v0) * v;\n out.x = finite(x(a, b, params));\n out.y = finite(y(a, b, params));\n out.z = finite(z(a, b, params));\n };\n }\n const [x0, x1] = this.uDomain ?? [space.xRange[0] - this.x, space.xRange[1] - this.x];\n const [y0, y1] = this.vDomain ?? [space.yRange[0] - this.y, space.yRange[1] - this.y];\n // Held inside the axes: a pole would otherwise stretch one triangle across the scene.\n const low = space.zRange[0] - this.z;\n const high = space.zRange[1] - this.z;\n const { f } = equation;\n return (u, v, out) => {\n out.x = x0 + (x1 - x0) * u;\n out.y = y0 + (y1 - y0) * v;\n out.z = clamp(finite(f(out.x, out.y, params)), low, high);\n };\n }\n\n private _floorShadow(space: GraphSpace): Geometry3D | undefined {\n const sample = this._sampler(space);\n if (!sample) return undefined;\n const scale = this.colorScale as unknown as NormalizedColor[];\n const [low, high] = space.zRange;\n const floor = low - this.z;\n const point: Vector3 = { x: 0, y: 0, z: 0 };\n return Geo.parametric({\n segments: Math.max(2, Math.round(this.segments)),\n vertex: (u, v) => {\n sample(u, v, point);\n return space.offset(point.x, point.y, floor);\n },\n ...(scale.length > 0\n ? {\n color: (u: number, v: number) => {\n sample(u, v, point);\n return colorAt(scale, high > low ? (point.z + this.z - low) / (high - low) : 0);\n },\n }\n : {}),\n revision: revisionOf(`${this._key(space)}|${JSON.stringify(scale)}|floor`),\n });\n }\n\n private _meshLines(space: GraphSpace): Vector3[] {\n const count = Math.round(this.meshLines);\n const sample = count > 0 ? this._sampler(space) : null;\n if (!sample) return [];\n const steps = Math.max(2, Math.round(this.segments));\n const key = `${this._key(space)}|${count}|${steps}`;\n if (key === this._linesKey) return this._lines;\n const lines: Vector3[] = [];\n const point: Vector3 = { x: 0, y: 0, z: 0 };\n const at = (u: number, v: number): Vector3 => {\n sample(u, v, point);\n return space.offset(point.x, point.y, point.z);\n };\n for (let i = 0; i <= count; i++) {\n const fixed = i / count;\n for (let j = 0; j < steps; j++) {\n lines.push(at(fixed, j / steps), at(fixed, (j + 1) / steps));\n lines.push(at(j / steps, fixed), at((j + 1) / steps, fixed));\n }\n }\n this._lines = lines;\n this._linesKey = key;\n return lines;\n }\n}\n\nfunction equationOf(source: string): SurfaceEquation | null {\n const equation = parseSurface(source, surfaceParams(source));\n return equation instanceof Error ? null : equation;\n}\n\n// A hole in the data is drawn flat rather than as a hole in the mesh.\nfunction finite(value: number): number {\n return Number.isFinite(value) ? value : 0;\n}\n\nfunction mapMaterials(\n material: Material3D | readonly Material3D[],\n change: (material: Material3D) => Material3D,\n): Material3D | readonly Material3D[] {\n return Array.isArray(material) ? (material as readonly Material3D[]).map(change) : change(material as Material3D);\n}\n"]}
1
+ {"version":3,"file":"surface-plot3d.js","sourceRoot":"","sources":["../../src/three/surface-plot3d.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EACR,WAAW,EACX,GAAG,EACH,UAAU,EACV,GAAG,EACH,QAAQ,EACR,KAAK,GAoBR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,YAAY,EAAE,aAAa,EAAwB,MAAM,mBAAmB,CAAC;AAEtF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAmB,MAAM,eAAe,CAAC;AAC1G,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAmB,MAAM,SAAS,CAAC;AAiB/D,MAAM,KAAK,GAAG;IACV,GAAG,WAAW;IACd,UAAU,EAAE,KAAK,CAAC,MAAM,CAAkC,EAAE,EAAE;QAC1D,OAAO,EAA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n type Color,\r\n type Geometry3D,\r\n type Material3D,\r\n type Mesh3DProps,\r\n type NodeOf,\r\n type NormalizedColor,\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 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 { parseSurface, surfaceParams, type SurfaceEquation } 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 { colorAt, lerpScale, readScale } from \"../kit/scale\";\r\nimport { lerpParams, lerpSource, readSource, revisionOf, 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 SurfacePlot3dProps extends Mesh3DProps {\r\n expression?: string | PlotSource;\r\n uDomain?: Interval | null;\r\n vDomain?: Interval | null;\r\n params?: ExpressionScope;\r\n segments?: number;\r\n colorScale?: Color[];\r\n meshLines?: number;\r\n meshColor?: Color;\r\n floorShadow?: number;\r\n}\r\n\r\n/** A graph point for grid coordinate `(u, v)`, both 0 to 1, written into `out`. */\r\ntype SurfaceSampler = (u: number, v: number, out: Vector3) => void;\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: \"surfaceEquation\",\r\n }),\r\n /**\r\n * The span of each variable that is drawn: x and y for a height, which run\r\n * the width of the axes when left out, u and v for a parametric surface,\r\n * which run from 0 to 1.\r\n */\r\n uDomain: domainEntry(-3, 3),\r\n vDomain: domainEntry(-3, 3),\r\n /** The equation's named values: any name in it that is not a variable, a function or a constant. */\r\n params: Types.custom<ExpressionScope>({}, { lerp: lerpParams }),\r\n /** How finely the surface is sampled, each way. */\r\n segments: Types.number(48, { min: 2, max: 256, step: 1, animatable: false }),\r\n /** Colours by height, lowest first, over the axes' z range. Empty paints the surface in its fill. */\r\n colorScale: Types.custom<Color[], NormalizedColor[]>([], { resolve: readScale, lerp: lerpScale, kind: \"vector\" }),\r\n /** How many lines are drawn across the surface each way; zero leaves it bare. */\r\n meshLines: Types.number(12, { min: 0, max: 64, step: 1, animatable: false }),\r\n meshColor: Types.custom<Color, Color>(\"#0b1220\", { kind: \"color\" }),\r\n /** The opacity of the surface's shadow, laid flat on the floor of the axes and coloured by height; zero draws none. */\r\n floorShadow: Types.number(0, { min: 0, max: 1, step: 0.01 }),\r\n graph: graphEntry(),\r\n};\r\n\r\n/** What a surface is drawn from: its own entries, as its node and its helpers read them. */\r\nexport type SurfaceValues = Values<typeof state> & { readonly x: number; readonly y: number; readonly z: number };\r\n\r\n/**\r\n * A surface in a 3D graph: a height over x and y (`sin(x) * cos(y)`), or three\r\n * parts in u and v. A point put inside it rides it.\r\n */\r\nexport const SurfacePlot3d = component3d({\r\n key: \"surfacePlot3d\",\r\n state,\r\n defaults: { fill: PLOT_COLOR },\r\n commands: {\r\n /** Change the equation, the surface 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 spans that are drawn. */\r\n domainTo: { args: [\"uDomain\", \"vDomain\"] },\r\n },\r\n space: (s) => surfaceSpace(s),\r\n render: (ctx, s) => ctx.draw(drawSurface(s)),\r\n});\r\n\r\nexport type SurfacePlot3d = NodeOf<typeof SurfacePlot3d>;\r\n\r\n/**\r\n * The surface's height above its own origin at graph `(x, y)`, or `NaN`\r\n * where it has none or is not a height. What a point riding it reads.\r\n */\r\nexport function surfaceValueAt(surface: Pick<SurfaceValues, \"expression\" | \"params\">, x: number, y: number): number {\r\n const { source, blend } = surface.expression;\r\n const value = heightOf(surface, source, x, y);\r\n if (!blend) return value;\r\n const from = heightOf(surface, blend.from, x, y);\r\n return from + (value - from) * blend.t;\r\n}\r\n\r\n/** A point inside a surface stands on it: its `x` and `y` say where, and its height is the surface's. */\r\nfunction surfaceSpace(s: SurfaceValues): ChildSpace3D | null {\r\n const space = graphOf(s);\r\n if (!space) return null;\r\n return {\r\n toLocal: (x, y, z) => {\r\n const height = surfaceValueAt(s, x, y);\r\n return space.offset(x, y, Number.isFinite(height) ? height : z);\r\n },\r\n };\r\n}\r\n\r\nfunction drawSurface(s: SurfaceValues): Graphics3D {\r\n const g3 = new Graphics3D();\r\n const space = graphOf(s);\r\n const lines = space ? meshLines(s, space) : [];\r\n const scaled = s.colorScale.length > 0;\r\n // A surface is seen from both sides; a vertex colour multiplies the fill, so a scale is shown on white.\r\n const surface = { ...s, faces: s.faces ?? \"both\", ...(scaled ? { vertexColors: true, fill: \"white\" } : {}) };\r\n for (const op of Material.mesh(surface, space ? surfaceGeometry(s, space) : undefined).ops()) {\r\n if (op.kind !== \"mesh\") continue;\r\n g3.mesh(op.geometry, mapMaterials(op.material, (material) => ({\r\n ...material,\r\n // Pushed back a hair so the lines drawn on it are not fought for, and blended rather than a hole when faded.\r\n ...(lines.length > 0 ? { polygonOffset: true, polygonOffsetFactor: 1, polygonOffsetUnits: 1 } : {}),\r\n ...((s.opacity ?? 1) < 1 ? { depthWrite: false } : {}),\r\n } as Material3D)), op.transform);\r\n }\r\n if (lines.length > 0) {\r\n const color = colorOps.resolve(s.meshColor);\r\n g3.line({ points: lines, segments: true, stroke: { fill: color }, opacity: color[3] * (s.opacity ?? 1) });\r\n }\r\n const shadow = space && s.floorShadow > 0 ? floorShadow(s, space) : undefined;\r\n if (shadow) {\r\n g3.mesh(shadow, Mat.basic({\r\n color: scaled ? \"white\" : PLOT_COLOR,\r\n vertexColors: scaled,\r\n opacity: s.floorShadow * (s.opacity ?? 1),\r\n transparent: true,\r\n // Translucent and under everything: writing depth would hide the floor's grid lines behind it.\r\n depthWrite: false,\r\n faces: \"both\",\r\n }));\r\n }\r\n return g3;\r\n}\r\n\r\nfunction surfaceGeometry(s: SurfaceValues, space: GraphSpace): Geometry3D | undefined {\r\n const sample = sampler(s, space);\r\n if (!sample) return undefined;\r\n const scale = s.colorScale;\r\n const point: Vector3 = { x: 0, y: 0, z: 0 };\r\n const low = space.offset(0, 0, space.zRange[0] - s.z).y;\r\n const high = space.offset(0, 0, space.zRange[1] - s.z).y;\r\n return Geo.parametric({\r\n segments: Math.max(2, Math.round(s.segments)),\r\n vertex: (u, v) => {\r\n sample(u, v, point);\r\n return space.offset(point.x, point.y, point.z);\r\n },\r\n ...(scale.length > 0\r\n ? { color: (_u, _v, position) => colorAt(scale, high > low ? (position.y - low) / (high - low) : 0) }\r\n : {}),\r\n computeNormals: true,\r\n revision: revisionOf(`${keyOf(s, space)}|${JSON.stringify(scale)}`),\r\n });\r\n}\r\n\r\nfunction heightOf(surface: Pick<SurfaceValues, \"params\">, source: string, x: number, y: number): number {\r\n const equation = equationOf(source);\r\n if (equation?.kind !== \"height\") return NaN;\r\n return equation.f(x, y, scopeFor(surfaceParams(source), surface.params));\r\n}\r\n\r\nfunction keyOf(s: SurfaceValues, space: GraphSpace): string {\r\n const { source, blend } = s.expression;\r\n return [source, blend?.from, blend?.t, space.revision, s.uDomain, s.vDomain, JSON.stringify(s.params), s.x, s.y, s.z].join(\"|\");\r\n}\r\n\r\nfunction sampler(s: SurfaceValues, space: GraphSpace): SurfaceSampler | null {\r\n const { source, blend } = s.expression;\r\n const to = surfaceOf(s, source, space);\r\n if (!to || !blend) return to;\r\n const from = surfaceOf(s, blend.from, space);\r\n if (!from) return to;\r\n const start: Vector3 = { x: 0, y: 0, z: 0 };\r\n return (u, v, out) => {\r\n from(u, v, start);\r\n to(u, v, out);\r\n out.x = start.x + (out.x - start.x) * blend.t;\r\n out.y = start.y + (out.y - start.y) * blend.t;\r\n out.z = start.z + (out.z - start.z) * blend.t;\r\n };\r\n}\r\n\r\n/** `source` as graph points, measured from the surface's own position. */\r\nfunction surfaceOf(s: SurfaceValues, source: string, space: GraphSpace): SurfaceSampler | null {\r\n const equation = equationOf(source);\r\n if (!equation) return null;\r\n const params = scopeFor(surfaceParams(source), s.params);\r\n if (equation.kind === \"parametric\") {\r\n const [u0, u1] = s.uDomain ?? [0, 1];\r\n const [v0, v1] = s.vDomain ?? [0, 1];\r\n const { x, y, z } = equation;\r\n return (u, v, out) => {\r\n const a = u0 + (u1 - u0) * u;\r\n const b = v0 + (v1 - v0) * v;\r\n out.x = finite(x(a, b, params));\r\n out.y = finite(y(a, b, params));\r\n out.z = finite(z(a, b, params));\r\n };\r\n }\r\n const [x0, x1] = s.uDomain ?? [space.xRange[0] - s.x, space.xRange[1] - s.x];\r\n const [y0, y1] = s.vDomain ?? [space.yRange[0] - s.y, space.yRange[1] - s.y];\r\n // Held inside the axes: a pole would otherwise stretch one triangle across the scene.\r\n const low = space.zRange[0] - s.z;\r\n const high = space.zRange[1] - s.z;\r\n const { f } = equation;\r\n return (u, v, out) => {\r\n out.x = x0 + (x1 - x0) * u;\r\n out.y = y0 + (y1 - y0) * v;\r\n out.z = clamp(finite(f(out.x, out.y, params)), low, high);\r\n };\r\n}\r\n\r\nfunction floorShadow(s: SurfaceValues, space: GraphSpace): Geometry3D | undefined {\r\n const sample = sampler(s, space);\r\n if (!sample) return undefined;\r\n const scale = s.colorScale;\r\n const [low, high] = space.zRange;\r\n const floor = low - s.z;\r\n const point: Vector3 = { x: 0, y: 0, z: 0 };\r\n return Geo.parametric({\r\n segments: Math.max(2, Math.round(s.segments)),\r\n vertex: (u, v) => {\r\n sample(u, v, point);\r\n return space.offset(point.x, point.y, floor);\r\n },\r\n ...(scale.length > 0\r\n ? {\r\n color: (u: number, v: number) => {\r\n sample(u, v, point);\r\n return colorAt(scale, high > low ? (point.z + s.z - low) / (high - low) : 0);\r\n },\r\n }\r\n : {}),\r\n revision: revisionOf(`${keyOf(s, space)}|${JSON.stringify(scale)}|floor`),\r\n });\r\n}\r\n\r\n/** The last lines drawn for each surface, kept while what they are drawn from is unchanged. */\r\nconst linesDrawn = new WeakMap<object, { readonly key: string; readonly lines: Vector3[] }>();\r\n\r\nfunction meshLines(s: SurfaceValues, space: GraphSpace): Vector3[] {\r\n const count = Math.round(s.meshLines);\r\n const sample = count > 0 ? sampler(s, space) : null;\r\n if (!sample) return [];\r\n const steps = Math.max(2, Math.round(s.segments));\r\n const key = `${keyOf(s, space)}|${count}|${steps}`;\r\n const kept = linesDrawn.get(s);\r\n if (kept?.key === key) return kept.lines;\r\n const lines: Vector3[] = [];\r\n const point: Vector3 = { x: 0, y: 0, z: 0 };\r\n const at = (u: number, v: number): Vector3 => {\r\n sample(u, v, point);\r\n return space.offset(point.x, point.y, point.z);\r\n };\r\n for (let i = 0; i <= count; i++) {\r\n const fixed = i / count;\r\n for (let j = 0; j < steps; j++) {\r\n lines.push(at(fixed, j / steps), at(fixed, (j + 1) / steps));\r\n lines.push(at(j / steps, fixed), at((j + 1) / steps, fixed));\r\n }\r\n }\r\n linesDrawn.set(s, { key, lines });\r\n return lines;\r\n}\r\n\r\nfunction equationOf(source: string): SurfaceEquation | null {\r\n const equation = parseSurface(source, surfaceParams(source));\r\n return equation instanceof Error ? null : equation;\r\n}\r\n\r\n// A hole in the data is drawn flat rather than as a hole in the mesh.\r\nfunction finite(value: number): number {\r\n return Number.isFinite(value) ? value : 0;\r\n}\r\n\r\nfunction mapMaterials(\r\n material: Material3D | readonly Material3D[],\r\n change: (material: Material3D) => Material3D,\r\n): Material3D | readonly Material3D[] {\r\n return Array.isArray(material) ? (material as readonly Material3D[]).map(change) : change(material as Material3D);\r\n}\r\n"]}
@@ -1,4 +1,4 @@
1
- import { Graphics3D, Mesh3D, type Command, type CommandArgs, type Mesh3DProps, type NodeConfig, type Vector3, type Vector3Input } from "@motionscript/sdk";
1
+ import { type Mesh3DProps, type NodeOf, type Vector3, type Vector3Input, type Blend3D as _Blend3D, type Color as _Color, 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
2
  export interface VectorArrow3dProps extends Mesh3DProps {
3
3
  tail?: Vector3Input;
4
4
  head?: Vector3Input;
@@ -6,20 +6,91 @@ export interface VectorArrow3dProps extends Mesh3DProps {
6
6
  tip?: boolean;
7
7
  }
8
8
  /** An arrow between two points of a 3D graph: a vector from the origin by default. */
9
- export declare class VectorArrow3d extends Mesh3D<VectorArrow3dProps> {
10
- tail: Vector3;
11
- head: Vector3;
9
+ export declare const VectorArrow3d: import("@motionscript/sdk").Component<"vectorArrow3d", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Transform3DState, {
10
+ tail: import("@motionscript/sdk").Type<Vector3Input, Vector3, false>;
11
+ head: import("@motionscript/sdk").Type<Vector3Input, Vector3, false>;
12
12
  /** The radius of the shaft, in scene units; the tip is sized from it. */
13
- thickness: number;
14
- tip: boolean;
15
- constructor(props?: NodeConfig<VectorArrow3d, VectorArrow3dProps>);
16
- /** Animate either end, or both. */
17
- endpointsTo(args: CommandArgs<{
18
- tail?: Vector3Input;
19
- head?: Vector3Input;
20
- }> & {
21
- duration: number;
22
- }): Command<VectorArrow3dProps>;
23
- protected buildGraphics3D(): Graphics3D;
24
- }
13
+ thickness: import("@motionscript/sdk").Type<number, number, false>;
14
+ tip: import("@motionscript/sdk").Type<boolean, boolean, false>;
15
+ graph: import("@motionscript/sdk").Type<import("./space.js").Graph3D | null, import("./space.js").Graph3D | null, true>;
16
+ opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
17
+ blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
18
+ fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
19
+ faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
20
+ wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
21
+ vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
22
+ alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
23
+ aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
24
+ normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
25
+ envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
26
+ geometry: import("@motionscript/sdk").Type<_Geometry3D | undefined, _Geometry3D | undefined, false>;
27
+ material: import("@motionscript/sdk").Type<_Material3D | readonly _Material3D[] | undefined, _Material3D | readonly _Material3D[] | undefined, false>;
28
+ roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
29
+ metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
30
+ emission: import("@motionscript/sdk").Type<_Color | undefined, _NormalizedColor | undefined, false>;
31
+ emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
32
+ roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
33
+ metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
34
+ shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
35
+ unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
36
+ }>, {
37
+ readonly endpointsTo: readonly ["tail", "head"];
38
+ }, null, _Node3D<_Node3DProps>, import("@motionscript/sdk").CallProps3D<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Transform3DState, {
39
+ tail: import("@motionscript/sdk").Type<Vector3Input, Vector3, false>;
40
+ head: import("@motionscript/sdk").Type<Vector3Input, Vector3, false>;
41
+ /** The radius of the shaft, in scene units; the tip is sized from it. */
42
+ thickness: import("@motionscript/sdk").Type<number, number, false>;
43
+ tip: import("@motionscript/sdk").Type<boolean, boolean, false>;
44
+ graph: import("@motionscript/sdk").Type<import("./space.js").Graph3D | null, import("./space.js").Graph3D | null, true>;
45
+ opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
46
+ blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
47
+ fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
48
+ faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
49
+ wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
50
+ vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
51
+ alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
52
+ aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
53
+ normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
54
+ envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
55
+ geometry: import("@motionscript/sdk").Type<_Geometry3D | undefined, _Geometry3D | undefined, false>;
56
+ material: import("@motionscript/sdk").Type<_Material3D | readonly _Material3D[] | undefined, _Material3D | readonly _Material3D[] | undefined, false>;
57
+ roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
58
+ metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
59
+ emission: import("@motionscript/sdk").Type<_Color | undefined, _NormalizedColor | undefined, false>;
60
+ emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
61
+ roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
62
+ metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
63
+ shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
64
+ unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
65
+ }>, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Transform3DState, {
66
+ tail: import("@motionscript/sdk").Type<Vector3Input, Vector3, false>;
67
+ head: import("@motionscript/sdk").Type<Vector3Input, Vector3, false>;
68
+ /** The radius of the shaft, in scene units; the tip is sized from it. */
69
+ thickness: import("@motionscript/sdk").Type<number, number, false>;
70
+ tip: import("@motionscript/sdk").Type<boolean, boolean, false>;
71
+ graph: import("@motionscript/sdk").Type<import("./space.js").Graph3D | null, import("./space.js").Graph3D | null, true>;
72
+ opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
73
+ blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
74
+ fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
75
+ faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
76
+ wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
77
+ vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
78
+ alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
79
+ aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
80
+ normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
81
+ envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
82
+ geometry: import("@motionscript/sdk").Type<_Geometry3D | undefined, _Geometry3D | undefined, false>;
83
+ material: import("@motionscript/sdk").Type<_Material3D | readonly _Material3D[] | undefined, _Material3D | readonly _Material3D[] | undefined, false>;
84
+ roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
85
+ metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
86
+ emission: import("@motionscript/sdk").Type<_Color | undefined, _NormalizedColor | undefined, false>;
87
+ emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
88
+ roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
89
+ metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
90
+ shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
91
+ unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
92
+ }>, {
93
+ readonly endpointsTo: readonly ["tail", "head"];
94
+ }, _Node3D<_Node3DProps>>>>;
95
+ export type VectorArrow3d = NodeOf<typeof VectorArrow3d>;
25
96
  //# sourceMappingURL=vector-arrow3d.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vector-arrow3d.d.ts","sourceRoot":"","sources":["../../src/three/vector-arrow3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,UAAU,EAEV,MAAM,EAIN,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,YAAY,EACpB,MAAM,mBAAmB,CAAC;AAI3B,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACnD,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,sFAAsF;AACtF,qBAOa,aAAc,SAAQ,MAAM,CAAC,kBAAkB,CAAC;IACyD,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IAChI,yEAAyE;IACV,SAAS,EAAE,MAAM,CAAC;IACzB,GAAG,EAAE,OAAO,CAAC;gBAEzD,KAAK,CAAC,EAAE,UAAU,CAAC,aAAa,EAAE,kBAAkB,CAAC;IAIjE,mCAAmC;IAEnC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC;QAAE,IAAI,CAAC,EAAE,YAAY,CAAC;QAAC,IAAI,CAAC,EAAE,YAAY,CAAA;KAAE,CAAC,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC;cAI7G,eAAe,IAAI,UAAU;CA0BnD"}
1
+ {"version":3,"file":"vector-arrow3d.d.ts","sourceRoot":"","sources":["../../src/three/vector-arrow3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAOH,KAAK,WAAW,EAChB,KAAK,MAAM,EAEX,KAAK,OAAO,EACZ,KAAK,YAAY,EAEjB,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,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,kBAAmB,SAAQ,WAAW;IACnD,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,OAAO,CAAC;CACjB;AAgBD,sFAAsF;AACtF,eAAO,MAAM,aAAa;;;IAPtB,yEAAyE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAzE,yEAAyE;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAzE,yEAAyE;;;;;;;;;;;;;;;;;;;;;;;;;;2BAe3E,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC"}
@@ -1,72 +1,53 @@
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;
1
+ import { component3d, Graphics3D, lerpVector3, Material, resolveVector3, Types, } from "@motionscript/sdk";
2
+ import { meshEntries } from "./entries.js";
3
+ import { aim, graphEntry, graphOf } from "./space.js";
4
+ function point(initial) {
5
+ return Types.custom(initial, { resolve: resolveVector3, lerp: lerpVector3, kind: "vector3" });
6
+ }
7
+ const state = {
8
+ ...meshEntries,
9
+ tail: point({ x: 0, y: 0, z: 0 }),
10
+ head: point({ x: 1, y: 1, z: 1 }),
11
+ /** The radius of the shaft, in scene units; the tip is sized from it. */
12
+ thickness: Types.number(0.035, { min: 0.001, step: 0.005 }),
13
+ tip: Types.boolean(true, { animatable: false }),
14
+ graph: graphEntry(),
6
15
  };
7
- import { command, Graphics3D, lerpVector3, Mesh3D, node, property, resolveVector3, } from "@motionscript/sdk";
8
- import { stated } from "../kit/geometry.js";
9
- import { aim, spaceOf } from "./space.js";
10
16
  /** An arrow between two points of a 3D graph: a vector from the origin by default. */
11
- let VectorArrow3d = class VectorArrow3d extends Mesh3D {
12
- constructor(props) {
13
- super(props ?? {});
14
- }
15
- /** Animate either end, or both. */
16
- endpointsTo(args) {
17
- return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });
18
- }
19
- buildGraphics3D() {
20
- const g3 = new Graphics3D();
21
- const space = spaceOf(this);
22
- const { tail, head, thickness } = this;
23
- // Outside a graph an arrow is drawn in the scene's own units.
24
- const from = space ? space.offset(tail.x, tail.y, tail.z) : tail;
25
- const to = space ? space.offset(head.x, head.y, head.z) : head;
26
- const along = { x: to.x - from.x, y: to.y - from.y, z: to.z - from.z };
27
- const length = Math.hypot(along.x, along.y, along.z);
28
- if (!(length > 0))
29
- return g3;
30
- const paint = this.materialShorthand();
31
- const quaternion = aim(along);
32
- const tipLength = this.tip ? Math.min(thickness * 8, length) : 0;
33
- const shaft = length - tipLength;
34
- const at = (distance) => ({
35
- x: from.x + (along.x * distance) / length,
36
- y: from.y + (along.y * distance) / length,
37
- z: from.z + (along.z * distance) / length,
38
- });
39
- if (shaft > 0)
40
- g3.cylinder({ ...paint, radius: thickness, height: shaft, segments: [12, 1], position: at(shaft / 2), quaternion });
41
- if (tipLength > 0) {
42
- g3.cone({ ...paint, radius: thickness * 2.8, height: tipLength, segments: [20, 1], position: at(shaft + tipLength / 2), quaternion });
43
- }
17
+ export const VectorArrow3d = component3d({
18
+ key: "vectorArrow3d",
19
+ state,
20
+ commands: {
21
+ /** Animate either end, or both. */
22
+ endpointsTo: { args: ["tail", "head"] },
23
+ },
24
+ render: (ctx, s) => ctx.draw(drawArrow(s)),
25
+ });
26
+ function drawArrow(s) {
27
+ const g3 = new Graphics3D();
28
+ const space = graphOf(s);
29
+ const { tail, head, thickness } = s;
30
+ // Outside a graph an arrow is drawn in the scene's own units.
31
+ const from = space ? space.offset(tail.x, tail.y, tail.z) : tail;
32
+ const to = space ? space.offset(head.x, head.y, head.z) : head;
33
+ const along = { x: to.x - from.x, y: to.y - from.y, z: to.z - from.z };
34
+ const length = Math.hypot(along.x, along.y, along.z);
35
+ if (!(length > 0))
44
36
  return g3;
37
+ const paint = Material.shorthand(s);
38
+ const quaternion = aim(along);
39
+ const tipLength = s.tip ? Math.min(thickness * 8, length) : 0;
40
+ const shaft = length - tipLength;
41
+ const at = (distance) => ({
42
+ x: from.x + (along.x * distance) / length,
43
+ y: from.y + (along.y * distance) / length,
44
+ z: from.z + (along.z * distance) / length,
45
+ });
46
+ if (shaft > 0)
47
+ g3.cylinder({ ...paint, radius: thickness, height: shaft, segments: [12, 1], position: at(shaft / 2), quaternion });
48
+ if (tipLength > 0) {
49
+ g3.cone({ ...paint, radius: thickness * 2.8, height: tipLength, segments: [20, 1], position: at(shaft + tipLength / 2), quaternion });
45
50
  }
46
- };
47
- __decorate([
48
- property({ default: { x: 0, y: 0, z: 0 }, mapper: resolveVector3, tween: lerpVector3, kind: "vector3" })
49
- ], VectorArrow3d.prototype, "tail", void 0);
50
- __decorate([
51
- property({ default: { x: 1, y: 1, z: 1 }, mapper: resolveVector3, tween: lerpVector3, kind: "vector3" })
52
- ], VectorArrow3d.prototype, "head", void 0);
53
- __decorate([
54
- property({ default: 0.035, min: 0.001, step: 0.005 })
55
- ], VectorArrow3d.prototype, "thickness", void 0);
56
- __decorate([
57
- property({ default: true, animatable: false })
58
- ], VectorArrow3d.prototype, "tip", void 0);
59
- __decorate([
60
- command({ args: ["tail", "head"] })
61
- ], VectorArrow3d.prototype, "endpointsTo", null);
62
- VectorArrow3d = __decorate([
63
- node({
64
- key: "vectorArrow3d",
65
- within: ["axes3d"],
66
- forkable: true,
67
- layout: { acceptsChildren: false },
68
- seed: { head: { x: 2, y: 1, z: 1.5 }, fill: "#f97316" },
69
- })
70
- ], VectorArrow3d);
71
- export { VectorArrow3d };
51
+ return g3;
52
+ }
72
53
  //# sourceMappingURL=vector-arrow3d.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vector-arrow3d.js","sourceRoot":"","sources":["../../src/three/vector-arrow3d.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACH,OAAO,EACP,UAAU,EACV,WAAW,EACX,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,cAAc,GAOjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AASvC,sFAAsF;AAQ/E,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,MAA0B;IAOzD,YAAY,KAAqD;QAC7D,KAAK,CAAC,KAAK,IAAI,E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r\n resolveVector3,\r\n type Command,\r\n type CommandArgs,\r\n type Mesh3DProps,\r\n type NodeConfig,\r\n type Vector3,\r\n type Vector3Input,\r\n} from \"@motionscript/sdk\";\r\nimport { stated } from \"../kit/geometry\";\r\nimport { aim, spaceOf } from \"./space\";\r\n\r\nexport interface VectorArrow3dProps extends Mesh3DProps {\r\n tail?: Vector3Input;\r\n head?: Vector3Input;\r\n thickness?: number;\r\n tip?: boolean;\r\n}\r\n\r\n/** An arrow between two points of a 3D graph: a vector from the origin by default. */\r\n@node({\r\n key: \"vectorArrow3d\",\r\n within: [\"axes3d\"],\r\n forkable: true,\r\n layout: { acceptsChildren: false },\r\n seed: { head: { x: 2, y: 1, z: 1.5 }, fill: \"#f97316\" },\r\n})\r\nexport class VectorArrow3d extends Mesh3D<VectorArrow3dProps> {\r\n @property({ default: { x: 0, y: 0, z: 0 }, mapper: resolveVector3, tween: lerpVector3, kind: \"vector3\" }) declare tail: Vector3;\r\n @property({ default: { x: 1, y: 1, z: 1 }, mapper: resolveVector3, tween: lerpVector3, kind: \"vector3\" }) declare head: Vector3;\r\n /** The radius of the shaft, in scene units; the tip is sized from it. */\r\n @property({ default: 0.035, min: 0.001, step: 0.005 }) declare thickness: number;\r\n @property({ default: true, animatable: false }) declare tip: boolean;\r\n\r\n constructor(props?: NodeConfig<VectorArrow3d, VectorArrow3dProps>) {\r\n super(props ?? {});\r\n }\r\n\r\n /** Animate either end, or both. */\r\n @command({ args: [\"tail\", \"head\"] })\r\n endpointsTo(args: CommandArgs<{ tail?: Vector3Input; head?: Vector3Input }> & { duration: number }): Command<VectorArrow3dProps> {\r\n return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });\r\n }\r\n\r\n protected override buildGraphics3D(): Graphics3D {\r\n const g3 = new Graphics3D();\r\n const space = spaceOf(this);\r\n const { tail, head, thickness } = this;\r\n // Outside a graph an arrow is drawn in the scene's own units.\r\n const from = space ? space.offset(tail.x, tail.y, tail.z) : tail;\r\n const to = space ? space.offset(head.x, head.y, head.z) : head;\r\n const along: Vector3 = { x: to.x - from.x, y: to.y - from.y, z: to.z - from.z };\r\n const length = Math.hypot(along.x, along.y, along.z);\r\n if (!(length > 0)) return g3;\r\n\r\n const paint = this.materialShorthand();\r\n const quaternion = aim(along);\r\n const tipLength = this.tip ? Math.min(thickness * 8, length) : 0;\r\n const shaft = length - tipLength;\r\n const at = (distance: number): Vector3 => ({\r\n x: from.x + (along.x * distance) / length,\r\n y: from.y + (along.y * distance) / length,\r\n z: from.z + (along.z * distance) / length,\r\n });\r\n if (shaft > 0) g3.cylinder({ ...paint, radius: thickness, height: shaft, segments: [12, 1], position: at(shaft / 2), quaternion });\r\n if (tipLength > 0) {\r\n g3.cone({ ...paint, radius: thickness * 2.8, height: tipLength, segments: [20, 1], position: at(shaft + tipLength / 2), quaternion });\r\n }\r\n return g3;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"vector-arrow3d.js","sourceRoot":"","sources":["../../src/three/vector-arrow3d.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,UAAU,EACV,WAAW,EACX,QAAQ,EACR,cAAc,EACd,KAAK,GAkBR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AASnD,SAAS,KAAK,CAAC,OAAgB;IAC3B,OAAO,KAAK,CAAC,MAAM,CAAwB,OAAO,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;AACzH,CAAC;AAED,MAAM,KAAK,GAAG;IACV,GAAG,WAAW;IACd,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IACjC,IAAI,EAAE,KAAK,CAAC,EAAE,CAA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S,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;IACnI,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;QAChB,EAAE,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,SAAS,GAAG,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,KAAK,GAAG,SAAS,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;IAC1I,CAAC;IACD,OAAO,EAAE,CAAC;AACd,CAAC","sourcesContent":["import {\r\n component3d,\r\n Graphics3D,\r\n lerpVector3,\r\n Material,\r\n resolveVector3,\r\n Types,\r\n type Mesh3DProps,\r\n type NodeOf,\r\n type Values,\r\n type Vector3,\r\n type Vector3Input,\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 Geometry3D as _Geometry3D,\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 { meshEntries } from \"./entries\";\r\nimport { aim, graphEntry, graphOf } from \"./space\";\r\n\r\nexport interface VectorArrow3dProps extends Mesh3DProps {\r\n tail?: Vector3Input;\r\n head?: Vector3Input;\r\n thickness?: number;\r\n tip?: boolean;\r\n}\r\n\r\nfunction point(initial: Vector3) {\r\n return Types.custom<Vector3Input, Vector3>(initial, { resolve: resolveVector3, lerp: lerpVector3, kind: \"vector3\" });\r\n}\r\n\r\nconst state = {\r\n ...meshEntries,\r\n tail: point({ x: 0, y: 0, z: 0 }),\r\n head: point({ x: 1, y: 1, z: 1 }),\r\n /** The radius of the shaft, in scene units; the tip is sized from it. */\r\n thickness: Types.number(0.035, { min: 0.001, step: 0.005 }),\r\n tip: Types.boolean(true, { animatable: false }),\r\n graph: graphEntry(),\r\n};\r\n\r\n/** An arrow between two points of a 3D graph: a vector from the origin by default. */\r\nexport const VectorArrow3d = component3d({\r\n key: \"vectorArrow3d\",\r\n state,\r\n commands: {\r\n /** Animate either end, or both. */\r\n endpointsTo: { args: [\"tail\", \"head\"] },\r\n },\r\n render: (ctx, s) => ctx.draw(drawArrow(s)),\r\n});\r\n\r\nexport type VectorArrow3d = NodeOf<typeof VectorArrow3d>;\r\n\r\nfunction drawArrow(s: Values<typeof state>): Graphics3D {\r\n const g3 = new Graphics3D();\r\n const space = graphOf(s);\r\n const { tail, head, thickness } = s;\r\n // Outside a graph an arrow is drawn in the scene's own units.\r\n const from = space ? space.offset(tail.x, tail.y, tail.z) : tail;\r\n const to = space ? space.offset(head.x, head.y, head.z) : head;\r\n const along: Vector3 = { x: to.x - from.x, y: to.y - from.y, z: to.z - from.z };\r\n const length = Math.hypot(along.x, along.y, along.z);\r\n if (!(length > 0)) return g3;\r\n\r\n const paint = Material.shorthand(s);\r\n const quaternion = aim(along);\r\n const tipLength = s.tip ? Math.min(thickness * 8, length) : 0;\r\n const shaft = length - tipLength;\r\n const at = (distance: number): Vector3 => ({\r\n x: from.x + (along.x * distance) / length,\r\n y: from.y + (along.y * distance) / length,\r\n z: from.z + (along.z * distance) / length,\r\n });\r\n if (shaft > 0) g3.cylinder({ ...paint, radius: thickness, height: shaft, segments: [12, 1], position: at(shaft / 2), quaternion });\r\n if (tipLength > 0) {\r\n g3.cone({ ...paint, radius: thickness * 2.8, height: tipLength, segments: [20, 1], position: at(shaft + tipLength / 2), quaternion });\r\n }\r\n return g3;\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@motionscript/math",
3
- "version": "0.1.0-alpha.5",
3
+ "version": "0.1.0-alpha.7",
4
4
  "type": "module",
5
5
  "description": "Math for Motion Script: coordinate systems, function and vector-field plots, 3D graphs and surfaces, network graphs, and LaTeX formulas typeset to glyph paths that morph token by token.",
6
6
  "repository": {
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "license": "Apache-2.0",
55
55
  "peerDependencies": {
56
- "@motionscript/sdk": "^0.1.0-alpha.5"
56
+ "@motionscript/sdk": "^0.1.0-alpha.7"
57
57
  },
58
58
  "dependencies": {
59
59
  "@mathjax/mathjax-newcm-font": "^4.1.1",
@@ -68,8 +68,8 @@
68
68
  "typescript": "^6.0.3",
69
69
  "typescript-eslint": "^8.48.0",
70
70
  "vitest": "^4.1.5",
71
- "@motionscript/sdk": "0.1.0-alpha.5",
72
- "@motionscript/core": "0.1.0-alpha.5"
71
+ "@motionscript/sdk": "0.1.0-alpha.7",
72
+ "@motionscript/core": "0.1.0-alpha.7"
73
73
  },
74
74
  "scripts": {
75
75
  "build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json --resolve-full-paths && node ../../../scripts/build-browser.mjs",