manim-web 0.3.24 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/GLTFLoader-CisHz7tR.js +1381 -0
- package/dist/GLTFLoader-DMbWuMln.js +1381 -0
- package/dist/{MathJaxBundle-xSidSV0E.js → MathJaxBundle-BSrlS0Dh.js} +3338 -3320
- package/dist/OBJLoader-Clh2POv9.js +287 -0
- package/dist/OBJLoader-kkTsEhJf.js +287 -0
- package/dist/animation/Always.d.ts +72 -0
- package/dist/animation/Always.d.ts.map +1 -0
- package/dist/animation/AlwaysRedraw.d.ts +15 -0
- package/dist/animation/AlwaysRedraw.d.ts.map +1 -0
- package/dist/animation/Animation.d.ts +9 -0
- package/dist/animation/Animation.d.ts.map +1 -1
- package/dist/animation/AnimationUtilities.d.ts +25 -0
- package/dist/animation/AnimationUtilities.d.ts.map +1 -1
- package/dist/animation/creation/Create.d.ts +40 -11
- package/dist/animation/creation/Create.d.ts.map +1 -1
- package/dist/animation/transform/PointMorphStrategy.d.ts +6 -0
- package/dist/animation/transform/PointMorphStrategy.d.ts.map +1 -1
- package/dist/animation/transform/Transform.d.ts.map +1 -1
- package/dist/animation/transform/TransformPairing.d.ts +17 -0
- package/dist/animation/transform/TransformPairing.d.ts.map +1 -1
- package/dist/animation/updaters.d.ts +69 -0
- package/dist/animation/updaters.d.ts.map +1 -0
- package/dist/compiler-CfW6eH2M.js +2 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/parity.d.ts +78 -0
- package/dist/constants/parity.d.ts.map +1 -0
- package/dist/core/Mobject.d.ts +48 -3
- package/dist/core/Mobject.d.ts.map +1 -1
- package/dist/core/MobjectTraversal.d.ts +7 -0
- package/dist/core/MobjectTraversal.d.ts.map +1 -1
- package/dist/core/MobjectTypes.d.ts +15 -0
- package/dist/core/MobjectTypes.d.ts.map +1 -1
- package/dist/core/Scene.d.ts +14 -0
- package/dist/core/Scene.d.ts.map +1 -1
- package/dist/core/SpecialThreeDScene.d.ts +64 -0
- package/dist/core/SpecialThreeDScene.d.ts.map +1 -0
- package/dist/core/VMobject.d.ts +143 -0
- package/dist/core/VMobject.d.ts.map +1 -1
- package/dist/core/VMobjectColorGradient.d.ts +20 -0
- package/dist/core/VMobjectColorGradient.d.ts.map +1 -0
- package/dist/core/VMobjectCurveMath.d.ts +128 -0
- package/dist/core/VMobjectCurveMath.d.ts.map +1 -0
- package/dist/core/VMobjectRendering.d.ts +38 -1
- package/dist/core/VMobjectRendering.d.ts.map +1 -1
- package/dist/core/VMobjectRoundCorners.d.ts +37 -0
- package/dist/core/VMobjectRoundCorners.d.ts.map +1 -0
- package/dist/esm-CiMKSfxz.js +1273 -0
- package/dist/export/FrameExporter.d.ts +86 -0
- package/dist/export/FrameExporter.d.ts.map +1 -0
- package/dist/export/GifExporter.d.ts +4 -0
- package/dist/export/GifExporter.d.ts.map +1 -1
- package/dist/export/WebCodecsExporter.d.ts +108 -0
- package/dist/export/WebCodecsExporter.d.ts.map +1 -0
- package/dist/export/index.d.ts +2 -0
- package/dist/export/index.d.ts.map +1 -1
- package/dist/global-compiler-D_nF-JaV.js +8 -0
- package/dist/global-renderer-gyshX_QF.js +8 -0
- package/dist/index.d.ts +29 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/integrations/react.js +17 -16
- package/dist/integrations/vue.js +16 -15
- package/dist/integrations/webcomponent.d.ts +65 -0
- package/dist/integrations/webcomponent.d.ts.map +1 -0
- package/dist/integrations/webcomponent.js +2 -0
- package/dist/manim-web.browser.js +36877 -45066
- package/dist/mobjects/geometry/AngleShapes.d.ts.map +1 -1
- package/dist/mobjects/geometry/ArcPolygon.d.ts +30 -0
- package/dist/mobjects/geometry/ArcPolygon.d.ts.map +1 -1
- package/dist/mobjects/geometry/DashedLine.d.ts.map +1 -1
- package/dist/mobjects/geometry/Label.d.ts +32 -0
- package/dist/mobjects/geometry/Label.d.ts.map +1 -0
- package/dist/mobjects/geometry/index.d.ts +2 -1
- package/dist/mobjects/geometry/index.d.ts.map +1 -1
- package/dist/mobjects/graphing/Axes.d.ts +73 -6
- package/dist/mobjects/graphing/Axes.d.ts.map +1 -1
- package/dist/mobjects/graphing/CoordinateSystem.d.ts +40 -0
- package/dist/mobjects/graphing/CoordinateSystem.d.ts.map +1 -0
- package/dist/mobjects/graphing/axes-calculus.d.ts +79 -0
- package/dist/mobjects/graphing/axes-calculus.d.ts.map +1 -0
- package/dist/mobjects/graphing/index.d.ts +3 -0
- package/dist/mobjects/graphing/index.d.ts.map +1 -1
- package/dist/mobjects/graphing/scale.d.ts +72 -0
- package/dist/mobjects/graphing/scale.d.ts.map +1 -0
- package/dist/mobjects/text/MathJaxRenderer.d.ts +5 -0
- package/dist/mobjects/text/MathJaxRenderer.d.ts.map +1 -1
- package/dist/mobjects/text/MathTex.d.ts +23 -0
- package/dist/mobjects/text/MathTex.d.ts.map +1 -1
- package/dist/mobjects/text/MathTexImage.d.ts.map +1 -1
- package/dist/mobjects/text/Text.d.ts +53 -0
- package/dist/mobjects/text/Text.d.ts.map +1 -1
- package/dist/mobjects/text/Typst.d.ts +113 -0
- package/dist/mobjects/text/Typst.d.ts.map +1 -0
- package/dist/mobjects/text/TypstRenderer.d.ts +57 -0
- package/dist/mobjects/text/TypstRenderer.d.ts.map +1 -0
- package/dist/mobjects/text/index.d.ts +5 -2
- package/dist/mobjects/text/index.d.ts.map +1 -1
- package/dist/mobjects/text/katexStyles.d.ts +5 -0
- package/dist/mobjects/text/katexStyles.d.ts.map +1 -1
- package/dist/mobjects/text/registerFont.d.ts +38 -0
- package/dist/mobjects/text/registerFont.d.ts.map +1 -0
- package/dist/mobjects/text/textStyleRuns.d.ts +111 -0
- package/dist/mobjects/text/textStyleRuns.d.ts.map +1 -0
- package/dist/mobjects/three-d/ModelMobject.d.ts +122 -0
- package/dist/mobjects/three-d/ModelMobject.d.ts.map +1 -0
- package/dist/mobjects/three-d/ThreeDAxes.d.ts +37 -4
- package/dist/mobjects/three-d/ThreeDAxes.d.ts.map +1 -1
- package/dist/mobjects/three-d/threeDVmobUtils.d.ts +25 -0
- package/dist/mobjects/three-d/threeDVmobUtils.d.ts.map +1 -0
- package/dist/mobjects/video/VideoMobject.d.ts +126 -0
- package/dist/mobjects/video/VideoMobject.d.ts.map +1 -0
- package/dist/mobjects/video/index.d.ts +2 -0
- package/dist/mobjects/video/index.d.ts.map +1 -0
- package/dist/mp4-muxer-5DGKGEJk.js +900 -0
- package/dist/player/Player.d.ts +4 -0
- package/dist/player/Player.d.ts.map +1 -1
- package/dist/renderer-DR_79fB0.js +2 -0
- package/dist/{src-Cc3xTIkV.js → src-C817VR8M.js} +10693 -7971
- package/dist/three.core-1aHSpGwp.js +11626 -0
- package/dist/utils/ManimColor.d.ts +163 -0
- package/dist/utils/ManimColor.d.ts.map +1 -0
- package/dist/utils/bezier.d.ts +95 -0
- package/dist/utils/bezier.d.ts.map +1 -0
- package/dist/utils/color.d.ts +99 -0
- package/dist/utils/color.d.ts.map +1 -0
- package/dist/utils/debug.d.ts +36 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/iterables.d.ts +162 -0
- package/dist/utils/iterables.d.ts.map +1 -0
- package/dist/utils/paths.d.ts +38 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/simpleFunctions.d.ts +26 -0
- package/dist/utils/simpleFunctions.d.ts.map +1 -0
- package/dist/utils/spaceOps.d.ts +119 -0
- package/dist/utils/spaceOps.d.ts.map +1 -0
- package/dist/utils/unit.d.ts +28 -0
- package/dist/utils/unit.d.ts.map +1 -0
- package/dist/wasm-CIlzm7By.js +76 -0
- package/dist/wasm-pack-shim-B3C4KoWa.js +1688 -0
- package/dist/wasm-pack-shim-BgTFpSvJ.js +911 -0
- package/dist/webcomponent-BS5WnkDO.js +707 -0
- package/dist/webm-muxer-BGY-Mgbp.js +857 -0
- package/package.json +19 -8
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { Fr as e, Ft as t, Gn as n, In as r, Lt as i, Pr as a, Qn as o, U as s, Xi as c, dr as l, eo as u, ir as d, j as f, jn as p, qt as m } from "./three.core-1aHSpGwp.js";
|
|
2
|
+
//#region node_modules/three/examples/jsm/loaders/OBJLoader.js
|
|
3
|
+
var h = /^[og]\s*(.+)?/, g = /^mtllib /, _ = /^usemtl /, v = /^usemap /, y = /\s+/, b = new u(), x = new u(), S = new u(), C = new u(), w = new u(), T = new s();
|
|
4
|
+
function E() {
|
|
5
|
+
let e = {
|
|
6
|
+
objects: [],
|
|
7
|
+
object: {},
|
|
8
|
+
vertices: [],
|
|
9
|
+
normals: [],
|
|
10
|
+
colors: [],
|
|
11
|
+
uvs: [],
|
|
12
|
+
materials: {},
|
|
13
|
+
materialLibraries: [],
|
|
14
|
+
startObject: function(e, t) {
|
|
15
|
+
if (this.object && this.object.fromDeclaration === !1) {
|
|
16
|
+
this.object.name = e, this.object.fromDeclaration = t !== !1;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
let n = this.object && typeof this.object.currentMaterial == "function" ? this.object.currentMaterial() : void 0;
|
|
20
|
+
if (this.object && typeof this.object._finalize == "function" && this.object._finalize(!0), this.object = {
|
|
21
|
+
name: e || "",
|
|
22
|
+
fromDeclaration: t !== !1,
|
|
23
|
+
geometry: {
|
|
24
|
+
vertices: [],
|
|
25
|
+
normals: [],
|
|
26
|
+
colors: [],
|
|
27
|
+
uvs: [],
|
|
28
|
+
hasUVIndices: !1
|
|
29
|
+
},
|
|
30
|
+
materials: [],
|
|
31
|
+
smooth: !0,
|
|
32
|
+
startMaterial: function(e, t) {
|
|
33
|
+
let n = this._finalize(!1);
|
|
34
|
+
n && (n.inherited || n.groupCount <= 0) && this.materials.splice(n.index, 1);
|
|
35
|
+
let r = {
|
|
36
|
+
index: this.materials.length,
|
|
37
|
+
name: e || "",
|
|
38
|
+
mtllib: Array.isArray(t) && t.length > 0 ? t[t.length - 1] : "",
|
|
39
|
+
smooth: n === void 0 ? this.smooth : n.smooth,
|
|
40
|
+
groupStart: n === void 0 ? 0 : n.groupEnd,
|
|
41
|
+
groupEnd: -1,
|
|
42
|
+
groupCount: -1,
|
|
43
|
+
inherited: !1,
|
|
44
|
+
clone: function(e) {
|
|
45
|
+
let t = {
|
|
46
|
+
index: typeof e == "number" ? e : this.index,
|
|
47
|
+
name: this.name,
|
|
48
|
+
mtllib: this.mtllib,
|
|
49
|
+
smooth: this.smooth,
|
|
50
|
+
groupStart: 0,
|
|
51
|
+
groupEnd: -1,
|
|
52
|
+
groupCount: -1,
|
|
53
|
+
inherited: !1
|
|
54
|
+
};
|
|
55
|
+
return t.clone = this.clone.bind(t), t;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return this.materials.push(r), r;
|
|
59
|
+
},
|
|
60
|
+
currentMaterial: function() {
|
|
61
|
+
if (this.materials.length > 0) return this.materials[this.materials.length - 1];
|
|
62
|
+
},
|
|
63
|
+
_finalize: function(e) {
|
|
64
|
+
let t = this.currentMaterial();
|
|
65
|
+
if (t && t.groupEnd === -1 && (t.groupEnd = this.geometry.vertices.length / 3, t.groupCount = t.groupEnd - t.groupStart, t.inherited = !1), e && this.materials.length > 1) for (let e = this.materials.length - 1; e >= 0; e--) this.materials[e].groupCount <= 0 && this.materials.splice(e, 1);
|
|
66
|
+
return e && this.materials.length === 0 && this.materials.push({
|
|
67
|
+
name: "",
|
|
68
|
+
smooth: this.smooth
|
|
69
|
+
}), t;
|
|
70
|
+
}
|
|
71
|
+
}, n && n.name && typeof n.clone == "function") {
|
|
72
|
+
let e = n.clone(0);
|
|
73
|
+
e.inherited = !0, this.object.materials.push(e);
|
|
74
|
+
}
|
|
75
|
+
this.objects.push(this.object);
|
|
76
|
+
},
|
|
77
|
+
finalize: function() {
|
|
78
|
+
this.object && typeof this.object._finalize == "function" && this.object._finalize(!0);
|
|
79
|
+
},
|
|
80
|
+
parseVertexIndex: function(e, t) {
|
|
81
|
+
let n = parseInt(e, 10);
|
|
82
|
+
return (n >= 0 ? n - 1 : n + t / 3) * 3;
|
|
83
|
+
},
|
|
84
|
+
parseNormalIndex: function(e, t) {
|
|
85
|
+
let n = parseInt(e, 10);
|
|
86
|
+
return (n >= 0 ? n - 1 : n + t / 3) * 3;
|
|
87
|
+
},
|
|
88
|
+
parseUVIndex: function(e, t) {
|
|
89
|
+
let n = parseInt(e, 10);
|
|
90
|
+
return (n >= 0 ? n - 1 : n + t / 2) * 2;
|
|
91
|
+
},
|
|
92
|
+
addVertex: function(e, t, n) {
|
|
93
|
+
let r = this.vertices, i = this.object.geometry.vertices;
|
|
94
|
+
i.push(r[e + 0], r[e + 1], r[e + 2]), i.push(r[t + 0], r[t + 1], r[t + 2]), i.push(r[n + 0], r[n + 1], r[n + 2]);
|
|
95
|
+
},
|
|
96
|
+
addVertexPoint: function(e) {
|
|
97
|
+
let t = this.vertices;
|
|
98
|
+
this.object.geometry.vertices.push(t[e + 0], t[e + 1], t[e + 2]);
|
|
99
|
+
},
|
|
100
|
+
addVertexLine: function(e) {
|
|
101
|
+
let t = this.vertices;
|
|
102
|
+
this.object.geometry.vertices.push(t[e + 0], t[e + 1], t[e + 2]);
|
|
103
|
+
},
|
|
104
|
+
addNormal: function(e, t, n) {
|
|
105
|
+
let r = this.normals, i = this.object.geometry.normals;
|
|
106
|
+
i.push(r[e + 0], r[e + 1], r[e + 2]), i.push(r[t + 0], r[t + 1], r[t + 2]), i.push(r[n + 0], r[n + 1], r[n + 2]);
|
|
107
|
+
},
|
|
108
|
+
addFaceNormal: function(e, t, n) {
|
|
109
|
+
let r = this.vertices, i = this.object.geometry.normals;
|
|
110
|
+
b.fromArray(r, e), x.fromArray(r, t), S.fromArray(r, n), w.subVectors(S, x), C.subVectors(b, x), w.cross(C), w.normalize(), i.push(w.x, w.y, w.z), i.push(w.x, w.y, w.z), i.push(w.x, w.y, w.z);
|
|
111
|
+
},
|
|
112
|
+
addColor: function(e, t, n) {
|
|
113
|
+
let r = this.colors, i = this.object.geometry.colors;
|
|
114
|
+
r[e] !== void 0 && i.push(r[e + 0], r[e + 1], r[e + 2]), r[t] !== void 0 && i.push(r[t + 0], r[t + 1], r[t + 2]), r[n] !== void 0 && i.push(r[n + 0], r[n + 1], r[n + 2]);
|
|
115
|
+
},
|
|
116
|
+
addUV: function(e, t, n) {
|
|
117
|
+
let r = this.uvs, i = this.object.geometry.uvs;
|
|
118
|
+
i.push(r[e + 0], r[e + 1]), i.push(r[t + 0], r[t + 1]), i.push(r[n + 0], r[n + 1]);
|
|
119
|
+
},
|
|
120
|
+
addDefaultUV: function() {
|
|
121
|
+
let e = this.object.geometry.uvs;
|
|
122
|
+
e.push(0, 0), e.push(0, 0), e.push(0, 0);
|
|
123
|
+
},
|
|
124
|
+
addUVLine: function(e) {
|
|
125
|
+
let t = this.uvs;
|
|
126
|
+
this.object.geometry.uvs.push(t[e + 0], t[e + 1]);
|
|
127
|
+
},
|
|
128
|
+
addFace: function(e, t, n, r, i, a, o, s, c) {
|
|
129
|
+
let l = this.vertices.length, u = this.parseVertexIndex(e, l), d = this.parseVertexIndex(t, l), f = this.parseVertexIndex(n, l);
|
|
130
|
+
if (this.addVertex(u, d, f), this.addColor(u, d, f), o !== void 0 && o !== "") {
|
|
131
|
+
let e = this.normals.length;
|
|
132
|
+
u = this.parseNormalIndex(o, e), d = this.parseNormalIndex(s, e), f = this.parseNormalIndex(c, e), this.addNormal(u, d, f);
|
|
133
|
+
} else this.addFaceNormal(u, d, f);
|
|
134
|
+
if (r !== void 0 && r !== "") {
|
|
135
|
+
let e = this.uvs.length;
|
|
136
|
+
u = this.parseUVIndex(r, e), d = this.parseUVIndex(i, e), f = this.parseUVIndex(a, e), this.addUV(u, d, f), this.object.geometry.hasUVIndices = !0;
|
|
137
|
+
} else this.addDefaultUV();
|
|
138
|
+
},
|
|
139
|
+
addPointGeometry: function(e) {
|
|
140
|
+
this.object.geometry.type = "Points";
|
|
141
|
+
let t = this.vertices.length;
|
|
142
|
+
for (let n = 0, r = e.length; n < r; n++) {
|
|
143
|
+
let r = this.parseVertexIndex(e[n], t);
|
|
144
|
+
this.addVertexPoint(r), this.addColor(r);
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
addLineGeometry: function(e, t) {
|
|
148
|
+
this.object.geometry.type = "Line";
|
|
149
|
+
let n = this.vertices.length, r = this.uvs.length;
|
|
150
|
+
for (let t = 0, r = e.length; t < r; t++) this.addVertexLine(this.parseVertexIndex(e[t], n));
|
|
151
|
+
for (let e = 0, n = t.length; e < n; e++) this.addUVLine(this.parseUVIndex(t[e], r));
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
return e.startObject("", !1), e;
|
|
155
|
+
}
|
|
156
|
+
var D = class extends n {
|
|
157
|
+
constructor(e) {
|
|
158
|
+
super(e), this.materials = null;
|
|
159
|
+
}
|
|
160
|
+
load(e, n, r, i) {
|
|
161
|
+
let a = this, o = new t(this.manager);
|
|
162
|
+
o.setPath(this.path), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(e, function(t) {
|
|
163
|
+
try {
|
|
164
|
+
n(a.parse(t));
|
|
165
|
+
} catch (t) {
|
|
166
|
+
i ? i(t) : console.error(t), a.manager.itemError(e);
|
|
167
|
+
}
|
|
168
|
+
}, r, i);
|
|
169
|
+
}
|
|
170
|
+
setMaterials(e) {
|
|
171
|
+
return this.materials = e, this;
|
|
172
|
+
}
|
|
173
|
+
parse(t) {
|
|
174
|
+
let n = new E();
|
|
175
|
+
t.indexOf("\r\n") !== -1 && (t = t.replace(/\r\n/g, "\n")), t.indexOf("\\\n") !== -1 && (t = t.replace(/\\\n/g, ""));
|
|
176
|
+
let s = t.split("\n"), u = [];
|
|
177
|
+
for (let e = 0, t = s.length; e < t; e++) {
|
|
178
|
+
let t = s[e].trimStart();
|
|
179
|
+
if (t.length === 0) continue;
|
|
180
|
+
let r = t.charAt(0);
|
|
181
|
+
if (r !== "#") if (r === "v") {
|
|
182
|
+
let e = t.split(y);
|
|
183
|
+
switch (e[0]) {
|
|
184
|
+
case "v":
|
|
185
|
+
n.vertices.push(parseFloat(e[1]), parseFloat(e[2]), parseFloat(e[3])), e.length >= 7 ? (T.setRGB(parseFloat(e[4]), parseFloat(e[5]), parseFloat(e[6]), c), n.colors.push(T.r, T.g, T.b)) : n.colors.push(void 0, void 0, void 0);
|
|
186
|
+
break;
|
|
187
|
+
case "vn":
|
|
188
|
+
n.normals.push(parseFloat(e[1]), parseFloat(e[2]), parseFloat(e[3]));
|
|
189
|
+
break;
|
|
190
|
+
case "vt":
|
|
191
|
+
n.uvs.push(parseFloat(e[1]), parseFloat(e[2]));
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
} else if (r === "f") {
|
|
195
|
+
let e = t.slice(1).trim().split(y), r = [];
|
|
196
|
+
for (let t = 0, n = e.length; t < n; t++) {
|
|
197
|
+
let n = e[t];
|
|
198
|
+
if (n.length > 0) {
|
|
199
|
+
let e = n.split("/");
|
|
200
|
+
r.push(e);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
let i = r[0];
|
|
204
|
+
for (let e = 1, t = r.length - 1; e < t; e++) {
|
|
205
|
+
let t = r[e], a = r[e + 1];
|
|
206
|
+
n.addFace(i[0], t[0], a[0], i[1], t[1], a[1], i[2], t[2], a[2]);
|
|
207
|
+
}
|
|
208
|
+
} else if (r === "l") {
|
|
209
|
+
let e = t.substring(1).trim().split(" "), r = [], i = [];
|
|
210
|
+
if (t.indexOf("/") === -1) r = e;
|
|
211
|
+
else for (let t = 0, n = e.length; t < n; t++) {
|
|
212
|
+
let n = e[t].split("/");
|
|
213
|
+
n[0] !== "" && r.push(n[0]), n[1] !== "" && i.push(n[1]);
|
|
214
|
+
}
|
|
215
|
+
n.addLineGeometry(r, i);
|
|
216
|
+
} else if (r === "p") {
|
|
217
|
+
let e = t.slice(1).trim().split(" ");
|
|
218
|
+
n.addPointGeometry(e);
|
|
219
|
+
} else if ((u = h.exec(t)) !== null) {
|
|
220
|
+
let e = (" " + u[0].slice(1).trim()).slice(1);
|
|
221
|
+
n.startObject(e);
|
|
222
|
+
} else if (_.test(t)) n.object.startMaterial(t.substring(7).trim(), n.materialLibraries);
|
|
223
|
+
else if (g.test(t)) n.materialLibraries.push(t.substring(7).trim());
|
|
224
|
+
else if (v.test(t)) console.warn("THREE.OBJLoader: Rendering identifier \"usemap\" not supported. Textures must be defined in MTL files.");
|
|
225
|
+
else if (r === "s") {
|
|
226
|
+
if (u = t.split(" "), u.length > 1) {
|
|
227
|
+
let e = u[1].trim().toLowerCase();
|
|
228
|
+
n.object.smooth = e !== "0" && e !== "off";
|
|
229
|
+
} else n.object.smooth = !0;
|
|
230
|
+
let e = n.object.currentMaterial();
|
|
231
|
+
e && (e.smooth = n.object.smooth);
|
|
232
|
+
} else {
|
|
233
|
+
if (t === "\0") continue;
|
|
234
|
+
console.warn("THREE.OBJLoader: Unexpected line: \"" + t + "\"");
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
n.finalize();
|
|
238
|
+
let b = new m();
|
|
239
|
+
if (b.materialLibraries = [].concat(n.materialLibraries), !(n.objects.length === 1 && n.objects[0].geometry.vertices.length === 0)) for (let t = 0, s = n.objects.length; t < s; t++) {
|
|
240
|
+
let s = n.objects[t], c = s.geometry, u = s.materials, m = c.type === "Line", h = c.type === "Points", g = !1;
|
|
241
|
+
if (c.vertices.length === 0) continue;
|
|
242
|
+
let _ = new f();
|
|
243
|
+
_.setAttribute("position", new i(c.vertices, 3)), c.normals.length > 0 && _.setAttribute("normal", new i(c.normals, 3)), c.colors.length > 0 && (g = !0, _.setAttribute("color", new i(c.colors, 3))), c.hasUVIndices === !0 && _.setAttribute("uv", new i(c.uvs, 2));
|
|
244
|
+
let v = [];
|
|
245
|
+
for (let t = 0, r = u.length; t < r; t++) {
|
|
246
|
+
let r = u[t], i = r.name + "_" + r.smooth + "_" + g, a = n.materials[i];
|
|
247
|
+
if (this.materials !== null) {
|
|
248
|
+
if (a = this.materials.create(r.name), m && a && !(a instanceof p)) {
|
|
249
|
+
let e = new p();
|
|
250
|
+
o.prototype.copy.call(e, a), e.color.copy(a.color), a = e;
|
|
251
|
+
} else if (h && a && !(a instanceof e)) {
|
|
252
|
+
let t = new e({
|
|
253
|
+
size: 10,
|
|
254
|
+
sizeAttenuation: !1
|
|
255
|
+
});
|
|
256
|
+
o.prototype.copy.call(t, a), t.color.copy(a.color), t.map = a.map, a = t;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
a === void 0 && (a = m ? new p() : h ? new e({
|
|
260
|
+
size: 1,
|
|
261
|
+
sizeAttenuation: !1
|
|
262
|
+
}) : new l(), a.name = r.name, a.flatShading = !r.smooth, a.vertexColors = g, n.materials[i] = a), v.push(a);
|
|
263
|
+
}
|
|
264
|
+
let y;
|
|
265
|
+
if (v.length > 1) {
|
|
266
|
+
for (let e = 0, t = u.length; e < t; e++) {
|
|
267
|
+
let t = u[e];
|
|
268
|
+
_.addGroup(t.groupStart, t.groupCount, e);
|
|
269
|
+
}
|
|
270
|
+
y = m ? new r(_, v) : h ? new a(_, v) : new d(_, v);
|
|
271
|
+
} else y = m ? new r(_, v[0]) : h ? new a(_, v[0]) : new d(_, v[0]);
|
|
272
|
+
y.name = s.name, b.add(y);
|
|
273
|
+
}
|
|
274
|
+
else if (n.vertices.length > 0) {
|
|
275
|
+
let t = new e({
|
|
276
|
+
size: 1,
|
|
277
|
+
sizeAttenuation: !1
|
|
278
|
+
}), r = new f();
|
|
279
|
+
r.setAttribute("position", new i(n.vertices, 3)), n.colors.length > 0 && n.colors[0] !== void 0 && (r.setAttribute("color", new i(n.colors, 3)), t.vertexColors = !0);
|
|
280
|
+
let o = new a(r, t);
|
|
281
|
+
b.add(o);
|
|
282
|
+
}
|
|
283
|
+
return b;
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
//#endregion
|
|
287
|
+
export { D as OBJLoader };
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { BufferGeometry as e, Color as t, FileLoader as n, Float32BufferAttribute as r, Group as i, LineBasicMaterial as a, LineSegments as o, Loader as s, Material as c, Mesh as l, MeshPhongMaterial as u, Points as d, PointsMaterial as f, SRGBColorSpace as p, Vector3 as m } from "three";
|
|
2
|
+
//#region node_modules/three/examples/jsm/loaders/OBJLoader.js
|
|
3
|
+
var h = /^[og]\s*(.+)?/, g = /^mtllib /, _ = /^usemtl /, v = /^usemap /, y = /\s+/, b = new m(), x = new m(), S = new m(), C = new m(), w = new m(), T = new t();
|
|
4
|
+
function E() {
|
|
5
|
+
let e = {
|
|
6
|
+
objects: [],
|
|
7
|
+
object: {},
|
|
8
|
+
vertices: [],
|
|
9
|
+
normals: [],
|
|
10
|
+
colors: [],
|
|
11
|
+
uvs: [],
|
|
12
|
+
materials: {},
|
|
13
|
+
materialLibraries: [],
|
|
14
|
+
startObject: function(e, t) {
|
|
15
|
+
if (this.object && this.object.fromDeclaration === !1) {
|
|
16
|
+
this.object.name = e, this.object.fromDeclaration = t !== !1;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
let n = this.object && typeof this.object.currentMaterial == "function" ? this.object.currentMaterial() : void 0;
|
|
20
|
+
if (this.object && typeof this.object._finalize == "function" && this.object._finalize(!0), this.object = {
|
|
21
|
+
name: e || "",
|
|
22
|
+
fromDeclaration: t !== !1,
|
|
23
|
+
geometry: {
|
|
24
|
+
vertices: [],
|
|
25
|
+
normals: [],
|
|
26
|
+
colors: [],
|
|
27
|
+
uvs: [],
|
|
28
|
+
hasUVIndices: !1
|
|
29
|
+
},
|
|
30
|
+
materials: [],
|
|
31
|
+
smooth: !0,
|
|
32
|
+
startMaterial: function(e, t) {
|
|
33
|
+
let n = this._finalize(!1);
|
|
34
|
+
n && (n.inherited || n.groupCount <= 0) && this.materials.splice(n.index, 1);
|
|
35
|
+
let r = {
|
|
36
|
+
index: this.materials.length,
|
|
37
|
+
name: e || "",
|
|
38
|
+
mtllib: Array.isArray(t) && t.length > 0 ? t[t.length - 1] : "",
|
|
39
|
+
smooth: n === void 0 ? this.smooth : n.smooth,
|
|
40
|
+
groupStart: n === void 0 ? 0 : n.groupEnd,
|
|
41
|
+
groupEnd: -1,
|
|
42
|
+
groupCount: -1,
|
|
43
|
+
inherited: !1,
|
|
44
|
+
clone: function(e) {
|
|
45
|
+
let t = {
|
|
46
|
+
index: typeof e == "number" ? e : this.index,
|
|
47
|
+
name: this.name,
|
|
48
|
+
mtllib: this.mtllib,
|
|
49
|
+
smooth: this.smooth,
|
|
50
|
+
groupStart: 0,
|
|
51
|
+
groupEnd: -1,
|
|
52
|
+
groupCount: -1,
|
|
53
|
+
inherited: !1
|
|
54
|
+
};
|
|
55
|
+
return t.clone = this.clone.bind(t), t;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return this.materials.push(r), r;
|
|
59
|
+
},
|
|
60
|
+
currentMaterial: function() {
|
|
61
|
+
if (this.materials.length > 0) return this.materials[this.materials.length - 1];
|
|
62
|
+
},
|
|
63
|
+
_finalize: function(e) {
|
|
64
|
+
let t = this.currentMaterial();
|
|
65
|
+
if (t && t.groupEnd === -1 && (t.groupEnd = this.geometry.vertices.length / 3, t.groupCount = t.groupEnd - t.groupStart, t.inherited = !1), e && this.materials.length > 1) for (let e = this.materials.length - 1; e >= 0; e--) this.materials[e].groupCount <= 0 && this.materials.splice(e, 1);
|
|
66
|
+
return e && this.materials.length === 0 && this.materials.push({
|
|
67
|
+
name: "",
|
|
68
|
+
smooth: this.smooth
|
|
69
|
+
}), t;
|
|
70
|
+
}
|
|
71
|
+
}, n && n.name && typeof n.clone == "function") {
|
|
72
|
+
let e = n.clone(0);
|
|
73
|
+
e.inherited = !0, this.object.materials.push(e);
|
|
74
|
+
}
|
|
75
|
+
this.objects.push(this.object);
|
|
76
|
+
},
|
|
77
|
+
finalize: function() {
|
|
78
|
+
this.object && typeof this.object._finalize == "function" && this.object._finalize(!0);
|
|
79
|
+
},
|
|
80
|
+
parseVertexIndex: function(e, t) {
|
|
81
|
+
let n = parseInt(e, 10);
|
|
82
|
+
return (n >= 0 ? n - 1 : n + t / 3) * 3;
|
|
83
|
+
},
|
|
84
|
+
parseNormalIndex: function(e, t) {
|
|
85
|
+
let n = parseInt(e, 10);
|
|
86
|
+
return (n >= 0 ? n - 1 : n + t / 3) * 3;
|
|
87
|
+
},
|
|
88
|
+
parseUVIndex: function(e, t) {
|
|
89
|
+
let n = parseInt(e, 10);
|
|
90
|
+
return (n >= 0 ? n - 1 : n + t / 2) * 2;
|
|
91
|
+
},
|
|
92
|
+
addVertex: function(e, t, n) {
|
|
93
|
+
let r = this.vertices, i = this.object.geometry.vertices;
|
|
94
|
+
i.push(r[e + 0], r[e + 1], r[e + 2]), i.push(r[t + 0], r[t + 1], r[t + 2]), i.push(r[n + 0], r[n + 1], r[n + 2]);
|
|
95
|
+
},
|
|
96
|
+
addVertexPoint: function(e) {
|
|
97
|
+
let t = this.vertices;
|
|
98
|
+
this.object.geometry.vertices.push(t[e + 0], t[e + 1], t[e + 2]);
|
|
99
|
+
},
|
|
100
|
+
addVertexLine: function(e) {
|
|
101
|
+
let t = this.vertices;
|
|
102
|
+
this.object.geometry.vertices.push(t[e + 0], t[e + 1], t[e + 2]);
|
|
103
|
+
},
|
|
104
|
+
addNormal: function(e, t, n) {
|
|
105
|
+
let r = this.normals, i = this.object.geometry.normals;
|
|
106
|
+
i.push(r[e + 0], r[e + 1], r[e + 2]), i.push(r[t + 0], r[t + 1], r[t + 2]), i.push(r[n + 0], r[n + 1], r[n + 2]);
|
|
107
|
+
},
|
|
108
|
+
addFaceNormal: function(e, t, n) {
|
|
109
|
+
let r = this.vertices, i = this.object.geometry.normals;
|
|
110
|
+
b.fromArray(r, e), x.fromArray(r, t), S.fromArray(r, n), w.subVectors(S, x), C.subVectors(b, x), w.cross(C), w.normalize(), i.push(w.x, w.y, w.z), i.push(w.x, w.y, w.z), i.push(w.x, w.y, w.z);
|
|
111
|
+
},
|
|
112
|
+
addColor: function(e, t, n) {
|
|
113
|
+
let r = this.colors, i = this.object.geometry.colors;
|
|
114
|
+
r[e] !== void 0 && i.push(r[e + 0], r[e + 1], r[e + 2]), r[t] !== void 0 && i.push(r[t + 0], r[t + 1], r[t + 2]), r[n] !== void 0 && i.push(r[n + 0], r[n + 1], r[n + 2]);
|
|
115
|
+
},
|
|
116
|
+
addUV: function(e, t, n) {
|
|
117
|
+
let r = this.uvs, i = this.object.geometry.uvs;
|
|
118
|
+
i.push(r[e + 0], r[e + 1]), i.push(r[t + 0], r[t + 1]), i.push(r[n + 0], r[n + 1]);
|
|
119
|
+
},
|
|
120
|
+
addDefaultUV: function() {
|
|
121
|
+
let e = this.object.geometry.uvs;
|
|
122
|
+
e.push(0, 0), e.push(0, 0), e.push(0, 0);
|
|
123
|
+
},
|
|
124
|
+
addUVLine: function(e) {
|
|
125
|
+
let t = this.uvs;
|
|
126
|
+
this.object.geometry.uvs.push(t[e + 0], t[e + 1]);
|
|
127
|
+
},
|
|
128
|
+
addFace: function(e, t, n, r, i, a, o, s, c) {
|
|
129
|
+
let l = this.vertices.length, u = this.parseVertexIndex(e, l), d = this.parseVertexIndex(t, l), f = this.parseVertexIndex(n, l);
|
|
130
|
+
if (this.addVertex(u, d, f), this.addColor(u, d, f), o !== void 0 && o !== "") {
|
|
131
|
+
let e = this.normals.length;
|
|
132
|
+
u = this.parseNormalIndex(o, e), d = this.parseNormalIndex(s, e), f = this.parseNormalIndex(c, e), this.addNormal(u, d, f);
|
|
133
|
+
} else this.addFaceNormal(u, d, f);
|
|
134
|
+
if (r !== void 0 && r !== "") {
|
|
135
|
+
let e = this.uvs.length;
|
|
136
|
+
u = this.parseUVIndex(r, e), d = this.parseUVIndex(i, e), f = this.parseUVIndex(a, e), this.addUV(u, d, f), this.object.geometry.hasUVIndices = !0;
|
|
137
|
+
} else this.addDefaultUV();
|
|
138
|
+
},
|
|
139
|
+
addPointGeometry: function(e) {
|
|
140
|
+
this.object.geometry.type = "Points";
|
|
141
|
+
let t = this.vertices.length;
|
|
142
|
+
for (let n = 0, r = e.length; n < r; n++) {
|
|
143
|
+
let r = this.parseVertexIndex(e[n], t);
|
|
144
|
+
this.addVertexPoint(r), this.addColor(r);
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
addLineGeometry: function(e, t) {
|
|
148
|
+
this.object.geometry.type = "Line";
|
|
149
|
+
let n = this.vertices.length, r = this.uvs.length;
|
|
150
|
+
for (let t = 0, r = e.length; t < r; t++) this.addVertexLine(this.parseVertexIndex(e[t], n));
|
|
151
|
+
for (let e = 0, n = t.length; e < n; e++) this.addUVLine(this.parseUVIndex(t[e], r));
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
return e.startObject("", !1), e;
|
|
155
|
+
}
|
|
156
|
+
var D = class extends s {
|
|
157
|
+
constructor(e) {
|
|
158
|
+
super(e), this.materials = null;
|
|
159
|
+
}
|
|
160
|
+
load(e, t, r, i) {
|
|
161
|
+
let a = this, o = new n(this.manager);
|
|
162
|
+
o.setPath(this.path), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(e, function(n) {
|
|
163
|
+
try {
|
|
164
|
+
t(a.parse(n));
|
|
165
|
+
} catch (t) {
|
|
166
|
+
i ? i(t) : console.error(t), a.manager.itemError(e);
|
|
167
|
+
}
|
|
168
|
+
}, r, i);
|
|
169
|
+
}
|
|
170
|
+
setMaterials(e) {
|
|
171
|
+
return this.materials = e, this;
|
|
172
|
+
}
|
|
173
|
+
parse(t) {
|
|
174
|
+
let n = new E();
|
|
175
|
+
t.indexOf("\r\n") !== -1 && (t = t.replace(/\r\n/g, "\n")), t.indexOf("\\\n") !== -1 && (t = t.replace(/\\\n/g, ""));
|
|
176
|
+
let s = t.split("\n"), m = [];
|
|
177
|
+
for (let e = 0, t = s.length; e < t; e++) {
|
|
178
|
+
let t = s[e].trimStart();
|
|
179
|
+
if (t.length === 0) continue;
|
|
180
|
+
let r = t.charAt(0);
|
|
181
|
+
if (r !== "#") if (r === "v") {
|
|
182
|
+
let e = t.split(y);
|
|
183
|
+
switch (e[0]) {
|
|
184
|
+
case "v":
|
|
185
|
+
n.vertices.push(parseFloat(e[1]), parseFloat(e[2]), parseFloat(e[3])), e.length >= 7 ? (T.setRGB(parseFloat(e[4]), parseFloat(e[5]), parseFloat(e[6]), p), n.colors.push(T.r, T.g, T.b)) : n.colors.push(void 0, void 0, void 0);
|
|
186
|
+
break;
|
|
187
|
+
case "vn":
|
|
188
|
+
n.normals.push(parseFloat(e[1]), parseFloat(e[2]), parseFloat(e[3]));
|
|
189
|
+
break;
|
|
190
|
+
case "vt":
|
|
191
|
+
n.uvs.push(parseFloat(e[1]), parseFloat(e[2]));
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
} else if (r === "f") {
|
|
195
|
+
let e = t.slice(1).trim().split(y), r = [];
|
|
196
|
+
for (let t = 0, n = e.length; t < n; t++) {
|
|
197
|
+
let n = e[t];
|
|
198
|
+
if (n.length > 0) {
|
|
199
|
+
let e = n.split("/");
|
|
200
|
+
r.push(e);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
let i = r[0];
|
|
204
|
+
for (let e = 1, t = r.length - 1; e < t; e++) {
|
|
205
|
+
let t = r[e], a = r[e + 1];
|
|
206
|
+
n.addFace(i[0], t[0], a[0], i[1], t[1], a[1], i[2], t[2], a[2]);
|
|
207
|
+
}
|
|
208
|
+
} else if (r === "l") {
|
|
209
|
+
let e = t.substring(1).trim().split(" "), r = [], i = [];
|
|
210
|
+
if (t.indexOf("/") === -1) r = e;
|
|
211
|
+
else for (let t = 0, n = e.length; t < n; t++) {
|
|
212
|
+
let n = e[t].split("/");
|
|
213
|
+
n[0] !== "" && r.push(n[0]), n[1] !== "" && i.push(n[1]);
|
|
214
|
+
}
|
|
215
|
+
n.addLineGeometry(r, i);
|
|
216
|
+
} else if (r === "p") {
|
|
217
|
+
let e = t.slice(1).trim().split(" ");
|
|
218
|
+
n.addPointGeometry(e);
|
|
219
|
+
} else if ((m = h.exec(t)) !== null) {
|
|
220
|
+
let e = (" " + m[0].slice(1).trim()).slice(1);
|
|
221
|
+
n.startObject(e);
|
|
222
|
+
} else if (_.test(t)) n.object.startMaterial(t.substring(7).trim(), n.materialLibraries);
|
|
223
|
+
else if (g.test(t)) n.materialLibraries.push(t.substring(7).trim());
|
|
224
|
+
else if (v.test(t)) console.warn("THREE.OBJLoader: Rendering identifier \"usemap\" not supported. Textures must be defined in MTL files.");
|
|
225
|
+
else if (r === "s") {
|
|
226
|
+
if (m = t.split(" "), m.length > 1) {
|
|
227
|
+
let e = m[1].trim().toLowerCase();
|
|
228
|
+
n.object.smooth = e !== "0" && e !== "off";
|
|
229
|
+
} else n.object.smooth = !0;
|
|
230
|
+
let e = n.object.currentMaterial();
|
|
231
|
+
e && (e.smooth = n.object.smooth);
|
|
232
|
+
} else {
|
|
233
|
+
if (t === "\0") continue;
|
|
234
|
+
console.warn("THREE.OBJLoader: Unexpected line: \"" + t + "\"");
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
n.finalize();
|
|
238
|
+
let b = new i();
|
|
239
|
+
if (b.materialLibraries = [].concat(n.materialLibraries), !(n.objects.length === 1 && n.objects[0].geometry.vertices.length === 0)) for (let t = 0, i = n.objects.length; t < i; t++) {
|
|
240
|
+
let i = n.objects[t], s = i.geometry, p = i.materials, m = s.type === "Line", h = s.type === "Points", g = !1;
|
|
241
|
+
if (s.vertices.length === 0) continue;
|
|
242
|
+
let _ = new e();
|
|
243
|
+
_.setAttribute("position", new r(s.vertices, 3)), s.normals.length > 0 && _.setAttribute("normal", new r(s.normals, 3)), s.colors.length > 0 && (g = !0, _.setAttribute("color", new r(s.colors, 3))), s.hasUVIndices === !0 && _.setAttribute("uv", new r(s.uvs, 2));
|
|
244
|
+
let v = [];
|
|
245
|
+
for (let e = 0, t = p.length; e < t; e++) {
|
|
246
|
+
let t = p[e], r = t.name + "_" + t.smooth + "_" + g, i = n.materials[r];
|
|
247
|
+
if (this.materials !== null) {
|
|
248
|
+
if (i = this.materials.create(t.name), m && i && !(i instanceof a)) {
|
|
249
|
+
let e = new a();
|
|
250
|
+
c.prototype.copy.call(e, i), e.color.copy(i.color), i = e;
|
|
251
|
+
} else if (h && i && !(i instanceof f)) {
|
|
252
|
+
let e = new f({
|
|
253
|
+
size: 10,
|
|
254
|
+
sizeAttenuation: !1
|
|
255
|
+
});
|
|
256
|
+
c.prototype.copy.call(e, i), e.color.copy(i.color), e.map = i.map, i = e;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
i === void 0 && (i = m ? new a() : h ? new f({
|
|
260
|
+
size: 1,
|
|
261
|
+
sizeAttenuation: !1
|
|
262
|
+
}) : new u(), i.name = t.name, i.flatShading = !t.smooth, i.vertexColors = g, n.materials[r] = i), v.push(i);
|
|
263
|
+
}
|
|
264
|
+
let y;
|
|
265
|
+
if (v.length > 1) {
|
|
266
|
+
for (let e = 0, t = p.length; e < t; e++) {
|
|
267
|
+
let t = p[e];
|
|
268
|
+
_.addGroup(t.groupStart, t.groupCount, e);
|
|
269
|
+
}
|
|
270
|
+
y = m ? new o(_, v) : h ? new d(_, v) : new l(_, v);
|
|
271
|
+
} else y = m ? new o(_, v[0]) : h ? new d(_, v[0]) : new l(_, v[0]);
|
|
272
|
+
y.name = i.name, b.add(y);
|
|
273
|
+
}
|
|
274
|
+
else if (n.vertices.length > 0) {
|
|
275
|
+
let t = new f({
|
|
276
|
+
size: 1,
|
|
277
|
+
sizeAttenuation: !1
|
|
278
|
+
}), i = new e();
|
|
279
|
+
i.setAttribute("position", new r(n.vertices, 3)), n.colors.length > 0 && n.colors[0] !== void 0 && (i.setAttribute("color", new r(n.colors, 3)), t.vertexColors = !0);
|
|
280
|
+
let a = new d(i, t);
|
|
281
|
+
b.add(a);
|
|
282
|
+
}
|
|
283
|
+
return b;
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
//#endregion
|
|
287
|
+
export { D as OBJLoader };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Mobject } from '../core/Mobject';
|
|
2
|
+
/**
|
|
3
|
+
* The keys of `M` whose values are methods.
|
|
4
|
+
*
|
|
5
|
+
* Used to constrain `methodName` so only callable members of a mobject are
|
|
6
|
+
* accepted. The predicate uses `never[]` parameters so a method with concrete
|
|
7
|
+
* parameter types (for example `setX(x: number)`) still matches.
|
|
8
|
+
*/
|
|
9
|
+
export type MethodKeys<M> = {
|
|
10
|
+
[K in keyof M]: M[K] extends (...args: never[]) => unknown ? K : never;
|
|
11
|
+
}[keyof M];
|
|
12
|
+
/**
|
|
13
|
+
* Re-apply a mobject method each frame with arguments from live getters.
|
|
14
|
+
*
|
|
15
|
+
* Adds an updater that calls `mob[methodName]` with the current value of each
|
|
16
|
+
* getter. Use it to continually set a property from a value that changes over
|
|
17
|
+
* time, for example a `ValueTracker`.
|
|
18
|
+
*
|
|
19
|
+
* @param mob - The mobject that owns the method.
|
|
20
|
+
* @param methodName - The name of a method on `mob`.
|
|
21
|
+
* @param argGetters - Zero or more getters; each is called every frame.
|
|
22
|
+
* @returns `mob`, for chaining.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const tracker = new ValueTracker(0);
|
|
27
|
+
* fAlways(dot, 'setX', () => tracker.getValue());
|
|
28
|
+
* // Each frame: dot.setX(tracker.getValue()).
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function fAlways<M extends Mobject>(mob: M, methodName: MethodKeys<M>, ...argGetters: Array<() => unknown>): M;
|
|
32
|
+
/**
|
|
33
|
+
* Re-apply a mobject method each frame with fixed arguments.
|
|
34
|
+
*
|
|
35
|
+
* Adds an updater that calls `mob[methodName]` with the same arguments on every
|
|
36
|
+
* frame. Use it to keep a property pinned to a fixed value against other
|
|
37
|
+
* updaters that would change it.
|
|
38
|
+
*
|
|
39
|
+
* @param mob - The mobject that owns the method.
|
|
40
|
+
* @param methodName - The name of a method on `mob`.
|
|
41
|
+
* @param args - Zero or more fixed arguments, re-applied every frame.
|
|
42
|
+
* @returns `mob`, for chaining.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* always(dot, 'setX', 2);
|
|
47
|
+
* // Each frame: dot.setX(2).
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function always<M extends Mobject>(mob: M, methodName: MethodKeys<M>, ...args: unknown[]): M;
|
|
51
|
+
/**
|
|
52
|
+
* Assert that `(mob, methodName)` names a method of a Mobject (CE
|
|
53
|
+
* `assert_is_mobject_method`).
|
|
54
|
+
*
|
|
55
|
+
* CE takes one bound method and recovers the receiver from `method.__self__`.
|
|
56
|
+
* A JavaScript method reference loses its `this`, so this repo validates the
|
|
57
|
+
* `(mobject, methodName)` pair that `always` / `fAlways` already accept. The
|
|
58
|
+
* check throws a clear `Error` when `mob` is not a `Mobject`, or when
|
|
59
|
+
* `mob[methodName]` is not a function.
|
|
60
|
+
*
|
|
61
|
+
* @param mob - The value that must be a `Mobject`.
|
|
62
|
+
* @param methodName - The name that must resolve to a method on `mob`.
|
|
63
|
+
* @throws Error when `mob` is not a `Mobject` or `methodName` is not a method.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* assertIsMobjectMethod(dot, 'setX'); // ok
|
|
68
|
+
* assertIsMobjectMethod(dot, 'nope'); // throws
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare function assertIsMobjectMethod(mob: unknown, methodName: string): void;
|
|
72
|
+
//# sourceMappingURL=Always.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Always.d.ts","sourceRoot":"","sources":["../../src/animation/Always.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAK1C;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;KACzB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,GAAG,CAAC,GAAG,KAAK;CACvE,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,OAAO,EACvC,GAAG,EAAE,CAAC,EACN,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,GAAG,UAAU,EAAE,KAAK,CAAC,MAAM,OAAO,CAAC,GAClC,CAAC,CASH;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,OAAO,EACtC,GAAG,EAAE,CAAC,EACN,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,GAAG,IAAI,EAAE,OAAO,EAAE,GACjB,CAAC,CAMH;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAW5E"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Mobject } from '../core/Mobject';
|
|
2
|
+
/**
|
|
3
|
+
* Create a mobject that redraws itself on every frame.
|
|
4
|
+
*
|
|
5
|
+
* @param fn - Factory that returns the mobject for the current frame.
|
|
6
|
+
* @returns The mobject, with an updater that rebuilds it each frame.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const label = alwaysRedraw(() => new Text(`x = ${dot.getCenter()[0].toFixed(2)}`));
|
|
11
|
+
* scene.add(label);
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function alwaysRedraw(fn: () => Mobject): Mobject;
|
|
15
|
+
//# sourceMappingURL=AlwaysRedraw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AlwaysRedraw.d.ts","sourceRoot":"","sources":["../../src/animation/AlwaysRedraw.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,OAAO,GAAG,OAAO,CAMvD"}
|
|
@@ -71,6 +71,15 @@ export declare abstract class Animation {
|
|
|
71
71
|
* @param alpha Progress from 0 (start) to 1 (end)
|
|
72
72
|
*/
|
|
73
73
|
abstract interpolate(alpha: number): void;
|
|
74
|
+
/**
|
|
75
|
+
* Manim CE's `get_sub_alpha`: remaps a global progress `alpha` into the
|
|
76
|
+
* local progress of family member `index` (of `count`) under a `lagRatio`
|
|
77
|
+
* stagger. With `lagRatio <= 0` (or a single member), every member tracks
|
|
78
|
+
* `alpha` directly. Subclasses that stagger across a mobject's family
|
|
79
|
+
* (e.g. Create) should index this by `familyMembersWithPoints()`, never by
|
|
80
|
+
* rendering-layer primitives.
|
|
81
|
+
*/
|
|
82
|
+
protected getSubAlpha(alpha: number, index: number, count: number, lagRatio: number): number;
|
|
74
83
|
/**
|
|
75
84
|
* Update the animation for the current frame.
|
|
76
85
|
* @param _dt Time delta since last frame (unused, but available for subclasses)
|