@motionscript/math 0.1.0-alpha.7 → 0.1.0-alpha.8
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 +2 -0
- package/NOTICE +15 -14
- package/dist/annotate/angle-mark.d.ts +6 -6
- package/dist/annotate/curly-brace.d.ts +9 -9
- package/dist/annotate/emphasis-mark.d.ts +9 -9
- package/dist/browser/chunks/{chunk-ABYBW64J.js → chunk-FETQZEN2.js} +2 -2
- package/dist/browser/chunks/{chunk-ABYBW64J.js.map → chunk-FETQZEN2.js.map} +2 -2
- 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/kit/follow.d.ts +2 -2
- package/dist/kit/sampler.js +1 -1
- package/dist/kit/sampler.js.map +1 -1
- package/dist/marks/drop-lines.d.ts +6 -6
- package/dist/marks/plot-point.d.ts +3 -3
- package/dist/marks/riemann-sum.d.ts +3 -3
- package/dist/marks/tangent-line.d.ts +6 -6
- package/dist/marks/vector-arrow.d.ts +6 -6
- package/dist/plots/function-plot.d.ts +8 -8
- package/dist/tex/matrix.d.ts +2 -2
- package/dist/tex/node.d.ts +2 -2
- package/dist/tex/typeset.d.ts +4 -4
- package/dist/tex/typeset.d.ts.map +1 -1
- package/dist/three/curve-plot3d.d.ts +27 -27
- package/dist/three/curve-plot3d.d.ts.map +1 -1
- package/dist/three/curve-plot3d.js +3 -2
- package/dist/three/curve-plot3d.js.map +1 -1
- package/dist/three/label3d.d.ts.map +1 -1
- package/dist/three/label3d.js +3 -1
- package/dist/three/label3d.js.map +1 -1
- package/dist/three/plot-point3d.d.ts +27 -27
- package/dist/three/surface-plot3d.d.ts +36 -36
- package/dist/three/surface-plot3d.js +6 -1
- package/dist/three/surface-plot3d.js.map +1 -1
- package/dist/three/vector-arrow3d.d.ts +27 -27
- package/package.json +5 -4
- package/src/kit/sampler.ts +1 -1
- package/src/three/curve-plot3d.ts +3 -1
- package/src/three/label3d.ts +3 -1
- package/src/three/surface-plot3d.ts +7 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { component3d, Geo, Material, Types, } from "@motionscript/sdk";
|
|
1
|
+
import { component3d, Geo, Graphics3D, Material, Types, } from "@motionscript/sdk";
|
|
2
2
|
import { parseSpaceCurve, spaceCurveParams } from "../kit/equation3d.js";
|
|
3
3
|
import { PLOT_COLOR } from "../kit/furniture.js";
|
|
4
4
|
import { clamp } from "../kit/geometry.js";
|
|
@@ -39,7 +39,8 @@ export const CurvePlot3d = component3d({
|
|
|
39
39
|
/** Draw the curve on, or wipe it off: animates `start` and `end`. */
|
|
40
40
|
progressTo: { args: ["start", "end"] },
|
|
41
41
|
},
|
|
42
|
-
|
|
42
|
+
// Declaring, its paint on a stand-in: only a material loads, and the curve's points are not sampled.
|
|
43
|
+
render: (ctx, s) => ctx.draw(ctx.declaring ? new Graphics3D().plane(Material.shorthand(s)) : Material.mesh(s, curveGeometry(s))),
|
|
43
44
|
});
|
|
44
45
|
function curveGeometry(s) {
|
|
45
46
|
const space = graphOf(s);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"curve-plot3d.js","sourceRoot":"","sources":["../../src/three/curve-plot3d.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,GAAG,EACH,QAAQ,EACR,KAAK,GAiBR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAA2B,MAAM,mBAAmB,CAAC;AAE/F,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAmB,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE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r\n type Values,\r\n type Vector3,\r\n // Named so the emitted declaration reaches these through the sdk, not core.\r\n type Blend3D as _Blend3D,\r\n type Color as _Color,\r\n type Faces3D as _Faces3D,\r\n type Fill3D as _Fill3D,\r\n type Material3D as _Material3D,\r\n type Node3D as _Node3D,\r\n type Node3DProps as _Node3DProps,\r\n type NormalizedColor as _NormalizedColor,\r\n type Shading3D as _Shading3D,\r\n type Texture3D as _Texture3D,\r\n} from \"@motionscript/sdk\";\r\nimport type { Interval } from \"../kit/coords\";\r\nimport { parseSpaceCurve, spaceCurveParams, type SpaceCurveEquation } from \"../kit/equation3d\";\r\nimport type { ExpressionScope } from \"../kit/expression\";\r\nimport { PLOT_COLOR } from \"../kit/furniture\";\r\nimport { clamp } from \"../kit/geometry\";\r\nimport { lerpParams, lerpSource, readSource, scopeFor, type PlotSource } from \"../kit/source\";\r\nimport { domainEntry, meshEntries } from \"./entries\";\r\nimport { graphEntry, graphOf, type GraphSpace } from \"./space\";\r\n\r\nexport interface CurvePlot3dProps extends Mesh3DProps {\r\n expression?: string | PlotSource;\r\n domain?: Interval | null;\r\n params?: ExpressionScope;\r\n samples?: number;\r\n thickness?: number;\r\n start?: number;\r\n end?: number;\r\n}\r\n\r\nconst state = {\r\n ...meshEntries,\r\n expression: Types.custom<string | PlotSource, PlotSource>(\"\", {\r\n resolve: readSource,\r\n lerp: lerpSource,\r\n kind: \"spaceCurveEquation\",\r\n }),\r\n /** The span of `t` that is drawn; 0 to 1 when left out. */\r\n domain: domainEntry(0, 1),\r\n params: Types.custom<ExpressionScope>({}, { lerp: lerpParams }),\r\n /** How many points the curve is drawn through. */\r\n samples: Types.number(160, { min: 2, max: 2000, step: 1, animatable: false }),\r\n /** The radius of the line, in scene units. */\r\n thickness: Types.number(0.04, { min: 0.001, step: 0.005 }),\r\n /** The part of the curve that is drawn, as shares of its length in `t`. */\r\n start: Types.number(0, { min: 0, max: 1, step: 0.01 }),\r\n end: Types.number(1, { min: 0, max: 1, step: 0.01 }),\r\n graph: graphEntry(),\r\n};\r\n\r\ntype CurveValues = Values<typeof state>;\r\n\r\n/** A curve through a 3D graph, three parts in `t`: `(cos(t), sin(t), t / 4)`. */\r\nexport const CurvePlot3d = component3d({\r\n key: \"curvePlot3d\",\r\n state,\r\n defaults: { fill: PLOT_COLOR },\r\n commands: {\r\n /** Change the equation, the curve bending from the one into the other. */\r\n morphTo: { args: [\"expression\"] },\r\n /** Animate the equation's named values. */\r\n paramsTo: { args: [\"params\"] },\r\n /** Animate the span of `t` that is drawn. */\r\n domainTo: { args: [\"domain\"] },\r\n /** Draw the curve on, or wipe it off: animates `start` and `end`. */\r\n progressTo: { args: [\"start\", \"end\"] },\r\n },\r\n render: (ctx, s) => ctx.draw(Material.mesh(s, curveGeometry(s))),\r\n});\r\n\r\nexport type CurvePlot3d = NodeOf<typeof CurvePlot3d>;\r\n\r\nfunction curveGeometry(s: CurveValues): Geometry3D | undefined {\r\n const space = graphOf(s);\r\n if (!space) return undefined;\r\n const points = pointsOf(s, space);\r\n if (points.length < 2) return undefined;\r\n return Geo.tube({ points, radius: s.thickness, segments: [points.length - 1, 8] });\r\n}\r\n\r\n/** The last run drawn for each curve, kept while what it is drawn from is unchanged. */\r\nconst runs = new WeakMap<object, { readonly key: string; readonly run: Vector3[] }>();\r\n\r\nfunction pointsOf(s: CurveValues, space: GraphSpace): Vector3[] {\r\n const { source, blend } = s.expression;\r\n const start = clamp(s.start, 0, 1);\r\n const end = clamp(s.end, 0, 1);\r\n const samples = Math.max(2, Math.round(s.samples));\r\n const key = [source, blend?.from, blend?.t, space.revision, s.domain, JSON.stringify(s.params), start, end, samples].join(\"|\");\r\n const kept = runs.get(s);\r\n if (kept?.key === key) return kept.run;\r\n const run: Vector3[] = [];\r\n runs.set(s, { key, run });\r\n const to = curveOf(s, source);\r\n if (!to || !(end > start)) return run;\r\n const from = blend ? curveOf(s, blend.from) : null;\r\n const steps = Math.max(1, Math.round(samples * (end - start)));\r\n const a: Vector3 = { x: 0, y: 0, z: 0 };\r\n const b: Vector3 = { x: 0, y: 0, z: 0 };\r\n for (let i = 0; i <= steps; i++) {\r\n const u = start + ((end - start) * i) / steps;\r\n if (!to(u, b)) continue;\r\n if (from && blend) {\r\n if (!from(u, a)) continue;\r\n b.x = a.x + (b.x - a.x) * blend.t;\r\n b.y = a.y + (b.y - a.y) * blend.t;\r\n b.z = a.z + (b.z - a.z) * blend.t;\r\n }\r\n run.push(space.offset(b.x, b.y, b.z));\r\n }\r\n return run;\r\n}\r\n\r\n/** `source` as a graph point for a share `u` of its span, or `false` where it has none. */\r\nfunction curveOf(s: CurveValues, source: string): ((u: number, out: Vector3) => boolean) | null {\r\n const equation = equationOf(source);\r\n if (!equation) return null;\r\n const params = scopeFor(spaceCurveParams(source), s.params);\r\n const [t0, t1] = s.domain ?? [0, 1];\r\n const { x, y, z } = equation;\r\n return (u, out) => {\r\n const t = t0 + (t1 - t0) * u;\r\n out.x = x(t, 0, params);\r\n out.y = y(t, 0, params);\r\n out.z = z(t, 0, params);\r\n return Number.isFinite(out.x) && Number.isFinite(out.y) && Number.isFinite(out.z);\r\n };\r\n}\r\n\r\nfunction equationOf(source: string): SpaceCurveEquation | null {\r\n const equation = parseSpaceCurve(source, spaceCurveParams(source));\r\n return equation instanceof Error ? null : equation;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"curve-plot3d.js","sourceRoot":"","sources":["../../src/three/curve-plot3d.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,GAAG,EACH,UAAU,EACV,QAAQ,EACR,KAAK,GAiBR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAA2B,MAAM,mBAAmB,CAAC;AAE/F,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAmB,MAAM,eA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AAE,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;IACnE,OAAO,QAAQ,YAAY,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;AACvD,CAAC","sourcesContent":["import {\r\n component3d,\r\n Geo,\r\n Graphics3D,\r\n Material,\r\n Types,\r\n type Geometry3D,\r\n type Mesh3DProps,\r\n type NodeOf,\r\n type Values,\r\n type Vector3,\r\n // Named so the emitted declaration reaches these through the sdk, not core.\r\n type Blend3D as _Blend3D,\r\n type Color as _Color,\r\n type Faces3D as _Faces3D,\r\n type Fill3D as _Fill3D,\r\n type Material3D as _Material3D,\r\n type Node3D as _Node3D,\r\n type Node3DProps as _Node3DProps,\r\n type NormalizedColor as _NormalizedColor,\r\n type Shading3D as _Shading3D,\r\n type Texture3D as _Texture3D,\r\n} from \"@motionscript/sdk\";\r\nimport type { Interval } from \"../kit/coords\";\r\nimport { parseSpaceCurve, spaceCurveParams, type SpaceCurveEquation } from \"../kit/equation3d\";\r\nimport type { ExpressionScope } from \"../kit/expression\";\r\nimport { PLOT_COLOR } from \"../kit/furniture\";\r\nimport { clamp } from \"../kit/geometry\";\r\nimport { lerpParams, lerpSource, readSource, scopeFor, type PlotSource } from \"../kit/source\";\r\nimport { domainEntry, meshEntries } from \"./entries\";\r\nimport { graphEntry, graphOf, type GraphSpace } from \"./space\";\r\n\r\nexport interface CurvePlot3dProps extends Mesh3DProps {\r\n expression?: string | PlotSource;\r\n domain?: Interval | null;\r\n params?: ExpressionScope;\r\n samples?: number;\r\n thickness?: number;\r\n start?: number;\r\n end?: number;\r\n}\r\n\r\nconst state = {\r\n ...meshEntries,\r\n expression: Types.custom<string | PlotSource, PlotSource>(\"\", {\r\n resolve: readSource,\r\n lerp: lerpSource,\r\n kind: \"spaceCurveEquation\",\r\n }),\r\n /** The span of `t` that is drawn; 0 to 1 when left out. */\r\n domain: domainEntry(0, 1),\r\n params: Types.custom<ExpressionScope>({}, { lerp: lerpParams }),\r\n /** How many points the curve is drawn through. */\r\n samples: Types.number(160, { min: 2, max: 2000, step: 1, animatable: false }),\r\n /** The radius of the line, in scene units. */\r\n thickness: Types.number(0.04, { min: 0.001, step: 0.005 }),\r\n /** The part of the curve that is drawn, as shares of its length in `t`. */\r\n start: Types.number(0, { min: 0, max: 1, step: 0.01 }),\r\n end: Types.number(1, { min: 0, max: 1, step: 0.01 }),\r\n graph: graphEntry(),\r\n};\r\n\r\ntype CurveValues = Values<typeof state>;\r\n\r\n/** A curve through a 3D graph, three parts in `t`: `(cos(t), sin(t), t / 4)`. */\r\nexport const CurvePlot3d = component3d({\r\n key: \"curvePlot3d\",\r\n state,\r\n defaults: { fill: PLOT_COLOR },\r\n commands: {\r\n /** Change the equation, the curve bending from the one into the other. */\r\n morphTo: { args: [\"expression\"] },\r\n /** Animate the equation's named values. */\r\n paramsTo: { args: [\"params\"] },\r\n /** Animate the span of `t` that is drawn. */\r\n domainTo: { args: [\"domain\"] },\r\n /** Draw the curve on, or wipe it off: animates `start` and `end`. */\r\n progressTo: { args: [\"start\", \"end\"] },\r\n },\r\n // Declaring, its paint on a stand-in: only a material loads, and the curve's points are not sampled.\r\n render: (ctx, s) => ctx.draw(ctx.declaring ? new Graphics3D().plane(Material.shorthand(s)) : Material.mesh(s, curveGeometry(s))),\r\n});\r\n\r\nexport type CurvePlot3d = NodeOf<typeof CurvePlot3d>;\r\n\r\nfunction curveGeometry(s: CurveValues): Geometry3D | undefined {\r\n const space = graphOf(s);\r\n if (!space) return undefined;\r\n const points = pointsOf(s, space);\r\n if (points.length < 2) return undefined;\r\n return Geo.tube({ points, radius: s.thickness, segments: [points.length - 1, 8] });\r\n}\r\n\r\n/** The last run drawn for each curve, kept while what it is drawn from is unchanged. */\r\nconst runs = new WeakMap<object, { readonly key: string; readonly run: Vector3[] }>();\r\n\r\nfunction pointsOf(s: CurveValues, space: GraphSpace): Vector3[] {\r\n const { source, blend } = s.expression;\r\n const start = clamp(s.start, 0, 1);\r\n const end = clamp(s.end, 0, 1);\r\n const samples = Math.max(2, Math.round(s.samples));\r\n const key = [source, blend?.from, blend?.t, space.revision, s.domain, JSON.stringify(s.params), start, end, samples].join(\"|\");\r\n const kept = runs.get(s);\r\n if (kept?.key === key) return kept.run;\r\n const run: Vector3[] = [];\r\n runs.set(s, { key, run });\r\n const to = curveOf(s, source);\r\n if (!to || !(end > start)) return run;\r\n const from = blend ? curveOf(s, blend.from) : null;\r\n const steps = Math.max(1, Math.round(samples * (end - start)));\r\n const a: Vector3 = { x: 0, y: 0, z: 0 };\r\n const b: Vector3 = { x: 0, y: 0, z: 0 };\r\n for (let i = 0; i <= steps; i++) {\r\n const u = start + ((end - start) * i) / steps;\r\n if (!to(u, b)) continue;\r\n if (from && blend) {\r\n if (!from(u, a)) continue;\r\n b.x = a.x + (b.x - a.x) * blend.t;\r\n b.y = a.y + (b.y - a.y) * blend.t;\r\n b.z = a.z + (b.z - a.z) * blend.t;\r\n }\r\n run.push(space.offset(b.x, b.y, b.z));\r\n }\r\n return run;\r\n}\r\n\r\n/** `source` as a graph point for a share `u` of its span, or `false` where it has none. */\r\nfunction curveOf(s: CurveValues, source: string): ((u: number, out: Vector3) => boolean) | null {\r\n const equation = equationOf(source);\r\n if (!equation) return null;\r\n const params = scopeFor(spaceCurveParams(source), s.params);\r\n const [t0, t1] = s.domain ?? [0, 1];\r\n const { x, y, z } = equation;\r\n return (u, out) => {\r\n const t = t0 + (t1 - t0) * u;\r\n out.x = x(t, 0, params);\r\n out.y = y(t, 0, params);\r\n out.z = z(t, 0, params);\r\n return Number.isFinite(out.x) && Number.isFinite(out.y) && Number.isFinite(out.z);\r\n };\r\n}\r\n\r\nfunction equationOf(source: string): SpaceCurveEquation | null {\r\n const equation = parseSpaceCurve(source, spaceCurveParams(source));\r\n return equation instanceof Error ? null : equation;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label3d.d.ts","sourceRoot":"","sources":["../../src/three/label3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,KAAK,EAAE,KAAK,UAAU,EAAyB,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGlI,6GAA6G;AAE7G,MAAM,WAAW,YAAY;IACzB,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACtB;
|
|
1
|
+
{"version":3,"file":"label3d.d.ts","sourceRoot":"","sources":["../../src/three/label3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,KAAK,EAAE,KAAK,UAAU,EAAyB,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGlI,6GAA6G;AAE7G,MAAM,WAAW,YAAY;IACzB,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACtB;AA+BD,kDAAkD;AAClD,wBAAgB,WAAW,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,CAShG"}
|
package/dist/three/label3d.js
CHANGED
|
@@ -21,7 +21,9 @@ function card(text, style) {
|
|
|
21
21
|
textAlign: "center",
|
|
22
22
|
})
|
|
23
23
|
.fill(Fills.color(style.color));
|
|
24
|
-
|
|
24
|
+
// Its pixels never change, so the renderer rasterizes it once rather than every frame.
|
|
25
|
+
const texture = { ...Tex.surface(source, { width, height: CARD_HEIGHT }), static: true, identity: `label3d:${key}` };
|
|
26
|
+
const made = { texture, width };
|
|
25
27
|
cards.set(key, made);
|
|
26
28
|
return made;
|
|
27
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label3d.js","sourceRoot":"","sources":["../../src/three/label3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAo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EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,GAAG,EAAE,EAAE,CAAC;IACvI,MAAM,IAAI,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAChC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACrB,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,WAAW,CAAC,EAAc,EAAE,IAAY,EAAE,EAAW,EAAE,KAAmB;IACtF,IAAI,IAAI,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;QAAE,OAAO;IAC7C,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAC/C,EAAE,CAAC,MAAM,CAAC;QACN,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;QAC5E,QAAQ,EAAE,EAAE;QACZ,KAAK,EAAE,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC,GAAG,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;KACrD,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { Fills, Graphics2D, Mat, Tex, type Color, type Graphics3D, type SurfaceTexture3D, type Vector3 } from \"@motionscript/sdk\";\r\nimport { createBoundedCache } from \"../kit/cache\";\r\n\r\n/** Text in a 3D graph: a camera-facing card, so a number reads square-on from wherever the scene is seen. */\r\n\r\nexport interface LabelStyle3D {\r\n /** The height of the text's em, in scene units. */\r\n size: number;\r\n color: Color;\r\n fontFamily: string;\r\n}\r\n\r\n/** The em the text is rasterized at, in buffer pixels, and the card's height around it. */\r\nconst EM = 64;\r\nconst CARD_HEIGHT = 96;\r\n\r\n// A texture's identity is its source object, so one text in one style is one source for as long as it is asked for.\r\nconst cards = createBoundedCache<{ texture: SurfaceTexture3D; width: number }>(256);\r\n\r\nfunction card(text: string, style: LabelStyle3D): { texture: SurfaceTexture3D; width: number } {\r\n const key = `${style.fontFamily}|${JSON.stringify(style.color)}|${text}`;\r\n const hit = cards.get(key);\r\n if (hit) return hit;\r\n const width = Math.min(1024, Math.max(128, Math.ceil((text.length * EM * 0.62 + EM) / 32) * 32));\r\n const source = new Graphics2D()\r\n .text({\r\n text,\r\n fontSize: EM,\r\n ...(style.fontFamily === \"\" ? {} : { fontFamily: style.fontFamily }),\r\n wrap: false,\r\n width,\r\n textAlign: \"center\",\r\n })\r\n .fill(Fills.color(style.color));\r\n // Its pixels never change, so the renderer rasterizes it once rather than every frame.\r\n const texture: SurfaceTexture3D = { ...Tex.surface(source, { width, height: CARD_HEIGHT }), static: true, identity: `label3d:${key}` };\r\n const made = { texture, width };\r\n cards.set(key, made);\r\n return made;\r\n}\r\n\r\n/** Draw `text` centred on `at`, a local point. */\r\nexport function drawLabel3D(g3: Graphics3D, text: string, at: Vector3, style: LabelStyle3D): void {\r\n if (text === \"\" || !(style.size > 0)) return;\r\n const { texture, width } = card(text, style);\r\n const height = (style.size * CARD_HEIGHT) / EM;\r\n g3.sprite({\r\n material: Mat.sprite({ map: texture, transparent: true, depthWrite: false }),\r\n position: at,\r\n scale: [(height * width) / CARD_HEIGHT, height, 1],\r\n });\r\n}\r\n"]}
|
|
@@ -18,25 +18,25 @@ export declare const PlotPoint3d: import("@motionscript/sdk").Component<"plotPoi
|
|
|
18
18
|
readonly labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
19
19
|
readonly labelColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
|
|
20
20
|
readonly fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
21
|
-
readonly opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
22
|
-
readonly blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
|
|
23
21
|
readonly fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
|
|
24
|
-
readonly
|
|
25
|
-
readonly
|
|
26
|
-
readonly vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
27
|
-
readonly alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
28
|
-
readonly aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
29
|
-
readonly normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
30
|
-
readonly envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
22
|
+
readonly blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
|
|
23
|
+
readonly opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
31
24
|
readonly geometry: import("@motionscript/sdk").Type<_Geometry3D | undefined, _Geometry3D | undefined, false>;
|
|
32
25
|
readonly material: import("@motionscript/sdk").Type<_Material3D | readonly _Material3D[] | undefined, _Material3D | readonly _Material3D[] | undefined, false>;
|
|
33
26
|
readonly roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
34
27
|
readonly metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
35
28
|
readonly emission: import("@motionscript/sdk").Type<Color | undefined, _NormalizedColor | undefined, false>;
|
|
36
29
|
readonly emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
30
|
+
readonly normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
37
31
|
readonly roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
38
32
|
readonly metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
33
|
+
readonly aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
34
|
+
readonly alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
35
|
+
readonly envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
36
|
+
readonly wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
39
37
|
readonly shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
|
|
38
|
+
readonly faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
|
|
39
|
+
readonly vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
40
40
|
readonly unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
41
41
|
}>, {}, null, _Node3D<_Node3DProps>, import("@motionscript/sdk").CallProps3D<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Transform3DState, {
|
|
42
42
|
/** In scene units, so a point is the same size whatever the axes show. */
|
|
@@ -46,25 +46,25 @@ export declare const PlotPoint3d: import("@motionscript/sdk").Component<"plotPoi
|
|
|
46
46
|
readonly labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
47
47
|
readonly labelColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
|
|
48
48
|
readonly fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
49
|
-
readonly opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
50
|
-
readonly blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
|
|
51
49
|
readonly fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
|
|
52
|
-
readonly
|
|
53
|
-
readonly
|
|
54
|
-
readonly vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
55
|
-
readonly alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
56
|
-
readonly aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
57
|
-
readonly normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
58
|
-
readonly envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
50
|
+
readonly blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
|
|
51
|
+
readonly opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
59
52
|
readonly geometry: import("@motionscript/sdk").Type<_Geometry3D | undefined, _Geometry3D | undefined, false>;
|
|
60
53
|
readonly material: import("@motionscript/sdk").Type<_Material3D | readonly _Material3D[] | undefined, _Material3D | readonly _Material3D[] | undefined, false>;
|
|
61
54
|
readonly roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
62
55
|
readonly metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
63
56
|
readonly emission: import("@motionscript/sdk").Type<Color | undefined, _NormalizedColor | undefined, false>;
|
|
64
57
|
readonly emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
58
|
+
readonly normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
65
59
|
readonly roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
66
60
|
readonly metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
61
|
+
readonly aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
62
|
+
readonly alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
63
|
+
readonly envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
64
|
+
readonly wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
67
65
|
readonly shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
|
|
66
|
+
readonly faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
|
|
67
|
+
readonly vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
68
68
|
readonly unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
69
69
|
}>, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Transform3DState, {
|
|
70
70
|
/** In scene units, so a point is the same size whatever the axes show. */
|
|
@@ -74,25 +74,25 @@ export declare const PlotPoint3d: import("@motionscript/sdk").Component<"plotPoi
|
|
|
74
74
|
readonly labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
75
75
|
readonly labelColor: import("@motionscript/sdk").Type<Color, _NormalizedColor, false>;
|
|
76
76
|
readonly fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
77
|
-
readonly opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
78
|
-
readonly blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
|
|
79
77
|
readonly fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
|
|
80
|
-
readonly
|
|
81
|
-
readonly
|
|
82
|
-
readonly vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
83
|
-
readonly alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
84
|
-
readonly aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
85
|
-
readonly normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
86
|
-
readonly envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
78
|
+
readonly blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
|
|
79
|
+
readonly opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
87
80
|
readonly geometry: import("@motionscript/sdk").Type<_Geometry3D | undefined, _Geometry3D | undefined, false>;
|
|
88
81
|
readonly material: import("@motionscript/sdk").Type<_Material3D | readonly _Material3D[] | undefined, _Material3D | readonly _Material3D[] | undefined, false>;
|
|
89
82
|
readonly roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
90
83
|
readonly metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
91
84
|
readonly emission: import("@motionscript/sdk").Type<Color | undefined, _NormalizedColor | undefined, false>;
|
|
92
85
|
readonly emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
86
|
+
readonly normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
93
87
|
readonly roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
94
88
|
readonly metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
89
|
+
readonly aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
90
|
+
readonly alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
91
|
+
readonly envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
92
|
+
readonly wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
95
93
|
readonly shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
|
|
94
|
+
readonly faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
|
|
95
|
+
readonly vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
96
96
|
readonly unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
97
97
|
}>, {}, _Node3D<_Node3DProps>>>>;
|
|
98
98
|
export type PlotPoint3d = NodeOf<typeof PlotPoint3d>;
|
|
@@ -34,25 +34,25 @@ declare const state: {
|
|
|
34
34
|
/** The opacity of the surface's shadow, laid flat on the floor of the axes and coloured by height; zero draws none. */
|
|
35
35
|
floorShadow: import("@motionscript/sdk").Type<number, number, false>;
|
|
36
36
|
graph: import("@motionscript/sdk").Type<import("./space.js").Graph3D | null, import("./space.js").Graph3D | null, true>;
|
|
37
|
-
opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
38
|
-
blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
|
|
39
37
|
fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
43
|
-
alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
44
|
-
aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
45
|
-
normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
46
|
-
envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
38
|
+
blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
|
|
39
|
+
opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
47
40
|
geometry: import("@motionscript/sdk").Type<Geometry3D | undefined, Geometry3D | undefined, false>;
|
|
48
41
|
material: import("@motionscript/sdk").Type<Material3D | readonly Material3D[] | undefined, Material3D | readonly Material3D[] | undefined, false>;
|
|
49
42
|
roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
50
43
|
metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
51
44
|
emission: import("@motionscript/sdk").Type<Color | undefined, NormalizedColor | undefined, false>;
|
|
52
45
|
emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
46
|
+
normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
53
47
|
roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
54
48
|
metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
49
|
+
aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
50
|
+
alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
51
|
+
envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
52
|
+
wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
55
53
|
shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
|
|
54
|
+
faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
|
|
55
|
+
vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
56
56
|
unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
57
57
|
};
|
|
58
58
|
/** What a surface is drawn from: its own entries, as its node and its helpers read them. */
|
|
@@ -86,25 +86,25 @@ export declare const SurfacePlot3d: import("@motionscript/sdk").Component<"surfa
|
|
|
86
86
|
/** The opacity of the surface's shadow, laid flat on the floor of the axes and coloured by height; zero draws none. */
|
|
87
87
|
floorShadow: import("@motionscript/sdk").Type<number, number, false>;
|
|
88
88
|
graph: import("@motionscript/sdk").Type<import("./space.js").Graph3D | null, import("./space.js").Graph3D | null, true>;
|
|
89
|
-
opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
90
|
-
blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
|
|
91
89
|
fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
95
|
-
alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
96
|
-
aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
97
|
-
normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
98
|
-
envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
90
|
+
blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
|
|
91
|
+
opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
99
92
|
geometry: import("@motionscript/sdk").Type<Geometry3D | undefined, Geometry3D | undefined, false>;
|
|
100
93
|
material: import("@motionscript/sdk").Type<Material3D | readonly Material3D[] | undefined, Material3D | readonly Material3D[] | undefined, false>;
|
|
101
94
|
roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
102
95
|
metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
103
96
|
emission: import("@motionscript/sdk").Type<Color | undefined, NormalizedColor | undefined, false>;
|
|
104
97
|
emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
98
|
+
normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
105
99
|
roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
106
100
|
metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
101
|
+
aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
102
|
+
alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
103
|
+
envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
104
|
+
wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
107
105
|
shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
|
|
106
|
+
faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
|
|
107
|
+
vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
108
108
|
unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
109
109
|
}>, {
|
|
110
110
|
readonly morphTo: readonly ["expression"];
|
|
@@ -131,25 +131,25 @@ export declare const SurfacePlot3d: import("@motionscript/sdk").Component<"surfa
|
|
|
131
131
|
/** The opacity of the surface's shadow, laid flat on the floor of the axes and coloured by height; zero draws none. */
|
|
132
132
|
floorShadow: import("@motionscript/sdk").Type<number, number, false>;
|
|
133
133
|
graph: import("@motionscript/sdk").Type<import("./space.js").Graph3D | null, import("./space.js").Graph3D | null, true>;
|
|
134
|
-
opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
135
|
-
blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
|
|
136
134
|
fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
140
|
-
alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
141
|
-
aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
142
|
-
normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
143
|
-
envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
135
|
+
blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
|
|
136
|
+
opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
144
137
|
geometry: import("@motionscript/sdk").Type<Geometry3D | undefined, Geometry3D | undefined, false>;
|
|
145
138
|
material: import("@motionscript/sdk").Type<Material3D | readonly Material3D[] | undefined, Material3D | readonly Material3D[] | undefined, false>;
|
|
146
139
|
roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
147
140
|
metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
148
141
|
emission: import("@motionscript/sdk").Type<Color | undefined, NormalizedColor | undefined, false>;
|
|
149
142
|
emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
143
|
+
normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
150
144
|
roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
151
145
|
metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
146
|
+
aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
147
|
+
alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
148
|
+
envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
149
|
+
wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
152
150
|
shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
|
|
151
|
+
faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
|
|
152
|
+
vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
153
153
|
unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
154
154
|
}>, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Transform3DState, {
|
|
155
155
|
expression: import("@motionscript/sdk").Type<string | PlotSource, PlotSource, false>;
|
|
@@ -172,25 +172,25 @@ export declare const SurfacePlot3d: import("@motionscript/sdk").Component<"surfa
|
|
|
172
172
|
/** The opacity of the surface's shadow, laid flat on the floor of the axes and coloured by height; zero draws none. */
|
|
173
173
|
floorShadow: import("@motionscript/sdk").Type<number, number, false>;
|
|
174
174
|
graph: import("@motionscript/sdk").Type<import("./space.js").Graph3D | null, import("./space.js").Graph3D | null, true>;
|
|
175
|
-
opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
176
|
-
blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
|
|
177
175
|
fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
181
|
-
alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
182
|
-
aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
183
|
-
normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
184
|
-
envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
176
|
+
blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
|
|
177
|
+
opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
185
178
|
geometry: import("@motionscript/sdk").Type<Geometry3D | undefined, Geometry3D | undefined, false>;
|
|
186
179
|
material: import("@motionscript/sdk").Type<Material3D | readonly Material3D[] | undefined, Material3D | readonly Material3D[] | undefined, false>;
|
|
187
180
|
roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
188
181
|
metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
189
182
|
emission: import("@motionscript/sdk").Type<Color | undefined, NormalizedColor | undefined, false>;
|
|
190
183
|
emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
184
|
+
normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
191
185
|
roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
192
186
|
metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
187
|
+
aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
188
|
+
alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
189
|
+
envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
190
|
+
wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
193
191
|
shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
|
|
192
|
+
faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
|
|
193
|
+
vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
194
194
|
unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
195
195
|
}>, {
|
|
196
196
|
readonly morphTo: readonly ["expression"];
|
|
@@ -50,7 +50,7 @@ export const SurfacePlot3d = component3d({
|
|
|
50
50
|
domainTo: { args: ["uDomain", "vDomain"] },
|
|
51
51
|
},
|
|
52
52
|
space: (s) => surfaceSpace(s),
|
|
53
|
-
render: (ctx, s) => ctx.draw(drawSurface(s)),
|
|
53
|
+
render: (ctx, s) => ctx.draw(ctx.declaring ? declaredSurface(s) : drawSurface(s)),
|
|
54
54
|
});
|
|
55
55
|
/**
|
|
56
56
|
* The surface's height above its own origin at graph `(x, y)`, or `NaN`
|
|
@@ -76,6 +76,11 @@ function surfaceSpace(s) {
|
|
|
76
76
|
},
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
|
+
/** Its paint on a stand-in: only a material loads, and reading no equation keeps a morph from re-declaring. */
|
|
80
|
+
function declaredSurface(s) {
|
|
81
|
+
const paint = Material.shorthand(s);
|
|
82
|
+
return new Graphics3D().plane(s.colorScale.length > 0 ? { ...paint, fill: "white" } : paint);
|
|
83
|
+
}
|
|
79
84
|
function drawSurface(s) {
|
|
80
85
|
const g3 = new Graphics3D();
|
|
81
86
|
const space = graphOf(s);
|
|
@@ -1 +1 @@
|
|
|
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,EAAE,UAAU;QACn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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
|
+
{"version":3,"file":"surface-plot3d.js","sourceRoot":"","sources":["../../src/three/surface-plot3d.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EACR,WAAW,EACX,GAAG,EAC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AAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;YAC7D,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QACjE,CAAC;IACL,CAAC;IACD,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,UAAU,CAAC,MAAc;IAC9B,MAAM,QAAQ,GAAG,YAAY,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7D,OAAO,QAAQ,YAAY,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;AACvD,CAAC;AAED,sEAAsE;AACtE,SAAS,MAAM,CAAC,KAAa;IACzB,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,YAAY,CACjB,QAA4C,EAC5C,MAA4C;IAE5C,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAE,QAAkC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAsB,CAAC,CAAC;AACtH,CAAC","sourcesContent":["import {\r\n colorOps,\r\n component3d,\r\n Geo,\r\n Graphics3D,\r\n Mat,\r\n Material,\r\n Types,\r\n type ChildSpace3D,\r\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(ctx.declaring ? declaredSurface(s) : 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\n/** Its paint on a stand-in: only a material loads, and reading no equation keeps a morph from re-declaring. */\r\nfunction declaredSurface(s: SurfaceValues): Graphics3D {\r\n const paint = Material.shorthand(s);\r\n return new Graphics3D().plane(s.colorScale.length > 0 ? { ...paint, fill: \"white\" } : paint);\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"]}
|