manim-web 0.3.6 → 0.3.8
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/dist/animation/Animation.d.ts +16 -1
- package/dist/animation/Animation.d.ts.map +1 -1
- package/dist/animation/MasterTimeline.d.ts +77 -0
- package/dist/animation/MasterTimeline.d.ts.map +1 -0
- package/dist/animation/Timeline.d.ts +1 -1
- package/dist/animation/Timeline.d.ts.map +1 -1
- package/dist/animation/transform/ApplyTransforms.d.ts +91 -0
- package/dist/animation/transform/ApplyTransforms.d.ts.map +1 -0
- package/dist/animation/transform/FadeTransforms.d.ts +76 -0
- package/dist/animation/transform/FadeTransforms.d.ts.map +1 -0
- package/dist/animation/transform/MovementTransforms.d.ts +131 -0
- package/dist/animation/transform/MovementTransforms.d.ts.map +1 -0
- package/dist/animation/transform/SpecialTransforms.d.ts +158 -0
- package/dist/animation/transform/SpecialTransforms.d.ts.map +1 -0
- package/dist/animation/transform/TransformExtensions.d.ts +11 -430
- package/dist/animation/transform/TransformExtensions.d.ts.map +1 -1
- package/dist/animation/transform/index.d.ts +4 -1
- package/dist/animation/transform/index.d.ts.map +1 -1
- package/dist/core/Group.d.ts +4 -1
- package/dist/core/Group.d.ts.map +1 -1
- package/dist/core/InteractiveScene.d.ts.map +1 -1
- package/dist/core/LinearTransformationScene.d.ts +152 -0
- package/dist/core/LinearTransformationScene.d.ts.map +1 -0
- package/dist/core/Mobject.d.ts +26 -389
- package/dist/core/Mobject.d.ts.map +1 -1
- package/dist/core/MobjectPositioning.d.ts +32 -0
- package/dist/core/MobjectPositioning.d.ts.map +1 -0
- package/dist/core/MobjectState.d.ts +40 -0
- package/dist/core/MobjectState.d.ts.map +1 -0
- package/dist/core/MobjectTypes.d.ts +51 -0
- package/dist/core/MobjectTypes.d.ts.map +1 -0
- package/dist/core/MovingCameraScene.d.ts +77 -0
- package/dist/core/MovingCameraScene.d.ts.map +1 -0
- package/dist/core/Renderer.d.ts +5 -0
- package/dist/core/Renderer.d.ts.map +1 -1
- package/dist/core/Scene.d.ts +25 -0
- package/dist/core/Scene.d.ts.map +1 -1
- package/dist/core/SceneExtensions.d.ts +7 -654
- package/dist/core/SceneExtensions.d.ts.map +1 -1
- package/dist/core/StateManager.d.ts.map +1 -1
- package/dist/core/ThreeDScene.d.ts +199 -0
- package/dist/core/ThreeDScene.d.ts.map +1 -0
- package/dist/core/VMobject.d.ts +48 -200
- package/dist/core/VMobject.d.ts.map +1 -1
- package/dist/core/VMobjectCurves.d.ts +25 -0
- package/dist/core/VMobjectCurves.d.ts.map +1 -0
- package/dist/core/VMobjectGeometry.d.ts +84 -0
- package/dist/core/VMobjectGeometry.d.ts.map +1 -0
- package/dist/core/VMobjectRendering.d.ts +138 -0
- package/dist/core/VMobjectRendering.d.ts.map +1 -0
- package/dist/core/VectorScene.d.ts +106 -0
- package/dist/core/VectorScene.d.ts.map +1 -0
- package/dist/core/ZoomedScene.d.ts +151 -0
- package/dist/core/ZoomedScene.d.ts.map +1 -0
- package/dist/core/index.d.ts +6 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/export/GifExporter.d.ts +4 -3
- package/dist/export/GifExporter.d.ts.map +1 -1
- package/dist/export/VideoExporter.d.ts.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13439 -12758
- package/dist/integrations/react.js +322 -318
- package/dist/integrations/vue.js +316 -312
- package/dist/interaction/Clickable.d.ts.map +1 -1
- package/dist/interaction/Draggable.d.ts.map +1 -1
- package/dist/interaction/Hoverable.d.ts.map +1 -1
- package/dist/interaction/SelectionManager.d.ts.map +1 -1
- package/dist/mobjects/geometry/AnnularSector.d.ts +107 -0
- package/dist/mobjects/geometry/AnnularSector.d.ts.map +1 -0
- package/dist/mobjects/geometry/Annulus.d.ts +89 -0
- package/dist/mobjects/geometry/Annulus.d.ts.map +1 -0
- package/dist/mobjects/geometry/ArcPolygon.d.ts +74 -0
- package/dist/mobjects/geometry/ArcPolygon.d.ts.map +1 -0
- package/dist/mobjects/geometry/ArcShapes.d.ts +11 -657
- package/dist/mobjects/geometry/ArcShapes.d.ts.map +1 -1
- package/dist/mobjects/geometry/BooleanOperations.d.ts.map +1 -1
- package/dist/mobjects/geometry/CurvedArrow.d.ts +95 -0
- package/dist/mobjects/geometry/CurvedArrow.d.ts.map +1 -0
- package/dist/mobjects/geometry/CurvedDoubleArrow.d.ts +60 -0
- package/dist/mobjects/geometry/CurvedDoubleArrow.d.ts.map +1 -0
- package/dist/mobjects/geometry/Ellipse.d.ts +98 -0
- package/dist/mobjects/geometry/Ellipse.d.ts.map +1 -0
- package/dist/mobjects/geometry/Rectangle.d.ts +3 -3
- package/dist/mobjects/geometry/Rectangle.d.ts.map +1 -1
- package/dist/mobjects/geometry/Sector.d.ts +99 -0
- package/dist/mobjects/geometry/Sector.d.ts.map +1 -0
- package/dist/mobjects/geometry/ShapeMatchers.d.ts +5 -1
- package/dist/mobjects/geometry/ShapeMatchers.d.ts.map +1 -1
- package/dist/mobjects/geometry/TangentialArc.d.ts +58 -0
- package/dist/mobjects/geometry/TangentialArc.d.ts.map +1 -0
- package/dist/mobjects/geometry/index.d.ts +10 -3
- package/dist/mobjects/geometry/index.d.ts.map +1 -1
- package/dist/mobjects/graph/DiGraph.d.ts +26 -0
- package/dist/mobjects/graph/DiGraph.d.ts.map +1 -0
- package/dist/mobjects/graph/GenericGraph.d.ts +184 -0
- package/dist/mobjects/graph/GenericGraph.d.ts.map +1 -0
- package/dist/mobjects/graph/Graph.d.ts +10 -0
- package/dist/mobjects/graph/Graph.d.ts.map +1 -0
- package/dist/mobjects/graph/graphFactories.d.ts +49 -0
- package/dist/mobjects/graph/graphFactories.d.ts.map +1 -0
- package/dist/mobjects/graph/graphTypes.d.ts +110 -0
- package/dist/mobjects/graph/graphTypes.d.ts.map +1 -0
- package/dist/mobjects/graph/index.d.ts +6 -417
- package/dist/mobjects/graph/index.d.ts.map +1 -1
- package/dist/mobjects/graph/layoutAlgorithms.d.ts +11 -0
- package/dist/mobjects/graph/layoutAlgorithms.d.ts.map +1 -0
- package/dist/mobjects/graphing/FunctionGraph.d.ts.map +1 -1
- package/dist/mobjects/graphing/ParametricFunction.d.ts +1 -1
- package/dist/mobjects/graphing/ParametricFunction.d.ts.map +1 -1
- package/dist/mobjects/image/index.d.ts +2 -1
- package/dist/mobjects/image/index.d.ts.map +1 -1
- package/dist/mobjects/point/Mobject1D.d.ts +129 -0
- package/dist/mobjects/point/Mobject1D.d.ts.map +1 -0
- package/dist/mobjects/point/Mobject2D.d.ts +170 -0
- package/dist/mobjects/point/Mobject2D.d.ts.map +1 -0
- package/dist/mobjects/point/PGroup.d.ts +111 -0
- package/dist/mobjects/point/PGroup.d.ts.map +1 -0
- package/dist/mobjects/point/PMobject.d.ts +152 -0
- package/dist/mobjects/point/PMobject.d.ts.map +1 -0
- package/dist/mobjects/point/PointCloudDot.d.ts +98 -0
- package/dist/mobjects/point/PointCloudDot.d.ts.map +1 -0
- package/dist/mobjects/point/PointMobject.d.ts +62 -0
- package/dist/mobjects/point/PointMobject.d.ts.map +1 -0
- package/dist/mobjects/point/index.d.ts +7 -701
- package/dist/mobjects/point/index.d.ts.map +1 -1
- package/dist/mobjects/svg/Brace.d.ts.map +1 -1
- package/dist/mobjects/text/Code.d.ts +2 -39
- package/dist/mobjects/text/Code.d.ts.map +1 -1
- package/dist/mobjects/text/CodeHighlighting.d.ts +50 -0
- package/dist/mobjects/text/CodeHighlighting.d.ts.map +1 -0
- package/dist/mobjects/text/CodeLanguageData.d.ts +25 -0
- package/dist/mobjects/text/CodeLanguageData.d.ts.map +1 -0
- package/dist/mobjects/text/MathTex.d.ts +1 -0
- package/dist/mobjects/text/MathTex.d.ts.map +1 -1
- package/dist/mobjects/text/MathTexSVG.d.ts +2 -0
- package/dist/mobjects/text/MathTexSVG.d.ts.map +1 -1
- package/dist/mobjects/text/Variable.d.ts.map +1 -1
- package/dist/mobjects/text/katex-styles.d.ts.map +1 -1
- package/dist/player/Player.d.ts +85 -0
- package/dist/player/Player.d.ts.map +1 -0
- package/dist/player/PlayerController.d.ts +22 -0
- package/dist/player/PlayerController.d.ts.map +1 -0
- package/dist/player/PlayerUI.d.ts +70 -0
- package/dist/player/PlayerUI.d.ts.map +1 -0
- package/dist/player/index.d.ts +4 -0
- package/dist/player/index.d.ts.map +1 -0
- package/dist/utils/hungarian.d.ts.map +1 -1
- package/dist/utils/skeletonize.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateManager.d.ts","sourceRoot":"","sources":["../../src/core/StateManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"StateManager.d.ts","sourceRoot":"","sources":["../../src/core/StateManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAY,KAAK,EAAE,MAAM,YAAY,CAAC;AAM7C;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAC;IAEX,yBAAyB;IACzB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAEnC,sCAAsC;IACtC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAE3C,sBAAsB;IACtB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhC,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IAEd,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAEhB,mBAAmB;IACnB,WAAW,EAAE,MAAM,CAAC;IAEpB,uBAAuB;IACvB,WAAW,EAAE,MAAM,CAAC;IAEpB,wBAAwB;IACxB,KAAK,EAAE,YAAY,CAAC;IAIpB,6BAA6B;IA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,CAAC,YAAY,CAAkB;IAEtC;;;OAGG;gBACS,WAAW,EAAE,MAAM,OAAO,EAAE,EAAE,QAAQ,GAAE,MAAW;IAS/D;;;;;;OAMG;IACH,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa;IAenC;;;;;OAKG;IACH,IAAI,IAAI,OAAO;IAcf;;;;;OAKG;IACH,IAAI,IAAI,OAAO;IAiBf;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa;IAIvC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAIvC;;OAEG;IACH,YAAY,IAAI,IAAI;IAKpB,qCAAqC;IACrC,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,qCAAqC;IACrC,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,gCAAgC;IAChC,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,gCAAgC;IAChC,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,qDAAqD;IACrD,IAAI,SAAS,IAAI,aAAa,CAAC,aAAa,CAAC,CAE5C;IAED,qDAAqD;IACrD,IAAI,SAAS,IAAI,aAAa,CAAC,aAAa,CAAC,CAE5C;IAMD,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,cAAc;CAOvB;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAW3D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAMzD"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { Scene, SceneOptions } from './Scene';
|
|
2
|
+
import { Camera3D } from './Camera';
|
|
3
|
+
import { Lighting } from './Lighting';
|
|
4
|
+
import { OrbitControls, OrbitControlsOptions } from '../interaction/OrbitControls';
|
|
5
|
+
import { Mobject, Vector3Tuple } from './Mobject';
|
|
6
|
+
/**
|
|
7
|
+
* Options for configuring a ThreeDScene.
|
|
8
|
+
*/
|
|
9
|
+
export interface ThreeDSceneOptions extends SceneOptions {
|
|
10
|
+
/** Camera field of view in degrees. Defaults to 45. */
|
|
11
|
+
fov?: number;
|
|
12
|
+
/** Initial camera phi angle (polar, from Y axis). Defaults to PI/4. */
|
|
13
|
+
phi?: number;
|
|
14
|
+
/** Initial camera theta angle (azimuthal, in XZ plane). Defaults to -PI/4. */
|
|
15
|
+
theta?: number;
|
|
16
|
+
/** Initial camera distance from origin. Defaults to 15. */
|
|
17
|
+
distance?: number;
|
|
18
|
+
/** Enable orbit controls for user interaction. Defaults to true. */
|
|
19
|
+
enableOrbitControls?: boolean;
|
|
20
|
+
/** Orbit controls configuration options. */
|
|
21
|
+
orbitControlsOptions?: OrbitControlsOptions;
|
|
22
|
+
/** Whether to set up default lighting. Defaults to true. */
|
|
23
|
+
setupLighting?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Scene configured for 3D content.
|
|
27
|
+
* Provides a 3D camera, orbit controls, and lighting setup by default.
|
|
28
|
+
* Compatible with the Timeline system for animations.
|
|
29
|
+
*/
|
|
30
|
+
export declare class ThreeDScene extends Scene {
|
|
31
|
+
private _camera3D;
|
|
32
|
+
private _lighting;
|
|
33
|
+
private _orbitControls;
|
|
34
|
+
private _orbitControlsEnabled;
|
|
35
|
+
private _isRendering;
|
|
36
|
+
private _orbitRafId;
|
|
37
|
+
private _orbitInteracting;
|
|
38
|
+
private _hudScene;
|
|
39
|
+
private _hudCamera;
|
|
40
|
+
private _fixedMobjects;
|
|
41
|
+
private _ambientRotationRate;
|
|
42
|
+
private _lastRenderTime;
|
|
43
|
+
private _illusionRotationRate;
|
|
44
|
+
private _illusionOriginPhi;
|
|
45
|
+
private _illusionOriginTheta;
|
|
46
|
+
private _illusionThetaTracker;
|
|
47
|
+
private _illusionPhiTracker;
|
|
48
|
+
private _illusionActive;
|
|
49
|
+
/**
|
|
50
|
+
* Create a new 3D scene.
|
|
51
|
+
* @param container - DOM element to render into
|
|
52
|
+
* @param options - Scene configuration options
|
|
53
|
+
*/
|
|
54
|
+
constructor(container: HTMLElement, options?: ThreeDSceneOptions);
|
|
55
|
+
/**
|
|
56
|
+
* Override add to re-enable depth testing for proper 3D occlusion.
|
|
57
|
+
* The base Scene disables depthTest for 2D render-order layering,
|
|
58
|
+
* but 3D scenes need depth testing for correct visibility.
|
|
59
|
+
*/
|
|
60
|
+
add(...mobjects: Mobject[]): this;
|
|
61
|
+
/**
|
|
62
|
+
* Get the 3D camera.
|
|
63
|
+
*/
|
|
64
|
+
get camera3D(): Camera3D;
|
|
65
|
+
/**
|
|
66
|
+
* Get the lighting system.
|
|
67
|
+
*/
|
|
68
|
+
get lighting(): Lighting;
|
|
69
|
+
/**
|
|
70
|
+
* Get the orbit controls (if enabled).
|
|
71
|
+
*/
|
|
72
|
+
get orbitControls(): OrbitControls | null;
|
|
73
|
+
/**
|
|
74
|
+
* Set the camera orientation using spherical coordinates.
|
|
75
|
+
* @param phi - Polar angle from Y axis (0 = top, PI = bottom)
|
|
76
|
+
* @param theta - Azimuthal angle in XZ plane
|
|
77
|
+
* @param distance - Optional distance from the look-at point
|
|
78
|
+
* @returns this for chaining
|
|
79
|
+
*/
|
|
80
|
+
setCameraOrientation(phi: number, theta: number, distance?: number): this;
|
|
81
|
+
/**
|
|
82
|
+
* Set the camera's look-at target.
|
|
83
|
+
* @param target - Target position [x, y, z]
|
|
84
|
+
* @returns this for chaining
|
|
85
|
+
*/
|
|
86
|
+
setLookAt(target: Vector3Tuple): this;
|
|
87
|
+
/**
|
|
88
|
+
* Get the current camera orientation angles.
|
|
89
|
+
* @returns Object with phi, theta, and distance
|
|
90
|
+
*/
|
|
91
|
+
getCameraOrientation(): {
|
|
92
|
+
phi: number;
|
|
93
|
+
theta: number;
|
|
94
|
+
distance: number;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Begin continuous ambient rotation of the camera around the scene.
|
|
98
|
+
* Rotates the camera's theta angle at the given rate (radians per second)
|
|
99
|
+
* during wait() calls and play() calls.
|
|
100
|
+
* Equivalent to Python Manim's begin_ambient_camera_rotation(rate).
|
|
101
|
+
* @param rate - Rotation rate in radians per second. Defaults to 0.1.
|
|
102
|
+
* @returns this for chaining
|
|
103
|
+
*/
|
|
104
|
+
beginAmbientCameraRotation(rate?: number): this;
|
|
105
|
+
/**
|
|
106
|
+
* Stop the ambient camera rotation.
|
|
107
|
+
* Equivalent to Python Manim's stop_ambient_camera_rotation().
|
|
108
|
+
* @returns this for chaining
|
|
109
|
+
*/
|
|
110
|
+
stopAmbientCameraRotation(): this;
|
|
111
|
+
/**
|
|
112
|
+
* Begin 3D illusion camera rotation.
|
|
113
|
+
* Unlike ambient rotation (which only rotates theta), this also oscillates
|
|
114
|
+
* phi sinusoidally, creating a wobbling 3D illusion as if the viewer walks
|
|
115
|
+
* around the scene.
|
|
116
|
+
* Equivalent to Python Manim's begin_3dillusion_camera_rotation(rate).
|
|
117
|
+
* @param rate - Rotation rate in radians per second. Defaults to 2.
|
|
118
|
+
* @returns this for chaining
|
|
119
|
+
*/
|
|
120
|
+
begin3DIllusionCameraRotation(rate?: number): this;
|
|
121
|
+
/**
|
|
122
|
+
* Stop the 3D illusion camera rotation.
|
|
123
|
+
* Equivalent to Python Manim's stop_3dillusion_camera_rotation().
|
|
124
|
+
* @returns this for chaining
|
|
125
|
+
*/
|
|
126
|
+
stop3DIllusionCameraRotation(): this;
|
|
127
|
+
/**
|
|
128
|
+
* Animate the camera to a new orientation over a given duration.
|
|
129
|
+
* Equivalent to Python Manim's move_camera(phi, theta, distance).
|
|
130
|
+
* If no duration is given, snaps instantly.
|
|
131
|
+
* @param options - Target orientation and duration
|
|
132
|
+
* @returns Promise that resolves when the animation completes
|
|
133
|
+
*/
|
|
134
|
+
moveCamera(options: {
|
|
135
|
+
phi?: number;
|
|
136
|
+
theta?: number;
|
|
137
|
+
distance?: number;
|
|
138
|
+
duration?: number;
|
|
139
|
+
}): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Enable or disable orbit controls.
|
|
142
|
+
* @param enabled - Whether orbit controls should be enabled
|
|
143
|
+
* @returns this for chaining
|
|
144
|
+
*/
|
|
145
|
+
setOrbitControlsEnabled(enabled: boolean): this;
|
|
146
|
+
/**
|
|
147
|
+
* Pin mobjects to the screen (HUD) so they don't move with the 3D camera.
|
|
148
|
+
* Equivalent to Python Manim's add_fixed_in_frame_mobjects.
|
|
149
|
+
* @param mobjects - Mobjects to fix in screen space
|
|
150
|
+
* @returns this for chaining
|
|
151
|
+
*/
|
|
152
|
+
addFixedInFrameMobjects(...mobjects: Mobject[]): this;
|
|
153
|
+
/**
|
|
154
|
+
* Remove mobjects from the fixed-in-frame HUD.
|
|
155
|
+
* @param mobjects - Mobjects to unpin from screen space
|
|
156
|
+
* @returns this for chaining
|
|
157
|
+
*/
|
|
158
|
+
removeFixedInFrameMobjects(...mobjects: Mobject[]): this;
|
|
159
|
+
/**
|
|
160
|
+
* Override: also needs per-frame rendering when camera is animating.
|
|
161
|
+
*/
|
|
162
|
+
protected _needsPerFrameRendering(): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Override _render to use the 3D camera with two-pass rendering for HUD.
|
|
165
|
+
* This is called by the animation loop internally.
|
|
166
|
+
*/
|
|
167
|
+
protected _render(): void;
|
|
168
|
+
/**
|
|
169
|
+
* Public render - delegates to _render.
|
|
170
|
+
*/
|
|
171
|
+
render(): void;
|
|
172
|
+
/**
|
|
173
|
+
* Override clear to also clear the HUD scene and fixed mobjects.
|
|
174
|
+
*/
|
|
175
|
+
clear(options?: {
|
|
176
|
+
render?: boolean;
|
|
177
|
+
}): this;
|
|
178
|
+
/**
|
|
179
|
+
* Override remove to also handle fixed mobjects.
|
|
180
|
+
*/
|
|
181
|
+
remove(...mobjects: Mobject[]): this;
|
|
182
|
+
/**
|
|
183
|
+
* Handle window resize.
|
|
184
|
+
* @param width - New width in pixels
|
|
185
|
+
* @param height - New height in pixels
|
|
186
|
+
*/
|
|
187
|
+
resize(width: number, height: number): this;
|
|
188
|
+
/**
|
|
189
|
+
* Start a lightweight rAF loop for orbit controls when the scene
|
|
190
|
+
* isn't already rendering (no active animations/waits).
|
|
191
|
+
* Stops automatically when the user releases and damping settles.
|
|
192
|
+
*/
|
|
193
|
+
private _startOrbitLoop;
|
|
194
|
+
/**
|
|
195
|
+
* Clean up all resources.
|
|
196
|
+
*/
|
|
197
|
+
dispose(): void;
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=ThreeDScene.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThreeDScene.d.ts","sourceRoot":"","sources":["../../src/core/ThreeDScene.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAmB,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACtD,uDAAuD;IACvD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,4CAA4C;IAC5C,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,4DAA4D;IAC5D,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,OAAO,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-
* This is the base class for all path-based shapes.
|
|
6
|
-
*
|
|
7
|
-
* Points are stored as cubic Bezier control points:
|
|
8
|
-
* [anchor1, handle1, handle2, anchor2, handle3, handle4, anchor3, ...]
|
|
9
|
-
*
|
|
10
|
-
* Each curve segment uses 4 points: anchor -> handle -> handle -> anchor
|
|
11
|
-
* Consecutive segments share the anchor point.
|
|
12
|
-
*/
|
|
13
|
-
import * as THREE from 'three';
|
|
14
|
-
/**
|
|
15
|
-
* 2D Point interface for backward compatibility
|
|
16
|
-
*/
|
|
17
|
-
export interface Point {
|
|
18
|
-
x: number;
|
|
19
|
-
y: number;
|
|
20
|
-
}
|
|
1
|
+
import { Vector3Tuple } from './Mobject';
|
|
2
|
+
import { VMobjectRendering } from './VMobjectRendering';
|
|
3
|
+
import { Point } from './VMobjectCurves';
|
|
4
|
+
export type { Point } from './VMobjectCurves';
|
|
21
5
|
/**
|
|
22
6
|
* Vectorized mobject class for path-based shapes.
|
|
23
7
|
*/
|
|
24
|
-
export declare class VMobject extends
|
|
8
|
+
export declare class VMobject extends VMobjectRendering {
|
|
25
9
|
/**
|
|
26
10
|
* Array of cubic Bezier control points in 3D.
|
|
27
11
|
* Each point is [x, y, z].
|
|
@@ -30,67 +14,7 @@ export declare class VMobject extends Mobject {
|
|
|
30
14
|
protected _points3D: number[][];
|
|
31
15
|
/** Number of points visible (for Create animation) */
|
|
32
16
|
protected _visiblePointCount: number | null;
|
|
33
|
-
/** Three.js stroke material (Line2 LineMaterial for thick strokes) */
|
|
34
|
-
protected _strokeMaterial: LineMaterial | null;
|
|
35
|
-
/** Three.js fill material */
|
|
36
|
-
protected _fillMaterial: THREE.MeshBasicMaterial | null;
|
|
37
|
-
/** Whether geometry needs rebuild (separate from material dirty) */
|
|
38
|
-
protected _geometryDirty: boolean;
|
|
39
|
-
/** Cached Line2 for in-place geometry updates (avoids dispose/recreate) */
|
|
40
|
-
private _cachedLine2;
|
|
41
|
-
/** Cached Line2 array for multi-subpath stroke rendering */
|
|
42
|
-
private _cachedLine2Array;
|
|
43
|
-
/** Cached fill mesh for in-place geometry updates */
|
|
44
|
-
private _cachedFillMesh;
|
|
45
|
-
/** Renderer resolution for LineMaterial (set by Scene) */
|
|
46
|
-
static _rendererWidth: number;
|
|
47
|
-
static _rendererHeight: number;
|
|
48
|
-
/** Camera frame width in world units (set by Scene, for stroke width conversion) */
|
|
49
|
-
static _frameWidth: number;
|
|
50
|
-
/**
|
|
51
|
-
* Convert Manim-compatible strokeWidth to LineMaterial linewidth in pixels.
|
|
52
|
-
* Python Manim uses cairo_line_width_multiple=0.01, so:
|
|
53
|
-
* linewidth_px = strokeWidth * 0.01 * (rendererWidth / frameWidth)
|
|
54
|
-
*/
|
|
55
|
-
static _toLinewidth(strokeWidth: number): number;
|
|
56
|
-
/**
|
|
57
|
-
* When true, VMobjects use GPU Bezier SDF shaders for stroke rendering
|
|
58
|
-
* instead of the default Line2/LineMaterial approach. This produces
|
|
59
|
-
* ManimGL-quality anti-aliased curves with variable stroke width and
|
|
60
|
-
* round caps. Default: false (opt-in).
|
|
61
|
-
*/
|
|
62
|
-
static useShaderCurves: boolean;
|
|
63
|
-
/** Shared BezierRenderer instance (lazy-initialized when useShaderCurves is first used) */
|
|
64
|
-
private static _sharedBezierRenderer;
|
|
65
|
-
/** Per-instance: cached Bezier SDF stroke mesh */
|
|
66
|
-
private _cachedBezierMesh;
|
|
67
|
-
/** Per-instance override for shader curves (null = use static default) */
|
|
68
|
-
private _useShaderCurvesOverride;
|
|
69
|
-
/**
|
|
70
|
-
* When true, render stroke as a mesh ring with miter-joined corners instead
|
|
71
|
-
* of Line2 for closed paths. Falls back to Line2 for open/partial paths
|
|
72
|
-
* (e.g. during Create/Uncreate animations).
|
|
73
|
-
*/
|
|
74
|
-
useStrokeMesh: boolean;
|
|
75
|
-
/** Cached mesh-based stroke ring */
|
|
76
|
-
private _cachedStrokeMesh;
|
|
77
|
-
/** Material for mesh-based stroke */
|
|
78
|
-
private _strokeMeshMaterial;
|
|
79
|
-
/**
|
|
80
|
-
* Get the shared BezierRenderer, creating it if needed.
|
|
81
|
-
*/
|
|
82
|
-
private static _getBezierRenderer;
|
|
83
17
|
constructor();
|
|
84
|
-
/**
|
|
85
|
-
* Check whether this instance should use shader-based Bezier curve rendering.
|
|
86
|
-
* Returns the per-instance override if set, otherwise the class-level default.
|
|
87
|
-
*/
|
|
88
|
-
get shaderCurves(): boolean;
|
|
89
|
-
/**
|
|
90
|
-
* Enable or disable shader-based Bezier curve rendering for this instance.
|
|
91
|
-
* Pass `null` to revert to the class-level VMobject.useShaderCurves default.
|
|
92
|
-
*/
|
|
93
|
-
set shaderCurves(value: boolean | null);
|
|
94
18
|
/**
|
|
95
19
|
* Get all points as 2D Point objects (derived from _points3D)
|
|
96
20
|
*/
|
|
@@ -133,6 +57,15 @@ export declare class VMobject extends Mobject {
|
|
|
133
57
|
* Get points that should be visible (for rendering) as 3D arrays
|
|
134
58
|
*/
|
|
135
59
|
getVisiblePoints3D(): number[][];
|
|
60
|
+
/**
|
|
61
|
+
* Set visible point count for progressive creation animations.
|
|
62
|
+
* Use null to show all points.
|
|
63
|
+
*/
|
|
64
|
+
setVisiblePointCount(count: number | null): void;
|
|
65
|
+
/**
|
|
66
|
+
* Get the visible point count (null means all points visible).
|
|
67
|
+
*/
|
|
68
|
+
getVisiblePointCount(): number | null;
|
|
136
69
|
/**
|
|
137
70
|
* Add points to this VMobject using 2D Point objects
|
|
138
71
|
*/
|
|
@@ -165,138 +98,43 @@ export declare class VMobject extends Mobject {
|
|
|
165
98
|
*/
|
|
166
99
|
interpolate(target: VMobject, alpha: number): this;
|
|
167
100
|
/**
|
|
168
|
-
* Align points between this VMobject and a target so they have the same
|
|
169
|
-
*
|
|
101
|
+
* Align points between this VMobject and a target so they have the same
|
|
102
|
+
* count, consistent winding, and optimal rotation for smooth morphing.
|
|
170
103
|
* @param target - The target VMobject to align with
|
|
171
104
|
*/
|
|
172
105
|
alignPoints(target: VMobject): void;
|
|
173
106
|
/**
|
|
174
|
-
*
|
|
107
|
+
* Compute the signed area of a 2D polygon formed by the anchor points.
|
|
108
|
+
* Positive = counter-clockwise, negative = clockwise.
|
|
175
109
|
*/
|
|
176
|
-
|
|
110
|
+
private static _signedArea2D;
|
|
177
111
|
/**
|
|
178
|
-
*
|
|
179
|
-
*
|
|
112
|
+
* Reverse a cubic-bezier point path while preserving bezier structure.
|
|
113
|
+
* For cubic segments [A0, H1, H2, A1, H3, H4, A2, ...],
|
|
114
|
+
* reversing means the path goes in the opposite direction.
|
|
180
115
|
*/
|
|
181
|
-
|
|
116
|
+
private static _reverseBezierPath;
|
|
182
117
|
/**
|
|
183
|
-
*
|
|
118
|
+
* Find the cyclic rotation of `target` anchor points that minimises
|
|
119
|
+
* total squared distance to `source`, then apply that rotation.
|
|
120
|
+
* Only rotates by multiples of the bezier stride (3) to preserve
|
|
121
|
+
* the cubic bezier segment structure.
|
|
184
122
|
*/
|
|
185
|
-
|
|
123
|
+
private static _bestRotation;
|
|
186
124
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* Earcut handles concave polygons, self-intersecting paths, and holes far
|
|
190
|
-
* more robustly than Three.js' built-in ShapeGeometry triangulator, which
|
|
191
|
-
* is a simple ear-clipping implementation that struggles with complex SVG
|
|
192
|
-
* outlines.
|
|
193
|
-
*
|
|
194
|
-
* If earcut returns zero triangles (completely degenerate input) we fall
|
|
195
|
-
* back to THREE.ShapeGeometry so existing simple shapes still render.
|
|
196
|
-
*
|
|
197
|
-
* @param points3D - The visible Bezier control points
|
|
198
|
-
* @returns A BufferGeometry ready for use as a fill mesh, or null if the
|
|
199
|
-
* polygon is too degenerate even for fallback.
|
|
200
|
-
*/
|
|
201
|
-
protected _buildEarcutFillGeometry(points3D: number[][]): THREE.BufferGeometry | null;
|
|
202
|
-
/**
|
|
203
|
-
* Build fill geometry for multi-subpath shapes (compound glyphs).
|
|
204
|
-
* Uses point-in-polygon containment to distinguish holes (subpaths inside
|
|
205
|
-
* another subpath, like the counter of "0") from disjoint regions (like
|
|
206
|
-
* the two bars of "=" or the dot+stroke of "i").
|
|
207
|
-
*/
|
|
208
|
-
private _buildEarcutFillGeometryMulti;
|
|
209
|
-
/**
|
|
210
|
-
* Ray-casting point-in-polygon test (2D).
|
|
211
|
-
* Returns true if point is inside the polygon ring.
|
|
212
|
-
*/
|
|
213
|
-
private static _pointInPolygon;
|
|
214
|
-
/**
|
|
215
|
-
* Sample the Bezier path into a 2D polyline suitable for earcut triangulation.
|
|
216
|
-
*
|
|
217
|
-
* This is similar to _sampleBezierPath but returns [x, y] pairs (no z) and
|
|
218
|
-
* skips duplicate-point de-duplication at segment boundaries (earcut handles
|
|
219
|
-
* that correctly and de-dup can introduce off-by-one for hole indices).
|
|
220
|
-
*/
|
|
221
|
-
private _sampleBezierOutline;
|
|
222
|
-
/**
|
|
223
|
-
* Split a sampled outline into separate rings based on subpath control-point
|
|
224
|
-
* lengths. Used for compound paths (outer boundary + holes).
|
|
225
|
-
*
|
|
226
|
-
* Each subpath length is the number of Bezier control points. We compute
|
|
227
|
-
* how many sampled points each subpath produced and split accordingly.
|
|
228
|
-
*/
|
|
229
|
-
/**
|
|
230
|
-
* Create the Three.js backing object for this VMobject.
|
|
231
|
-
* Creates both stroke (using Line2 for thick, smooth strokes) and fill meshes.
|
|
232
|
-
*/
|
|
233
|
-
protected _createThreeObject(): THREE.Object3D;
|
|
234
|
-
/**
|
|
235
|
-
* Update the geometry within the Three.js group.
|
|
236
|
-
* Reuses existing Line2 / Mesh objects when possible to avoid expensive
|
|
237
|
-
* dispose-and-recreate cycles during per-frame animation updates.
|
|
238
|
-
*
|
|
239
|
-
* When `shaderCurves` is enabled, stroke rendering uses GPU Bezier SDF
|
|
240
|
-
* shaders via BezierRenderer instead of the Line2 polyline approach.
|
|
241
|
-
*/
|
|
242
|
-
protected _updateGeometry(group: THREE.Group): void;
|
|
243
|
-
/**
|
|
244
|
-
* Update stroke using the classic Line2 approach (polyline approximation).
|
|
245
|
-
* Supports subpath-aware rendering: when getSubpaths() returns multiple
|
|
246
|
-
* subpaths, each is rendered as a separate Line2 to avoid visible bridge lines.
|
|
247
|
-
*/
|
|
248
|
-
private _updateLine2Stroke;
|
|
249
|
-
/**
|
|
250
|
-
* Render multiple separate Line2 strokes, one per subpath.
|
|
251
|
-
*/
|
|
252
|
-
private _updateLine2StrokeMulti;
|
|
253
|
-
/**
|
|
254
|
-
* Check if the Bezier control points form a closed path (first ≈ last anchor).
|
|
255
|
-
*/
|
|
256
|
-
private _isClosedPath;
|
|
257
|
-
/**
|
|
258
|
-
* Build a mesh-based stroke ring from a closed sampled path.
|
|
259
|
-
* Uses miter joins at corners for pixel-perfect sharp corners.
|
|
260
|
-
* Stroke width is in world units (strokeWidth * 0.005 per side).
|
|
261
|
-
*/
|
|
262
|
-
private _updateMeshStroke;
|
|
263
|
-
/**
|
|
264
|
-
* Remove the cached mesh-based stroke ring.
|
|
265
|
-
*/
|
|
266
|
-
private _removeMeshStroke;
|
|
267
|
-
/**
|
|
268
|
-
* Remove all cached multi-subpath Line2 objects.
|
|
269
|
-
*/
|
|
270
|
-
private _clearCachedLine2Array;
|
|
271
|
-
/**
|
|
272
|
-
* Update stroke using GPU Bezier SDF shader (ManimGL-quality rendering).
|
|
273
|
-
* Each cubic Bezier segment becomes one instanced quad rendered by the
|
|
274
|
-
* BezierShaderMaterial fragment shader.
|
|
275
|
-
*/
|
|
276
|
-
private _updateBezierStroke;
|
|
277
|
-
/**
|
|
278
|
-
* Dispose and remove all children from a Three.js group
|
|
279
|
-
*/
|
|
280
|
-
private _disposeGroupChildren;
|
|
281
|
-
/**
|
|
282
|
-
* Sample Bezier curves for smooth rendering.
|
|
283
|
-
* Uses adaptive sampling: nearly-linear segments (from prepareForNonlinearTransform)
|
|
284
|
-
* use only their endpoints, avoiding expensive per-sample Bezier evaluation.
|
|
285
|
-
*
|
|
286
|
-
* @param points - Bezier control points
|
|
287
|
-
* @param samplesPerSegment - Number of samples per curved Bezier segment
|
|
288
|
-
* @returns Sampled points along the path
|
|
289
|
-
*/
|
|
290
|
-
private _sampleBezierPath;
|
|
291
|
-
/**
|
|
292
|
-
* Check if a cubic Bezier segment is nearly linear by measuring the maximum
|
|
293
|
-
* distance from handles to the chord (p0 → p3).
|
|
125
|
+
* Interpolate a 3D point list to have a specific number of points.
|
|
294
126
|
*/
|
|
295
|
-
|
|
127
|
+
protected _interpolatePointList3D(points: number[][], targetCount: number): number[][];
|
|
296
128
|
/**
|
|
297
|
-
*
|
|
129
|
+
* Create a copy of this VMobject.
|
|
130
|
+
* Subclasses override _createCopy() to produce an instance of the right
|
|
131
|
+
* concrete type (Circle, Square, etc.), but those constructors typically
|
|
132
|
+
* regenerate points from their own parameters (radius, sideLength, ...).
|
|
133
|
+
* After a Transform animation has morphed the point data, the regenerated
|
|
134
|
+
* points no longer match the actual visual state. We therefore always
|
|
135
|
+
* overwrite the clone's _points3D with the source's current data.
|
|
298
136
|
*/
|
|
299
|
-
|
|
137
|
+
copy(): VMobject;
|
|
300
138
|
/**
|
|
301
139
|
* Create a copy of this VMobject
|
|
302
140
|
*/
|
|
@@ -312,6 +150,16 @@ export declare class VMobject extends Mobject {
|
|
|
312
150
|
* rather than point centroid, which is inaccurate for Bezier control points.
|
|
313
151
|
*/
|
|
314
152
|
getCenter(): Vector3Tuple;
|
|
153
|
+
/** @internal Check if a Bezier segment is nearly linear. */
|
|
154
|
+
protected static _isNearlyLinear(p0: number[], p1: number[], p2: number[], p3: number[]): boolean;
|
|
155
|
+
/** @internal Ray-casting point-in-polygon test. */
|
|
156
|
+
protected static _pointInPolygon(point: number[], ring: number[][]): boolean;
|
|
157
|
+
/** @internal Sample Bezier outline for earcut triangulation. */
|
|
158
|
+
protected _sampleBezierOutline(points: number[][], samplesPerSegment: number): number[][];
|
|
159
|
+
/** @internal Sample Bezier path for stroke rendering. */
|
|
160
|
+
protected _sampleBezierPath(points: number[][], samplesPerSegment?: number): number[][];
|
|
161
|
+
/** @internal Check if Bezier control points form a closed path. */
|
|
162
|
+
protected _isClosedPath(points3D: number[][]): boolean;
|
|
315
163
|
/**
|
|
316
164
|
* Clean up Three.js resources
|
|
317
165
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VMobject.d.ts","sourceRoot":"","sources":["../../src/core/VMobject.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"VMobject.d.ts","sourceRoot":"","sources":["../../src/core/VMobject.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAW9C,YAAY,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;GAEG;AACH,qBAAa,QAAS,SAAQ,iBAAiB;IAC7C;;;;OAIG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,CAAM;IAErC,sDAAsD;IACtD,SAAS,CAAC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAQ;;IAcnD;;OAEG;IACH,IAAI,MAAM,IAAI,KAAK,EAAE,CAEpB;IAED;;;;;OAKG;IACH,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,IAAI;IAoB7C;;;;OAIG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,IAAI;IAIrC;;;OAGG;IACH,SAAS,IAAI,MAAM,EAAE,EAAE;IAIvB;;OAEG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;OAEG;IACH,IAAI,iBAAiB,IAAI,MAAM,CAE9B;IAED;;OAEG;IACH,IAAI,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAIlC;IAED;;OAEG;IACH,gBAAgB,IAAI,KAAK,EAAE;IAK3B;;OAEG;IACH,kB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CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC;IAIvC;;;;OAIG;IACH,OAAO,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAK3D;;;;OAIG;IACH,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,EAAE;IAItD;;OAEG;cACgB,WAAW,IAAI,QAAQ;CAK3C;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Curve utility types and pure helper functions for VMobject.
|
|
3
|
+
*
|
|
4
|
+
* This module contains only items that do NOT need to construct VMobject
|
|
5
|
+
* instances, avoiding circular dependency issues.
|
|
6
|
+
*
|
|
7
|
+
* Functions that create new VMobject instances (getNthCurve, curvesAsSubmobjects)
|
|
8
|
+
* live in VMobject.ts and are re-exported from there.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* 2D Point interface for backward compatibility
|
|
12
|
+
*/
|
|
13
|
+
export interface Point {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get the number of curve segments from a Bezier point array.
|
|
19
|
+
* Each cubic Bezier segment uses 4 points (anchor, handle, handle, anchor),
|
|
20
|
+
* with consecutive segments sharing anchors.
|
|
21
|
+
* @param points - The 3D control points array
|
|
22
|
+
* @returns Number of curve segments
|
|
23
|
+
*/
|
|
24
|
+
export declare function getNumCurvesFromPoints(points: number[][]): number;
|
|
25
|
+
//# sourceMappingURL=VMobjectCurves.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VMobjectCurves.d.ts","sourceRoot":"","sources":["../../src/core/VMobjectCurves.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,CAGjE"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Point } from './VMobjectCurves';
|
|
2
|
+
/**
|
|
3
|
+
* Geometry building utilities for VMobject rendering.
|
|
4
|
+
*
|
|
5
|
+
* Provides standalone functions for:
|
|
6
|
+
* - Sampling Bezier curves into polylines
|
|
7
|
+
* - Building earcut-triangulated fill geometry
|
|
8
|
+
* - Converting Bezier control points to THREE.Shape / CurvePath
|
|
9
|
+
* - Mesh-based stroke ring construction with miter joins
|
|
10
|
+
* - Point-in-polygon and linearity tests
|
|
11
|
+
*/
|
|
12
|
+
import * as THREE from 'three';
|
|
13
|
+
/**
|
|
14
|
+
* Check if a cubic Bezier segment is nearly linear by measuring the maximum
|
|
15
|
+
* distance from handles to the chord (p0 -> p3).
|
|
16
|
+
*/
|
|
17
|
+
export declare function isNearlyLinear(p0: number[], p1: number[], p2: number[], p3: number[]): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Sample Bezier curves for smooth rendering.
|
|
20
|
+
* Uses adaptive sampling: nearly-linear segments (from prepareForNonlinearTransform)
|
|
21
|
+
* use only their endpoints, avoiding expensive per-sample Bezier evaluation.
|
|
22
|
+
*
|
|
23
|
+
* @param points - Bezier control points
|
|
24
|
+
* @param samplesPerSegment - Number of samples per curved Bezier segment
|
|
25
|
+
* @returns Sampled points along the path
|
|
26
|
+
*/
|
|
27
|
+
export declare function sampleBezierPath(points: number[][], samplesPerSegment?: number): number[][];
|
|
28
|
+
/**
|
|
29
|
+
* Sample the Bezier path into a 2D polyline suitable for earcut triangulation.
|
|
30
|
+
*
|
|
31
|
+
* This is similar to sampleBezierPath but returns [x, y] pairs (no z) and
|
|
32
|
+
* skips duplicate-point de-duplication at segment boundaries (earcut handles
|
|
33
|
+
* that correctly and de-dup can introduce off-by-one for hole indices).
|
|
34
|
+
*/
|
|
35
|
+
export declare function sampleBezierOutline(points: number[][], samplesPerSegment: number): number[][];
|
|
36
|
+
/**
|
|
37
|
+
* Ray-casting point-in-polygon test (2D).
|
|
38
|
+
* Returns true if point is inside the polygon ring.
|
|
39
|
+
*/
|
|
40
|
+
export declare function pointInPolygon(point: number[], ring: number[][]): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Convert Bezier control points to a Three.js Shape for filled rendering.
|
|
43
|
+
* @param visiblePoints - The visible points as 2D Point objects
|
|
44
|
+
* @returns THREE.Shape representing the path
|
|
45
|
+
*/
|
|
46
|
+
export declare function pointsToShape(visiblePoints: Point[]): THREE.Shape;
|
|
47
|
+
/**
|
|
48
|
+
* Convert points to a THREE.CurvePath for stroke rendering
|
|
49
|
+
* @param visiblePoints3D - The visible points as 3D arrays
|
|
50
|
+
*/
|
|
51
|
+
export declare function pointsToCurvePath(visiblePoints3D: number[][]): THREE.CurvePath<THREE.Vector3>;
|
|
52
|
+
/**
|
|
53
|
+
* Build a THREE.BufferGeometry for the filled region using earcut triangulation.
|
|
54
|
+
*
|
|
55
|
+
* Earcut handles concave polygons, self-intersecting paths, and holes far
|
|
56
|
+
* more robustly than Three.js' built-in ShapeGeometry triangulator.
|
|
57
|
+
*
|
|
58
|
+
* If earcut returns zero triangles (completely degenerate input) we fall
|
|
59
|
+
* back to THREE.ShapeGeometry so existing simple shapes still render.
|
|
60
|
+
*
|
|
61
|
+
* @param points3D - The visible Bezier control points
|
|
62
|
+
* @param visiblePoints - 2D points for fallback shape
|
|
63
|
+
* @param getSubpaths - Optional function to get subpath lengths for compound paths
|
|
64
|
+
* @returns A BufferGeometry or null if too degenerate
|
|
65
|
+
*/
|
|
66
|
+
export declare function buildEarcutFillGeometry(points3D: number[][], visiblePoints: Point[], getSubpaths?: () => number[]): THREE.BufferGeometry | null;
|
|
67
|
+
/**
|
|
68
|
+
* Build mesh-based stroke geometry from a closed sampled path.
|
|
69
|
+
* Uses miter joins at corners for pixel-perfect sharp corners.
|
|
70
|
+
*
|
|
71
|
+
* @param group - The THREE.Group for world matrix computation
|
|
72
|
+
* @param sampledPoints - Sampled path points
|
|
73
|
+
* @param strokeWidth - Stroke width
|
|
74
|
+
* @param opacity - Current opacity
|
|
75
|
+
* @returns BufferGeometry and index data, or null if insufficient points
|
|
76
|
+
*/
|
|
77
|
+
export declare function buildMeshStrokeGeometry(group: THREE.Group, sampledPoints: number[][], strokeWidth: number, opacity: number): {
|
|
78
|
+
geometry: THREE.BufferGeometry;
|
|
79
|
+
} | null;
|
|
80
|
+
/**
|
|
81
|
+
* Check if the Bezier control points form a closed path (first ~ last anchor).
|
|
82
|
+
*/
|
|
83
|
+
export declare function isClosedPath(points3D: number[][]): boolean;
|
|
84
|
+
//# sourceMappingURL=VMobjectGeometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VMobjectGeometry.d.ts","sourceRoot":"","sources":["../../src/core/VMobjectGeometry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAM9C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,OAAO,CAa9F;AAMD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,iBAAiB,GAAE,MAAU,GAAG,MAAM,EAAE,EAAE,CAqC9F;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,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