manim-web 0.16.0 → 0.18.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 (37) hide show
  1. package/dist/MTLLoader-C4f4JmoY.js +169 -0
  2. package/dist/MTLLoader-CuV0f5vX.js +169 -0
  3. package/dist/index.d.ts +3 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +3 -3
  6. package/dist/integrations/react.js +17 -17
  7. package/dist/integrations/vue.js +16 -16
  8. package/dist/manim-web.browser.js +2331 -1623
  9. package/dist/mobjects/graph/DiGraph.d.ts.map +1 -1
  10. package/dist/mobjects/graph/GenericGraph.d.ts +15 -0
  11. package/dist/mobjects/graph/GenericGraph.d.ts.map +1 -1
  12. package/dist/mobjects/graph/graphEdgeDecorations.d.ts +27 -0
  13. package/dist/mobjects/graph/graphEdgeDecorations.d.ts.map +1 -0
  14. package/dist/mobjects/graph/graphTypes.d.ts +8 -0
  15. package/dist/mobjects/graph/graphTypes.d.ts.map +1 -1
  16. package/dist/mobjects/graphing/ContourPlot.d.ts +77 -0
  17. package/dist/mobjects/graphing/ContourPlot.d.ts.map +1 -0
  18. package/dist/mobjects/graphing/HeatMap.d.ts +85 -0
  19. package/dist/mobjects/graphing/HeatMap.d.ts.map +1 -0
  20. package/dist/mobjects/graphing/colormap.d.ts +34 -0
  21. package/dist/mobjects/graphing/colormap.d.ts.map +1 -0
  22. package/dist/mobjects/graphing/index.d.ts +4 -0
  23. package/dist/mobjects/graphing/index.d.ts.map +1 -1
  24. package/dist/mobjects/graphing/marchingSquares.d.ts +26 -0
  25. package/dist/mobjects/graphing/marchingSquares.d.ts.map +1 -0
  26. package/dist/mobjects/three-d/ImplicitSurface.d.ts +122 -0
  27. package/dist/mobjects/three-d/ImplicitSurface.d.ts.map +1 -0
  28. package/dist/mobjects/three-d/ModelMobject.d.ts +19 -1
  29. package/dist/mobjects/three-d/ModelMobject.d.ts.map +1 -1
  30. package/dist/mobjects/three-d/index.d.ts +2 -0
  31. package/dist/mobjects/three-d/index.d.ts.map +1 -1
  32. package/dist/mobjects/three-d/marchingCubes.d.ts +47 -0
  33. package/dist/mobjects/three-d/marchingCubes.d.ts.map +1 -0
  34. package/dist/mobjects/three-d/objMaterials.d.ts +54 -0
  35. package/dist/mobjects/three-d/objMaterials.d.ts.map +1 -0
  36. package/dist/{src-CIYJhSa5.js → src-DfxRF-kW.js} +2266 -1558
  37. package/package.json +1 -1
@@ -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"}
@@ -0,0 +1,54 @@
1
+ import { ModelLoader } from './ModelMobject';
2
+ /** A preloaded MTL material set. Three.js MaterialCreator satisfies it. */
3
+ export interface MtlMaterials {
4
+ preload(): void;
5
+ }
6
+ /**
7
+ * The minimal MTLLoader contract ModelMobject needs. Three.js MTLLoader
8
+ * satisfies it structurally. Tests implement it with a stub.
9
+ */
10
+ export interface MtlLoader {
11
+ setPath(path: string): MtlLoader;
12
+ setResourcePath(path: string): MtlLoader;
13
+ loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<MtlMaterials>;
14
+ }
15
+ /**
16
+ * The OBJLoader subset that accepts materials. OBJLoader.setMaterials applies
17
+ * the given materials to the meshes it then parses.
18
+ */
19
+ export interface ObjMaterialSink {
20
+ setMaterials(materials: MtlMaterials): void;
21
+ }
22
+ /** Builds an MTLLoader. The DI seam set by `setMtlLoaderFactory`. */
23
+ export type MtlLoaderFactory = () => MtlLoader | Promise<MtlLoader>;
24
+ /** The options that drive OBJ material loading. A subset of ModelMobjectOptions. */
25
+ export interface ObjMaterialOptions {
26
+ /** Explicit companion .mtl URL. Takes priority over `loadMaterials`. */
27
+ mtlUrl?: string;
28
+ /** Auto-derive the .mtl URL from the .obj URL and load it. Default: false. */
29
+ loadMaterials?: boolean;
30
+ /** Inject an MTLLoader directly (bypasses the factory and the network). */
31
+ mtlLoader?: MtlLoader;
32
+ /** Progress callback forwarded to the MTLLoader. */
33
+ onProgress?: (event: ProgressEvent) => void;
34
+ }
35
+ /**
36
+ * Inject an MTLLoader factory, replacing the lazy-loaded Three.js MTLLoader.
37
+ * Pass `null` to restore the default. Tests use this to avoid any real loader.
38
+ */
39
+ export declare function setMtlLoaderFactory(factory: MtlLoaderFactory | null): void;
40
+ /** The directory part of a URL, with its trailing slash; ignores query and fragment. */
41
+ export declare function deriveBasePath(url: string): string;
42
+ /** The companion .mtl URL for an .obj URL (same name, .mtl extension). */
43
+ export declare function deriveMtlUrl(objUrl: string): string;
44
+ /**
45
+ * Load the companion .mtl and hand its materials to the OBJ loader before it
46
+ * parses. Call this on the resolved OBJ loader before `loadAsync`.
47
+ *
48
+ * It is a no-op when neither `mtlUrl` nor `loadMaterials` is set (so an OBJ
49
+ * loads exactly as before), and when the loader cannot accept materials. The
50
+ * MTLLoader base path and resource path come from the .mtl URL, so texture maps
51
+ * named in the .mtl load from the same directory.
52
+ */
53
+ export declare function applyObjMaterials(loader: ModelLoader, objUrl: string, options: ObjMaterialOptions): Promise<void>;
54
+ //# sourceMappingURL=objMaterials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objMaterials.d.ts","sourceRoot":"","sources":["../../../src/mobjects/three-d/objMaterials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,2EAA2E;AAC3E,MAAM,WAAW,YAAY;IAC3B,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC5F;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,SAAS,EAAE,YAAY,GAAG,IAAI,CAAC;CAC7C;AAED,qEAAqE;AACrE,MAAM,MAAM,gBAAgB,GAAG,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAEpE,oFAAoF;AACpF,MAAM,WAAW,kBAAkB;IACjC,wEAAwE;IACxE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,oDAAoD;IACpD,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAC7C;AAKD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAE1E;AAeD,wFAAwF;AACxF,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIlD;AASD,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAGnD;AAcD;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAWf"}