manim-web 0.10.0 → 0.12.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 (69) 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/audio/Voiceover.d.ts +95 -0
  6. package/dist/audio/Voiceover.d.ts.map +1 -0
  7. package/dist/audio/VoiceoverScene.d.ts +28 -0
  8. package/dist/audio/VoiceoverScene.d.ts.map +1 -0
  9. package/dist/audio/bookmarks.d.ts +40 -0
  10. package/dist/audio/bookmarks.d.ts.map +1 -0
  11. package/dist/audio/speechSynthesizer.d.ts +95 -0
  12. package/dist/audio/speechSynthesizer.d.ts.map +1 -0
  13. package/dist/core/Mobject.d.ts +31 -0
  14. package/dist/core/Mobject.d.ts.map +1 -1
  15. package/dist/core/Scene.d.ts +9 -0
  16. package/dist/core/Scene.d.ts.map +1 -1
  17. package/dist/export/FrameExporter.d.ts +86 -0
  18. package/dist/export/FrameExporter.d.ts.map +1 -0
  19. package/dist/export/WebCodecsExporter.d.ts +108 -0
  20. package/dist/export/WebCodecsExporter.d.ts.map +1 -0
  21. package/dist/export/index.d.ts +2 -0
  22. package/dist/export/index.d.ts.map +1 -1
  23. package/dist/index.d.ts +12 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +3 -2
  26. package/dist/integrations/react.js +17 -16
  27. package/dist/integrations/vue.js +16 -15
  28. package/dist/integrations/webcomponent.d.ts +65 -0
  29. package/dist/integrations/webcomponent.d.ts.map +1 -0
  30. package/dist/integrations/webcomponent.js +2 -0
  31. package/dist/interaction/MovablePoint.d.ts +127 -0
  32. package/dist/interaction/MovablePoint.d.ts.map +1 -0
  33. package/dist/interaction/Slider.d.ts +125 -0
  34. package/dist/interaction/Slider.d.ts.map +1 -0
  35. package/dist/interaction/index.d.ts +2 -0
  36. package/dist/interaction/index.d.ts.map +1 -1
  37. package/dist/manim-web.browser.js +10073 -20358
  38. package/dist/mobjects/svg/SVGMobject.d.ts +29 -0
  39. package/dist/mobjects/svg/SVGMobject.d.ts.map +1 -1
  40. package/dist/mobjects/svg/index.d.ts +3 -1
  41. package/dist/mobjects/svg/index.d.ts.map +1 -1
  42. package/dist/mobjects/svg/svgFill.d.ts +42 -0
  43. package/dist/mobjects/svg/svgFill.d.ts.map +1 -0
  44. package/dist/mobjects/svg/svgGradients.d.ts +68 -0
  45. package/dist/mobjects/svg/svgGradients.d.ts.map +1 -0
  46. package/dist/mobjects/svg/svgImage.d.ts +9 -0
  47. package/dist/mobjects/svg/svgImage.d.ts.map +1 -0
  48. package/dist/mobjects/svg/svgLoader.d.ts +35 -0
  49. package/dist/mobjects/svg/svgLoader.d.ts.map +1 -0
  50. package/dist/mobjects/svg/svgText.d.ts +15 -0
  51. package/dist/mobjects/svg/svgText.d.ts.map +1 -0
  52. package/dist/mobjects/three-d/ModelMobject.d.ts +122 -0
  53. package/dist/mobjects/three-d/ModelMobject.d.ts.map +1 -0
  54. package/dist/mobjects/video/VideoMobject.d.ts +126 -0
  55. package/dist/mobjects/video/VideoMobject.d.ts.map +1 -0
  56. package/dist/mobjects/video/index.d.ts +2 -0
  57. package/dist/mobjects/video/index.d.ts.map +1 -0
  58. package/dist/mp4-muxer-5DGKGEJk.js +900 -0
  59. package/dist/player/Player.d.ts +4 -0
  60. package/dist/player/Player.d.ts.map +1 -1
  61. package/dist/rendering/blendModes.d.ts +38 -0
  62. package/dist/rendering/blendModes.d.ts.map +1 -0
  63. package/dist/{src-D29Z9zIa.js → src-BQF5-SG7.js} +6853 -6218
  64. package/dist/three.core-1aHSpGwp.js +11626 -0
  65. package/dist/utils/ThemeManager.d.ts +79 -0
  66. package/dist/utils/ThemeManager.d.ts.map +1 -0
  67. package/dist/webcomponent-BS5WnkDO.js +707 -0
  68. package/dist/webm-muxer-BGY-Mgbp.js +857 -0
  69. 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,95 @@
1
+ import { AddSoundOptions, AudioTrack } from '../core/AudioManager';
2
+ import { Bookmark } from './bookmarks';
3
+ import { SpeechOptions, SpeechSynthesizer } from './speechSynthesizer';
4
+ /**
5
+ * Tracks one narration segment: lets a callback wait for a bookmark or for the
6
+ * whole narration to finish. One tracker is created per `voiceover` call.
7
+ */
8
+ export interface VoiceoverTracker {
9
+ /** The spoken text, with bookmark markers already removed. */
10
+ readonly text: string;
11
+ /** Every bookmark found in the transcript, in order. */
12
+ readonly bookmarks: ReadonlyArray<Bookmark>;
13
+ /** Resolves when the narration finishes (or fails, or is cancelled). */
14
+ readonly finished: Promise<void>;
15
+ /** The failure message if the narration errored, else `null`. */
16
+ readonly error: string | null;
17
+ /**
18
+ * Resolve when the narration reaches `mark`. Resolves immediately if the
19
+ * mark was already reached, and resolves on finish if the mark never arrives
20
+ * (so an animation beat never hangs).
21
+ */
22
+ waitForMark(mark: string): Promise<void>;
23
+ /** Resolve when the narration finishes. Same promise as {@link finished}. */
24
+ waitForFinish(): Promise<void>;
25
+ /** Whether the narration has already reached `mark`. */
26
+ markReached(mark: string): boolean;
27
+ }
28
+ /** Options for a `Voiceover` instance or a single `voiceover` call. */
29
+ export interface VoiceoverOptions extends SpeechOptions {
30
+ /** A synthesizer that overrides the injected / default one for this scope. */
31
+ synthesizer?: SpeechSynthesizer;
32
+ }
33
+ /** A callback that runs animations while the narration plays. */
34
+ export type VoiceoverCallback = (tracker: VoiceoverTracker) => void | Promise<void>;
35
+ /** The scheduler a pre-recorded voiceover plays through (AudioManager satisfies it). */
36
+ export interface VoiceoverAudioScheduler {
37
+ /** Schedule a clip on the timeline. */
38
+ addSound(url: string, options?: AddSoundOptions): Promise<AudioTrack>;
39
+ /** Start playback of the scheduled timeline. */
40
+ play(): void;
41
+ }
42
+ /** Options for a pre-recorded voiceover. */
43
+ export interface VoiceoverAudioOptions {
44
+ /** URL of the narration audio clip. */
45
+ url: string;
46
+ /** The scheduler that plays the clip (usually a scene's `audioManager`). */
47
+ audioManager: VoiceoverAudioScheduler;
48
+ /** Map of bookmark name to time in seconds from the clip start. */
49
+ bookmarks?: Record<string, number>;
50
+ /** When to start the clip on the scheduler timeline (seconds). Default 0. */
51
+ time?: number;
52
+ /** Narration length in seconds. Falls back to the scheduled track duration. */
53
+ duration?: number;
54
+ /** Playback gain in [0, 1]. */
55
+ gain?: number;
56
+ }
57
+ /**
58
+ * Narrates text and syncs animation beats to the narration.
59
+ *
60
+ * One instance can be reused for a whole scene; each `voiceover` call is one
61
+ * narration segment with its own tracker.
62
+ */
63
+ export declare class Voiceover {
64
+ private readonly _options;
65
+ private _activeHandle;
66
+ constructor(options?: VoiceoverOptions);
67
+ /**
68
+ * Speak `text` and run `callback` while it plays.
69
+ *
70
+ * The narration and the callback run together. Any `<bookmark mark="..."/>`
71
+ * markers in `text` are stripped before speaking and exposed through the
72
+ * tracker. The returned promise resolves after the narration finishes.
73
+ *
74
+ * @param text - Narration, optionally with bookmark markers.
75
+ * @param callback - Runs animations; may await `tracker.waitForMark`.
76
+ * @param options - Per-call speech options (merged over the instance options).
77
+ * @returns The tracker for this narration segment.
78
+ */
79
+ voiceover(text: string, callback?: VoiceoverCallback, options?: VoiceoverOptions): Promise<VoiceoverTracker>;
80
+ /**
81
+ * Play a pre-recorded narration clip through the given scheduler and sync
82
+ * animation beats to explicit bookmark times.
83
+ *
84
+ * Scheduling is delegated to the {@link VoiceoverAudioScheduler} (normally a
85
+ * scene's `audioManager`); this method never duplicates audio scheduling.
86
+ *
87
+ * @param options - Clip URL, scheduler, bookmark times and timing.
88
+ * @param callback - Runs animations; may await `tracker.waitForMark`.
89
+ * @returns The tracker for this narration segment.
90
+ */
91
+ voiceoverAudio(options: VoiceoverAudioOptions, callback?: VoiceoverCallback): Promise<VoiceoverTracker>;
92
+ /** Cancel the narration currently in flight, if any. */
93
+ cancel(): void;
94
+ }
95
+ //# sourceMappingURL=Voiceover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Voiceover.d.ts","sourceRoot":"","sources":["../../src/audio/Voiceover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAM7B;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wDAAwD;IACxD,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC5C,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,6EAA6E;IAC7E,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,wDAAwD;IACxD,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACpC;AAyGD,uEAAuE;AACvE,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,8EAA8E;IAC9E,WAAW,CAAC,EAAE,iBAAiB,CAAC;CACjC;AAED,iEAAiE;AACjE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEpF,wFAAwF;AACxF,MAAM,WAAW,uBAAuB;IACtC,uCAAuC;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACtE,gDAAgD;IAChD,IAAI,IAAI,IAAI,CAAC;CACd;AAED,4CAA4C;AAC5C,MAAM,WAAW,qBAAqB;IACpC,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,4EAA4E;IAC5E,YAAY,EAAE,uBAAuB,CAAC;IACtC,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAiBD;;;;;GAKG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmB;IAC5C,OAAO,CAAC,aAAa,CAAmC;gBAE5C,OAAO,GAAE,gBAAqB;IAI1C;;;;;;;;;;;OAWG;IACG,SAAS,CACb,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,iBAAiB,EAC5B,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IA4B5B;;;;;;;;;;OAUG;IACG,cAAc,CAClB,OAAO,EAAE,qBAAqB,EAC9B,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,OAAO,CAAC,gBAAgB,CAAC;IA0B5B,wDAAwD;IACxD,MAAM,IAAI,IAAI;CAMf"}