@realsee/dnalogel 3.77.4 → 3.77.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/dist/DigitalPerformancePlugin/controller/index.d.ts +224 -0
- package/dist/DigitalPerformancePlugin/core/DigitalHuman.d.ts +55 -0
- package/dist/DigitalPerformancePlugin/core/DigitalPlayground.d.ts +40 -0
- package/dist/DigitalPerformancePlugin/core/DigitalStateMachine.d.ts +150 -0
- package/dist/DigitalPerformancePlugin/core/Trace.d.ts +9 -0
- package/dist/DigitalPerformancePlugin/index.d.ts +11 -0
- package/dist/DigitalPerformancePlugin/mock.d.ts +76 -0
- package/dist/DigitalPerformancePlugin/typings/index.d.ts +79 -0
- package/dist/index.cjs.js +86 -73
- package/dist/index.d.ts +1 -0
- package/dist/index.js +12895 -11194
- package/dist/index.umd.js +88 -75
- package/libs/DigitalPerformancePlugin/controller/index.d.ts +2 -2
- package/libs/DigitalPerformancePlugin/controller/index.js +164 -173
- package/libs/DigitalPerformancePlugin/core/DigitalHuman.d.ts +16 -6
- package/libs/DigitalPerformancePlugin/core/DigitalHuman.js +128 -102
- package/libs/DigitalPerformancePlugin/core/DigitalPlayground.d.ts +11 -5
- package/libs/DigitalPerformancePlugin/core/DigitalPlayground.js +84 -74
- package/libs/DigitalPerformancePlugin/core/DigitalStateMachine.d.ts +7 -0
- package/libs/DigitalPerformancePlugin/mock.d.ts +6 -0
- package/libs/DigitalPerformancePlugin/mock.js +272 -274
- package/libs/base/BasePlugin.js +1 -1
- package/libs/index.d.ts +1 -0
- package/libs/index.js +161 -150
- package/libs/shared-utils/logger.js +1 -1
- 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 = (
|
|
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(
|
|
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(
|
|
11
|
-
return
|
|
12
|
-
}, x = (
|
|
13
|
-
var P = (
|
|
14
|
-
var
|
|
15
|
-
var o = (
|
|
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(
|
|
17
|
+
n(e.next(a));
|
|
18
18
|
} catch (l) {
|
|
19
19
|
s(l);
|
|
20
20
|
}
|
|
21
|
-
},
|
|
21
|
+
}, r = (a) => {
|
|
22
22
|
try {
|
|
23
|
-
n(e.throw(
|
|
23
|
+
n(e.throw(a));
|
|
24
24
|
} catch (l) {
|
|
25
25
|
s(l);
|
|
26
26
|
}
|
|
27
|
-
}, n = (
|
|
28
|
-
n((e = e.apply(
|
|
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
|
|
31
|
+
import { Vector3 as w } from "three";
|
|
32
32
|
import { convertMockToPlayer as z } from "../mock.js";
|
|
33
|
-
import { transformPosition as
|
|
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
|
|
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
|
|
102
|
-
const e = [], i = [], s = /* @__PURE__ */ new Set();
|
|
103
|
-
t.chapters.forEach((
|
|
104
|
-
|
|
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
|
|
107
|
-
e.push(
|
|
108
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
203
|
-
|
|
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
|
|
207
|
-
|
|
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((
|
|
210
|
-
if (
|
|
211
|
-
const n = this.playground.getDigitalHuman(
|
|
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
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
|
|
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`),
|
|
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 (
|
|
238
|
-
console.warn(`${this.NAME} [continueAllRemaining] progress stagnant for 3s, assuming chapter completed`),
|
|
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
|
-
|
|
243
|
-
setTimeout(
|
|
241
|
+
a = 0, n = (h == null ? void 0 : h.currentTime) || 0;
|
|
242
|
+
setTimeout(u, 200);
|
|
244
243
|
};
|
|
245
|
-
|
|
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
|
|
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 ${
|
|
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[
|
|
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
|
|
259
|
-
|
|
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
|
|
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 ${
|
|
264
|
+
this.config.debug && console.log(`${this.NAME} continuous playback stopped after chapter ${r + 1}`);
|
|
266
265
|
break;
|
|
267
266
|
}
|
|
268
|
-
|
|
269
|
-
} catch (
|
|
270
|
-
console.error(`${this.NAME} failed to play chapter ${n.name}:`,
|
|
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
|
|
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,
|
|
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:
|
|
302
|
+
isCompleted: r,
|
|
304
303
|
isNearHardcodedPause: o,
|
|
305
|
-
shouldContinueFromPause: !
|
|
306
|
-
}), this.emitPlayingPlayersChanged(), !
|
|
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
|
|
318
|
+
const r = t[o];
|
|
320
319
|
this.config.debug;
|
|
321
320
|
try {
|
|
322
|
-
const n = this.state.currentChapter && this.state.currentChapter.name ===
|
|
323
|
-
if (!n ||
|
|
324
|
-
const h =
|
|
325
|
-
if (
|
|
326
|
-
const
|
|
327
|
-
|
|
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: ${
|
|
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((
|
|
333
|
-
const T = this.playground.getDigitalHuman(
|
|
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: ${
|
|
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(
|
|
340
|
-
const
|
|
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 ${
|
|
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
|
|
428
|
-
|
|
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,
|
|
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
|
|
445
|
-
s.offset = { x:
|
|
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: ((
|
|
449
|
+
name: ((a = t.players[0]) == null ? void 0 : a.chapterName) || "Chapter 1",
|
|
451
450
|
players: []
|
|
452
451
|
}
|
|
453
452
|
];
|
|
454
|
-
let
|
|
455
|
-
return t.players.forEach((l,
|
|
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
|
|
458
|
+
const f = N(new w(y.x, y.y, y.z), e == null ? void 0 : e.transform);
|
|
460
459
|
return {
|
|
461
|
-
x:
|
|
462
|
-
y:
|
|
463
|
-
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
|
|
468
|
-
new
|
|
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:
|
|
474
|
-
y:
|
|
475
|
-
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
|
|
482
|
-
h.matrix[12] =
|
|
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
|
|
485
|
-
((M = l.config) == null ? void 0 : M.type) === "simultaneous" ||
|
|
486
|
-
id:
|
|
487
|
-
name: l.chapterName || `Chapter ${
|
|
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[
|
|
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),
|
|
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:
|
|
545
|
+
endTime: r,
|
|
547
546
|
chapter: i
|
|
548
|
-
}), e =
|
|
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((
|
|
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
|
|
570
|
-
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((
|
|
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
|
|
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
|
|
613
|
-
if (!
|
|
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:
|
|
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,
|
|
617
|
-
|
|
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((
|
|
625
|
-
this.state.currentScript.chapters.forEach((
|
|
626
|
-
|
|
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 =
|
|
639
|
-
const $ = c.keyframesManager.getStateByTime(
|
|
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 :
|
|
648
|
-
if (
|
|
649
|
-
const C = this.playground.getDigitalHuman(
|
|
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:
|
|
652
|
-
items:
|
|
653
|
-
effects:
|
|
654
|
-
}), C.state.currentTime =
|
|
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
|
|
658
|
-
if (
|
|
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
|
|
661
|
-
|
|
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
|
|
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((
|
|
678
|
-
i.forEach((
|
|
679
|
-
const n =
|
|
680
|
-
n.keyframes && Array.isArray(n.keyframes) && n.keyframes.forEach((
|
|
681
|
-
|
|
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((
|
|
685
|
-
const n =
|
|
686
|
-
let
|
|
687
|
-
if (
|
|
688
|
-
|
|
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
|
-
|
|
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
|
-
),
|
|
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
|
-
}),
|
|
698
|
+
}), a.state.currentTime = e, a.continueAnimation();
|
|
704
699
|
}
|
|
705
700
|
}))
|
|
706
|
-
), t.players.filter((
|
|
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
|
|
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
|
|
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
|
|
731
|
-
this.config.debug && console.log(`${this.NAME} seeking to chapter ${t} at ${e}ms (global: ${
|
|
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
|
|
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) =>
|
|
747
|
-
var
|
|
741
|
+
const e = (i) => m(this, null, function* () {
|
|
742
|
+
var a;
|
|
748
743
|
t(i);
|
|
749
|
-
const s = ((
|
|
750
|
-
var
|
|
751
|
-
return l.chapter.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
|
|
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
|
/**
|