@realsee/dnalogel 3.77.4 → 3.77.6

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 (74) hide show
  1. package/CHANGELOG.md +20 -11
  2. package/dist/DigitalPerformancePlugin/controller/index.d.ts +224 -0
  3. package/dist/DigitalPerformancePlugin/core/DigitalHuman.d.ts +55 -0
  4. package/dist/DigitalPerformancePlugin/core/DigitalPlayground.d.ts +40 -0
  5. package/dist/DigitalPerformancePlugin/core/DigitalStateMachine.d.ts +150 -0
  6. package/dist/DigitalPerformancePlugin/core/Trace.d.ts +9 -0
  7. package/dist/DigitalPerformancePlugin/index.d.ts +11 -0
  8. package/dist/DigitalPerformancePlugin/mock.d.ts +76 -0
  9. package/dist/DigitalPerformancePlugin/typings/index.d.ts +79 -0
  10. package/dist/PanoTagPlugin/controller/Tag/BaseTag.d.ts +5 -1
  11. package/dist/PanoTagPlugin/controller/Tag/BoxTag.d.ts +119 -0
  12. package/dist/PanoTagPlugin/controller/Tag/MaskTag.d.ts +257 -0
  13. package/dist/PanoTagPlugin/controller/Tag/MaskTag.shaders.d.ts +10 -0
  14. package/dist/PanoTagPlugin/controller/Tag/PolygonTag.d.ts +112 -0
  15. package/dist/PanoTagPlugin/controller/TagRender.d.ts +1 -1
  16. package/dist/PanoTagPlugin/controller/index.d.ts +55 -2
  17. package/dist/PanoTagPlugin/typings/controller.d.ts +10 -0
  18. package/dist/PanoTagPlugin/typings/tag/Tag.d.ts +8 -3
  19. package/dist/PanoTagPlugin/typings/tag/Utils.d.ts +50 -1
  20. package/dist/PanoTagPlugin/utils/sculptDataToBoxPosition.d.ts +6 -0
  21. package/dist/PanoTagPlugin/utils/tag/tagCheck.d.ts +6 -0
  22. package/dist/PanoTagPlugin/utils/tagPosition.d.ts +12 -3
  23. package/dist/index.cjs.js +188 -92
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.js +17508 -14249
  26. package/dist/index.umd.js +184 -88
  27. package/libs/CruisePlugin/Move.js +7 -2
  28. package/libs/CruisePlugin/Work.js +7 -2
  29. package/libs/CruisePlugin/index.js +11 -6
  30. package/libs/DigitalPerformancePlugin/controller/index.d.ts +2 -2
  31. package/libs/DigitalPerformancePlugin/controller/index.js +164 -173
  32. package/libs/DigitalPerformancePlugin/core/DigitalHuman.d.ts +16 -6
  33. package/libs/DigitalPerformancePlugin/core/DigitalHuman.js +128 -102
  34. package/libs/DigitalPerformancePlugin/core/DigitalPlayground.d.ts +11 -5
  35. package/libs/DigitalPerformancePlugin/core/DigitalPlayground.js +84 -74
  36. package/libs/DigitalPerformancePlugin/core/DigitalStateMachine.d.ts +7 -0
  37. package/libs/DigitalPerformancePlugin/mock.d.ts +6 -0
  38. package/libs/DigitalPerformancePlugin/mock.js +272 -274
  39. package/libs/GuideLinePlugin/Controller.js +9 -4
  40. package/libs/GuideLinePlugin/GuideLineItem.js +7 -2
  41. package/libs/GuideLinePlugin/GuideLineModeItem.js +7 -2
  42. package/libs/GuideLinePlugin/index.js +11 -6
  43. package/libs/PanoTagPlugin/Components/TagItem.js +122 -122
  44. package/libs/PanoTagPlugin/controller/Tag/BaseTag.d.ts +5 -1
  45. package/libs/PanoTagPlugin/controller/Tag/BaseTag.js +320 -289
  46. package/libs/PanoTagPlugin/controller/Tag/BoxTag.d.ts +119 -0
  47. package/libs/PanoTagPlugin/controller/Tag/BoxTag.js +515 -0
  48. package/libs/PanoTagPlugin/controller/Tag/MaskTag.d.ts +257 -0
  49. package/libs/PanoTagPlugin/controller/Tag/MaskTag.js +815 -0
  50. package/libs/PanoTagPlugin/controller/Tag/MaskTag.shaders.d.ts +10 -0
  51. package/libs/PanoTagPlugin/controller/Tag/MaskTag.shaders.js +94 -0
  52. package/libs/PanoTagPlugin/controller/Tag/PolygonTag.d.ts +112 -0
  53. package/libs/PanoTagPlugin/controller/Tag/PolygonTag.js +478 -0
  54. package/libs/PanoTagPlugin/controller/TagRender.d.ts +1 -1
  55. package/libs/PanoTagPlugin/controller/TagUtil.js +19 -17
  56. package/libs/PanoTagPlugin/controller/index.d.ts +55 -2
  57. package/libs/PanoTagPlugin/controller/index.js +261 -148
  58. package/libs/PanoTagPlugin/index.js +16 -11
  59. package/libs/PanoTagPlugin/typings/controller.d.ts +10 -0
  60. package/libs/PanoTagPlugin/typings/tag/Tag.d.ts +8 -3
  61. package/libs/PanoTagPlugin/typings/tag/Utils.d.ts +50 -1
  62. package/libs/PanoTagPlugin/utils/addDebugPoints.js +27 -13
  63. package/libs/PanoTagPlugin/utils/index.js +29 -26
  64. package/libs/PanoTagPlugin/utils/sculptDataToBoxPosition.d.ts +6 -0
  65. package/libs/PanoTagPlugin/utils/sculptDataToBoxPosition.js +18 -0
  66. package/libs/PanoTagPlugin/utils/tag/tagCheck.d.ts +6 -0
  67. package/libs/PanoTagPlugin/utils/tag/tagCheck.js +26 -14
  68. package/libs/PanoTagPlugin/utils/tagPosition.d.ts +12 -3
  69. package/libs/PanoTagPlugin/utils/tagPosition.js +49 -16
  70. package/libs/base/BasePlugin.js +1 -1
  71. package/libs/index.d.ts +1 -0
  72. package/libs/index.js +166 -150
  73. package/libs/shared-utils/logger.js +1 -1
  74. package/package.json +2 -2
@@ -2,35 +2,35 @@ var D = Object.defineProperty, k = Object.defineProperties;
2
2
  var H = Object.getOwnPropertyDescriptors;
3
3
  var S = Object.getOwnPropertySymbols;
4
4
  var I = Object.prototype.hasOwnProperty, U = Object.prototype.propertyIsEnumerable;
5
- var v = (f, t, e) => t in f ? D(f, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : f[t] = e, E = (f, t) => {
5
+ var v = (d, t, e) => t in d ? D(d, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : d[t] = e, E = (d, t) => {
6
6
  for (var e in t || (t = {}))
7
- I.call(t, e) && v(f, e, t[e]);
7
+ I.call(t, e) && v(d, e, t[e]);
8
8
  if (S)
9
9
  for (var e of S(t))
10
- U.call(t, e) && v(f, e, t[e]);
11
- return f;
12
- }, x = (f, t) => k(f, H(t));
13
- var P = (f, t, e) => (v(f, typeof t != "symbol" ? t + "" : t, e), e);
14
- var p = (f, t, e) => new Promise((i, s) => {
15
- var o = (r) => {
10
+ U.call(t, e) && v(d, e, t[e]);
11
+ return d;
12
+ }, x = (d, t) => k(d, H(t));
13
+ var P = (d, t, e) => (v(d, typeof t != "symbol" ? t + "" : t, e), e);
14
+ var m = (d, t, e) => new Promise((i, s) => {
15
+ var o = (a) => {
16
16
  try {
17
- n(e.next(r));
17
+ n(e.next(a));
18
18
  } catch (l) {
19
19
  s(l);
20
20
  }
21
- }, a = (r) => {
21
+ }, r = (a) => {
22
22
  try {
23
- n(e.throw(r));
23
+ n(e.throw(a));
24
24
  } catch (l) {
25
25
  s(l);
26
26
  }
27
- }, n = (r) => r.done ? i(r.value) : Promise.resolve(r.value).then(o, a);
28
- n((e = e.apply(f, t)).next());
27
+ }, n = (a) => a.done ? i(a.value) : Promise.resolve(a.value).then(o, r);
28
+ n((e = e.apply(d, t)).next());
29
29
  });
30
30
  import { DigitalPlayground as R } from "../core/DigitalPlayground.js";
31
- import { Vector3 as N } from "three";
31
+ import { Vector3 as w } from "three";
32
32
  import { convertMockToPlayer as z } from "../mock.js";
33
- import { transformPosition as w } from "../../shared-utils/five/transformPosition.js";
33
+ import { transformPosition as N } from "../../shared-utils/five/transformPosition.js";
34
34
  import "@realsee/five/gltf-loader";
35
35
  import "../core/DigitalHuman.js";
36
36
  import "../core/DigitalStateMachine.js";
@@ -67,13 +67,11 @@ class Q {
67
67
  playMode: "single"
68
68
  }, this.NAME = G, this.config.debug, this.init();
69
69
  }
70
- init() {
71
- }
72
70
  /**
73
71
  * 加载剧本数据
74
72
  */
75
73
  loadScript(t) {
76
- return p(this, null, function* () {
74
+ return m(this, null, function* () {
77
75
  try {
78
76
  if (this.state.currentScript = t, this.playground.setScript(t), this.clearProgressCache(), this.config.debug, yield this.preloadResources(t), this.five && this.five.scene) {
79
77
  yield new Promise((i) => requestAnimationFrame(i));
@@ -94,23 +92,29 @@ class Q {
94
92
  }
95
93
  });
96
94
  }
95
+ init() {
96
+ }
97
97
  /**
98
98
  * 预加载资源
99
99
  */
100
100
  preloadResources(t) {
101
- return p(this, null, function* () {
102
- const e = [], i = [], s = /* @__PURE__ */ new Set();
103
- t.chapters.forEach((o) => {
104
- o.players.forEach((a) => {
101
+ return m(this, null, function* () {
102
+ const e = [], i = [], s = /* @__PURE__ */ new Set(), o = [], r = /* @__PURE__ */ new Map();
103
+ t.chapters.forEach((n) => {
104
+ n.players.forEach((a) => {
105
105
  if (a.type === "model") {
106
- const n = a;
107
- e.push(n.model), i.push(a.id), n.keyframes.forEach((r) => {
108
- r.animation && s.add(r.animation.url);
106
+ const l = a;
107
+ e.push(l.model), i.push(a.id), l.keyframes.forEach((u) => {
108
+ u.animation && (s.add(u.animation.url), u.animation.item && (o.push(u.animation.item.url), r.set(u.animation.item.url, {
109
+ position: u.animation.item.position,
110
+ rotation: u.animation.item.rotation
111
+ })));
109
112
  });
110
113
  }
111
114
  });
112
115
  }), yield Promise.all([
113
116
  this.playground.loadModels(e, i),
117
+ this.playground.loadItems(o, r),
114
118
  this.playground.loadAnimations(Array.from(s))
115
119
  ]), this.config.debug;
116
120
  });
@@ -119,7 +123,7 @@ class Q {
119
123
  * 播放指定章节
120
124
  */
121
125
  playChapter(t) {
122
- return p(this, null, function* () {
126
+ return m(this, null, function* () {
123
127
  this.emitPlayingPlayersChanged();
124
128
  try {
125
129
  this.state.currentChapter = t, this.state.playing = !0, this.state.playMode = "single", this.config.debug, yield this.playground.playByChapter(t), this.state.playing = !1, this.config.debug;
@@ -132,7 +136,7 @@ class Q {
132
136
  * 播放指定章节(内部方法,用于连续播放)
133
137
  */
134
138
  playChapterForContinuous(t) {
135
- return p(this, null, function* () {
139
+ return m(this, null, function* () {
136
140
  this.emitPlayingPlayersChanged();
137
141
  try {
138
142
  this.state.currentChapter = t, this.state.playing = !0, this.config.debug, yield this.playground.playByChapter(t), this.state.continuousPlaying && (this.state.playing = !0), yield new Promise((e) => setTimeout(e, 100)), this.config.debug;
@@ -145,7 +149,7 @@ class Q {
145
149
  * 播放指定章节(通过索引)
146
150
  */
147
151
  playChapterByIndex(t) {
148
- return p(this, null, function* () {
152
+ return m(this, null, function* () {
149
153
  if (!this.state.currentScript)
150
154
  throw new Error("No script loaded");
151
155
  if (t < 0 || t >= this.state.currentScript.chapters.length)
@@ -163,7 +167,7 @@ class Q {
163
167
  * 继续播放
164
168
  */
165
169
  continue() {
166
- return p(this, null, function* () {
170
+ return m(this, null, function* () {
167
171
  this._autoPlayOnNaturalEnd = !0;
168
172
  try {
169
173
  this.config.debug && console.log(`${this.NAME} continuing in ${this.state.playMode} mode`), this.state.playMode === "continuous" ? yield this.continueAllRemaining() : (this.state.currentChapter && this.state.currentChapter.players.forEach((t) => {
@@ -181,7 +185,7 @@ class Q {
181
185
  * 连续播放模式下的继续播放(从暂停位置继续播放所有剩余章节)
182
186
  */
183
187
  continueAllRemaining() {
184
- return p(this, null, function* () {
188
+ return m(this, null, function* () {
185
189
  if (!this.state.currentScript || !this.state.currentChapter)
186
190
  throw new Error("No script or chapter loaded");
187
191
  const t = this.state.currentScript.chapters, e = t.findIndex((i) => i.name === this.state.currentChapter.name);
@@ -199,75 +203,70 @@ class Q {
199
203
  isCompleted: o,
200
204
  isNearHardcodedPause: s
201
205
  }), o ? (console.log(`${this.NAME} [continueAllRemaining] chapter already completed, restarting`), yield this.playChapterForContinuous(this.state.currentChapter), i = this.getProgress(), console.log(`${this.NAME} [continueAllRemaining] progress after restart:`, i)) : s ? (console.log(`${this.NAME} [continueAllRemaining] detected hardcoded pause, skipping to 27500ms`), this.state.currentChapter.players.filter((n) => n.type === "model").forEach((n) => {
202
- const r = this.playground.getDigitalHuman(n.model, n.id);
203
- r && (r.state.currentTime = 27500);
206
+ const a = this.playground.getDigitalHuman(n.model, n.id);
207
+ a && (a.state.currentTime = 27500);
204
208
  }), this.state.currentChapter.players.forEach((n) => {
205
209
  if (n.type === "model") {
206
- const r = this.playground.getDigitalHuman(n.model, n.id);
207
- r && r.continueAnimation();
210
+ const a = this.playground.getDigitalHuman(n.model, n.id);
211
+ a && a.continueAnimation();
208
212
  }
209
- }), this.state.playing = !0, console.log(`${this.NAME} [continueAllRemaining] after hardcoded pause skip - playing:`, this.state.playing)) : (console.log(`${this.NAME} [continueAllRemaining] continuing from paused position`), this.state.currentChapter.players.forEach((a) => {
210
- if (a.type === "model") {
211
- const n = this.playground.getDigitalHuman(a.model, a.id);
213
+ }), this.state.playing = !0, console.log(`${this.NAME} [continueAllRemaining] after hardcoded pause skip - playing:`, this.state.playing)) : (console.log(`${this.NAME} [continueAllRemaining] continuing from paused position`), this.state.currentChapter.players.forEach((r) => {
214
+ if (r.type === "model") {
215
+ const n = this.playground.getDigitalHuman(r.model, r.id);
212
216
  n && n.continueAnimation();
213
217
  }
214
- }), this.state.playing = !0, console.log(`${this.NAME} [continueAllRemaining] after continue - playing:`, this.state.playing)), i = this.getProgress(), console.log(
215
- `${this.NAME} [continueAllRemaining] updated progress before wait:`,
216
- i,
217
- "playing:",
218
- this.state.playing
219
- ), i && i.currentTime < i.totalTime ? yield new Promise((a) => {
220
- let n = (i == null ? void 0 : i.currentTime) || 0, r = 0;
221
- const l = 15, m = () => {
222
- var g;
223
- if (!((g = this.state) != null && g.continuousPlaying)) {
224
- console.log(`${this.NAME} [continueAllRemaining] stopped by user`), a();
218
+ }), this.state.playing = !0, console.log(`${this.NAME} [continueAllRemaining] after continue - playing:`, this.state.playing)), i = this.getProgress(), console.log(`${this.NAME} [continueAllRemaining] updated progress before wait:`, i, "playing:", this.state.playing), i && i.currentTime < i.totalTime ? yield new Promise((r) => {
219
+ let n = (i == null ? void 0 : i.currentTime) || 0, a = 0;
220
+ const l = 15, u = () => {
221
+ var p;
222
+ if (!((p = this.state) != null && p.continuousPlaying)) {
223
+ console.log(`${this.NAME} [continueAllRemaining] stopped by user`), r();
225
224
  return;
226
225
  }
227
226
  const h = this.getProgress();
228
227
  if (this.config.debug, h && h.currentTime >= h.totalTime) {
229
- a();
228
+ r();
230
229
  return;
231
230
  }
232
231
  if (h && h.currentTime < 0) {
233
- console.warn(`${this.NAME} [continueAllRemaining] detected negative time, skipping wait`), a();
232
+ console.warn(`${this.NAME} [continueAllRemaining] detected negative time, skipping wait`), r();
234
233
  return;
235
234
  }
236
235
  if (h && h.currentTime === n) {
237
- if (r++, r >= l) {
238
- console.warn(`${this.NAME} [continueAllRemaining] progress stagnant for 3s, assuming chapter completed`), a();
236
+ if (a++, a >= l) {
237
+ console.warn(`${this.NAME} [continueAllRemaining] progress stagnant for 3s, assuming chapter completed`), r();
239
238
  return;
240
239
  }
241
240
  } else
242
- r = 0, n = (h == null ? void 0 : h.currentTime) || 0;
243
- setTimeout(m, 200);
241
+ a = 0, n = (h == null ? void 0 : h.currentTime) || 0;
242
+ setTimeout(u, 200);
244
243
  };
245
- m();
244
+ u();
246
245
  }) : console.log(`${this.NAME} [continueAllRemaining] chapter already completed or restarted, skipping wait`), console.log(
247
246
  `${this.NAME} [continueAllRemaining] starting to play remaining chapters from index ${e + 1} to ${t.length - 1}`
248
247
  ), this.emitPlayingPlayersChanged();
249
- for (let a = e + 1; a < t.length; a++) {
248
+ for (let r = e + 1; r < t.length; r++) {
250
249
  if (!this.state.continuousPlaying) {
251
- this.config.debug && console.log(`${this.NAME} continuous playback stopped by user at chapter ${a + 1}`);
250
+ this.config.debug && console.log(`${this.NAME} continuous playback stopped by user at chapter ${r + 1}`);
252
251
  break;
253
252
  }
254
- const n = t[a];
253
+ const n = t[r];
255
254
  this.config.debug;
256
255
  try {
257
256
  n.players.filter((h) => h.type === "model").forEach((h) => {
258
- const g = this.playground.getDigitalHuman(h.model, h.id);
259
- g && (g.state.currentTime = 0);
257
+ const p = this.playground.getDigitalHuman(h.model, h.id);
258
+ p && (p.state.currentTime = 0);
260
259
  });
261
260
  const l = Date.now();
262
261
  yield this.playChapterForContinuous(n);
263
- const m = Date.now() - l;
262
+ const u = Date.now() - l;
264
263
  if (this.config.debug, !this.state.continuousPlaying) {
265
- this.config.debug && console.log(`${this.NAME} continuous playback stopped after chapter ${a + 1}`);
264
+ this.config.debug && console.log(`${this.NAME} continuous playback stopped after chapter ${r + 1}`);
266
265
  break;
267
266
  }
268
- a < t.length - 1 && (yield new Promise((h) => setTimeout(h, 1e3)));
269
- } catch (r) {
270
- console.error(`${this.NAME} failed to play chapter ${n.name}:`, r), this.state.continuousPlaying = !1;
267
+ r < t.length - 1 && (yield new Promise((h) => setTimeout(h, 1e3)));
268
+ } catch (a) {
269
+ console.error(`${this.NAME} failed to play chapter ${n.name}:`, a), this.state.continuousPlaying = !1;
271
270
  break;
272
271
  }
273
272
  }
@@ -283,7 +282,7 @@ class Q {
283
282
  * 从当前章节播放到最后一个章节(连续自动播放)
284
283
  */
285
284
  playAllRemaining() {
286
- return p(this, null, function* () {
285
+ return m(this, null, function* () {
287
286
  if (this._autoPlayOnNaturalEnd = !0, !this.state.currentScript)
288
287
  throw new Error("No script loaded");
289
288
  const t = this.state.currentScript.chapters;
@@ -295,15 +294,15 @@ class Q {
295
294
  this.config.debug;
296
295
  const i = !this.state.playing && this.state.currentChapter !== null, s = this.getProgress();
297
296
  if (i) {
298
- const o = s && s.currentTime >= 26e3 && s.currentTime <= 27e3, a = s && s.totalTime > 0 && s.currentTime >= s.totalTime;
297
+ const o = s && s.currentTime >= 26e3 && s.currentTime <= 27e3, r = s && s.totalTime > 0 && s.currentTime >= s.totalTime;
299
298
  if (console.log(`${this.NAME} [playAllRemaining] pause analysis:`, {
300
299
  hasProgress: !!s,
301
300
  currentTime: s == null ? void 0 : s.currentTime,
302
301
  totalTime: s == null ? void 0 : s.totalTime,
303
- isCompleted: a,
302
+ isCompleted: r,
304
303
  isNearHardcodedPause: o,
305
- shouldContinueFromPause: !a || o
306
- }), this.emitPlayingPlayersChanged(), !a || o) {
304
+ shouldContinueFromPause: !r || o
305
+ }), this.emitPlayingPlayersChanged(), !r || o) {
307
306
  this.config.debug, yield this.continue();
308
307
  return;
309
308
  } else if (this.config.debug, e += 1, e >= t.length) {
@@ -316,35 +315,35 @@ class Q {
316
315
  this.config.debug && console.log(`${this.NAME} continuous playback stopped by user at chapter ${o + 1}`), this.emitPlayingPlayersChanged();
317
316
  break;
318
317
  }
319
- const a = t[o];
318
+ const r = t[o];
320
319
  this.config.debug;
321
320
  try {
322
- const n = this.state.currentChapter && this.state.currentChapter.name === a.name, r = i && n && o === e;
323
- if (!n || r) {
324
- const h = a.players.filter((g) => g.type === "model");
325
- if (r) {
326
- const g = this.getProgress();
327
- g && g.currentTime >= 26e3 && g.currentTime <= 27e3 ? (h.forEach((b) => {
321
+ const n = this.state.currentChapter && this.state.currentChapter.name === r.name, a = i && n && o === e;
322
+ if (!n || a) {
323
+ const h = r.players.filter((p) => p.type === "model");
324
+ if (a) {
325
+ const p = this.getProgress();
326
+ p && p.currentTime >= 26e3 && p.currentTime <= 27e3 ? (h.forEach((b) => {
328
327
  const M = this.playground.getDigitalHuman(b.model);
329
328
  M && (M.state.currentTime = 27500);
330
- }), this.config.debug && console.log(`${this.NAME} skipped hardcoded pause for chapter: ${a.name}`)) : this.config.debug && console.log(`${this.NAME} continuing current chapter from existing position: ${a.name}`);
329
+ }), this.config.debug && console.log(`${this.NAME} skipped hardcoded pause for chapter: ${r.name}`)) : this.config.debug && console.log(`${this.NAME} continuing current chapter from existing position: ${r.name}`);
331
330
  } else
332
- h.forEach((g) => {
333
- const T = this.playground.getDigitalHuman(g.model, g.id);
331
+ h.forEach((p) => {
332
+ const T = this.playground.getDigitalHuman(p.model, p.id);
334
333
  T && (T.state.currentTime = 0);
335
- }), this.config.debug && console.log(`${this.NAME} reset time for new chapter: ${a.name}`);
334
+ }), this.config.debug && console.log(`${this.NAME} reset time for new chapter: ${r.name}`);
336
335
  } else
337
336
  this.config.debug;
338
337
  const l = Date.now();
339
- yield this.playChapterForContinuous(a);
340
- const m = Date.now() - l;
338
+ yield this.playChapterForContinuous(r);
339
+ const u = Date.now() - l;
341
340
  if (this.config.debug, this.state.continuousPlaying && !this.state.playing && (console.warn(`${this.NAME} [playAllRemaining] chapter completed but playing state is false, fixing...`), this.state.playing = !0), !this.state.continuousPlaying) {
342
341
  this.config.debug && console.log(`${this.NAME} continuous playback stopped after chapter ${o + 1}`), this.emitPlayingPlayersChanged();
343
342
  break;
344
343
  }
345
344
  o < t.length - 1, o < t.length - 1 && (yield new Promise((h) => setTimeout(h, 1e3)));
346
345
  } catch (n) {
347
- console.error(`${this.NAME} failed to play chapter ${a.name}:`, n), this.emitPlayingPlayersChanged(), this.state.continuousPlaying = !1;
346
+ console.error(`${this.NAME} failed to play chapter ${r.name}:`, n), this.emitPlayingPlayersChanged(), this.state.continuousPlaying = !1;
348
347
  break;
349
348
  }
350
349
  }
@@ -424,8 +423,8 @@ class Q {
424
423
  if (i.type === "model") {
425
424
  const s = i, o = s.keyframes[s.keyframes.length - 1];
426
425
  o && (t = Math.max(t, o.timeStamp));
427
- const a = this.playground.getDigitalHuman(s.model, s.id);
428
- a && (e = Math.max(e, a.state.currentTime || 0));
426
+ const r = this.playground.getDigitalHuman(s.model, s.id);
427
+ r && (e = Math.max(e, r.state.currentTime || 0));
429
428
  }
430
429
  }), { currentTime: e, totalTime: t };
431
430
  }
@@ -436,57 +435,57 @@ class Q {
436
435
  * @param totalDelay 可选,默认0
437
436
  */
438
437
  transformScriptData(t, e, i = 0) {
439
- var n, r;
438
+ var n, a;
440
439
  if (!t || !t.players || !Array.isArray(t.players))
441
440
  return t;
442
441
  const s = (n = t.players[0]) != null && n.fiveState ? E({}, t.players[0].fiveState) : void 0;
443
442
  if (s && s.offset && e) {
444
- const l = new N(s.offset.x, s.offset.y, s.offset.z), m = w(l, e == null ? void 0 : e.transform);
445
- s.offset = { x: m.x, y: m.y, z: m.z };
443
+ const l = new w(s.offset.x, s.offset.y, s.offset.z), u = N(l, e == null ? void 0 : e.transform);
444
+ s.offset = { x: u.x, y: u.y, z: u.z };
446
445
  }
447
446
  const o = [
448
447
  {
449
448
  id: 0,
450
- name: ((r = t.players[0]) == null ? void 0 : r.chapterName) || "Chapter 1",
449
+ name: ((a = t.players[0]) == null ? void 0 : a.chapterName) || "Chapter 1",
451
450
  players: []
452
451
  }
453
452
  ];
454
- let a = 0;
455
- return t.players.forEach((l, m) => {
453
+ let r = 0;
454
+ return t.players.forEach((l, u) => {
456
455
  var T, b, M;
457
456
  let h = E({}, l);
458
457
  if (e && ((T = h.track) != null && T.path && Array.isArray(h.track.path) && (h.track.path = h.track.path.map((y) => {
459
- const d = w(new N(y.x, y.y, y.z), e == null ? void 0 : e.transform);
458
+ const f = N(new w(y.x, y.y, y.z), e == null ? void 0 : e.transform);
460
459
  return {
461
- x: d.x,
462
- y: d.y,
463
- z: d.z
460
+ x: f.x,
461
+ y: f.y,
462
+ z: f.z
464
463
  };
465
464
  })), (b = h.track) != null && b.points && Array.isArray(h.track.points) && (h.track.points = h.track.points.map((y) => {
466
465
  if (y.point) {
467
- const d = w(
468
- new N(y.point.x, y.point.y, y.point.z),
466
+ const f = N(
467
+ new w(y.point.x, y.point.y, y.point.z),
469
468
  e == null ? void 0 : e.transform
470
469
  );
471
470
  return x(E({}, y), {
472
471
  point: {
473
- x: d.x,
474
- y: d.y,
475
- z: d.z
472
+ x: f.x,
473
+ y: f.y,
474
+ z: f.z
476
475
  }
477
476
  });
478
477
  }
479
478
  return y;
480
479
  })), h.matrix && Array.isArray(h.matrix) && h.matrix.length >= 16)) {
481
- const y = new N(h.matrix[12], h.matrix[13], h.matrix[14]), d = w(y, e == null ? void 0 : e.transform);
482
- h.matrix[12] = d.x, h.matrix[13] = d.y, h.matrix[14] = d.z;
480
+ const y = new w(h.matrix[12], h.matrix[13], h.matrix[14]), f = N(y, e == null ? void 0 : e.transform);
481
+ h.matrix[12] = f.x, h.matrix[13] = f.y, h.matrix[14] = f.z;
483
482
  }
484
- const g = z(h, i);
485
- ((M = l.config) == null ? void 0 : M.type) === "simultaneous" || m > 0 && a++, o[a] || o.push({
486
- id: a,
487
- name: l.chapterName || `Chapter ${a + 1}`,
483
+ const p = z(h, i);
484
+ ((M = l.config) == null ? void 0 : M.type) === "simultaneous" || u > 0 && r++, o[r] || o.push({
485
+ id: r,
486
+ name: l.chapterName || `Chapter ${r + 1}`,
488
487
  players: []
489
- }), o[a].players.push(g);
488
+ }), o[r].players.push(p);
490
489
  }), {
491
490
  id: t.id,
492
491
  name: t.name,
@@ -537,15 +536,15 @@ class Q {
537
536
  const t = [];
538
537
  let e = 0;
539
538
  return this.state.currentScript.chapters.forEach((i, s) => {
540
- const o = this.calculateChapterDuration(i), a = e + o;
539
+ const o = this.calculateChapterDuration(i), r = e + o;
541
540
  t.push({
542
541
  chapterIndex: s,
543
542
  chapterName: i.name,
544
543
  startTime: e,
545
544
  duration: o,
546
- endTime: a,
545
+ endTime: r,
547
546
  chapter: i
548
- }), e = a;
547
+ }), e = r;
549
548
  }), this.chapterTimeMapCache = t, this.config.debug && console.log(`${this.NAME} generated chapter time map:`, t), t;
550
549
  }
551
550
  /**
@@ -563,11 +562,11 @@ class Q {
563
562
  getGlobalProgress() {
564
563
  let t = 0, e = 0, i = 0;
565
564
  if (this.state.currentChapter) {
566
- const n = this.getChapterTimeMap().find((r) => r.chapter.name === this.state.currentChapter.name);
565
+ const n = this.getChapterTimeMap().find((a) => a.chapter.name === this.state.currentChapter.name);
567
566
  if (n) {
568
567
  e = n.chapterIndex;
569
- const r = this.getProgress();
570
- i = (r == null ? void 0 : r.currentTime) || 0, t = n.startTime + i;
568
+ const a = this.getProgress();
569
+ i = (a == null ? void 0 : a.currentTime) || 0, t = n.startTime + i;
571
570
  }
572
571
  }
573
572
  const s = this.getTotalDuration(), o = s > 0 ? t / s * 100 : 0;
@@ -587,7 +586,7 @@ class Q {
587
586
  const e = this.getChapterTimeMap();
588
587
  if (e.length === 0)
589
588
  return null;
590
- const s = e.find((a) => t >= a.startTime && t < a.endTime) || (t >= e[e.length - 1].startTime ? e[e.length - 1] : null);
589
+ const s = e.find((r) => t >= r.startTime && t < r.endTime) || (t >= e[e.length - 1].startTime ? e[e.length - 1] : null);
591
590
  if (!s)
592
591
  return null;
593
592
  const o = t - s.startTime;
@@ -601,7 +600,7 @@ class Q {
601
600
  * 跳转到指定的全局时间
602
601
  */
603
602
  seekToGlobalTime(t, e) {
604
- return p(this, null, function* () {
603
+ return m(this, null, function* () {
605
604
  var i;
606
605
  this._autoPlayOnNaturalEnd = !!e;
607
606
  try {
@@ -609,21 +608,21 @@ class Q {
609
608
  throw new Error("No script loaded");
610
609
  const s = this.getTotalDuration(), o = Math.max(0, Math.min(t, s));
611
610
  this.config.debug, this.emit("seek-started", o);
612
- const a = this.getChapterByGlobalTime(o);
613
- if (!a)
611
+ const r = this.getChapterByGlobalTime(o);
612
+ if (!r)
614
613
  throw new Error("Unable to locate chapter for the specified time");
615
- const { chapterIndex: n, chapterTime: r, chapter: l } = a, m = this.state.playing;
616
- this.state.playing && this.pause(), (!this.state.currentChapter || this.state.currentChapter.name !== l.name) && (this.config.debug && console.log(`${this.NAME} switching to chapter ${n}: ${l.name}`), yield this.initializeChapterForSeek(l, r), this.state.currentChapter = l, this.emit("chapter-changed", n, l)), this.setTimelineTo(r), r === 0 && this.state.currentScript.chapters.forEach((u) => {
617
- u.players.forEach((C) => {
614
+ const { chapterIndex: n, chapterTime: a, chapter: l } = r, u = this.state.playing;
615
+ this.state.playing && this.pause(), (!this.state.currentChapter || this.state.currentChapter.name !== l.name) && (this.config.debug && console.log(`${this.NAME} switching to chapter ${n}: ${l.name}`), yield this.initializeChapterForSeek(l, a), this.state.currentChapter = l, this.emit("chapter-changed", n, l)), this.setTimelineTo(a), a === 0 && this.state.currentScript.chapters.forEach((g) => {
616
+ g.players.forEach((C) => {
618
617
  if (C.type === "model") {
619
618
  const A = this.playground.getDigitalHuman(C.model, C.id);
620
619
  A && A.stopAnimation();
621
620
  }
622
621
  });
623
622
  });
624
- const T = this.getChapterTimeMap().find((u) => u.chapter.name === l.name), b = (i = T == null ? void 0 : T.chapterIndex) != null ? i : 0;
625
- this.state.currentScript.chapters.forEach((u, C) => {
626
- u.players.forEach((A) => {
623
+ const T = this.getChapterTimeMap().find((g) => g.chapter.name === l.name), b = (i = T == null ? void 0 : T.chapterIndex) != null ? i : 0;
624
+ this.state.currentScript.chapters.forEach((g, C) => {
625
+ g.players.forEach((A) => {
627
626
  if (A.type === "model") {
628
627
  const c = this.playground.getDigitalHuman(A.model, A.id);
629
628
  if (!c)
@@ -635,8 +634,8 @@ class Q {
635
634
  keyframes: A.keyframes,
636
635
  items: A.items,
637
636
  effects: A.effects
638
- }), c.state.currentTime = r, c.model.visible = !0, c.container.visible = !0, c.state.currentTime = r, c.keyframesManager && c.keyframes) {
639
- const $ = c.keyframesManager.getStateByTime(r, c.keyframes, "model");
637
+ }), c.state.currentTime = a, c.model.visible = !0, c.container.visible = !0, c.state.currentTime = a, c.keyframesManager && c.keyframes) {
638
+ const $ = c.keyframesManager.getStateByTime(a, c.keyframes, "model");
640
639
  $ && (c.model.position.copy($.translation), c.model.quaternion.copy($.quaternion), c.model.scale.copy($.scale), c.model.visible = $.visible);
641
640
  }
642
641
  e ? c.continueAnimation() : c.pauseAnimation && c.pauseAnimation();
@@ -644,21 +643,21 @@ class Q {
644
643
  c.model.visible = !1, c.container.visible = !1, c.state.currentTime = 0, c.pauseAnimation && c.pauseAnimation();
645
644
  }
646
645
  });
647
- }), (e !== void 0 ? e : m) && (this.state.playing = !0, l.players.forEach((u) => {
648
- if (u.type === "model") {
649
- const C = this.playground.getDigitalHuman(u.model, u.id);
646
+ }), (e !== void 0 ? e : u) && (this.state.playing = !0, l.players.forEach((g) => {
647
+ if (g.type === "model") {
648
+ const C = this.playground.getDigitalHuman(g.model, g.id);
650
649
  C && (C.play({
651
- keyframes: u.keyframes,
652
- items: u.items,
653
- effects: u.effects
654
- }), C.state.currentTime = r, C.continueAnimation());
650
+ keyframes: g.keyframes,
651
+ items: g.items,
652
+ effects: g.effects
653
+ }), C.state.currentTime = a, C.continueAnimation());
655
654
  }
656
655
  }), this.emit("playback-started", o)), this.emit("seek-completed", o);
657
- const d = this.getChapterTimeMap().find((u) => u.chapter.name === l.name);
658
- if (d && Math.abs(r - d.duration) < 1 && // 允许1ms误差
656
+ const f = this.getChapterTimeMap().find((g) => g.chapter.name === l.name);
657
+ if (f && Math.abs(a - f.duration) < 1 && // 允许1ms误差
659
658
  e) {
660
- const u = this.state.currentScript.chapters[n + 1];
661
- u && (this.config.debug && console.log(`${this.NAME} seekToGlobalTime: auto switch to next chapter:`, u.name), yield this.playChapter(u));
659
+ const g = this.state.currentScript.chapters[n + 1];
660
+ g && (this.config.debug && console.log(`${this.NAME} seekToGlobalTime: auto switch to next chapter:`, g.name), yield this.playChapter(g));
662
661
  }
663
662
  this.config.debug;
664
663
  } catch (s) {
@@ -670,40 +669,36 @@ class Q {
670
669
  * 初始化章节用于跳转(不自动播放)
671
670
  */
672
671
  initializeChapterForSeek(t, e = 0) {
673
- return p(this, null, function* () {
672
+ return m(this, null, function* () {
674
673
  this.emitPlayingPlayersChanged();
675
674
  try {
676
675
  this.config.debug && console.log(`${this.NAME} initializing chapter for seek: ${t.name}`), this.playground.reset();
677
- const i = t.players.filter((a) => a.type === "model"), s = [];
678
- i.forEach((a) => {
679
- const n = a;
680
- n.keyframes && Array.isArray(n.keyframes) && n.keyframes.forEach((r) => {
681
- r.animation && r.animation.url && s.push(r.animation.url);
676
+ const i = t.players.filter((r) => r.type === "model"), s = [];
677
+ i.forEach((r) => {
678
+ const n = r;
679
+ n.keyframes && Array.isArray(n.keyframes) && n.keyframes.forEach((a) => {
680
+ a.animation && a.animation.url && s.push(a.animation.url);
682
681
  });
683
682
  }), s.length > 0 && (yield this.playground.loadAnimations(s)), yield Promise.all(
684
- i.map((a) => p(this, null, function* () {
685
- const n = a;
686
- let r = this.playground.getDigitalHuman(n.model, n.id);
687
- if (r || (yield this.playground.loadModels([n.model], [n.id]), r = this.playground.getDigitalHuman(n.model, n.id)), r && n.keyframes.length > 0) {
688
- r.state.currentTime = e, r.state.currentAnimation = null, r.keyframes = n.keyframes;
683
+ i.map((r) => m(this, null, function* () {
684
+ const n = r;
685
+ let a = this.playground.getDigitalHuman(n.model, n.id);
686
+ if (a || (yield this.playground.loadModels([n.model], [n.id]), a = this.playground.getDigitalHuman(n.model, n.id)), a && n.keyframes.length > 0) {
687
+ a.state.currentTime = e, a.state.currentAnimation = null, a.keyframes = n.keyframes;
689
688
  const l = n.keyframes[0];
690
- r.model.position.set(
691
- l.position[0],
692
- l.position[1],
693
- l.position[2]
694
- ), r.model.quaternion.set(
689
+ a.model.position.set(l.position[0], l.position[1], l.position[2]), a.model.quaternion.set(
695
690
  l.quaternion[0],
696
691
  l.quaternion[1],
697
692
  l.quaternion[2],
698
693
  l.quaternion[3]
699
- ), r.model.scale.set(l.scale[0], l.scale[1], l.scale[2]), r.model.visible = l.visible, r.play({
694
+ ), a.model.scale.set(l.scale[0], l.scale[1], l.scale[2]), a.model.visible = l.visible, a.play({
700
695
  keyframes: n.keyframes,
701
696
  items: n.items,
702
697
  effects: n.effects
703
- }), r.state.currentTime = e, r.continueAnimation();
698
+ }), a.state.currentTime = e, a.continueAnimation();
704
699
  }
705
700
  }))
706
- ), t.players.filter((a) => a.type === "camera").length > 0 && this.config.debug, this.config.debug;
701
+ ), t.players.filter((r) => r.type === "camera").length > 0 && this.config.debug, this.config.debug;
707
702
  } catch (i) {
708
703
  throw console.error(`${this.NAME} failed to initialize chapter for seek:`, i), i;
709
704
  }
@@ -713,7 +708,7 @@ class Q {
713
708
  * 跳转到指定百分比位置
714
709
  */
715
710
  seekToPercentage(t, e) {
716
- return p(this, null, function* () {
711
+ return m(this, null, function* () {
717
712
  const i = Math.max(0, Math.min(100, t)), o = this.getTotalDuration() * i / 100;
718
713
  this.config.debug && console.log(`${this.NAME} seeking to ${i}% (${o}ms)`), yield this.seekToGlobalTime(o, e);
719
714
  });
@@ -722,20 +717,20 @@ class Q {
722
717
  * 跳转到指定章节的指定时间
723
718
  */
724
719
  seekToChapter(t, e = 0, i) {
725
- return p(this, null, function* () {
720
+ return m(this, null, function* () {
726
721
  if (!this.state.currentScript)
727
722
  throw new Error("No script loaded");
728
723
  if (t < 0 || t >= this.state.currentScript.chapters.length)
729
724
  throw new Error("Invalid chapter index");
730
- const a = this.getChapterTimeMap()[t].startTime + Math.max(0, e);
731
- this.config.debug && console.log(`${this.NAME} seeking to chapter ${t} at ${e}ms (global: ${a}ms)`), yield this.seekToGlobalTime(a, i);
725
+ const r = this.getChapterTimeMap()[t].startTime + Math.max(0, e);
726
+ this.config.debug && console.log(`${this.NAME} seeking to chapter ${t} at ${e}ms (global: ${r}ms)`), yield this.seekToGlobalTime(r, i);
732
727
  });
733
728
  }
734
729
  /**
735
730
  * 从指定全局时间开始播放所有剩余内容
736
731
  */
737
732
  playFromGlobalTime(t) {
738
- return p(this, null, function* () {
733
+ return m(this, null, function* () {
739
734
  yield this.seekToGlobalTime(t, !0), yield this.playAllRemaining();
740
735
  });
741
736
  }
@@ -743,12 +738,12 @@ class Q {
743
738
  * 注册进度变化监听器
744
739
  */
745
740
  onProgressChanged(t) {
746
- const e = (i) => p(this, null, function* () {
747
- var r;
741
+ const e = (i) => m(this, null, function* () {
742
+ var a;
748
743
  t(i);
749
- const s = ((r = this.state.currentScript) == null ? void 0 : r.chapters) || [], o = this.state.currentChapter ? s.findIndex((l) => l.name === this.state.currentChapter.name) : -1, n = this.getChapterTimeMap().find((l) => {
750
- var m;
751
- return l.chapter.name === ((m = this.state.currentChapter) == null ? void 0 : m.name);
744
+ const s = ((a = this.state.currentScript) == null ? void 0 : a.chapters) || [], o = this.state.currentChapter ? s.findIndex((l) => l.name === this.state.currentChapter.name) : -1, n = this.getChapterTimeMap().find((l) => {
745
+ var u;
746
+ return l.chapter.name === ((u = this.state.currentChapter) == null ? void 0 : u.name);
752
747
  });
753
748
  if (this.state.playing && this.state.currentChapter && n && i.currentChapterTime >= n.duration - 10 && // 允许10ms误差,比较章节内时间
754
749
  this._autoPlayOnNaturalEnd) {
@@ -771,9 +766,7 @@ class Q {
771
766
  */
772
767
  setProgressUpdateInterval(t) {
773
768
  const e = this.progressUpdateInterval;
774
- this.progressUpdateInterval = Math.max(50, t), this.config.debug && console.log(
775
- `${this.NAME} progress update interval changed from ${e}ms to ${this.progressUpdateInterval}ms`
776
- ), this.progressUpdateTimer !== null && (this.stopProgressUpdateTimer(), this.startProgressUpdateTimer());
769
+ this.progressUpdateInterval = Math.max(50, t), this.config.debug && console.log(`${this.NAME} progress update interval changed from ${e}ms to ${this.progressUpdateInterval}ms`), this.progressUpdateTimer !== null && (this.stopProgressUpdateTimer(), this.startProgressUpdateTimer());
777
770
  }
778
771
  /**
779
772
  * 启动进度更新定时器
@@ -796,7 +789,7 @@ class Q {
796
789
  * 播放完整的所有章节(从头开始)
797
790
  */
798
791
  playAllChapters() {
799
- return p(this, null, function* () {
792
+ return m(this, null, function* () {
800
793
  if (!this.state.currentScript || this.state.currentScript.chapters.length === 0)
801
794
  throw new Error("No script or chapters loaded");
802
795
  this.config.debug, yield this.seekToGlobalTime(0, !0), yield this.playAllRemaining();
@@ -849,9 +842,7 @@ class Q {
849
842
  * 获取当前正在播放的所有player(数组)
850
843
  */
851
844
  getCurrentPlayingPlayers() {
852
- const e = this.getGlobalProgress().currentTime, s = this.getChapterTimeMap().find(
853
- (o) => e >= o.startTime && e < o.endTime
854
- );
845
+ const e = this.getGlobalProgress().currentTime, s = this.getChapterTimeMap().find((o) => e >= o.startTime && e < o.endTime);
855
846
  return s ? this.getPlayingPlayersFromChapter(s.chapter) : [];
856
847
  }
857
848
  /**