manim-web 0.3.24 → 0.11.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 (145) hide show
  1. package/README.md +5 -1
  2. package/dist/GLTFLoader-CisHz7tR.js +1381 -0
  3. package/dist/GLTFLoader-DMbWuMln.js +1381 -0
  4. package/dist/{MathJaxBundle-xSidSV0E.js → MathJaxBundle-BSrlS0Dh.js} +3338 -3320
  5. package/dist/OBJLoader-Clh2POv9.js +287 -0
  6. package/dist/OBJLoader-kkTsEhJf.js +287 -0
  7. package/dist/animation/Always.d.ts +72 -0
  8. package/dist/animation/Always.d.ts.map +1 -0
  9. package/dist/animation/AlwaysRedraw.d.ts +15 -0
  10. package/dist/animation/AlwaysRedraw.d.ts.map +1 -0
  11. package/dist/animation/Animation.d.ts +9 -0
  12. package/dist/animation/Animation.d.ts.map +1 -1
  13. package/dist/animation/AnimationUtilities.d.ts +25 -0
  14. package/dist/animation/AnimationUtilities.d.ts.map +1 -1
  15. package/dist/animation/creation/Create.d.ts +40 -11
  16. package/dist/animation/creation/Create.d.ts.map +1 -1
  17. package/dist/animation/transform/PointMorphStrategy.d.ts +6 -0
  18. package/dist/animation/transform/PointMorphStrategy.d.ts.map +1 -1
  19. package/dist/animation/transform/Transform.d.ts.map +1 -1
  20. package/dist/animation/transform/TransformPairing.d.ts +17 -0
  21. package/dist/animation/transform/TransformPairing.d.ts.map +1 -1
  22. package/dist/animation/updaters.d.ts +69 -0
  23. package/dist/animation/updaters.d.ts.map +1 -0
  24. package/dist/compiler-CfW6eH2M.js +2 -0
  25. package/dist/constants/index.d.ts +1 -0
  26. package/dist/constants/index.d.ts.map +1 -1
  27. package/dist/constants/parity.d.ts +78 -0
  28. package/dist/constants/parity.d.ts.map +1 -0
  29. package/dist/core/Mobject.d.ts +48 -3
  30. package/dist/core/Mobject.d.ts.map +1 -1
  31. package/dist/core/MobjectTraversal.d.ts +7 -0
  32. package/dist/core/MobjectTraversal.d.ts.map +1 -1
  33. package/dist/core/MobjectTypes.d.ts +15 -0
  34. package/dist/core/MobjectTypes.d.ts.map +1 -1
  35. package/dist/core/Scene.d.ts +14 -0
  36. package/dist/core/Scene.d.ts.map +1 -1
  37. package/dist/core/SpecialThreeDScene.d.ts +64 -0
  38. package/dist/core/SpecialThreeDScene.d.ts.map +1 -0
  39. package/dist/core/VMobject.d.ts +143 -0
  40. package/dist/core/VMobject.d.ts.map +1 -1
  41. package/dist/core/VMobjectColorGradient.d.ts +20 -0
  42. package/dist/core/VMobjectColorGradient.d.ts.map +1 -0
  43. package/dist/core/VMobjectCurveMath.d.ts +128 -0
  44. package/dist/core/VMobjectCurveMath.d.ts.map +1 -0
  45. package/dist/core/VMobjectRendering.d.ts +38 -1
  46. package/dist/core/VMobjectRendering.d.ts.map +1 -1
  47. package/dist/core/VMobjectRoundCorners.d.ts +37 -0
  48. package/dist/core/VMobjectRoundCorners.d.ts.map +1 -0
  49. package/dist/esm-CiMKSfxz.js +1273 -0
  50. package/dist/export/FrameExporter.d.ts +86 -0
  51. package/dist/export/FrameExporter.d.ts.map +1 -0
  52. package/dist/export/GifExporter.d.ts +4 -0
  53. package/dist/export/GifExporter.d.ts.map +1 -1
  54. package/dist/export/WebCodecsExporter.d.ts +108 -0
  55. package/dist/export/WebCodecsExporter.d.ts.map +1 -0
  56. package/dist/export/index.d.ts +2 -0
  57. package/dist/export/index.d.ts.map +1 -1
  58. package/dist/global-compiler-D_nF-JaV.js +8 -0
  59. package/dist/global-renderer-gyshX_QF.js +8 -0
  60. package/dist/index.d.ts +29 -4
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +3 -2
  63. package/dist/integrations/react.js +17 -16
  64. package/dist/integrations/vue.js +16 -15
  65. package/dist/integrations/webcomponent.d.ts +65 -0
  66. package/dist/integrations/webcomponent.d.ts.map +1 -0
  67. package/dist/integrations/webcomponent.js +2 -0
  68. package/dist/manim-web.browser.js +36877 -45066
  69. package/dist/mobjects/geometry/AngleShapes.d.ts.map +1 -1
  70. package/dist/mobjects/geometry/ArcPolygon.d.ts +30 -0
  71. package/dist/mobjects/geometry/ArcPolygon.d.ts.map +1 -1
  72. package/dist/mobjects/geometry/DashedLine.d.ts.map +1 -1
  73. package/dist/mobjects/geometry/Label.d.ts +32 -0
  74. package/dist/mobjects/geometry/Label.d.ts.map +1 -0
  75. package/dist/mobjects/geometry/index.d.ts +2 -1
  76. package/dist/mobjects/geometry/index.d.ts.map +1 -1
  77. package/dist/mobjects/graphing/Axes.d.ts +73 -6
  78. package/dist/mobjects/graphing/Axes.d.ts.map +1 -1
  79. package/dist/mobjects/graphing/CoordinateSystem.d.ts +40 -0
  80. package/dist/mobjects/graphing/CoordinateSystem.d.ts.map +1 -0
  81. package/dist/mobjects/graphing/axes-calculus.d.ts +79 -0
  82. package/dist/mobjects/graphing/axes-calculus.d.ts.map +1 -0
  83. package/dist/mobjects/graphing/index.d.ts +3 -0
  84. package/dist/mobjects/graphing/index.d.ts.map +1 -1
  85. package/dist/mobjects/graphing/scale.d.ts +72 -0
  86. package/dist/mobjects/graphing/scale.d.ts.map +1 -0
  87. package/dist/mobjects/text/MathJaxRenderer.d.ts +5 -0
  88. package/dist/mobjects/text/MathJaxRenderer.d.ts.map +1 -1
  89. package/dist/mobjects/text/MathTex.d.ts +23 -0
  90. package/dist/mobjects/text/MathTex.d.ts.map +1 -1
  91. package/dist/mobjects/text/MathTexImage.d.ts.map +1 -1
  92. package/dist/mobjects/text/Text.d.ts +53 -0
  93. package/dist/mobjects/text/Text.d.ts.map +1 -1
  94. package/dist/mobjects/text/Typst.d.ts +113 -0
  95. package/dist/mobjects/text/Typst.d.ts.map +1 -0
  96. package/dist/mobjects/text/TypstRenderer.d.ts +57 -0
  97. package/dist/mobjects/text/TypstRenderer.d.ts.map +1 -0
  98. package/dist/mobjects/text/index.d.ts +5 -2
  99. package/dist/mobjects/text/index.d.ts.map +1 -1
  100. package/dist/mobjects/text/katexStyles.d.ts +5 -0
  101. package/dist/mobjects/text/katexStyles.d.ts.map +1 -1
  102. package/dist/mobjects/text/registerFont.d.ts +38 -0
  103. package/dist/mobjects/text/registerFont.d.ts.map +1 -0
  104. package/dist/mobjects/text/textStyleRuns.d.ts +111 -0
  105. package/dist/mobjects/text/textStyleRuns.d.ts.map +1 -0
  106. package/dist/mobjects/three-d/ModelMobject.d.ts +122 -0
  107. package/dist/mobjects/three-d/ModelMobject.d.ts.map +1 -0
  108. package/dist/mobjects/three-d/ThreeDAxes.d.ts +37 -4
  109. package/dist/mobjects/three-d/ThreeDAxes.d.ts.map +1 -1
  110. package/dist/mobjects/three-d/threeDVmobUtils.d.ts +25 -0
  111. package/dist/mobjects/three-d/threeDVmobUtils.d.ts.map +1 -0
  112. package/dist/mobjects/video/VideoMobject.d.ts +126 -0
  113. package/dist/mobjects/video/VideoMobject.d.ts.map +1 -0
  114. package/dist/mobjects/video/index.d.ts +2 -0
  115. package/dist/mobjects/video/index.d.ts.map +1 -0
  116. package/dist/mp4-muxer-5DGKGEJk.js +900 -0
  117. package/dist/player/Player.d.ts +4 -0
  118. package/dist/player/Player.d.ts.map +1 -1
  119. package/dist/renderer-DR_79fB0.js +2 -0
  120. package/dist/{src-Cc3xTIkV.js → src-C817VR8M.js} +10693 -7971
  121. package/dist/three.core-1aHSpGwp.js +11626 -0
  122. package/dist/utils/ManimColor.d.ts +163 -0
  123. package/dist/utils/ManimColor.d.ts.map +1 -0
  124. package/dist/utils/bezier.d.ts +95 -0
  125. package/dist/utils/bezier.d.ts.map +1 -0
  126. package/dist/utils/color.d.ts +99 -0
  127. package/dist/utils/color.d.ts.map +1 -0
  128. package/dist/utils/debug.d.ts +36 -0
  129. package/dist/utils/debug.d.ts.map +1 -0
  130. package/dist/utils/iterables.d.ts +162 -0
  131. package/dist/utils/iterables.d.ts.map +1 -0
  132. package/dist/utils/paths.d.ts +38 -0
  133. package/dist/utils/paths.d.ts.map +1 -0
  134. package/dist/utils/simpleFunctions.d.ts +26 -0
  135. package/dist/utils/simpleFunctions.d.ts.map +1 -0
  136. package/dist/utils/spaceOps.d.ts +119 -0
  137. package/dist/utils/spaceOps.d.ts.map +1 -0
  138. package/dist/utils/unit.d.ts +28 -0
  139. package/dist/utils/unit.d.ts.map +1 -0
  140. package/dist/wasm-CIlzm7By.js +76 -0
  141. package/dist/wasm-pack-shim-B3C4KoWa.js +1688 -0
  142. package/dist/wasm-pack-shim-BgTFpSvJ.js +911 -0
  143. package/dist/webcomponent-BS5WnkDO.js +707 -0
  144. package/dist/webm-muxer-BGY-Mgbp.js +857 -0
  145. package/package.json +19 -8
@@ -2,6 +2,7 @@ import { Vector3Tuple } from '../../core/Mobject';
2
2
  import { TexturedMobject } from '../../core/TexturedMobject';
3
3
  import { TextGlyphGroup } from './TextGlyphGroup';
4
4
  import { SkeletonizeOptions } from '../../utils/skeletonize';
5
+ import { TextStyleMaps, TextStyleRun, StyledTextParams } from './textStyleRuns';
5
6
  import * as THREE from 'three';
6
7
  /**
7
8
  * Options for creating a Text mobject
@@ -31,6 +32,21 @@ export interface TextOptions {
31
32
  textAlign?: 'left' | 'center' | 'right';
32
33
  /** URL to a font file (OTF/TTF) for glyph vector extraction. When provided, loadGlyphs() can extract glyph outlines for stroke-draw animation. */
33
34
  fontUrl?: string;
35
+ /** Per-substring color map (text-to-color), as in Manim CE. Colors every occurrence of each substring. */
36
+ t2c?: Record<string, string>;
37
+ /** Per-substring font-weight map (text-to-weight), e.g. { bold: 'bold' }. */
38
+ t2w?: Record<string, string | number>;
39
+ /** Per-substring font-style map (text-to-slant), e.g. { x: 'italic' }. */
40
+ t2s?: Record<string, string>;
41
+ /**
42
+ * Linear color gradient fill, as in Manim CE `Text(..., gradient=(A, B, ...))`.
43
+ * Provide 2+ CSS colors. The text fills with a horizontal left-to-right
44
+ * gradient that spans its rendered box, with the colors evenly spaced across
45
+ * [0, 1]. The gradient takes precedence over the flat `color`. It composes
46
+ * with `t2c`: a substring colored by `t2c` keeps that color, and only the
47
+ * remaining (un-colored) characters take the gradient.
48
+ */
49
+ gradient?: string[];
34
50
  }
35
51
  export declare class Text extends TexturedMobject {
36
52
  protected _text: string;
@@ -45,6 +61,10 @@ export declare class Text extends TexturedMobject {
45
61
  protected _textAlign: 'left' | 'center' | 'right';
46
62
  /** Optional font URL for glyph vector extraction */
47
63
  protected _fontUrl?: string;
64
+ /** Per-substring style maps (t2c/t2w/t2s). Empty when no styling requested. */
65
+ protected _styleMaps: TextStyleMaps;
66
+ /** Linear color gradient (2+ colors), or null when the fill is flat. */
67
+ protected _gradient: string[] | null;
48
68
  /** Cached glyph group (created lazily by loadGlyphs) */
49
69
  protected _glyphGroup: TextGlyphGroup | null;
50
70
  /** Off-screen canvas for text rendering */
@@ -72,6 +92,24 @@ export declare class Text extends TexturedMobject {
72
92
  * @returns this for chaining
73
93
  */
74
94
  setText(text: string): this;
95
+ /**
96
+ * Get the per-substring style layout model: lines of styled runs.
97
+ *
98
+ * This is the testable model behind `t2c`/`t2w`/`t2s`. A run's null fields
99
+ * fall back to the Text base color/weight/style at render time.
100
+ */
101
+ getStyledTextLines(): TextStyleRun[][];
102
+ /**
103
+ * Get the configured linear gradient colors, or null when the fill is flat.
104
+ * Returns a copy so callers cannot mutate the internal state.
105
+ */
106
+ getGradient(): string[] | null;
107
+ /**
108
+ * True when this Text renders through the styled-run canvas path: either a
109
+ * per-substring style map (t2c/t2w/t2s) or an active color gradient is set.
110
+ * Plain Text with none of these keeps the original flat render path.
111
+ */
112
+ protected _usesStyledPath(): boolean;
75
113
  /**
76
114
  * Get the current font size
77
115
  */
@@ -121,6 +159,21 @@ export declare class Text extends TexturedMobject {
121
159
  * Draw text with custom letter spacing
122
160
  */
123
161
  protected _drawTextWithLetterSpacing(text: string, startX: number, y: number, _fontSize: number): void;
162
+ /** Collect the style and layout fields the styled canvas path needs. */
163
+ protected _styledTextParams(): StyledTextParams;
164
+ /**
165
+ * Measure styled (t2c/t2w/t2s) text via the shared styled-run layout helper.
166
+ */
167
+ protected _measureStyledText(): {
168
+ lines: string[];
169
+ width: number;
170
+ height: number;
171
+ };
172
+ /**
173
+ * Render styled (t2c/t2w/t2s) text through the shared styled-run renderer,
174
+ * then store the resulting world-space size.
175
+ */
176
+ protected _renderStyledToCanvas(): void;
124
177
  /**
125
178
  * Update the mesh geometry to match new dimensions
126
179
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../src/mobjects/text/Text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAOlE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sFAAsF;IACtF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IACxC,kJAAkJ;IAClJ,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAkFD,qBA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H,SAAS,CAAC,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAY9C;;OAEG;IACM,OAAO,IAAI,IAAI;CAUzB"}
@@ -0,0 +1,113 @@
1
+ import { VGroup } from '../../core/VGroup';
2
+ import { Vector3Tuple } from '../../core/Mobject';
3
+ export interface TypstOptions {
4
+ /** Typst markup to compile. For `MathTypst`, math-mode content without `$`. */
5
+ typst: string;
6
+ /** Color as CSS color string. Default: WHITE ('#ffffff'). */
7
+ color?: string;
8
+ /** Scale factor (1 = standard size). Default: DEFAULT_FONT_SIZE_PT. */
9
+ fontSize?: number;
10
+ /** Position in 3D space. Default: [0, 0, 0]. */
11
+ position?: Vector3Tuple;
12
+ /** Stroke width for glyph outlines. Default: 0.00001. */
13
+ strokeWidth?: number;
14
+ /** Fill opacity for glyph interiors. Default: 1. */
15
+ fillOpacity?: number;
16
+ /** Explicit target height in world units. Overrides fontSize scaling. */
17
+ height?: number;
18
+ }
19
+ /** Options for `MathTypst` (identical shape to `TypstOptions`). */
20
+ export type MathTypstOptions = TypstOptions;
21
+ export declare class Typst extends VGroup {
22
+ /** Raw markup the user passed (before any math-mode wrapping). */
23
+ protected _typst: string;
24
+ /** Actual source compiled by Typst (wrapped for math mode in `MathTypst`). */
25
+ protected _source: string;
26
+ protected _fontSize: number;
27
+ protected _color: string;
28
+ protected _svgStrokeWidth: number;
29
+ protected _svgFillOpacity: number;
30
+ protected _targetHeight: number | undefined;
31
+ /** Promise that resolves when rendering is complete. */
32
+ protected _renderPromise: Promise<void> | null;
33
+ /** Error from rendering, if any. */
34
+ protected _renderError: Error | null;
35
+ constructor(options: TypstOptions);
36
+ /**
37
+ * Build the Typst source actually compiled from the user's markup.
38
+ * The base `Typst` compiles the markup verbatim; `MathTypst` overrides this to
39
+ * wrap the markup in math-mode delimiters.
40
+ *
41
+ * Pure (depends only on its argument), so it is safe to call from the base
42
+ * constructor before subclass fields initialize.
43
+ */
44
+ protected _buildSource(markup: string): string;
45
+ /**
46
+ * Wait for the Typst markup to finish compiling and rendering.
47
+ */
48
+ waitForRender(): Promise<void>;
49
+ /** Get the raw markup the user passed. */
50
+ getTypst(): string;
51
+ /** Get the actual Typst source compiled (math-wrapped for `MathTypst`). */
52
+ getSource(): string;
53
+ /**
54
+ * Get the render error, if any. Returns null when rendering succeeded or is
55
+ * still in progress.
56
+ */
57
+ getRenderError(): Error | null;
58
+ /**
59
+ * World-space center. An empty (not-yet-rendered) Typst falls back to its
60
+ * world-space origin instead of throwing, because Typst is built lazily and
61
+ * `scale()` / `moveTo()` may run before the SVG geometry exists.
62
+ */
63
+ getCenter(): Vector3Tuple;
64
+ /**
65
+ * Override setColor to propagate to all VMobject children (fill + stroke).
66
+ */
67
+ setColor(color: string): this;
68
+ /**
69
+ * Start the async rendering process.
70
+ */
71
+ protected _startRender(): void;
72
+ /**
73
+ * Compile the Typst source to SVG and build VMobject paths.
74
+ */
75
+ protected _render(): Promise<void>;
76
+ /**
77
+ * Restyle all VMobject children for solid glyph rendering.
78
+ */
79
+ protected _restyleChildren(group: VGroup): void;
80
+ /**
81
+ * Scale and center the assembled paths by transforming point data directly.
82
+ *
83
+ * Unit flow mirrors MathTex: convert Typst SVG units to world units via the
84
+ * font-size baseline and `TYPST_SVG_UNITS_PER_EM`. An explicit `height`
85
+ * overrides the fontSize scaling with an exact target.
86
+ */
87
+ protected _scaleToTarget(): void;
88
+ /**
89
+ * Bake any pending parent `scaleVector` (e.g. from a pre-render `scale()`)
90
+ * into descendant geometry so post-render `shift` / `moveTo` operate in the
91
+ * same coordinate frame as the rendered glyphs (mirrors MathTex #324).
92
+ */
93
+ protected _consumePendingScale(): void;
94
+ copy(): Typst;
95
+ }
96
+ /**
97
+ * MathTypst - Typst in display math mode.
98
+ *
99
+ * Wraps the input in Typst math delimiters (`$ ... $`), mirroring how `MathTex`
100
+ * renders math while `Tex` renders text. The raw markup is kept verbatim in
101
+ * `getTypst()`; the wrapped form is what the compiler receives (`getSource()`).
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * const eq = new MathTypst({ typst: 'sum_(k=1)^n k = frac(n(n + 1), 2)' });
106
+ * await eq.waitForRender();
107
+ * ```
108
+ */
109
+ export declare class MathTypst extends Typst {
110
+ protected _buildSource(markup: string): string;
111
+ copy(): MathTypst;
112
+ }
113
+ //# sourceMappingURL=Typst.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Typst.d.ts","sourceRoot":"","sources":["../../../src/mobjects/text/Typst.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,KAAK,EAAyB,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAiB9E,MAAM,WAAW,YAAY;IAC3B,+EAA+E;IAC/E,KAAK,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,mEAAmE;AACnE,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAE5C,qBAAa,KAAM,SAAQ,MAAM;IAC/B,kEAAkE;IAClE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,8EAA8E;IAC9E,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,eAAe,EAAE,MAAM,CAAC;IAClC,SAAS,CAAC,eAAe,EAAE,MAAM,CAAC;IAClC,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5C,wDAAwD;IACxD,SAAS,CAAC,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAQ;IACtD,oCAAoC;IACpC,SAAS,CAAC,YAAY,EAAE,KAAK,GAAG,IAAI,CAAQ;gBAEhC,OAAO,EAAE,YAAY;IA8BjC;;;;;;;OAOG;IACH,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAI9C;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IASpC,0CAA0C;IAC1C,QAAQ,IAAI,MAAM;IAIlB,2EAA2E;IAC3E,SAAS,IAAI,MAAM;IAInB;;;OAGG;IACH,cAAc,IAAI,KAAK,GAAG,IAAI;IAI9B;;;;OAIG;IACM,SAAS,IAAI,YAAY;IAOlC;;OAEG;IACM,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAkBtC;;OAEG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAW9B;;OAEG;cACa,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBxC;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAmB/C;;;;;;OAMG;IACH,SAAS,CAAC,cAAc,IAAI,IAAI;IAgDhC;;;;OAIG;IACH,SAAS,CAAC,oBAAoB,IAAI,IAAI;IAuB7B,IAAI,IAAI,KAAK;CAavB;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,SAAU,SAAQ,KAAK;cACf,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAI9C,IAAI,IAAI,SAAS;CAa3B"}
@@ -0,0 +1,57 @@
1
+ import { VGroup } from '../../core/VGroup';
2
+ export interface TypstRenderOptions {
3
+ /** Stroke / fill color for the resulting VMobjects. Default: WHITE. */
4
+ color?: string;
5
+ /** Stroke width passed to the SVG importer. Default: 0.02. */
6
+ strokeWidth?: number;
7
+ /** Fill opacity passed to the SVG importer. Default: 1. */
8
+ fillOpacity?: number;
9
+ }
10
+ export interface TypstRenderResult {
11
+ /** The root SVG element produced by the Typst compiler. */
12
+ svgElement: SVGElement;
13
+ /** VMobject group with one child per glyph / path. */
14
+ vmobjectGroup: VGroup;
15
+ /** Original SVG string (for debugging or caching). */
16
+ svgString: string;
17
+ /** Bounding width in the SVG's viewBox units. */
18
+ width: number;
19
+ /** Bounding height in the SVG's viewBox units. */
20
+ height: number;
21
+ }
22
+ /**
23
+ * A function that compiles a Typst source string to a full SVG string.
24
+ * Used as the dependency-injection seam: tests set a mock compiler so the
25
+ * real WASM compiler is never loaded.
26
+ */
27
+ export type TypstSvgCompiler = (source: string) => Promise<string> | string;
28
+ /**
29
+ * Inject a Typst compiler, replacing the lazy-loaded WASM compiler.
30
+ *
31
+ * Pass a function that maps a Typst source string to an SVG string. Pass `null`
32
+ * to restore the default WASM-backed compiler. Tests use this to avoid any real
33
+ * WASM compile.
34
+ */
35
+ export declare function setTypstCompiler(compiler: TypstSvgCompiler | null): void;
36
+ /**
37
+ * Check whether the Typst compiler has already been loaded.
38
+ */
39
+ export declare function isTypstLoaded(): boolean;
40
+ /**
41
+ * Pre-load the Typst compiler so the first render is fast.
42
+ * Call this early if you know Typst will be used.
43
+ */
44
+ export declare function preloadTypst(): Promise<void>;
45
+ /**
46
+ * Compile a Typst source string to SVG and convert the result into VMobject
47
+ * paths suitable for manim-web animation.
48
+ *
49
+ * The returned VMobject coordinates are raw SVG viewBox units (not world units).
50
+ * The caller (`Typst`) applies the final point -> world conversion.
51
+ *
52
+ * @param source - The Typst source to compile (already wrapped for math mode
53
+ * by `MathTypst` when applicable).
54
+ * @param options - Rendering options.
55
+ */
56
+ export declare function renderTypstToSVG(source: string, options?: TypstRenderOptions): Promise<TypstRenderResult>;
57
+ //# sourceMappingURL=TypstRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypstRenderer.d.ts","sourceRoot":"","sources":["../../../src/mobjects/text/TypstRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAQhD,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,2DAA2D;IAC3D,UAAU,EAAE,UAAU,CAAC;IACvB,sDAAsD;IACtD,aAAa,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AAoB5E;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAExE;AA8BD;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED;;;GAGG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAGlD;AAeD;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CA0D5B"}
@@ -5,16 +5,19 @@
5
5
  * applied to Three.js plane meshes, as well as LaTeX rendering using KaTeX.
6
6
  */
7
7
  export { Text, type TextOptions } from './Text';
8
+ export { type TextStyleMaps, type TextStyleRun, buildStyledTextLines } from './textStyleRuns';
8
9
  export { GlyphVMobject, type GlyphVMobjectOptions } from './GlyphVMobject';
9
10
  export { TextGlyphGroup, type TextGlyphGroupOptions } from './TextGlyphGroup';
10
11
  export { Paragraph, type ParagraphOptions } from './Paragraph';
11
12
  export { MarkupText, type MarkupTextOptions, type StyledTextSegment } from './MarkupText';
12
- export { ensureKatexStyles, areKatexStylesLoaded } from './katexStyles';
13
+ export { ensureKatexStyles, areKatexStylesLoaded, setKatexStylesheetUrl } from './katexStyles';
13
14
  export { MathTex, type MathTexOptions, MathTexSVG, type MathTexSVGOptions } from './MathTex';
14
15
  export { MathTexImage, type MathTexImageOptions, type TexRenderer } from './MathTexImage';
15
- export { renderLatexToSVG, preloadMathJax, isMathJaxLoaded, katexCanRender, type MathJaxRenderOptions, type MathJaxRenderResult, } from './MathJaxRenderer';
16
+ export { renderLatexToSVG, preloadMathJax, isMathJaxLoaded, katexCanRender, setMathJaxScriptUrl, type MathJaxRenderOptions, type MathJaxRenderResult, } from './MathJaxRenderer';
16
17
  export { parseSVGPathData, svgToVMobjects, type SVGToVMobjectOptions } from './svgPathParser';
17
18
  export { Tex, type TexOptions } from './Tex';
19
+ export { Typst, MathTypst, type TypstOptions, type MathTypstOptions } from './Typst';
20
+ export { renderTypstToSVG, preloadTypst, isTypstLoaded, setTypstCompiler, type TypstRenderOptions, type TypstRenderResult, type TypstSvgCompiler, } from './TypstRenderer';
18
21
  export { DecimalNumber, Integer, type DecimalNumberOptions } from './DecimalNumber';
19
22
  export { Variable, type VariableOptions } from './Variable';
20
23
  export { Code, type CodeOptions, type CodeColorScheme, type Token, type TokenType, DEFAULT_COLOR_SCHEME, MONOKAI_COLOR_SCHEME, } from './Code';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mobjects/text/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGhD,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,M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AAE,KAAK,EAAE,SAAS,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAGpF,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAG5D,OAAO,EACL,IAAI,EACJ,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,KAAK,EACV,KAAK,SAAS,EACd,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACL,mBAAmB,EACnB,KAAK,0BAA0B,EAC/B,WAAW,EACX,KAAK,kBAAkB,GACxB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,YAAY,EACZ,KAAK,EACL,YAAY,EACZ,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,mBAAmB,GACzB,MAAM,kBAAkB,CAAC"}
@@ -3,6 +3,11 @@
3
3
  *
4
4
  * Ensures the KaTeX stylesheet is loaded for proper LaTeX rendering.
5
5
  */
6
+ /**
7
+ * Configure the stylesheet loaded by {@link ensureKatexStyles}.
8
+ * Pass `null` when the application bundles KaTeX CSS itself.
9
+ */
10
+ export declare function setKatexStylesheetUrl(url: string | null): void;
6
11
  /**
7
12
  * Ensure KaTeX styles are loaded in the document.
8
13
  * This is called automatically by MathTex on first use.
@@ -1 +1 @@
1
- {"version":3,"file":"katexStyles.d.ts","sourceRoot":"","sources":["../../../src/mobjects/text/katexStyles.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiCH;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAGxC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CA4BlD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C"}
1
+ {"version":3,"file":"katexStyles.d.ts","sourceRoot":"","sources":["../../../src/mobjects/text/katexStyles.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAK9D;AA4BD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAGxC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAiClD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * `registerFont` — register a custom font in the browser (CE `register_font`).
3
+ *
4
+ * CE's `register_font(path)` registers a font file with the system so Pango can
5
+ * use it when rasterizing text. The browser analog is the CSS Font Loading API:
6
+ * build a `FontFace` and add it to `document.fonts`. The browser then loads the
7
+ * font lazily the first time text uses the family, so adding the face is enough
8
+ * to make the family available — no eager `load()` call is required.
9
+ *
10
+ * The function is guarded for environments without the API (Node, test workers,
11
+ * server-side rendering): it returns `false` and does nothing when `document`,
12
+ * `document.fonts`, or `FontFace` is unavailable, so it is safe to call anywhere.
13
+ */
14
+ /**
15
+ * A font source accepted by `registerFont`.
16
+ *
17
+ * - A `string` is a CSS source. A bare URL or path is wrapped as `url("…")`;
18
+ * a value that already starts with `url(` or `local(` is used verbatim.
19
+ * - A `BufferSource` (an `ArrayBuffer` or typed-array view) is font binary data,
20
+ * passed straight to the `FontFace` constructor.
21
+ */
22
+ export type FontSource = string | BufferSource;
23
+ /**
24
+ * Register a custom font so text mobjects can use it by family name.
25
+ *
26
+ * @param family - The font-family name to register the source under.
27
+ * @param source - A CSS source string, a URL/path, or font binary data.
28
+ * @returns `true` when the font was registered, `false` when the CSS Font
29
+ * Loading API is unavailable (for example in Node or a test worker).
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * registerFont('Inter', 'https://example.com/Inter.woff2');
34
+ * registerFont('Inter', 'url("/fonts/Inter.woff2")'); // explicit CSS source
35
+ * ```
36
+ */
37
+ export declare function registerFont(family: string, source: FontSource): boolean;
38
+ //# sourceMappingURL=registerFont.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerFont.d.ts","sourceRoot":"","sources":["../../../src/mobjects/text/registerFont.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,YAAY,CAAC;AAE/C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAiBxE"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Per-substring style runs for the canvas-raster Text mobject.
3
+ *
4
+ * Manim CE lets `Text` color or restyle sub-strings through `t2c`
5
+ * (text-to-color), `t2w` (text-to-weight) and `t2s` (text-to-slant) maps. This
6
+ * module turns the plain text plus those maps into a layout model: a list of
7
+ * lines, each a list of styled runs. The model is pure and testable; the Text
8
+ * canvas renderer draws each run with its own font and color.
9
+ */
10
+ /** Per-substring style maps, as in Manim CE `Text`. */
11
+ export interface TextStyleMaps {
12
+ /** Map from a substring to a CSS color. Colors every occurrence. */
13
+ t2c?: Record<string, string>;
14
+ /** Map from a substring to a font weight ('bold', 'normal', 100-900). */
15
+ t2w?: Record<string, string | number>;
16
+ /** Map from a substring to a font style ('italic', 'oblique', 'normal'). */
17
+ t2s?: Record<string, string>;
18
+ }
19
+ /** One run of characters that share the same resolved style. */
20
+ export interface TextStyleRun {
21
+ /** The run text (never contains a newline). */
22
+ text: string;
23
+ /** Resolved color, or null to use the Text base color. */
24
+ color: string | null;
25
+ /** Resolved font weight, or null to use the Text base weight. */
26
+ fontWeight: string | number | null;
27
+ /** Resolved font style, or null to use the Text base style. */
28
+ fontStyle: string | null;
29
+ }
30
+ /** True when at least one style map has an entry. */
31
+ export declare function hasStyleMaps(maps: TextStyleMaps): boolean;
32
+ /**
33
+ * Split `text` into lines on '\n', then each line into styled runs.
34
+ * An empty line yields an empty run list.
35
+ */
36
+ export declare function buildStyledTextLines(text: string, maps: TextStyleMaps): TextStyleRun[][];
37
+ /** Base font fields a run falls back to when it has no override. */
38
+ export interface RunFontBase {
39
+ fontStyle: string;
40
+ fontWeight: string | number;
41
+ /** The scaled point size, used directly as `<n>pt` in the CSS font string. */
42
+ sizePt: number;
43
+ fontFamily: string;
44
+ }
45
+ /** Build the CSS canvas font string for one run, with base fallbacks. */
46
+ export declare function runFontString(run: TextStyleRun, base: RunFontBase): string;
47
+ /** One color stop of a linear gradient: an offset in [0, 1] and its CSS color. */
48
+ export interface GradientStop {
49
+ offset: number;
50
+ color: string;
51
+ }
52
+ /**
53
+ * Build evenly-spaced gradient color stops from a color list.
54
+ *
55
+ * Two colors map to offsets [0, 1], three to [0, 0.5, 1], and n colors to
56
+ * offset i/(n-1). The color order is preserved. A single color is degenerate:
57
+ * it yields one stop at offset 0, which fills a solid color. An empty list
58
+ * yields no stops.
59
+ *
60
+ * This is pure, so the stop math is unit-testable without a real canvas.
61
+ */
62
+ export declare function buildGradientStops(colors: string[]): GradientStop[];
63
+ /**
64
+ * True when `gradient` can drive a linear gradient fill: it exists and has at
65
+ * least two colors, as Manim CE requires.
66
+ */
67
+ export declare function gradientIsActive(gradient: string[] | null | undefined): gradient is string[];
68
+ /** Style and layout fields the styled canvas path needs from a Text instance. */
69
+ export interface StyledTextParams {
70
+ fontSize: number;
71
+ fontFamily: string;
72
+ fontStyle: string;
73
+ fontWeight: string | number;
74
+ lineHeight: number;
75
+ textAlign: 'left' | 'center' | 'right';
76
+ color: string;
77
+ fillOpacity: number;
78
+ strokeWidth: number;
79
+ /**
80
+ * Optional linear color gradient (2+ colors). When set, runs with no explicit
81
+ * color (no `t2c` match) fill with a horizontal left-to-right gradient that
82
+ * spans the text's rendered box. Runs with an explicit `t2c` color keep that
83
+ * color, so the gradient composes with `t2c` rather than overriding it.
84
+ */
85
+ gradient?: string[];
86
+ }
87
+ /**
88
+ * Measure styled text. Each run is measured with its own font so a bolder or
89
+ * italic run reserves the correct width. Letter spacing is not applied in
90
+ * styled mode so measure and render stay consistent.
91
+ */
92
+ export declare function measureStyledText(ctx: CanvasRenderingContext2D, styledLines: TextStyleRun[][], params: StyledTextParams): {
93
+ lines: string[];
94
+ width: number;
95
+ height: number;
96
+ };
97
+ /**
98
+ * Draw styled text to the canvas and return its world-space size. Each run is
99
+ * drawn with its own font and color; x advances by the measured width of each
100
+ * run, so mixed-weight and mixed-style runs stay correctly spaced.
101
+ *
102
+ * The world-size conversion matches the plain Text path exactly.
103
+ */
104
+ export declare function renderStyledTextToCanvas(canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D, styledLines: TextStyleRun[][], params: StyledTextParams, worldPerPt: {
105
+ defaultFontSizePt: number;
106
+ defaultFontSizeInWorld: number;
107
+ }): {
108
+ width: number;
109
+ height: number;
110
+ };
111
+ //# sourceMappingURL=textStyleRuns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textStyleRuns.d.ts","sourceRoot":"","sources":["../../../src/mobjects/text/textStyleRuns.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,yEAAyE;IACzE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACtC,4EAA4E;IAC5E,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,gEAAgE;AAChE,MAAM,WAAW,YAAY;IAC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UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAuCD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,wBAAwB,EAC7B,WAAW,EAAE,YAAY,EAAE,EAAE,EAC7B,MAAM,EAAE,gBAAgB,GACvB;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAcpD;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,iBAAiB,EACzB,GAAG,EAAE,wBAAwB,EAC7B,WAAW,EAAE,YAAY,EAAE,EAAE,EAC7B,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE;IAAE,iBAAiB,EAAE,MAAM,CAAC;IAAC,sBAAsB,EAAE,MAAM,CAAA;CAAE,GACxE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAgEnC"}
@@ -0,0 +1,122 @@
1
+ import { Vector3Tuple } from '../../core/Mobject';
2
+ import { Mobject3D } from './Mobject3D';
3
+ /**
4
+ * ModelMobject - import an external 3D model (glTF / .glb / .obj) as a mobject.
5
+ *
6
+ * ManimCE has no way to import an external 3D model (see the long-standing
7
+ * "OBJ Support" request). Three.js ships loaders for the common formats, so
8
+ * manim-web exposes them through a mobject that drops the loaded
9
+ * `THREE.Object3D` into the normal Group/Mobject hierarchy. The model then
10
+ * participates in shift / scale / rotate, z-depth and the 3D camera exactly
11
+ * like a built-in primitive (Cube, Surface3D, ...).
12
+ *
13
+ * Scene-graph wiring (why there are nested groups):
14
+ * wrapper - returned as `_threeObject`; its local transform is written
15
+ * by `Mobject._syncToThree` from the mobject transform, so it
16
+ * must stay under manim's control alone.
17
+ * content - carries the `scale` and `upAxis` options.
18
+ * center - carries the `center` recenter offset.
19
+ * model - the pristine loaded Object3D (never mutated by options, so
20
+ * `copy()` can clone it and re-apply the options cleanly).
21
+ *
22
+ * The real Three.js example loaders are pulled in through a lazy dynamic
23
+ * `import()` on first use, so the base bundle and SSR never load them. Tests
24
+ * inject a loader (via the `loader` option or `setModelLoaderFactory`), which
25
+ * bypasses the import and the network entirely - mirroring the
26
+ * `setTypstCompiler` dependency-injection seam in TypstRenderer.
27
+ */
28
+ import * as THREE from 'three';
29
+ /** Supported model formats, picked from the URL extension. */
30
+ export type ModelFormat = 'gltf' | 'obj';
31
+ /**
32
+ * The model's up direction. An axis name, or an explicit vector. The model is
33
+ * rotated so this direction aligns with the scene up (+Y).
34
+ */
35
+ export type ModelUpAxis = 'x' | 'y' | 'z' | Vector3Tuple;
36
+ /** A GLTF-style result, whose root Object3D lives on `.scene`. */
37
+ interface GltfLike {
38
+ scene: THREE.Object3D;
39
+ }
40
+ /**
41
+ * The minimal loader contract ModelMobject needs. Three.js GLTFLoader and
42
+ * OBJLoader both satisfy it structurally. Tests implement it with a stub.
43
+ */
44
+ export interface ModelLoader {
45
+ loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<THREE.Object3D | GltfLike>;
46
+ }
47
+ /** Builds a loader for a format. The DI seam set by `setModelLoaderFactory`. */
48
+ export type ModelLoaderFactory = (format: ModelFormat) => ModelLoader | Promise<ModelLoader>;
49
+ /** Options for {@link ModelMobject.fromUrl}. */
50
+ export interface ModelMobjectOptions {
51
+ /** Uniform factor, or per-axis factors, applied to the loaded model. */
52
+ scale?: number | Vector3Tuple;
53
+ /** The model's up direction; the model is rotated to the scene up (+Y). */
54
+ upAxis?: ModelUpAxis;
55
+ /** Recenter the model's bounding box to the origin. Default: false. */
56
+ center?: boolean;
57
+ /** Convenience fill color applied to every mesh material. */
58
+ color?: string;
59
+ /** Replace every mesh material with this one. Wins over `color`. */
60
+ materialOverride?: THREE.Material;
61
+ /** Progress callback forwarded to the loader. */
62
+ onProgress?: (event: ProgressEvent) => void;
63
+ /** Inject a loader directly (bypasses the factory and the network). */
64
+ loader?: ModelLoader;
65
+ /**
66
+ * When false, a load failure resolves to an empty ModelMobject whose
67
+ * {@link ModelMobject.getLoadError} holds the error instead of rejecting.
68
+ * Default: true (the returned promise rejects on failure).
69
+ */
70
+ throwOnError?: boolean;
71
+ }
72
+ /**
73
+ * Inject a loader factory, replacing the lazy-loaded Three.js example loaders.
74
+ * Pass `null` to restore the default. Tests use this to avoid any real loader.
75
+ */
76
+ export declare function setModelLoaderFactory(factory: ModelLoaderFactory | null): void;
77
+ /** Pick the model format from a URL's extension (ignores query and fragment). */
78
+ export declare function detectModelFormat(url: string): ModelFormat;
79
+ export declare class ModelMobject extends Mobject3D {
80
+ private readonly _model;
81
+ private readonly _centerGroup;
82
+ private readonly _content;
83
+ private readonly _wrapper;
84
+ private readonly _format;
85
+ private readonly _options;
86
+ private _loadError;
87
+ /**
88
+ * Prefer {@link ModelMobject.fromUrl}. This constructor wraps an already
89
+ * loaded Object3D (or `null` for an empty placeholder) and applies the
90
+ * geometry options.
91
+ */
92
+ constructor(object: THREE.Object3D | null, options?: ModelMobjectOptions, format?: ModelFormat | null);
93
+ /**
94
+ * Load a model from a URL and return a ready ModelMobject.
95
+ *
96
+ * The loader is chosen from the extension: `.glb` / `.gltf` -> GLTFLoader,
97
+ * `.obj` -> OBJLoader. Inject a loader with the `loader` option (or
98
+ * `setModelLoaderFactory`) to avoid the network, e.g. in tests.
99
+ */
100
+ static fromUrl(url: string, options?: ModelMobjectOptions): Promise<ModelMobject>;
101
+ /** Offset the center group so the model's bounding box sits at the origin. */
102
+ private _recenter;
103
+ /** Rotate the content group so the model's up axis aligns with +Y. */
104
+ private _applyUpAxis;
105
+ private _upAxisVector;
106
+ /** Scale the content group uniformly or per axis. */
107
+ private _applyScale;
108
+ /** Apply a material override, or a fill color, to every mesh in the model. */
109
+ private _applyMaterials;
110
+ private _applyColor;
111
+ private _forEachMesh;
112
+ /** The loaded model root (an empty Group if the load failed). */
113
+ getObject(): THREE.Object3D;
114
+ /** The format this model was loaded as, or null for a bare construction. */
115
+ getFormat(): ModelFormat | null;
116
+ /** The load error, or null if the model loaded successfully. */
117
+ getLoadError(): Error | null;
118
+ protected _createThreeObject(): THREE.Object3D;
119
+ copy(): ModelMobject;
120
+ }
121
+ export {};
122
+ //# sourceMappingURL=ModelMobject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelMobject.d.ts","sourceRoot":"","sources":["../../../src/mobjects/three-d/ModelMobject.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMxC,8DAA8D;AAC9D,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,KAAK,CAAC;AAEzC;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,YAAY,CAAC;AAEzD,kEAAkE;AAClE,UAAU,QAAQ;IAChB,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,SAAS,CACP,GAAG,EAAE,MAAM,EACX,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAC1C,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;CACvC;AAED,gFAAgF;AAChF,MAAM,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,WAAW,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAE7F,gDAAgD;AAChD,MAAM,WAAW,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