manim-web 0.3.5 → 0.3.7

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 (159) hide show
  1. package/dist/animation/Animation.d.ts +16 -1
  2. package/dist/animation/Animation.d.ts.map +1 -1
  3. package/dist/animation/MasterTimeline.d.ts +70 -0
  4. package/dist/animation/MasterTimeline.d.ts.map +1 -0
  5. package/dist/animation/Timeline.d.ts +1 -1
  6. package/dist/animation/Timeline.d.ts.map +1 -1
  7. package/dist/animation/fading/FadeIn.d.ts.map +1 -1
  8. package/dist/animation/movement/Shift.d.ts +2 -3
  9. package/dist/animation/movement/Shift.d.ts.map +1 -1
  10. package/dist/animation/transform/ApplyTransforms.d.ts +91 -0
  11. package/dist/animation/transform/ApplyTransforms.d.ts.map +1 -0
  12. package/dist/animation/transform/FadeTransforms.d.ts +76 -0
  13. package/dist/animation/transform/FadeTransforms.d.ts.map +1 -0
  14. package/dist/animation/transform/MovementTransforms.d.ts +131 -0
  15. package/dist/animation/transform/MovementTransforms.d.ts.map +1 -0
  16. package/dist/animation/transform/SpecialTransforms.d.ts +158 -0
  17. package/dist/animation/transform/SpecialTransforms.d.ts.map +1 -0
  18. package/dist/animation/transform/TransformExtensions.d.ts +11 -430
  19. package/dist/animation/transform/TransformExtensions.d.ts.map +1 -1
  20. package/dist/animation/transform/index.d.ts +4 -1
  21. package/dist/animation/transform/index.d.ts.map +1 -1
  22. package/dist/core/Group.d.ts +4 -1
  23. package/dist/core/Group.d.ts.map +1 -1
  24. package/dist/core/InteractiveScene.d.ts.map +1 -1
  25. package/dist/core/LinearTransformationScene.d.ts +152 -0
  26. package/dist/core/LinearTransformationScene.d.ts.map +1 -0
  27. package/dist/core/Mobject.d.ts +26 -389
  28. package/dist/core/Mobject.d.ts.map +1 -1
  29. package/dist/core/MobjectPositioning.d.ts +32 -0
  30. package/dist/core/MobjectPositioning.d.ts.map +1 -0
  31. package/dist/core/MobjectState.d.ts +40 -0
  32. package/dist/core/MobjectState.d.ts.map +1 -0
  33. package/dist/core/MobjectTypes.d.ts +51 -0
  34. package/dist/core/MobjectTypes.d.ts.map +1 -0
  35. package/dist/core/MovingCameraScene.d.ts +77 -0
  36. package/dist/core/MovingCameraScene.d.ts.map +1 -0
  37. package/dist/core/Renderer.d.ts +5 -0
  38. package/dist/core/Renderer.d.ts.map +1 -1
  39. package/dist/core/Scene.d.ts +88 -1
  40. package/dist/core/Scene.d.ts.map +1 -1
  41. package/dist/core/SceneExtensions.d.ts +7 -637
  42. package/dist/core/SceneExtensions.d.ts.map +1 -1
  43. package/dist/core/StateManager.d.ts.map +1 -1
  44. package/dist/core/ThreeDScene.d.ts +199 -0
  45. package/dist/core/ThreeDScene.d.ts.map +1 -0
  46. package/dist/core/VMobject.d.ts +48 -200
  47. package/dist/core/VMobject.d.ts.map +1 -1
  48. package/dist/core/VMobjectCurves.d.ts +25 -0
  49. package/dist/core/VMobjectCurves.d.ts.map +1 -0
  50. package/dist/core/VMobjectGeometry.d.ts +84 -0
  51. package/dist/core/VMobjectGeometry.d.ts.map +1 -0
  52. package/dist/core/VMobjectRendering.d.ts +138 -0
  53. package/dist/core/VMobjectRendering.d.ts.map +1 -0
  54. package/dist/core/VectorScene.d.ts +106 -0
  55. package/dist/core/VectorScene.d.ts.map +1 -0
  56. package/dist/core/ZoomedScene.d.ts +151 -0
  57. package/dist/core/ZoomedScene.d.ts.map +1 -0
  58. package/dist/core/index.d.ts +6 -2
  59. package/dist/core/index.d.ts.map +1 -1
  60. package/dist/export/GifExporter.d.ts +4 -3
  61. package/dist/export/GifExporter.d.ts.map +1 -1
  62. package/dist/export/VideoExporter.d.ts +3 -3
  63. package/dist/export/VideoExporter.d.ts.map +1 -1
  64. package/dist/index.d.ts +8 -3
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +13671 -12768
  67. package/dist/integrations/react.js +500 -461
  68. package/dist/integrations/vue.js +370 -331
  69. package/dist/interaction/Clickable.d.ts.map +1 -1
  70. package/dist/interaction/Draggable.d.ts.map +1 -1
  71. package/dist/interaction/Hoverable.d.ts.map +1 -1
  72. package/dist/interaction/SelectionManager.d.ts.map +1 -1
  73. package/dist/mobjects/geometry/AnnularSector.d.ts +107 -0
  74. package/dist/mobjects/geometry/AnnularSector.d.ts.map +1 -0
  75. package/dist/mobjects/geometry/Annulus.d.ts +89 -0
  76. package/dist/mobjects/geometry/Annulus.d.ts.map +1 -0
  77. package/dist/mobjects/geometry/ArcPolygon.d.ts +74 -0
  78. package/dist/mobjects/geometry/ArcPolygon.d.ts.map +1 -0
  79. package/dist/mobjects/geometry/ArcShapes.d.ts +11 -657
  80. package/dist/mobjects/geometry/ArcShapes.d.ts.map +1 -1
  81. package/dist/mobjects/geometry/BooleanOperations.d.ts.map +1 -1
  82. package/dist/mobjects/geometry/CurvedArrow.d.ts +95 -0
  83. package/dist/mobjects/geometry/CurvedArrow.d.ts.map +1 -0
  84. package/dist/mobjects/geometry/CurvedDoubleArrow.d.ts +60 -0
  85. package/dist/mobjects/geometry/CurvedDoubleArrow.d.ts.map +1 -0
  86. package/dist/mobjects/geometry/Ellipse.d.ts +98 -0
  87. package/dist/mobjects/geometry/Ellipse.d.ts.map +1 -0
  88. package/dist/mobjects/geometry/Rectangle.d.ts +3 -3
  89. package/dist/mobjects/geometry/Rectangle.d.ts.map +1 -1
  90. package/dist/mobjects/geometry/Sector.d.ts +99 -0
  91. package/dist/mobjects/geometry/Sector.d.ts.map +1 -0
  92. package/dist/mobjects/geometry/ShapeMatchers.d.ts +5 -1
  93. package/dist/mobjects/geometry/ShapeMatchers.d.ts.map +1 -1
  94. package/dist/mobjects/geometry/TangentialArc.d.ts +58 -0
  95. package/dist/mobjects/geometry/TangentialArc.d.ts.map +1 -0
  96. package/dist/mobjects/geometry/index.d.ts +10 -3
  97. package/dist/mobjects/geometry/index.d.ts.map +1 -1
  98. package/dist/mobjects/graph/DiGraph.d.ts +26 -0
  99. package/dist/mobjects/graph/DiGraph.d.ts.map +1 -0
  100. package/dist/mobjects/graph/GenericGraph.d.ts +184 -0
  101. package/dist/mobjects/graph/GenericGraph.d.ts.map +1 -0
  102. package/dist/mobjects/graph/Graph.d.ts +10 -0
  103. package/dist/mobjects/graph/Graph.d.ts.map +1 -0
  104. package/dist/mobjects/graph/graphFactories.d.ts +49 -0
  105. package/dist/mobjects/graph/graphFactories.d.ts.map +1 -0
  106. package/dist/mobjects/graph/graphTypes.d.ts +110 -0
  107. package/dist/mobjects/graph/graphTypes.d.ts.map +1 -0
  108. package/dist/mobjects/graph/index.d.ts +6 -417
  109. package/dist/mobjects/graph/index.d.ts.map +1 -1
  110. package/dist/mobjects/graph/layoutAlgorithms.d.ts +11 -0
  111. package/dist/mobjects/graph/layoutAlgorithms.d.ts.map +1 -0
  112. package/dist/mobjects/graphing/FunctionGraph.d.ts.map +1 -1
  113. package/dist/mobjects/graphing/ParametricFunction.d.ts +1 -1
  114. package/dist/mobjects/graphing/ParametricFunction.d.ts.map +1 -1
  115. package/dist/mobjects/image/index.d.ts +2 -1
  116. package/dist/mobjects/image/index.d.ts.map +1 -1
  117. package/dist/mobjects/point/Mobject1D.d.ts +129 -0
  118. package/dist/mobjects/point/Mobject1D.d.ts.map +1 -0
  119. package/dist/mobjects/point/Mobject2D.d.ts +170 -0
  120. package/dist/mobjects/point/Mobject2D.d.ts.map +1 -0
  121. package/dist/mobjects/point/PGroup.d.ts +111 -0
  122. package/dist/mobjects/point/PGroup.d.ts.map +1 -0
  123. package/dist/mobjects/point/PMobject.d.ts +152 -0
  124. package/dist/mobjects/point/PMobject.d.ts.map +1 -0
  125. package/dist/mobjects/point/PointCloudDot.d.ts +98 -0
  126. package/dist/mobjects/point/PointCloudDot.d.ts.map +1 -0
  127. package/dist/mobjects/point/PointMobject.d.ts +62 -0
  128. package/dist/mobjects/point/PointMobject.d.ts.map +1 -0
  129. package/dist/mobjects/point/index.d.ts +7 -701
  130. package/dist/mobjects/point/index.d.ts.map +1 -1
  131. package/dist/mobjects/svg/Brace.d.ts.map +1 -1
  132. package/dist/mobjects/text/Code.d.ts +2 -39
  133. package/dist/mobjects/text/Code.d.ts.map +1 -1
  134. package/dist/mobjects/text/CodeHighlighting.d.ts +50 -0
  135. package/dist/mobjects/text/CodeHighlighting.d.ts.map +1 -0
  136. package/dist/mobjects/text/CodeLanguageData.d.ts +25 -0
  137. package/dist/mobjects/text/CodeLanguageData.d.ts.map +1 -0
  138. package/dist/mobjects/text/DecimalNumber.d.ts.map +1 -1
  139. package/dist/mobjects/text/MathTex.d.ts +1 -0
  140. package/dist/mobjects/text/MathTex.d.ts.map +1 -1
  141. package/dist/mobjects/text/MathTexSVG.d.ts +2 -0
  142. package/dist/mobjects/text/MathTexSVG.d.ts.map +1 -1
  143. package/dist/mobjects/text/Text.d.ts.map +1 -1
  144. package/dist/mobjects/text/Variable.d.ts.map +1 -1
  145. package/dist/mobjects/text/katex-styles.d.ts.map +1 -1
  146. package/dist/mobjects/three-d/Arrow3D.d.ts.map +1 -1
  147. package/dist/player/Player.d.ts +85 -0
  148. package/dist/player/Player.d.ts.map +1 -0
  149. package/dist/player/PlayerController.d.ts +22 -0
  150. package/dist/player/PlayerController.d.ts.map +1 -0
  151. package/dist/player/PlayerUI.d.ts +70 -0
  152. package/dist/player/PlayerUI.d.ts.map +1 -0
  153. package/dist/player/index.d.ts +4 -0
  154. package/dist/player/index.d.ts.map +1 -0
  155. package/dist/rate-functions/index.d.ts +144 -1
  156. package/dist/rate-functions/index.d.ts.map +1 -1
  157. package/dist/utils/hungarian.d.ts.map +1 -1
  158. package/dist/utils/skeletonize.d.ts.map +1 -1
  159. package/package.json +3 -3
@@ -0,0 +1,152 @@
1
+ import { Scene, SceneOptions } from './Scene';
2
+ import { Mobject, Vector3Tuple } from './Mobject';
3
+ /**
4
+ * Options for configuring a LinearTransformationScene.
5
+ */
6
+ export interface LinearTransformationSceneOptions extends SceneOptions {
7
+ /** X-axis range as [min, max, step]. Defaults to [-5, 5, 1]. */
8
+ xRange?: [number, number, number];
9
+ /** Y-axis range as [min, max, step]. Defaults to [-5, 5, 1]. */
10
+ yRange?: [number, number, number];
11
+ /** Visual length of the x-axis. Defaults to 10. */
12
+ xLength?: number;
13
+ /** Visual length of the y-axis. Defaults to 10. */
14
+ yLength?: number;
15
+ /** Color for the i basis vector. Defaults to green. */
16
+ iColor?: string;
17
+ /** Color for the j basis vector. Defaults to red. */
18
+ jColor?: string;
19
+ /** Whether to show basis vectors by default. Defaults to true. */
20
+ showBasisVectors?: boolean;
21
+ /** Color for background grid lines. Defaults to '#555555'. */
22
+ gridColor?: string;
23
+ }
24
+ /**
25
+ * Matrix type for 2D linear transformations.
26
+ * Represented as [[a, b], [c, d]] where the matrix is:
27
+ * | a b |
28
+ * | c d |
29
+ */
30
+ export type Matrix2D = [[number, number], [number, number]];
31
+ /**
32
+ * Scene for linear algebra visualizations.
33
+ * Shows basis vectors and a grid that transforms with matrices.
34
+ */
35
+ export declare class LinearTransformationScene extends Scene {
36
+ private _xRange;
37
+ private _yRange;
38
+ private _xLength;
39
+ private _yLength;
40
+ private _iColor;
41
+ private _jColor;
42
+ private _gridColor;
43
+ private _grid;
44
+ private _iVector;
45
+ private _jVector;
46
+ private _transformableObjects;
47
+ private _currentMatrix;
48
+ private _showBasisVectors;
49
+ /**
50
+ * Create a new linear transformation scene.
51
+ * @param container - DOM element to render into
52
+ * @param options - Scene configuration options
53
+ */
54
+ constructor(container: HTMLElement, options?: LinearTransformationSceneOptions);
55
+ /**
56
+ * Set up the background grid.
57
+ */
58
+ private _setupGrid;
59
+ /**
60
+ * Set up the basis vectors.
61
+ */
62
+ private _setupBasisVectors;
63
+ /**
64
+ * Convert x coordinate to visual x position.
65
+ */
66
+ private _coordToVisualX;
67
+ /**
68
+ * Convert y coordinate to visual y position.
69
+ */
70
+ private _coordToVisualY;
71
+ /**
72
+ * Convert graph coordinates to visual point coordinates.
73
+ * @param x - X coordinate in graph space
74
+ * @param y - Y coordinate in graph space
75
+ * @returns The visual point [x, y, z]
76
+ */
77
+ coordsToPoint(x: number, y: number): Vector3Tuple;
78
+ /**
79
+ * Convert visual point to graph coordinates.
80
+ * @param point - Visual point [x, y, z]
81
+ * @returns Graph coordinates [x, y]
82
+ */
83
+ pointToCoords(point: Vector3Tuple): [number, number];
84
+ /**
85
+ * Get the i basis vector mobject.
86
+ */
87
+ get iVector(): Mobject | null;
88
+ /**
89
+ * Get the j basis vector mobject.
90
+ */
91
+ get jVector(): Mobject | null;
92
+ /**
93
+ * Get the background grid mobject.
94
+ */
95
+ get grid(): Mobject | null;
96
+ /**
97
+ * Get the current transformation matrix.
98
+ */
99
+ get currentMatrix(): Matrix2D;
100
+ /**
101
+ * Apply a matrix transformation to all transformable objects.
102
+ * @param matrix - 2D transformation matrix [[a, b], [c, d]]
103
+ * @returns this for chaining
104
+ */
105
+ applyMatrix(matrix: Matrix2D): this;
106
+ /**
107
+ * Reset the transformation to identity.
108
+ * @returns this for chaining
109
+ */
110
+ resetTransformation(): this;
111
+ /**
112
+ * Rebuild the scene from scratch.
113
+ */
114
+ private _rebuildScene;
115
+ /**
116
+ * Add a vector to the scene that will transform with the matrix.
117
+ * @param vector - Vector coordinates [x, y]
118
+ * @param options - Optional configuration
119
+ * @returns The created vector mobject
120
+ */
121
+ addVector(vector: [number, number], options?: {
122
+ color?: string;
123
+ addToTransformable?: boolean;
124
+ }): Mobject;
125
+ /**
126
+ * Add a mobject (such as a label or shape) that will transform with the matrix.
127
+ * Use this to add any mobject that should participate in linear transformations.
128
+ * @param mobject - The mobject to add
129
+ * @param position - Optional position [x, y] in graph coordinates
130
+ * @returns The added mobject
131
+ */
132
+ addTransformableLabel(mobject: Mobject, position?: [number, number]): Mobject;
133
+ /**
134
+ * Get the origin point in visual coordinates.
135
+ */
136
+ getOrigin(): Vector3Tuple;
137
+ /**
138
+ * Show the basis vectors if hidden.
139
+ * @returns this for chaining
140
+ */
141
+ showBasisVectors(): this;
142
+ /**
143
+ * Hide the basis vectors.
144
+ * @returns this for chaining
145
+ */
146
+ hideBasisVectors(): this;
147
+ /**
148
+ * Clean up all resources.
149
+ */
150
+ dispose(): void;
151
+ }
152
+ //# sourceMappingURL=LinearTransformationScene.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinearTransformationScene.d.ts","sourceRoot":"","sources":["../../src/core/LinearTransformationScene.ts"],"names":[],"mappings":"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"}
@@ -1,247 +1,66 @@
1
+ import { Vector3Tuple, UpdaterFunction, MobjectStyle } from './MobjectTypes';
1
2
  import * as THREE from 'three';
2
- /**
3
- * Vector3 type as a tuple for external API
4
- */
5
- export type Vector3Tuple = [number, number, number];
6
- export declare const UP: Vector3Tuple;
7
- export declare const DOWN: Vector3Tuple;
8
- export declare const LEFT: Vector3Tuple;
9
- export declare const RIGHT: Vector3Tuple;
10
- export declare const OUT: Vector3Tuple;
11
- export declare const IN: Vector3Tuple;
12
- export declare const ORIGIN: Vector3Tuple;
13
- export declare const UL: Vector3Tuple;
14
- export declare const UR: Vector3Tuple;
15
- export declare const DL: Vector3Tuple;
16
- export declare const DR: Vector3Tuple;
17
- /**
18
- * Updater function type that runs every frame
19
- * @param mobject - The mobject being updated
20
- * @param dt - Delta time in seconds since last frame
21
- */
22
- export type UpdaterFunction = (mobject: Mobject, dt: number) => void;
23
- /**
24
- * Style properties for mobjects
25
- */
26
- export interface MobjectStyle {
27
- fillColor?: string;
28
- fillOpacity?: number;
29
- strokeColor?: string;
30
- strokeOpacity?: number;
31
- strokeWidth?: number;
32
- }
33
- /**
34
- * Base mathematical object class.
35
- * All visible objects in manimweb inherit from this class.
36
- */
3
+ export { type Vector3Tuple, type UpdaterFunction, type MobjectStyle, type VMobjectLike, isVMobjectLike, UP, DOWN, LEFT, RIGHT, OUT, IN, ORIGIN, UL, UR, DL, DR, } from './MobjectTypes';
4
+ /** Base mathematical object class. All visible objects in manimweb inherit from this class. */
37
5
  export declare abstract class Mobject {
38
- /** Unique identifier for this mobject */
39
6
  readonly id: string;
40
- /** Parent mobject in hierarchy */
41
7
  parent: Mobject | null;
42
- /** Child mobjects */
43
8
  children: Mobject[];
44
- /** Position in 3D space */
45
9
  position: THREE.Vector3;
46
- /** Rotation as Euler angles */
47
10
  rotation: THREE.Euler;
48
- /** Scale factors (named scaleVector to avoid conflict with scale method) */
49
11
  scaleVector: THREE.Vector3;
50
- /** Color as CSS color string (syncs stroke and fill via setter) */
51
12
  protected _color: string;
52
13
  get color(): string;
53
14
  set color(value: string);
54
- /** Overall opacity (0-1) - protected for backward compatibility */
55
15
  protected _opacity: number;
56
- /** Stroke width for outlines (default 4, matching Manim's thicker strokes) */
57
16
  strokeWidth: number;
58
- /** Fill opacity (0-1) */
59
17
  fillOpacity: number;
60
- /** When true, children skip the 2D z-layering offset in _syncToThree.
61
- * Set this on 3D container objects (e.g. ThreeDAxes) where z-offsets
62
- * would shift objects away from their intended 3D positions. */
18
+ /** When true, children skip the 2D z-layering offset in _syncToThree. */
63
19
  protected _disableChildZLayering: boolean;
64
- /** Style properties for backward compatibility */
65
20
  protected _style: MobjectStyle;
66
- /** Three.js backing object */
67
21
  _threeObject: THREE.Object3D | null;
68
- /** Dirty flag indicating transforms need sync */
69
22
  _dirty: boolean;
70
- /** Updater functions that run every frame */
71
23
  private _updaters;
72
- /**
73
- * Saved mobject copy (used by Restore animation in TransformExtensions).
74
- * Set by saveState().
75
- */
24
+ /** Saved mobject copy (used by Restore animation). Set by saveState(). */
76
25
  savedState: Mobject | null;
77
- /**
78
- * Target copy used by generateTarget() / MoveToTarget animation.
79
- * Call generateTarget() to create a copy, modify targetCopy, then
80
- * play MoveToTarget to interpolate from current to target state.
81
- */
26
+ /** Target copy used by generateTarget() / MoveToTarget animation. */
82
27
  targetCopy: Mobject | null;
83
- /**
84
- * JSON-serializable saved state (used by restoreState()).
85
- * Set by saveState() -- typed as `unknown` here to avoid circular import;
86
- * actual type is MobjectState from StateManager.ts.
87
- */
28
+ /** JSON-serializable saved state (used by restoreState()). */
88
29
  __savedMobjectState: unknown;
89
30
  private static _idCounter;
90
- private static _tempVec3;
91
- private static _tempBox3;
92
- private static _tempQuaternion;
93
31
  constructor();
94
- /**
95
- * Get the overall opacity of the mobject
96
- */
97
32
  get opacity(): number;
98
- /**
99
- * Set the overall opacity of the mobject
100
- */
101
33
  set opacity(value: number);
102
- /**
103
- * Get the style properties
104
- */
105
34
  get style(): MobjectStyle;
106
- /**
107
- * Set style properties
108
- */
109
35
  setStyle(style: Partial<MobjectStyle>): this;
110
- /**
111
- * Get all submobjects (alias for children)
112
- */
113
36
  get submobjects(): Mobject[];
114
- /**
115
- * Translate the mobject by a delta
116
- * @param delta - Translation vector [x, y, z]
117
- * @returns this for chaining
118
- */
37
+ setColor(color: string): this;
38
+ setOpacity(opacity: number): this;
39
+ setStrokeWidth(width: number): this;
40
+ setFillOpacity(opacity: number): this;
41
+ setFill(color?: string, opacity?: number): this;
42
+ get fillColor(): string | undefined;
43
+ set fillColor(color: string);
119
44
  shift(delta: Vector3Tuple): this;
120
- /**
121
- * Move the mobject to an absolute position, or align with another Mobject.
122
- * @param target - Target position [x, y, z] or Mobject to align with
123
- * @param alignedEdge - Optional edge direction to align (e.g., UL aligns upper-left edges)
124
- * @returns this for chaining
125
- */
126
45
  moveTo(target: Vector3Tuple | Mobject, alignedEdge?: Vector3Tuple): this;
127
46
  /**
128
- * Rotate the mobject around an axis
129
- * Uses object pooling to avoid allocations in hot paths (performance optimization).
130
- * @param angle - Rotation angle in radians
131
- * @param axisOrOptions - Axis of rotation [x, y, z] (defaults to Z axis), or options object
132
- * @returns this for chaining
47
+ * Rotate the mobject around an axis.
48
+ * Delegates to rotateMobject for the heavy lifting.
133
49
  */
134
50
  rotate(angle: number, axisOrOptions?: Vector3Tuple | {
135
51
  axis?: Vector3Tuple;
136
52
  aboutPoint?: Vector3Tuple;
137
53
  }): this;
138
- /**
139
- * Rotate the mobject about the coordinate origin [0, 0, 0].
140
- * @param angle - Rotation angle in radians
141
- * @param axis - Axis of rotation (defaults to Z axis [0, 0, 1])
142
- * @returns this for chaining
143
- */
144
54
  rotateAboutOrigin(angle: number, axis?: Vector3Tuple): this;
145
- /**
146
- * Flip the mobject along an axis (mirror reflection).
147
- * @param axis - Axis to flip across, defaults to RIGHT ([1,0,0]) for horizontal flip
148
- * @returns this for chaining
149
- */
150
55
  flip(axis?: Vector3Tuple): this;
151
- /**
152
- * Scale the mobject uniformly or non-uniformly
153
- * @param factor - Scale factor (number for uniform, tuple for non-uniform)
154
- * @returns this for chaining
155
- */
156
56
  scale(factor: number | Vector3Tuple): this;
157
- /**
158
- * Set the mobject's color
159
- * Only marks dirty if value actually changed (performance optimization).
160
- * @param color - CSS color string
161
- * @returns this for chaining
162
- */
163
- setColor(color: string): this;
164
- /**
165
- * Set the mobject's overall opacity
166
- * Only marks dirty if value actually changed (performance optimization).
167
- * @param opacity - Opacity value (0-1)
168
- * @returns this for chaining
169
- */
170
- setOpacity(opacity: number): this;
171
- /**
172
- * Set the stroke width for outlines
173
- * Only marks dirty if value actually changed (performance optimization).
174
- * @param width - Stroke width in pixels
175
- * @returns this for chaining
176
- */
177
- setStrokeWidth(width: number): this;
178
- /**
179
- * Set the fill opacity
180
- * Only marks dirty if value actually changed (performance optimization).
181
- * @param opacity - Fill opacity (0-1)
182
- * @returns this for chaining
183
- */
184
- setFillOpacity(opacity: number): this;
185
- /**
186
- * Set the fill color and/or opacity (Manim Python parity: set_fill)
187
- * @param color - CSS color string (optional)
188
- * @param opacity - Fill opacity 0-1 (optional)
189
- * @returns this for chaining
190
- */
191
- setFill(color?: string, opacity?: number): this;
192
- /**
193
- * Get the fill color
194
- */
195
- get fillColor(): string | undefined;
196
- /**
197
- * Set the fill color
198
- */
199
- set fillColor(color: string);
200
- /**
201
- * Add a child mobject (supports multiple arguments for backward compatibility)
202
- * @param mobjects - Child mobjects to add
203
- * @returns this for chaining
204
- */
205
57
  add(...mobjects: Mobject[]): this;
206
- /**
207
- * Remove a child mobject (supports multiple arguments for backward compatibility)
208
- * @param mobjects - Child mobjects to remove
209
- * @returns this for chaining
210
- */
211
58
  remove(...mobjects: Mobject[]): this;
212
- /**
213
- * Create a deep copy of this mobject
214
- * @returns New mobject with copied properties
215
- */
216
59
  copy(): Mobject;
217
- /**
218
- * Replace this mobject's visual properties with those of another mobject.
219
- * Preserves identity (updaters, scene membership) but copies appearance.
220
- * @param other - The mobject to copy appearance from
221
- * @returns this for chaining
222
- */
60
+ protected abstract _createCopy(): Mobject;
223
61
  become(other: Mobject): this;
224
- /**
225
- * Scale and reposition this mobject to match another mobject's bounding box.
226
- * Matches Manim Python's replace() behavior.
227
- * @param target - The mobject whose bounding box to match
228
- * @param stretch - If true, stretch per-axis to match exactly; if false (default), uniform scale to match width
229
- * @returns this for chaining
230
- */
231
62
  replace(target: Mobject, stretch?: boolean): this;
232
- /**
233
- * Create a new instance for copying. Subclasses must implement this.
234
- */
235
- protected abstract _createCopy(): Mobject;
236
- /**
237
- * Get the center point of this mobject
238
- * @returns Center position as [x, y, z]
239
- */
240
63
  getCenter(): Vector3Tuple;
241
- /**
242
- * Get the bounding box of this mobject in world coordinates.
243
- * @returns Object with min and max Vector3Tuple
244
- */
245
64
  getBounds(): {
246
65
  min: {
247
66
  x: number;
@@ -254,234 +73,52 @@ export declare abstract class Mobject {
254
73
  z: number;
255
74
  };
256
75
  };
257
- /**
258
- * Position this mobject next to another mobject
259
- * @param target The mobject to position next to
260
- * @param direction Direction from target (e.g., RIGHT, UP)
261
- * @param buff Buffer distance between mobjects, default 0.25
262
- * @returns this for chaining
263
- */
264
76
  nextTo(target: Mobject | Vector3Tuple, direction?: Vector3Tuple, buff?: number): this;
265
- /**
266
- * Align this mobject with another along an edge
267
- * @param target The mobject or point to align with
268
- * @param direction The direction/edge to align (e.g., LEFT aligns left edges)
269
- * @returns this for chaining
270
- */
271
77
  alignTo(target: Mobject | Vector3Tuple, direction: Vector3Tuple): this;
272
- /**
273
- * Move this mobject to align its center with a point or mobject center
274
- * @param target Target mobject or point to align with
275
- * @param alignedEdge Optional edge to align instead of centers
276
- * @returns this for chaining
277
- */
278
78
  moveToAligned(target: Mobject | Vector3Tuple, alignedEdge?: Vector3Tuple): this;
279
- /**
280
- * Get the edge point of the bounding box in a direction
281
- * @param direction Direction to get edge in
282
- * @returns Edge point as [x, y, z]
283
- */
284
79
  _getEdgeInDirection(direction: Vector3Tuple): Vector3Tuple;
285
- /**
286
- * Get bounding box dimensions
287
- * Uses object pooling to avoid allocations in hot paths (performance optimization).
288
- * @returns Object with width, height, and depth
289
- */
290
- protected _getBoundingBox(): {
80
+ getBoundingBox(): {
81
+ width: number;
82
+ height: number;
83
+ depth: number;
84
+ };
85
+ /** @deprecated Use getBoundingBox() instead. */
86
+ _getBoundingBox(): {
291
87
  width: number;
292
88
  height: number;
293
89
  depth: number;
294
90
  };
295
- /**
296
- * Get a specific edge point of the bounding box in a direction
297
- * @param direction Direction to the edge point
298
- * @returns Edge point as [x, y, z]
299
- */
300
91
  getEdge(direction: Vector3Tuple): Vector3Tuple;
301
- /**
302
- * Get the top edge center
303
- * @returns Top edge center as [x, y, z]
304
- */
305
92
  getTop(): Vector3Tuple;
306
- /**
307
- * Get the bottom edge center
308
- * @returns Bottom edge center as [x, y, z]
309
- */
310
93
  getBottom(): Vector3Tuple;
311
- /**
312
- * Get the left edge center
313
- * @returns Left edge center as [x, y, z]
314
- */
315
94
  getLeft(): Vector3Tuple;
316
- /**
317
- * Get the right edge center
318
- * @returns Right edge center as [x, y, z]
319
- */
320
95
  getRight(): Vector3Tuple;
321
- /**
322
- * Set the x-coordinate of this mobject's center, preserving y and z.
323
- * Matches Manim Python's set_x() behavior.
324
- */
325
96
  setX(x: number): this;
326
- /**
327
- * Set the y-coordinate of this mobject's center, preserving x and z.
328
- * Matches Manim Python's set_y() behavior.
329
- */
330
97
  setY(y: number): this;
331
- /**
332
- * Set the z-coordinate of this mobject's center, preserving x and y.
333
- * Matches Manim Python's set_z() behavior.
334
- */
335
98
  setZ(z: number): this;
336
- /**
337
- * Center this mobject at origin
338
- * @returns this for chaining
339
- */
340
99
  center(): this;
341
- /**
342
- * Move to the edge of the frame
343
- * @param direction Direction to move towards
344
- * @param buff Buffer from edge
345
- * @returns this for chaining
346
- */
347
- toEdge(direction: Vector3Tuple, buff?: number): this;
348
- /**
349
- * Move to a corner of the frame
350
- * @param direction Corner direction (e.g., UR for upper right)
351
- * @param buff Buffer from edges
352
- * @returns this for chaining
353
- */
354
- toCorner(direction?: Vector3Tuple, buff?: number): this;
355
- /**
356
- * Sync transform properties to the Three.js object
357
- */
100
+ toEdge(direction: Vector3Tuple, buff?: number, frameDimensions?: [number, number]): this;
101
+ toCorner(direction?: Vector3Tuple, buff?: number, frameDimensions?: [number, number]): this;
358
102
  _syncToThree(): void;
359
- /**
360
- * Sync material-specific properties. Override in subclasses.
361
- */
362
103
  protected _syncMaterialToThree(): void;
363
- /**
364
- * Mark this mobject as needing sync
365
- */
366
104
  _markDirty(): void;
367
- /**
368
- * Mark this mobject and all ancestors as needing sync.
369
- * Use when a deep child's geometry changes and the parent tree must re-traverse.
370
- * Short-circuits if this node is already dirty (ancestors must be dirty too).
371
- */
372
105
  _markDirtyUpward(): void;
373
- /**
374
- * Check if this mobject needs sync
375
- */
376
106
  get isDirty(): boolean;
377
- /**
378
- * Get the Three.js object, creating it if necessary
379
- */
380
107
  getThreeObject(): THREE.Object3D;
381
- /**
382
- * Create the Three.js backing object. Subclasses must implement.
383
- */
384
108
  protected abstract _createThreeObject(): THREE.Object3D;
385
- /**
386
- * Apply a function to this mobject and all descendants
387
- */
388
109
  applyToFamily(func: (mobject: Mobject) => void): this;
389
- /**
390
- * Get all mobjects in the family (this mobject and all descendants)
391
- */
392
110
  getFamily(): Mobject[];
393
- /**
394
- * Add an updater function that runs every frame
395
- * @param updater Function called with (mobject, dt) each frame
396
- * @param callOnAdd Whether to call immediately, default false
397
- * @returns this for chaining
398
- */
399
111
  addUpdater(updater: UpdaterFunction, callOnAdd?: boolean): this;
400
- /**
401
- * Remove an updater function
402
- * @param updater The updater function to remove
403
- * @returns this for chaining
404
- */
405
112
  removeUpdater(updater: UpdaterFunction): this;
406
- /**
407
- * Remove all updaters
408
- * @returns this for chaining
409
- */
410
113
  clearUpdaters(): this;
411
- /**
412
- * Check if this mobject has any updaters
413
- * @returns true if the mobject has updaters
414
- */
415
114
  hasUpdaters(): boolean;
416
- /**
417
- * Get all updaters (for internal use)
418
- * @returns A copy of the updaters array
419
- */
420
115
  getUpdaters(): UpdaterFunction[];
421
- /**
422
- * Run all updaters with given dt
423
- * Called by Scene during render loop
424
- * @param dt Delta time in seconds since last frame
425
- */
426
116
  update(dt: number): void;
427
- /**
428
- * Apply a point-wise function to every VMobject descendant's control points.
429
- * Uses duck-type check for getPoints/setPoints to avoid circular imports.
430
- * @param fn - Function mapping [x, y, z] to [x', y', z']
431
- * @returns this for chaining
432
- */
433
117
  applyFunction(fn: (point: number[]) => number[]): this;
434
- /**
435
- * Subdivide every VMobject descendant's cubic Bezier curves so that non-linear
436
- * transforms produce smooth results. Each cubic segment is split into n sub-segments
437
- * via de Casteljau evaluation.
438
- * @param numPieces - Number of sub-segments per original cubic segment (default 50)
439
- * @returns this for chaining
440
- */
441
118
  prepareForNonlinearTransform(numPieces?: number): this;
442
- /**
443
- * Create a copy of this mobject as a target for MoveToTarget animation.
444
- * Modify the returned copy, then play `new MoveToTarget(this)` to
445
- * smoothly interpolate from the current state to the target.
446
- *
447
- * @returns The target copy for modification
448
- *
449
- * @example
450
- * ```ts
451
- * mob.generateTarget();
452
- * mob.targetCopy!.shift([2, 0, 0]);
453
- * mob.targetCopy!.setColor('red');
454
- * await scene.play(new MoveToTarget(mob));
455
- * ```
456
- */
457
119
  generateTarget(): Mobject;
458
- /**
459
- * Save the current state of this mobject so it can be restored later.
460
- * Stores a deep copy on `this.savedState` (for Restore animation
461
- * compatibility) and a serializable snapshot on `this.__savedMobjectState`
462
- * (for restoreState).
463
- *
464
- * @returns this for chaining
465
- *
466
- * @example
467
- * ```ts
468
- * mob.saveState();
469
- * mob.shift([2, 0, 0]);
470
- * mob.setColor('red');
471
- * mob.restoreState(); // back to original position and color
472
- * ```
473
- */
474
120
  saveState(): this;
475
- /**
476
- * Restore this mobject to its previously saved state (from saveState).
477
- * Uses the deep copy stored on `this.savedState` to restore all properties.
478
- *
479
- * @returns true if state was restored, false if no saved state exists
480
- */
481
121
  restoreState(): boolean;
482
- /**
483
- * Clean up Three.js resources.
484
- */
485
122
  dispose(): void;
486
123
  }
487
124
  export default Mobject;