manim-web 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -19
- package/dist/animation/transform/MovementTransforms.d.ts.map +1 -1
- package/dist/export/chooseExporter.d.ts +19 -0
- package/dist/export/chooseExporter.d.ts.map +1 -0
- package/dist/export/index.d.ts +1 -0
- package/dist/export/index.d.ts.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/integrations/react.js +17 -17
- package/dist/integrations/vue.js +16 -16
- package/dist/interaction/DynamicMatrix.d.ts +164 -0
- package/dist/interaction/DynamicMatrix.d.ts.map +1 -0
- package/dist/interaction/index.d.ts +1 -0
- package/dist/interaction/index.d.ts.map +1 -1
- package/dist/manim-web.browser.js +1240 -623
- package/dist/mobjects/three-d/Line3D.d.ts.map +1 -1
- package/dist/player/ExportSettingsUI.d.ts +82 -0
- package/dist/player/ExportSettingsUI.d.ts.map +1 -0
- package/dist/player/Player.d.ts +50 -2
- package/dist/player/Player.d.ts.map +1 -1
- package/dist/player/PlayerUI.d.ts +15 -1
- package/dist/player/PlayerUI.d.ts.map +1 -1
- package/dist/player/SlideInteractionRenderer.d.ts +32 -0
- package/dist/player/SlideInteractionRenderer.d.ts.map +1 -0
- package/dist/player/index.d.ts +1 -0
- package/dist/player/index.d.ts.map +1 -1
- package/dist/serialization/defaults.d.ts +13 -0
- package/dist/serialization/defaults.d.ts.map +1 -0
- package/dist/serialization/index.d.ts +15 -0
- package/dist/serialization/index.d.ts.map +1 -0
- package/dist/serialization/props.d.ts +16 -0
- package/dist/serialization/props.d.ts.map +1 -0
- package/dist/serialization/registry.d.ts +17 -0
- package/dist/serialization/registry.d.ts.map +1 -0
- package/dist/serialization/serialize.d.ts +24 -0
- package/dist/serialization/serialize.d.ts.map +1 -0
- package/dist/serialization/types.d.ts +70 -0
- package/dist/serialization/types.d.ts.map +1 -0
- package/dist/{src-BcBBUMTP.js → src-BLA8Tb0K.js} +1222 -605
- package/package.json +1 -1
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { Mobject, Vector3Tuple } from '../core/Mobject';
|
|
2
|
+
/**
|
|
3
|
+
* A 2x2 linear map written row-major as `[[a, b], [c, d]]`, i.e.
|
|
4
|
+
* `| a b |`
|
|
5
|
+
* `| c d |`.
|
|
6
|
+
* Its columns are the images of the basis vectors: `i = (a, c)`, `j = (b, d)`.
|
|
7
|
+
*/
|
|
8
|
+
export type Matrix2x2 = [[number, number], [number, number]];
|
|
9
|
+
/**
|
|
10
|
+
* A source of a live 2D basis vector. Either a getter that returns `[x, y]`, or
|
|
11
|
+
* any object with `getPoint()` (such as a {@link MovablePoint}) whose first two
|
|
12
|
+
* components are read.
|
|
13
|
+
*/
|
|
14
|
+
export type BasisVectorSource = (() => readonly [number, number]) | {
|
|
15
|
+
getPoint(): Vector3Tuple;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Anything that can drive {@link applyMatrixLive}: a fixed matrix, a getter that
|
|
19
|
+
* returns the current matrix, or a {@link MatrixTracker}.
|
|
20
|
+
*/
|
|
21
|
+
export type MatrixSource = Matrix2x2 | (() => Matrix2x2) | MatrixTracker;
|
|
22
|
+
/**
|
|
23
|
+
* A mobject whose position follows the live transform, mapped from a fixed base
|
|
24
|
+
* position under the identity matrix.
|
|
25
|
+
*/
|
|
26
|
+
export interface DependentPoint {
|
|
27
|
+
/** The mobject to move each frame. */
|
|
28
|
+
mobject: Mobject;
|
|
29
|
+
/** Its position under the identity matrix, in the plane's coordinate space. */
|
|
30
|
+
base: Vector3Tuple;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Options for {@link applyMatrixLive}.
|
|
34
|
+
*/
|
|
35
|
+
export interface DynamicMatrixOptions {
|
|
36
|
+
/** Pivot the transform is applied about. Default `[0, 0, 0]` (the origin). */
|
|
37
|
+
aboutPoint?: Vector3Tuple;
|
|
38
|
+
/** Dependent points/vectors that follow the transform. */
|
|
39
|
+
dependents?: DependentPoint[];
|
|
40
|
+
/** Called with the current matrix after every re-map (e.g. to trigger a render). */
|
|
41
|
+
onChange?: (matrix: Matrix2x2) => void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Handle returned by {@link applyMatrixLive}. Controls the live binding without
|
|
45
|
+
* re-reading the mobject.
|
|
46
|
+
*/
|
|
47
|
+
export interface LiveMatrixBinding {
|
|
48
|
+
/** The tracker driving the transform. */
|
|
49
|
+
readonly tracker: MatrixTracker;
|
|
50
|
+
/** The current matrix. */
|
|
51
|
+
getMatrix(): Matrix2x2;
|
|
52
|
+
/** Set the matrix and re-map immediately. */
|
|
53
|
+
setMatrix(matrix: Matrix2x2): LiveMatrixBinding;
|
|
54
|
+
/** Register a dependent point after binding. */
|
|
55
|
+
addDependentPoint(mobject: Mobject, base: Vector3Tuple): LiveMatrixBinding;
|
|
56
|
+
/** Re-map once from the current matrix (called automatically each frame). */
|
|
57
|
+
update(): LiveMatrixBinding;
|
|
58
|
+
/** Detach the per-frame updater so the geometry stops following the matrix. */
|
|
59
|
+
remove(): void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* MatrixTracker — holds a live 2x2 matrix, the matrix analogue of
|
|
63
|
+
* {@link ValueTracker}.
|
|
64
|
+
*
|
|
65
|
+
* It either stores a matrix directly (via the constructor or {@link setMatrix})
|
|
66
|
+
* or computes one on every read from a getter ({@link fromGetter}) or from two
|
|
67
|
+
* basis-vector sources ({@link fromBasisVectors}). Bind it to a grid with
|
|
68
|
+
* {@link applyMatrixLive}.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const iPoint = new MovablePoint(scene, { point: [1, 0, 0] });
|
|
73
|
+
* const jPoint = new MovablePoint(scene, { point: [0, 1, 0] });
|
|
74
|
+
* const tracker = MatrixTracker.fromBasisVectors(iPoint, jPoint);
|
|
75
|
+
* applyMatrixLive(plane, tracker, { onChange: () => scene.render() });
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare class MatrixTracker {
|
|
79
|
+
private _matrix;
|
|
80
|
+
private _compute;
|
|
81
|
+
/**
|
|
82
|
+
* Create a tracker holding a fixed matrix.
|
|
83
|
+
* @param matrix - The initial matrix. Default: the identity.
|
|
84
|
+
*/
|
|
85
|
+
constructor(matrix?: Matrix2x2);
|
|
86
|
+
/**
|
|
87
|
+
* Get the current matrix as a fresh copy.
|
|
88
|
+
* @returns The current matrix.
|
|
89
|
+
*/
|
|
90
|
+
getMatrix(): Matrix2x2;
|
|
91
|
+
/**
|
|
92
|
+
* Set the matrix directly, dropping any getter source.
|
|
93
|
+
* @param matrix - The new matrix.
|
|
94
|
+
* @returns this for chaining.
|
|
95
|
+
*/
|
|
96
|
+
setMatrix(matrix: Matrix2x2): this;
|
|
97
|
+
/**
|
|
98
|
+
* Set the matrix from its two column basis vectors.
|
|
99
|
+
* @param i - The image of the x basis vector, `(a, c)`.
|
|
100
|
+
* @param j - The image of the y basis vector, `(b, d)`.
|
|
101
|
+
* @returns this for chaining.
|
|
102
|
+
*/
|
|
103
|
+
setColumns(i: readonly [number, number], j: readonly [number, number]): this;
|
|
104
|
+
/**
|
|
105
|
+
* Get the two column basis vectors `[i, j]` of the current matrix.
|
|
106
|
+
* @returns `[i, j]` where `i = (a, c)` and `j = (b, d)`.
|
|
107
|
+
*/
|
|
108
|
+
getColumns(): [[number, number], [number, number]];
|
|
109
|
+
/**
|
|
110
|
+
* Map a 2D point by the current matrix (about the origin).
|
|
111
|
+
* @param point - The point `[x, y]` to transform.
|
|
112
|
+
* @returns The transformed point `[x', y']`.
|
|
113
|
+
*/
|
|
114
|
+
transformPoint(point: readonly [number, number]): [number, number];
|
|
115
|
+
/**
|
|
116
|
+
* Create a tracker whose matrix is recomputed from a getter on every read.
|
|
117
|
+
* @param getter - Returns the current matrix.
|
|
118
|
+
* @returns A new MatrixTracker.
|
|
119
|
+
*/
|
|
120
|
+
static fromGetter(getter: () => Matrix2x2): MatrixTracker;
|
|
121
|
+
/**
|
|
122
|
+
* Create a tracker whose matrix is built live from two basis-vector sources.
|
|
123
|
+
* The columns follow the sources, so dragging a {@link MovablePoint} drives
|
|
124
|
+
* the matrix in real time.
|
|
125
|
+
* @param iSource - Source of the x basis vector image (first column).
|
|
126
|
+
* @param jSource - Source of the y basis vector image (second column).
|
|
127
|
+
* @returns A new MatrixTracker.
|
|
128
|
+
*/
|
|
129
|
+
static fromBasisVectors(iSource: BasisVectorSource, jSource: BasisVectorSource): MatrixTracker;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Factory for a {@link MatrixTracker}.
|
|
133
|
+
* @param matrix - The initial matrix. Default: the identity.
|
|
134
|
+
* @returns A new MatrixTracker.
|
|
135
|
+
*/
|
|
136
|
+
export declare function makeMatrixTracker(matrix?: Matrix2x2): MatrixTracker;
|
|
137
|
+
/**
|
|
138
|
+
* Bind a mobject to a live 2x2 matrix so it morphs continuously.
|
|
139
|
+
*
|
|
140
|
+
* Every VMobject leaf in `target`'s family is snapshotted at bind time. An
|
|
141
|
+
* updater is added to `target`; each frame it re-maps every snapshotted point
|
|
142
|
+
* by the current matrix (about `aboutPoint`) and moves any dependent points.
|
|
143
|
+
* Because the re-map always starts from the snapshot, the transform is absolute
|
|
144
|
+
* and free of per-frame drift — a collapsed (singular) matrix is just a flat
|
|
145
|
+
* grid, with full recovery on the next frame.
|
|
146
|
+
*
|
|
147
|
+
* The one-shot `applyMatrix` is untouched; this is the additive live mode.
|
|
148
|
+
*
|
|
149
|
+
* @param target - The grid/plane/mobject to morph (e.g. a `NumberPlane`).
|
|
150
|
+
* @param matrix - The driving matrix, getter, or {@link MatrixTracker}.
|
|
151
|
+
* @param options - Pivot, dependent points and an `onChange` render hook.
|
|
152
|
+
* @returns A {@link LiveMatrixBinding} controlling the binding.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* const tracker = MatrixTracker.fromBasisVectors(iPoint, jPoint);
|
|
157
|
+
* applyMatrixLive(plane, tracker, {
|
|
158
|
+
* dependents: [{ mobject: vector, base: [2, 1, 0] }],
|
|
159
|
+
* onChange: () => scene.render(),
|
|
160
|
+
* });
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export declare function applyMatrixLive(target: Mobject, matrix: MatrixSource, options?: DynamicMatrixOptions): LiveMatrixBinding;
|
|
164
|
+
//# sourceMappingURL=DynamicMatrix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DynamicMatrix.d.ts","sourceRoot":"","sources":["../../src/interaction/DynamicMatrix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,OAAO,EAAE,YAAY,EAAwB,MAAM,iBAAiB,CAAC;AAI9E;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE7D;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG;IAAE,QAAQ,IAAI,YAAY,CAAA;CAAE,CAAC;AAEjG;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,CAAC,MAAM,SAAS,CAAC,GAAG,aAAa,CAAC;AAEzE;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,+EAA+E;IAC/E,IAAI,EAAE,YAAY,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,8EAA8E;IAC9E,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,0DAA0D;IAC1D,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;IAC9B,oFAAo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AAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,iBAAiB,GAAG,aAAa;CAU/F;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,aAAa,CAEnE;AAeD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,oBAAyB,GACjC,iBAAiB,CAoDnB"}
|
|
@@ -9,6 +9,7 @@ export { Hoverable, makeHoverable, type HoverableOptions } from './Hoverable';
|
|
|
9
9
|
export { Clickable, makeClickable, type ClickableOptions } from './Clickable';
|
|
10
10
|
export { MovablePoint, makeMovablePoint, type MovablePointOptions } from './MovablePoint';
|
|
11
11
|
export { Slider, makeSlider, type SliderOptions } from './Slider';
|
|
12
|
+
export { MatrixTracker, makeMatrixTracker, applyMatrixLive, type Matrix2x2, type MatrixSource, type BasisVectorSource, type DependentPoint, type DynamicMatrixOptions, type LiveMatrixBinding, } from './DynamicMatrix';
|
|
12
13
|
export { SelectionManager, type SelectionManagerOptions } from './SelectionManager';
|
|
13
14
|
export { OrbitControls, type OrbitControlsOptions } from './OrbitControls';
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interaction/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,QAAQ,EACR,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,S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