manim-web 0.3.18 → 0.3.19
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/README.md +26 -40
- package/dist/AllPackages-C4Ha3Jps.js +7912 -0
- package/dist/AllPackages-Dwxf_-Ps.js +7912 -0
- package/dist/BaseConfiguration-D2fikupy.js +4402 -0
- package/dist/BaseConfiguration-DYpI8zxb.js +4402 -0
- package/dist/Entities-BxzKxtF2.js +458 -0
- package/dist/Entities-gIbwAkB6.js +458 -0
- package/dist/GifExporter-7EpPGupp.js +338 -0
- package/dist/GifExporter-DCrSD6FV.js +338 -0
- package/dist/InputJax-BszJvLkW.js +43 -0
- package/dist/InputJax-CgHBfQsv.js +43 -0
- package/dist/MathItem-4gYKatZT.js +77 -0
- package/dist/MathItem-BGJUnd1K.js +77 -0
- package/dist/Options-CQim5zsr.js +188 -0
- package/dist/Options-Cn9jv1mh.js +188 -0
- package/dist/PrioritizedList-C1R4aNEC.js +36 -0
- package/dist/PrioritizedList-lIkFMNlo.js +36 -0
- package/dist/Styles-Bi9Db-2J.js +411 -0
- package/dist/Styles-CzHPc-An.js +411 -0
- package/dist/TeXAtom-Cinii27y.js +2025 -0
- package/dist/TeXAtom-DFdvwkN2.js +2025 -0
- package/dist/VideoExporter-6w8xBpcV.js +102 -0
- package/dist/VideoExporter-DdQb18dC.js +102 -0
- package/dist/animation/creation/Create.d.ts +1 -1
- package/dist/animation/movement/Rotate.d.ts +2 -0
- package/dist/animation/movement/Rotate.d.ts.map +1 -1
- package/dist/animation/movement/Scale.d.ts +2 -0
- package/dist/animation/movement/Scale.d.ts.map +1 -1
- package/dist/animation/transform/ApplyTransforms.d.ts +1 -2
- package/dist/animation/transform/ApplyTransforms.d.ts.map +1 -1
- package/dist/animation/utility/index.d.ts +2 -0
- package/dist/animation/utility/index.d.ts.map +1 -1
- package/dist/chunk-DeC0fbbY.js +23 -0
- package/dist/core/Group.d.ts +2 -2
- package/dist/core/Group.d.ts.map +1 -1
- package/dist/core/Mobject.d.ts +26 -6
- package/dist/core/Mobject.d.ts.map +1 -1
- package/dist/core/MobjectState.d.ts +23 -2
- package/dist/core/MobjectState.d.ts.map +1 -1
- package/dist/core/Scene.d.ts +7 -1
- package/dist/core/Scene.d.ts.map +1 -1
- package/dist/core/ThreeDScene.d.ts +17 -0
- package/dist/core/ThreeDScene.d.ts.map +1 -1
- package/dist/core/VGroup.d.ts +1 -1
- package/dist/core/VGroup.d.ts.map +1 -1
- package/dist/html-DKkfg_ss.js +1587 -0
- package/dist/html-DpiYkktJ.js +1587 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -579
- package/dist/integrations/react.js +144 -735
- package/dist/integrations/vue.js +109 -735
- package/dist/interaction/Draggable.d.ts.map +1 -1
- package/dist/lengths-C0YS8_KC.js +65 -0
- package/dist/lengths-eBH2o1TO.js +65 -0
- package/dist/liteAdaptor-CB8lQj3d.js +828 -0
- package/dist/liteAdaptor-DvuW8HsZ.js +828 -0
- package/dist/manim-web.browser.js +72327 -83816
- package/dist/mathjax-BVz9WLAG.js +105 -0
- package/dist/mathjax-BbWkqal4.js +2 -0
- package/dist/mathjax-BrFZxFhK.js +2 -0
- package/dist/mathjax-DdKmwllV.js +105 -0
- package/dist/mo-B60kIOAG.js +3271 -0
- package/dist/mo-cSv2058o.js +3271 -0
- package/dist/mobjects/geometry/AngleShapes.d.ts +8 -0
- package/dist/mobjects/geometry/AngleShapes.d.ts.map +1 -1
- package/dist/mobjects/geometry/DashedLine.d.ts +2 -2
- package/dist/mobjects/geometry/DashedLine.d.ts.map +1 -1
- package/dist/mobjects/graphing/Axes.d.ts +2 -2
- package/dist/mobjects/graphing/Axes.d.ts.map +1 -1
- package/dist/mobjects/graphing/ComplexPlane.d.ts +4 -1
- package/dist/mobjects/graphing/ComplexPlane.d.ts.map +1 -1
- package/dist/mobjects/matrix/Matrix.d.ts +2 -2
- package/dist/mobjects/matrix/Matrix.d.ts.map +1 -1
- package/dist/mobjects/point/PGroup.d.ts +1 -1
- package/dist/mobjects/point/PGroup.d.ts.map +1 -1
- package/dist/mobjects/point/PMobject.d.ts +1 -1
- package/dist/mobjects/point/PMobject.d.ts.map +1 -1
- package/dist/mobjects/svg/Brace.d.ts +3 -3
- package/dist/mobjects/svg/Brace.d.ts.map +1 -1
- package/dist/mobjects/table/Table.d.ts +4 -4
- package/dist/mobjects/table/Table.d.ts.map +1 -1
- package/dist/mobjects/text/MathJaxRenderer.d.ts.map +1 -1
- package/dist/mobjects/text/MathTex.d.ts +61 -202
- package/dist/mobjects/text/MathTex.d.ts.map +1 -1
- package/dist/mobjects/text/MathTexImage.d.ts +254 -0
- package/dist/mobjects/text/MathTexImage.d.ts.map +1 -0
- package/dist/mobjects/text/MathTexParts.d.ts +10 -10
- package/dist/mobjects/text/MathTexParts.d.ts.map +1 -1
- package/dist/mobjects/text/Tex.d.ts +2 -7
- package/dist/mobjects/text/Tex.d.ts.map +1 -1
- package/dist/mobjects/text/Variable.d.ts +5 -5
- package/dist/mobjects/text/Variable.d.ts.map +1 -1
- package/dist/mobjects/text/index.d.ts +2 -2
- package/dist/mobjects/text/index.d.ts.map +1 -1
- package/dist/mobjects/text/svgPathParser.d.ts.map +1 -1
- package/dist/player/Player.d.ts +8 -2
- package/dist/player/Player.d.ts.map +1 -1
- package/dist/player/PlayerController.d.ts +2 -0
- package/dist/player/PlayerController.d.ts.map +1 -1
- package/dist/player/PlayerUI.d.ts +5 -0
- package/dist/player/PlayerUI.d.ts.map +1 -1
- package/dist/src-0ifQdJUj.js +59703 -0
- package/dist/svg-BDTt4xHZ.js +23879 -0
- package/dist/svg-DzbC3CbJ.js +23879 -0
- package/dist/tex-CRhAZgfS.js +401 -0
- package/dist/tex-D3LEgNlQ.js +401 -0
- package/dist/utils/math.d.ts +7 -0
- package/dist/utils/math.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/featureFlags-H97tY2Rw.js +0 -59814
- package/dist/mobjects/text/MathTexSVG.d.ts +0 -102
- package/dist/mobjects/text/MathTexSVG.d.ts.map +0 -1
|
@@ -1,249 +1,108 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
* MathTex - LaTeX rendering for manimweb using KaTeX (default) or MathJax (fallback)
|
|
4
|
-
*
|
|
5
|
-
* This module provides LaTeX math rendering capabilities by:
|
|
6
|
-
* 1. Using KaTeX to render LaTeX to HTML (fast, limited subset)
|
|
7
|
-
* 2. Falling back to MathJax SVG output for unsupported LaTeX (full LaTeX support)
|
|
8
|
-
* 3. Converting output to canvas via DOM walking / SVG foreignObject
|
|
9
|
-
* 4. Creating a THREE.js textured plane mesh
|
|
10
|
-
*
|
|
11
|
-
* Renderer selection:
|
|
12
|
-
* - 'katex' : KaTeX only (fast, limited subset)
|
|
13
|
-
* - 'mathjax': MathJax only (slower, full LaTeX including \usepackage, align, etc.)
|
|
14
|
-
* - 'auto' : Try KaTeX first; fall back to MathJax if KaTeX throws (default)
|
|
15
|
-
*/
|
|
16
|
-
import * as THREE from 'three';
|
|
17
|
-
/**
|
|
18
|
-
* Which renderer to use for LaTeX.
|
|
19
|
-
* - 'katex' : KaTeX only (fast, but limited LaTeX subset)
|
|
20
|
-
* - 'mathjax': MathJax SVG only (slower, full LaTeX support)
|
|
21
|
-
* - 'auto' : Try KaTeX first; if it throws, fall back to MathJax
|
|
22
|
-
*/
|
|
23
|
-
export type TexRenderer = 'katex' | 'mathjax' | 'auto';
|
|
24
|
-
/**
|
|
25
|
-
* Options for creating a MathTex object
|
|
26
|
-
*/
|
|
1
|
+
import { VGroup } from '../../core/VGroup';
|
|
2
|
+
import { Vector3Tuple } from '../../core/Mobject';
|
|
27
3
|
export interface MathTexOptions {
|
|
28
|
-
/** LaTeX string or array of strings for multi-part expressions.
|
|
29
|
-
* When an array is provided, each string becomes a separate sub-mobject
|
|
30
|
-
* accessible via getPart(index), matching Python Manim's behavior. */
|
|
4
|
+
/** LaTeX string or array of strings for multi-part expressions. */
|
|
31
5
|
latex: string | string[];
|
|
32
|
-
/** Color as CSS color string. Default: '#ffffff' */
|
|
6
|
+
/** Color as CSS color string. Default: WHITE ('#ffffff') */
|
|
33
7
|
color?: string;
|
|
34
|
-
/**
|
|
8
|
+
/** Scale factor (1 = standard math size). Default: 1 */
|
|
35
9
|
fontSize?: number;
|
|
36
10
|
/** Use display mode (block) vs inline mode. Default: true */
|
|
37
11
|
displayMode?: boolean;
|
|
38
|
-
/** Position in 3D space. Default: [0,
|
|
12
|
+
/** Position in 3D space. Default: [0,0,0] */
|
|
39
13
|
position?: Vector3Tuple;
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
renderer?: TexRenderer;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Internal state for async rendering
|
|
52
|
-
*/
|
|
53
|
-
interface RenderState {
|
|
54
|
-
canvas: HTMLCanvasElement | null;
|
|
55
|
-
texture: THREE.CanvasTexture | null;
|
|
56
|
-
mesh: THREE.Mesh | null;
|
|
57
|
-
width: number;
|
|
58
|
-
height: number;
|
|
59
|
-
isRendering: boolean;
|
|
60
|
-
renderPromise: Promise<void> | null;
|
|
61
|
-
renderError: Error | null;
|
|
14
|
+
/** Stroke width for glyph outlines. Default: 0.02 */
|
|
15
|
+
strokeWidth?: number;
|
|
16
|
+
/** Fill opacity for glyph interiors. Default: 1 */
|
|
17
|
+
fillOpacity?: number;
|
|
18
|
+
/** Explicit target height in world units. Overrides fontSize scaling. */
|
|
19
|
+
height?: number;
|
|
20
|
+
/** Custom LaTeX macros as { name: expansion }. */
|
|
21
|
+
macros?: Record<string, string>;
|
|
62
22
|
}
|
|
63
|
-
|
|
64
|
-
* MathTex - A mobject for rendering LaTeX mathematical expressions
|
|
65
|
-
*
|
|
66
|
-
* Uses KaTeX for LaTeX parsing and renders to a textured plane in Three.js.
|
|
67
|
-
* The rendering is asynchronous but the constructor is synchronous.
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* // Create a simple equation
|
|
72
|
-
* const equation = new MathTex({ latex: 'E = mc^2' });
|
|
73
|
-
*
|
|
74
|
-
* // Create a colored integral
|
|
75
|
-
* const integral = new MathTex({
|
|
76
|
-
* latex: '\\int_0^\\infty e^{-x^2} dx = \\frac{\\sqrt{\\pi}}{2}',
|
|
77
|
-
* color: '#00ff00',
|
|
78
|
-
* fontSize: 64
|
|
79
|
-
* });
|
|
80
|
-
*
|
|
81
|
-
* // Wait for rendering to complete before animating
|
|
82
|
-
* await integral.waitForRender();
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
export declare class MathTex extends Mobject {
|
|
23
|
+
export declare class MathTex extends VGroup {
|
|
86
24
|
protected _latex: string;
|
|
87
25
|
protected _fontSize: number;
|
|
88
26
|
protected _displayMode: boolean;
|
|
89
|
-
protected
|
|
90
|
-
|
|
91
|
-
protected
|
|
92
|
-
|
|
93
|
-
protected
|
|
27
|
+
protected _color: string;
|
|
28
|
+
protected _svgStrokeWidth: number;
|
|
29
|
+
protected _svgFillOpacity: number;
|
|
30
|
+
protected _targetHeight: number | undefined;
|
|
31
|
+
protected _macros: Record<string, string> | undefined;
|
|
32
|
+
protected _svgViewBoxWidth: number;
|
|
94
33
|
/** Whether this is a multi-part MathTex (created from string[]) */
|
|
95
34
|
protected _isMultiPart: boolean;
|
|
96
|
-
/** Child
|
|
97
|
-
protected _parts:
|
|
98
|
-
/** Promise that resolves when
|
|
99
|
-
protected
|
|
100
|
-
/**
|
|
101
|
-
protected
|
|
35
|
+
/** Child part groups (only when _isMultiPart is true) */
|
|
36
|
+
protected _parts: VGroup[];
|
|
37
|
+
/** Promise that resolves when rendering is complete */
|
|
38
|
+
protected _renderPromise: Promise<void> | null;
|
|
39
|
+
/** Error from rendering, if any */
|
|
40
|
+
protected _renderError: Error | null;
|
|
102
41
|
constructor(options: MathTexOptions);
|
|
103
|
-
/**
|
|
104
|
-
* Get the renderer mode
|
|
105
|
-
*/
|
|
106
|
-
getRenderer(): TexRenderer;
|
|
107
|
-
/**
|
|
108
|
-
* Get which renderer was actually used for the current render.
|
|
109
|
-
* Returns null if not yet rendered.
|
|
110
|
-
*/
|
|
111
|
-
getActiveRenderer(): 'katex' | 'mathjax' | null;
|
|
112
|
-
/**
|
|
113
|
-
* Set the renderer mode and re-render.
|
|
114
|
-
* @param renderer The renderer to use
|
|
115
|
-
* @returns this for chaining
|
|
116
|
-
*/
|
|
117
|
-
setRenderer(renderer: TexRenderer): this;
|
|
118
|
-
/**
|
|
119
|
-
* Get the LaTeX string
|
|
120
|
-
*/
|
|
121
|
-
getLatex(): string;
|
|
122
|
-
/**
|
|
123
|
-
* Set the LaTeX string and re-render
|
|
124
|
-
* @param latex New LaTeX string
|
|
125
|
-
* @returns this for chaining
|
|
126
|
-
*/
|
|
127
|
-
setLatex(latex: string): this;
|
|
128
|
-
/**
|
|
129
|
-
* Get the font size
|
|
130
|
-
*/
|
|
131
|
-
getFontSize(): number;
|
|
132
|
-
/**
|
|
133
|
-
* Set the font size and re-render
|
|
134
|
-
* @param size New font size in pixels
|
|
135
|
-
* @returns this for chaining
|
|
136
|
-
*/
|
|
137
|
-
setFontSize(size: number): this;
|
|
138
|
-
/**
|
|
139
|
-
* Override setColor — texture is always rendered white, so we only need
|
|
140
|
-
* to update the material tint via _syncMaterialToThree (no re-render).
|
|
141
|
-
*/
|
|
142
|
-
setColor(color: string): this;
|
|
143
|
-
/**
|
|
144
|
-
* Override setOpacity to propagate to multi-part children.
|
|
145
|
-
*/
|
|
146
|
-
setOpacity(opacity: number): this;
|
|
147
42
|
/**
|
|
148
43
|
* Wait for the LaTeX to finish rendering.
|
|
149
|
-
* For multi-part MathTex, waits for all parts to render and be arranged.
|
|
150
|
-
* @returns Promise that resolves when rendering is complete
|
|
151
44
|
*/
|
|
152
45
|
waitForRender(): Promise<void>;
|
|
153
46
|
/**
|
|
154
|
-
* Get a sub-part of a multi-part
|
|
155
|
-
* Only available when
|
|
156
|
-
*
|
|
157
|
-
* @returns The MathTex sub-part at the given index
|
|
47
|
+
* Get a sub-part of a multi-part expression.
|
|
48
|
+
* Only available when created with a string array.
|
|
49
|
+
* Returns a VGroup with setColor() support.
|
|
158
50
|
*/
|
|
159
|
-
getPart(index: number):
|
|
51
|
+
getPart(index: number): VGroup;
|
|
160
52
|
/**
|
|
161
|
-
* Get the number of parts
|
|
53
|
+
* Get the number of parts.
|
|
162
54
|
*/
|
|
163
55
|
getPartCount(): number;
|
|
164
56
|
/**
|
|
165
|
-
*
|
|
166
|
-
* Positions parts so their content (minus padding) is seamlessly adjacent.
|
|
57
|
+
* Get the LaTeX string.
|
|
167
58
|
*/
|
|
168
|
-
|
|
59
|
+
getLatex(): string;
|
|
169
60
|
/**
|
|
170
|
-
*
|
|
61
|
+
* Get the render error, if any.
|
|
62
|
+
* Returns null if rendering succeeded or is still in progress.
|
|
171
63
|
*/
|
|
172
|
-
|
|
64
|
+
getRenderError(): Error | null;
|
|
173
65
|
/**
|
|
174
|
-
*
|
|
175
|
-
* @returns [width, height] or [0, 0] if not yet rendered
|
|
66
|
+
* Override setColor to propagate to all VMobject children (fill + stroke).
|
|
176
67
|
*/
|
|
177
|
-
|
|
68
|
+
setColor(color: string): this;
|
|
178
69
|
/**
|
|
179
|
-
* Start the async rendering process
|
|
70
|
+
* Start the async rendering process.
|
|
180
71
|
*/
|
|
181
72
|
protected _startRender(): void;
|
|
182
73
|
/**
|
|
183
|
-
* Render the LaTeX to
|
|
184
|
-
*
|
|
185
|
-
* Renderer selection logic:
|
|
186
|
-
* - 'katex' : Use KaTeX directly (throwOnError: false)
|
|
187
|
-
* - 'mathjax': Use MathJax SVG output, rendered to canvas via Image
|
|
188
|
-
* - 'auto' : Try KaTeX with throwOnError: true. If it throws,
|
|
189
|
-
* fall back to MathJax.
|
|
190
|
-
*/
|
|
191
|
-
protected _renderLatex(): Promise<void>;
|
|
192
|
-
/**
|
|
193
|
-
* Determine which concrete renderer to use for the current LaTeX string.
|
|
194
|
-
*/
|
|
195
|
-
private _resolveRenderer;
|
|
196
|
-
/**
|
|
197
|
-
* Parse an SVG dimension attribute that may use "ex" units and convert
|
|
198
|
-
* to pixels. MathJax outputs width/height like "5.002ex"; parseFloat
|
|
199
|
-
* strips the suffix, so we detect "ex" and scale appropriately.
|
|
74
|
+
* Render the LaTeX to VMobject paths.
|
|
200
75
|
*/
|
|
201
|
-
|
|
76
|
+
protected _render(): Promise<void>;
|
|
202
77
|
/**
|
|
203
|
-
*
|
|
204
|
-
* texture in the same way the KaTeX path works, keeping the visual
|
|
205
|
-
* pipeline consistent.
|
|
78
|
+
* Restyle all VMobject children for solid glyph rendering.
|
|
206
79
|
*/
|
|
207
|
-
protected
|
|
80
|
+
protected _restyleChildren(group: VGroup): void;
|
|
208
81
|
/**
|
|
209
|
-
*
|
|
210
|
-
* and drawing each text element at its computed CSS position.
|
|
82
|
+
* Scale and center the assembled paths by transforming actual point data.
|
|
211
83
|
*/
|
|
212
|
-
protected
|
|
84
|
+
protected _scaleToTarget(): void;
|
|
213
85
|
/**
|
|
214
|
-
*
|
|
215
|
-
*
|
|
86
|
+
* Render a multi-part expression by:
|
|
87
|
+
* 1. Rendering the FULL expression as one MathJax call (correct layout)
|
|
88
|
+
* 2. Rendering each part separately to count its glyphs
|
|
89
|
+
* 3. Splitting the full expression's VMobjects into part groups by glyph count
|
|
216
90
|
*/
|
|
217
|
-
|
|
91
|
+
private _renderMultiPart;
|
|
218
92
|
/**
|
|
219
|
-
*
|
|
93
|
+
* Lightweight VGroup used as a part container in multi-part mode.
|
|
94
|
+
* Supports setColor() for per-part coloring.
|
|
220
95
|
*/
|
|
221
|
-
|
|
96
|
+
private static _PartGroup;
|
|
222
97
|
/**
|
|
223
|
-
* Create
|
|
224
|
-
*/
|
|
225
|
-
protected _createThreeObject(): THREE.Object3D;
|
|
226
|
-
/**
|
|
227
|
-
* Sync material properties to Three.js
|
|
228
|
-
*/
|
|
229
|
-
protected _syncMaterialToThree(): void;
|
|
230
|
-
/**
|
|
231
|
-
* Create a copy of this MathTex
|
|
98
|
+
* Create a copy of this MathTex.
|
|
232
99
|
*/
|
|
233
100
|
protected _createCopy(): MathTex;
|
|
234
|
-
/**
|
|
235
|
-
* Set reveal progress for Write animation (left-to-right wipe).
|
|
236
|
-
* @param alpha - Progress from 0 (hidden) to 1 (fully visible)
|
|
237
|
-
*/
|
|
238
|
-
setRevealProgress(alpha: number): void;
|
|
239
|
-
/**
|
|
240
|
-
* Get the center of this MathTex
|
|
241
|
-
*/
|
|
242
|
-
getCenter(): Vector3Tuple;
|
|
243
|
-
/**
|
|
244
|
-
* Clean up Three.js resources
|
|
245
|
-
*/
|
|
246
|
-
dispose(): void;
|
|
247
101
|
}
|
|
248
|
-
|
|
102
|
+
/**
|
|
103
|
+
* @deprecated Use `MathTex` instead. `MathTexSVG` is a backwards-compatible alias.
|
|
104
|
+
*/
|
|
105
|
+
export declare const MathTexSVG: typeof MathTex;
|
|
106
|
+
/** @deprecated Use `MathTexOptions` instead. */
|
|
107
|
+
export type MathTexSVGOptions = MathTexOptions;
|
|
249
108
|
//# sourceMappingURL=MathTex.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MathTex.d.ts","sourceRoot":"","sources":["../../../src/mobjects/text/MathTex.ts"],"names":[],"mappings":"AACA
|
|
1
|
+
{"version":3,"file":"MathTex.d.ts","sourceRoot":"","sources":["../../../src/mobjects/text/MathTex.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,KAAK,EAAW,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIhE,MAAM,WAAW,cAAc;IAC7B,mEAAmE;IACnE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAA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C;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAU9B;;OAEG;IACH,YAAY,IAAI,MAAM;IAItB;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;;OAGG;IACH,cAAc,IAAI,KAAK,GAAG,IAAI;IAI9B;;OAEG;IACM,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IA0BtC;;OAEG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAW9B;;OAEG;cACa,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAiCxC;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAgB/C;;OAEG;IACH,SAAS,CAAC,cAAc,IAAI,IAAI;IAwDhC;;;;;OAKG;YACW,gBAAgB;IA2E9B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU,CAqBvB;IAEF;;OAEG;cACgB,WAAW,IAAI,OAAO;CAgB1C;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,gBAAU,CAAC;AAClC,gDAAgD;AAChD,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC"}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { Mobject, Vector3Tuple } from '../../core/Mobject';
|
|
2
|
+
/**
|
|
3
|
+
* MathTexImage - Rasterized LaTeX rendering for manimweb using KaTeX (default) or MathJax (fallback)
|
|
4
|
+
*
|
|
5
|
+
* This module provides LaTeX math rendering capabilities by:
|
|
6
|
+
* 1. Using KaTeX to render LaTeX to HTML (fast, limited subset)
|
|
7
|
+
* 2. Falling back to MathJax SVG output for unsupported LaTeX (full LaTeX support)
|
|
8
|
+
* 3. Converting output to canvas via DOM walking / SVG foreignObject
|
|
9
|
+
* 4. Creating a THREE.js textured plane mesh
|
|
10
|
+
*
|
|
11
|
+
* Renderer selection:
|
|
12
|
+
* - 'katex' : KaTeX only (fast, limited subset)
|
|
13
|
+
* - 'mathjax': MathJax only (slower, full LaTeX including \usepackage, align, etc.)
|
|
14
|
+
* - 'auto' : Try KaTeX first; fall back to MathJax if KaTeX throws (default)
|
|
15
|
+
*
|
|
16
|
+
* NOTE: This is the rasterized (texture-based) renderer. For SVG path-based
|
|
17
|
+
* rendering (recommended), use MathTex from './MathTex' instead.
|
|
18
|
+
*/
|
|
19
|
+
import * as THREE from 'three';
|
|
20
|
+
/**
|
|
21
|
+
* Which renderer to use for LaTeX.
|
|
22
|
+
* - 'katex' : KaTeX only (fast, but limited LaTeX subset)
|
|
23
|
+
* - 'mathjax': MathJax SVG only (slower, full LaTeX support)
|
|
24
|
+
* - 'auto' : Try KaTeX first; if it throws, fall back to MathJax
|
|
25
|
+
*/
|
|
26
|
+
export type TexRenderer = 'katex' | 'mathjax' | 'auto';
|
|
27
|
+
/**
|
|
28
|
+
* Options for creating a MathTexImage object
|
|
29
|
+
*/
|
|
30
|
+
export interface MathTexImageOptions {
|
|
31
|
+
/** LaTeX string or array of strings for multi-part expressions.
|
|
32
|
+
* When an array is provided, each string becomes a separate sub-mobject
|
|
33
|
+
* accessible via getPart(index), matching Python Manim's behavior. */
|
|
34
|
+
latex: string | string[];
|
|
35
|
+
/** Color as CSS color string. Default: '#ffffff' */
|
|
36
|
+
color?: string;
|
|
37
|
+
/** Base font size in pixels. Default: 48 */
|
|
38
|
+
fontSize?: number;
|
|
39
|
+
/** Use display mode (block) vs inline mode. Default: true */
|
|
40
|
+
displayMode?: boolean;
|
|
41
|
+
/** Position in 3D space. Default: [0, 0, 0] */
|
|
42
|
+
position?: Vector3Tuple;
|
|
43
|
+
/** Internal: padding in pixels around the rendered content. Default: 10 */
|
|
44
|
+
_padding?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Which renderer to use.
|
|
47
|
+
* - 'katex' : KaTeX only (fast)
|
|
48
|
+
* - 'mathjax': MathJax SVG only (full LaTeX support)
|
|
49
|
+
* - 'auto' : KaTeX first, MathJax fallback (default)
|
|
50
|
+
*/
|
|
51
|
+
renderer?: TexRenderer;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Internal state for async rendering
|
|
55
|
+
*/
|
|
56
|
+
interface RenderState {
|
|
57
|
+
canvas: HTMLCanvasElement | null;
|
|
58
|
+
texture: THREE.CanvasTexture | null;
|
|
59
|
+
mesh: THREE.Mesh | null;
|
|
60
|
+
width: number;
|
|
61
|
+
height: number;
|
|
62
|
+
isRendering: boolean;
|
|
63
|
+
renderPromise: Promise<void> | null;
|
|
64
|
+
renderError: Error | null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* MathTexImage - A mobject for rendering LaTeX mathematical expressions via rasterization
|
|
68
|
+
*
|
|
69
|
+
* Uses KaTeX for LaTeX parsing and renders to a textured plane in Three.js.
|
|
70
|
+
* The rendering is asynchronous but the constructor is synchronous.
|
|
71
|
+
*
|
|
72
|
+
* NOTE: For SVG path-based rendering (recommended, like Python Manim), use MathTex instead.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* // Create a simple equation (rasterized)
|
|
77
|
+
* const equation = new MathTexImage({ latex: 'E = mc^2' });
|
|
78
|
+
*
|
|
79
|
+
* // Create a colored integral
|
|
80
|
+
* const integral = new MathTexImage({
|
|
81
|
+
* latex: '\\int_0^\\infty e^{-x^2} dx = \\frac{\\sqrt{\\pi}}{2}',
|
|
82
|
+
* color: '#00ff00',
|
|
83
|
+
* fontSize: 64
|
|
84
|
+
* });
|
|
85
|
+
*
|
|
86
|
+
* // Wait for rendering to complete before animating
|
|
87
|
+
* await integral.waitForRender();
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare class MathTexImage extends Mobject {
|
|
91
|
+
protected _latex: string;
|
|
92
|
+
protected _fontSize: number;
|
|
93
|
+
protected _displayMode: boolean;
|
|
94
|
+
protected _renderState: RenderState;
|
|
95
|
+
/** User-requested renderer mode */
|
|
96
|
+
protected _renderer: TexRenderer;
|
|
97
|
+
/** Which renderer was actually used for the last successful render */
|
|
98
|
+
protected _activeRenderer: 'katex' | 'mathjax' | null;
|
|
99
|
+
/** Whether this is a multi-part MathTexImage (created from string[]) */
|
|
100
|
+
protected _isMultiPart: boolean;
|
|
101
|
+
/** Child MathTexImage parts (only when _isMultiPart is true) */
|
|
102
|
+
protected _parts: MathTexImage[];
|
|
103
|
+
/** Promise that resolves when parts are arranged (multi-part only) */
|
|
104
|
+
protected _arrangePromise: Promise<void> | null;
|
|
105
|
+
/** Padding in pixels around rendered content */
|
|
106
|
+
protected _padding: number;
|
|
107
|
+
constructor(options: MathTexImageOptions);
|
|
108
|
+
/**
|
|
109
|
+
* Get the renderer mode
|
|
110
|
+
*/
|
|
111
|
+
getRenderer(): TexRenderer;
|
|
112
|
+
/**
|
|
113
|
+
* Get which renderer was actually used for the current render.
|
|
114
|
+
* Returns null if not yet rendered.
|
|
115
|
+
*/
|
|
116
|
+
getActiveRenderer(): 'katex' | 'mathjax' | null;
|
|
117
|
+
/**
|
|
118
|
+
* Set the renderer mode and re-render.
|
|
119
|
+
* @param renderer The renderer to use
|
|
120
|
+
* @returns this for chaining
|
|
121
|
+
*/
|
|
122
|
+
setRenderer(renderer: TexRenderer): this;
|
|
123
|
+
/**
|
|
124
|
+
* Get the LaTeX string
|
|
125
|
+
*/
|
|
126
|
+
getLatex(): string;
|
|
127
|
+
/**
|
|
128
|
+
* Set the LaTeX string and re-render
|
|
129
|
+
* @param latex New LaTeX string
|
|
130
|
+
* @returns this for chaining
|
|
131
|
+
*/
|
|
132
|
+
setLatex(latex: string): this;
|
|
133
|
+
/**
|
|
134
|
+
* Get the font size
|
|
135
|
+
*/
|
|
136
|
+
getFontSize(): number;
|
|
137
|
+
/**
|
|
138
|
+
* Set the font size and re-render
|
|
139
|
+
* @param size New font size in pixels
|
|
140
|
+
* @returns this for chaining
|
|
141
|
+
*/
|
|
142
|
+
setFontSize(size: number): this;
|
|
143
|
+
/**
|
|
144
|
+
* Override setColor — texture is always rendered white, so we only need
|
|
145
|
+
* to update the material tint via _syncMaterialToThree (no re-render).
|
|
146
|
+
*/
|
|
147
|
+
setColor(color: string): this;
|
|
148
|
+
/**
|
|
149
|
+
* Override setStrokeOpacity to propagate to multi-part children.
|
|
150
|
+
*/
|
|
151
|
+
setStrokeOpacity(opacity: number): this;
|
|
152
|
+
/**
|
|
153
|
+
* Wait for the LaTeX to finish rendering.
|
|
154
|
+
* For multi-part MathTexImage, waits for all parts to render and be arranged.
|
|
155
|
+
* @returns Promise that resolves when rendering is complete
|
|
156
|
+
*/
|
|
157
|
+
waitForRender(): Promise<void>;
|
|
158
|
+
/**
|
|
159
|
+
* Get a sub-part of a multi-part MathTexImage expression.
|
|
160
|
+
* Only available when the MathTexImage was created with a string array.
|
|
161
|
+
* @param index Zero-based index of the part
|
|
162
|
+
* @returns The MathTexImage sub-part at the given index
|
|
163
|
+
*/
|
|
164
|
+
getPart(index: number): MathTexImage;
|
|
165
|
+
/**
|
|
166
|
+
* Get the number of parts (1 for single-string, N for multi-part).
|
|
167
|
+
*/
|
|
168
|
+
getPartCount(): number;
|
|
169
|
+
/**
|
|
170
|
+
* Arrange child parts horizontally after they all render.
|
|
171
|
+
* Positions parts so their content (minus padding) is seamlessly adjacent.
|
|
172
|
+
*/
|
|
173
|
+
private _arrangeParts;
|
|
174
|
+
/**
|
|
175
|
+
* Check if rendering is in progress
|
|
176
|
+
*/
|
|
177
|
+
isRendering(): boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Get the rendered dimensions in world units
|
|
180
|
+
* @returns [width, height] or [0, 0] if not yet rendered
|
|
181
|
+
*/
|
|
182
|
+
getDimensions(): [number, number];
|
|
183
|
+
/**
|
|
184
|
+
* Start the async rendering process
|
|
185
|
+
*/
|
|
186
|
+
protected _startRender(): void;
|
|
187
|
+
/**
|
|
188
|
+
* Render the LaTeX to a canvas using the selected renderer.
|
|
189
|
+
*
|
|
190
|
+
* Renderer selection logic:
|
|
191
|
+
* - 'katex' : Use KaTeX directly (throwOnError: false)
|
|
192
|
+
* - 'mathjax': Use MathJax SVG output, rendered to canvas via Image
|
|
193
|
+
* - 'auto' : Try KaTeX with throwOnError: true. If it throws,
|
|
194
|
+
* fall back to MathJax.
|
|
195
|
+
*/
|
|
196
|
+
protected _renderLatex(): Promise<void>;
|
|
197
|
+
/**
|
|
198
|
+
* Determine which concrete renderer to use for the current LaTeX string.
|
|
199
|
+
*/
|
|
200
|
+
private _resolveRenderer;
|
|
201
|
+
/**
|
|
202
|
+
* Parse an SVG dimension attribute that may use "ex" units and convert
|
|
203
|
+
* to pixels. MathJax outputs width/height like "5.002ex"; parseFloat
|
|
204
|
+
* strips the suffix, so we detect "ex" and scale appropriately.
|
|
205
|
+
*/
|
|
206
|
+
private _parseSvgDimension;
|
|
207
|
+
/**
|
|
208
|
+
* Render using MathJax SVG output. The SVG is painted onto a canvas
|
|
209
|
+
* texture in the same way the KaTeX path works, keeping the visual
|
|
210
|
+
* pipeline consistent.
|
|
211
|
+
*/
|
|
212
|
+
protected _renderLatexViaMathJax(): Promise<void>;
|
|
213
|
+
/**
|
|
214
|
+
* Render the LaTeX to a canvas by walking the KaTeX DOM
|
|
215
|
+
* and drawing each text element at its computed CSS position.
|
|
216
|
+
*/
|
|
217
|
+
protected _renderLatexViaKaTeX(): Promise<void>;
|
|
218
|
+
/**
|
|
219
|
+
* Walk the KaTeX DOM tree and render text nodes + SVG elements
|
|
220
|
+
* at their computed CSS positions onto a canvas.
|
|
221
|
+
*/
|
|
222
|
+
protected _renderDomToCanvas(container: HTMLElement, containerRect: DOMRect, width: number, height: number, padding: number): Promise<HTMLCanvasElement>;
|
|
223
|
+
/**
|
|
224
|
+
* Update the mesh geometry to match current dimensions
|
|
225
|
+
*/
|
|
226
|
+
protected _updateMeshGeometry(): void;
|
|
227
|
+
/**
|
|
228
|
+
* Create the Three.js backing object
|
|
229
|
+
*/
|
|
230
|
+
protected _createThreeObject(): THREE.Object3D;
|
|
231
|
+
/**
|
|
232
|
+
* Sync material properties to Three.js
|
|
233
|
+
*/
|
|
234
|
+
protected _syncMaterialToThree(): void;
|
|
235
|
+
/**
|
|
236
|
+
* Create a copy of this MathTexImage
|
|
237
|
+
*/
|
|
238
|
+
protected _createCopy(): MathTexImage;
|
|
239
|
+
/**
|
|
240
|
+
* Set reveal progress for Write animation (left-to-right wipe).
|
|
241
|
+
* @param alpha - Progress from 0 (hidden) to 1 (fully visible)
|
|
242
|
+
*/
|
|
243
|
+
setRevealProgress(alpha: number): void;
|
|
244
|
+
/**
|
|
245
|
+
* Get the center of this MathTexImage
|
|
246
|
+
*/
|
|
247
|
+
getCenter(): Vector3Tuple;
|
|
248
|
+
/**
|
|
249
|
+
* Clean up Three.js resources
|
|
250
|
+
*/
|
|
251
|
+
dispose(): void;
|
|
252
|
+
}
|
|
253
|
+
export {};
|
|
254
|
+
//# sourceMappingURL=MathTexImage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MathTexImage.d.ts","sourceRoot":"","sources":["../../../src/mobjects/text/MathTexImage.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAI3D;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;2EAEuE;IACvE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CA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SAAS,CAAC,kBAAkB,IAAI,KAAK,CAAC,QAAQ;IA8B9C;;OAEG;cACgB,oBAAoB,IAAI,IAAI;IAqB/C;;OAEG;cACgB,WAAW,IAAI,YAAY;IAY9C;;;OAGG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAiCtC;;OAEG;IACM,SAAS,IAAI,YAAY;IAIlC;;OAEG;IACM,OAAO,IAAI,IAAI;CAUzB"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MathTexImage, MathTexImageOptions } from './MathTexImage';
|
|
2
2
|
import { VGroup } from '../../core/VGroup';
|
|
3
|
-
export type SingleStringMathTexOptions = Omit<
|
|
3
|
+
export type SingleStringMathTexOptions = Omit<MathTexImageOptions, 'latex'>;
|
|
4
4
|
/**
|
|
5
|
-
* SingleStringMathTex - A variant of
|
|
5
|
+
* SingleStringMathTex - A variant of MathTexImage for single-string LaTeX
|
|
6
6
|
*
|
|
7
|
-
* Wraps
|
|
7
|
+
* Wraps MathTexImage but enforces that the LaTeX is treated as a single
|
|
8
8
|
* indivisible expression (no part splitting).
|
|
9
9
|
*/
|
|
10
|
-
export declare class SingleStringMathTex extends
|
|
10
|
+
export declare class SingleStringMathTex extends MathTexImage {
|
|
11
11
|
constructor(latex: string, options?: SingleStringMathTexOptions);
|
|
12
12
|
/**
|
|
13
13
|
* Get the LaTeX source string
|
|
@@ -21,10 +21,10 @@ export interface MathTexPartOptions {
|
|
|
21
21
|
fontSize?: number;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* MathTexPart - Represents a selectable part of a
|
|
24
|
+
* MathTexPart - Represents a selectable part of a MathTexImage expression
|
|
25
25
|
*
|
|
26
|
-
* Allows creating
|
|
27
|
-
* Each part is a separate
|
|
26
|
+
* Allows creating MathTexImage expressions with individually styleable/animatable parts.
|
|
27
|
+
* Each part is a separate MathTexImage that can be colored or animated independently.
|
|
28
28
|
*
|
|
29
29
|
* @example
|
|
30
30
|
* ```typescript
|
|
@@ -55,11 +55,11 @@ export declare class MathTexPart extends VGroup {
|
|
|
55
55
|
/**
|
|
56
56
|
* Get a specific part by index
|
|
57
57
|
*/
|
|
58
|
-
getPart(index: number):
|
|
58
|
+
getPart(index: number): MathTexImage | undefined;
|
|
59
59
|
/**
|
|
60
60
|
* Get all parts
|
|
61
61
|
*/
|
|
62
|
-
getParts():
|
|
62
|
+
getParts(): MathTexImage[];
|
|
63
63
|
/**
|
|
64
64
|
* Get the number of parts
|
|
65
65
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MathTexParts.d.ts","sourceRoot":"","sources":["../../../src/mobjects/text/MathTexParts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"MathTexParts.d.ts","sourceRoot":"","sources":["../../../src/mobjects/text/MathTexParts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;AAE5E;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,YAAY;gBACvC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,0BAA+B;IAInE;;OAEG;IACH,YAAY,IAAI,MAAM;CAGvB;AAED,MAAM,WAAW,kBAAkB;IACjC,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,WAAY,SAAQ,MAAM;IACrC,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,YAAY,CAAgB;;IAMpC;;OAEG;IACH,MAAM,CAAC,SAAS,CACd,KAAK,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,EAClE,OAAO,GAAE,MAAY,GACpB,WAAW;IAgCd;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAIhD;;OAEG;IACH,QAAQ,IAAI,YAAY,EAAE;IAI1B;;OAEG;IACH,WAAW,IAAI,MAAM;IAIrB;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAOhD;;OAEG;IACH,cAAc,IAAI,MAAM,EAAE;IAI1B;;OAEG;IACH,YAAY,IAAI,MAAM;CAGvB"}
|
|
@@ -19,17 +19,12 @@ export type TexOptions = MathTexOptions;
|
|
|
19
19
|
* const colored = new Tex({
|
|
20
20
|
* latex: '\\frac{d}{dx}\\sin(x) = \\cos(x)',
|
|
21
21
|
* color: '#ffff00',
|
|
22
|
-
* fontSize: 56
|
|
23
|
-
* });
|
|
24
|
-
*
|
|
25
|
-
* // Use MathJax for advanced LaTeX
|
|
26
|
-
* const chem = new Tex({
|
|
27
|
-
* latex: '\\ce{H2O -> H+ + OH-}',
|
|
28
|
-
* renderer: 'mathjax'
|
|
29
22
|
* });
|
|
30
23
|
* ```
|
|
31
24
|
*/
|
|
32
25
|
export declare class Tex extends MathTex {
|
|
26
|
+
/** Original unwrapped latex, used by _createCopy to avoid double-wrapping */
|
|
27
|
+
private _originalLatex;
|
|
33
28
|
constructor(options: TexOptions);
|
|
34
29
|
/**
|
|
35
30
|
* Create a copy of this Tex
|