manim-web 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/index.d.ts +2 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +3 -3
  4. package/dist/integrations/react.js +17 -17
  5. package/dist/integrations/vue.js +16 -16
  6. package/dist/manim-web.browser.js +2290 -1622
  7. package/dist/mobjects/graph/DiGraph.d.ts.map +1 -1
  8. package/dist/mobjects/graph/GenericGraph.d.ts +15 -0
  9. package/dist/mobjects/graph/GenericGraph.d.ts.map +1 -1
  10. package/dist/mobjects/graph/graphEdgeDecorations.d.ts +27 -0
  11. package/dist/mobjects/graph/graphEdgeDecorations.d.ts.map +1 -0
  12. package/dist/mobjects/graph/graphTypes.d.ts +8 -0
  13. package/dist/mobjects/graph/graphTypes.d.ts.map +1 -1
  14. package/dist/mobjects/graphing/ContourPlot.d.ts +77 -0
  15. package/dist/mobjects/graphing/ContourPlot.d.ts.map +1 -0
  16. package/dist/mobjects/graphing/HeatMap.d.ts +85 -0
  17. package/dist/mobjects/graphing/HeatMap.d.ts.map +1 -0
  18. package/dist/mobjects/graphing/colormap.d.ts +34 -0
  19. package/dist/mobjects/graphing/colormap.d.ts.map +1 -0
  20. package/dist/mobjects/graphing/index.d.ts +4 -0
  21. package/dist/mobjects/graphing/index.d.ts.map +1 -1
  22. package/dist/mobjects/graphing/marchingSquares.d.ts +26 -0
  23. package/dist/mobjects/graphing/marchingSquares.d.ts.map +1 -0
  24. package/dist/mobjects/three-d/ImplicitSurface.d.ts +122 -0
  25. package/dist/mobjects/three-d/ImplicitSurface.d.ts.map +1 -0
  26. package/dist/mobjects/three-d/index.d.ts +2 -0
  27. package/dist/mobjects/three-d/index.d.ts.map +1 -1
  28. package/dist/mobjects/three-d/marchingCubes.d.ts +47 -0
  29. package/dist/mobjects/three-d/marchingCubes.d.ts.map +1 -0
  30. package/dist/{src-CIYJhSa5.js → src-BDtZsFr6.js} +2274 -1606
  31. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DiGraph.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graph/DiGraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,QAAQ,EAAa,cAAc,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,qBAAa,OAAQ,SAAQ,YAAY;gBAC3B,OAAO,GAAE,cAAmB;IAexC;;OAEG;IACH,eAAe,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE;IAUxC;;OAEG;IACH,cAAc,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE;IAUvC;;OAEG;IACH,YAAY,CAAC,CAAC,EAAE,QAAQ,GAAG,MAAM;IAIjC;;OAEG;IACH,WAAW,CAAC,CAAC,EAAE,QAAQ,GAAG,MAAM;IAIvB,IAAI,IAAI,OAAO;CAWzB"}
1
+ {"version":3,"file":"DiGraph.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graph/DiGraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,QAAQ,EAAa,cAAc,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,qBAAa,OAAQ,SAAQ,YAAY;gBAC3B,OAAO,GAAE,cAAmB;IAqBxC;;OAEG;IACH,eAAe,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE;IAUxC;;OAEG;IACH,cAAc,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE;IAUvC;;OAEG;IACH,YAAY,CAAC,CAAC,EAAE,QAAQ,GAAG,MAAM;IAIjC;;OAEG;IACH,WAAW,CAAC,CAAC,EAAE,QAAQ,GAAG,MAAM;IAIvB,IAAI,IAAI,OAAO;CAWzB"}
@@ -1,6 +1,7 @@
1
1
  import { Mobject, Vector3Tuple } from '../../core/Mobject';
2
2
  import { Dot } from '../geometry/Dot';
3
3
  import { VertexId, EdgeTuple, LayoutType, VertexStyleOptions, EdgeStyleOptions, VertexConfig, EdgeConfig, LayoutConfig, GenericGraphOptions } from './graphTypes';
4
+ import { Text } from '../text/Text';
4
5
  /**
5
6
  * GenericGraph - Base class for graph visualization
6
7
  *
@@ -20,6 +21,8 @@ export declare class GenericGraph extends Mobject {
20
21
  protected _vertexMobjects: Map<VertexId, Dot>;
21
22
  /** Map of edge key to Line/Arrow mobject */
22
23
  protected _edgeMobjects: Map<string, Mobject>;
24
+ /** Map of edge key to its weight/label Text mobject */
25
+ protected _edgeLabelMobjects: Map<string, Text>;
23
26
  /** Layout configuration */
24
27
  protected _layoutConfig: LayoutConfig;
25
28
  /** Default vertex style */
@@ -147,12 +150,24 @@ export declare class GenericGraph extends Mobject {
147
150
  * Get the Line/Arrow mobject for an edge
148
151
  */
149
152
  getEdgeMobject(source: VertexId, target: VertexId): Mobject | undefined;
153
+ /**
154
+ * Get the weight/label Text mobject for an edge, if the edge has one.
155
+ */
156
+ getEdgeLabelMobject(source: VertexId, target: VertexId): Text | undefined;
157
+ /**
158
+ * Check whether an edge is a self-loop (connects a vertex to itself).
159
+ */
160
+ isSelfLoop(source: VertexId, target: VertexId): boolean;
150
161
  /**
151
162
  * Change the layout algorithm
152
163
  * @param layout - Layout type or configuration
153
164
  * @returns this for chaining
154
165
  */
155
166
  setLayout(layout: LayoutType | LayoutConfig): this;
167
+ /**
168
+ * Remove and forget the label mobject for an edge, if any.
169
+ */
170
+ protected _removeEdgeLabel(key: string): void;
156
171
  /**
157
172
  * Get all vertex positions
158
173
  */
@@ -1 +1 @@
1
- {"version":3,"file":"GenericGraph.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graph/GenericGraph.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OA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AE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO;IAMvD;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,YAAY,GAAG,IAAI;IAkClD;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAQ7C;;OAEG;IACH,YAAY,IAAI,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC;IAM3C;;OAEG;IACH,cAAc,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAShD;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IASrE;;OAEG;IACH,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,WAAW,GAAE,MAAY,EAAE,SAAS,GAAE,MAAY,GAAG,IAAI;IAUzF;;OAEG;IACH,WAAW,IAAI,IAAI;IAmBnB;;OAEG;IACH,SAAS,CAAC,kBAAkB,IAAI,KAAK,CAAC,QAAQ;IAK9C;;OAEG;IACM,IAAI,IAAI,YAAY;CAW9B"}
@@ -0,0 +1,27 @@
1
+ import { Vector3Tuple } from '../../core/Mobject';
2
+ import { Arc } from '../geometry/Arc';
3
+ import { Text } from '../text/Text';
4
+ import { EdgeConfig, EdgeStyleOptions } from './graphTypes';
5
+ /** Default gap between a straight edge and its label. */
6
+ export declare const DEFAULT_EDGE_LABEL_BUFF = 0.2;
7
+ /**
8
+ * Return the text to render on an edge, or null when there is nothing to show.
9
+ *
10
+ * An explicit `label` wins. Otherwise a numeric `weight` renders as its string.
11
+ */
12
+ export declare function edgeLabelString(cfg?: EdgeConfig): string | null;
13
+ /**
14
+ * Build the loop arc for a self-loop edge. The arc is a near-full circle above
15
+ * the vertex. For a directed graph it carries an arrow tip at its end.
16
+ */
17
+ export declare function createSelfLoopEdge(vertexCenter: Vector3Tuple, vertexRadius: number, style: EdgeStyleOptions, directed: boolean): Arc;
18
+ /** Point at which to place the label of a self-loop edge (above the loop). */
19
+ export declare function selfLoopLabelPoint(vertexCenter: Vector3Tuple, vertexRadius: number, style: EdgeStyleOptions): Vector3Tuple;
20
+ /**
21
+ * Point at which to place the label of a straight edge: the midpoint, pushed
22
+ * perpendicular to the edge by `buff` so the text clears the line.
23
+ */
24
+ export declare function straightEdgeLabelPoint(start: Vector3Tuple, end: Vector3Tuple, buff: number): Vector3Tuple;
25
+ /** Build the text mobject for an edge label (a weight or an explicit label). */
26
+ export declare function createEdgeLabel(text: string, style: EdgeStyleOptions): Text;
27
+ //# sourceMappingURL=graphEdgeDecorations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphEdgeDecorations.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graph/graphEdgeDecorations.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAMjE,yDAAyD;AACzD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAW/D;AAcD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,OAAO,GAChB,GAAG,CAcL;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,gBAAgB,GACtB,YAAY,CAKd;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,YAAY,EACnB,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,MAAM,GACX,YAAY,CAed;AAED,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAM3E"}
@@ -38,6 +38,14 @@ export interface EdgeStyleOptions {
38
38
  tipLength?: number;
39
39
  /** For directed graphs, tip width. Default: 0.12 */
40
40
  tipWidth?: number;
41
+ /** Radius of a self-loop arc (edge from a vertex to itself). Default: 0.3 */
42
+ selfLoopRadius?: number;
43
+ /** Font size for a weight or label rendered on the edge. Default: 24 */
44
+ labelFontSize?: number;
45
+ /** Color for a weight or label rendered on the edge. Default: edge color */
46
+ labelColor?: string;
47
+ /** Gap between a straight edge and its label. Default: 0.2 */
48
+ labelBuff?: number;
41
49
  }
42
50
  /**
43
51
  * Configuration for a single vertex
@@ -1 +1 @@
1
- {"version":3,"file":"graphTypes.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graph/graphTypes.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvC;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,QAAQ,GACR,UAAU,GACV,OAAO,GACP,MAAM,GACN,QAAQ,GACR,MAAM,GACN,cAAc,GACd,UAAU,GACV,WAAW,GACX,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,WAAW,CAAC,EAAE,MA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M,CAAC;IACf,qDAAqD;IACrD,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IACrC,6CAA6C;IAC7C,SAAS,CAAC,EAAE,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,iCAAiC;IACjC,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IACtB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC;IACpB,2BAA2B;IAC3B,MAAM,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACnC,6BAA6B;IAC7B,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,2BAA2B;IAC3B,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,+BAA+B;IAC/B,YAAY,CAAC,EAAE,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC1E,sDAAsD;IACtD,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAClE,oDAAoD;IACpD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,mCAAmC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,mBAAmB,CAAC"}
@@ -0,0 +1,77 @@
1
+ import { VMobject } from '../../core/VMobject';
2
+ import { Axes } from './Axes';
3
+ /** A 2D scalar field g(x, y). */
4
+ export type ContourField = (x: number, y: number) => number;
5
+ /**
6
+ * Options for creating a ContourPlot.
7
+ */
8
+ export interface ContourPlotOptions {
9
+ /** The scalar field g(x, y). Contours are the level sets g = level. */
10
+ func: ContourField;
11
+ /** The iso levels to draw. Default: [-2, -1, 0, 1, 2] */
12
+ levels?: number[];
13
+ /** X range [min, max]. Default: [-5, 5] */
14
+ xRange?: [number, number];
15
+ /** Y range [min, max]. Default: [-5, 5] */
16
+ yRange?: [number, number];
17
+ /** Grid cells per axis for the marching-squares sampling. Default: 48 */
18
+ resolution?: number;
19
+ /** Stroke color. Default: '#58c4dd' (Manim blue) */
20
+ color?: string;
21
+ /** Stroke width in pixels. Default: 2 */
22
+ strokeWidth?: number;
23
+ /** Reference axes for coordinate transformation. Optional. */
24
+ axes?: Axes;
25
+ }
26
+ /**
27
+ * ContourPlot - iso-contour lines of a 2D scalar field g(x, y).
28
+ *
29
+ * The field is sampled on a regular grid, then marching squares (see
30
+ * {@link marchingSquares}) extracts the line segments of each requested level.
31
+ * The segments are drawn as one stroked VMobject with a path break between
32
+ * them, so disjoint contours and nested loops all render. When `axes` is given,
33
+ * segment endpoints map through `axes.coordsToPoint`, matching
34
+ * {@link ImplicitFunction}.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * // Concentric circles: g = x^2 + y^2 contoured at 1, 4, 9
39
+ * const contours = new ContourPlot({
40
+ * func: (x, y) => x * x + y * y,
41
+ * levels: [1, 4, 9],
42
+ * xRange: [-4, 4],
43
+ * yRange: [-4, 4],
44
+ * });
45
+ * ```
46
+ */
47
+ export declare class ContourPlot extends VMobject {
48
+ private _func;
49
+ private _levels;
50
+ private _xRange;
51
+ private _yRange;
52
+ private _resolution;
53
+ private _axes;
54
+ constructor(options: ContourPlotOptions);
55
+ /** Sample the field grid and return the values plus the coordinate axes. */
56
+ private _sampleGrid;
57
+ /** Collect contour segments across every requested level. */
58
+ private _contourSegments;
59
+ /** Map a field-space point to scene space through the axes, if any. */
60
+ private _toScene;
61
+ /** Convert a straight segment into four cubic-Bezier control points. */
62
+ private _segmentToBezier;
63
+ /** Build the stroked path from the contour segments. */
64
+ private _generatePoints;
65
+ /** Get the scalar field. */
66
+ getFunc(): ContourField;
67
+ /** Set the scalar field and rebuild the contours. */
68
+ setFunc(func: ContourField): this;
69
+ /** Get the contour levels. */
70
+ getLevels(): number[];
71
+ /** Set the contour levels and rebuild. */
72
+ setLevels(levels: number[]): this;
73
+ /** Set the reference axes and rebuild. */
74
+ setAxes(axes: Axes | null): this;
75
+ copy(): ContourPlot;
76
+ }
77
+ //# sourceMappingURL=ContourPlot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContourPlot.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/ContourPlot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,iCAAiC;AACjC,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,IAAI,EAAE,YAAY,CAAC;IACnB,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,2CAA2C;IAC3C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,WAAY,SAAQ,QAAQ;IACvC,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,KAAK,CAAc;gBAEf,OAAO,EAAE,kBAAkB;IA4BvC,4EAA4E;IAC5E,OAAO,CAAC,WAAW;IAoBnB,6DAA6D;IAC7D,OAAO,CAAC,gBAAgB;IASxB,uEAAuE;IACvE,OAAO,CAAC,QAAQ;IAIhB,wEAAwE;IACxE,OAAO,CAAC,gBAAgB;IAUxB,wDAAwD;IACxD,OAAO,CAAC,eAAe;IAsBvB,4BAA4B;IAC5B,OAAO,IAAI,YAAY;IAIvB,qDAAqD;IACrD,OAAO,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IAMjC,8BAA8B;IAC9B,SAAS,IAAI,MAAM,EAAE;IAIrB,0CAA0C;IAC1C,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI;IAMjC,0CAA0C;IAC1C,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI;IAMvB,IAAI,IAAI,WAAW;CAc7B"}
@@ -0,0 +1,85 @@
1
+ import { Vector3Tuple } from '../../core/Mobject';
2
+ import { Mobject3D } from '../three-d/Mobject3D';
3
+ import * as THREE from 'three';
4
+ /** A 2D scalar field g(x, y). */
5
+ export type ScalarField2D = (x: number, y: number) => number;
6
+ /**
7
+ * Options for creating a HeatMap.
8
+ */
9
+ export interface HeatMapOptions {
10
+ /** The scalar field g(x, y) to visualize. */
11
+ func: ScalarField2D;
12
+ /** X range [min, max]. Default: [-5, 5] */
13
+ xRange?: [number, number];
14
+ /** Y range [min, max]. Default: [-5, 5] */
15
+ yRange?: [number, number];
16
+ /** Grid cells per axis, or [nx, ny]. Default: 64 */
17
+ resolution?: number | [number, number];
18
+ /** Value domain [min, max] mapped across the palette. Auto-computed if omitted. */
19
+ domain?: [number, number];
20
+ /** Ordered hex color stops. Default: a viridis-like palette. */
21
+ palette?: readonly string[];
22
+ /** Blend the palette in perceptually-uniform Oklab space. Default: false */
23
+ useOklab?: boolean;
24
+ /** Opacity from 0 to 1. Default: 1 */
25
+ opacity?: number;
26
+ /** Center position [x, y, z]. Default: [0, 0, 0] */
27
+ center?: Vector3Tuple;
28
+ }
29
+ /**
30
+ * HeatMap - a colored plane that encodes a 2D scalar field g(x, y).
31
+ *
32
+ * The region is sampled on a regular grid and rendered as a flat mesh in the
33
+ * z = 0 plane. Each grid vertex is colored by its field value through a color
34
+ * map (see `colormap`), and the GPU interpolates the color across each cell,
35
+ * so the plane shows a smooth heat gradient. The value domain is taken from the
36
+ * sampled minimum and maximum unless an explicit `domain` is given.
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * // A 2D Gaussian bump
41
+ * const heat = new HeatMap({
42
+ * func: (x, y) => Math.exp(-(x * x + y * y) / 4),
43
+ * xRange: [-3, 3],
44
+ * yRange: [-3, 3],
45
+ * domain: [0, 1],
46
+ * });
47
+ * ```
48
+ */
49
+ export declare class HeatMap extends Mobject3D {
50
+ private _func;
51
+ private _xRange;
52
+ private _yRange;
53
+ private _nx;
54
+ private _ny;
55
+ private _palette;
56
+ private _useOklab;
57
+ private _centerPoint;
58
+ private _domain;
59
+ private _domainExplicit;
60
+ constructor(options: HeatMapOptions);
61
+ /** The x coordinate of grid column `ix`. */
62
+ private _coordX;
63
+ /** The y coordinate of grid row `iy`. */
64
+ private _coordY;
65
+ /** Scan the grid for the value range when no explicit domain is given. */
66
+ private _autoDomain;
67
+ /** Build the indexed plane geometry with a per-vertex color attribute. */
68
+ private _buildGeometry;
69
+ protected _createThreeObject(): THREE.Object3D;
70
+ protected _syncMaterialToThree(): void;
71
+ /** Rebuild the geometry after the field, domain, or palette changes. */
72
+ private _updateGeometry;
73
+ /** The color (hex) that the map assigns to the field at (x, y). */
74
+ colorAt(x: number, y: number): string;
75
+ /** The value domain [min, max] mapped across the palette. */
76
+ getDomain(): [number, number];
77
+ /** Set the value domain and rebuild. */
78
+ setDomain(domain: [number, number]): this;
79
+ /** Get the scalar field. */
80
+ getFunc(): ScalarField2D;
81
+ /** Set the scalar field and rebuild. Recomputes an auto domain if in use. */
82
+ setFunc(func: ScalarField2D): this;
83
+ copy(): HeatMap;
84
+ }
85
+ //# sourceMappingURL=HeatMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeatMap.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/HeatMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD,iCAAiC;AACjC,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,6CAA6C;IAC7C,IAAI,EAAE,aAAa,CAAC;IACpB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,2CAA2C;IAC3C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,mFAAmF;IACnF,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,gEAAgE;IAChE,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,OAAQ,SAAQ,SAAS;IACpC,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,eAAe,CAAU;gBAErB,OAAO,EAAE,cAAc;IAgCnC,4CAA4C;IAC5C,OAAO,CAAC,OAAO;IAKf,yCAAyC;IACzC,OAAO,CAAC,OAAO;IAKf,0EAA0E;IAC1E,OAAO,CAAC,WAAW;IAoBnB,0EAA0E;IAC1E,OAAO,CAAC,cAAc;IA2CtB,SAAS,CAAC,kBAAkB,IAAI,KAAK,CAAC,QAAQ;cAU3B,oBAAoB,IAAI,IAAI;IAY/C,wEAAwE;IACxE,OAAO,CAAC,eAAe;IASvB,mEAAmE;IACnE,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IAKrC,6DAA6D;IAC7D,SAAS,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IAI7B,wCAAwC;IACxC,SAAS,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAOzC,4BAA4B;IAC5B,OAAO,IAAI,aAAa;IAIxB,6EAA6E;IAC7E,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAOzB,IAAI,IAAI,OAAO;CAezB"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Perceptual color maps for scalar-field visualization.
3
+ *
4
+ * A color map is an ordered list of hex color stops spread evenly over the
5
+ * unit interval. {@link sampleColormap} reads a color for any `t` in 0..1 by
6
+ * blending the two surrounding stops. Blending runs in sRGB by default, or in
7
+ * perceptually-uniform Oklab (see `utils/oklab`) when `useOklab` is set, which
8
+ * keeps the midpoint of a palette bright instead of muddy.
9
+ */
10
+ /** A built-in viridis-like palette: dark blue through green to yellow. */
11
+ export declare const VIRIDIS: readonly string[];
12
+ /** A built-in warm palette: black through red and orange to white. */
13
+ export declare const INFERNO: readonly string[];
14
+ /** A simple blue-white-red diverging palette, centered on white. */
15
+ export declare const COOLWARM: readonly string[];
16
+ /**
17
+ * Sample a color map at position `t` in 0..1.
18
+ *
19
+ * `t` is clamped to 0..1. A palette with one stop returns that stop. Otherwise
20
+ * `t` is scaled across the stops and the two surrounding stops are blended.
21
+ *
22
+ * @param palette Ordered hex color stops. Must hold at least one color.
23
+ * @param t Position along the palette, clamped to 0..1.
24
+ * @param useOklab Blend in Oklab space for a perceptually-uniform result.
25
+ */
26
+ export declare function sampleColormap(palette: readonly string[], t: number, useOklab?: boolean): string;
27
+ /**
28
+ * Map a scalar `value` in the domain `[min, max]` to a color map color.
29
+ *
30
+ * The value is normalized to 0..1 across the domain, then clamped. A zero-width
31
+ * domain (`min === max`) maps every value to the first stop.
32
+ */
33
+ export declare function valueToColor(value: number, min: number, max: number, palette: readonly string[], useOklab?: boolean): string;
34
+ //# sourceMappingURL=colormap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colormap.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/colormap.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,0EAA0E;AAC1E,eAAO,MAAM,OAAO,EAAE,SAAS,MAAM,EAOpC,CAAC;AAEF,sEAAsE;AACtE,eAAO,MAAM,OAAO,EAAE,SAAS,MAAM,EAOpC,CAAC;AAEF,oEAAoE;AACpE,eAAO,MAAM,QAAQ,EAAE,SAAS,MAAM,EAAsC,CAAC;AAE7E;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,UAAQ,GAAG,MAAM,CAc9F;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,QAAQ,UAAQ,GACf,MAAM,CAIR"}
@@ -12,6 +12,10 @@ export { type VerticalLinesToGraphOptions, type SecantSlopeGroupOptions } from '
12
12
  export { NumberPlane, type NumberPlaneOptions, type BackgroundLineStyle } from './NumberPlane';
13
13
  export { FunctionGraph, type FunctionGraphOptions } from './FunctionGraph';
14
14
  export { ImplicitFunction, type ImplicitFunctionOptions } from './ImplicitFunction';
15
+ export { sampleColormap, valueToColor, VIRIDIS, INFERNO, COOLWARM } from './colormap';
16
+ export { marchingSquares, type ContourSegment } from './marchingSquares';
17
+ export { HeatMap, type HeatMapOptions, type ScalarField2D } from './HeatMap';
18
+ export { ContourPlot, type ContourPlotOptions, type ContourField } from './ContourPlot';
15
19
  export { ParametricFunction, type ParametricFunctionOptions } from './ParametricFunction';
16
20
  export { VectorFieldVector, type VectorFieldVectorOptions } from './Vector';
17
21
  export { ComplexPlane, type ComplexPlaneOptions, type Complex } from './ComplexPlane';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,UAAU,EACV,KAAK,iBAAiB,EACtB,YAAY,EACZ,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGhD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAGtF,OAAO,EAAE,KAAK,2BAA2B,EAAE,KAAK,uBAA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AK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,GAC7B,MAAM,eAAe,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Marching-squares iso-contour extraction for a 2D scalar field.
3
+ *
4
+ * The algorithm walks a regular grid of sampled values and emits the line
5
+ * segments of the iso-contour `value = iso` within each cell. Unlike the
6
+ * adaptive, zero-level marching squares embedded in {@link ImplicitFunction},
7
+ * this is a fixed-grid routine that takes an arbitrary iso level, so one grid
8
+ * can be contoured at many levels. {@link ContourPlot} uses it for that.
9
+ *
10
+ * A cell is classified by whether each of its four corners is above `iso`.
11
+ * The 16 cases map to zero, one, or two segments. Saddle cases (5 and 10) are
12
+ * resolved with the average of the four corners, the common asymptotic decider.
13
+ */
14
+ /** A line segment of an iso-contour, in field coordinates. */
15
+ export type ContourSegment = [[number, number], [number, number]];
16
+ /**
17
+ * Extract the iso-contour segments of a sampled scalar field.
18
+ *
19
+ * @param values Grid values indexed `values[iy][ix]`, dimensions
20
+ * `(ys.length) x (xs.length)`.
21
+ * @param xs The x coordinate of each grid column, length `nx + 1`.
22
+ * @param ys The y coordinate of each grid row, length `ny + 1`.
23
+ * @param iso The contour level. A corner is "set" when its value is above iso.
24
+ */
25
+ export declare function marchingSquares(values: number[][], xs: number[], ys: number[], iso?: number): ContourSegment[];
26
+ //# sourceMappingURL=marchingSquares.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marchingSquares.d.ts","sourceRoot":"","sources":["../../../src/mobjects/graphing/marchingSquares.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,8DAA8D;AAC9D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AA8ElE;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EAAE,EAAE,EAClB,EAAE,EAAE,MAAM,EAAE,EACZ,EAAE,EAAE,MAAM,EAAE,EACZ,GAAG,SAAI,GACN,cAAc,EAAE,CA6ClB"}
@@ -0,0 +1,122 @@
1
+ import { Vector3Tuple } from '../../core/Mobject';
2
+ import { Mobject3D } from './Mobject3D';
3
+ import { ScalarField3D } from './marchingCubes';
4
+ import * as THREE from 'three';
5
+ /**
6
+ * Options for creating an ImplicitSurface.
7
+ */
8
+ export interface ImplicitSurfaceOptions {
9
+ /** The scalar field f(x, y, z). The surface is the level set f = isoLevel. */
10
+ func: ScalarField3D;
11
+ /** X range [min, max]. Default: [-2, 2] */
12
+ xRange?: [number, number];
13
+ /** Y range [min, max]. Default: [-2, 2] */
14
+ yRange?: [number, number];
15
+ /** Z range [min, max]. Default: [-2, 2] */
16
+ zRange?: [number, number];
17
+ /** Grid cells per axis for the marching-cubes sampling. Default: 24 */
18
+ resolution?: number;
19
+ /** The iso level of the extracted surface. Default: 0 */
20
+ isoLevel?: number;
21
+ /** Color as CSS color string. Default: '#58c4dd' (Manim blue) */
22
+ color?: string;
23
+ /** Opacity from 0 to 1. Default: 1 */
24
+ opacity?: number;
25
+ /** Render as wireframe. Default: false */
26
+ wireframe?: boolean;
27
+ /** Render both sides. Default: true */
28
+ doubleSided?: boolean;
29
+ /** Center position [x, y, z]. Default: [0, 0, 0] */
30
+ center?: Vector3Tuple;
31
+ }
32
+ /**
33
+ * ImplicitSurface - the 3D isosurface f(x, y, z) = isoLevel.
34
+ *
35
+ * The surface is built with marching cubes (see {@link marchingCubes}) over a
36
+ * sampled grid, so an arbitrary smooth scalar field can be visualised without a
37
+ * parametrisation. It extends {@link Mobject3D} and reuses the Surface3D
38
+ * material and depth conventions, including the transparent depth prepass from
39
+ * issue #416, so a translucent isosurface occludes itself correctly.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * // A unit sphere: x^2 + y^2 + z^2 = 1
44
+ * const sphere = new ImplicitSurface({
45
+ * func: (x, y, z) => x * x + y * y + z * z,
46
+ * isoLevel: 1,
47
+ * resolution: 32,
48
+ * });
49
+ *
50
+ * // A torus implicit surface
51
+ * const torus = new ImplicitSurface({
52
+ * func: (x, y, z) => {
53
+ * const q = Math.sqrt(x * x + y * y) - 1;
54
+ * return q * q + z * z;
55
+ * },
56
+ * isoLevel: 0.09,
57
+ * opacity: 0.6,
58
+ * });
59
+ * ```
60
+ */
61
+ export declare class ImplicitSurface extends Mobject3D {
62
+ private _func;
63
+ private _xRange;
64
+ private _yRange;
65
+ private _zRange;
66
+ private _resolution;
67
+ private _isoLevel;
68
+ private _wireframe;
69
+ private _doubleSided;
70
+ private _centerPoint;
71
+ private _positions;
72
+ private _triangleCount;
73
+ constructor(options: ImplicitSurfaceOptions);
74
+ /** Run marching cubes and cache the resulting triangle soup. */
75
+ private _computeSurface;
76
+ /** Build an indexed-free BufferGeometry with smooth normals from the cache. */
77
+ private _buildGeometry;
78
+ /**
79
+ * The depth prepass only helps a translucent solid. An opaque surface
80
+ * already writes depth, a wireframe must stay visible, and a faded-out
81
+ * surface must not depth-block other transparent objects.
82
+ */
83
+ private _prepassEnabled;
84
+ /** Enable or disable the prepass; disabled means skipped by the renderer. */
85
+ private _applyPrepassState;
86
+ /** Find the depth-prepass child mesh, if this surface has one. */
87
+ private _getPrepassMesh;
88
+ /**
89
+ * Create the Three.js mesh. A transparent surface renders in two passes to
90
+ * fix self-occlusion (issue #416): a depth-only prepass writes the front-most
91
+ * layer, then the color pass depth-tests against it. The prepass mesh is
92
+ * created before the color mesh so its lower object.id wins three.js'
93
+ * reversePainterSortStable tiebreak and draws first.
94
+ */
95
+ protected _createThreeObject(): THREE.Object3D;
96
+ /** Sync material properties to the Three.js object. */
97
+ protected _syncMaterialToThree(): void;
98
+ /** Recompute the surface and rebind the geometry on both meshes. */
99
+ private _updateGeometry;
100
+ /** The flat vertex positions of the surface triangles. */
101
+ getPositions(): Float32Array;
102
+ /** The number of triangles in the surface. */
103
+ getTriangleCount(): number;
104
+ /** Get the scalar field. */
105
+ getFunc(): ScalarField3D;
106
+ /** Set a new scalar field and rebuild the surface. */
107
+ setFunc(func: ScalarField3D): this;
108
+ /** Get the iso level. */
109
+ getIsoLevel(): number;
110
+ /** Set the iso level and rebuild the surface. */
111
+ setIsoLevel(isoLevel: number): this;
112
+ /** Get the grid resolution. */
113
+ getResolution(): number;
114
+ /** Set the grid resolution and rebuild the surface. */
115
+ setResolution(resolution: number): this;
116
+ /** Whether wireframe mode is enabled. */
117
+ isWireframe(): boolean;
118
+ /** Set wireframe mode. */
119
+ setWireframe(value: boolean): this;
120
+ copy(): ImplicitSurface;
121
+ }
122
+ //# sourceMappingURL=ImplicitSurface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImplicitSurface.d.ts","sourceRoot":"","sources":["../../../src/mobjects/three-d/ImplicitSurface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,8EAA8E;IAC9E,IAAI,EAAE,aAAa,CAAC;IACpB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,2CAA2C;IAC3C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,2CAA2C;IAC3C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0CAA0C;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AAG,IAAI;IAMnC,+BAA+B;IAC/B,aAAa,IAAI,MAAM;IAIvB,uDAAuD;IACvD,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAMvC,yCAAyC;IACzC,WAAW,IAAI,OAAO;IAItB,0BAA0B;IAC1B,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAMzB,IAAI,IAAI,eAAe;CAiBjC"}
@@ -18,4 +18,6 @@ export { TexturedSurface, texturedSphere, type TexturedSurfaceOptions, type Text
18
18
  export { ThreeDAxes, type ThreeDAxesOptions } from './ThreeDAxes';
19
19
  export { Prism, Dot3D, ThreeDVMobject, type PrismOptions, type Dot3DOptions, type ThreeDVMobjectOptions, } from './ThreeDExtensions';
20
20
  export { ConvexHull3D, type ConvexHull3DOptions } from './ConvexHull3D';
21
+ export { marchingCubes, type MarchingCubesOptions, type MarchingCubesResult, type ScalarField3D, } from './marchingCubes';
22
+ export { ImplicitSurface, type ImplicitSurfaceOptions } from './ImplicitSurface';
21
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mobjects/three-d/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACpF,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAGnD,OAAO,EACL,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,YAAY,EACZ,KAAK,iBAAiB,EACtB,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,MAAM,SAAS,CAAC;AAGnD,OAAO,EACL,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAGnE,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,KAAK,wBAAwB,GAC9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,eAAe,EACf,cAAc,EACd,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,GAC3B,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGlE,OAAO,EACL,KAAK,EACL,KAAK,EACL,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,qBAAqB,GAC3B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGxE,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,aAAa,GACnB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Marching-cubes isosurface extraction for a 3D scalar field.
3
+ *
4
+ * The algorithm samples a scalar field `f(x, y, z)` on a regular grid and
5
+ * extracts the triangle mesh of the level set `f = iso`. This module uses the
6
+ * marching-tetrahedra variant: it splits every grid cube into six tetrahedra
7
+ * that share the cube's main diagonal, then polygonises each tetrahedron. The
8
+ * tetrahedral form needs no 256-entry lookup table, so it is compact and
9
+ * watertight, at the cost of more triangles than classic marching cubes.
10
+ *
11
+ * The output is a non-indexed triangle soup as a flat `Float32Array`. Three.js
12
+ * recomputes smooth normals from it, and manim-web renders the surface
13
+ * double-sided, so triangle winding does not affect the shaded result.
14
+ */
15
+ /** A scalar field sampled at a point in space. */
16
+ export type ScalarField3D = (x: number, y: number, z: number) => number;
17
+ /** Options that control how the grid is sampled. */
18
+ export interface MarchingCubesOptions {
19
+ /** The scalar field to polygonise. */
20
+ field: ScalarField3D;
21
+ /** X range as [min, max]. */
22
+ xRange: [number, number];
23
+ /** Y range as [min, max]. */
24
+ yRange: [number, number];
25
+ /** Z range as [min, max]. */
26
+ zRange: [number, number];
27
+ /** Grid cells per axis. A higher value gives a finer surface. */
28
+ resolution: number;
29
+ /** The iso level of the extracted surface. */
30
+ isoLevel: number;
31
+ }
32
+ /** The polygonised surface as a non-indexed triangle soup. */
33
+ export interface MarchingCubesResult {
34
+ /** Flat vertex positions: `[x0, y0, z0, x1, y1, z1, ...]`. */
35
+ positions: Float32Array;
36
+ /** The number of triangles. */
37
+ triangleCount: number;
38
+ }
39
+ /**
40
+ * Extract the isosurface `field = isoLevel` over the sampled grid.
41
+ *
42
+ * The grid holds `resolution` cells per axis, so it samples
43
+ * `(resolution + 1)^3` points. Field values are evaluated once per grid point
44
+ * and cached, so the output is deterministic for a given input.
45
+ */
46
+ export declare function marchingCubes(options: MarchingCubesOptions): MarchingCubesResult;
47
+ //# sourceMappingURL=marchingCubes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marchingCubes.d.ts","sourceRoot":"","sources":["../../../src/mobjects/three-d/marchingCubes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,kDAAkD;AAClD,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAExE,oDAAoD;AACpD,MAAM,WAAW,oBAAoB;IACnC,sCAAsC;IACtC,KAAK,EAAE,aAAa,CAAC;IACrB,6BAA6B;IAC7B,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzB,6BAA6B;IAC7B,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzB,6BAA6B;IAC7B,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzB,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,8DAA8D;AAC9D,MAAM,WAAW,mBAAmB;IAClC,8DAA8D;IAC9D,SAAS,EAAE,YAAY,CAAC;IACxB,+BAA+B;IAC/B,aAAa,EAAE,MAAM,CAAC;CACvB;AA8FD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,mBAAmB,CA8DhF"}