@motionscript/math 0.1.0-alpha.4 → 0.1.0-alpha.6

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 +132 -92
  2. package/README.md +39 -33
  3. package/dist/annotate/angle-mark.d.ts +52 -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 +59 -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 +43 -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 +58 -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 +24 -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 +28 -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 +37 -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 +30 -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 +38 -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 +30 -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 +107 -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 +34 -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 +38 -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 +34 -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 +31 -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 +99 -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 +69 -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 +126 -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 +51 -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 +92 -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 +47 -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 +56 -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 +55 -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 +140 -54
  156. package/dist/three/axes3d.d.ts.map +1 -1
  157. package/dist/three/axes3d.js +159 -204
  158. package/dist/three/axes3d.js.map +1 -1
  159. package/dist/three/curve-plot3d.d.ts +70 -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 +57 -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 +131 -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 +58 -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 +182 -161
  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,6 +1,5 @@
1
- import { Canvas3D, type AssetScope, type Canvas3DProps, type Color, type Command, type CommandArgs, type NodeConfig, type Scene3D } from "@motionscript/sdk";
1
+ import { type Canvas3DProps, type Color, type NodeOf, type Alignment as _Alignment, type CornerRadiusResolved as _CornerRadiusResolved, type CornerStyleResolved as _CornerStyleResolved, type Fill as _Fill, type FillResolved as _FillResolved, type FlowMode as _FlowMode, type FlowResolved as _FlowResolved, type GapSize as _GapSize, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type NormalizedColor as _NormalizedColor, type PostEffect3D as _PostEffect3D, type RectCornerRadius as _RectCornerRadius, type RectCornerStyle as _RectCornerStyle, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved, type Shadows3D as _Shadows3D, type Stroke as _Stroke, type StrokeResolved as _StrokeResolved, type ToneMapping3D as _ToneMapping3D, type Vector2 as _Vector2 } from "@motionscript/sdk";
2
2
  import type { Interval } from "../kit/coords.js";
3
- import { type GraphSpace } from "./space.js";
4
3
  export interface Axes3dProps extends Canvas3DProps {
5
4
  xRange?: Interval;
6
5
  yRange?: Interval;
@@ -32,56 +31,143 @@ export interface Axes3dProps extends Canvas3DProps {
32
31
  * does. Its 3D children sit in its graph coordinates: a surface, a space curve,
33
32
  * a point, an arrow, or any 3D node. `orbitTo` swings the camera round it.
34
33
  */
35
- export declare class Axes3d<P extends Axes3dProps = Axes3dProps> extends Canvas3D<P> {
36
- xRange: Interval;
37
- yRange: Interval;
38
- zRange: Interval;
39
- /** How long each axis is drawn, in scene units. */
40
- xLength: number;
41
- yLength: number;
42
- zLength: number;
43
- /** The spacing of each axis's ticks; zero picks a tidy one for the axis's length. */
44
- xStep: number;
45
- yStep: number;
46
- zStep: number;
47
- color: Color;
48
- /** The radius of an axis line, in scene units. */
49
- thickness: number;
50
- tips: boolean;
51
- ticks: boolean;
52
- tickSize: number;
53
- /** Lines across the plane the x and y axes lie in, at each of their ticks. */
54
- grid: boolean;
55
- /** (`gridColor` is the viewport's own reference grid.) */
56
- gridLineColor: Color;
57
- /** A number at each tick. */
58
- labels: boolean;
59
- /** The height of a label's text, in scene units. */
60
- labelSize: number;
61
- labelColor: Color;
62
- fontFamily: string;
63
- /** A title at the positive end of each axis. */
64
- xLabel: string;
65
- yLabel: string;
66
- zLabel: string;
67
- constructor(props?: NodeConfig<Axes3d<P>, P>);
68
- /** Animate the window of values the axes show; everything drawn in them follows. */
69
- rangeTo(args: CommandArgs<{
70
- xRange?: Interval;
71
- yRange?: Interval;
72
- zRange?: Interval;
73
- }> & {
74
- duration: number;
75
- }): Command<P>;
76
- declareAssets(assets: AssetScope): void;
77
- /** @internal */
78
- _spaceOf(): GraphSpace;
79
- /** @internal */
80
- _graphSpace(): GraphSpace;
81
- protected buildScene3D(): Scene3D;
82
- private _space;
83
- private _spaceKey;
84
- /** The axes, their ticks, numbers and titles, and the grid, in the scene's units. */
85
- private _furniture;
86
- }
34
+ export declare const Axes3d: import("@motionscript/sdk").Component<"axes3d", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
35
+ readonly xRange: import("@motionscript/sdk").Type<Interval, Interval, false>;
36
+ readonly yRange: import("@motionscript/sdk").Type<Interval, Interval, false>;
37
+ readonly zRange: import("@motionscript/sdk").Type<Interval, Interval, false>;
38
+ readonly xLength: import("@motionscript/sdk").Type<number, number, false>;
39
+ readonly yLength: import("@motionscript/sdk").Type<number, number, false>;
40
+ readonly zLength: import("@motionscript/sdk").Type<number, number, false>;
41
+ readonly xStep: import("@motionscript/sdk").Type<number, number, false>;
42
+ readonly yStep: import("@motionscript/sdk").Type<number, number, false>;
43
+ readonly zStep: import("@motionscript/sdk").Type<number, number, false>;
44
+ readonly color: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
45
+ readonly thickness: import("@motionscript/sdk").Type<number, number, false>;
46
+ readonly tips: import("@motionscript/sdk").Type<boolean, boolean, false>;
47
+ readonly ticks: import("@motionscript/sdk").Type<boolean, boolean, false>;
48
+ readonly tickSize: import("@motionscript/sdk").Type<number, number, false>;
49
+ readonly grid: import("@motionscript/sdk").Type<boolean, boolean, false>;
50
+ readonly gridLineColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
51
+ readonly labels: import("@motionscript/sdk").Type<boolean, boolean, false>;
52
+ readonly labelSize: import("@motionscript/sdk").Type<number, number, false>;
53
+ readonly labelColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
54
+ readonly fontFamily: import("@motionscript/sdk").Type<string, string, false>;
55
+ readonly xLabel: import("@motionscript/sdk").Type<string, string, false>;
56
+ readonly yLabel: import("@motionscript/sdk").Type<string, string, false>;
57
+ readonly zLabel: import("@motionscript/sdk").Type<string, string, false>;
58
+ readonly orbit: import("@motionscript/sdk").Type<number, number, false>;
59
+ readonly elevation: import("@motionscript/sdk").Type<number, number, false>;
60
+ readonly zoom: import("@motionscript/sdk").Type<number, number, false>;
61
+ readonly fov: import("@motionscript/sdk").Type<number, number, false>;
62
+ readonly ambientIntensity: import("@motionscript/sdk").Type<number, number, false>;
63
+ readonly ambientColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
64
+ readonly keyIntensity: import("@motionscript/sdk").Type<number, number, false>;
65
+ readonly keyColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
66
+ readonly showGrid: import("@motionscript/sdk").Type<boolean, boolean, false>;
67
+ readonly gridSize: import("@motionscript/sdk").Type<number, number, false>;
68
+ readonly gridDivisions: import("@motionscript/sdk").Type<number, number, false>;
69
+ readonly gridMajorEvery: import("@motionscript/sdk").Type<number, number, false>;
70
+ readonly gridColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
71
+ readonly gridMajorColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
72
+ readonly showAxes: import("@motionscript/sdk").Type<boolean, boolean, false>;
73
+ readonly axisXColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
74
+ readonly axisZColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
75
+ readonly gridFade: import("@motionscript/sdk").Type<number, number, false>;
76
+ readonly gridFadeColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
77
+ readonly maxPixelRatio: import("@motionscript/sdk").Type<number, number, false>;
78
+ readonly antialias: import("@motionscript/sdk").Type<boolean, boolean, false>;
79
+ readonly shadows: import("@motionscript/sdk").Type<_Shadows3D, _Shadows3D, false>;
80
+ readonly tone: import("@motionscript/sdk").Type<_ToneMapping3D | undefined, _ToneMapping3D | undefined, false>;
81
+ readonly exposure: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
82
+ readonly post: import("@motionscript/sdk").Type<_PostEffect3D | readonly _PostEffect3D[] | undefined, _PostEffect3D | readonly _PostEffect3D[] | undefined, false>;
83
+ readonly cornerRadius: import("@motionscript/sdk").Attribute<_RectCornerRadius, _CornerRadiusResolved>;
84
+ readonly cornerStyle: import("@motionscript/sdk").Attribute<_RectCornerStyle, _CornerStyleResolved>;
85
+ readonly flow: import("@motionscript/sdk").Type<_FlowMode, _FlowResolved, false>;
86
+ readonly gap: import("@motionscript/sdk").Type<_GapSize, _GapSize, false>;
87
+ readonly wrap: boolean;
88
+ readonly crossGap: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
89
+ readonly columns: import("@motionscript/sdk").Type<number, number, false>;
90
+ readonly align: import("@motionscript/sdk").Attribute<_Alignment, _Vector2>;
91
+ readonly fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
92
+ readonly stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
93
+ readonly shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
94
+ readonly overlay: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
95
+ readonly start: import("@motionscript/sdk").Type<number, number, false>;
96
+ readonly end: import("@motionscript/sdk").Type<number, number, false>;
97
+ }>, {
98
+ readonly rangeTo: readonly ["xRange", "yRange", "zRange"];
99
+ readonly orbitTo: readonly ["orbit", "elevation", "zoom"];
100
+ readonly fillTo: readonly ["fill"];
101
+ readonly strokeTo: readonly ["stroke"];
102
+ readonly shadowTo: readonly ["shadow"];
103
+ readonly overlayTo: readonly ["overlay"];
104
+ readonly progressTo: readonly ["start", "end"];
105
+ readonly flash: {
106
+ readonly portion: import("@motionscript/sdk").Type<number, number, false>;
107
+ };
108
+ }, readonly ["2d", "3d"], _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
109
+ readonly xRange: import("@motionscript/sdk").Type<Interval, Interval, false>;
110
+ readonly yRange: import("@motionscript/sdk").Type<Interval, Interval, false>;
111
+ readonly zRange: import("@motionscript/sdk").Type<Interval, Interval, false>;
112
+ readonly xLength: import("@motionscript/sdk").Type<number, number, false>;
113
+ readonly yLength: import("@motionscript/sdk").Type<number, number, false>;
114
+ readonly zLength: import("@motionscript/sdk").Type<number, number, false>;
115
+ readonly xStep: import("@motionscript/sdk").Type<number, number, false>;
116
+ readonly yStep: import("@motionscript/sdk").Type<number, number, false>;
117
+ readonly zStep: import("@motionscript/sdk").Type<number, number, false>;
118
+ readonly color: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
119
+ readonly thickness: import("@motionscript/sdk").Type<number, number, false>;
120
+ readonly tips: import("@motionscript/sdk").Type<boolean, boolean, false>;
121
+ readonly ticks: import("@motionscript/sdk").Type<boolean, boolean, false>;
122
+ readonly tickSize: import("@motionscript/sdk").Type<number, number, false>;
123
+ readonly grid: import("@motionscript/sdk").Type<boolean, boolean, false>;
124
+ readonly gridLineColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
125
+ readonly labels: import("@motionscript/sdk").Type<boolean, boolean, false>;
126
+ readonly labelSize: import("@motionscript/sdk").Type<number, number, false>;
127
+ readonly labelColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
128
+ readonly fontFamily: import("@motionscript/sdk").Type<string, string, false>;
129
+ readonly xLabel: import("@motionscript/sdk").Type<string, string, false>;
130
+ readonly yLabel: import("@motionscript/sdk").Type<string, string, false>;
131
+ readonly zLabel: import("@motionscript/sdk").Type<string, string, false>;
132
+ readonly orbit: import("@motionscript/sdk").Type<number, number, false>;
133
+ readonly elevation: import("@motionscript/sdk").Type<number, number, false>;
134
+ readonly zoom: import("@motionscript/sdk").Type<number, number, false>;
135
+ readonly fov: import("@motionscript/sdk").Type<number, number, false>;
136
+ readonly ambientIntensity: import("@motionscript/sdk").Type<number, number, false>;
137
+ readonly ambientColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
138
+ readonly keyIntensity: import("@motionscript/sdk").Type<number, number, false>;
139
+ readonly keyColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
140
+ readonly showGrid: import("@motionscript/sdk").Type<boolean, boolean, false>;
141
+ readonly gridSize: import("@motionscript/sdk").Type<number, number, false>;
142
+ readonly gridDivisions: import("@motionscript/sdk").Type<number, number, false>;
143
+ readonly gridMajorEvery: import("@motionscript/sdk").Type<number, number, false>;
144
+ readonly gridColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
145
+ readonly gridMajorColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
146
+ readonly showAxes: import("@motionscript/sdk").Type<boolean, boolean, false>;
147
+ readonly axisXColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
148
+ readonly axisZColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
149
+ readonly gridFade: import("@motionscript/sdk").Type<number, number, false>;
150
+ readonly gridFadeColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
151
+ readonly maxPixelRatio: import("@motionscript/sdk").Type<number, number, false>;
152
+ readonly antialias: import("@motionscript/sdk").Type<boolean, boolean, false>;
153
+ readonly shadows: import("@motionscript/sdk").Type<_Shadows3D, _Shadows3D, false>;
154
+ readonly tone: import("@motionscript/sdk").Type<_ToneMapping3D | undefined, _ToneMapping3D | undefined, false>;
155
+ readonly exposure: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
156
+ readonly post: import("@motionscript/sdk").Type<_PostEffect3D | readonly _PostEffect3D[] | undefined, _PostEffect3D | readonly _PostEffect3D[] | undefined, false>;
157
+ readonly cornerRadius: import("@motionscript/sdk").Attribute<_RectCornerRadius, _CornerRadiusResolved>;
158
+ readonly cornerStyle: import("@motionscript/sdk").Attribute<_RectCornerStyle, _CornerStyleResolved>;
159
+ readonly flow: import("@motionscript/sdk").Type<_FlowMode, _FlowResolved, false>;
160
+ readonly gap: import("@motionscript/sdk").Type<_GapSize, _GapSize, false>;
161
+ readonly wrap: boolean;
162
+ readonly crossGap: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
163
+ readonly columns: import("@motionscript/sdk").Type<number, number, false>;
164
+ readonly align: import("@motionscript/sdk").Attribute<_Alignment, _Vector2>;
165
+ readonly fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
166
+ readonly stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
167
+ readonly shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
168
+ readonly overlay: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
169
+ readonly start: import("@motionscript/sdk").Type<number, number, false>;
170
+ readonly end: import("@motionscript/sdk").Type<number, number, false>;
171
+ }>, readonly ["2d", "3d"]>>;
172
+ export type Axes3d = NodeOf<typeof Axes3d>;
87
173
  //# sourceMappingURL=axes3d.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"axes3d.d.ts","sourceRoot":"","sources":["../../src/three/axes3d.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EAQR,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,OAAO,EAIf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAK9C,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAEtD,MAAM,WAAW,WAAY,SAAQ,aAAa;IAC9C,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAA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AAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAsDD;;;;;GAKG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAoBjB,CAAC;AAEH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC"}
@@ -1,228 +1,183 @@
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 { Canvas3D, colorProperty, command, Geo, Graphics3D, Mat, node, property, } from "@motionscript/sdk";
1
+ import { component2d, Flow, Geo, Graphics3D, Mat, Paint, provides, Shapes, Types, View3D, } from "@motionscript/sdk";
8
2
  import { AXIS_COLOR, lerpInterval, readInterval } from "../kit/furniture.js";
9
- import { clamp, stated } from "../kit/geometry.js";
3
+ import { clamp } from "../kit/geometry.js";
10
4
  import { formatTick, ticksFor } from "../kit/ticks.js";
11
5
  import { drawLabel3D } from "./label3d.js";
12
- import { graphSpace } from "./space.js";
6
+ import { GRAPH_3D, graphSpace } from "./space.js";
13
7
  /** How many pixels of a 2D axis one scene unit counts as, when an axis picks its own tick spacing. */
14
8
  const UNIT_AS_PIXELS = 64;
15
9
  /** The turn that lays a shape built along the scene's +y along each graph axis. */
16
10
  const ALONG = { x: [90, 0, 0], y: [0, 0, -90], z: [0, 0, 0] };
17
11
  /** The graph axis each axis's tick marks lie along. */
18
12
  const TICK_ALONG = { x: "y", y: "x", z: "y" };
13
+ function range(initial) {
14
+ return Types.custom(initial, { resolve: readInterval, lerp: lerpInterval });
15
+ }
16
+ /** The axes' own entries, beside a 3D canvas's. */
17
+ const own = {
18
+ xRange: range([-3, 3]),
19
+ yRange: range([-3, 3]),
20
+ zRange: range([-2, 2]),
21
+ /** How long each axis is drawn, in scene units. */
22
+ xLength: Types.number(6, { min: 0.01, step: 0.1 }),
23
+ yLength: Types.number(6, { min: 0.01, step: 0.1 }),
24
+ zLength: Types.number(4, { min: 0.01, step: 0.1 }),
25
+ /** The spacing of each axis's ticks; zero picks a tidy one for the axis's length. */
26
+ xStep: Types.number(0, { min: 0 }),
27
+ yStep: Types.number(0, { min: 0 }),
28
+ zStep: Types.number(0, { min: 0 }),
29
+ color: Types.color(AXIS_COLOR),
30
+ /** The radius of an axis line, in scene units. */
31
+ thickness: Types.number(0.02, { min: 0, step: 0.005 }),
32
+ tips: Types.boolean(true, { animatable: false }),
33
+ ticks: Types.boolean(true, { animatable: false }),
34
+ tickSize: Types.number(0.16, { min: 0, step: 0.01 }),
35
+ /** Lines across the plane the x and y axes lie in, at each of their ticks. */
36
+ grid: Types.boolean(false, { animatable: false }),
37
+ /** (`gridColor` is the viewport's own reference grid.) */
38
+ gridLineColor: Types.color("#374151"),
39
+ /** A number at each tick. */
40
+ labels: Types.boolean(false, { animatable: false }),
41
+ /** The height of a label's text, in scene units. */
42
+ labelSize: Types.number(0.26, { min: 0.01, step: 0.01 }),
43
+ labelColor: Types.color(AXIS_COLOR),
44
+ fontFamily: Types.text("", { animatable: false }),
45
+ /** A title at the positive end of each axis. */
46
+ xLabel: Types.text("x", { animatable: false }),
47
+ yLabel: Types.text("y", { animatable: false }),
48
+ zLabel: Types.text("z", { animatable: false }),
49
+ };
19
50
  /**
20
51
  * A 3D graph: three axes through a box of graph coordinates, z up, seen through
21
52
  * a camera of its own, so it stands on a 2D stage as it is, the way `axes2d`
22
53
  * does. Its 3D children sit in its graph coordinates: a surface, a space curve,
23
54
  * a point, an arrow, or any 3D node. `orbitTo` swings the camera round it.
24
55
  */
25
- let Axes3d = class Axes3d extends Canvas3D {
26
- constructor(props) {
27
- super((props ?? {}));
28
- }
29
- /** Animate the window of values the axes show; everything drawn in them follows. */
30
- rangeTo(args) {
31
- return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });
32
- }
33
- declareAssets(assets) {
34
- super.declareAssets(assets);
35
- if (this.fontFamily !== "")
36
- assets.font(this.fontFamily);
37
- }
38
- /** @internal */
39
- _spaceOf() {
40
- return this._graphSpace();
41
- }
42
- /** @internal */
43
- _graphSpace() {
44
- const { xRange, yRange, zRange, xLength, yLength, zLength } = this;
45
- const key = [xRange, yRange, zRange, xLength, yLength, zLength].join("|");
46
- if (key !== this._spaceKey) {
47
- this._space = graphSpace(xRange, yRange, zRange, { x: xLength, y: yLength, z: zLength });
48
- this._spaceKey = key;
49
- }
50
- return this._space;
51
- }
52
- buildScene3D() {
53
- const scene = super.buildScene3D();
54
- scene.draw(this._furniture());
55
- return scene;
56
- }
57
- _space = null;
58
- _spaceKey = "";
59
- /** The axes, their ticks, numbers and titles, and the grid, in the scene's units. */
60
- _furniture() {
61
- const space = this._graphSpace();
62
- const g3 = new Graphics3D();
63
- const ranges = { x: space.xRange, y: space.yRange, z: space.zRange };
64
- const lengths = { x: this.xLength, y: this.yLength, z: this.zLength };
65
- const steps = { x: this.xStep, y: this.yStep, z: this.zStep };
66
- const titles = { x: this.xLabel, y: this.yLabel, z: this.zLabel };
67
- // Where each axis is crossed by the other two: their zero, or the nearest end of a range without one.
68
- const cross = {
69
- x: clamp(0, ranges.x[0], ranges.x[1]),
70
- y: clamp(0, ranges.y[0], ranges.y[1]),
71
- z: clamp(0, ranges.z[0], ranges.z[1]),
72
- };
73
- const at = (axis, value, shift = {}) => {
74
- const point = { ...cross, [axis]: value };
75
- const local = space.toLocal(point.x, point.y, point.z);
76
- const moved = space.offset(0, 0, 0);
77
- for (const key of ["x", "y", "z"]) {
78
- const by = shift[key];
79
- if (by === undefined)
80
- continue;
81
- // A shift is in scene units, along the graph axis it names.
82
- if (key === "x")
83
- moved.z += by;
84
- else if (key === "y")
85
- moved.x += by;
86
- else
87
- moved.y += by;
88
- }
89
- return { x: local.x + moved.x, y: local.y + moved.y, z: local.z + moved.z };
90
- };
91
- const { thickness, tickSize } = this;
92
- const paint = Mat.basic({ color: this.color });
93
- const style = { size: this.labelSize, color: this.labelColor, fontFamily: this.fontFamily };
94
- const tipLength = this.tips ? thickness * 9 : 0;
95
- const marks = [];
96
- const plane = [];
97
- for (const axis of ["x", "y", "z"]) {
98
- const [min, max] = ranges[axis];
99
- const length = lengths[axis];
100
- if (!(max > min) || !(length > 0))
56
+ export const Axes3d = component2d({
57
+ key: "axes3d",
58
+ state: { ...Paint.state, ...Flow.state, ...Shapes.corners, ...View3D.state, ...own },
59
+ defaults: { width: "fill", height: "fill" },
60
+ commands: {
61
+ ...Paint.commands,
62
+ ...View3D.commands,
63
+ /** Animate the window of values the axes show; everything drawn in them follows. */
64
+ rangeTo: { args: ["xRange", "yRange", "zRange"] },
65
+ },
66
+ allowedChildren: ["2d", "3d"],
67
+ load: (loader, s) => {
68
+ View3D.load(loader);
69
+ if (s.fontFamily !== "")
70
+ loader.font(s.fontFamily);
71
+ },
72
+ provide: (s) => [provides(GRAPH_3D, graphOfAxes(s))],
73
+ space: (s) => axesSpace(s),
74
+ measure: (measurer, s, children) => Flow.measure(measurer, s, children, Paint.inset(s)),
75
+ layout: (box, s, children) => Flow.layout(box, s, children, Paint.inset(s)),
76
+ render: (ctx, s) => View3D.draw(ctx, s, (scene) => scene.draw(furniture(s))),
77
+ });
78
+ /** The last space worked out for each axes, kept while its ranges and lengths are unchanged. */
79
+ const spaces = new WeakMap();
80
+ /** The coordinates of a 3D graph: what its children's `x`, `y` and `z` are in. */
81
+ function axesSpace(s) {
82
+ const { xRange, yRange, zRange, xLength, yLength, zLength } = s;
83
+ const key = [xRange, yRange, zRange, xLength, yLength, zLength].join("|");
84
+ let kept = spaces.get(s);
85
+ if (kept?.key !== key)
86
+ spaces.set(s, (kept = { key, space: graphSpace(xRange, yRange, zRange, { x: xLength, y: yLength, z: zLength }) }));
87
+ return kept.space;
88
+ }
89
+ // One per axes, so the context its subtree holds is the same from frame to frame.
90
+ const graphs = new WeakMap();
91
+ function graphOfAxes(s) {
92
+ let graph = graphs.get(s);
93
+ if (!graph)
94
+ graphs.set(s, (graph = { space: () => axesSpace(s) }));
95
+ return graph;
96
+ }
97
+ /** The axes, their ticks, numbers and titles, and the grid, in the scene's units. */
98
+ function furniture(s) {
99
+ const space = axesSpace(s);
100
+ const g3 = new Graphics3D();
101
+ const ranges = { x: space.xRange, y: space.yRange, z: space.zRange };
102
+ const lengths = { x: s.xLength, y: s.yLength, z: s.zLength };
103
+ const steps = { x: s.xStep, y: s.yStep, z: s.zStep };
104
+ const titles = { x: s.xLabel, y: s.yLabel, z: s.zLabel };
105
+ // Where each axis is crossed by the other two: their zero, or the nearest end of a range without one.
106
+ const cross = {
107
+ x: clamp(0, ranges.x[0], ranges.x[1]),
108
+ y: clamp(0, ranges.y[0], ranges.y[1]),
109
+ z: clamp(0, ranges.z[0], ranges.z[1]),
110
+ };
111
+ const at = (axis, value, shift = {}) => {
112
+ const point = { ...cross, [axis]: value };
113
+ const local = space.toLocal(point.x, point.y, point.z);
114
+ const moved = space.offset(0, 0, 0);
115
+ for (const key of ["x", "y", "z"]) {
116
+ const by = shift[key];
117
+ if (by === undefined)
101
118
  continue;
102
- if (thickness > 0) {
103
- const from = at(axis, min);
104
- const to = at(axis, max);
105
- g3.mesh(Geo.cylinder({ radius: thickness, height: length, segments: [12, 1] }), paint, {
106
- position: { x: (from.x + to.x) / 2, y: (from.y + to.y) / 2, z: (from.z + to.z) / 2 },
119
+ // A shift is in scene units, along the graph axis it names.
120
+ if (key === "x")
121
+ moved.z += by;
122
+ else if (key === "y")
123
+ moved.x += by;
124
+ else
125
+ moved.y += by;
126
+ }
127
+ return { x: local.x + moved.x, y: local.y + moved.y, z: local.z + moved.z };
128
+ };
129
+ const { thickness, tickSize } = s;
130
+ const paint = Mat.basic({ color: s.color });
131
+ const style = { size: s.labelSize, color: s.labelColor, fontFamily: s.fontFamily };
132
+ const tipLength = s.tips ? thickness * 9 : 0;
133
+ const marks = [];
134
+ const plane = [];
135
+ for (const axis of ["x", "y", "z"]) {
136
+ const [min, max] = ranges[axis];
137
+ const length = lengths[axis];
138
+ if (!(max > min) || !(length > 0))
139
+ continue;
140
+ if (thickness > 0) {
141
+ const from = at(axis, min);
142
+ const to = at(axis, max);
143
+ g3.mesh(Geo.cylinder({ radius: thickness, height: length, segments: [12, 1] }), paint, {
144
+ position: { x: (from.x + to.x) / 2, y: (from.y + to.y) / 2, z: (from.z + to.z) / 2 },
145
+ rotation: ALONG[axis],
146
+ });
147
+ if (s.tips) {
148
+ g3.mesh(Geo.cone({ radius: thickness * 3.2, height: tipLength, segments: [16, 1] }), paint, {
149
+ position: at(axis, max, { [axis]: tipLength / 2 }),
107
150
  rotation: ALONG[axis],
108
151
  });
109
- if (this.tips) {
110
- g3.mesh(Geo.cone({ radius: thickness * 3.2, height: tipLength, segments: [16, 1] }), paint, {
111
- position: at(axis, max, { [axis]: tipLength / 2 }),
112
- rotation: ALONG[axis],
113
- });
114
- }
115
- }
116
- const ticks = ticksFor(ranges[axis], steps[axis], length * UNIT_AS_PIXELS);
117
- const side = TICK_ALONG[axis];
118
- for (const value of ticks.values) {
119
- // The crossing is marked by the other axes, and the far end by the tip.
120
- if (Math.abs(value - cross[axis]) < 1e-9 || (this.tips && Math.abs(value - max) < 1e-9))
121
- continue;
122
- if (this.ticks && tickSize > 0)
123
- marks.push({ position: at(axis, value), rotation: ALONG[side] });
124
- if (this.labels) {
125
- drawLabel3D(g3, formatTick(value, ticks.step), at(axis, value, { [side]: -(tickSize / 2 + style.size * 0.8) }), style);
126
- }
127
152
  }
128
- drawLabel3D(g3, titles[axis], at(axis, max, { [axis]: tipLength + style.size * 0.9 }), style);
129
- if (this.grid && axis !== "z") {
130
- const other = axis === "x" ? "y" : "x";
131
- for (const value of ticks.values) {
132
- const a = { x: 0, y: 0, z: cross.z, [axis]: value, [other]: ranges[other][0] };
133
- const b = { ...a, [other]: ranges[other][1] };
134
- plane.push(space.toLocal(a.x, a.y, a.z), space.toLocal(b.x, b.y, b.z));
135
- }
153
+ }
154
+ const ticks = ticksFor(ranges[axis], steps[axis], length * UNIT_AS_PIXELS);
155
+ const side = TICK_ALONG[axis];
156
+ for (const value of ticks.values) {
157
+ // The crossing is marked by the other axes, and the far end by the tip.
158
+ if (Math.abs(value - cross[axis]) < 1e-9 || (s.tips && Math.abs(value - max) < 1e-9))
159
+ continue;
160
+ if (s.ticks && tickSize > 0)
161
+ marks.push({ position: at(axis, value), rotation: ALONG[side] });
162
+ if (s.labels) {
163
+ drawLabel3D(g3, formatTick(value, ticks.step), at(axis, value, { [side]: -(tickSize / 2 + style.size * 0.8) }), style);
136
164
  }
137
165
  }
138
- if (marks.length > 0) {
139
- g3.instances(Geo.cylinder({ radius: Math.max(thickness * 0.7, 0.008), height: tickSize, segments: [8, 1] }), paint, marks);
166
+ drawLabel3D(g3, titles[axis], at(axis, max, { [axis]: tipLength + style.size * 0.9 }), style);
167
+ if (s.grid && axis !== "z") {
168
+ const other = axis === "x" ? "y" : "x";
169
+ for (const value of ticks.values) {
170
+ const a = { x: 0, y: 0, z: cross.z, [axis]: value, [other]: ranges[other][0] };
171
+ const b = { ...a, [other]: ranges[other][1] };
172
+ plane.push(space.toLocal(a.x, a.y, a.z), space.toLocal(b.x, b.y, b.z));
173
+ }
140
174
  }
141
- if (plane.length > 0)
142
- g3.line({ points: plane, segments: true, stroke: { fill: this.gridLineColor } });
143
- return g3;
144
175
  }
145
- };
146
- __decorate([
147
- property({ default: [-3, 3], mapper: readInterval, tween: lerpInterval })
148
- ], Axes3d.prototype, "xRange", void 0);
149
- __decorate([
150
- property({ default: [-3, 3], mapper: readInterval, tween: lerpInterval })
151
- ], Axes3d.prototype, "yRange", void 0);
152
- __decorate([
153
- property({ default: [-2, 2], mapper: readInterval, tween: lerpInterval })
154
- ], Axes3d.prototype, "zRange", void 0);
155
- __decorate([
156
- property({ default: 6, min: 0.01, step: 0.1 })
157
- ], Axes3d.prototype, "xLength", void 0);
158
- __decorate([
159
- property({ default: 6, min: 0.01, step: 0.1 })
160
- ], Axes3d.prototype, "yLength", void 0);
161
- __decorate([
162
- property({ default: 4, min: 0.01, step: 0.1 })
163
- ], Axes3d.prototype, "zLength", void 0);
164
- __decorate([
165
- property({ default: 0, min: 0 })
166
- ], Axes3d.prototype, "xStep", void 0);
167
- __decorate([
168
- property({ default: 0, min: 0 })
169
- ], Axes3d.prototype, "yStep", void 0);
170
- __decorate([
171
- property({ default: 0, min: 0 })
172
- ], Axes3d.prototype, "zStep", void 0);
173
- __decorate([
174
- colorProperty({ default: AXIS_COLOR })
175
- ], Axes3d.prototype, "color", void 0);
176
- __decorate([
177
- property({ default: 0.02, min: 0, step: 0.005 })
178
- ], Axes3d.prototype, "thickness", void 0);
179
- __decorate([
180
- property({ default: true, animatable: false })
181
- ], Axes3d.prototype, "tips", void 0);
182
- __decorate([
183
- property({ default: true, animatable: false })
184
- ], Axes3d.prototype, "ticks", void 0);
185
- __decorate([
186
- property({ default: 0.16, min: 0, step: 0.01 })
187
- ], Axes3d.prototype, "tickSize", void 0);
188
- __decorate([
189
- property({ default: false, animatable: false })
190
- ], Axes3d.prototype, "grid", void 0);
191
- __decorate([
192
- colorProperty({ default: "#374151" })
193
- ], Axes3d.prototype, "gridLineColor", void 0);
194
- __decorate([
195
- property({ default: false, animatable: false })
196
- ], Axes3d.prototype, "labels", void 0);
197
- __decorate([
198
- property({ default: 0.26, min: 0.01, step: 0.01 })
199
- ], Axes3d.prototype, "labelSize", void 0);
200
- __decorate([
201
- colorProperty({ default: AXIS_COLOR })
202
- ], Axes3d.prototype, "labelColor", void 0);
203
- __decorate([
204
- property({ default: "", animatable: false })
205
- ], Axes3d.prototype, "fontFamily", void 0);
206
- __decorate([
207
- property({ default: "x", animatable: false })
208
- ], Axes3d.prototype, "xLabel", void 0);
209
- __decorate([
210
- property({ default: "y", animatable: false })
211
- ], Axes3d.prototype, "yLabel", void 0);
212
- __decorate([
213
- property({ default: "z", animatable: false })
214
- ], Axes3d.prototype, "zLabel", void 0);
215
- __decorate([
216
- command({ args: ["xRange", "yRange", "zRange"] })
217
- ], Axes3d.prototype, "rangeTo", null);
218
- Axes3d = __decorate([
219
- node({
220
- key: "axes3d",
221
- parentKey: "canvas3d",
222
- forkable: true,
223
- layout: { defaultWidthMode: "fixed", defaultHeightMode: "fixed", acceptsChildren: true },
224
- seed: { width: 800, height: 500 },
225
- })
226
- ], Axes3d);
227
- export { Axes3d };
176
+ if (marks.length > 0) {
177
+ g3.instances(Geo.cylinder({ radius: Math.max(thickness * 0.7, 0.008), height: tickSize, segments: [8, 1] }), paint, marks);
178
+ }
179
+ if (plane.length > 0)
180
+ g3.line({ points: plane, segments: true, stroke: { fill: s.gridLineColor } });
181
+ return g3;
182
+ }
228
183
  //# sourceMappingURL=axes3d.js.map