@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.
- package/CHANGELOG.md +28 -0
- package/README.md +39 -33
- package/dist/annotate/angle-mark.d.ts +77 -27
- package/dist/annotate/angle-mark.d.ts.map +1 -1
- package/dist/annotate/angle-mark.js +80 -115
- package/dist/annotate/angle-mark.js.map +1 -1
- package/dist/annotate/curly-brace.d.ts +94 -25
- package/dist/annotate/curly-brace.d.ts.map +1 -1
- package/dist/annotate/curly-brace.js +85 -100
- package/dist/annotate/curly-brace.js.map +1 -1
- package/dist/annotate/emphasis-mark.d.ts +69 -9
- package/dist/annotate/emphasis-mark.d.ts.map +1 -1
- package/dist/annotate/emphasis-mark.js +33 -34
- package/dist/annotate/emphasis-mark.js.map +1 -1
- package/dist/browser/chunks/chunk-ABYBW64J.js +2 -0
- package/dist/browser/chunks/chunk-ABYBW64J.js.map +7 -0
- package/dist/browser/chunks/chunk-K77KLQX4.js +2 -0
- package/dist/browser/chunks/chunk-K77KLQX4.js.map +7 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/browser/kit.js +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/browser/tex.js +1 -1
- package/dist/browser/tex.js.map +2 -2
- package/dist/engine.d.ts +26 -19
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +17 -14
- package/dist/engine.js.map +1 -1
- package/dist/kit/component.d.ts +51 -0
- package/dist/kit/component.d.ts.map +1 -0
- package/dist/kit/component.js +30 -0
- package/dist/kit/component.js.map +1 -0
- package/dist/kit/curve.d.ts +22 -11
- package/dist/kit/curve.d.ts.map +1 -1
- package/dist/kit/curve.js +25 -18
- package/dist/kit/curve.js.map +1 -1
- package/dist/kit/field-mark.d.ts +56 -35
- package/dist/kit/field-mark.d.ts.map +1 -1
- package/dist/kit/field-mark.js +100 -120
- package/dist/kit/field-mark.js.map +1 -1
- package/dist/kit/follow.d.ts +67 -29
- package/dist/kit/follow.d.ts.map +1 -1
- package/dist/kit/follow.js +114 -110
- package/dist/kit/follow.js.map +1 -1
- package/dist/kit/furniture.d.ts +3 -1
- package/dist/kit/furniture.d.ts.map +1 -1
- package/dist/kit/furniture.js +5 -0
- package/dist/kit/furniture.js.map +1 -1
- package/dist/kit/graph.d.ts +46 -0
- package/dist/kit/graph.d.ts.map +1 -0
- package/dist/kit/graph.js +90 -0
- package/dist/kit/graph.js.map +1 -0
- package/dist/kit/mark.d.ts +64 -39
- package/dist/kit/mark.d.ts.map +1 -1
- package/dist/kit/mark.js +80 -96
- package/dist/kit/mark.js.map +1 -1
- package/dist/kit/place.d.ts +10 -8
- package/dist/kit/place.d.ts.map +1 -1
- package/dist/kit/place.js +28 -30
- package/dist/kit/place.js.map +1 -1
- package/dist/kit/system.d.ts +27 -29
- package/dist/kit/system.d.ts.map +1 -1
- package/dist/kit/system.js +62 -58
- package/dist/kit/system.js.map +1 -1
- package/dist/kit/withdrawn.d.ts +3 -3
- package/dist/kit/withdrawn.js +3 -3
- package/dist/kit/withdrawn.js.map +1 -1
- package/dist/marks/curve-area.d.ts +37 -18
- package/dist/marks/curve-area.d.ts.map +1 -1
- package/dist/marks/curve-area.js +50 -73
- package/dist/marks/curve-area.js.map +1 -1
- package/dist/marks/drop-lines.d.ts +45 -10
- package/dist/marks/drop-lines.d.ts.map +1 -1
- package/dist/marks/drop-lines.js +37 -52
- package/dist/marks/drop-lines.js.map +1 -1
- package/dist/marks/plot-point.d.ts +56 -20
- package/dist/marks/plot-point.d.ts.map +1 -1
- package/dist/marks/plot-point.js +65 -91
- package/dist/marks/plot-point.js.map +1 -1
- package/dist/marks/riemann-sum.d.ts +47 -26
- package/dist/marks/riemann-sum.d.ts.map +1 -1
- package/dist/marks/riemann-sum.js +57 -85
- package/dist/marks/riemann-sum.js.map +1 -1
- package/dist/marks/tangent-line.d.ts +58 -14
- package/dist/marks/tangent-line.d.ts.map +1 -1
- package/dist/marks/tangent-line.js +73 -87
- package/dist/marks/tangent-line.js.map +1 -1
- package/dist/marks/vector-arrow.d.ts +48 -20
- package/dist/marks/vector-arrow.d.ts.map +1 -1
- package/dist/marks/vector-arrow.js +58 -78
- package/dist/marks/vector-arrow.js.map +1 -1
- package/dist/nodes.d.ts +13 -5
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +0 -6
- package/dist/nodes.js.map +1 -1
- package/dist/plots/function-plot.d.ts +135 -43
- package/dist/plots/function-plot.d.ts.map +1 -1
- package/dist/plots/function-plot.js +146 -177
- package/dist/plots/function-plot.js.map +1 -1
- package/dist/plots/points-plot.d.ts +55 -19
- package/dist/plots/points-plot.d.ts.map +1 -1
- package/dist/plots/points-plot.js +31 -58
- package/dist/plots/points-plot.js.map +1 -1
- package/dist/plots/stream-lines.d.ts +60 -19
- package/dist/plots/stream-lines.d.ts.map +1 -1
- package/dist/plots/stream-lines.js +60 -79
- package/dist/plots/stream-lines.js.map +1 -1
- package/dist/plots/traced-path.d.ts +54 -15
- package/dist/plots/traced-path.d.ts.map +1 -1
- package/dist/plots/traced-path.js +33 -48
- package/dist/plots/traced-path.js.map +1 -1
- package/dist/plots/vector-field.d.ts +48 -11
- package/dist/plots/vector-field.d.ts.map +1 -1
- package/dist/plots/vector-field.js +50 -64
- package/dist/plots/vector-field.js.map +1 -1
- package/dist/structures/network-graph.d.ts +140 -49
- package/dist/structures/network-graph.d.ts.map +1 -1
- package/dist/structures/network-graph.js +168 -217
- package/dist/structures/network-graph.js.map +1 -1
- package/dist/structures/sample-space.d.ts +90 -38
- package/dist/structures/sample-space.d.ts.map +1 -1
- package/dist/structures/sample-space.js +132 -170
- package/dist/structures/sample-space.js.map +1 -1
- package/dist/systems/axes2d.d.ts +159 -37
- package/dist/systems/axes2d.d.ts.map +1 -1
- package/dist/systems/axes2d.js +147 -183
- package/dist/systems/axes2d.js.map +1 -1
- package/dist/systems/number-line.d.ts +80 -28
- package/dist/systems/number-line.d.ts.map +1 -1
- package/dist/systems/number-line.js +82 -118
- package/dist/systems/number-line.js.map +1 -1
- package/dist/systems/number-plane.d.ts +140 -31
- package/dist/systems/number-plane.d.ts.map +1 -1
- package/dist/systems/number-plane.js +142 -149
- package/dist/systems/number-plane.js.map +1 -1
- package/dist/systems/polar-plane.d.ts +76 -26
- package/dist/systems/polar-plane.d.ts.map +1 -1
- package/dist/systems/polar-plane.js +107 -133
- package/dist/systems/polar-plane.js.map +1 -1
- package/dist/tex/index.d.ts.map +1 -1
- package/dist/tex/index.js +1 -0
- package/dist/tex/index.js.map +1 -1
- package/dist/tex/matrix.d.ts +88 -18
- package/dist/tex/matrix.d.ts.map +1 -1
- package/dist/tex/matrix.js +33 -50
- package/dist/tex/matrix.js.map +1 -1
- package/dist/tex/node.d.ts +84 -201
- package/dist/tex/node.d.ts.map +1 -1
- package/dist/tex/node.js +23 -593
- package/dist/tex/node.js.map +1 -1
- package/dist/tex/typeset.d.ts +133 -0
- package/dist/tex/typeset.d.ts.map +1 -0
- package/dist/tex/typeset.js +403 -0
- package/dist/tex/typeset.js.map +1 -0
- package/dist/three/axes3d.d.ts +214 -54
- package/dist/three/axes3d.d.ts.map +1 -1
- package/dist/three/axes3d.js +163 -204
- package/dist/three/axes3d.js.map +1 -1
- package/dist/three/curve-plot3d.d.ts +108 -42
- package/dist/three/curve-plot3d.d.ts.map +1 -1
- package/dist/three/curve-plot3d.js +97 -132
- package/dist/three/curve-plot3d.js.map +1 -1
- package/dist/three/entries.d.ts +17 -0
- package/dist/three/entries.d.ts.map +1 -0
- package/dist/three/entries.js +15 -0
- package/dist/three/entries.js.map +1 -0
- package/dist/three/plot-point3d.d.ts +85 -12
- package/dist/three/plot-point3d.d.ts.map +1 -1
- package/dist/three/plot-point3d.js +27 -53
- package/dist/three/plot-point3d.js.map +1 -1
- package/dist/three/space.d.ts +17 -2
- package/dist/three/space.d.ts.map +1 -1
- package/dist/three/space.js +19 -8
- package/dist/three/space.js.map +1 -1
- package/dist/three/surface-plot3d.d.ts +176 -49
- package/dist/three/surface-plot3d.d.ts.map +1 -1
- package/dist/three/surface-plot3d.js +227 -261
- package/dist/three/surface-plot3d.js.map +1 -1
- package/dist/three/vector-arrow3d.d.ts +87 -16
- package/dist/three/vector-arrow3d.d.ts.map +1 -1
- package/dist/three/vector-arrow3d.js +48 -67
- package/dist/three/vector-arrow3d.js.map +1 -1
- package/package.json +4 -4
- package/src/annotate/angle-mark.ts +95 -105
- package/src/annotate/curly-brace.ts +107 -85
- package/src/annotate/emphasis-mark.ts +55 -26
- package/src/engine.ts +35 -21
- package/src/kit/component.ts +57 -0
- package/src/kit/curve.ts +38 -20
- package/src/kit/field-mark.ts +124 -108
- package/src/kit/follow.ts +146 -120
- package/src/kit/furniture.ts +6 -1
- package/src/kit/graph.ts +116 -0
- package/src/kit/mark.ts +135 -114
- package/src/kit/place.ts +32 -56
- package/src/kit/system.ts +77 -71
- package/src/kit/withdrawn.ts +3 -3
- package/src/marks/curve-area.ts +65 -65
- package/src/marks/drop-lines.ts +50 -42
- package/src/marks/plot-point.ts +77 -82
- package/src/marks/riemann-sum.ts +73 -72
- package/src/marks/tangent-line.ts +87 -71
- package/src/marks/vector-arrow.ts +73 -73
- package/src/nodes.ts +41 -5
- package/src/plots/function-plot.ts +155 -171
- package/src/plots/points-plot.ts +46 -50
- package/src/plots/stream-lines.ts +75 -66
- package/src/plots/traced-path.ts +51 -33
- package/src/plots/vector-field.ts +68 -49
- package/src/structures/network-graph.ts +168 -185
- package/src/structures/sample-space.ts +149 -148
- package/src/systems/axes2d.ts +165 -156
- package/src/systems/number-line.ts +91 -92
- package/src/systems/number-plane.ts +149 -120
- package/src/systems/polar-plane.ts +117 -116
- package/src/tex/index.ts +2 -1
- package/src/tex/matrix.ts +62 -40
- package/src/tex/node.ts +54 -621
- package/src/tex/typeset.ts +461 -0
- package/src/three/axes3d.ts +187 -160
- package/src/three/curve-plot3d.ts +107 -110
- package/src/three/entries.ts +42 -0
- package/src/three/plot-point3d.ts +42 -45
- package/src/three/space.ts +34 -9
- package/src/three/surface-plot3d.ts +312 -323
- package/src/three/vector-arrow3d.ts +65 -54
- package/dist/browser/chunks/chunk-3GJB6AVO.js +0 -2
- package/dist/browser/chunks/chunk-3GJB6AVO.js.map +0 -7
- package/dist/browser/chunks/chunk-D5WHCVBC.js +0 -2
- package/dist/browser/chunks/chunk-D5WHCVBC.js.map +0 -7
- package/dist/browser/chunks/chunk-WL4KEX7Y.js +0 -2
- package/dist/browser/chunks/chunk-WL4KEX7Y.js.map +0 -7
- package/src/kit/placement.ts +0 -8
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Material,
|
|
3
|
+
Types,
|
|
4
|
+
type EntryOptions,
|
|
5
|
+
type Geometry3D,
|
|
6
|
+
type Type,
|
|
7
|
+
// Named so the emitted declaration reaches these through the sdk, not core.
|
|
8
|
+
type Blend3D as _Blend3D,
|
|
9
|
+
type Color as _Color,
|
|
10
|
+
type Faces3D as _Faces3D,
|
|
11
|
+
type Fill3D as _Fill3D,
|
|
12
|
+
type Material3D as _Material3D,
|
|
13
|
+
type NormalizedColor as _NormalizedColor,
|
|
14
|
+
type Shading3D as _Shading3D,
|
|
15
|
+
type Texture3D as _Texture3D,
|
|
16
|
+
} from "@motionscript/sdk";
|
|
17
|
+
import type { Interval } from "../kit/coords";
|
|
18
|
+
import { lerpDomain } from "../kit/source";
|
|
19
|
+
|
|
20
|
+
type MeshState = { readonly geometry: Type<Geometry3D | undefined> } & typeof Material.state;
|
|
21
|
+
// Restated key by key, so a mark spreading these names each entry's type through the sdk: spread
|
|
22
|
+
// as inferred, a mark's declaration copied `emission`'s colour types from core's own.
|
|
23
|
+
type Restated<T> = { [K in Extract<keyof T, string>]: T[K] };
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A mesh's entries, as a 3D mark draws with them: its surface, and the
|
|
27
|
+
* `geometry` a mesh takes, which a mark builds itself and never reads.
|
|
28
|
+
*/
|
|
29
|
+
export const meshEntries: Restated<MeshState> = {
|
|
30
|
+
geometry: Types.custom<Geometry3D | undefined>(undefined),
|
|
31
|
+
...Material.state,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
interface RangeHints extends EntryOptions {
|
|
35
|
+
readonly defaultMin: number;
|
|
36
|
+
readonly defaultMax: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** A span of a variable, unset until given: what a host offers as a range from `defaultMin` to `defaultMax`. */
|
|
40
|
+
export function domainEntry(defaultMin: number, defaultMax: number): Type<Interval | null> {
|
|
41
|
+
return Types.custom<Interval | null, Interval | null, RangeHints>(null, { lerp: lerpDomain, kind: "range", defaultMin, defaultMax });
|
|
42
|
+
}
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
component3d,
|
|
3
3
|
Geo,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
node,
|
|
7
|
-
property,
|
|
8
|
-
type AssetScope,
|
|
4
|
+
Material,
|
|
5
|
+
Types,
|
|
9
6
|
type Color,
|
|
10
|
-
type Geometry3D,
|
|
11
7
|
type Mesh3DProps,
|
|
12
|
-
type
|
|
8
|
+
type NodeOf,
|
|
9
|
+
// Named so the emitted declaration reaches these through the sdk, not core.
|
|
10
|
+
type Blend3D as _Blend3D,
|
|
11
|
+
type Color as _Color,
|
|
12
|
+
type Faces3D as _Faces3D,
|
|
13
|
+
type Fill3D as _Fill3D,
|
|
14
|
+
type Geometry3D as _Geometry3D,
|
|
15
|
+
type Material3D as _Material3D,
|
|
16
|
+
type Node3D as _Node3D,
|
|
17
|
+
type Node3DProps as _Node3DProps,
|
|
18
|
+
type NormalizedColor as _NormalizedColor,
|
|
19
|
+
type Shading3D as _Shading3D,
|
|
20
|
+
type Texture3D as _Texture3D,
|
|
13
21
|
} from "@motionscript/sdk";
|
|
22
|
+
import { meshEntries } from "./entries";
|
|
14
23
|
import { drawLabel3D } from "./label3d";
|
|
15
24
|
|
|
16
25
|
export interface PlotPoint3dProps extends Mesh3DProps {
|
|
@@ -25,42 +34,30 @@ export interface PlotPoint3dProps extends Mesh3DProps {
|
|
|
25
34
|
* A dot at graph coordinates in a 3D graph, with an optional label. Put inside
|
|
26
35
|
* a surface it rides it: its `x` and `y` say where, and its height is the surface's.
|
|
27
36
|
*/
|
|
28
|
-
|
|
37
|
+
export const PlotPoint3d = component3d({
|
|
29
38
|
key: "plotPoint3d",
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
super.declareAssets(assets);
|
|
50
|
-
if (this.fontFamily !== "") assets.font(this.fontFamily);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
protected override buildGeometry(): Geometry3D | undefined {
|
|
54
|
-
return this.radius > 0 ? Geo.sphere({ radius: this.radius, segments: [24, 16] }) : undefined;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
protected override buildGraphics3D(): Graphics3D {
|
|
58
|
-
const g3 = super.buildGraphics3D();
|
|
59
|
-
drawLabel3D(g3, this.label, { x: 0, y: this.radius + this.labelSize * 0.85, z: 0 }, {
|
|
60
|
-
size: this.labelSize,
|
|
61
|
-
color: this.labelColor,
|
|
62
|
-
fontFamily: this.fontFamily,
|
|
39
|
+
state: {
|
|
40
|
+
...meshEntries,
|
|
41
|
+
/** In scene units, so a point is the same size whatever the axes show. */
|
|
42
|
+
radius: Types.number(0.1, { min: 0, step: 0.01 }),
|
|
43
|
+
label: Types.text("", { animatable: false }),
|
|
44
|
+
/** The height of the label's text, in scene units. */
|
|
45
|
+
labelSize: Types.number(0.26, { min: 0.01, step: 0.01 }),
|
|
46
|
+
labelColor: Types.color("#e5e7eb"),
|
|
47
|
+
fontFamily: Types.text("", { animatable: false }),
|
|
48
|
+
},
|
|
49
|
+
load: (loader, s) => {
|
|
50
|
+
if (s.fontFamily !== "") loader.font(s.fontFamily);
|
|
51
|
+
},
|
|
52
|
+
render: (ctx, s) => {
|
|
53
|
+
const g3 = Material.mesh(s, s.radius > 0 ? Geo.sphere({ radius: s.radius, segments: [24, 16] }) : undefined);
|
|
54
|
+
drawLabel3D(g3, s.label, { x: 0, y: s.radius + s.labelSize * 0.85, z: 0 }, {
|
|
55
|
+
size: s.labelSize,
|
|
56
|
+
color: s.labelColor,
|
|
57
|
+
fontFamily: s.fontFamily,
|
|
63
58
|
});
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
}
|
|
59
|
+
ctx.draw(g3);
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export type PlotPoint3d = NodeOf<typeof PlotPoint3d>;
|
package/src/three/space.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
Types,
|
|
4
|
+
type ChildSpace3D,
|
|
5
|
+
type Node3D,
|
|
6
|
+
type Type,
|
|
7
|
+
type Vector3,
|
|
8
|
+
// Named so the emitted declaration reaches these through the sdk, not core.
|
|
9
|
+
type Context as _Context,
|
|
10
|
+
} from "@motionscript/sdk";
|
|
2
11
|
import type { Interval } from "../kit/coords";
|
|
3
12
|
|
|
4
13
|
/**
|
|
@@ -39,17 +48,33 @@ function unit([min, max]: Interval, length: number): number {
|
|
|
39
48
|
return span > 0 ? length / span : 0;
|
|
40
49
|
}
|
|
41
50
|
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
/** A 3D graph, as the marks inside it see it: its coordinates as they stand now. */
|
|
52
|
+
export interface Graph3D {
|
|
53
|
+
space(): GraphSpace;
|
|
44
54
|
}
|
|
45
55
|
|
|
46
|
-
/** The graph a
|
|
56
|
+
/** The graph a mark is inside: `axes3d` provides itself to everything in it. */
|
|
57
|
+
export const GRAPH_3D = createContext<Graph3D | null>(null, "math:graph3d");
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The entry a mark reads the graph it is drawn in through, set from the nearest
|
|
61
|
+
* `axes3d` above it, through any 3D node between; `null` outside one.
|
|
62
|
+
*/
|
|
63
|
+
export function graphEntry(): Type<Graph3D | null, Graph3D | null, true> {
|
|
64
|
+
return Types.custom<Graph3D | null, Graph3D | null, { readonly private: true }>(null, {
|
|
65
|
+
private: true,
|
|
66
|
+
inherit: (use) => use(GRAPH_3D),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The graph space a mark with a {@link graphEntry} is drawn in, or `null` outside a graph. */
|
|
71
|
+
export function graphOf(mark: { readonly graph: Graph3D | null }): GraphSpace | null {
|
|
72
|
+
return mark.graph?.space() ?? null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The graph a 3D node is drawn in: what the nearest `axes3d` above it provides, once it is in the tree. */
|
|
47
76
|
export function spaceOf(mark: Node3D): GraphSpace | null {
|
|
48
|
-
|
|
49
|
-
const spaced = at as Partial<Spaced>;
|
|
50
|
-
if (typeof spaced._graphSpace === "function") return spaced._graphSpace();
|
|
51
|
-
}
|
|
52
|
-
return null;
|
|
77
|
+
return mark.useContext(GRAPH_3D)?.space() ?? null;
|
|
53
78
|
}
|
|
54
79
|
|
|
55
80
|
/** A unit quaternion turning the scene's +y, the way a cylinder or a cone points, onto `direction`. */
|