manim-web 0.10.0 → 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.
Files changed (33) hide show
  1. package/dist/GLTFLoader-CisHz7tR.js +1381 -0
  2. package/dist/GLTFLoader-DMbWuMln.js +1381 -0
  3. package/dist/OBJLoader-Clh2POv9.js +287 -0
  4. package/dist/OBJLoader-kkTsEhJf.js +287 -0
  5. package/dist/export/FrameExporter.d.ts +86 -0
  6. package/dist/export/FrameExporter.d.ts.map +1 -0
  7. package/dist/export/WebCodecsExporter.d.ts +108 -0
  8. package/dist/export/WebCodecsExporter.d.ts.map +1 -0
  9. package/dist/export/index.d.ts +2 -0
  10. package/dist/export/index.d.ts.map +1 -1
  11. package/dist/index.d.ts +4 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +3 -2
  14. package/dist/integrations/react.js +17 -16
  15. package/dist/integrations/vue.js +16 -15
  16. package/dist/integrations/webcomponent.d.ts +65 -0
  17. package/dist/integrations/webcomponent.d.ts.map +1 -0
  18. package/dist/integrations/webcomponent.js +2 -0
  19. package/dist/manim-web.browser.js +9285 -20305
  20. package/dist/mobjects/three-d/ModelMobject.d.ts +122 -0
  21. package/dist/mobjects/three-d/ModelMobject.d.ts.map +1 -0
  22. package/dist/mobjects/video/VideoMobject.d.ts +126 -0
  23. package/dist/mobjects/video/VideoMobject.d.ts.map +1 -0
  24. package/dist/mobjects/video/index.d.ts +2 -0
  25. package/dist/mobjects/video/index.d.ts.map +1 -0
  26. package/dist/mp4-muxer-5DGKGEJk.js +900 -0
  27. package/dist/player/Player.d.ts +4 -0
  28. package/dist/player/Player.d.ts.map +1 -1
  29. package/dist/{src-D29Z9zIa.js → src-C817VR8M.js} +7511 -7611
  30. package/dist/three.core-1aHSpGwp.js +11626 -0
  31. package/dist/webcomponent-BS5WnkDO.js +707 -0
  32. package/dist/webm-muxer-BGY-Mgbp.js +857 -0
  33. package/package.json +9 -2
@@ -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,86 @@
1
+ /**
2
+ * FrameExporter - in-browser PNG frame export for manim-web scenes.
3
+ *
4
+ * Captures the scene's WebGL canvas as PNG image data with no ffmpeg and no
5
+ * server round-trip. It uses `canvas.toBlob` when available and falls back to
6
+ * `canvas.toDataURL` so it also works where `toBlob` is missing.
7
+ *
8
+ * Two capture modes are provided:
9
+ * - `exportFramePNG` captures one frame (the current frame, or a seeked time).
10
+ * - `exportPNGSequence` seeks and captures one frame per timeline step, the
11
+ * same frame loop VideoExporter uses.
12
+ */
13
+ /**
14
+ * Duck-type interface for Scene, used to avoid a circular import.
15
+ * FrameExporter only needs canvas access, seek, and the timeline duration.
16
+ */
17
+ interface ExportableScene {
18
+ getCanvas(): HTMLCanvasElement;
19
+ getWidth(): number;
20
+ getHeight(): number;
21
+ seek(time: number): void;
22
+ getTimelineDuration(): number | null;
23
+ }
24
+ /** Options for a single-frame PNG capture. */
25
+ export interface FrameExportOptions {
26
+ /** Timeline time in seconds to seek to before capture. Omit for current frame. */
27
+ time?: number;
28
+ /** Image MIME type. Defaults to 'image/png'. */
29
+ type?: string;
30
+ /** Quality from 0-1 for lossy types such as 'image/jpeg'. Ignored for PNG. */
31
+ quality?: number;
32
+ }
33
+ /** Options for a PNG frame-sequence capture. */
34
+ export interface PNGSequenceOptions {
35
+ /** Frames per second to sample the timeline at. */
36
+ fps: number;
37
+ /** Start time in seconds. Defaults to 0. */
38
+ from?: number;
39
+ /** End time in seconds. Defaults to the timeline duration (or 5 if unknown). */
40
+ to?: number;
41
+ /** Image MIME type. Defaults to 'image/png'. */
42
+ type?: string;
43
+ /** Quality from 0-1 for lossy types. */
44
+ quality?: number;
45
+ /** Progress callback (0-1). */
46
+ onProgress?: (progress: number) => void;
47
+ }
48
+ /**
49
+ * Export a single frame as a PNG Blob.
50
+ *
51
+ * When `time` is given, the scene seeks to it (which renders the frame) before
52
+ * capture. Otherwise the current frame is captured as-is.
53
+ *
54
+ * @param scene - The scene to capture
55
+ * @param options - Capture options
56
+ * @returns A Promise that resolves to the frame Blob
57
+ */
58
+ export declare function exportFramePNG(scene: ExportableScene, options?: FrameExportOptions): Promise<Blob>;
59
+ /**
60
+ * Export a range of the timeline as a PNG frame sequence.
61
+ *
62
+ * The loop seeks to each frame time and captures the canvas, mirroring
63
+ * VideoExporter's frame loop. The result is one Blob per frame in order.
64
+ *
65
+ * @param scene - The scene to capture
66
+ * @param options - Sequence options (fps is required)
67
+ * @returns A Promise that resolves to the array of frame Blobs
68
+ */
69
+ export declare function exportPNGSequence(scene: ExportableScene, options: PNGSequenceOptions): Promise<Blob[]>;
70
+ /**
71
+ * Download a Blob as a file by clicking a temporary anchor element.
72
+ *
73
+ * @param blob - The blob to download
74
+ * @param filename - The target filename
75
+ */
76
+ export declare function downloadBlob(blob: Blob, filename: string): void;
77
+ /**
78
+ * Convenience helper: capture one PNG frame and download it.
79
+ *
80
+ * @param scene - The scene to capture
81
+ * @param filename - The target filename. Defaults to 'frame.png'.
82
+ * @param options - Capture options
83
+ */
84
+ export declare function exportAndDownloadPNG(scene: ExportableScene, filename?: string, options?: FrameExportOptions): Promise<void>;
85
+ export {};
86
+ //# sourceMappingURL=FrameExporter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FrameExporter.d.ts","sourceRoot":"","sources":["../../src/export/FrameExporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;GAGG;AACH,UAAU,eAAe;IACvB,SAAS,IAAI,iBAAiB,CAAC;IAC/B,QAAQ,IAAI,MAAM,CAAC;IACnB,SAAS,IAAI,MAAM,CAAC;IACpB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,mBAAmB,IAAI,MAAM,GAAG,IAAI,CAAC;CACtC;AAED,8CAA8C;AAC9C,MAAM,WAAW,kBAAkB;IACjC,kFAAkF;IAClF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,gDAAgD;AAChD,MAAM,WAAW,kBAAkB;IACjC,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gFAAgF;IAChF,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AA+CD;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,eAAe,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAMf;AAED;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,eAAe,EACtB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,IAAI,EAAE,CAAC,CAoBjB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAS/D;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,eAAe,EACtB,QAAQ,GAAE,MAAoB,EAC9B,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAGf"}