@motionscript/math 0.1.0-alpha.6 → 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 +8 -0
- package/NOTICE +15 -14
- package/dist/annotate/angle-mark.d.ts +26 -1
- package/dist/annotate/angle-mark.d.ts.map +1 -1
- package/dist/annotate/curly-brace.d.ts +38 -3
- package/dist/annotate/curly-brace.d.ts.map +1 -1
- package/dist/annotate/emphasis-mark.d.ts +29 -3
- package/dist/annotate/emphasis-mark.d.ts.map +1 -1
- 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/component.d.ts.map +1 -1
- package/dist/kit/field-mark.d.ts +1 -3
- package/dist/kit/field-mark.d.ts.map +1 -1
- package/dist/kit/follow.d.ts.map +1 -1
- package/dist/kit/sampler.js +1 -1
- package/dist/kit/sampler.js.map +1 -1
- package/dist/marks/curve-area.d.ts +14 -1
- package/dist/marks/curve-area.d.ts.map +1 -1
- package/dist/marks/drop-lines.d.ts +18 -1
- package/dist/marks/drop-lines.d.ts.map +1 -1
- package/dist/marks/plot-point.d.ts +22 -3
- package/dist/marks/plot-point.d.ts.map +1 -1
- package/dist/marks/riemann-sum.d.ts +20 -3
- package/dist/marks/riemann-sum.d.ts.map +1 -1
- package/dist/marks/tangent-line.d.ts +21 -1
- package/dist/marks/tangent-line.d.ts.map +1 -1
- package/dist/marks/vector-arrow.d.ts +19 -1
- package/dist/marks/vector-arrow.d.ts.map +1 -1
- package/dist/plots/function-plot.d.ts +29 -1
- package/dist/plots/function-plot.d.ts.map +1 -1
- package/dist/plots/points-plot.d.ts +22 -1
- package/dist/plots/points-plot.d.ts.map +1 -1
- package/dist/plots/stream-lines.d.ts +23 -1
- package/dist/plots/stream-lines.d.ts.map +1 -1
- package/dist/plots/traced-path.d.ts +21 -1
- package/dist/plots/traced-path.d.ts.map +1 -1
- package/dist/plots/vector-field.d.ts +18 -1
- package/dist/plots/vector-field.d.ts.map +1 -1
- package/dist/structures/network-graph.d.ts +42 -1
- package/dist/structures/network-graph.d.ts.map +1 -1
- package/dist/structures/sample-space.d.ts +22 -1
- package/dist/structures/sample-space.d.ts.map +1 -1
- package/dist/systems/axes2d.d.ts +34 -1
- package/dist/systems/axes2d.d.ts.map +1 -1
- package/dist/systems/number-line.d.ts +30 -1
- package/dist/systems/number-line.d.ts.map +1 -1
- package/dist/systems/number-plane.d.ts +49 -1
- package/dist/systems/number-plane.d.ts.map +1 -1
- package/dist/systems/polar-plane.d.ts +30 -1
- package/dist/systems/polar-plane.d.ts.map +1 -1
- package/dist/tex/matrix.d.ts +33 -1
- package/dist/tex/matrix.d.ts.map +1 -1
- package/dist/tex/node.d.ts +30 -1
- package/dist/tex/node.d.ts.map +1 -1
- package/dist/tex/typeset.d.ts.map +1 -1
- package/dist/three/axes3d.d.ts +75 -1
- package/dist/three/axes3d.d.ts.map +1 -1
- package/dist/three/axes3d.js +6 -2
- package/dist/three/axes3d.js.map +1 -1
- package/dist/three/curve-plot3d.d.ts +40 -2
- 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 +30 -2
- package/dist/three/plot-point3d.d.ts.map +1 -1
- package/dist/three/surface-plot3d.d.ts +48 -3
- package/dist/three/surface-plot3d.d.ts.map +1 -1
- package/dist/three/surface-plot3d.js +6 -1
- package/dist/three/surface-plot3d.js.map +1 -1
- package/dist/three/vector-arrow3d.d.ts +31 -2
- package/dist/three/vector-arrow3d.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/kit/sampler.ts +1 -1
- package/src/three/axes3d.ts +8 -2
- package/src/three/curve-plot3d.ts +3 -1
- package/src/three/label3d.ts +3 -1
- package/src/three/surface-plot3d.ts +7 -1
|
@@ -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;QACnB,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,iBAAiB;KAC1B,CAAC;IACF;;;;OAIG;IACH,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC3B,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC3B,oGAAoG;IACpG,MAAM,EAAE,KAAK,CAAC,MAAM,CAAkB,EAAE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AC,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(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,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,OA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AC,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"]}
|
|
@@ -14,8 +14,8 @@ export declare const VectorArrow3d: import("@motionscript/sdk").Component<"vecto
|
|
|
14
14
|
tip: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
15
15
|
graph: import("@motionscript/sdk").Type<import("./space.js").Graph3D | null, import("./space.js").Graph3D | null, true>;
|
|
16
16
|
fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
|
|
17
|
-
opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
18
17
|
blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
|
|
18
|
+
opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
19
19
|
geometry: import("@motionscript/sdk").Type<_Geometry3D | undefined, _Geometry3D | undefined, false>;
|
|
20
20
|
material: import("@motionscript/sdk").Type<_Material3D | readonly _Material3D[] | undefined, _Material3D | readonly _Material3D[] | undefined, false>;
|
|
21
21
|
roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
@@ -43,8 +43,35 @@ export declare const VectorArrow3d: import("@motionscript/sdk").Component<"vecto
|
|
|
43
43
|
tip: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
44
44
|
graph: import("@motionscript/sdk").Type<import("./space.js").Graph3D | null, import("./space.js").Graph3D | null, true>;
|
|
45
45
|
fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
|
|
46
|
+
blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
|
|
46
47
|
opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
48
|
+
geometry: import("@motionscript/sdk").Type<_Geometry3D | undefined, _Geometry3D | undefined, false>;
|
|
49
|
+
material: import("@motionscript/sdk").Type<_Material3D | readonly _Material3D[] | undefined, _Material3D | readonly _Material3D[] | undefined, false>;
|
|
50
|
+
roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
51
|
+
metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
52
|
+
emission: import("@motionscript/sdk").Type<_Color | undefined, _NormalizedColor | undefined, false>;
|
|
53
|
+
emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
54
|
+
normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
55
|
+
roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
56
|
+
metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
57
|
+
aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
58
|
+
alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
|
|
59
|
+
envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
60
|
+
wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
61
|
+
shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
|
|
62
|
+
faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
|
|
63
|
+
vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
64
|
+
unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
65
|
+
}>, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Transform3DState, {
|
|
66
|
+
tail: import("@motionscript/sdk").Type<Vector3Input, Vector3, false>;
|
|
67
|
+
head: import("@motionscript/sdk").Type<Vector3Input, Vector3, false>;
|
|
68
|
+
/** The radius of the shaft, in scene units; the tip is sized from it. */
|
|
69
|
+
thickness: import("@motionscript/sdk").Type<number, number, false>;
|
|
70
|
+
tip: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
71
|
+
graph: import("@motionscript/sdk").Type<import("./space.js").Graph3D | null, import("./space.js").Graph3D | null, true>;
|
|
72
|
+
fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
|
|
47
73
|
blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
|
|
74
|
+
opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
48
75
|
geometry: import("@motionscript/sdk").Type<_Geometry3D | undefined, _Geometry3D | undefined, false>;
|
|
49
76
|
material: import("@motionscript/sdk").Type<_Material3D | readonly _Material3D[] | undefined, _Material3D | readonly _Material3D[] | undefined, false>;
|
|
50
77
|
roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
@@ -62,6 +89,8 @@ export declare const VectorArrow3d: import("@motionscript/sdk").Component<"vecto
|
|
|
62
89
|
faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
|
|
63
90
|
vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
|
|
64
91
|
unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
65
|
-
}
|
|
92
|
+
}>, {
|
|
93
|
+
readonly endpointsTo: readonly ["tail", "head"];
|
|
94
|
+
}, _Node3D<_Node3DProps>>>>;
|
|
66
95
|
export type VectorArrow3d = NodeOf<typeof VectorArrow3d>;
|
|
67
96
|
//# sourceMappingURL=vector-arrow3d.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector-arrow3d.d.ts","sourceRoot":"","sources":["../../src/three/vector-arrow3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAOH,KAAK,WAAW,EAChB,KAAK,MAAM,EAEX,KAAK,OAAO,EACZ,KAAK,YAAY,EAEjB,KAAK,OAAO,IAAI,QAAQ,EACxB,KAAK,KAAK,IAAI,MAAM,EACpB,KAAK,OAAO,IAAI,QAAQ,EACxB,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,UAAU,IAAI,WAAW,EAC9B,KAAK,UAAU,IAAI,WAAW,EAC9B,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,eAAe,IAAI,gBAAgB,EACxC,KAAK,SAAS,IAAI,UAAU,EAC5B,KAAK,SAAS,IAAI,UAAU,EAC/B,MAAM,mBAAmB,CAAC;AAI3B,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACnD,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,OAAO,CAAC;CACjB;AAgBD,sFAAsF;AACtF,eAAO,MAAM,aAAa;;;IAPtB,yEAAyE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAzE,yEAAyE
|
|
1
|
+
{"version":3,"file":"vector-arrow3d.d.ts","sourceRoot":"","sources":["../../src/three/vector-arrow3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAOH,KAAK,WAAW,EAChB,KAAK,MAAM,EAEX,KAAK,OAAO,EACZ,KAAK,YAAY,EAEjB,KAAK,OAAO,IAAI,QAAQ,EACxB,KAAK,KAAK,IAAI,MAAM,EACpB,KAAK,OAAO,IAAI,QAAQ,EACxB,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,UAAU,IAAI,WAAW,EAC9B,KAAK,UAAU,IAAI,WAAW,EAC9B,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,eAAe,IAAI,gBAAgB,EACxC,KAAK,SAAS,IAAI,UAAU,EAC5B,KAAK,SAAS,IAAI,UAAU,EAC/B,MAAM,mBAAmB,CAAC;AAI3B,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACnD,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,OAAO,CAAC;CACjB;AAgBD,sFAAsF;AACtF,eAAO,MAAM,aAAa;;;IAPtB,yEAAyE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAzE,yEAAyE;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAzE,yEAAyE;;;;;;;;;;;;;;;;;;;;;;;;;;2BAe3E,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motionscript/math",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Math for Motion Script: coordinate systems, function and vector-field plots, 3D graphs and surfaces, network graphs, and LaTeX formulas typeset to glyph paths that morph token by token.",
|
|
6
6
|
"repository": {
|
|
@@ -52,8 +52,9 @@
|
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
54
|
"license": "Apache-2.0",
|
|
55
|
+
"author": "Motionscript",
|
|
55
56
|
"peerDependencies": {
|
|
56
|
-
"@motionscript/sdk": "^0.1.0-alpha.
|
|
57
|
+
"@motionscript/sdk": "^0.1.0-alpha.8"
|
|
57
58
|
},
|
|
58
59
|
"dependencies": {
|
|
59
60
|
"@mathjax/mathjax-newcm-font": "^4.1.1",
|
|
@@ -68,8 +69,8 @@
|
|
|
68
69
|
"typescript": "^6.0.3",
|
|
69
70
|
"typescript-eslint": "^8.48.0",
|
|
70
71
|
"vitest": "^4.1.5",
|
|
71
|
-
"@motionscript/
|
|
72
|
-
"@motionscript/
|
|
72
|
+
"@motionscript/core": "0.1.0-alpha.8",
|
|
73
|
+
"@motionscript/sdk": "0.1.0-alpha.8"
|
|
73
74
|
},
|
|
74
75
|
"scripts": {
|
|
75
76
|
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json --resolve-full-paths && node ../../../scripts/build-browser.mjs",
|
package/src/kit/sampler.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface SampleOptions {
|
|
|
16
16
|
minStep?: number;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
/**
|
|
19
|
+
/** Path coordinates are 32-bit floats in the renderer; past this a clamped point still clips to the same edge. */
|
|
20
20
|
const COORD_LIMIT = 16_000;
|
|
21
21
|
/** How far, in pixels, the drawn chord may stray from the curve. */
|
|
22
22
|
const TOLERANCE_PX = 0.25;
|
package/src/three/axes3d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
type Canvas3DProps,
|
|
13
13
|
type Color,
|
|
14
14
|
type NodeOf,
|
|
15
|
+
type Scene3D,
|
|
15
16
|
type Transform3D,
|
|
16
17
|
type Values,
|
|
17
18
|
type Vector3,
|
|
@@ -142,18 +143,23 @@ export const Axes3d = component2d({
|
|
|
142
143
|
},
|
|
143
144
|
allowedChildren: ["2d", "3d"],
|
|
144
145
|
load: (loader, s) => {
|
|
145
|
-
View3D.load(loader);
|
|
146
|
+
View3D.load(loader, furnish(s));
|
|
146
147
|
if (s.fontFamily !== "") loader.font(s.fontFamily);
|
|
147
148
|
},
|
|
148
149
|
provide: (s) => [provides(GRAPH_3D, graphOfAxes(s))],
|
|
149
150
|
space: (s) => axesSpace(s),
|
|
150
151
|
measure: (measurer, s, children) => Flow.measure(measurer, s, children, Paint.inset(s)),
|
|
151
152
|
layout: (box, s, children) => Flow.layout(box, s, children, Paint.inset(s)),
|
|
152
|
-
render: (ctx, s) => View3D.draw(ctx, s, (
|
|
153
|
+
render: (ctx, s) => View3D.draw(ctx, s, furnish(s)),
|
|
153
154
|
});
|
|
154
155
|
|
|
155
156
|
export type Axes3d = NodeOf<typeof Axes3d>;
|
|
156
157
|
|
|
158
|
+
/** The axes' own drawing, added to the scene: what `render` draws and `load` declares. */
|
|
159
|
+
function furnish(s: AxesValues): (scene: Scene3D) => void {
|
|
160
|
+
return (scene) => scene.draw(furniture(s));
|
|
161
|
+
}
|
|
162
|
+
|
|
157
163
|
/** The last space worked out for each axes, kept while its ranges and lengths are unchanged. */
|
|
158
164
|
const spaces = new WeakMap<object, { readonly key: string; readonly space: GraphSpace }>();
|
|
159
165
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
component3d,
|
|
3
3
|
Geo,
|
|
4
|
+
Graphics3D,
|
|
4
5
|
Material,
|
|
5
6
|
Types,
|
|
6
7
|
type Geometry3D,
|
|
@@ -76,7 +77,8 @@ export const CurvePlot3d = component3d({
|
|
|
76
77
|
/** Draw the curve on, or wipe it off: animates `start` and `end`. */
|
|
77
78
|
progressTo: { args: ["start", "end"] },
|
|
78
79
|
},
|
|
79
|
-
|
|
80
|
+
// Declaring, its paint on a stand-in: only a material loads, and the curve's points are not sampled.
|
|
81
|
+
render: (ctx, s) => ctx.draw(ctx.declaring ? new Graphics3D().plane(Material.shorthand(s)) : Material.mesh(s, curveGeometry(s))),
|
|
80
82
|
});
|
|
81
83
|
|
|
82
84
|
export type CurvePlot3d = NodeOf<typeof CurvePlot3d>;
|
package/src/three/label3d.ts
CHANGED
|
@@ -32,7 +32,9 @@ function card(text: string, style: LabelStyle3D): { texture: SurfaceTexture3D; w
|
|
|
32
32
|
textAlign: "center",
|
|
33
33
|
})
|
|
34
34
|
.fill(Fills.color(style.color));
|
|
35
|
-
|
|
35
|
+
// Its pixels never change, so the renderer rasterizes it once rather than every frame.
|
|
36
|
+
const texture: SurfaceTexture3D = { ...Tex.surface(source, { width, height: CARD_HEIGHT }), static: true, identity: `label3d:${key}` };
|
|
37
|
+
const made = { texture, width };
|
|
36
38
|
cards.set(key, made);
|
|
37
39
|
return made;
|
|
38
40
|
}
|
|
@@ -99,7 +99,7 @@ export const SurfacePlot3d = component3d({
|
|
|
99
99
|
domainTo: { args: ["uDomain", "vDomain"] },
|
|
100
100
|
},
|
|
101
101
|
space: (s) => surfaceSpace(s),
|
|
102
|
-
render: (ctx, s) => ctx.draw(drawSurface(s)),
|
|
102
|
+
render: (ctx, s) => ctx.draw(ctx.declaring ? declaredSurface(s) : drawSurface(s)),
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
export type SurfacePlot3d = NodeOf<typeof SurfacePlot3d>;
|
|
@@ -128,6 +128,12 @@ function surfaceSpace(s: SurfaceValues): ChildSpace3D | null {
|
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
/** Its paint on a stand-in: only a material loads, and reading no equation keeps a morph from re-declaring. */
|
|
132
|
+
function declaredSurface(s: SurfaceValues): Graphics3D {
|
|
133
|
+
const paint = Material.shorthand(s);
|
|
134
|
+
return new Graphics3D().plane(s.colorScale.length > 0 ? { ...paint, fill: "white" } : paint);
|
|
135
|
+
}
|
|
136
|
+
|
|
131
137
|
function drawSurface(s: SurfaceValues): Graphics3D {
|
|
132
138
|
const g3 = new Graphics3D();
|
|
133
139
|
const space = graphOf(s);
|