@spatialwalk/avatarkit 1.0.0-beta.27 → 1.0.0-beta.28
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 +19 -4
- package/README.md +24 -24
- package/dist/{StreamingAudioPlayer-C6v9Ed55.js → StreamingAudioPlayer-DLwlYvg8.js} +1 -1
- package/dist/core/AvatarDownloader.d.ts +2 -2
- package/dist/core/{AvatarKit.d.ts → AvatarSDK.d.ts} +1 -1
- package/dist/{index-s9KqPWVW.js → index-ByaJBTpA.js} +863 -853
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/package.json +1 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (r, e, t) =>
|
|
4
|
-
class
|
|
1
|
+
var mn = Object.defineProperty;
|
|
2
|
+
var pn = (r, e, t) => e in r ? mn(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var u = (r, e, t) => pn(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
class gn {
|
|
5
5
|
/**
|
|
6
6
|
* 构造函数(内部使用)
|
|
7
7
|
* @param id 数字人 ID
|
|
8
8
|
* @param characterMeta 角色元数据
|
|
9
9
|
* @param resources 资源数据
|
|
10
10
|
*/
|
|
11
|
-
constructor(e, t,
|
|
11
|
+
constructor(e, t, n) {
|
|
12
12
|
u(this, "id");
|
|
13
13
|
u(this, "characterMeta");
|
|
14
14
|
u(this, "resources");
|
|
15
|
-
this.id = e, this.characterMeta = t, this.resources =
|
|
15
|
+
this.id = e, this.characterMeta = t, this.resources = n;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* 获取角色元数据(内部使用)
|
|
@@ -29,32 +29,32 @@ class pi {
|
|
|
29
29
|
return this.resources;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
var
|
|
32
|
+
var vn = /* @__PURE__ */ ((r) => (r.CAMERA = "camera", r.ANIMATION_IDLE = "frameIdle", r.MODEL_SHAPE = "shape", r.MODEL_GS = "gsStandard", r))(vn || {});
|
|
33
33
|
function ta(r) {
|
|
34
|
-
var e, t,
|
|
34
|
+
var e, t, n, i, a, s, o, l, m, c, h;
|
|
35
35
|
return {
|
|
36
36
|
camera: ((t = (e = r.camera) == null ? void 0 : e.resource) == null ? void 0 : t.remote) || null,
|
|
37
|
-
frameIdle: ((a = (
|
|
37
|
+
frameIdle: ((a = (i = (n = r.animations) == null ? void 0 : n.frameIdle) == null ? void 0 : i.resource) == null ? void 0 : a.remote) || null,
|
|
38
38
|
shape: ((l = (o = (s = r.models) == null ? void 0 : s.shape) == null ? void 0 : o.resource) == null ? void 0 : l.remote) || null,
|
|
39
39
|
gsStandard: ((h = (c = (m = r.models) == null ? void 0 : m.gsStandard) == null ? void 0 : c.resource) == null ? void 0 : h.remote) || null
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
var se = /* @__PURE__ */ ((r) => (r.cn = "cn", r.intl = "intl", r.test = "test", r))(se || {}), Y = /* @__PURE__ */ ((r) => (r.sdk = "sdk", r.host = "host", r))(Y || {}), Ce = /* @__PURE__ */ ((r) => (r.off = "off", r.error = "error", r.warning = "warning", r.all = "all", r))(Ce || {}), me = /* @__PURE__ */ ((r) => (r.downloading = "downloading", r.completed = "completed", r.failed = "failed", r))(me || {}),
|
|
42
|
+
var se = /* @__PURE__ */ ((r) => (r.cn = "cn", r.intl = "intl", r.test = "test", r))(se || {}), Y = /* @__PURE__ */ ((r) => (r.sdk = "sdk", r.host = "host", r))(Y || {}), Ce = /* @__PURE__ */ ((r) => (r.off = "off", r.error = "error", r.warning = "warning", r.all = "all", r))(Ce || {}), me = /* @__PURE__ */ ((r) => (r.downloading = "downloading", r.completed = "completed", r.failed = "failed", r))(me || {}), ie = /* @__PURE__ */ ((r) => (r.disconnected = "disconnected", r.connecting = "connecting", r.connected = "connected", r.failed = "failed", r))(ie || {}), de = /* @__PURE__ */ ((r) => (r.idle = "idle", r.playing = "playing", r))(de || {}), x = /* @__PURE__ */ ((r) => (r.idle = "idle", r.active = "active", r.playing = "playing", r.paused = "paused", r))(x || {}), yn = /* @__PURE__ */ ((r) => (r.appIDUnrecognized = "appIDUnrecognized", r.sessionTokenInvalid = "sessionTokenInvalid", r.sessionTokenExpired = "sessionTokenExpired", r.failedToFetchAvatarMetadata = "failedToFetchAvatarMetadata", r.failedToDownloadAvatarAssets = "failedToDownloadAvatarAssets", r))(yn || {});
|
|
43
43
|
class X extends Error {
|
|
44
44
|
constructor(e, t) {
|
|
45
45
|
super(e), this.code = t, this.name = "SPAvatarError";
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function wn() {
|
|
49
49
|
return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).get("debug") === "1";
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
return
|
|
51
|
+
function Sn() {
|
|
52
|
+
return wn();
|
|
53
53
|
}
|
|
54
54
|
const M = {
|
|
55
55
|
// Dynamic debug mode check (includes URL parameter)
|
|
56
56
|
get debug() {
|
|
57
|
-
return
|
|
57
|
+
return Sn();
|
|
58
58
|
},
|
|
59
59
|
camera: {
|
|
60
60
|
position: [-0.02, -0.013, 1.5],
|
|
@@ -110,22 +110,22 @@ function vt(r) {
|
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
112
|
var Qt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
113
|
-
function
|
|
113
|
+
function bn(r) {
|
|
114
114
|
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
115
115
|
}
|
|
116
116
|
var er = { exports: {} }, Ue = { exports: {} }, yt;
|
|
117
|
-
function
|
|
117
|
+
function An() {
|
|
118
118
|
return yt || (yt = 1, function(r, e) {
|
|
119
|
-
(function(t,
|
|
120
|
-
r.exports =
|
|
119
|
+
(function(t, n) {
|
|
120
|
+
r.exports = n();
|
|
121
121
|
})(Qt, function() {
|
|
122
122
|
function t(w) {
|
|
123
123
|
return !isNaN(parseFloat(w)) && isFinite(w);
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function n(w) {
|
|
126
126
|
return w.charAt(0).toUpperCase() + w.substring(1);
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function i(w) {
|
|
129
129
|
return function() {
|
|
130
130
|
return this[w];
|
|
131
131
|
};
|
|
@@ -134,7 +134,7 @@ function bi() {
|
|
|
134
134
|
function h(w) {
|
|
135
135
|
if (w)
|
|
136
136
|
for (var b = 0; b < c.length; b++)
|
|
137
|
-
w[c[b]] !== void 0 && this["set" +
|
|
137
|
+
w[c[b]] !== void 0 && this["set" + n(c[b])](w[c[b]]);
|
|
138
138
|
}
|
|
139
139
|
h.prototype = {
|
|
140
140
|
getArgs: function() {
|
|
@@ -173,13 +173,13 @@ function bi() {
|
|
|
173
173
|
});
|
|
174
174
|
};
|
|
175
175
|
for (var p = 0; p < a.length; p++)
|
|
176
|
-
h.prototype["get" +
|
|
176
|
+
h.prototype["get" + n(a[p])] = i(a[p]), h.prototype["set" + n(a[p])] = /* @__PURE__ */ function(w) {
|
|
177
177
|
return function(b) {
|
|
178
178
|
this[w] = !!b;
|
|
179
179
|
};
|
|
180
180
|
}(a[p]);
|
|
181
181
|
for (var v = 0; v < s.length; v++)
|
|
182
|
-
h.prototype["get" +
|
|
182
|
+
h.prototype["get" + n(s[v])] = i(s[v]), h.prototype["set" + n(s[v])] = /* @__PURE__ */ function(w) {
|
|
183
183
|
return function(b) {
|
|
184
184
|
if (!t(b))
|
|
185
185
|
throw new TypeError(w + " must be a Number");
|
|
@@ -187,7 +187,7 @@ function bi() {
|
|
|
187
187
|
};
|
|
188
188
|
}(s[v]);
|
|
189
189
|
for (var S = 0; S < o.length; S++)
|
|
190
|
-
h.prototype["get" +
|
|
190
|
+
h.prototype["get" + n(o[S])] = i(o[S]), h.prototype["set" + n(o[S])] = /* @__PURE__ */ function(w) {
|
|
191
191
|
return function(b) {
|
|
192
192
|
this[w] = String(b);
|
|
193
193
|
};
|
|
@@ -197,10 +197,10 @@ function bi() {
|
|
|
197
197
|
}(Ue)), Ue.exports;
|
|
198
198
|
}
|
|
199
199
|
(function(r, e) {
|
|
200
|
-
(function(t,
|
|
201
|
-
r.exports =
|
|
202
|
-
})(Qt, function(
|
|
203
|
-
var
|
|
200
|
+
(function(t, n) {
|
|
201
|
+
r.exports = n(An());
|
|
202
|
+
})(Qt, function(n) {
|
|
203
|
+
var i = /(^|@)\S+:\d+/, a = /^\s*at .*(\S+:\d+|\(native\))/m, s = /^(eval@)?(\[native code])?$/;
|
|
204
204
|
return {
|
|
205
205
|
/**
|
|
206
206
|
* Given an Error object, extract the most information from it.
|
|
@@ -234,7 +234,7 @@ function bi() {
|
|
|
234
234
|
var h = c.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, ""), p = h.match(/ (\(.+\)$)/);
|
|
235
235
|
h = p ? h.replace(p[0], "") : h;
|
|
236
236
|
var v = this.extractLocation(p ? p[1] : h), S = p && h || void 0, w = ["eval", "<anonymous>"].indexOf(v[0]) > -1 ? void 0 : v[0];
|
|
237
|
-
return new
|
|
237
|
+
return new n({
|
|
238
238
|
functionName: S,
|
|
239
239
|
fileName: w,
|
|
240
240
|
lineNumber: v[1],
|
|
@@ -250,11 +250,11 @@ function bi() {
|
|
|
250
250
|
}, this);
|
|
251
251
|
return m.map(function(c) {
|
|
252
252
|
if (c.indexOf(" > eval") > -1 && (c = c.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1")), c.indexOf("@") === -1 && c.indexOf(":") === -1)
|
|
253
|
-
return new
|
|
253
|
+
return new n({
|
|
254
254
|
functionName: c
|
|
255
255
|
});
|
|
256
256
|
var h = /((.*".+"[^@]*)?[^@]*)(?:@)/, p = c.match(h), v = p && p[1] ? p[1] : void 0, S = this.extractLocation(c.replace(h, ""));
|
|
257
|
-
return new
|
|
257
|
+
return new n({
|
|
258
258
|
functionName: v,
|
|
259
259
|
fileName: S[0],
|
|
260
260
|
lineNumber: S[1],
|
|
@@ -273,7 +273,7 @@ function bi() {
|
|
|
273
273
|
for (var m = /Line (\d+).*script (?:in )?(\S+)/i, c = l.message.split(`
|
|
274
274
|
`), h = [], p = 2, v = c.length; p < v; p += 2) {
|
|
275
275
|
var S = m.exec(c[p]);
|
|
276
|
-
S && h.push(new
|
|
276
|
+
S && h.push(new n({
|
|
277
277
|
fileName: S[2],
|
|
278
278
|
lineNumber: S[1],
|
|
279
279
|
source: c[p]
|
|
@@ -286,7 +286,7 @@ function bi() {
|
|
|
286
286
|
`), h = [], p = 0, v = c.length; p < v; p += 2) {
|
|
287
287
|
var S = m.exec(c[p]);
|
|
288
288
|
S && h.push(
|
|
289
|
-
new
|
|
289
|
+
new n({
|
|
290
290
|
functionName: S[3] || void 0,
|
|
291
291
|
fileName: S[2],
|
|
292
292
|
lineNumber: S[1],
|
|
@@ -300,13 +300,13 @@ function bi() {
|
|
|
300
300
|
parseOpera11: function(l) {
|
|
301
301
|
var m = l.stack.split(`
|
|
302
302
|
`).filter(function(c) {
|
|
303
|
-
return !!c.match(
|
|
303
|
+
return !!c.match(i) && !c.match(/^Error created at/);
|
|
304
304
|
}, this);
|
|
305
305
|
return m.map(function(c) {
|
|
306
306
|
var h = c.split("@"), p = this.extractLocation(h.pop()), v = h.shift() || "", S = v.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0, w;
|
|
307
307
|
v.match(/\(([^)]*)\)/) && (w = v.replace(/^[^(]+\(([^)]*)\)$/, "$1"));
|
|
308
308
|
var b = w === void 0 || w === "[arguments not available]" ? void 0 : w.split(",");
|
|
309
|
-
return new
|
|
309
|
+
return new n({
|
|
310
310
|
functionName: S,
|
|
311
311
|
args: b,
|
|
312
312
|
fileName: p[0],
|
|
@@ -319,17 +319,17 @@ function bi() {
|
|
|
319
319
|
};
|
|
320
320
|
});
|
|
321
321
|
})(er);
|
|
322
|
-
var
|
|
323
|
-
const
|
|
322
|
+
var Cn = er.exports;
|
|
323
|
+
const _n = /* @__PURE__ */ bn(Cn);
|
|
324
324
|
let wt = () => {
|
|
325
325
|
var r = (() => {
|
|
326
|
-
var e = Object.defineProperty, t = Object.getOwnPropertyDescriptor,
|
|
326
|
+
var e = Object.defineProperty, t = Object.getOwnPropertyDescriptor, n = Object.getOwnPropertyNames, i = Object.prototype.hasOwnProperty, a = (f, g) => {
|
|
327
327
|
for (var y in g) e(f, y, { get: g[y], enumerable: !0 });
|
|
328
328
|
}, s = (f, g, y, A) => {
|
|
329
|
-
if (g && typeof g == "object" || typeof g == "function") for (let I of
|
|
329
|
+
if (g && typeof g == "object" || typeof g == "function") for (let I of n(g)) !i.call(f, I) && I !== y && e(f, I, { get: () => g[I], enumerable: !(A = t(g, I)) || A.enumerable });
|
|
330
330
|
return f;
|
|
331
331
|
}, o = (f) => s(e({}, "__esModule", { value: !0 }), f), l = {};
|
|
332
|
-
a(l, { default: () =>
|
|
332
|
+
a(l, { default: () => hn });
|
|
333
333
|
var m = (f) => Array.isArray(f), c = (f) => typeof f == "function", h = (f) => f.length === 0, p = (f) => typeof f == "number", v = (f) => typeof f == "object" && f !== null, S = (f) => f instanceof RegExp, w = (f) => typeof f == "string", b = (f) => f === void 0, P = (f) => {
|
|
334
334
|
const g = /* @__PURE__ */ new Map();
|
|
335
335
|
return (y) => {
|
|
@@ -428,8 +428,8 @@ let wt = () => {
|
|
|
428
428
|
if (y(I)) {
|
|
429
429
|
const pt = I.index, gt = I.output.length;
|
|
430
430
|
if (gt > mt) {
|
|
431
|
-
const
|
|
432
|
-
q.set(B, { index: pt, output:
|
|
431
|
+
const fn = I.output.slice(mt, gt);
|
|
432
|
+
q.set(B, { index: pt, output: fn });
|
|
433
433
|
} else q.set(B, pt);
|
|
434
434
|
return !0;
|
|
435
435
|
} else return q.set(B, !1), !1;
|
|
@@ -452,7 +452,7 @@ let wt = () => {
|
|
|
452
452
|
g = rt[y] + g, f = Math.floor((f - 1) / 26);
|
|
453
453
|
}
|
|
454
454
|
return g;
|
|
455
|
-
},
|
|
455
|
+
}, nt = (f) => {
|
|
456
456
|
let g = 0;
|
|
457
457
|
for (let y = 0, A = f.length; y < A; y++) g = g * 26 + rt.indexOf(f[y]) + 1;
|
|
458
458
|
return g;
|
|
@@ -461,56 +461,56 @@ let wt = () => {
|
|
|
461
461
|
const y = [];
|
|
462
462
|
for (; f <= g; ) y.push(f++);
|
|
463
463
|
return y;
|
|
464
|
-
}, vr = (f, g, y) => Be(f, g).map((A) => String(A).padStart(y, "0")),
|
|
464
|
+
}, vr = (f, g, y) => Be(f, g).map((A) => String(A).padStart(y, "0")), it = (f, g) => Be(nt(f), nt(g)).map(gr), Q = (f) => f, at = (f) => yr((g) => O(g, f, { memoization: !1 }).join("")), yr = (f) => {
|
|
465
465
|
const g = {};
|
|
466
466
|
return (y) => g[y] ?? (g[y] = f(y));
|
|
467
|
-
}, wr = _(/^\*\*\/\*$/, ".*"), Sr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (f, g, y) => `.*${g ? "" : "(?:^|/)"}${y.replaceAll(".", "\\.")}`), br = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (f, g, y, A) => `.*${g ? "" : "(?:^|/)"}${y.replaceAll(".", "\\.")}(?:${A.replaceAll(",", "|").replaceAll(".", "\\.")})`), Oe = _(/\\./, Q), Ar = _(/[$.*+?^(){}[\]\|]/, (f) => `\\${f}`), Cr = _(/./, Q), _r = _(/^(?:!!)*!(.*)$/, (f, g) => `(?!^${ht(g)}$).*?`), Ir = _(/^(!!)+/, ""), Pr = J([_r, Ir]), Er = _(/\/(\*\*\/)+/, "(?:/.+/|/)"), kr = _(/^(\*\*\/)+/, "(?:^|.*/)"), xr = _(/\/(\*\*)$/, "(?:/.*|$)"), Fr = _(/\*\*/, ".*"), st = J([Er, kr, xr, Fr]), Mr = _(/\*\/(?!\*\*\/)/, "[^/]*/"), Tr = _(/\*/, "[^/]*"), ot = J([Mr, Tr]), lt = _("?", "[^/]"), Lr = _("[", Q), Rr = _("]", Q), Dr = _(/[!^]/, "^/"), Br = _(/[a-z]-[a-z]|[0-9]-[0-9]/i, Q), Or = _(/[$.*+?^(){}[\|]/, (f) => `\\${f}`), Nr = _(/[^\]]/, Q), Ur = J([Oe, Or, Br, Nr]), ct = G([Lr, j(Dr), te(Ur), Rr]), Vr = _("{", "(?:"), zr = _("}", ")"), $r = _(/(\d+)\.\.(\d+)/, (f, g, y) => vr(+g, +y, Math.min(g.length, y.length)).join("|")), Wr = _(/([a-z]+)\.\.([a-z]+)/, (f, g, y) =>
|
|
467
|
+
}, wr = _(/^\*\*\/\*$/, ".*"), Sr = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (f, g, y) => `.*${g ? "" : "(?:^|/)"}${y.replaceAll(".", "\\.")}`), br = _(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (f, g, y, A) => `.*${g ? "" : "(?:^|/)"}${y.replaceAll(".", "\\.")}(?:${A.replaceAll(",", "|").replaceAll(".", "\\.")})`), Oe = _(/\\./, Q), Ar = _(/[$.*+?^(){}[\]\|]/, (f) => `\\${f}`), Cr = _(/./, Q), _r = _(/^(?:!!)*!(.*)$/, (f, g) => `(?!^${ht(g)}$).*?`), Ir = _(/^(!!)+/, ""), Pr = J([_r, Ir]), Er = _(/\/(\*\*\/)+/, "(?:/.+/|/)"), kr = _(/^(\*\*\/)+/, "(?:^|.*/)"), xr = _(/\/(\*\*)$/, "(?:/.*|$)"), Fr = _(/\*\*/, ".*"), st = J([Er, kr, xr, Fr]), Mr = _(/\*\/(?!\*\*\/)/, "[^/]*/"), Tr = _(/\*/, "[^/]*"), ot = J([Mr, Tr]), lt = _("?", "[^/]"), Lr = _("[", Q), Rr = _("]", Q), Dr = _(/[!^]/, "^/"), Br = _(/[a-z]-[a-z]|[0-9]-[0-9]/i, Q), Or = _(/[$.*+?^(){}[\|]/, (f) => `\\${f}`), Nr = _(/[^\]]/, Q), Ur = J([Oe, Or, Br, Nr]), ct = G([Lr, j(Dr), te(Ur), Rr]), Vr = _("{", "(?:"), zr = _("}", ")"), $r = _(/(\d+)\.\.(\d+)/, (f, g, y) => vr(+g, +y, Math.min(g.length, y.length)).join("|")), Wr = _(/([a-z]+)\.\.([a-z]+)/, (f, g, y) => it(g, y).join("|")), Gr = _(/([A-Z]+)\.\.([A-Z]+)/, (f, g, y) => it(g.toLowerCase(), y.toLowerCase()).join("|").toUpperCase()), qr = J([$r, Wr, Gr]), dt = G([Vr, qr, zr]), Hr = _("{", "(?:"), jr = _("}", ")"), Kr = _(",", "|"), Yr = _(/[$.*+?^(){[\]\|]/, (f) => `\\${f}`), Xr = _(/[^}]/, Q), Zr = tt(() => ut), Jr = J([st, ot, lt, ct, dt, Zr, Oe, Yr, Kr, Xr]), ut = G([Hr, te(Jr), jr]), Qr = te(J([wr, Sr, br, Pr, st, ot, lt, ct, dt, ut, Oe, Ar, Cr])), en = Qr, tn = at(en), ht = tn, rn = _(/\\./, Q), nn = _(/./, Q), an = _(/\*\*\*+/, "*"), sn = _(/([^/{[(!])\*\*/, (f, g) => `${g}*`), on = _(/(^|.)\*\*(?=[^*/)\]}])/, (f, g) => `${g}*`), ln = te(J([rn, an, sn, on, nn])), cn = ln, dn = at(cn), un = dn, Ne = (f, g) => {
|
|
468
468
|
const y = Array.isArray(f) ? f : [f];
|
|
469
469
|
if (!y.length) return !1;
|
|
470
470
|
const A = y.map(Ne.compile), I = y.every((B) => /(\/(?:\*\*)?|\[\/\])$/.test(B)), F = g.replace(/[\\\/]+/g, "/").replace(/\/$/, I ? "/" : "");
|
|
471
471
|
return A.some((B) => B.test(F));
|
|
472
472
|
};
|
|
473
|
-
Ne.compile = (f) => new RegExp(`^${ht(
|
|
474
|
-
var
|
|
473
|
+
Ne.compile = (f) => new RegExp(`^${ht(un(f))}$`, "s");
|
|
474
|
+
var hn = Ne;
|
|
475
475
|
return o(l);
|
|
476
476
|
})();
|
|
477
477
|
return r.default || r;
|
|
478
478
|
}, Ve;
|
|
479
|
-
const
|
|
479
|
+
const In = (r, e) => (Ve || (Ve = wt(), wt = null), Ve(r, e)), Pn = /^[A-Za-z]:\//;
|
|
480
480
|
function he(r = "") {
|
|
481
|
-
return r && r.replace(/\\/g, "/").replace(
|
|
481
|
+
return r && r.replace(/\\/g, "/").replace(Pn, (e) => e.toUpperCase());
|
|
482
482
|
}
|
|
483
|
-
const
|
|
483
|
+
const En = /^[/\\]{2}/, kn = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, tr = /^[A-Za-z]:$/, St = /^\/([A-Za-z]:)?$/, xn = /.(\.[^./]+|\.)$/, Fn = /^[/\\]|^[a-zA-Z]:[/\\]/, Mn = "/", Xe = function(r) {
|
|
484
484
|
if (r.length === 0)
|
|
485
485
|
return ".";
|
|
486
486
|
r = he(r);
|
|
487
|
-
const e = r.match(
|
|
488
|
-
return r = Ze(r, !t), r.length === 0 ? t ? "/" :
|
|
489
|
-
},
|
|
487
|
+
const e = r.match(En), t = Se(r), n = r[r.length - 1] === "/";
|
|
488
|
+
return r = Ze(r, !t), r.length === 0 ? t ? "/" : n ? "./" : "." : (n && (r += "/"), tr.test(r) && (r += "/"), e ? t ? `//${r}` : `//./${r}` : t && !Se(r) ? `/${r}` : r);
|
|
489
|
+
}, Tn = function(...r) {
|
|
490
490
|
let e = "";
|
|
491
491
|
for (const t of r)
|
|
492
492
|
if (t)
|
|
493
493
|
if (e.length > 0) {
|
|
494
|
-
const
|
|
495
|
-
|
|
494
|
+
const n = e[e.length - 1] === "/", i = t[0] === "/";
|
|
495
|
+
n && i ? e += t.slice(1) : e += n || i ? t : `/${t}`;
|
|
496
496
|
} else
|
|
497
497
|
e += t;
|
|
498
498
|
return Xe(e);
|
|
499
499
|
};
|
|
500
|
-
function
|
|
500
|
+
function Ln() {
|
|
501
501
|
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
|
|
502
502
|
}
|
|
503
503
|
const Te = function(...r) {
|
|
504
|
-
r = r.map((
|
|
504
|
+
r = r.map((n) => he(n));
|
|
505
505
|
let e = "", t = !1;
|
|
506
|
-
for (let
|
|
507
|
-
const
|
|
508
|
-
!
|
|
506
|
+
for (let n = r.length - 1; n >= -1 && !t; n--) {
|
|
507
|
+
const i = n >= 0 ? r[n] : Ln();
|
|
508
|
+
!i || i.length === 0 || (e = `${i}/${e}`, t = Se(i));
|
|
509
509
|
}
|
|
510
510
|
return e = Ze(e, !t), t && !Se(e) ? `/${e}` : e.length > 0 ? e : ".";
|
|
511
511
|
};
|
|
512
512
|
function Ze(r, e) {
|
|
513
|
-
let t = "",
|
|
513
|
+
let t = "", n = 0, i = -1, a = 0, s = null;
|
|
514
514
|
for (let o = 0; o <= r.length; ++o) {
|
|
515
515
|
if (o < r.length)
|
|
516
516
|
s = r[o];
|
|
@@ -520,112 +520,112 @@ function Ze(r, e) {
|
|
|
520
520
|
s = "/";
|
|
521
521
|
}
|
|
522
522
|
if (s === "/") {
|
|
523
|
-
if (!(
|
|
524
|
-
if (t.length < 2 ||
|
|
523
|
+
if (!(i === o - 1 || a === 1)) if (a === 2) {
|
|
524
|
+
if (t.length < 2 || n !== 2 || t[t.length - 1] !== "." || t[t.length - 2] !== ".") {
|
|
525
525
|
if (t.length > 2) {
|
|
526
526
|
const l = t.lastIndexOf("/");
|
|
527
|
-
l === -1 ? (t = "",
|
|
527
|
+
l === -1 ? (t = "", n = 0) : (t = t.slice(0, l), n = t.length - 1 - t.lastIndexOf("/")), i = o, a = 0;
|
|
528
528
|
continue;
|
|
529
529
|
} else if (t.length > 0) {
|
|
530
|
-
t = "",
|
|
530
|
+
t = "", n = 0, i = o, a = 0;
|
|
531
531
|
continue;
|
|
532
532
|
}
|
|
533
533
|
}
|
|
534
|
-
e && (t += t.length > 0 ? "/.." : "..",
|
|
534
|
+
e && (t += t.length > 0 ? "/.." : "..", n = 2);
|
|
535
535
|
} else
|
|
536
|
-
t.length > 0 ? t += `/${r.slice(
|
|
537
|
-
|
|
536
|
+
t.length > 0 ? t += `/${r.slice(i + 1, o)}` : t = r.slice(i + 1, o), n = o - i - 1;
|
|
537
|
+
i = o, a = 0;
|
|
538
538
|
} else s === "." && a !== -1 ? ++a : a = -1;
|
|
539
539
|
}
|
|
540
540
|
return t;
|
|
541
541
|
}
|
|
542
542
|
const Se = function(r) {
|
|
543
|
-
return
|
|
544
|
-
},
|
|
543
|
+
return kn.test(r);
|
|
544
|
+
}, Rn = function(r) {
|
|
545
545
|
return he(r);
|
|
546
546
|
}, rr = function(r) {
|
|
547
547
|
if (r === "..") return "";
|
|
548
|
-
const e =
|
|
548
|
+
const e = xn.exec(he(r));
|
|
549
549
|
return e && e[1] || "";
|
|
550
|
-
},
|
|
551
|
-
const t = Te(r).replace(St, "$1").split("/"),
|
|
552
|
-
if (
|
|
553
|
-
return
|
|
554
|
-
const
|
|
555
|
-
for (const a of
|
|
556
|
-
if (
|
|
550
|
+
}, Dn = function(r, e) {
|
|
551
|
+
const t = Te(r).replace(St, "$1").split("/"), n = Te(e).replace(St, "$1").split("/");
|
|
552
|
+
if (n[0][1] === ":" && t[0][1] === ":" && t[0] !== n[0])
|
|
553
|
+
return n.join("/");
|
|
554
|
+
const i = [...t];
|
|
555
|
+
for (const a of i) {
|
|
556
|
+
if (n[0] !== a)
|
|
557
557
|
break;
|
|
558
|
-
t.shift(),
|
|
558
|
+
t.shift(), n.shift();
|
|
559
559
|
}
|
|
560
|
-
return [...t.map(() => ".."), ...
|
|
561
|
-
},
|
|
560
|
+
return [...t.map(() => ".."), ...n].join("/");
|
|
561
|
+
}, nr = function(r) {
|
|
562
562
|
const e = he(r).replace(/\/$/, "").split("/").slice(0, -1);
|
|
563
563
|
return e.length === 1 && tr.test(e[0]) && (e[0] += "/"), e.join("/") || (Se(r) ? "/" : ".");
|
|
564
|
-
},
|
|
564
|
+
}, Bn = function(r) {
|
|
565
565
|
const e = r.ext ? r.ext.startsWith(".") ? r.ext : `.${r.ext}` : "", t = [r.root, r.dir, r.base ?? (r.name ?? "") + e].filter(
|
|
566
566
|
Boolean
|
|
567
567
|
);
|
|
568
568
|
return he(
|
|
569
569
|
r.root ? Te(...t) : t.join("/")
|
|
570
570
|
);
|
|
571
|
-
},
|
|
571
|
+
}, ir = function(r, e) {
|
|
572
572
|
const t = he(r).split("/");
|
|
573
|
-
let
|
|
574
|
-
for (let
|
|
575
|
-
const a = t[
|
|
573
|
+
let n = "";
|
|
574
|
+
for (let i = t.length - 1; i >= 0; i--) {
|
|
575
|
+
const a = t[i];
|
|
576
576
|
if (a) {
|
|
577
|
-
|
|
577
|
+
n = a;
|
|
578
578
|
break;
|
|
579
579
|
}
|
|
580
580
|
}
|
|
581
|
-
return e &&
|
|
582
|
-
},
|
|
583
|
-
var
|
|
584
|
-
const e = ((a = (
|
|
581
|
+
return e && n.endsWith(e) ? n.slice(0, -e.length) : n;
|
|
582
|
+
}, On = function(r) {
|
|
583
|
+
var i, a;
|
|
584
|
+
const e = ((a = (i = Fn.exec(r)) == null ? void 0 : i[0]) == null ? void 0 : a.replace(/\\/g, "/")) || "", t = ir(r), n = rr(t);
|
|
585
585
|
return {
|
|
586
586
|
root: e,
|
|
587
|
-
dir:
|
|
587
|
+
dir: nr(r),
|
|
588
588
|
base: t,
|
|
589
|
-
ext:
|
|
590
|
-
name: t.slice(0, t.length -
|
|
589
|
+
ext: n,
|
|
590
|
+
name: t.slice(0, t.length - n.length)
|
|
591
591
|
};
|
|
592
|
-
},
|
|
592
|
+
}, Nn = (r, e) => In(e, Xe(r)), bt = {
|
|
593
593
|
__proto__: null,
|
|
594
|
-
basename:
|
|
595
|
-
dirname:
|
|
594
|
+
basename: ir,
|
|
595
|
+
dirname: nr,
|
|
596
596
|
extname: rr,
|
|
597
|
-
format:
|
|
597
|
+
format: Bn,
|
|
598
598
|
isAbsolute: Se,
|
|
599
|
-
join:
|
|
600
|
-
matchesGlob:
|
|
599
|
+
join: Tn,
|
|
600
|
+
matchesGlob: Nn,
|
|
601
601
|
normalize: Xe,
|
|
602
602
|
normalizeString: Ze,
|
|
603
|
-
parse:
|
|
604
|
-
relative:
|
|
603
|
+
parse: On,
|
|
604
|
+
relative: Dn,
|
|
605
605
|
resolve: Te,
|
|
606
|
-
sep:
|
|
607
|
-
toNamespacedPath:
|
|
608
|
-
},
|
|
606
|
+
sep: Mn,
|
|
607
|
+
toNamespacedPath: Rn
|
|
608
|
+
}, Un = /* @__PURE__ */ (() => {
|
|
609
609
|
var r;
|
|
610
610
|
return ((r = globalThis.process) == null ? void 0 : r.platform) === "win32" ? ";" : ":";
|
|
611
|
-
})(),
|
|
611
|
+
})(), Vn = { posix: void 0, win32: void 0 }, ar = (r = Un) => new Proxy(bt, {
|
|
612
612
|
get(e, t) {
|
|
613
|
-
return t === "delimiter" ? r : t === "posix" ? He : t === "win32" ?
|
|
613
|
+
return t === "delimiter" ? r : t === "posix" ? He : t === "win32" ? zn : Vn[t] || bt[t];
|
|
614
614
|
}
|
|
615
|
-
}), He = /* @__PURE__ */ ar(":"),
|
|
615
|
+
}), He = /* @__PURE__ */ ar(":"), zn = /* @__PURE__ */ ar(";");
|
|
616
616
|
var E = /* @__PURE__ */ ((r) => (r[r.Error = 0] = "Error", r[r.Warning = 1] = "Warning", r[r.Log = 2] = "Log", r[r.Verbose = 3] = "Verbose", r[r.Debug = 4] = "Debug", r))(E || {}), T = /* @__PURE__ */ ((r) => (r.Error = "error", r.Warning = "warn", r.Log = "log", r.Verbose = "verbose", r.Debug = "debug", r))(T || {}), oe = /* @__PURE__ */ ((r) => (r.JSON = "json", r.Pretty = "pretty", r))(oe || {});
|
|
617
|
-
const
|
|
617
|
+
const $n = !0;
|
|
618
618
|
function R(r, e, t = r) {
|
|
619
|
-
return (
|
|
620
|
-
const
|
|
621
|
-
return ~a ? r + sr(
|
|
619
|
+
return (n) => {
|
|
620
|
+
const i = `${n}`, a = i.indexOf(e, r.length);
|
|
621
|
+
return ~a ? r + sr(i, e, t, a) + e : r + i + e;
|
|
622
622
|
};
|
|
623
623
|
}
|
|
624
|
-
function sr(r, e, t,
|
|
625
|
-
const
|
|
626
|
-
return ~s ?
|
|
624
|
+
function sr(r, e, t, n) {
|
|
625
|
+
const i = r.substring(0, n) + t, a = r.substring(n + e.length), s = a.indexOf(e);
|
|
626
|
+
return ~s ? i + sr(a, e, t, s) : i + a;
|
|
627
627
|
}
|
|
628
|
-
function
|
|
628
|
+
function Wn(r = $n) {
|
|
629
629
|
return {
|
|
630
630
|
isColorSupported: r,
|
|
631
631
|
reset: r ? (e) => `\x1B[0m${e}\x1B[0m` : String,
|
|
@@ -655,13 +655,13 @@ function $i(r = zi) {
|
|
|
655
655
|
bgWhite: r ? R("\x1B[47m", "\x1B[49m") : String
|
|
656
656
|
};
|
|
657
657
|
}
|
|
658
|
-
const U =
|
|
658
|
+
const U = Wn(), je = {
|
|
659
659
|
[T.Error]: E.Error,
|
|
660
660
|
[T.Warning]: E.Warning,
|
|
661
661
|
[T.Log]: E.Log,
|
|
662
662
|
[T.Verbose]: E.Verbose,
|
|
663
663
|
[T.Debug]: E.Debug
|
|
664
|
-
},
|
|
664
|
+
}, Gn = {
|
|
665
665
|
[E.Error]: T.Error,
|
|
666
666
|
[E.Warning]: T.Warning,
|
|
667
667
|
[E.Log]: T.Log,
|
|
@@ -673,7 +673,7 @@ const U = $i(), je = {
|
|
|
673
673
|
T.Log,
|
|
674
674
|
T.Verbose,
|
|
675
675
|
T.Debug
|
|
676
|
-
],
|
|
676
|
+
], qn = {
|
|
677
677
|
[E.Error]: U.red,
|
|
678
678
|
[E.Warning]: U.yellow,
|
|
679
679
|
[E.Log]: U.blue,
|
|
@@ -686,7 +686,7 @@ const U = $i(), je = {
|
|
|
686
686
|
E.Verbose,
|
|
687
687
|
E.Debug
|
|
688
688
|
], Ct = [oe.JSON, oe.Pretty];
|
|
689
|
-
function
|
|
689
|
+
function Hn(r) {
|
|
690
690
|
return r.stack == null ? [] : r.stack.split(`
|
|
691
691
|
`).map((e) => e.trim()).slice(1).filter((e) => !!/^at (.*)( \(.*:(\d+):(\d+)\))|at (.*)(:(\d+):(\d+))/i.exec(e)).map((e) => {
|
|
692
692
|
const t = /at (.*)( \((.*):(\d+):(\d+)\))|at (.*)(:(\d+):(\d+))/i.exec(e);
|
|
@@ -712,21 +712,21 @@ function qi(r) {
|
|
|
712
712
|
function or(r) {
|
|
713
713
|
return r == null ? !1 : r instanceof Error;
|
|
714
714
|
}
|
|
715
|
-
function lr(r, e, t,
|
|
715
|
+
function lr(r, e, t, n, i) {
|
|
716
716
|
let a = { context: "" };
|
|
717
717
|
typeof t < "u" && t !== null && (a = { ...t }), typeof e < "u" && e !== null && (a.context = e);
|
|
718
718
|
const s = /* @__PURE__ */ new Date();
|
|
719
719
|
return {
|
|
720
720
|
"@timestamp": s.getTime(),
|
|
721
|
-
"@localetime":
|
|
721
|
+
"@localetime": i ? i(s) : s.toISOString(),
|
|
722
722
|
level: r,
|
|
723
723
|
fields: a,
|
|
724
|
-
message:
|
|
724
|
+
message: n
|
|
725
725
|
};
|
|
726
726
|
}
|
|
727
|
-
function
|
|
728
|
-
const s = lr(r, e, t,
|
|
729
|
-
return typeof
|
|
727
|
+
function jn(r, e, t, n, i, a) {
|
|
728
|
+
const s = lr(r, e, t, n, a);
|
|
729
|
+
return typeof i < "u" && i !== null && (s.errored = !0, s.error = { stack: i }), s;
|
|
730
730
|
}
|
|
731
731
|
function _t(r) {
|
|
732
732
|
let e = "";
|
|
@@ -752,15 +752,15 @@ function _t(r) {
|
|
|
752
752
|
function xe(r) {
|
|
753
753
|
const e = [];
|
|
754
754
|
e.push(r["@localetime"]), e.push(
|
|
755
|
-
|
|
755
|
+
qn[je[r.level]](
|
|
756
756
|
`[${r.level}]`
|
|
757
757
|
)
|
|
758
758
|
);
|
|
759
759
|
let t = "";
|
|
760
760
|
r.fields.isNestSystemModule != null && (t = U.magenta(`[${r.fields.nestSystemModule}]`), delete r.fields.isNestSystemModule, delete r.fields.nestSystemModule), r.fields.context != null && (t = U.magenta(`[${r.fields.context}]`), delete r.fields.context), t.length > 0 && e.push(t), "module" in r.fields && r.fields.module != null && (e.push(U.magenta(`[${r.fields.module}]`)), delete r.fields.module), e.push(r.message);
|
|
761
|
-
const
|
|
762
|
-
|
|
763
|
-
for (const [a, s] of
|
|
761
|
+
const n = Object.entries(r.fields);
|
|
762
|
+
n.length > 0 && e.push(" {");
|
|
763
|
+
for (const [a, s] of n) {
|
|
764
764
|
let o = s;
|
|
765
765
|
if (or(s)) {
|
|
766
766
|
if (s.message && (o = _t(s.message)), o || (o = ""), s.cause != null)
|
|
@@ -773,34 +773,34 @@ function xe(r) {
|
|
|
773
773
|
o = _t(s);
|
|
774
774
|
e.push(`${U.gray(a)}${U.gray("=")}${o}`);
|
|
775
775
|
}
|
|
776
|
-
|
|
777
|
-
let
|
|
778
|
-
return r.errored != null && r.errored && r.error && r.error.stack != null && r.error.stack && (
|
|
779
|
-
${r.error.stack}`),
|
|
776
|
+
n.length > 0 && e.push("}");
|
|
777
|
+
let i = e.join(" ");
|
|
778
|
+
return r.errored != null && r.errored && r.error && r.error.stack != null && r.error.stack && (i += `
|
|
779
|
+
${r.error.stack}`), i;
|
|
780
780
|
}
|
|
781
|
-
function
|
|
781
|
+
function Kn(r) {
|
|
782
782
|
return r >= E.Debug;
|
|
783
783
|
}
|
|
784
|
-
function
|
|
784
|
+
function Yn(r) {
|
|
785
785
|
return r >= E.Verbose;
|
|
786
786
|
}
|
|
787
|
-
function
|
|
787
|
+
function Xn(r) {
|
|
788
788
|
return r >= E.Log;
|
|
789
789
|
}
|
|
790
|
-
function
|
|
790
|
+
function Zn(r) {
|
|
791
791
|
return r >= E.Warning;
|
|
792
792
|
}
|
|
793
|
-
function
|
|
793
|
+
function Jn(r) {
|
|
794
794
|
return r >= E.Error;
|
|
795
795
|
}
|
|
796
796
|
function cr() {
|
|
797
797
|
return typeof window < "u";
|
|
798
798
|
}
|
|
799
|
-
function
|
|
799
|
+
function Qn() {
|
|
800
800
|
return !cr() && Ke() === oe.Pretty;
|
|
801
801
|
}
|
|
802
|
-
function
|
|
803
|
-
return
|
|
802
|
+
function ei(r, e) {
|
|
803
|
+
return Qn() ? `\x1B]8;;file://${r}\x1B\\${e}\x1B]8;;\x1B\\` : e;
|
|
804
804
|
}
|
|
805
805
|
const Pe = {
|
|
806
806
|
configured: !1,
|
|
@@ -825,7 +825,7 @@ function _e(r) {
|
|
|
825
825
|
function Ke() {
|
|
826
826
|
return Pe.format;
|
|
827
827
|
}
|
|
828
|
-
function
|
|
828
|
+
function ti() {
|
|
829
829
|
return Pe.timeFormatter;
|
|
830
830
|
}
|
|
831
831
|
function dr(r) {
|
|
@@ -850,7 +850,7 @@ function dr(r) {
|
|
|
850
850
|
const h = e.child();
|
|
851
851
|
if (Le.includes(c))
|
|
852
852
|
h.logLevel = c, h.shouldUseGlobalConfig = !1, h.debug(
|
|
853
|
-
`setting log level to ${
|
|
853
|
+
`setting log level to ${Gn[c]} (${c})`
|
|
854
854
|
);
|
|
855
855
|
else
|
|
856
856
|
throw new Error(
|
|
@@ -905,7 +905,7 @@ function dr(r) {
|
|
|
905
905
|
return h;
|
|
906
906
|
},
|
|
907
907
|
withCallStack(c) {
|
|
908
|
-
const h =
|
|
908
|
+
const h = Hn(c).slice(2).filter((p) => !p.invalid);
|
|
909
909
|
return h.length === 0 ? e : e.child({
|
|
910
910
|
function: h[0].function,
|
|
911
911
|
file: `${h[0].file}:${h[0].line}:${h[0].column}`,
|
|
@@ -936,8 +936,8 @@ function dr(r) {
|
|
|
936
936
|
const h = e.child();
|
|
937
937
|
return h.errorProcessor = c, h;
|
|
938
938
|
}
|
|
939
|
-
}, t = () => e.shouldUseGlobalConfig ? It() : e.logLevel,
|
|
940
|
-
const v =
|
|
939
|
+
}, t = () => e.shouldUseGlobalConfig ? It() : e.logLevel, n = () => e.shouldUseGlobalConfig ? Ke() : e.format, i = () => e.shouldUseGlobalConfig ? ti() : e.timeFormatter ?? ((c) => c.toISOString()), a = (c) => c != null && c.length > 0 ? Object.keys(e.fields).length > 0 ? [e.fields, ...c] : c : e.fields, s = (c, h, p) => {
|
|
940
|
+
const v = n();
|
|
941
941
|
if (cr() && v === oe.Pretty) {
|
|
942
942
|
c.fields = Object.fromEntries(
|
|
943
943
|
Object.entries(c.fields).filter(([b, P]) => {
|
|
@@ -952,10 +952,10 @@ function dr(r) {
|
|
|
952
952
|
const S = v === oe.Pretty ? xe(c) : JSON.stringify(c);
|
|
953
953
|
console[h](S);
|
|
954
954
|
}, o = {
|
|
955
|
-
[T.Debug]:
|
|
956
|
-
[T.Verbose]:
|
|
957
|
-
[T.Log]:
|
|
958
|
-
[T.Warning]:
|
|
955
|
+
[T.Debug]: Kn,
|
|
956
|
+
[T.Verbose]: Yn,
|
|
957
|
+
[T.Log]: Xn,
|
|
958
|
+
[T.Warning]: Zn
|
|
959
959
|
}, l = {
|
|
960
960
|
[T.Debug]: "debug",
|
|
961
961
|
[T.Verbose]: "log",
|
|
@@ -970,7 +970,7 @@ function dr(r) {
|
|
|
970
970
|
e.context,
|
|
971
971
|
w,
|
|
972
972
|
h,
|
|
973
|
-
|
|
973
|
+
i()
|
|
974
974
|
);
|
|
975
975
|
s(b, l[c], w);
|
|
976
976
|
};
|
|
@@ -984,29 +984,29 @@ function dr(r) {
|
|
|
984
984
|
m(T.Warning, c, h);
|
|
985
985
|
}, e.error = (c, h, ...p) => {
|
|
986
986
|
const v = t();
|
|
987
|
-
if (!
|
|
987
|
+
if (!Jn(v))
|
|
988
988
|
return;
|
|
989
|
-
const S = a(p), w =
|
|
989
|
+
const S = a(p), w = jn(
|
|
990
990
|
T.Error,
|
|
991
991
|
e.context,
|
|
992
992
|
S,
|
|
993
993
|
c,
|
|
994
994
|
h,
|
|
995
|
-
|
|
995
|
+
i()
|
|
996
996
|
);
|
|
997
997
|
s(w, "error", S);
|
|
998
998
|
}, e.errorWithError = (c, h, ...p) => e.withError(h).error(c, void 0, ...p), e;
|
|
999
999
|
}
|
|
1000
|
-
function
|
|
1000
|
+
function ri(r) {
|
|
1001
1001
|
var a;
|
|
1002
|
-
const t =
|
|
1003
|
-
return r = r ?? `${
|
|
1002
|
+
const t = _n.parse(new Error())[1], n = ((a = t.fileName) == null ? void 0 : a.replace("async", "").trim()) ?? "", i = He.join(...n.split(He.sep).slice(-2));
|
|
1003
|
+
return r = r ?? `${i}:${t.lineNumber}`, dr(ei(n, r));
|
|
1004
1004
|
}
|
|
1005
|
-
const
|
|
1005
|
+
const ni = (r) => ri(r).useGlobalConfig();
|
|
1006
1006
|
_e(E.Warning);
|
|
1007
|
-
const d =
|
|
1007
|
+
const d = ni("Web").withErrorProcessor((r) => r).useGlobalConfig();
|
|
1008
1008
|
let N = null;
|
|
1009
|
-
function
|
|
1009
|
+
function ii(r) {
|
|
1010
1010
|
switch (r) {
|
|
1011
1011
|
case Ce.off:
|
|
1012
1012
|
N || (N = { ...d }), Object.assign(d, {
|
|
@@ -1038,25 +1038,25 @@ function nn(r) {
|
|
|
1038
1038
|
break;
|
|
1039
1039
|
}
|
|
1040
1040
|
}
|
|
1041
|
-
const
|
|
1042
|
-
let
|
|
1043
|
-
let
|
|
1041
|
+
const ai = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1042
|
+
let si = (r) => crypto.getRandomValues(new Uint8Array(r)), oi = (r, e, t) => {
|
|
1043
|
+
let n = (2 << Math.log2(r.length - 1)) - 1, i = -~(1.6 * n * e / r.length);
|
|
1044
1044
|
return (a = e) => {
|
|
1045
1045
|
let s = "";
|
|
1046
1046
|
for (; ; ) {
|
|
1047
|
-
let o = t(
|
|
1047
|
+
let o = t(i), l = i | 0;
|
|
1048
1048
|
for (; l--; )
|
|
1049
|
-
if (s += r[o[l] &
|
|
1049
|
+
if (s += r[o[l] & n] || "", s.length >= a) return s;
|
|
1050
1050
|
}
|
|
1051
1051
|
};
|
|
1052
|
-
},
|
|
1052
|
+
}, li = (r, e = 21) => oi(r, e | 0, si), Pt = (r = 21) => {
|
|
1053
1053
|
let e = "", t = crypto.getRandomValues(new Uint8Array(r |= 0));
|
|
1054
1054
|
for (; r--; )
|
|
1055
|
-
e +=
|
|
1055
|
+
e += ai[t[r] & 63];
|
|
1056
1056
|
return e;
|
|
1057
1057
|
};
|
|
1058
1058
|
const Et = "spavatar_client_id";
|
|
1059
|
-
function
|
|
1059
|
+
function ci() {
|
|
1060
1060
|
try {
|
|
1061
1061
|
const r = localStorage.getItem(Et);
|
|
1062
1062
|
if (r)
|
|
@@ -1067,12 +1067,12 @@ function cn() {
|
|
|
1067
1067
|
return `temp_${Pt(21)}_${Date.now()}`;
|
|
1068
1068
|
}
|
|
1069
1069
|
}
|
|
1070
|
-
const
|
|
1070
|
+
const di = li("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 12);
|
|
1071
1071
|
function kt() {
|
|
1072
|
-
const r = /* @__PURE__ */ new Date(), e = r.getUTCFullYear(), t = String(r.getUTCMonth() + 1).padStart(2, "0"),
|
|
1072
|
+
const r = /* @__PURE__ */ new Date(), e = r.getUTCFullYear(), t = String(r.getUTCMonth() + 1).padStart(2, "0"), n = String(r.getUTCDate()).padStart(2, "0"), i = String(r.getUTCHours()).padStart(2, "0"), a = String(r.getUTCMinutes()).padStart(2, "0"), s = String(r.getUTCSeconds()).padStart(2, "0"), o = `${e}${t}${n}${i}${a}${s}`, l = di();
|
|
1073
1073
|
return `${o}_${l}`;
|
|
1074
1074
|
}
|
|
1075
|
-
class
|
|
1075
|
+
class ui {
|
|
1076
1076
|
constructor() {
|
|
1077
1077
|
u(this, "ids", {
|
|
1078
1078
|
clientId: "",
|
|
@@ -1082,7 +1082,7 @@ class un {
|
|
|
1082
1082
|
connectionId: null,
|
|
1083
1083
|
conversationId: null
|
|
1084
1084
|
});
|
|
1085
|
-
this.ids.clientId =
|
|
1085
|
+
this.ids.clientId = ci();
|
|
1086
1086
|
}
|
|
1087
1087
|
// ========== 全局 ID ==========
|
|
1088
1088
|
getClientId() {
|
|
@@ -1161,27 +1161,27 @@ class un {
|
|
|
1161
1161
|
this.ids.userId = null, this.ids.appId = null, this.ids.sessionToken = null, this.ids.connectionId = null, this.ids.conversationId = null;
|
|
1162
1162
|
}
|
|
1163
1163
|
}
|
|
1164
|
-
const k = new
|
|
1165
|
-
let
|
|
1164
|
+
const k = new ui();
|
|
1165
|
+
let ne = [];
|
|
1166
1166
|
const xt = 100;
|
|
1167
|
-
async function
|
|
1168
|
-
if (
|
|
1167
|
+
async function hi() {
|
|
1168
|
+
if (ne.length === 0)
|
|
1169
1169
|
return;
|
|
1170
|
-
const r = [...
|
|
1171
|
-
|
|
1170
|
+
const r = [...ne];
|
|
1171
|
+
ne = [];
|
|
1172
1172
|
try {
|
|
1173
|
-
await
|
|
1173
|
+
await fi();
|
|
1174
1174
|
} catch (e) {
|
|
1175
|
-
d.warn("[CLS] Failed to flush logs:", e instanceof Error ? e.message : String(e)),
|
|
1175
|
+
d.warn("[CLS] Failed to flush logs:", e instanceof Error ? e.message : String(e)), ne.unshift(...r), ne.length > xt && (ne = ne.slice(0, xt));
|
|
1176
1176
|
}
|
|
1177
1177
|
}
|
|
1178
|
-
async function
|
|
1178
|
+
async function fi(r) {
|
|
1179
1179
|
}
|
|
1180
|
-
function
|
|
1181
|
-
|
|
1180
|
+
function mi() {
|
|
1181
|
+
ne.length > 0 && hi(), d.log("[CLS] Cleaned up");
|
|
1182
1182
|
}
|
|
1183
1183
|
function C(r, e = "info", t = {}) {
|
|
1184
|
-
const
|
|
1184
|
+
const n = {
|
|
1185
1185
|
environment: "unknown",
|
|
1186
1186
|
sessionToken: k.getSessionToken() ?? "",
|
|
1187
1187
|
userId: k.getUserId() ?? "",
|
|
@@ -1192,7 +1192,7 @@ function C(r, e = "info", t = {}) {
|
|
|
1192
1192
|
warning: "warn",
|
|
1193
1193
|
error: "error"
|
|
1194
1194
|
}[e] ?? "log";
|
|
1195
|
-
d[a](`[Telemetry] ${r}`,
|
|
1195
|
+
d[a](`[Telemetry] ${r}`, n);
|
|
1196
1196
|
}
|
|
1197
1197
|
const Ie = class Ie {
|
|
1198
1198
|
constructor() {
|
|
@@ -1220,11 +1220,11 @@ const Ie = class Ie {
|
|
|
1220
1220
|
* Initialize with HTMLAudioElement (traditional way)
|
|
1221
1221
|
*/
|
|
1222
1222
|
async initialize(e, t) {
|
|
1223
|
-
return this.onEndedCallback = t, this.useStreaming = !1, new Promise((
|
|
1223
|
+
return this.onEndedCallback = t, this.useStreaming = !1, new Promise((n, i) => {
|
|
1224
1224
|
this.audio = new Audio(e), this.audio.addEventListener("canplaythrough", () => {
|
|
1225
|
-
this.setupEventListeners(),
|
|
1225
|
+
this.setupEventListeners(), n();
|
|
1226
1226
|
}, { once: !0 }), this.audio.addEventListener("error", () => {
|
|
1227
|
-
|
|
1227
|
+
i(new Error(`Failed to load audio: ${e}`));
|
|
1228
1228
|
}, { once: !0 }), this.audio.load();
|
|
1229
1229
|
});
|
|
1230
1230
|
}
|
|
@@ -1234,8 +1234,8 @@ const Ie = class Ie {
|
|
|
1234
1234
|
*/
|
|
1235
1235
|
async initializeStreaming(e, t) {
|
|
1236
1236
|
this.streamingPlayer = e, this.onEndedCallback = t, this.useStreaming = !0, this.streamingPlayer.onEnded(() => {
|
|
1237
|
-
var
|
|
1238
|
-
this._isPlaying = !1, (
|
|
1237
|
+
var n;
|
|
1238
|
+
this._isPlaying = !1, (n = this.onEndedCallback) == null || n.call(this);
|
|
1239
1239
|
});
|
|
1240
1240
|
}
|
|
1241
1241
|
/**
|
|
@@ -1257,7 +1257,7 @@ const Ie = class Ie {
|
|
|
1257
1257
|
async createAndInitializeStreamingPlayer() {
|
|
1258
1258
|
if (this.streamingPlayer)
|
|
1259
1259
|
return;
|
|
1260
|
-
const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-
|
|
1260
|
+
const { StreamingAudioPlayer: e } = await import("./StreamingAudioPlayer-DLwlYvg8.js");
|
|
1261
1261
|
this.streamingPlayer = new e({
|
|
1262
1262
|
sampleRate: M.audio.sampleRate,
|
|
1263
1263
|
channelCount: 1,
|
|
@@ -1266,10 +1266,10 @@ const Ie = class Ie {
|
|
|
1266
1266
|
try {
|
|
1267
1267
|
await this.streamingPlayer.initialize();
|
|
1268
1268
|
} catch (t) {
|
|
1269
|
-
const
|
|
1270
|
-
throw d.error("[AnimationPlayer] Failed to initialize streaming player:",
|
|
1269
|
+
const n = t instanceof Error ? t.message : String(t);
|
|
1270
|
+
throw d.error("[AnimationPlayer] Failed to initialize streaming player:", n), C("character_player", "error", {
|
|
1271
1271
|
event: "streaming_player_initialize_failed",
|
|
1272
|
-
reason:
|
|
1272
|
+
reason: n
|
|
1273
1273
|
}), t;
|
|
1274
1274
|
}
|
|
1275
1275
|
this.useStreaming = !0;
|
|
@@ -1368,24 +1368,24 @@ const V = {
|
|
|
1368
1368
|
config: null,
|
|
1369
1369
|
promise: null
|
|
1370
1370
|
};
|
|
1371
|
-
async function
|
|
1371
|
+
async function pi(r) {
|
|
1372
1372
|
return V.promise ? (await V.promise, V.config || {}) : V.config ? V.config : (V.promise = (async () => {
|
|
1373
1373
|
try {
|
|
1374
1374
|
const t = typeof window < "u" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1") ? `/api/config/sdk?version=${r}` : `https://config.spatialwalk.top/sdk?version=${r}`;
|
|
1375
1375
|
d.log(`[SdkConfigLoader] Fetching SDK config from: ${t}`);
|
|
1376
|
-
const
|
|
1376
|
+
const n = await fetch(t, {
|
|
1377
1377
|
method: "GET",
|
|
1378
1378
|
headers: {
|
|
1379
1379
|
"Content-Type": "application/json"
|
|
1380
1380
|
}
|
|
1381
1381
|
});
|
|
1382
|
-
if (!
|
|
1383
|
-
throw new Error(`HTTP ${
|
|
1384
|
-
const
|
|
1385
|
-
if (!
|
|
1382
|
+
if (!n.ok)
|
|
1383
|
+
throw new Error(`HTTP ${n.status} ${n.statusText}`);
|
|
1384
|
+
const i = await n.json();
|
|
1385
|
+
if (!i.endpoints)
|
|
1386
1386
|
throw new Error("Invalid config response: missing endpoints");
|
|
1387
1387
|
const a = {};
|
|
1388
|
-
|
|
1388
|
+
i.endpoints.cn && (a[se.cn] = `https://${i.endpoints.cn}`), i.endpoints.us ? a[se.intl] = `https://${i.endpoints.us}` : i.endpoints.intl && (a[se.intl] = `https://${i.endpoints.intl}`), i.endpoints.test && (a[se.test] = `https://${i.endpoints.test}`), V.config = a, d.log("[SdkConfigLoader] SDK config fetched successfully:", a);
|
|
1389
1389
|
} catch {
|
|
1390
1390
|
V.config = {};
|
|
1391
1391
|
} finally {
|
|
@@ -1393,11 +1393,11 @@ async function pn(r) {
|
|
|
1393
1393
|
}
|
|
1394
1394
|
})(), await V.promise, V.config || {});
|
|
1395
1395
|
}
|
|
1396
|
-
function
|
|
1396
|
+
function gi() {
|
|
1397
1397
|
V.config = null, V.promise = null;
|
|
1398
1398
|
}
|
|
1399
1399
|
const Ft = "spavatar_first_use", Mt = "spavatar_last_active_date";
|
|
1400
|
-
function
|
|
1400
|
+
function vi() {
|
|
1401
1401
|
try {
|
|
1402
1402
|
if (localStorage.getItem(Ft) === "true")
|
|
1403
1403
|
return !1;
|
|
@@ -1410,7 +1410,7 @@ function vn() {
|
|
|
1410
1410
|
return !1;
|
|
1411
1411
|
}
|
|
1412
1412
|
}
|
|
1413
|
-
function
|
|
1413
|
+
function yi() {
|
|
1414
1414
|
try {
|
|
1415
1415
|
const r = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
1416
1416
|
if (localStorage.getItem(Mt) === r)
|
|
@@ -1424,7 +1424,7 @@ function yn() {
|
|
|
1424
1424
|
return !1;
|
|
1425
1425
|
}
|
|
1426
1426
|
}
|
|
1427
|
-
class
|
|
1427
|
+
class wi {
|
|
1428
1428
|
constructor() {
|
|
1429
1429
|
u(this, "heartbeatTimer", null);
|
|
1430
1430
|
u(this, "visibilityChangeHandler", null);
|
|
@@ -1493,8 +1493,8 @@ class wn {
|
|
|
1493
1493
|
typeof window > "u" || typeof document > "u" || !this.visibilityChangeHandler || (document.removeEventListener("visibilitychange", this.visibilityChangeHandler), this.visibilityChangeHandler = null);
|
|
1494
1494
|
}
|
|
1495
1495
|
}
|
|
1496
|
-
const Tt = new
|
|
1497
|
-
class
|
|
1496
|
+
const Tt = new wi();
|
|
1497
|
+
class Si {
|
|
1498
1498
|
constructor(e) {
|
|
1499
1499
|
u(this, "module");
|
|
1500
1500
|
u(this, "allocatedPointers");
|
|
@@ -1505,18 +1505,18 @@ class Sn {
|
|
|
1505
1505
|
* 分配 WASM 内存并复制数据 - 纯 API 方式
|
|
1506
1506
|
*/
|
|
1507
1507
|
allocateAndCopy(e) {
|
|
1508
|
-
const t = e.byteLength,
|
|
1509
|
-
if (!
|
|
1508
|
+
const t = e.byteLength, n = this.module._malloc(t);
|
|
1509
|
+
if (!n)
|
|
1510
1510
|
throw new Error(`Failed to allocate ${t} bytes in WASM memory`);
|
|
1511
|
-
const
|
|
1512
|
-
return this.module.writeArrayToMemory(
|
|
1511
|
+
const i = new Uint8Array(e);
|
|
1512
|
+
return this.module.writeArrayToMemory(i, n), this.allocatedPointers.add(n), { ptr: n, size: t };
|
|
1513
1513
|
}
|
|
1514
1514
|
/**
|
|
1515
1515
|
* 创建 AvatarTemplateConfig 结构体
|
|
1516
1516
|
*/
|
|
1517
1517
|
createTemplateConfig(e) {
|
|
1518
|
-
const
|
|
1519
|
-
if (!
|
|
1518
|
+
const n = this.module._malloc(40);
|
|
1519
|
+
if (!n)
|
|
1520
1520
|
throw new Error("Failed to allocate AvatarTemplateConfig structure");
|
|
1521
1521
|
if (!e.flameModel || e.flameModel.byteLength === 0)
|
|
1522
1522
|
throw new Error("flameModel is missing or empty!");
|
|
@@ -1526,21 +1526,21 @@ class Sn {
|
|
|
1526
1526
|
throw new Error("teethPb is missing or empty!");
|
|
1527
1527
|
if (!e.teethNpz || e.teethNpz.byteLength === 0)
|
|
1528
1528
|
throw new Error("teethNpz is missing or empty!");
|
|
1529
|
-
const
|
|
1529
|
+
const i = this.allocateAndCopy(e.flameModel), a = this.allocateAndCopy(e.flameTemplate), s = this.allocateAndCopy(e.teethPb), o = this.allocateAndCopy(e.teethNpz);
|
|
1530
1530
|
let l = 0;
|
|
1531
|
-
return this.module.setValue(
|
|
1531
|
+
return this.module.setValue(n + l, i.ptr, "i32"), l += 4, this.module.setValue(n + l, i.size, "i32"), l += 4, this.module.setValue(n + l, a.ptr, "i32"), l += 4, this.module.setValue(n + l, a.size, "i32"), l += 4, this.module.setValue(n + l, s.ptr, "i32"), l += 4, this.module.setValue(n + l, s.size, "i32"), l += 4, this.module.setValue(n + l, o.ptr, "i32"), l += 4, this.module.setValue(n + l, o.size, "i32"), l += 4, this.module.setValue(n + l, 0, "i32"), l += 4, this.module.setValue(n + l, 0, "i32"), l += 4, this.structPointers.set("template_config", n), n;
|
|
1532
1532
|
}
|
|
1533
1533
|
/**
|
|
1534
1534
|
* 创建 AvatarCharacterData 结构体 - 新版 Emscripten 方式
|
|
1535
1535
|
*/
|
|
1536
|
-
createCharacterData(e, t,
|
|
1536
|
+
createCharacterData(e, t, n) {
|
|
1537
1537
|
const a = this.module._malloc(16);
|
|
1538
1538
|
if (!a)
|
|
1539
1539
|
throw new Error("Failed to allocate AvatarCharacterData structure");
|
|
1540
1540
|
const s = this.allocateAndCopy(e), o = this.allocateAndCopy(t);
|
|
1541
1541
|
let l = 0;
|
|
1542
1542
|
this.module.setValue(a + l, s.ptr, "i32"), l += 4, this.module.setValue(a + l, s.size, "i32"), l += 4, this.module.setValue(a + l, o.ptr, "i32"), l += 4, this.module.setValue(a + l, o.size, "i32"), l += 4;
|
|
1543
|
-
const m =
|
|
1543
|
+
const m = n ? `character_data_${n}` : "character_data";
|
|
1544
1544
|
return this.structPointers.set(m, a), { dataPtr: a, shapePtr: s.ptr, plyPtr: o.ptr };
|
|
1545
1545
|
}
|
|
1546
1546
|
/**
|
|
@@ -1549,12 +1549,12 @@ class Sn {
|
|
|
1549
1549
|
*/
|
|
1550
1550
|
readFlameParams(e) {
|
|
1551
1551
|
let t = 0;
|
|
1552
|
-
const i = [];
|
|
1553
|
-
for (let p = 0; p < 300; p++)
|
|
1554
|
-
i.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1555
1552
|
const n = [];
|
|
1556
|
-
for (let p = 0; p <
|
|
1553
|
+
for (let p = 0; p < 300; p++)
|
|
1557
1554
|
n.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1555
|
+
const i = [];
|
|
1556
|
+
for (let p = 0; p < 100; p++)
|
|
1557
|
+
i.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1558
1558
|
const a = [];
|
|
1559
1559
|
for (let p = 0; p < 3; p++)
|
|
1560
1560
|
a.push(this.module.getValue(e + t, "float")), t += 4;
|
|
@@ -1575,8 +1575,8 @@ class Sn {
|
|
|
1575
1575
|
c.push(this.module.getValue(e + t, "float")), t += 4;
|
|
1576
1576
|
const h = this.module.getValue(e + t, "i32") !== 0;
|
|
1577
1577
|
return {
|
|
1578
|
-
shape_params:
|
|
1579
|
-
expr_params:
|
|
1578
|
+
shape_params: n,
|
|
1579
|
+
expr_params: i,
|
|
1580
1580
|
rotation: a,
|
|
1581
1581
|
translation: s,
|
|
1582
1582
|
neck_pose: o,
|
|
@@ -1591,43 +1591,43 @@ class Sn {
|
|
|
1591
1591
|
*/
|
|
1592
1592
|
createFlameParams(e) {
|
|
1593
1593
|
var a, s, o, l, m, c, h, p;
|
|
1594
|
-
const
|
|
1595
|
-
if (!
|
|
1594
|
+
const n = this.module._malloc(1684);
|
|
1595
|
+
if (!n)
|
|
1596
1596
|
throw new Error("Failed to allocate AvatarFlameParams structure");
|
|
1597
|
-
let
|
|
1597
|
+
let i = 0;
|
|
1598
1598
|
for (let v = 0; v < 300; v++) {
|
|
1599
1599
|
const S = ((a = e.shape_params) == null ? void 0 : a[v]) || 0;
|
|
1600
|
-
this.module.setValue(
|
|
1600
|
+
this.module.setValue(n + i, S, "float"), i += 4;
|
|
1601
1601
|
}
|
|
1602
1602
|
for (let v = 0; v < 100; v++) {
|
|
1603
1603
|
const S = ((s = e.expr_params) == null ? void 0 : s[v]) || 0;
|
|
1604
|
-
this.module.setValue(
|
|
1604
|
+
this.module.setValue(n + i, S, "float"), i += 4;
|
|
1605
1605
|
}
|
|
1606
1606
|
for (let v = 0; v < 3; v++) {
|
|
1607
1607
|
const S = ((o = e.rotation) == null ? void 0 : o[v]) || 0;
|
|
1608
|
-
this.module.setValue(
|
|
1608
|
+
this.module.setValue(n + i, S, "float"), i += 4;
|
|
1609
1609
|
}
|
|
1610
1610
|
for (let v = 0; v < 3; v++) {
|
|
1611
1611
|
const S = ((l = e.translation) == null ? void 0 : l[v]) || 0;
|
|
1612
|
-
this.module.setValue(
|
|
1612
|
+
this.module.setValue(n + i, S, "float"), i += 4;
|
|
1613
1613
|
}
|
|
1614
1614
|
for (let v = 0; v < 3; v++) {
|
|
1615
1615
|
const S = ((m = e.neck_pose) == null ? void 0 : m[v]) || 0;
|
|
1616
|
-
this.module.setValue(
|
|
1616
|
+
this.module.setValue(n + i, S, "float"), i += 4;
|
|
1617
1617
|
}
|
|
1618
1618
|
for (let v = 0; v < 3; v++) {
|
|
1619
1619
|
const S = ((c = e.jaw_pose) == null ? void 0 : c[v]) || 0;
|
|
1620
|
-
this.module.setValue(
|
|
1620
|
+
this.module.setValue(n + i, S, "float"), i += 4;
|
|
1621
1621
|
}
|
|
1622
1622
|
for (let v = 0; v < 6; v++) {
|
|
1623
1623
|
const S = ((h = e.eyes_pose) == null ? void 0 : h[v]) || 0;
|
|
1624
|
-
this.module.setValue(
|
|
1624
|
+
this.module.setValue(n + i, S, "float"), i += 4;
|
|
1625
1625
|
}
|
|
1626
1626
|
for (let v = 0; v < 2; v++) {
|
|
1627
1627
|
const S = ((p = e.eyelid) == null ? void 0 : p[v]) || 0;
|
|
1628
|
-
this.module.setValue(
|
|
1628
|
+
this.module.setValue(n + i, S, "float"), i += 4;
|
|
1629
1629
|
}
|
|
1630
|
-
return this.module.setValue(
|
|
1630
|
+
return this.module.setValue(n + i, e.has_eyelid ? 1 : 0, "i32"), i += 4, n;
|
|
1631
1631
|
}
|
|
1632
1632
|
/**
|
|
1633
1633
|
* 读取 AvatarSplatPointFlatArray 结构体数据(预计算协方差)
|
|
@@ -1647,24 +1647,24 @@ class Sn {
|
|
|
1647
1647
|
readSplatPointFlatArray(e) {
|
|
1648
1648
|
if (!e)
|
|
1649
1649
|
throw new Error("Invalid array pointer");
|
|
1650
|
-
const t = this.module.getValue(e, "i32"),
|
|
1651
|
-
if (
|
|
1650
|
+
const t = this.module.getValue(e, "i32"), n = this.module.getValue(e + 4, "i32");
|
|
1651
|
+
if (n === 0 || !t)
|
|
1652
1652
|
return null;
|
|
1653
|
-
const a =
|
|
1653
|
+
const a = n * 13, s = t / 4, o = new Float32Array(a);
|
|
1654
1654
|
return o.set(this.module.HEAPF32.subarray(s, s + a)), o;
|
|
1655
1655
|
}
|
|
1656
1656
|
/**
|
|
1657
1657
|
* 读取AvatarMeshData结构体数据
|
|
1658
1658
|
*/
|
|
1659
1659
|
readMeshData(e) {
|
|
1660
|
-
const t = this.module.getValue(e + 0, "*"),
|
|
1661
|
-
if (t &&
|
|
1662
|
-
for (let p = 0; p <
|
|
1660
|
+
const t = this.module.getValue(e + 0, "*"), n = this.module.getValue(e + 4, "i32"), i = this.module.getValue(e + 8, "*"), a = this.module.getValue(e + 12, "i32"), s = this.module.getValue(e + 16, "float"), o = this.module.getValue(e + 20, "*"), l = this.module.getValue(e + 24, "i32"), m = new Float32Array(n * 3);
|
|
1661
|
+
if (t && n > 0)
|
|
1662
|
+
for (let p = 0; p < n * 3; p++)
|
|
1663
1663
|
m[p] = this.module.getValue(t + p * 4, "float");
|
|
1664
1664
|
const c = new Uint32Array(a * 3);
|
|
1665
|
-
if (
|
|
1665
|
+
if (i && a > 0)
|
|
1666
1666
|
for (let p = 0; p < a * 3; p++)
|
|
1667
|
-
c[p] = this.module.getValue(
|
|
1667
|
+
c[p] = this.module.getValue(i + p * 4, "i32");
|
|
1668
1668
|
let h = null;
|
|
1669
1669
|
if (o && l > 0) {
|
|
1670
1670
|
h = new Float32Array(l * 3);
|
|
@@ -1673,7 +1673,7 @@ class Sn {
|
|
|
1673
1673
|
}
|
|
1674
1674
|
return {
|
|
1675
1675
|
vertices: m,
|
|
1676
|
-
vertexCount:
|
|
1676
|
+
vertexCount: n,
|
|
1677
1677
|
faces: c,
|
|
1678
1678
|
faceCount: a,
|
|
1679
1679
|
landmarks: h,
|
|
@@ -1716,7 +1716,7 @@ class Sn {
|
|
|
1716
1716
|
};
|
|
1717
1717
|
}
|
|
1718
1718
|
}
|
|
1719
|
-
class
|
|
1719
|
+
class bi {
|
|
1720
1720
|
constructor(e = {}) {
|
|
1721
1721
|
// 配置
|
|
1722
1722
|
u(this, "options");
|
|
@@ -1791,7 +1791,7 @@ class bn {
|
|
|
1791
1791
|
async loadWASMModule() {
|
|
1792
1792
|
try {
|
|
1793
1793
|
const { default: e } = await import("./avatar_core_wasm-BPIbbUx_.js");
|
|
1794
|
-
this.wasmConfig && Object.keys(this.wasmConfig).length > 0 ? this.wasmModule = await e(this.wasmConfig) : this.wasmModule = await e(), this.validateWASMModule(), this.memoryManager = new
|
|
1794
|
+
this.wasmConfig && Object.keys(this.wasmConfig).length > 0 ? this.wasmModule = await e(this.wasmConfig) : this.wasmModule = await e(), this.validateWASMModule(), this.memoryManager = new Si(this.wasmModule), this.setupCAPIFunctions(), d.log("✅ Created new WASM instance with clean C++ memory");
|
|
1795
1795
|
} catch (e) {
|
|
1796
1796
|
const t = e instanceof Error ? e.message : String(e);
|
|
1797
1797
|
throw new Error(`Failed to load WASM module: ${t}`);
|
|
@@ -1876,11 +1876,11 @@ class bn {
|
|
|
1876
1876
|
* @param characterId Optional character ID for multi-character support
|
|
1877
1877
|
*/
|
|
1878
1878
|
async getCurrentFrameParams(e = 0, t) {
|
|
1879
|
-
const
|
|
1879
|
+
const n = await this.getAnimationFrameParams(e, t);
|
|
1880
1880
|
try {
|
|
1881
|
-
return this.memoryManager.readFlameParams(
|
|
1881
|
+
return this.memoryManager.readFlameParams(n);
|
|
1882
1882
|
} finally {
|
|
1883
|
-
this.wasmModule._free(
|
|
1883
|
+
this.wasmModule._free(n);
|
|
1884
1884
|
}
|
|
1885
1885
|
}
|
|
1886
1886
|
/**
|
|
@@ -1888,13 +1888,13 @@ class bn {
|
|
|
1888
1888
|
*/
|
|
1889
1889
|
async initializeAvatarCore(e) {
|
|
1890
1890
|
try {
|
|
1891
|
-
const t = this.memoryManager.createTemplateConfig(e),
|
|
1892
|
-
if (!
|
|
1891
|
+
const t = this.memoryManager.createTemplateConfig(e), n = this.api.initialize(t);
|
|
1892
|
+
if (!n)
|
|
1893
1893
|
throw new Error("avatar_core_initialize returned NULL - initialization failed");
|
|
1894
|
-
this.coreHandle =
|
|
1894
|
+
this.coreHandle = n, await this.queryFlameInfo();
|
|
1895
1895
|
} catch (t) {
|
|
1896
|
-
const
|
|
1897
|
-
throw new Error(`Failed to initialize Avatar Core: ${
|
|
1896
|
+
const n = t instanceof Error ? t.message : String(t);
|
|
1897
|
+
throw new Error(`Failed to initialize Avatar Core: ${n}`);
|
|
1898
1898
|
}
|
|
1899
1899
|
}
|
|
1900
1900
|
/**
|
|
@@ -1913,10 +1913,10 @@ class bn {
|
|
|
1913
1913
|
return !0;
|
|
1914
1914
|
try {
|
|
1915
1915
|
return await this.initializeAvatarCore(t), this.isInitialized = !0, !0;
|
|
1916
|
-
} catch (
|
|
1917
|
-
d.errorWithError("❌ Template resources loading failed:",
|
|
1918
|
-
const
|
|
1919
|
-
throw new Error(`Template resources loading failed: ${
|
|
1916
|
+
} catch (n) {
|
|
1917
|
+
d.errorWithError("❌ Template resources loading failed:", n);
|
|
1918
|
+
const i = n instanceof Error ? n.message : String(n);
|
|
1919
|
+
throw new Error(`Template resources loading failed: ${i}`);
|
|
1920
1920
|
}
|
|
1921
1921
|
}
|
|
1922
1922
|
/**
|
|
@@ -1929,26 +1929,26 @@ class bn {
|
|
|
1929
1929
|
* @param characterId Optional character ID for multi-character support
|
|
1930
1930
|
* @returns Character handle
|
|
1931
1931
|
*/
|
|
1932
|
-
async loadCharacterFromBuffers(e, t,
|
|
1932
|
+
async loadCharacterFromBuffers(e, t, n) {
|
|
1933
1933
|
if (!this.isInitialized)
|
|
1934
1934
|
throw new Error("Avatar Core not initialized");
|
|
1935
|
-
const
|
|
1935
|
+
const i = performance.now();
|
|
1936
1936
|
try {
|
|
1937
1937
|
const { dataPtr: a, shapePtr: s, plyPtr: o } = this.memoryManager.createCharacterData(
|
|
1938
1938
|
e,
|
|
1939
1939
|
t,
|
|
1940
|
-
|
|
1940
|
+
n
|
|
1941
1941
|
), l = this.api.loadCharacter(this.coreHandle, a);
|
|
1942
1942
|
if (!l) {
|
|
1943
1943
|
this.memoryManager.free(s), this.memoryManager.free(o);
|
|
1944
|
-
const h =
|
|
1944
|
+
const h = n ? `character_data_${n}` : "character_data";
|
|
1945
1945
|
throw this.memoryManager.freeStruct(h), new Error("avatar_core_load_character returned NULL - character loading failed");
|
|
1946
1946
|
}
|
|
1947
1947
|
this.memoryManager.free(s), this.memoryManager.free(o);
|
|
1948
|
-
const m =
|
|
1948
|
+
const m = n ? `character_data_${n}` : "character_data";
|
|
1949
1949
|
this.memoryManager.freeStruct(m);
|
|
1950
|
-
const c =
|
|
1951
|
-
return this.characterHandles.set(c, l), !
|
|
1950
|
+
const c = n || "default";
|
|
1951
|
+
return this.characterHandles.set(c, l), !n || c === "default" ? (this.characterHandle = l, this.isCharacterLoaded = !0, await this.queryCharacterInfo()) : this.characterHandle || (this.characterHandle = l, this.isCharacterLoaded = !0), this.performanceMetrics.loadTime = performance.now() - i, l;
|
|
1952
1952
|
} catch (a) {
|
|
1953
1953
|
d.errorWithError("❌ Character loading failed:", a);
|
|
1954
1954
|
const s = a instanceof Error ? a.message : String(a);
|
|
@@ -1956,12 +1956,12 @@ class bn {
|
|
|
1956
1956
|
}
|
|
1957
1957
|
}
|
|
1958
1958
|
async loadAnimationFromData(e) {
|
|
1959
|
-
const t = this.memoryManager.allocateAndCopy(e),
|
|
1960
|
-
this.wasmModule.setValue(
|
|
1961
|
-
const
|
|
1962
|
-
if (this.wasmModule._free(
|
|
1959
|
+
const t = this.memoryManager.allocateAndCopy(e), n = this.wasmModule._malloc(8);
|
|
1960
|
+
this.wasmModule.setValue(n, t.ptr, "i32"), this.wasmModule.setValue(n + 4, t.size, "i32");
|
|
1961
|
+
const i = this.api.loadAnimation(this.coreHandle, n);
|
|
1962
|
+
if (this.wasmModule._free(n), !i)
|
|
1963
1963
|
throw new Error("avatar_core_load_animation returned NULL");
|
|
1964
|
-
return
|
|
1964
|
+
return i;
|
|
1965
1965
|
}
|
|
1966
1966
|
/**
|
|
1967
1967
|
* Load animation from ArrayBuffer (for CDN-based dynamic loading)
|
|
@@ -1973,27 +1973,27 @@ class bn {
|
|
|
1973
1973
|
if (!this.isInitialized)
|
|
1974
1974
|
throw new Error("Avatar Core not initialized");
|
|
1975
1975
|
try {
|
|
1976
|
-
const
|
|
1977
|
-
return this.animationHandles.set(a, { handle:
|
|
1978
|
-
} catch (
|
|
1979
|
-
d.errorWithError("❌ Failed to load animation from buffer:",
|
|
1980
|
-
const
|
|
1981
|
-
throw new Error(`Failed to load animation from buffer: ${
|
|
1976
|
+
const n = await this.loadAnimationFromData(e), i = await this.getAnimationTotalFrames(n), a = t || "default";
|
|
1977
|
+
return this.animationHandles.set(a, { handle: n, totalFrames: i }), this.animationHandle = n, this.totalFrames = i, n;
|
|
1978
|
+
} catch (n) {
|
|
1979
|
+
d.errorWithError("❌ Failed to load animation from buffer:", n);
|
|
1980
|
+
const i = n instanceof Error ? n.message : String(n);
|
|
1981
|
+
throw new Error(`Failed to load animation from buffer: ${i}`);
|
|
1982
1982
|
}
|
|
1983
1983
|
}
|
|
1984
1984
|
async switchAnimationFile(e) {
|
|
1985
1985
|
if (!this.isInitialized)
|
|
1986
1986
|
throw new Error("Avatar Core not initialized");
|
|
1987
1987
|
try {
|
|
1988
|
-
const t = `${this.options.baseAssetsPath}/${this.options.modelFolder}/${e}`,
|
|
1989
|
-
if (!
|
|
1990
|
-
throw new Error(`HTTP error! status: ${
|
|
1991
|
-
const a = await
|
|
1988
|
+
const t = `${this.options.baseAssetsPath}/${this.options.modelFolder}/${e}`, n = this.wasmConfig.baseUrl ? `${this.wasmConfig.baseUrl}${t}` : t, i = await fetch(n);
|
|
1989
|
+
if (!i.ok)
|
|
1990
|
+
throw new Error(`HTTP error! status: ${i.status}`);
|
|
1991
|
+
const a = await i.arrayBuffer(), s = await this.loadAnimationFromData(a);
|
|
1992
1992
|
return this.animationHandle = s, this.totalFrames = null, await this.getAnimationTotalFrames(), this.totalFrames;
|
|
1993
1993
|
} catch (t) {
|
|
1994
1994
|
d.errorWithError(`❌ Failed to switch animation to ${e}:`, t);
|
|
1995
|
-
const
|
|
1996
|
-
throw new Error(`Failed to switch animation: ${
|
|
1995
|
+
const n = t instanceof Error ? t.message : String(t);
|
|
1996
|
+
throw new Error(`Failed to switch animation: ${n}`);
|
|
1997
1997
|
}
|
|
1998
1998
|
}
|
|
1999
1999
|
/**
|
|
@@ -2005,18 +2005,18 @@ class bn {
|
|
|
2005
2005
|
if (!t)
|
|
2006
2006
|
throw new Error("No animation loaded");
|
|
2007
2007
|
try {
|
|
2008
|
-
const
|
|
2009
|
-
if (
|
|
2010
|
-
this.wasmModule._free(
|
|
2011
|
-
const s = this.api.getErrorString(
|
|
2008
|
+
const n = this.wasmModule._malloc(4), i = this.api.getAnimationFrameCount(t, n);
|
|
2009
|
+
if (i !== 0) {
|
|
2010
|
+
this.wasmModule._free(n);
|
|
2011
|
+
const s = this.api.getErrorString(i);
|
|
2012
2012
|
throw new Error(`Failed to get animation frame count: ${s}`);
|
|
2013
2013
|
}
|
|
2014
|
-
const a = this.wasmModule.getValue(
|
|
2015
|
-
return this.wasmModule._free(
|
|
2016
|
-
} catch (
|
|
2017
|
-
d.errorWithError("❌ Failed to get animation frame count:",
|
|
2018
|
-
const
|
|
2019
|
-
throw new Error(`Failed to get animation frame count: ${
|
|
2014
|
+
const a = this.wasmModule.getValue(n, "i32");
|
|
2015
|
+
return this.wasmModule._free(n), e || (this.totalFrames = a), a;
|
|
2016
|
+
} catch (n) {
|
|
2017
|
+
d.errorWithError("❌ Failed to get animation frame count:", n);
|
|
2018
|
+
const i = n instanceof Error ? n.message : String(n);
|
|
2019
|
+
throw new Error(`Failed to get animation frame count: ${i}`);
|
|
2020
2020
|
}
|
|
2021
2021
|
}
|
|
2022
2022
|
/**
|
|
@@ -2025,10 +2025,10 @@ class bn {
|
|
|
2025
2025
|
* @param characterId Optional character ID for multi-character support
|
|
2026
2026
|
*/
|
|
2027
2027
|
async getAnimationFrameParams(e = 0, t) {
|
|
2028
|
-
const
|
|
2028
|
+
const n = t || "default", i = this.animationHandles.get(n), a = (i == null ? void 0 : i.handle) || this.animationHandle;
|
|
2029
2029
|
if (!a)
|
|
2030
2030
|
throw new Error("No animation loaded");
|
|
2031
|
-
const s = (
|
|
2031
|
+
const s = (i == null ? void 0 : i.totalFrames) ?? this.totalFrames;
|
|
2032
2032
|
s !== null && s > 0 && (e = e % s, e < 0 && (e += s));
|
|
2033
2033
|
try {
|
|
2034
2034
|
const l = this.wasmModule._malloc(1684), m = this.api.getFrameFromAnimation(a, e, l);
|
|
@@ -2037,7 +2037,7 @@ class bn {
|
|
|
2037
2037
|
const h = this.api.getErrorString(m);
|
|
2038
2038
|
throw new Error(`Failed to get frame ${e}: ${h}`);
|
|
2039
2039
|
}
|
|
2040
|
-
const c = this.characterHandles.get(
|
|
2040
|
+
const c = this.characterHandles.get(n) || this.characterHandle;
|
|
2041
2041
|
if (c) {
|
|
2042
2042
|
const h = this.api.getCharacterShapeParams(c, l);
|
|
2043
2043
|
h !== 0 && d.warn(`Failed to get character shape params: ${this.api.getErrorString(h)}`);
|
|
@@ -2058,26 +2058,26 @@ class bn {
|
|
|
2058
2058
|
try {
|
|
2059
2059
|
const t = this.wasmModule._malloc(12);
|
|
2060
2060
|
this.wasmModule.setValue(t, e.enabled ? 1 : 0, "i32"), this.wasmModule.setValue(t + 4, e.auto_eyelid_adjustment !== !1 ? 1 : 0, "i32"), this.wasmModule.setValue(t + 8, e.eyelid_threshold || 0.2, "float");
|
|
2061
|
-
const
|
|
2062
|
-
return this.wasmModule._free(t), this.checkError(
|
|
2061
|
+
const n = this.api.setEyeTrackingConfig(this.coreHandle, this.characterHandle, t);
|
|
2062
|
+
return this.wasmModule._free(t), this.checkError(n, "avatar_core_set_eye_tracking_config"), !0;
|
|
2063
2063
|
} catch (t) {
|
|
2064
2064
|
d.errorWithError("❌ Failed to set eye tracking config:", t);
|
|
2065
|
-
const
|
|
2066
|
-
throw new Error(`Failed to set eye tracking config: ${
|
|
2065
|
+
const n = t instanceof Error ? t.message : String(t);
|
|
2066
|
+
throw new Error(`Failed to set eye tracking config: ${n}`);
|
|
2067
2067
|
}
|
|
2068
2068
|
}
|
|
2069
2069
|
/**
|
|
2070
2070
|
* 设置眼部追踪目标(高级功能)
|
|
2071
2071
|
*/
|
|
2072
|
-
async setGazeTarget(e, t,
|
|
2072
|
+
async setGazeTarget(e, t, n) {
|
|
2073
2073
|
if (!this.isCharacterLoaded)
|
|
2074
2074
|
throw new Error("Character not loaded");
|
|
2075
2075
|
try {
|
|
2076
|
-
const
|
|
2077
|
-
return this.checkError(
|
|
2078
|
-
} catch (
|
|
2079
|
-
d.errorWithError("❌ Failed to set gaze target:",
|
|
2080
|
-
const a =
|
|
2076
|
+
const i = this.api.setGazeTarget(this.coreHandle, this.characterHandle, e, t, n);
|
|
2077
|
+
return this.checkError(i, "avatar_core_set_gaze_target"), !0;
|
|
2078
|
+
} catch (i) {
|
|
2079
|
+
d.errorWithError("❌ Failed to set gaze target:", i);
|
|
2080
|
+
const a = i instanceof Error ? i.message : String(i);
|
|
2081
2081
|
throw new Error(`Failed to set gaze target: ${a}`);
|
|
2082
2082
|
}
|
|
2083
2083
|
}
|
|
@@ -2101,15 +2101,15 @@ class bn {
|
|
|
2101
2101
|
*/
|
|
2102
2102
|
async queryFlameInfo() {
|
|
2103
2103
|
try {
|
|
2104
|
-
const e = this.wasmModule._malloc(4), t = this.wasmModule._malloc(4),
|
|
2104
|
+
const e = this.wasmModule._malloc(4), t = this.wasmModule._malloc(4), n = this.wasmModule._malloc(4), i = this.api.getFlameInfo(
|
|
2105
2105
|
this.coreHandle,
|
|
2106
2106
|
e,
|
|
2107
2107
|
t,
|
|
2108
|
-
|
|
2108
|
+
n
|
|
2109
2109
|
);
|
|
2110
|
-
this.checkError(
|
|
2111
|
-
const a = this.wasmModule.getValue(e, "i32"), s = this.wasmModule.getValue(t, "i32"), o = this.wasmModule.getValue(
|
|
2112
|
-
this.wasmModule._free(e), this.wasmModule._free(t), this.wasmModule._free(
|
|
2110
|
+
this.checkError(i, "avatar_core_get_flame_info");
|
|
2111
|
+
const a = this.wasmModule.getValue(e, "i32"), s = this.wasmModule.getValue(t, "i32"), o = this.wasmModule.getValue(n, "i32");
|
|
2112
|
+
this.wasmModule._free(e), this.wasmModule._free(t), this.wasmModule._free(n), this.flameInfo = { vertexCount: a, faceCount: s, jointCount: o };
|
|
2113
2113
|
} catch (e) {
|
|
2114
2114
|
const t = e instanceof Error ? e.message : String(e);
|
|
2115
2115
|
d.errorWithError("Failed to query model info:", t);
|
|
@@ -2120,14 +2120,14 @@ class bn {
|
|
|
2120
2120
|
*/
|
|
2121
2121
|
async queryCharacterInfo() {
|
|
2122
2122
|
try {
|
|
2123
|
-
const e = this.wasmModule._malloc(4), t = this.wasmModule._malloc(1),
|
|
2123
|
+
const e = this.wasmModule._malloc(4), t = this.wasmModule._malloc(1), n = this.api.getCharacterInfo(
|
|
2124
2124
|
this.characterHandle,
|
|
2125
2125
|
e,
|
|
2126
2126
|
t
|
|
2127
2127
|
);
|
|
2128
|
-
this.checkError(
|
|
2129
|
-
const
|
|
2130
|
-
this.wasmModule._free(e), this.wasmModule._free(t), this.characterInfo = { pointCount:
|
|
2128
|
+
this.checkError(n, "avatar_core_get_character_info");
|
|
2129
|
+
const i = this.wasmModule.getValue(e, "i32"), a = this.wasmModule.getValue(t, "i8") !== 0;
|
|
2130
|
+
this.wasmModule._free(e), this.wasmModule._free(t), this.characterInfo = { pointCount: i, hasAnimation: a };
|
|
2131
2131
|
} catch (e) {
|
|
2132
2132
|
const t = e instanceof Error ? e.message : String(e);
|
|
2133
2133
|
d.errorWithError("❌ Failed to query character info:", t);
|
|
@@ -2138,15 +2138,15 @@ class bn {
|
|
|
2138
2138
|
*/
|
|
2139
2139
|
checkError(e, t) {
|
|
2140
2140
|
if (e !== 0) {
|
|
2141
|
-
const
|
|
2142
|
-
throw d.errorWithError(`❌ ${t} failed: code=${e}, name=${
|
|
2141
|
+
const n = this.errorCodes[e] || `UNKNOWN_ERROR_${e}`, i = this.api.getErrorString(e);
|
|
2142
|
+
throw d.errorWithError(`❌ ${t} failed: code=${e}, name=${n}, message=${i}`, new Error(`${t} failed: ${n} - ${i}`)), new Error(`${t} failed: ${n} - ${i}`);
|
|
2143
2143
|
}
|
|
2144
2144
|
}
|
|
2145
2145
|
/**
|
|
2146
2146
|
* 更新进度回调
|
|
2147
2147
|
*/
|
|
2148
|
-
async updateProgress(e, t,
|
|
2149
|
-
e && typeof e == "function" && e({ message: t, progress:
|
|
2148
|
+
async updateProgress(e, t, n) {
|
|
2149
|
+
e && typeof e == "function" && e({ message: t, progress: n });
|
|
2150
2150
|
}
|
|
2151
2151
|
/**
|
|
2152
2152
|
* 获取性能指标
|
|
@@ -2173,10 +2173,10 @@ class bn {
|
|
|
2173
2173
|
if (!this.coreHandle)
|
|
2174
2174
|
throw new Error("Avatar Core not initialized");
|
|
2175
2175
|
this.api.removeCharacter(this.coreHandle, e);
|
|
2176
|
-
const
|
|
2177
|
-
|
|
2178
|
-
} catch (
|
|
2179
|
-
d.errorWithError("❌ Failed to remove character:",
|
|
2176
|
+
const n = t || "default", i = this.animationHandles.get(n);
|
|
2177
|
+
i && this.coreHandle && (this.api.removeAnimation(this.coreHandle, i.handle), this.animationHandles.delete(n)), this.characterHandles.delete(n), !t && this.characterHandle === e && (this.characterHandle = null, this.animationHandle = null, this.totalFrames = null, this.isCharacterLoaded = !1);
|
|
2178
|
+
} catch (n) {
|
|
2179
|
+
d.errorWithError("❌ Failed to remove character:", n);
|
|
2180
2180
|
}
|
|
2181
2181
|
}
|
|
2182
2182
|
/**
|
|
@@ -2206,7 +2206,7 @@ class bn {
|
|
|
2206
2206
|
}
|
|
2207
2207
|
// 兼容 load3DGSData
|
|
2208
2208
|
// eslint-disable-next-line ts/no-explicit-any
|
|
2209
|
-
async load3DGSData(e, t,
|
|
2209
|
+
async load3DGSData(e, t, n) {
|
|
2210
2210
|
return !0;
|
|
2211
2211
|
}
|
|
2212
2212
|
/**
|
|
@@ -2224,8 +2224,8 @@ class bn {
|
|
|
2224
2224
|
async computeCompleteFrameFlat(e, t) {
|
|
2225
2225
|
if (!this.isCharacterLoaded)
|
|
2226
2226
|
throw new Error("Character not loaded");
|
|
2227
|
-
const
|
|
2228
|
-
let
|
|
2227
|
+
const n = performance.now();
|
|
2228
|
+
let i = null, a = null;
|
|
2229
2229
|
try {
|
|
2230
2230
|
const s = (e == null ? void 0 : e.frameIndex) ?? 0, o = t || this.characterHandle;
|
|
2231
2231
|
let l;
|
|
@@ -2237,23 +2237,23 @@ class bn {
|
|
|
2237
2237
|
}
|
|
2238
2238
|
!l && o === this.characterHandle && (l = "default");
|
|
2239
2239
|
}
|
|
2240
|
-
if (a = await this.getAnimationFrameParams(s, l),
|
|
2240
|
+
if (a = await this.getAnimationFrameParams(s, l), i = this.wasmModule._malloc(16), !o)
|
|
2241
2241
|
throw new Error("No character loaded");
|
|
2242
2242
|
const m = this.api.computeFrameFlat(
|
|
2243
2243
|
this.coreHandle,
|
|
2244
2244
|
o,
|
|
2245
2245
|
a,
|
|
2246
|
-
|
|
2246
|
+
i
|
|
2247
2247
|
);
|
|
2248
2248
|
this.checkError(m, "avatar_core_compute_frame_as_splat_points_flat");
|
|
2249
|
-
const c = this.memoryManager.readSplatPointFlatArray(
|
|
2249
|
+
const c = this.memoryManager.readSplatPointFlatArray(i), h = performance.now() - n;
|
|
2250
2250
|
return this.wasmTime = h, this.performanceMetrics.computeFrames++, this.performanceMetrics.totalComputeTime += h, this.performanceMetrics.averageComputeTime = this.performanceMetrics.totalComputeTime / this.performanceMetrics.computeFrames, c;
|
|
2251
2251
|
} catch (s) {
|
|
2252
2252
|
d.errorWithError("❌ computeCompleteFrameFlat failed:", s);
|
|
2253
2253
|
const o = s instanceof Error ? s.message : String(s);
|
|
2254
2254
|
throw new Error(`computeCompleteFrameFlat failed: ${o}`);
|
|
2255
2255
|
} finally {
|
|
2256
|
-
|
|
2256
|
+
i !== null && (this.api.freeSplatPointsFlat(i), this.wasmModule._free(i)), a !== null && this.wasmModule._free(a);
|
|
2257
2257
|
}
|
|
2258
2258
|
}
|
|
2259
2259
|
/**
|
|
@@ -2268,10 +2268,10 @@ class bn {
|
|
|
2268
2268
|
async computeFrameFlatFromParams(e, t) {
|
|
2269
2269
|
if (!this.isCharacterLoaded)
|
|
2270
2270
|
throw new Error("Character not loaded");
|
|
2271
|
-
const
|
|
2272
|
-
let
|
|
2271
|
+
const n = performance.now();
|
|
2272
|
+
let i = null, a = null;
|
|
2273
2273
|
try {
|
|
2274
|
-
a = this.memoryManager.createFlameParams(e),
|
|
2274
|
+
a = this.memoryManager.createFlameParams(e), i = this.wasmModule._malloc(16);
|
|
2275
2275
|
const s = t || this.characterHandle;
|
|
2276
2276
|
if (!s)
|
|
2277
2277
|
throw new Error("No character loaded");
|
|
@@ -2279,17 +2279,17 @@ class bn {
|
|
|
2279
2279
|
this.coreHandle,
|
|
2280
2280
|
s,
|
|
2281
2281
|
a,
|
|
2282
|
-
|
|
2282
|
+
i
|
|
2283
2283
|
);
|
|
2284
2284
|
this.checkError(o, "avatar_core_compute_frame_as_splat_points_flat");
|
|
2285
|
-
const l = this.memoryManager.readSplatPointFlatArray(
|
|
2285
|
+
const l = this.memoryManager.readSplatPointFlatArray(i), m = performance.now() - n;
|
|
2286
2286
|
return this.wasmTime = m, this.performanceMetrics.computeFrames++, this.performanceMetrics.totalComputeTime += m, this.performanceMetrics.averageComputeTime = this.performanceMetrics.totalComputeTime / this.performanceMetrics.computeFrames, l;
|
|
2287
2287
|
} catch (s) {
|
|
2288
2288
|
d.errorWithError("❌ computeFrameFlatFromParams failed:", s);
|
|
2289
2289
|
const o = s instanceof Error ? s.message : String(s);
|
|
2290
2290
|
throw new Error(`computeFrameFlatFromParams failed: ${o}`);
|
|
2291
2291
|
} finally {
|
|
2292
|
-
|
|
2292
|
+
i !== null && (this.api.freeSplatPointsFlat(i), this.wasmModule._free(i)), a !== null && this.wasmModule._free(a);
|
|
2293
2293
|
}
|
|
2294
2294
|
}
|
|
2295
2295
|
/**
|
|
@@ -2317,27 +2317,27 @@ class L {
|
|
|
2317
2317
|
* @param configuration 配置参数
|
|
2318
2318
|
*/
|
|
2319
2319
|
static async initialize(e, t) {
|
|
2320
|
-
var
|
|
2320
|
+
var n, i;
|
|
2321
2321
|
try {
|
|
2322
2322
|
if (this._isInitialized) {
|
|
2323
|
-
d.log(`[
|
|
2323
|
+
d.log(`[AvatarSDK] Re-initializing with new environment: ${t.environment}`), k.setAppId(e), this._configuration = t;
|
|
2324
2324
|
return;
|
|
2325
2325
|
}
|
|
2326
|
-
d.log(`[
|
|
2326
|
+
d.log(`[AvatarSDK] Initializing with appId: ${e}, environment: ${t.environment}`), this._configuration = t, t.logLevel !== void 0 && ii(t.logLevel), k.setAppId(e), d.log(`[AvatarSDK] Client ID: ${k.getClientId()}`), this._fetchSdkConfig().catch((a) => {
|
|
2327
2327
|
const s = a instanceof Error ? a.message : String(a);
|
|
2328
2328
|
d.warn("Failed to fetch SDK config from remote, using defaults:", s), C("sdk_config", "warning", {
|
|
2329
2329
|
reason: s
|
|
2330
2330
|
});
|
|
2331
|
-
}), await this.initializeWASMModule(), await this.initializeTemplateResources(), this._isInitialized = !0, C("sdk_initialized", "info", {}),
|
|
2332
|
-
appId: k.getAppId(),
|
|
2333
|
-
environment: (i = this._configuration) == null ? void 0 : i.environment
|
|
2334
|
-
}), yn() && C("sdk_daily_active", "info", {
|
|
2331
|
+
}), await this.initializeWASMModule(), await this.initializeTemplateResources(), this._isInitialized = !0, C("sdk_initialized", "info", {}), vi() && C("sdk_first_use", "info", {
|
|
2335
2332
|
appId: k.getAppId(),
|
|
2336
2333
|
environment: (n = this._configuration) == null ? void 0 : n.environment
|
|
2337
|
-
}),
|
|
2334
|
+
}), yi() && C("sdk_daily_active", "info", {
|
|
2335
|
+
appId: k.getAppId(),
|
|
2336
|
+
environment: (i = this._configuration) == null ? void 0 : i.environment
|
|
2337
|
+
}), Tt.start(this._configuration.environment), d.log("[AvatarSDK] Successfully initialized");
|
|
2338
2338
|
} catch (a) {
|
|
2339
2339
|
const s = a instanceof Error ? a.message : String(a);
|
|
2340
|
-
throw d.error("Failed to initialize
|
|
2340
|
+
throw d.error("Failed to initialize AvatarSDK:", s), C("sdk_startup", "error", {
|
|
2341
2341
|
reason: s
|
|
2342
2342
|
}), a;
|
|
2343
2343
|
}
|
|
@@ -2347,7 +2347,7 @@ class L {
|
|
|
2347
2347
|
*/
|
|
2348
2348
|
static async initializeWASMModule() {
|
|
2349
2349
|
try {
|
|
2350
|
-
d.log("[
|
|
2350
|
+
d.log("[AvatarSDK] Initializing WASM module..."), this._avatarCore = new bi({
|
|
2351
2351
|
logLevel: "basic",
|
|
2352
2352
|
enableValidation: !0,
|
|
2353
2353
|
enablePerformanceMetrics: !0,
|
|
@@ -2365,7 +2365,7 @@ class L {
|
|
|
2365
2365
|
// WASM 文件与 Emscripten JS 文件在同一目录(dist/ 根目录)
|
|
2366
2366
|
locateFile: (e, t) => e.startsWith("data:") || e.startsWith("http://") || e.startsWith("https://") ? e : t.endsWith("/") ? t + e : `${t}/${e}`
|
|
2367
2367
|
}
|
|
2368
|
-
}), await this._avatarCore.loadWASMModule(), d.log("[
|
|
2368
|
+
}), await this._avatarCore.loadWASMModule(), d.log("[AvatarSDK] WASM module initialized successfully");
|
|
2369
2369
|
} catch (e) {
|
|
2370
2370
|
throw d.error("Failed to initialize WASM module:", e instanceof Error ? e.message : String(e)), new Error(`WASM module initialization failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
2371
2371
|
}
|
|
@@ -2377,13 +2377,13 @@ class L {
|
|
|
2377
2377
|
static async initializeTemplateResources() {
|
|
2378
2378
|
if (!this._avatarCore)
|
|
2379
2379
|
throw new Error("AvatarCore not available");
|
|
2380
|
-
d.log("[
|
|
2380
|
+
d.log("[AvatarSDK] Loading template resources...");
|
|
2381
2381
|
try {
|
|
2382
|
-
const { AvatarDownloader: e } = await Promise.resolve().then(() =>
|
|
2383
|
-
await this._avatarCore.loadTemplateResourcesFromBuffers(
|
|
2382
|
+
const { AvatarDownloader: e } = await Promise.resolve().then(() => Wi), n = await new e().loadGlobalFlameResources();
|
|
2383
|
+
await this._avatarCore.loadTemplateResourcesFromBuffers(n) ? d.log("[AvatarSDK] Template resources initialized successfully") : d.log("[AvatarSDK] Template resources already initialized, skipping...");
|
|
2384
2384
|
} catch (e) {
|
|
2385
2385
|
const t = e instanceof Error ? e.message : String(e);
|
|
2386
|
-
throw d.error("[
|
|
2386
|
+
throw d.error("[AvatarSDK] Failed to initialize template resources:", t), C("template_init", "error", {
|
|
2387
2387
|
reason: t,
|
|
2388
2388
|
stage: "sdk_init"
|
|
2389
2389
|
}), new Error(`SDK initialization failed: Template resources loading failed - ${t}`);
|
|
@@ -2444,9 +2444,9 @@ class L {
|
|
|
2444
2444
|
static cleanup() {
|
|
2445
2445
|
if (this._isInitialized)
|
|
2446
2446
|
try {
|
|
2447
|
-
Tt.stop(), this._avatarCore && (this._avatarCore.release(), this._avatarCore = null), this._configuration = null, this._dynamicSdkConfig = null, this._isInitialized = !1, k.clear(),
|
|
2447
|
+
Tt.stop(), this._avatarCore && (this._avatarCore.release(), this._avatarCore = null), this._configuration = null, this._dynamicSdkConfig = null, this._isInitialized = !1, k.clear(), gi(), mi(), d.log("[AvatarSDK] Cleanup completed");
|
|
2448
2448
|
} catch (e) {
|
|
2449
|
-
d.error("Failed to cleanup
|
|
2449
|
+
d.error("Failed to cleanup AvatarSDK:", e instanceof Error ? e.message : String(e));
|
|
2450
2450
|
}
|
|
2451
2451
|
}
|
|
2452
2452
|
/**
|
|
@@ -2454,7 +2454,7 @@ class L {
|
|
|
2454
2454
|
*/
|
|
2455
2455
|
static async _fetchSdkConfig() {
|
|
2456
2456
|
try {
|
|
2457
|
-
this._dynamicSdkConfig = await
|
|
2457
|
+
this._dynamicSdkConfig = await pi(this._version);
|
|
2458
2458
|
} catch (e) {
|
|
2459
2459
|
const t = e instanceof Error ? e.message : String(e);
|
|
2460
2460
|
d.warn("Failed to fetch SDK config from remote, using defaults:", t), C("sdk_config", "warning", {
|
|
@@ -2467,9 +2467,9 @@ class L {
|
|
|
2467
2467
|
* @internal
|
|
2468
2468
|
*/
|
|
2469
2469
|
static getEnvironmentConfig() {
|
|
2470
|
-
var
|
|
2470
|
+
var i;
|
|
2471
2471
|
if (!this._configuration)
|
|
2472
|
-
throw new Error("
|
|
2472
|
+
throw new Error("AvatarSDK not initialized");
|
|
2473
2473
|
const t = {
|
|
2474
2474
|
[se.cn]: {
|
|
2475
2475
|
sdkApiBaseUrl: "https://api.open.spatialwalk.top",
|
|
@@ -2487,25 +2487,25 @@ class L {
|
|
|
2487
2487
|
if (!t)
|
|
2488
2488
|
throw new Error("Unknown environment");
|
|
2489
2489
|
return {
|
|
2490
|
-
sdkApiBaseUrl: ((
|
|
2490
|
+
sdkApiBaseUrl: ((i = this._dynamicSdkConfig) == null ? void 0 : i[this._configuration.environment]) || t.sdkApiBaseUrl,
|
|
2491
2491
|
driveningressWsUrl: t.driveningressWsUrl
|
|
2492
2492
|
};
|
|
2493
2493
|
}
|
|
2494
2494
|
}
|
|
2495
2495
|
u(L, "_isInitialized", !1), u(L, "_configuration", null), u(L, "_version", "1.0.0-beta.27"), u(L, "_avatarCore", null), u(L, "_dynamicSdkConfig", null);
|
|
2496
|
-
function
|
|
2496
|
+
function Ai() {
|
|
2497
2497
|
let r = 0, e = 0;
|
|
2498
|
-
for (let
|
|
2499
|
-
let
|
|
2500
|
-
if (r |= (
|
|
2498
|
+
for (let n = 0; n < 28; n += 7) {
|
|
2499
|
+
let i = this.buf[this.pos++];
|
|
2500
|
+
if (r |= (i & 127) << n, !(i & 128))
|
|
2501
2501
|
return this.assertBounds(), [r, e];
|
|
2502
2502
|
}
|
|
2503
2503
|
let t = this.buf[this.pos++];
|
|
2504
2504
|
if (r |= (t & 15) << 28, e = (t & 112) >> 4, !(t & 128))
|
|
2505
2505
|
return this.assertBounds(), [r, e];
|
|
2506
|
-
for (let
|
|
2507
|
-
let
|
|
2508
|
-
if (e |= (
|
|
2506
|
+
for (let n = 3; n <= 31; n += 7) {
|
|
2507
|
+
let i = this.buf[this.pos++];
|
|
2508
|
+
if (e |= (i & 127) << n, !(i & 128))
|
|
2509
2509
|
return this.assertBounds(), [r, e];
|
|
2510
2510
|
}
|
|
2511
2511
|
throw new Error("invalid varint");
|
|
@@ -2516,8 +2516,8 @@ function ze(r, e, t) {
|
|
|
2516
2516
|
if (t.push(l), !o)
|
|
2517
2517
|
return;
|
|
2518
2518
|
}
|
|
2519
|
-
const
|
|
2520
|
-
if (t.push((
|
|
2519
|
+
const n = r >>> 28 & 15 | (e & 7) << 4, i = !!(e >> 3);
|
|
2520
|
+
if (t.push((i ? n | 128 : n) & 255), !!i) {
|
|
2521
2521
|
for (let a = 3; a < 31; a = a + 7) {
|
|
2522
2522
|
const s = e >>> a, o = !!(s >>> 7), l = (o ? s | 128 : s) & 255;
|
|
2523
2523
|
if (t.push(l), !o)
|
|
@@ -2531,29 +2531,29 @@ function Lt(r) {
|
|
|
2531
2531
|
const e = r[0] === "-";
|
|
2532
2532
|
e && (r = r.slice(1));
|
|
2533
2533
|
const t = 1e6;
|
|
2534
|
-
let
|
|
2534
|
+
let n = 0, i = 0;
|
|
2535
2535
|
function a(s, o) {
|
|
2536
2536
|
const l = Number(r.slice(s, o));
|
|
2537
|
-
|
|
2537
|
+
i *= t, n = n * t + l, n >= Me && (i = i + (n / Me | 0), n = n % Me);
|
|
2538
2538
|
}
|
|
2539
|
-
return a(-24, -18), a(-18, -12), a(-12, -6), a(-6), e ? hr(
|
|
2539
|
+
return a(-24, -18), a(-18, -12), a(-12, -6), a(-6), e ? hr(n, i) : Je(n, i);
|
|
2540
2540
|
}
|
|
2541
|
-
function
|
|
2541
|
+
function Ci(r, e) {
|
|
2542
2542
|
let t = Je(r, e);
|
|
2543
|
-
const
|
|
2544
|
-
|
|
2545
|
-
const
|
|
2546
|
-
return
|
|
2543
|
+
const n = t.hi & 2147483648;
|
|
2544
|
+
n && (t = hr(t.lo, t.hi));
|
|
2545
|
+
const i = ur(t.lo, t.hi);
|
|
2546
|
+
return n ? "-" + i : i;
|
|
2547
2547
|
}
|
|
2548
2548
|
function ur(r, e) {
|
|
2549
|
-
if ({ lo: r, hi: e } =
|
|
2549
|
+
if ({ lo: r, hi: e } = _i(r, e), e <= 2097151)
|
|
2550
2550
|
return String(Me * e + r);
|
|
2551
|
-
const t = r & 16777215,
|
|
2552
|
-
let a = t +
|
|
2551
|
+
const t = r & 16777215, n = (r >>> 24 | e << 8) & 16777215, i = e >> 16 & 65535;
|
|
2552
|
+
let a = t + n * 6777216 + i * 6710656, s = n + i * 8147497, o = i * 2;
|
|
2553
2553
|
const l = 1e7;
|
|
2554
2554
|
return a >= l && (s += Math.floor(a / l), a %= l), s >= l && (o += Math.floor(s / l), s %= l), o.toString() + Rt(s) + Rt(a);
|
|
2555
2555
|
}
|
|
2556
|
-
function
|
|
2556
|
+
function _i(r, e) {
|
|
2557
2557
|
return { lo: r >>> 0, hi: e >>> 0 };
|
|
2558
2558
|
}
|
|
2559
2559
|
function Je(r, e) {
|
|
@@ -2577,7 +2577,7 @@ function Dt(r, e) {
|
|
|
2577
2577
|
e.push(1);
|
|
2578
2578
|
}
|
|
2579
2579
|
}
|
|
2580
|
-
function
|
|
2580
|
+
function Ii() {
|
|
2581
2581
|
let r = this.buf[this.pos++], e = r & 127;
|
|
2582
2582
|
if (!(r & 128))
|
|
2583
2583
|
return this.assertBounds(), e;
|
|
@@ -2594,23 +2594,23 @@ function In() {
|
|
|
2594
2594
|
throw new Error("invalid varint");
|
|
2595
2595
|
return this.assertBounds(), e >>> 0;
|
|
2596
2596
|
}
|
|
2597
|
-
const Z = /* @__PURE__ */
|
|
2598
|
-
function
|
|
2597
|
+
const Z = /* @__PURE__ */ Pi();
|
|
2598
|
+
function Pi() {
|
|
2599
2599
|
const r = new DataView(new ArrayBuffer(8));
|
|
2600
2600
|
if (typeof BigInt == "function" && typeof r.getBigInt64 == "function" && typeof r.getBigUint64 == "function" && typeof r.setBigInt64 == "function" && typeof r.setBigUint64 == "function" && (!!globalThis.Deno || typeof process != "object" || typeof process.env != "object" || process.env.BUF_BIGINT_DISABLE !== "1")) {
|
|
2601
|
-
const t = BigInt("-9223372036854775808"),
|
|
2601
|
+
const t = BigInt("-9223372036854775808"), n = BigInt("9223372036854775807"), i = BigInt("0"), a = BigInt("18446744073709551615");
|
|
2602
2602
|
return {
|
|
2603
2603
|
zero: BigInt(0),
|
|
2604
2604
|
supported: !0,
|
|
2605
2605
|
parse(s) {
|
|
2606
2606
|
const o = typeof s == "bigint" ? s : BigInt(s);
|
|
2607
|
-
if (o >
|
|
2607
|
+
if (o > n || o < t)
|
|
2608
2608
|
throw new Error(`invalid int64: ${s}`);
|
|
2609
2609
|
return o;
|
|
2610
2610
|
},
|
|
2611
2611
|
uParse(s) {
|
|
2612
2612
|
const o = typeof s == "bigint" ? s : BigInt(s);
|
|
2613
|
-
if (o > a || o <
|
|
2613
|
+
if (o > a || o < i)
|
|
2614
2614
|
throw new Error(`invalid uint64: ${s}`);
|
|
2615
2615
|
return o;
|
|
2616
2616
|
},
|
|
@@ -2649,11 +2649,11 @@ function Pn() {
|
|
|
2649
2649
|
uEnc(t) {
|
|
2650
2650
|
return typeof t != "string" && (t = t.toString()), Ot(t), Lt(t);
|
|
2651
2651
|
},
|
|
2652
|
-
dec(t,
|
|
2653
|
-
return
|
|
2652
|
+
dec(t, n) {
|
|
2653
|
+
return Ci(t, n);
|
|
2654
2654
|
},
|
|
2655
|
-
uDec(t,
|
|
2656
|
-
return ur(t,
|
|
2655
|
+
uDec(t, n) {
|
|
2656
|
+
return ur(t, n);
|
|
2657
2657
|
}
|
|
2658
2658
|
};
|
|
2659
2659
|
}
|
|
@@ -2691,7 +2691,7 @@ var ae;
|
|
|
2691
2691
|
(function(r) {
|
|
2692
2692
|
r[r.Varint = 0] = "Varint", r[r.Bit64 = 1] = "Bit64", r[r.LengthDelimited = 2] = "LengthDelimited", r[r.StartGroup = 3] = "StartGroup", r[r.EndGroup = 4] = "EndGroup", r[r.Bit32 = 5] = "Bit32";
|
|
2693
2693
|
})(ae || (ae = {}));
|
|
2694
|
-
const
|
|
2694
|
+
const Ei = 34028234663852886e22, ki = -34028234663852886e22, xi = 4294967295, Fi = 2147483647, Mi = -2147483648;
|
|
2695
2695
|
class fe {
|
|
2696
2696
|
constructor(e = fr().encodeUtf8) {
|
|
2697
2697
|
this.encodeUtf8 = e, this.stack = [], this.chunks = [], this.buf = [];
|
|
@@ -2702,11 +2702,11 @@ class fe {
|
|
|
2702
2702
|
finish() {
|
|
2703
2703
|
this.buf.length && (this.chunks.push(new Uint8Array(this.buf)), this.buf = []);
|
|
2704
2704
|
let e = 0;
|
|
2705
|
-
for (let
|
|
2706
|
-
e += this.chunks[
|
|
2707
|
-
let t = new Uint8Array(e),
|
|
2708
|
-
for (let
|
|
2709
|
-
t.set(this.chunks[
|
|
2705
|
+
for (let i = 0; i < this.chunks.length; i++)
|
|
2706
|
+
e += this.chunks[i].length;
|
|
2707
|
+
let t = new Uint8Array(e), n = 0;
|
|
2708
|
+
for (let i = 0; i < this.chunks.length; i++)
|
|
2709
|
+
t.set(this.chunks[i], n), n += this.chunks[i].length;
|
|
2710
2710
|
return this.chunks = [], t;
|
|
2711
2711
|
}
|
|
2712
2712
|
/**
|
|
@@ -2781,7 +2781,7 @@ class fe {
|
|
|
2781
2781
|
* Write a `float` value, 32-bit floating point number.
|
|
2782
2782
|
*/
|
|
2783
2783
|
float(e) {
|
|
2784
|
-
|
|
2784
|
+
Ti(e);
|
|
2785
2785
|
let t = new Uint8Array(4);
|
|
2786
2786
|
return new DataView(t.buffer).setFloat32(0, e, !0), this.raw(t);
|
|
2787
2787
|
}
|
|
@@ -2818,15 +2818,15 @@ class fe {
|
|
|
2818
2818
|
* Write a `fixed64` value, a signed, fixed-length 64-bit integer.
|
|
2819
2819
|
*/
|
|
2820
2820
|
sfixed64(e) {
|
|
2821
|
-
let t = new Uint8Array(8),
|
|
2822
|
-
return
|
|
2821
|
+
let t = new Uint8Array(8), n = new DataView(t.buffer), i = Z.enc(e);
|
|
2822
|
+
return n.setInt32(0, i.lo, !0), n.setInt32(4, i.hi, !0), this.raw(t);
|
|
2823
2823
|
}
|
|
2824
2824
|
/**
|
|
2825
2825
|
* Write a `fixed64` value, an unsigned, fixed-length 64 bit integer.
|
|
2826
2826
|
*/
|
|
2827
2827
|
fixed64(e) {
|
|
2828
|
-
let t = new Uint8Array(8),
|
|
2829
|
-
return
|
|
2828
|
+
let t = new Uint8Array(8), n = new DataView(t.buffer), i = Z.uEnc(e);
|
|
2829
|
+
return n.setInt32(0, i.lo, !0), n.setInt32(4, i.hi, !0), this.raw(t);
|
|
2830
2830
|
}
|
|
2831
2831
|
/**
|
|
2832
2832
|
* Write a `int64` value, a signed 64-bit varint.
|
|
@@ -2839,8 +2839,8 @@ class fe {
|
|
|
2839
2839
|
* Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.
|
|
2840
2840
|
*/
|
|
2841
2841
|
sint64(e) {
|
|
2842
|
-
const t = Z.enc(e),
|
|
2843
|
-
return ze(
|
|
2842
|
+
const t = Z.enc(e), n = t.hi >> 31, i = t.lo << 1 ^ n, a = (t.hi << 1 | t.lo >>> 31) ^ n;
|
|
2843
|
+
return ze(i, a, this.buf), this;
|
|
2844
2844
|
}
|
|
2845
2845
|
/**
|
|
2846
2846
|
* Write a `uint64` value, an unsigned 64-bit varint.
|
|
@@ -2852,16 +2852,16 @@ class fe {
|
|
|
2852
2852
|
}
|
|
2853
2853
|
class z {
|
|
2854
2854
|
constructor(e, t = fr().decodeUtf8) {
|
|
2855
|
-
this.decodeUtf8 = t, this.varint64 =
|
|
2855
|
+
this.decodeUtf8 = t, this.varint64 = Ai, this.uint32 = Ii, this.buf = e, this.len = e.length, this.pos = 0, this.view = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
2856
2856
|
}
|
|
2857
2857
|
/**
|
|
2858
2858
|
* Reads a tag - field number and wire type.
|
|
2859
2859
|
*/
|
|
2860
2860
|
tag() {
|
|
2861
|
-
let e = this.uint32(), t = e >>> 3,
|
|
2862
|
-
if (t <= 0 ||
|
|
2863
|
-
throw new Error("illegal tag: field no " + t + " wire type " +
|
|
2864
|
-
return [t,
|
|
2861
|
+
let e = this.uint32(), t = e >>> 3, n = e & 7;
|
|
2862
|
+
if (t <= 0 || n < 0 || n > 5)
|
|
2863
|
+
throw new Error("illegal tag: field no " + t + " wire type " + n);
|
|
2864
|
+
return [t, n];
|
|
2865
2865
|
}
|
|
2866
2866
|
/**
|
|
2867
2867
|
* Skip one element and return the skipped data.
|
|
@@ -2870,7 +2870,7 @@ class z {
|
|
|
2870
2870
|
* matching field number in the EndGroup tag.
|
|
2871
2871
|
*/
|
|
2872
2872
|
skip(e, t) {
|
|
2873
|
-
let
|
|
2873
|
+
let n = this.pos;
|
|
2874
2874
|
switch (e) {
|
|
2875
2875
|
case ae.Varint:
|
|
2876
2876
|
for (; this.buf[this.pos++] & 128; )
|
|
@@ -2882,8 +2882,8 @@ class z {
|
|
|
2882
2882
|
this.pos += 4;
|
|
2883
2883
|
break;
|
|
2884
2884
|
case ae.LengthDelimited:
|
|
2885
|
-
let
|
|
2886
|
-
this.pos +=
|
|
2885
|
+
let i = this.uint32();
|
|
2886
|
+
this.pos += i;
|
|
2887
2887
|
break;
|
|
2888
2888
|
case ae.StartGroup:
|
|
2889
2889
|
for (; ; ) {
|
|
@@ -2899,7 +2899,7 @@ class z {
|
|
|
2899
2899
|
default:
|
|
2900
2900
|
throw new Error("cant skip wire type " + e);
|
|
2901
2901
|
}
|
|
2902
|
-
return this.assertBounds(), this.buf.subarray(
|
|
2902
|
+
return this.assertBounds(), this.buf.subarray(n, this.pos);
|
|
2903
2903
|
}
|
|
2904
2904
|
/**
|
|
2905
2905
|
* Throws error if position in byte array is out of range.
|
|
@@ -2937,8 +2937,8 @@ class z {
|
|
|
2937
2937
|
* Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
|
|
2938
2938
|
*/
|
|
2939
2939
|
sint64() {
|
|
2940
|
-
let [e, t] = this.varint64(),
|
|
2941
|
-
return e = (e >>> 1 | (t & 1) << 31) ^
|
|
2940
|
+
let [e, t] = this.varint64(), n = -(e & 1);
|
|
2941
|
+
return e = (e >>> 1 | (t & 1) << 31) ^ n, t = t >>> 1 ^ n, Z.dec(e, t);
|
|
2942
2942
|
}
|
|
2943
2943
|
/**
|
|
2944
2944
|
* Read a `bool` field, a variant.
|
|
@@ -3002,7 +3002,7 @@ function We(r) {
|
|
|
3002
3002
|
r = Number(r);
|
|
3003
3003
|
else if (typeof r != "number")
|
|
3004
3004
|
throw new Error("invalid int32: " + typeof r);
|
|
3005
|
-
if (!Number.isInteger(r) || r >
|
|
3005
|
+
if (!Number.isInteger(r) || r > Fi || r < Mi)
|
|
3006
3006
|
throw new Error("invalid int32: " + r);
|
|
3007
3007
|
}
|
|
3008
3008
|
function Nt(r) {
|
|
@@ -3010,21 +3010,21 @@ function Nt(r) {
|
|
|
3010
3010
|
r = Number(r);
|
|
3011
3011
|
else if (typeof r != "number")
|
|
3012
3012
|
throw new Error("invalid uint32: " + typeof r);
|
|
3013
|
-
if (!Number.isInteger(r) || r >
|
|
3013
|
+
if (!Number.isInteger(r) || r > xi || r < 0)
|
|
3014
3014
|
throw new Error("invalid uint32: " + r);
|
|
3015
3015
|
}
|
|
3016
|
-
function
|
|
3016
|
+
function Ti(r) {
|
|
3017
3017
|
if (typeof r == "string") {
|
|
3018
3018
|
const e = r;
|
|
3019
3019
|
if (r = Number(r), Number.isNaN(r) && e !== "NaN")
|
|
3020
3020
|
throw new Error("invalid float32: " + e);
|
|
3021
3021
|
} else if (typeof r != "number")
|
|
3022
3022
|
throw new Error("invalid float32: " + typeof r);
|
|
3023
|
-
if (Number.isFinite(r) && (r >
|
|
3023
|
+
if (Number.isFinite(r) && (r > Ei || r < ki))
|
|
3024
3024
|
throw new Error("invalid float32: " + r);
|
|
3025
3025
|
}
|
|
3026
3026
|
var Ee = /* @__PURE__ */ ((r) => (r[r.MESSAGE_UNSPECIFIED = 0] = "MESSAGE_UNSPECIFIED", r[r.MESSAGE_ERROR = 2] = "MESSAGE_ERROR", r[r.MESSAGE_SERVER_RESPONSE_ANIMATION = 1004] = "MESSAGE_SERVER_RESPONSE_ANIMATION", r[r.MESSAGE_CLIENT_AUDIO_INPUT = 2003] = "MESSAGE_CLIENT_AUDIO_INPUT", r[r.UNRECOGNIZED = -1] = "UNRECOGNIZED", r))(Ee || {});
|
|
3027
|
-
function
|
|
3027
|
+
function Li(r) {
|
|
3028
3028
|
switch (r) {
|
|
3029
3029
|
case 0:
|
|
3030
3030
|
case "MESSAGE_UNSPECIFIED":
|
|
@@ -3044,7 +3044,7 @@ function Ln(r) {
|
|
|
3044
3044
|
return -1;
|
|
3045
3045
|
}
|
|
3046
3046
|
}
|
|
3047
|
-
function
|
|
3047
|
+
function Ri(r) {
|
|
3048
3048
|
switch (r) {
|
|
3049
3049
|
case 0:
|
|
3050
3050
|
return "MESSAGE_UNSPECIFIED";
|
|
@@ -3068,27 +3068,27 @@ const pe = {
|
|
|
3068
3068
|
},
|
|
3069
3069
|
decode(r, e) {
|
|
3070
3070
|
const t = r instanceof z ? r : new z(r);
|
|
3071
|
-
let
|
|
3072
|
-
const
|
|
3073
|
-
for (; t.pos <
|
|
3071
|
+
let n = e === void 0 ? t.len : t.pos + e;
|
|
3072
|
+
const i = Ut();
|
|
3073
|
+
for (; t.pos < n; ) {
|
|
3074
3074
|
const a = t.uint32();
|
|
3075
3075
|
switch (a >>> 3) {
|
|
3076
3076
|
case 1: {
|
|
3077
3077
|
if (a !== 10)
|
|
3078
3078
|
break;
|
|
3079
|
-
|
|
3079
|
+
i.reqId = t.string();
|
|
3080
3080
|
continue;
|
|
3081
3081
|
}
|
|
3082
3082
|
case 2: {
|
|
3083
3083
|
if (a !== 18)
|
|
3084
3084
|
break;
|
|
3085
|
-
|
|
3085
|
+
i.audio = t.bytes();
|
|
3086
3086
|
continue;
|
|
3087
3087
|
}
|
|
3088
3088
|
case 3: {
|
|
3089
3089
|
if (a !== 24)
|
|
3090
3090
|
break;
|
|
3091
|
-
|
|
3091
|
+
i.end = t.bool();
|
|
3092
3092
|
continue;
|
|
3093
3093
|
}
|
|
3094
3094
|
}
|
|
@@ -3096,18 +3096,18 @@ const pe = {
|
|
|
3096
3096
|
break;
|
|
3097
3097
|
t.skip(a & 7);
|
|
3098
3098
|
}
|
|
3099
|
-
return
|
|
3099
|
+
return i;
|
|
3100
3100
|
},
|
|
3101
3101
|
fromJSON(r) {
|
|
3102
3102
|
return {
|
|
3103
3103
|
reqId: $(r.reqId) ? globalThis.String(r.reqId) : "",
|
|
3104
|
-
audio: $(r.audio) ?
|
|
3104
|
+
audio: $(r.audio) ? Di(r.audio) : new Uint8Array(0),
|
|
3105
3105
|
end: $(r.end) ? globalThis.Boolean(r.end) : !1
|
|
3106
3106
|
};
|
|
3107
3107
|
},
|
|
3108
3108
|
toJSON(r) {
|
|
3109
3109
|
const e = {};
|
|
3110
|
-
return r.reqId !== "" && (e.reqId = r.reqId), r.audio.length !== 0 && (e.audio =
|
|
3110
|
+
return r.reqId !== "" && (e.reqId = r.reqId), r.audio.length !== 0 && (e.audio = Bi(r.audio)), r.end !== !1 && (e.end = r.end), e;
|
|
3111
3111
|
},
|
|
3112
3112
|
create(r) {
|
|
3113
3113
|
return pe.fromPartial(r ?? {});
|
|
@@ -3147,98 +3147,98 @@ const ge = {
|
|
|
3147
3147
|
},
|
|
3148
3148
|
decode(r, e) {
|
|
3149
3149
|
const t = r instanceof z ? r : new z(r);
|
|
3150
|
-
let
|
|
3151
|
-
const
|
|
3152
|
-
for (; t.pos <
|
|
3150
|
+
let n = e === void 0 ? t.len : t.pos + e;
|
|
3151
|
+
const i = Vt();
|
|
3152
|
+
for (; t.pos < n; ) {
|
|
3153
3153
|
const a = t.uint32();
|
|
3154
3154
|
switch (a >>> 3) {
|
|
3155
3155
|
case 2: {
|
|
3156
3156
|
if (a === 21) {
|
|
3157
|
-
|
|
3157
|
+
i.translation.push(t.float());
|
|
3158
3158
|
continue;
|
|
3159
3159
|
}
|
|
3160
3160
|
if (a === 18) {
|
|
3161
3161
|
const s = t.uint32() + t.pos;
|
|
3162
3162
|
for (; t.pos < s; )
|
|
3163
|
-
|
|
3163
|
+
i.translation.push(t.float());
|
|
3164
3164
|
continue;
|
|
3165
3165
|
}
|
|
3166
3166
|
break;
|
|
3167
3167
|
}
|
|
3168
3168
|
case 3: {
|
|
3169
3169
|
if (a === 29) {
|
|
3170
|
-
|
|
3170
|
+
i.rotation.push(t.float());
|
|
3171
3171
|
continue;
|
|
3172
3172
|
}
|
|
3173
3173
|
if (a === 26) {
|
|
3174
3174
|
const s = t.uint32() + t.pos;
|
|
3175
3175
|
for (; t.pos < s; )
|
|
3176
|
-
|
|
3176
|
+
i.rotation.push(t.float());
|
|
3177
3177
|
continue;
|
|
3178
3178
|
}
|
|
3179
3179
|
break;
|
|
3180
3180
|
}
|
|
3181
3181
|
case 4: {
|
|
3182
3182
|
if (a === 37) {
|
|
3183
|
-
|
|
3183
|
+
i.neckPose.push(t.float());
|
|
3184
3184
|
continue;
|
|
3185
3185
|
}
|
|
3186
3186
|
if (a === 34) {
|
|
3187
3187
|
const s = t.uint32() + t.pos;
|
|
3188
3188
|
for (; t.pos < s; )
|
|
3189
|
-
|
|
3189
|
+
i.neckPose.push(t.float());
|
|
3190
3190
|
continue;
|
|
3191
3191
|
}
|
|
3192
3192
|
break;
|
|
3193
3193
|
}
|
|
3194
3194
|
case 5: {
|
|
3195
3195
|
if (a === 45) {
|
|
3196
|
-
|
|
3196
|
+
i.jawPose.push(t.float());
|
|
3197
3197
|
continue;
|
|
3198
3198
|
}
|
|
3199
3199
|
if (a === 42) {
|
|
3200
3200
|
const s = t.uint32() + t.pos;
|
|
3201
3201
|
for (; t.pos < s; )
|
|
3202
|
-
|
|
3202
|
+
i.jawPose.push(t.float());
|
|
3203
3203
|
continue;
|
|
3204
3204
|
}
|
|
3205
3205
|
break;
|
|
3206
3206
|
}
|
|
3207
3207
|
case 6: {
|
|
3208
3208
|
if (a === 53) {
|
|
3209
|
-
|
|
3209
|
+
i.eyePose.push(t.float());
|
|
3210
3210
|
continue;
|
|
3211
3211
|
}
|
|
3212
3212
|
if (a === 50) {
|
|
3213
3213
|
const s = t.uint32() + t.pos;
|
|
3214
3214
|
for (; t.pos < s; )
|
|
3215
|
-
|
|
3215
|
+
i.eyePose.push(t.float());
|
|
3216
3216
|
continue;
|
|
3217
3217
|
}
|
|
3218
3218
|
break;
|
|
3219
3219
|
}
|
|
3220
3220
|
case 7: {
|
|
3221
3221
|
if (a === 61) {
|
|
3222
|
-
|
|
3222
|
+
i.eyeLid.push(t.float());
|
|
3223
3223
|
continue;
|
|
3224
3224
|
}
|
|
3225
3225
|
if (a === 58) {
|
|
3226
3226
|
const s = t.uint32() + t.pos;
|
|
3227
3227
|
for (; t.pos < s; )
|
|
3228
|
-
|
|
3228
|
+
i.eyeLid.push(t.float());
|
|
3229
3229
|
continue;
|
|
3230
3230
|
}
|
|
3231
3231
|
break;
|
|
3232
3232
|
}
|
|
3233
3233
|
case 8: {
|
|
3234
3234
|
if (a === 69) {
|
|
3235
|
-
|
|
3235
|
+
i.expression.push(t.float());
|
|
3236
3236
|
continue;
|
|
3237
3237
|
}
|
|
3238
3238
|
if (a === 66) {
|
|
3239
3239
|
const s = t.uint32() + t.pos;
|
|
3240
3240
|
for (; t.pos < s; )
|
|
3241
|
-
|
|
3241
|
+
i.expression.push(t.float());
|
|
3242
3242
|
continue;
|
|
3243
3243
|
}
|
|
3244
3244
|
break;
|
|
@@ -3248,7 +3248,7 @@ const ge = {
|
|
|
3248
3248
|
break;
|
|
3249
3249
|
t.skip(a & 7);
|
|
3250
3250
|
}
|
|
3251
|
-
return
|
|
3251
|
+
return i;
|
|
3252
3252
|
},
|
|
3253
3253
|
fromJSON(r) {
|
|
3254
3254
|
return {
|
|
@@ -3262,17 +3262,17 @@ const ge = {
|
|
|
3262
3262
|
};
|
|
3263
3263
|
},
|
|
3264
3264
|
toJSON(r) {
|
|
3265
|
-
var t,
|
|
3265
|
+
var t, n, i, a, s, o, l;
|
|
3266
3266
|
const e = {};
|
|
3267
|
-
return (t = r.translation) != null && t.length && (e.translation = r.translation), (
|
|
3267
|
+
return (t = r.translation) != null && t.length && (e.translation = r.translation), (n = r.rotation) != null && n.length && (e.rotation = r.rotation), (i = r.neckPose) != null && i.length && (e.neckPose = r.neckPose), (a = r.jawPose) != null && a.length && (e.jawPose = r.jawPose), (s = r.eyePose) != null && s.length && (e.eyePose = r.eyePose), (o = r.eyeLid) != null && o.length && (e.eyeLid = r.eyeLid), (l = r.expression) != null && l.length && (e.expression = r.expression), e;
|
|
3268
3268
|
},
|
|
3269
3269
|
create(r) {
|
|
3270
3270
|
return ge.fromPartial(r ?? {});
|
|
3271
3271
|
},
|
|
3272
3272
|
fromPartial(r) {
|
|
3273
|
-
var t,
|
|
3273
|
+
var t, n, i, a, s, o, l;
|
|
3274
3274
|
const e = Vt();
|
|
3275
|
-
return e.translation = ((t = r.translation) == null ? void 0 : t.map((m) => m)) || [], e.rotation = ((
|
|
3275
|
+
return e.translation = ((t = r.translation) == null ? void 0 : t.map((m) => m)) || [], e.rotation = ((n = r.rotation) == null ? void 0 : n.map((m) => m)) || [], e.neckPose = ((i = r.neckPose) == null ? void 0 : i.map((m) => m)) || [], e.jawPose = ((a = r.jawPose) == null ? void 0 : a.map((m) => m)) || [], e.eyePose = ((s = r.eyePose) == null ? void 0 : s.map((m) => m)) || [], e.eyeLid = ((o = r.eyeLid) == null ? void 0 : o.map((m) => m)) || [], e.expression = ((l = r.expression) == null ? void 0 : l.map((m) => m)) || [], e;
|
|
3276
3276
|
}
|
|
3277
3277
|
};
|
|
3278
3278
|
function zt() {
|
|
@@ -3286,15 +3286,15 @@ const ve = {
|
|
|
3286
3286
|
},
|
|
3287
3287
|
decode(r, e) {
|
|
3288
3288
|
const t = r instanceof z ? r : new z(r);
|
|
3289
|
-
let
|
|
3290
|
-
const
|
|
3291
|
-
for (; t.pos <
|
|
3289
|
+
let n = e === void 0 ? t.len : t.pos + e;
|
|
3290
|
+
const i = zt();
|
|
3291
|
+
for (; t.pos < n; ) {
|
|
3292
3292
|
const a = t.uint32();
|
|
3293
3293
|
switch (a >>> 3) {
|
|
3294
3294
|
case 1: {
|
|
3295
3295
|
if (a !== 10)
|
|
3296
3296
|
break;
|
|
3297
|
-
|
|
3297
|
+
i.keyframes.push(ge.decode(t, t.uint32()));
|
|
3298
3298
|
continue;
|
|
3299
3299
|
}
|
|
3300
3300
|
}
|
|
@@ -3302,7 +3302,7 @@ const ve = {
|
|
|
3302
3302
|
break;
|
|
3303
3303
|
t.skip(a & 7);
|
|
3304
3304
|
}
|
|
3305
|
-
return
|
|
3305
|
+
return i;
|
|
3306
3306
|
},
|
|
3307
3307
|
fromJSON(r) {
|
|
3308
3308
|
return {
|
|
@@ -3312,7 +3312,7 @@ const ve = {
|
|
|
3312
3312
|
toJSON(r) {
|
|
3313
3313
|
var t;
|
|
3314
3314
|
const e = {};
|
|
3315
|
-
return (t = r.keyframes) != null && t.length && (e.keyframes = r.keyframes.map((
|
|
3315
|
+
return (t = r.keyframes) != null && t.length && (e.keyframes = r.keyframes.map((n) => ge.toJSON(n))), e;
|
|
3316
3316
|
},
|
|
3317
3317
|
create(r) {
|
|
3318
3318
|
return ve.fromPartial(r ?? {});
|
|
@@ -3320,7 +3320,7 @@ const ve = {
|
|
|
3320
3320
|
fromPartial(r) {
|
|
3321
3321
|
var t;
|
|
3322
3322
|
const e = zt();
|
|
3323
|
-
return e.keyframes = ((t = r.keyframes) == null ? void 0 : t.map((
|
|
3323
|
+
return e.keyframes = ((t = r.keyframes) == null ? void 0 : t.map((n) => ge.fromPartial(n))) || [], e;
|
|
3324
3324
|
}
|
|
3325
3325
|
};
|
|
3326
3326
|
function $t() {
|
|
@@ -3332,21 +3332,21 @@ const ye = {
|
|
|
3332
3332
|
},
|
|
3333
3333
|
decode(r, e) {
|
|
3334
3334
|
const t = r instanceof z ? r : new z(r);
|
|
3335
|
-
let
|
|
3336
|
-
const
|
|
3337
|
-
for (; t.pos <
|
|
3335
|
+
let n = e === void 0 ? t.len : t.pos + e;
|
|
3336
|
+
const i = $t();
|
|
3337
|
+
for (; t.pos < n; ) {
|
|
3338
3338
|
const a = t.uint32();
|
|
3339
3339
|
switch (a >>> 3) {
|
|
3340
3340
|
case 1: {
|
|
3341
3341
|
if (a !== 10)
|
|
3342
3342
|
break;
|
|
3343
|
-
|
|
3343
|
+
i.reqId = t.string();
|
|
3344
3344
|
continue;
|
|
3345
3345
|
}
|
|
3346
3346
|
case 2: {
|
|
3347
3347
|
if (a !== 18)
|
|
3348
3348
|
break;
|
|
3349
|
-
|
|
3349
|
+
i.animation = ve.decode(t, t.uint32());
|
|
3350
3350
|
continue;
|
|
3351
3351
|
}
|
|
3352
3352
|
}
|
|
@@ -3354,7 +3354,7 @@ const ye = {
|
|
|
3354
3354
|
break;
|
|
3355
3355
|
t.skip(a & 7);
|
|
3356
3356
|
}
|
|
3357
|
-
return
|
|
3357
|
+
return i;
|
|
3358
3358
|
},
|
|
3359
3359
|
fromJSON(r) {
|
|
3360
3360
|
return {
|
|
@@ -3383,27 +3383,27 @@ const we = {
|
|
|
3383
3383
|
},
|
|
3384
3384
|
decode(r, e) {
|
|
3385
3385
|
const t = r instanceof z ? r : new z(r);
|
|
3386
|
-
let
|
|
3387
|
-
const
|
|
3388
|
-
for (; t.pos <
|
|
3386
|
+
let n = e === void 0 ? t.len : t.pos + e;
|
|
3387
|
+
const i = Wt();
|
|
3388
|
+
for (; t.pos < n; ) {
|
|
3389
3389
|
const a = t.uint32();
|
|
3390
3390
|
switch (a >>> 3) {
|
|
3391
3391
|
case 1: {
|
|
3392
3392
|
if (a !== 10)
|
|
3393
3393
|
break;
|
|
3394
|
-
|
|
3394
|
+
i.reqId = t.string();
|
|
3395
3395
|
continue;
|
|
3396
3396
|
}
|
|
3397
3397
|
case 2: {
|
|
3398
3398
|
if (a !== 16)
|
|
3399
3399
|
break;
|
|
3400
|
-
|
|
3400
|
+
i.code = t.int32();
|
|
3401
3401
|
continue;
|
|
3402
3402
|
}
|
|
3403
3403
|
case 3: {
|
|
3404
3404
|
if (a !== 26)
|
|
3405
3405
|
break;
|
|
3406
|
-
|
|
3406
|
+
i.reason = t.string();
|
|
3407
3407
|
continue;
|
|
3408
3408
|
}
|
|
3409
3409
|
}
|
|
@@ -3411,7 +3411,7 @@ const we = {
|
|
|
3411
3411
|
break;
|
|
3412
3412
|
t.skip(a & 7);
|
|
3413
3413
|
}
|
|
3414
|
-
return
|
|
3414
|
+
return i;
|
|
3415
3415
|
},
|
|
3416
3416
|
fromJSON(r) {
|
|
3417
3417
|
return {
|
|
@@ -3441,33 +3441,33 @@ const Ye = {
|
|
|
3441
3441
|
},
|
|
3442
3442
|
decode(r, e) {
|
|
3443
3443
|
const t = r instanceof z ? r : new z(r);
|
|
3444
|
-
let
|
|
3445
|
-
const
|
|
3446
|
-
for (; t.pos <
|
|
3444
|
+
let n = e === void 0 ? t.len : t.pos + e;
|
|
3445
|
+
const i = Gt();
|
|
3446
|
+
for (; t.pos < n; ) {
|
|
3447
3447
|
const a = t.uint32();
|
|
3448
3448
|
switch (a >>> 3) {
|
|
3449
3449
|
case 1: {
|
|
3450
3450
|
if (a !== 8)
|
|
3451
3451
|
break;
|
|
3452
|
-
|
|
3452
|
+
i.type = t.int32();
|
|
3453
3453
|
continue;
|
|
3454
3454
|
}
|
|
3455
3455
|
case 2: {
|
|
3456
3456
|
if (a !== 18)
|
|
3457
3457
|
break;
|
|
3458
|
-
|
|
3458
|
+
i.error = we.decode(t, t.uint32());
|
|
3459
3459
|
continue;
|
|
3460
3460
|
}
|
|
3461
3461
|
case 3: {
|
|
3462
3462
|
if (a !== 26)
|
|
3463
3463
|
break;
|
|
3464
|
-
|
|
3464
|
+
i.serverResponseAnimation = ye.decode(t, t.uint32());
|
|
3465
3465
|
continue;
|
|
3466
3466
|
}
|
|
3467
3467
|
case 4: {
|
|
3468
3468
|
if (a !== 34)
|
|
3469
3469
|
break;
|
|
3470
|
-
|
|
3470
|
+
i.clientAudioInput = pe.decode(t, t.uint32());
|
|
3471
3471
|
continue;
|
|
3472
3472
|
}
|
|
3473
3473
|
}
|
|
@@ -3475,11 +3475,11 @@ const Ye = {
|
|
|
3475
3475
|
break;
|
|
3476
3476
|
t.skip(a & 7);
|
|
3477
3477
|
}
|
|
3478
|
-
return
|
|
3478
|
+
return i;
|
|
3479
3479
|
},
|
|
3480
3480
|
fromJSON(r) {
|
|
3481
3481
|
return {
|
|
3482
|
-
type: $(r.type) ?
|
|
3482
|
+
type: $(r.type) ? Li(r.type) : 0,
|
|
3483
3483
|
error: $(r.error) ? we.fromJSON(r.error) : void 0,
|
|
3484
3484
|
serverResponseAnimation: $(r.serverResponseAnimation) ? ye.fromJSON(r.serverResponseAnimation) : void 0,
|
|
3485
3485
|
clientAudioInput: $(r.clientAudioInput) ? pe.fromJSON(r.clientAudioInput) : void 0
|
|
@@ -3487,7 +3487,7 @@ const Ye = {
|
|
|
3487
3487
|
},
|
|
3488
3488
|
toJSON(r) {
|
|
3489
3489
|
const e = {};
|
|
3490
|
-
return r.type !== 0 && (e.type =
|
|
3490
|
+
return r.type !== 0 && (e.type = Ri(r.type)), r.error !== void 0 && (e.error = we.toJSON(r.error)), r.serverResponseAnimation !== void 0 && (e.serverResponseAnimation = ye.toJSON(r.serverResponseAnimation)), r.clientAudioInput !== void 0 && (e.clientAudioInput = pe.toJSON(r.clientAudioInput)), e;
|
|
3491
3491
|
},
|
|
3492
3492
|
create(r) {
|
|
3493
3493
|
return Ye.fromPartial(r ?? {});
|
|
@@ -3497,13 +3497,13 @@ const Ye = {
|
|
|
3497
3497
|
return e.type = r.type ?? 0, e.error = r.error !== void 0 && r.error !== null ? we.fromPartial(r.error) : void 0, e.serverResponseAnimation = r.serverResponseAnimation !== void 0 && r.serverResponseAnimation !== null ? ye.fromPartial(r.serverResponseAnimation) : void 0, e.clientAudioInput = r.clientAudioInput !== void 0 && r.clientAudioInput !== null ? pe.fromPartial(r.clientAudioInput) : void 0, e;
|
|
3498
3498
|
}
|
|
3499
3499
|
};
|
|
3500
|
-
function
|
|
3500
|
+
function Di(r) {
|
|
3501
3501
|
const e = globalThis.atob(r), t = new Uint8Array(e.length);
|
|
3502
|
-
for (let
|
|
3503
|
-
t[
|
|
3502
|
+
for (let n = 0; n < e.length; ++n)
|
|
3503
|
+
t[n] = e.charCodeAt(n);
|
|
3504
3504
|
return t;
|
|
3505
3505
|
}
|
|
3506
|
-
function
|
|
3506
|
+
function Bi(r) {
|
|
3507
3507
|
const e = [];
|
|
3508
3508
|
return r.forEach((t) => {
|
|
3509
3509
|
e.push(globalThis.String.fromCharCode(t));
|
|
@@ -3512,7 +3512,7 @@ function Bn(r) {
|
|
|
3512
3512
|
function $(r) {
|
|
3513
3513
|
return r != null;
|
|
3514
3514
|
}
|
|
3515
|
-
class
|
|
3515
|
+
class Oi {
|
|
3516
3516
|
constructor() {
|
|
3517
3517
|
u(this, "events", /* @__PURE__ */ new Map());
|
|
3518
3518
|
}
|
|
@@ -3520,19 +3520,19 @@ class On {
|
|
|
3520
3520
|
this.events.has(e) || this.events.set(e, /* @__PURE__ */ new Set()), this.events.get(e).add(t);
|
|
3521
3521
|
}
|
|
3522
3522
|
off(e, t) {
|
|
3523
|
-
const
|
|
3524
|
-
|
|
3523
|
+
const n = this.events.get(e);
|
|
3524
|
+
n && (n.delete(t), n.size === 0 && this.events.delete(e));
|
|
3525
3525
|
}
|
|
3526
3526
|
// eslint-disable-next-line ts/no-explicit-any
|
|
3527
3527
|
emit(e, ...t) {
|
|
3528
|
-
const
|
|
3529
|
-
|
|
3528
|
+
const n = this.events.get(e);
|
|
3529
|
+
n && n.forEach((i) => i(...t));
|
|
3530
3530
|
}
|
|
3531
3531
|
removeAllListeners(e) {
|
|
3532
3532
|
e ? this.events.delete(e) : this.events.clear();
|
|
3533
3533
|
}
|
|
3534
3534
|
}
|
|
3535
|
-
class
|
|
3535
|
+
class Ni extends Oi {
|
|
3536
3536
|
constructor(t) {
|
|
3537
3537
|
super();
|
|
3538
3538
|
u(this, "wsUrl");
|
|
@@ -3562,16 +3562,16 @@ class Nn extends On {
|
|
|
3562
3562
|
}
|
|
3563
3563
|
try {
|
|
3564
3564
|
this.isConnecting = !0, this.currentCharacterId = t, k.generateConnectionId();
|
|
3565
|
-
const
|
|
3566
|
-
d.log("[AnimationWebSocketClient] Connecting to:",
|
|
3567
|
-
} catch (
|
|
3565
|
+
const n = this.buildWebSocketUrl(t);
|
|
3566
|
+
d.log("[AnimationWebSocketClient] Connecting to:", n), await this.connectWebSocket(n), d.log("[AnimationWebSocketClient] Connected successfully");
|
|
3567
|
+
} catch (n) {
|
|
3568
3568
|
this.isConnecting = !1;
|
|
3569
|
-
const
|
|
3570
|
-
throw d.error("[AnimationWebSocketClient] Connection failed:",
|
|
3569
|
+
const i = n instanceof Error ? n.message : String(n);
|
|
3570
|
+
throw d.error("[AnimationWebSocketClient] Connection failed:", i), C("character_animation_service", "error", {
|
|
3571
3571
|
characterId: t,
|
|
3572
3572
|
event: "connect_failed",
|
|
3573
|
-
reason:
|
|
3574
|
-
}),
|
|
3573
|
+
reason: i
|
|
3574
|
+
}), n;
|
|
3575
3575
|
}
|
|
3576
3576
|
}
|
|
3577
3577
|
/**
|
|
@@ -3584,7 +3584,7 @@ class Nn extends On {
|
|
|
3584
3584
|
* 发送音频数据
|
|
3585
3585
|
* @param conversationId - 会话ID(在 protobuf 协议中映射为 reqId 字段)
|
|
3586
3586
|
*/
|
|
3587
|
-
sendAudioData(t,
|
|
3587
|
+
sendAudioData(t, n, i) {
|
|
3588
3588
|
if (!this.ws || this.ws.readyState !== WebSocket.OPEN)
|
|
3589
3589
|
return d.error("[AnimationWebSocketClient] WebSocket not connected"), !1;
|
|
3590
3590
|
try {
|
|
@@ -3593,8 +3593,8 @@ class Nn extends On {
|
|
|
3593
3593
|
clientAudioInput: {
|
|
3594
3594
|
reqId: t,
|
|
3595
3595
|
// protobuf 协议中使用 reqId 字段名
|
|
3596
|
-
audio: new Uint8Array(
|
|
3597
|
-
end:
|
|
3596
|
+
audio: new Uint8Array(n),
|
|
3597
|
+
end: i
|
|
3598
3598
|
}
|
|
3599
3599
|
}, s = new fe();
|
|
3600
3600
|
Ye.encode(a, s);
|
|
@@ -3631,16 +3631,16 @@ class Nn extends On {
|
|
|
3631
3631
|
}
|
|
3632
3632
|
// ========== 私有方法 ==========
|
|
3633
3633
|
buildWebSocketUrl(t) {
|
|
3634
|
-
const
|
|
3635
|
-
|
|
3636
|
-
const
|
|
3637
|
-
return
|
|
3634
|
+
const n = new URL(this.wsUrl);
|
|
3635
|
+
n.searchParams.set("id", t), this.jwtToken && n.searchParams.set("token", this.jwtToken), this.appId && n.searchParams.set("appId", this.appId), this.clientId && n.searchParams.set("client_id", this.clientId);
|
|
3636
|
+
const i = k.getConnectionId();
|
|
3637
|
+
return i && n.searchParams.set("connection_id", i), n.toString();
|
|
3638
3638
|
}
|
|
3639
3639
|
connectWebSocket(t) {
|
|
3640
|
-
return new Promise((
|
|
3640
|
+
return new Promise((n, i) => {
|
|
3641
3641
|
try {
|
|
3642
3642
|
this.ws = new WebSocket(t), this.ws.onopen = () => {
|
|
3643
|
-
this.isConnecting = !1, this.currentRetryCount = 0, this.isManuallyDisconnected = !1, this.emit("connected"),
|
|
3643
|
+
this.isConnecting = !1, this.currentRetryCount = 0, this.isManuallyDisconnected = !1, this.emit("connected"), n();
|
|
3644
3644
|
}, this.ws.onmessage = (a) => {
|
|
3645
3645
|
a.data instanceof ArrayBuffer ? this.handleMessage(a.data) : a.data instanceof Blob ? a.data.arrayBuffer().then(this.handleMessage.bind(this)).catch((s) => {
|
|
3646
3646
|
d.error("[AnimationWebSocketClient] Failed to convert Blob to ArrayBuffer:", s), C("character_animation_service", "error", {
|
|
@@ -3661,41 +3661,41 @@ class Nn extends On {
|
|
|
3661
3661
|
}), !this.isManuallyDisconnected && this.currentRetryCount < this.reconnectAttempts && this.scheduleReconnect();
|
|
3662
3662
|
};
|
|
3663
3663
|
} catch (a) {
|
|
3664
|
-
this.isConnecting = !1,
|
|
3664
|
+
this.isConnecting = !1, i(a);
|
|
3665
3665
|
}
|
|
3666
3666
|
});
|
|
3667
3667
|
}
|
|
3668
3668
|
handleMessage(t) {
|
|
3669
3669
|
try {
|
|
3670
|
-
const
|
|
3671
|
-
if (
|
|
3672
|
-
d.error(`[AnimationWebSocketClient] Server error: reqId=${
|
|
3670
|
+
const n = new z(new Uint8Array(t)), i = Ye.decode(n);
|
|
3671
|
+
if (i.error) {
|
|
3672
|
+
d.error(`[AnimationWebSocketClient] Server error: reqId=${i.error.reqId}, code=${i.error.code}, reason=${i.error.reason}`), this.emit("error", new Error(i.error.reason || "Server error"));
|
|
3673
3673
|
return;
|
|
3674
3674
|
}
|
|
3675
|
-
if (
|
|
3675
|
+
if (i.type === Ee.MESSAGE_ERROR) {
|
|
3676
3676
|
d.warn("[AnimationWebSocketClient] MESSAGE_ERROR received but no error field in message"), C("character_animation_service", "warning", {
|
|
3677
3677
|
characterId: this.currentCharacterId,
|
|
3678
3678
|
event: "message_error_without_payload"
|
|
3679
3679
|
}), this.emit("error", new Error("Server returned error message without error details"));
|
|
3680
3680
|
return;
|
|
3681
3681
|
}
|
|
3682
|
-
this.emit("message",
|
|
3683
|
-
} catch (
|
|
3684
|
-
const
|
|
3685
|
-
d.error("[AnimationWebSocketClient] Failed to decode message:",
|
|
3682
|
+
this.emit("message", i);
|
|
3683
|
+
} catch (n) {
|
|
3684
|
+
const i = n instanceof Error ? n.message : String(n);
|
|
3685
|
+
d.error("[AnimationWebSocketClient] Failed to decode message:", i), this.emit("error", n);
|
|
3686
3686
|
}
|
|
3687
3687
|
}
|
|
3688
3688
|
scheduleReconnect() {
|
|
3689
3689
|
this.reconnectTimer && clearTimeout(this.reconnectTimer), this.currentRetryCount++;
|
|
3690
3690
|
const t = Math.min(1e3 * Math.pow(2, this.currentRetryCount - 1), 3e4);
|
|
3691
3691
|
d.log(`[AnimationWebSocketClient] Scheduling reconnect attempt ${this.currentRetryCount}/${this.reconnectAttempts} in ${t}ms`), this.reconnectTimer = window.setTimeout(() => {
|
|
3692
|
-
!this.isManuallyDisconnected && this.currentCharacterId && (this.emit("reconnecting", `Reconnect attempt ${this.currentRetryCount}`), this.connect(this.currentCharacterId).catch((
|
|
3693
|
-
d.error("[AnimationWebSocketClient] Reconnect failed:",
|
|
3692
|
+
!this.isManuallyDisconnected && this.currentCharacterId && (this.emit("reconnecting", `Reconnect attempt ${this.currentRetryCount}`), this.connect(this.currentCharacterId).catch((n) => {
|
|
3693
|
+
d.error("[AnimationWebSocketClient] Reconnect failed:", n instanceof Error ? n.message : String(n));
|
|
3694
3694
|
}));
|
|
3695
3695
|
}, t);
|
|
3696
3696
|
}
|
|
3697
3697
|
}
|
|
3698
|
-
class
|
|
3698
|
+
class Ui {
|
|
3699
3699
|
// 避免并发连接
|
|
3700
3700
|
constructor(e) {
|
|
3701
3701
|
u(this, "wsClient");
|
|
@@ -3709,7 +3709,7 @@ class Un {
|
|
|
3709
3709
|
u(this, "isConnecting", !1);
|
|
3710
3710
|
this.dataController = e;
|
|
3711
3711
|
const t = L.getEnvironmentConfig();
|
|
3712
|
-
this.wsClient = new
|
|
3712
|
+
this.wsClient = new Ni({
|
|
3713
3713
|
wsUrl: t.driveningressWsUrl,
|
|
3714
3714
|
reconnectAttempts: 5,
|
|
3715
3715
|
jwtToken: L.sessionToken || void 0,
|
|
@@ -3724,26 +3724,26 @@ class Un {
|
|
|
3724
3724
|
var s, o, l, m;
|
|
3725
3725
|
if (this.isConnecting)
|
|
3726
3726
|
throw d.warn("[NetworkLayer] Connection already in progress, waiting for current connection to complete"), new X("Connection already in progress", "CONNECTION_IN_PROGRESS");
|
|
3727
|
-
(o = (s = this.dataController).onConnectionState) == null || o.call(s,
|
|
3727
|
+
(o = (s = this.dataController).onConnectionState) == null || o.call(s, ie.connecting), this.isFallbackMode = !1, this.setupWebSocketListeners(), this.isConnecting = !0;
|
|
3728
3728
|
const t = 15e3;
|
|
3729
|
-
let
|
|
3730
|
-
const
|
|
3731
|
-
|
|
3729
|
+
let n = null;
|
|
3730
|
+
const i = this.wsClient.connect(e), a = new Promise((c) => {
|
|
3731
|
+
n = setTimeout(() => {
|
|
3732
3732
|
var h, p;
|
|
3733
3733
|
this.dataController.connected || (this.isFallbackMode = !0, d.warn(`[NetworkLayer] WebSocket connection timeout (${t}ms) - entering fallback mode`), C("character_manager", "warning", {
|
|
3734
3734
|
characterId: this.dataController.getAvatarId(),
|
|
3735
3735
|
event: "websocket_connection_timeout_fallback",
|
|
3736
3736
|
timeoutMs: t
|
|
3737
|
-
}), (p = (h = this.dataController).onConnectionState) == null || p.call(h,
|
|
3737
|
+
}), (p = (h = this.dataController).onConnectionState) == null || p.call(h, ie.failed)), c();
|
|
3738
3738
|
}, t);
|
|
3739
3739
|
});
|
|
3740
3740
|
try {
|
|
3741
|
-
await Promise.race([
|
|
3741
|
+
await Promise.race([i, a]), n && clearTimeout(n);
|
|
3742
3742
|
} catch (c) {
|
|
3743
|
-
throw
|
|
3743
|
+
throw n && clearTimeout(n), this.isFallbackMode || (this.isFallbackMode = !0, d.warn("[NetworkLayer] WebSocket connection failed - entering fallback mode"), C("character_manager", "warning", {
|
|
3744
3744
|
characterId: this.dataController.getAvatarId(),
|
|
3745
3745
|
event: "websocket_connection_failed_fallback"
|
|
3746
|
-
})), (m = (l = this.dataController).onConnectionState) == null || m.call(l,
|
|
3746
|
+
})), (m = (l = this.dataController).onConnectionState) == null || m.call(l, ie.failed), c;
|
|
3747
3747
|
} finally {
|
|
3748
3748
|
this.isConnecting = !1;
|
|
3749
3749
|
}
|
|
@@ -3766,11 +3766,11 @@ class Un {
|
|
|
3766
3766
|
event: "conversation_started",
|
|
3767
3767
|
conversationId: this.currentConversationId
|
|
3768
3768
|
}));
|
|
3769
|
-
const
|
|
3770
|
-
let
|
|
3771
|
-
|
|
3772
|
-
const a =
|
|
3773
|
-
if (a >= 2 &&
|
|
3769
|
+
const n = this.audioMetrics;
|
|
3770
|
+
let i = !1;
|
|
3771
|
+
n.startTimestamp === 0 && (n.startTimestamp = Date.now(), n.cachedStartTimestamp = String(n.startTimestamp), i = !0), n.accumulatedBytes += e.byteLength;
|
|
3772
|
+
const a = n.accumulatedBytes / this.audioBytesPerSecond;
|
|
3773
|
+
if (a >= 2 && n.tap2Timestamp === 0 && (n.tap2Timestamp = Date.now(), n.cachedTap2Timestamp = String(n.tap2Timestamp), i = !0), a >= 4 && n.tap4Timestamp === 0 && (n.tap4Timestamp = Date.now(), n.cachedTap4Timestamp = String(n.tap4Timestamp), i = !0), t && n.endTimestamp === 0 && (n.endTimestamp = Date.now(), n.cachedEndTimestamp = String(n.endTimestamp), i = !0), e.byteLength === 0 && !t && d.warn("[NetworkLayer] Warning: sending empty audio data (size=0, end=false)"), this.isFallbackMode) {
|
|
3774
3774
|
this.currentConversationId && (d.warn("[NetworkLayer] Fallback mode: skipping WebSocket send, triggering audio-only mode"), this.dataController.yieldFramesData([], this.currentConversationId));
|
|
3775
3775
|
return;
|
|
3776
3776
|
}
|
|
@@ -3782,7 +3782,7 @@ class Un {
|
|
|
3782
3782
|
});
|
|
3783
3783
|
return;
|
|
3784
3784
|
}
|
|
3785
|
-
|
|
3785
|
+
i && this.currentConversationId && this.reportDrivingLatency(this.currentConversationId);
|
|
3786
3786
|
}
|
|
3787
3787
|
/**
|
|
3788
3788
|
* 断开连接
|
|
@@ -3809,25 +3809,25 @@ class Un {
|
|
|
3809
3809
|
setupWebSocketListeners() {
|
|
3810
3810
|
this.wsClient.removeAllListeners(), this.wsClient.on("connected", () => {
|
|
3811
3811
|
var e, t;
|
|
3812
|
-
this.isFallbackMode = !1, this.dataController.setConnected(!0), (t = (e = this.dataController).onConnectionState) == null || t.call(e,
|
|
3812
|
+
this.isFallbackMode = !1, this.dataController.setConnected(!0), (t = (e = this.dataController).onConnectionState) == null || t.call(e, ie.connected), C("character_animation_service", "info", {
|
|
3813
3813
|
characterId: this.dataController.getAvatarId(),
|
|
3814
3814
|
event: "connected"
|
|
3815
3815
|
});
|
|
3816
3816
|
}), this.wsClient.on("disconnected", () => {
|
|
3817
3817
|
var e, t;
|
|
3818
|
-
this.dataController.setConnected(!1), k.clearConnectionId(), (t = (e = this.dataController).onConnectionState) == null || t.call(e,
|
|
3818
|
+
this.dataController.setConnected(!1), k.clearConnectionId(), (t = (e = this.dataController).onConnectionState) == null || t.call(e, ie.disconnected), C("character_animation_service", "warning", {
|
|
3819
3819
|
characterId: this.dataController.getAvatarId(),
|
|
3820
3820
|
event: "disconnected"
|
|
3821
3821
|
});
|
|
3822
3822
|
}), this.wsClient.on("reconnecting", () => {
|
|
3823
3823
|
}), this.wsClient.on("error", (e) => {
|
|
3824
|
-
var
|
|
3824
|
+
var n, i, a, s;
|
|
3825
3825
|
const t = e instanceof Error ? e.message : String(e);
|
|
3826
3826
|
d.error("[NetworkLayer] WebSocket error:", t), C("character_animation_service", "error", {
|
|
3827
3827
|
characterId: this.dataController.getAvatarId(),
|
|
3828
3828
|
event: "websocket_error",
|
|
3829
3829
|
reason: t
|
|
3830
|
-
}), (
|
|
3830
|
+
}), (i = (n = this.dataController).onConnectionState) == null || i.call(n, ie.failed), (s = (a = this.dataController).onError) == null || s.call(a, e);
|
|
3831
3831
|
}), this.wsClient.on("message", (e) => {
|
|
3832
3832
|
this.handleMessage(e);
|
|
3833
3833
|
});
|
|
@@ -3846,11 +3846,11 @@ class Un {
|
|
|
3846
3846
|
break;
|
|
3847
3847
|
}
|
|
3848
3848
|
} catch (t) {
|
|
3849
|
-
const
|
|
3850
|
-
d.error("[NetworkLayer] Failed to handle message:",
|
|
3849
|
+
const n = t instanceof Error ? t.message : String(t);
|
|
3850
|
+
d.error("[NetworkLayer] Failed to handle message:", n), C("character_manager", "error", {
|
|
3851
3851
|
characterId: this.dataController.getAvatarId(),
|
|
3852
3852
|
event: "handle_message_failed",
|
|
3853
|
-
reason:
|
|
3853
|
+
reason: n
|
|
3854
3854
|
});
|
|
3855
3855
|
}
|
|
3856
3856
|
}
|
|
@@ -3862,40 +3862,40 @@ class Un {
|
|
|
3862
3862
|
d.error("[NetworkLayer] Invalid animation message");
|
|
3863
3863
|
return;
|
|
3864
3864
|
}
|
|
3865
|
-
const { reqId: t, animation:
|
|
3866
|
-
if (!this.currentConversationId ||
|
|
3867
|
-
d.warn(`[NetworkLayer] Ignoring mismatched animation message - expected conversationId: ${this.currentConversationId}, received conversationId: ${
|
|
3865
|
+
const { reqId: t, animation: n } = e.serverResponseAnimation, i = t;
|
|
3866
|
+
if (!this.currentConversationId || i !== this.currentConversationId) {
|
|
3867
|
+
d.warn(`[NetworkLayer] Ignoring mismatched animation message - expected conversationId: ${this.currentConversationId}, received conversationId: ${i}`), C("character_manager", "warning", {
|
|
3868
3868
|
characterId: this.dataController.getAvatarId(),
|
|
3869
3869
|
event: "animation_conversationid_mismatch",
|
|
3870
3870
|
expectedConversationId: this.currentConversationId,
|
|
3871
|
-
receivedConversationId:
|
|
3871
|
+
receivedConversationId: i
|
|
3872
3872
|
});
|
|
3873
3873
|
return;
|
|
3874
3874
|
}
|
|
3875
|
-
if (
|
|
3876
|
-
const a =
|
|
3875
|
+
if (n != null && n.keyframes && n.keyframes.length > 0) {
|
|
3876
|
+
const a = n.keyframes;
|
|
3877
3877
|
try {
|
|
3878
|
-
this.dataController.yieldFramesData(a,
|
|
3878
|
+
this.dataController.yieldFramesData(a, i);
|
|
3879
3879
|
} catch (s) {
|
|
3880
3880
|
const o = s instanceof Error ? s.message : String(s);
|
|
3881
3881
|
d.error(`[NetworkLayer] Failed to yield animation data: ${o}`), C("yield_animation_failed", "error", {
|
|
3882
|
-
req_id:
|
|
3882
|
+
req_id: i,
|
|
3883
3883
|
description: o
|
|
3884
3884
|
});
|
|
3885
3885
|
}
|
|
3886
3886
|
this.dataController.getIsPlaying() || this.dataController.startStreamingPlayback(), this.audioMetrics.didRecvFirstFlame || (this.audioMetrics.didRecvFirstFlame = !0, this.audioMetrics.recvFirstFlameTimestamp = Date.now(), this.audioMetrics.cachedFirstFrameTimestamp = String(this.audioMetrics.recvFirstFlameTimestamp), this.currentConversationId && this.reportDrivingLatency(this.currentConversationId));
|
|
3887
3887
|
} else
|
|
3888
|
-
d.warn(`[NetworkLayer] Animation message has no animation data - conversationId: ${
|
|
3888
|
+
d.warn(`[NetworkLayer] Animation message has no animation data - conversationId: ${i}`), C("character_manager", "warning", {
|
|
3889
3889
|
characterId: this.dataController.getAvatarId(),
|
|
3890
3890
|
event: "animation_empty_keyframes",
|
|
3891
|
-
conversationId:
|
|
3891
|
+
conversationId: i
|
|
3892
3892
|
});
|
|
3893
3893
|
}
|
|
3894
3894
|
/**
|
|
3895
3895
|
* 处理错误消息
|
|
3896
3896
|
*/
|
|
3897
3897
|
handleErrorMessage(e) {
|
|
3898
|
-
var
|
|
3898
|
+
var i, a, s, o;
|
|
3899
3899
|
if (!e.error) {
|
|
3900
3900
|
d.warn("[NetworkLayer] MESSAGE_ERROR received but message.error is empty"), e.serverResponseAnimation && (d.warn("[NetworkLayer] MESSAGE_ERROR contains animation data, treating as animation message"), C("character_manager", "warning", {
|
|
3901
3901
|
characterId: this.dataController.getAvatarId(),
|
|
@@ -3909,11 +3909,11 @@ class Un {
|
|
|
3909
3909
|
con_id: k.getConnectionId() || "",
|
|
3910
3910
|
description: e.error.reason || `Server error: code=${e.error.code}`
|
|
3911
3911
|
});
|
|
3912
|
-
const
|
|
3913
|
-
(
|
|
3912
|
+
const n = ((i = e.error.code) == null ? void 0 : i.toString().toLowerCase()) ?? "";
|
|
3913
|
+
(n === "400" || n.includes("invalid")) && C("session_token_invalid", "warning", {
|
|
3914
3914
|
con_id: k.getConnectionId() || "",
|
|
3915
3915
|
description: e.error.reason || "Session token invalid"
|
|
3916
|
-
}), (
|
|
3916
|
+
}), (n.includes("unauth") || n === "401" || n.includes("expired")) && C("session_token_expired", "warning", {
|
|
3917
3917
|
con_id: k.getConnectionId() || "",
|
|
3918
3918
|
description: e.error.reason || "Session token expired"
|
|
3919
3919
|
}), (o = (s = this.dataController).onError) == null || o.call(s, new X(
|
|
@@ -3964,7 +3964,7 @@ class Un {
|
|
|
3964
3964
|
});
|
|
3965
3965
|
}
|
|
3966
3966
|
}
|
|
3967
|
-
class
|
|
3967
|
+
class Vi {
|
|
3968
3968
|
// 16kHz * 2 bytes per sample
|
|
3969
3969
|
constructor(e, t) {
|
|
3970
3970
|
// ========== Configuration and Composition ==========
|
|
@@ -4019,7 +4019,7 @@ class Vn {
|
|
|
4019
4019
|
cachedFirstFrameTimestamp: ""
|
|
4020
4020
|
});
|
|
4021
4021
|
u(this, "audioBytesPerSecond", 16e3 * 2);
|
|
4022
|
-
this.avatar = e, this.playbackMode = (t == null ? void 0 : t.playbackMode) ?? Y.sdk, this.playbackMode === Y.sdk && (this.networkLayer = new
|
|
4022
|
+
this.avatar = e, this.playbackMode = (t == null ? void 0 : t.playbackMode) ?? Y.sdk, this.playbackMode === Y.sdk && (this.networkLayer = new Ui(this));
|
|
4023
4023
|
}
|
|
4024
4024
|
// ========== Internal Accessors (for NetworkLayer and AvatarView) ==========
|
|
4025
4025
|
/**
|
|
@@ -4120,23 +4120,23 @@ class Vn {
|
|
|
4120
4120
|
* @returns conversationId - Conversation ID for this audio session
|
|
4121
4121
|
*/
|
|
4122
4122
|
send(e, t = !1) {
|
|
4123
|
-
var
|
|
4123
|
+
var i, a, s;
|
|
4124
4124
|
if (!this.networkLayer)
|
|
4125
|
-
return (
|
|
4125
|
+
return (i = this.onError) == null || i.call(this, new X("Network layer not available", "NETWORK_LAYER_NOT_AVAILABLE")), null;
|
|
4126
4126
|
if (!this.networkLayer.canSend())
|
|
4127
4127
|
return (a = this.onError) == null || a.call(this, new X("Service not connected", "NOT_CONNECTED")), C("character_manager", "warning", {
|
|
4128
4128
|
characterId: this.avatar.id,
|
|
4129
4129
|
event: "send_not_connected"
|
|
4130
4130
|
}), null;
|
|
4131
|
-
const
|
|
4132
|
-
return this.reqEnd && this.isPlaying &&
|
|
4131
|
+
const n = this.networkLayer.getCurrentConversationId();
|
|
4132
|
+
return this.reqEnd && this.isPlaying && n && this.interrupt(), this.addAudioChunkToBuffer(new Uint8Array(e), t), this.networkLayer.sendAudioData(e, t), t && (this.reqEnd = !0), !this.isPlaying && this.currentState === x.idle && (this.currentState = x.active, (s = this.onConversationState) == null || s.call(this, this.mapToConversationState(x.active))), this.networkLayer.getCurrentConversationId();
|
|
4133
4133
|
}
|
|
4134
4134
|
/**
|
|
4135
4135
|
* Close service (SDK mode only)
|
|
4136
4136
|
*/
|
|
4137
4137
|
close() {
|
|
4138
4138
|
var e;
|
|
4139
|
-
(this.isPlaying || this.currentState === x.paused) && this.stopPlayback(), this.clearPlaybackData(), this.networkLayer ? this.networkLayer.disconnect() : this.currentConversationId = null, this.reqEnd = !1, this.isConnected = !1, (e = this.onConnectionState) == null || e.call(this,
|
|
4139
|
+
(this.isPlaying || this.currentState === x.paused) && this.stopPlayback(), this.clearPlaybackData(), this.networkLayer ? this.networkLayer.disconnect() : this.currentConversationId = null, this.reqEnd = !1, this.isConnected = !1, (e = this.onConnectionState) == null || e.call(this, ie.disconnected);
|
|
4140
4140
|
}
|
|
4141
4141
|
// ========== Host Mode Interface ==========
|
|
4142
4142
|
/**
|
|
@@ -4162,7 +4162,7 @@ class Vn {
|
|
|
4162
4162
|
* @returns conversationId - Conversation ID for this audio session
|
|
4163
4163
|
*/
|
|
4164
4164
|
yieldAudioData(e, t = !1) {
|
|
4165
|
-
var
|
|
4165
|
+
var n, i;
|
|
4166
4166
|
if (this.reqEnd && this.isPlaying && this.currentConversationId && (this.interrupt(), this.currentConversationId = this.generateAndLogNewConversationId(), this.reqEnd = !1), this.currentConversationId || (this.isPlaying && this.interrupt(), this.currentConversationId = this.generateAndLogNewConversationId(), this.reqEnd = !1, this.clearPlaybackData()), t && (this.reqEnd = !0), this.playbackMode === Y.host) {
|
|
4167
4167
|
const a = this.hostModeMetrics;
|
|
4168
4168
|
let s = !1;
|
|
@@ -4170,7 +4170,7 @@ class Vn {
|
|
|
4170
4170
|
const o = a.accumulatedBytes / this.audioBytesPerSecond;
|
|
4171
4171
|
o >= 2 && a.tap2Timestamp === 0 && (a.tap2Timestamp = Date.now(), a.cachedTap2Timestamp = String(a.tap2Timestamp), s = !0), o >= 4 && a.tap4Timestamp === 0 && (a.tap4Timestamp = Date.now(), a.cachedTap4Timestamp = String(a.tap4Timestamp), s = !0), t && a.endTimestamp === 0 && (a.endTimestamp = Date.now(), a.cachedEndTimestamp = String(a.endTimestamp), s = !0), s && this.currentConversationId && this.reportDrivingLatency(this.currentConversationId);
|
|
4172
4172
|
}
|
|
4173
|
-
return this.isPlaying && ((
|
|
4173
|
+
return this.isPlaying && ((n = this.animationPlayer) != null && n.isStreamingReady()) ? this.animationPlayer.addAudioChunk(e, t) : (e.length > 0 || t) && (this.pendingAudioChunks.push({ data: e, isLast: t }), (i = this.onConversationState) == null || i.call(this, this.mapToConversationState(x.active))), this.currentConversationId;
|
|
4174
4174
|
}
|
|
4175
4175
|
/**
|
|
4176
4176
|
* Send animation keyframes (host mode or SDK mode)
|
|
@@ -4188,12 +4188,12 @@ class Vn {
|
|
|
4188
4188
|
});
|
|
4189
4189
|
return;
|
|
4190
4190
|
}
|
|
4191
|
-
const
|
|
4192
|
-
if (!
|
|
4193
|
-
d.warn(`[AvatarController] Ignoring mismatched animation data - expected conversationId: ${
|
|
4191
|
+
const n = this.getEffectiveConversationId();
|
|
4192
|
+
if (!n || t !== n) {
|
|
4193
|
+
d.warn(`[AvatarController] Ignoring mismatched animation data - expected conversationId: ${n}, received conversationId: ${t}`), C("character_manager", "warning", {
|
|
4194
4194
|
characterId: this.avatar.id,
|
|
4195
4195
|
event: "keyframes_conversationid_mismatch",
|
|
4196
|
-
expectedConversationId:
|
|
4196
|
+
expectedConversationId: n,
|
|
4197
4197
|
receivedConversationId: t
|
|
4198
4198
|
});
|
|
4199
4199
|
return;
|
|
@@ -4214,9 +4214,9 @@ class Vn {
|
|
|
4214
4214
|
}), this.enableAudioOnlyMode();
|
|
4215
4215
|
return;
|
|
4216
4216
|
}
|
|
4217
|
-
this.currentKeyframes.length === 0 ? (this.currentKeyframes = e, this.playbackMode === Y.host && !this.hostModeMetrics.didRecvFirstFlame && (this.hostModeMetrics.didRecvFirstFlame = !0, this.hostModeMetrics.recvFirstFlameTimestamp = Date.now(), this.hostModeMetrics.cachedFirstFrameTimestamp = String(this.hostModeMetrics.recvFirstFlameTimestamp), t && this.reportDrivingLatency(t))) : this.currentKeyframes.push(...e), this.emit("keyframesUpdate", this.currentKeyframes), !this.isPlaying && this.pendingAudioChunks.length > 0 && this.currentKeyframes.length > 0 && this.startStreamingPlayback().catch((
|
|
4217
|
+
this.currentKeyframes.length === 0 ? (this.currentKeyframes = e, this.playbackMode === Y.host && !this.hostModeMetrics.didRecvFirstFlame && (this.hostModeMetrics.didRecvFirstFlame = !0, this.hostModeMetrics.recvFirstFlameTimestamp = Date.now(), this.hostModeMetrics.cachedFirstFrameTimestamp = String(this.hostModeMetrics.recvFirstFlameTimestamp), t && this.reportDrivingLatency(t))) : this.currentKeyframes.push(...e), this.emit("keyframesUpdate", this.currentKeyframes), !this.isPlaying && this.pendingAudioChunks.length > 0 && this.currentKeyframes.length > 0 && this.startStreamingPlayback().catch((i) => {
|
|
4218
4218
|
var a;
|
|
4219
|
-
d.error("[AvatarController] Failed to auto-start playback:",
|
|
4219
|
+
d.error("[AvatarController] Failed to auto-start playback:", i), (a = this.onError) == null || a.call(this, new X("Failed to start playback", "PLAYBACK_START_FAILED"));
|
|
4220
4220
|
});
|
|
4221
4221
|
}
|
|
4222
4222
|
// ========== Common Interface ==========
|
|
@@ -4378,17 +4378,17 @@ class Vn {
|
|
|
4378
4378
|
* Start streaming playback (internal implementation)
|
|
4379
4379
|
*/
|
|
4380
4380
|
async startStreamingPlaybackInternal() {
|
|
4381
|
-
var e, t,
|
|
4381
|
+
var e, t, n;
|
|
4382
4382
|
if (this.animationPlayer || (this.animationPlayer = new ue()), !this.animationPlayer.isStreamingReady())
|
|
4383
4383
|
try {
|
|
4384
4384
|
await this.animationPlayer.createAndInitializeStreamingPlayer();
|
|
4385
|
-
} catch (
|
|
4386
|
-
const a =
|
|
4385
|
+
} catch (i) {
|
|
4386
|
+
const a = i instanceof Error ? i.message : String(i);
|
|
4387
4387
|
throw d.error("[AvatarController] Failed to create streaming player:", a), C("character_player", "error", {
|
|
4388
4388
|
characterId: this.avatar.id,
|
|
4389
4389
|
event: "streaming_player_init_failed",
|
|
4390
4390
|
reason: a
|
|
4391
|
-
}),
|
|
4391
|
+
}), i;
|
|
4392
4392
|
}
|
|
4393
4393
|
if (!this.currentKeyframes || this.currentKeyframes.length === 0) {
|
|
4394
4394
|
d.warn("[AvatarController] No animation data to play");
|
|
@@ -4403,15 +4403,15 @@ class Vn {
|
|
|
4403
4403
|
conversationId: ((s = this.networkLayer) == null ? void 0 : s.getCurrentConversationId()) || void 0
|
|
4404
4404
|
});
|
|
4405
4405
|
}), this.emit("startRendering");
|
|
4406
|
-
const
|
|
4407
|
-
|
|
4406
|
+
const i = this.animationPlayer.getStreamingPlayer();
|
|
4407
|
+
i && i.setAutoStart(!1), i && await i.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, this.currentState = x.playing, (e = this.onConversationState) == null || e.call(this, this.mapToConversationState(x.playing)), this.startPlaybackLoop(), C("character_player", "info", {
|
|
4408
4408
|
characterId: this.avatar.id,
|
|
4409
4409
|
event: "playback_started",
|
|
4410
4410
|
conversationId: ((t = this.networkLayer) == null ? void 0 : t.getCurrentConversationId()) || void 0
|
|
4411
4411
|
});
|
|
4412
|
-
} catch (
|
|
4413
|
-
const a =
|
|
4414
|
-
d.error("[AvatarController] Failed to start streaming playback:", a), (
|
|
4412
|
+
} catch (i) {
|
|
4413
|
+
const a = i instanceof Error ? i.message : String(i);
|
|
4414
|
+
d.error("[AvatarController] Failed to start streaming playback:", a), (n = this.onError) == null || n.call(this, new X("Failed to start streaming playback", "INIT_FAILED")), this.isPlaying = !1;
|
|
4415
4415
|
}
|
|
4416
4416
|
}
|
|
4417
4417
|
/**
|
|
@@ -4426,32 +4426,32 @@ class Vn {
|
|
|
4426
4426
|
return;
|
|
4427
4427
|
}
|
|
4428
4428
|
try {
|
|
4429
|
-
const
|
|
4430
|
-
if (
|
|
4429
|
+
const n = this.animationPlayer.getCurrentTime();
|
|
4430
|
+
if (n === 0) {
|
|
4431
4431
|
this.playbackLoopId = requestAnimationFrame(t);
|
|
4432
4432
|
return;
|
|
4433
4433
|
}
|
|
4434
|
-
let
|
|
4435
|
-
|
|
4436
|
-
let a =
|
|
4437
|
-
if (a < 0 && (a = 0), a >= this.currentKeyframes.length && (a = this.currentKeyframes.length - 1),
|
|
4434
|
+
let i = Math.floor(n * e);
|
|
4435
|
+
i < 0 && (i = 0);
|
|
4436
|
+
let a = i - this.keyframesOffset;
|
|
4437
|
+
if (a < 0 && (a = 0), a >= this.currentKeyframes.length && (a = this.currentKeyframes.length - 1), i === this.lastRenderedFrameIndex) {
|
|
4438
4438
|
this.playbackLoopId = requestAnimationFrame(t);
|
|
4439
4439
|
return;
|
|
4440
4440
|
}
|
|
4441
|
-
if (this.lastRenderedFrameIndex =
|
|
4442
|
-
const s = this.KEYFRAMES_CLEANUP_THRESHOLD, o =
|
|
4443
|
-
o > 0 && o <
|
|
4441
|
+
if (this.lastRenderedFrameIndex = i, this.currentKeyframes.length > this.MAX_KEYFRAMES) {
|
|
4442
|
+
const s = this.KEYFRAMES_CLEANUP_THRESHOLD, o = i - s;
|
|
4443
|
+
o > 0 && o < i && (this.currentKeyframes.splice(0, o), this.keyframesOffset += o, a = i - this.keyframesOffset, a < 0 && (a = 0), a >= this.currentKeyframes.length && (a = this.currentKeyframes.length - 1), d.log(`[AvatarController] Cleaned up ${o} old frames (kept ${this.currentKeyframes.length} frames, offset: ${this.keyframesOffset})`));
|
|
4444
4444
|
}
|
|
4445
4445
|
if (a >= 0 && a < this.currentKeyframes.length) {
|
|
4446
4446
|
const s = this.currentKeyframes[a], o = Jt(s), l = L.getAvatarCore();
|
|
4447
4447
|
if (l) {
|
|
4448
4448
|
const m = await l.computeFrameFlatFromParams(o, this.characterHandle ?? void 0);
|
|
4449
|
-
m && this.renderCallback && this.renderCallback(m,
|
|
4449
|
+
m && this.renderCallback && this.renderCallback(m, i);
|
|
4450
4450
|
}
|
|
4451
4451
|
}
|
|
4452
|
-
} catch (
|
|
4453
|
-
const
|
|
4454
|
-
d.error("[AvatarController] Playback loop error:",
|
|
4452
|
+
} catch (n) {
|
|
4453
|
+
const i = n instanceof Error ? n.message : String(n);
|
|
4454
|
+
d.error("[AvatarController] Playback loop error:", i);
|
|
4455
4455
|
}
|
|
4456
4456
|
this.isPlaying ? this.playbackLoopId = requestAnimationFrame(t) : this.playbackLoopId = null;
|
|
4457
4457
|
};
|
|
@@ -4484,32 +4484,32 @@ class Vn {
|
|
|
4484
4484
|
if (this.animationPlayer || (this.animationPlayer = new ue()), !this.animationPlayer.isStreamingReady())
|
|
4485
4485
|
try {
|
|
4486
4486
|
await this.animationPlayer.createAndInitializeStreamingPlayer();
|
|
4487
|
-
} catch (
|
|
4488
|
-
const
|
|
4489
|
-
throw d.error("[AvatarController] Failed to create streaming player for audio-only mode:",
|
|
4487
|
+
} catch (n) {
|
|
4488
|
+
const i = n instanceof Error ? n.message : String(n);
|
|
4489
|
+
throw d.error("[AvatarController] Failed to create streaming player for audio-only mode:", i), C("character_player", "error", {
|
|
4490
4490
|
characterId: this.avatar.id,
|
|
4491
4491
|
event: "audio_only_streaming_player_init_failed",
|
|
4492
|
-
reason:
|
|
4493
|
-
}),
|
|
4492
|
+
reason: i
|
|
4493
|
+
}), n;
|
|
4494
4494
|
}
|
|
4495
4495
|
try {
|
|
4496
4496
|
await this.animationPlayer.prepareStreamingPlayer(() => {
|
|
4497
|
-
var
|
|
4498
|
-
this.isPlaying = !1, this.currentState = x.idle, (
|
|
4497
|
+
var i;
|
|
4498
|
+
this.isPlaying = !1, this.currentState = x.idle, (i = this.onConversationState) == null || i.call(this, this.mapToConversationState(x.idle)), this.isAudioOnlyMode = !1, this.clearPlaybackData(), this.resetConversationIdState(), C("character_player", "info", {
|
|
4499
4499
|
characterId: this.avatar.id,
|
|
4500
4500
|
event: "audio_only_playback_ended",
|
|
4501
4501
|
conversationId: this.getEffectiveConversationId() || void 0
|
|
4502
4502
|
});
|
|
4503
4503
|
});
|
|
4504
|
-
const
|
|
4505
|
-
|
|
4504
|
+
const n = this.animationPlayer.getStreamingPlayer();
|
|
4505
|
+
n && n.setAutoStart(!0), n && await n.startNewSession(this.pendingAudioChunks), this.pendingAudioChunks = [], this.isPlaying = !0, this.currentState = x.playing, (e = this.onConversationState) == null || e.call(this, this.mapToConversationState(x.playing)), this.startAudioMonitoringLoop(), C("character_player", "info", {
|
|
4506
4506
|
characterId: this.avatar.id,
|
|
4507
4507
|
event: "audio_only_playback_started",
|
|
4508
4508
|
conversationId: this.getEffectiveConversationId() || void 0
|
|
4509
4509
|
});
|
|
4510
|
-
} catch (
|
|
4511
|
-
const
|
|
4512
|
-
throw d.error("[AvatarController] Failed to start audio-only playback:",
|
|
4510
|
+
} catch (n) {
|
|
4511
|
+
const i = n instanceof Error ? n.message : String(n);
|
|
4512
|
+
throw d.error("[AvatarController] Failed to start audio-only playback:", i), (t = this.onError) == null || t.call(this, new X("Failed to start audio-only playback", "AUDIO_ONLY_INIT_FAILED")), this.isPlaying = !1, this.isAudioOnlyMode = !1, n;
|
|
4513
4513
|
}
|
|
4514
4514
|
}
|
|
4515
4515
|
/**
|
|
@@ -4564,8 +4564,8 @@ class Vn {
|
|
|
4564
4564
|
* Emit event
|
|
4565
4565
|
*/
|
|
4566
4566
|
emit(e, t) {
|
|
4567
|
-
const
|
|
4568
|
-
|
|
4567
|
+
const n = this.eventListeners.get(e);
|
|
4568
|
+
n && n.forEach((i) => i(t));
|
|
4569
4569
|
}
|
|
4570
4570
|
/**
|
|
4571
4571
|
* 上报 driving_latency 事件(Host 模式)
|
|
@@ -4602,30 +4602,30 @@ function mr(r) {
|
|
|
4602
4602
|
}
|
|
4603
4603
|
return String(r);
|
|
4604
4604
|
}
|
|
4605
|
-
async function
|
|
4605
|
+
async function zi(r) {
|
|
4606
4606
|
try {
|
|
4607
|
-
const e = {}, t = L.appId,
|
|
4608
|
-
t && (e["X-App-Id"] = t),
|
|
4609
|
-
const
|
|
4607
|
+
const e = {}, t = L.appId, n = L.sessionToken;
|
|
4608
|
+
t && (e["X-App-Id"] = t), n && (e.Authorization = `Bearer ${n}`);
|
|
4609
|
+
const i = await fetch(r, {
|
|
4610
4610
|
headers: Object.keys(e).length > 0 ? e : void 0
|
|
4611
4611
|
});
|
|
4612
|
-
if (!
|
|
4613
|
-
throw new Error(`HTTP ${
|
|
4614
|
-
return await
|
|
4612
|
+
if (!i.ok)
|
|
4613
|
+
throw new Error(`HTTP ${i.status} ${i.statusText}`);
|
|
4614
|
+
return await i.arrayBuffer();
|
|
4615
4615
|
} catch (e) {
|
|
4616
4616
|
const t = mr(e);
|
|
4617
4617
|
throw new Error(`[downloadResource] ${r} → ${t}`);
|
|
4618
4618
|
}
|
|
4619
4619
|
}
|
|
4620
|
-
const $
|
|
4620
|
+
const $i = 50, le = /* @__PURE__ */ new Map();
|
|
4621
4621
|
async function Ge(r) {
|
|
4622
4622
|
const e = le.get(r);
|
|
4623
4623
|
if (e)
|
|
4624
4624
|
return le.delete(r), le.set(r, e), e;
|
|
4625
|
-
const t = await
|
|
4626
|
-
if (le.size >= $
|
|
4627
|
-
const
|
|
4628
|
-
|
|
4625
|
+
const t = await zi(r);
|
|
4626
|
+
if (le.size >= $i) {
|
|
4627
|
+
const n = le.keys().next().value;
|
|
4628
|
+
n && le.delete(n);
|
|
4629
4629
|
}
|
|
4630
4630
|
return le.set(r, t), t;
|
|
4631
4631
|
}
|
|
@@ -4643,7 +4643,7 @@ class pr {
|
|
|
4643
4643
|
if (!(e && Object.keys(e).length > 0))
|
|
4644
4644
|
return d.log("Template resources not provided in CharacterMeta, using global CDN config"), this.loadGlobalFlameResources(t);
|
|
4645
4645
|
d.log("Using template resources from CharacterMeta API");
|
|
4646
|
-
const
|
|
4646
|
+
const i = {
|
|
4647
4647
|
flameModel: {
|
|
4648
4648
|
url: (c = e.flameModel) == null ? void 0 : c.remote,
|
|
4649
4649
|
resourceName: "model.pb"
|
|
@@ -4660,7 +4660,7 @@ class pr {
|
|
|
4660
4660
|
url: (v = e.teethNpz) == null ? void 0 : v.remote,
|
|
4661
4661
|
resourceName: "teeth.npz"
|
|
4662
4662
|
}
|
|
4663
|
-
}, a = Object.keys(
|
|
4663
|
+
}, a = Object.keys(i).length;
|
|
4664
4664
|
let s = 0;
|
|
4665
4665
|
const o = (S, w) => {
|
|
4666
4666
|
t && (w && s++, t({
|
|
@@ -4670,7 +4670,7 @@ class pr {
|
|
|
4670
4670
|
total: a,
|
|
4671
4671
|
progress: Math.round(s / a * 100)
|
|
4672
4672
|
}));
|
|
4673
|
-
}, l = {}, m = Object.entries(
|
|
4673
|
+
}, l = {}, m = Object.entries(i).map(async ([S, { url: w, resourceName: b }]) => {
|
|
4674
4674
|
if (!w)
|
|
4675
4675
|
throw new Error(`[loadTemplateResources] Missing CDN URL for ${S} (${b})`);
|
|
4676
4676
|
o(b, !1), d.log(`📥 Loading ${S} from API CDN: ${w}`);
|
|
@@ -4682,27 +4682,27 @@ class pr {
|
|
|
4682
4682
|
/**
|
|
4683
4683
|
* Load global FLAME template resources from CDN
|
|
4684
4684
|
* Uses centralized FLAME CDN config (shared across all characters)
|
|
4685
|
-
* @internal 供
|
|
4685
|
+
* @internal 供 AvatarSDK 使用
|
|
4686
4686
|
*/
|
|
4687
4687
|
async loadGlobalFlameResources(e = null) {
|
|
4688
|
-
const { cdnBaseUrl: t, resources:
|
|
4688
|
+
const { cdnBaseUrl: t, resources: n } = M.flame, i = {
|
|
4689
4689
|
flameModel: {
|
|
4690
|
-
url: `${t}/${
|
|
4691
|
-
resourceName:
|
|
4690
|
+
url: `${t}/${n.flameModel}`,
|
|
4691
|
+
resourceName: n.flameModel
|
|
4692
4692
|
},
|
|
4693
4693
|
flameTemplate: {
|
|
4694
|
-
url: `${t}/${
|
|
4695
|
-
resourceName:
|
|
4694
|
+
url: `${t}/${n.flameTemplate}`,
|
|
4695
|
+
resourceName: n.flameTemplate
|
|
4696
4696
|
},
|
|
4697
4697
|
teethPb: {
|
|
4698
|
-
url: `${t}/${
|
|
4699
|
-
resourceName:
|
|
4698
|
+
url: `${t}/${n.teethPb}`,
|
|
4699
|
+
resourceName: n.teethPb
|
|
4700
4700
|
},
|
|
4701
4701
|
teethNpz: {
|
|
4702
|
-
url: `${t}/${
|
|
4703
|
-
resourceName:
|
|
4702
|
+
url: `${t}/${n.teethNpz}`,
|
|
4703
|
+
resourceName: n.teethNpz
|
|
4704
4704
|
}
|
|
4705
|
-
}, a = Object.keys(
|
|
4705
|
+
}, a = Object.keys(i).length;
|
|
4706
4706
|
let s = 0;
|
|
4707
4707
|
const o = (c, h) => {
|
|
4708
4708
|
e && (h && s++, e({
|
|
@@ -4712,7 +4712,7 @@ class pr {
|
|
|
4712
4712
|
total: a,
|
|
4713
4713
|
progress: Math.round(s / a * 100)
|
|
4714
4714
|
}));
|
|
4715
|
-
}, l = {}, m = Object.entries(
|
|
4715
|
+
}, l = {}, m = Object.entries(i).map(async ([c, { url: h, resourceName: p }]) => {
|
|
4716
4716
|
o(p, !1), d.log(`📥 Loading ${c} from global CDN: ${h}`);
|
|
4717
4717
|
const v = await Ge(h);
|
|
4718
4718
|
d.log(`✅ ${c} loaded: ${v.byteLength} bytes`), l[c] = v, o(p, !0);
|
|
@@ -4723,8 +4723,8 @@ class pr {
|
|
|
4723
4723
|
* Load camera settings from CharacterMeta (optional)
|
|
4724
4724
|
*/
|
|
4725
4725
|
async loadCameraSettings(e) {
|
|
4726
|
-
var
|
|
4727
|
-
const t = (
|
|
4726
|
+
var n, i;
|
|
4727
|
+
const t = (i = (n = e.camera) == null ? void 0 : n.resource) == null ? void 0 : i.remote;
|
|
4728
4728
|
if (!t) {
|
|
4729
4729
|
d.log("ℹ️ No camera resource URL provided");
|
|
4730
4730
|
return;
|
|
@@ -4750,8 +4750,8 @@ class pr {
|
|
|
4750
4750
|
*/
|
|
4751
4751
|
async loadCharacterData(e, t) {
|
|
4752
4752
|
var v, S, w, b, P, O, _, ee, H;
|
|
4753
|
-
const { progressCallback:
|
|
4754
|
-
if (!
|
|
4753
|
+
const { progressCallback: n = null } = t || {}, i = (w = (S = (v = e.models) == null ? void 0 : v.shape) == null ? void 0 : S.resource) == null ? void 0 : w.remote, a = (O = (P = (b = e.models) == null ? void 0 : b.gsStandard) == null ? void 0 : P.resource) == null ? void 0 : O.remote, s = (H = (ee = (_ = e.animations) == null ? void 0 : _.frameIdle) == null ? void 0 : ee.resource) == null ? void 0 : H.remote;
|
|
4754
|
+
if (!i || !a) {
|
|
4755
4755
|
const D = "Missing required resources: shape or gsStandard (point cloud)";
|
|
4756
4756
|
throw C("download_avatar_assets_failed", "error", {
|
|
4757
4757
|
avatar_id: e.characterId ?? "unknown",
|
|
@@ -4759,13 +4759,13 @@ class pr {
|
|
|
4759
4759
|
}), new Error(D);
|
|
4760
4760
|
}
|
|
4761
4761
|
const o = [
|
|
4762
|
-
{ key: "shape", url:
|
|
4762
|
+
{ key: "shape", url: i, filename: "shape.pb" },
|
|
4763
4763
|
{ key: "pointCloud", url: a, filename: "point_cloud.ply" }
|
|
4764
4764
|
];
|
|
4765
4765
|
s && o.push({ key: "idleAnimation", url: s, filename: "idle.pb", optional: !0 });
|
|
4766
4766
|
let l = 0;
|
|
4767
4767
|
const m = o.length, c = (D, W) => {
|
|
4768
|
-
|
|
4768
|
+
n && (W && l++, n({
|
|
4769
4769
|
stage: "character",
|
|
4770
4770
|
filename: D,
|
|
4771
4771
|
loaded: l,
|
|
@@ -4796,16 +4796,16 @@ class pr {
|
|
|
4796
4796
|
* Preload all resources (template + character data + camera info + settings)
|
|
4797
4797
|
*/
|
|
4798
4798
|
async preloadResources(e, t) {
|
|
4799
|
-
const { progressCallback:
|
|
4799
|
+
const { progressCallback: n = null } = t || {}, [i, a, s] = await Promise.all([
|
|
4800
4800
|
this.loadTemplateResources(e.flame, (o) => {
|
|
4801
|
-
|
|
4801
|
+
n && n({
|
|
4802
4802
|
...o,
|
|
4803
4803
|
stage: `template-${o.stage}`
|
|
4804
4804
|
});
|
|
4805
4805
|
}),
|
|
4806
4806
|
this.loadCharacterData(e, {
|
|
4807
4807
|
progressCallback: (o) => {
|
|
4808
|
-
|
|
4808
|
+
n && n({
|
|
4809
4809
|
...o,
|
|
4810
4810
|
stage: `character-${o.stage}`
|
|
4811
4811
|
});
|
|
@@ -4814,7 +4814,7 @@ class pr {
|
|
|
4814
4814
|
this.loadCameraSettings(e)
|
|
4815
4815
|
]);
|
|
4816
4816
|
return {
|
|
4817
|
-
templateResources:
|
|
4817
|
+
templateResources: i,
|
|
4818
4818
|
characterData: a,
|
|
4819
4819
|
preloadCameraSettings: s,
|
|
4820
4820
|
characterSettings: e.characterSettings
|
|
@@ -4827,7 +4827,7 @@ class pr {
|
|
|
4827
4827
|
}
|
|
4828
4828
|
// ============ API Client Methods ============
|
|
4829
4829
|
/**
|
|
4830
|
-
* Get
|
|
4830
|
+
* Get SPAvatarSDK SDK API Client (api.open.spatialwalk.top for cn, api.open.spatialwalk.cloud for intl)
|
|
4831
4831
|
* Used for: character details and resource URLs (public endpoints, no auth required)
|
|
4832
4832
|
*/
|
|
4833
4833
|
getSdkApiClient() {
|
|
@@ -4863,7 +4863,7 @@ class pr {
|
|
|
4863
4863
|
};
|
|
4864
4864
|
}
|
|
4865
4865
|
/**
|
|
4866
|
-
* Get single character by ID from
|
|
4866
|
+
* Get single character by ID from SPAvatarSDK SDK API (v2, iOS compatible)
|
|
4867
4867
|
* Domain: api.open.spatialwalk.top (cn) / api.open.spatialwalk.cloud (intl)
|
|
4868
4868
|
* Auth: Public endpoint, no authentication required
|
|
4869
4869
|
* Returns CharacterMeta with nested resource structure
|
|
@@ -4874,17 +4874,17 @@ class pr {
|
|
|
4874
4874
|
return await this.getSdkApiClient().request(`/v2/character/${e}`, {
|
|
4875
4875
|
method: "GET"
|
|
4876
4876
|
});
|
|
4877
|
-
} catch (
|
|
4878
|
-
d.errorWithError("Failed to fetch character:",
|
|
4879
|
-
const
|
|
4877
|
+
} catch (n) {
|
|
4878
|
+
d.errorWithError("Failed to fetch character:", n);
|
|
4879
|
+
const i = n && typeof n == "object" && "message" in n ? String(n.message) : "Failed to fetch character", a = n && typeof n == "object" && "data" in n && typeof n.data == "object" && ((t = n.data) != null && t.message) ? String(n.data.message) : null;
|
|
4880
4880
|
throw C("fetch_avatar_metadata_failed", "error", {
|
|
4881
4881
|
avatar_id: e ?? "unknown",
|
|
4882
|
-
description: a ||
|
|
4883
|
-
}), new Error(a ||
|
|
4882
|
+
description: a || i
|
|
4883
|
+
}), new Error(a || i);
|
|
4884
4884
|
}
|
|
4885
4885
|
}
|
|
4886
4886
|
}
|
|
4887
|
-
const
|
|
4887
|
+
const Wi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4888
4888
|
__proto__: null,
|
|
4889
4889
|
AvatarDownloader: pr
|
|
4890
4890
|
}, Symbol.toStringTag, { value: "Module" })), Re = class Re {
|
|
@@ -4908,11 +4908,11 @@ const Wn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4908
4908
|
d.log(`[AvatarManager] Loading avatar with id: ${e}`);
|
|
4909
4909
|
try {
|
|
4910
4910
|
if (!L.isInitialized)
|
|
4911
|
-
throw new Error("
|
|
4911
|
+
throw new Error("AvatarSDK not initialized. Please call AvatarSDK.initialize() first.");
|
|
4912
4912
|
this.avatarDownloader || (this.avatarDownloader = new pr()), d.log("[AvatarManager] Step 1: Fetching character metadata..."), t == null || t({ type: me.downloading, progress: 10 });
|
|
4913
|
-
const
|
|
4913
|
+
const n = await this.avatarDownloader.getCharacterById(e);
|
|
4914
4914
|
d.log("[AvatarManager] Step 2: Downloading resources..."), t == null || t({ type: me.downloading, progress: 30 });
|
|
4915
|
-
const
|
|
4915
|
+
const i = await this.avatarDownloader.preloadResources(n, {
|
|
4916
4916
|
progressCallback: (s) => {
|
|
4917
4917
|
const o = 30 + s.progress / 100 * 70;
|
|
4918
4918
|
t == null || t({
|
|
@@ -4922,17 +4922,17 @@ const Wn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4922
4922
|
}
|
|
4923
4923
|
});
|
|
4924
4924
|
d.log("[AvatarManager] Step 3: Creating Avatar instance...");
|
|
4925
|
-
const a = new
|
|
4925
|
+
const a = new gn(e, n, i);
|
|
4926
4926
|
return d.log("[AvatarManager] Avatar loaded successfully"), t == null || t({ type: me.completed }), C("character_load", "info", {
|
|
4927
4927
|
characterId: e,
|
|
4928
4928
|
event: "load_success"
|
|
4929
4929
|
}), a;
|
|
4930
|
-
} catch (
|
|
4931
|
-
const
|
|
4932
|
-
throw d.error("Failed to load avatar:",
|
|
4930
|
+
} catch (n) {
|
|
4931
|
+
const i = n instanceof Error ? n.message : String(n);
|
|
4932
|
+
throw d.error("Failed to load avatar:", i), C("character_load", "error", {
|
|
4933
4933
|
characterId: e,
|
|
4934
|
-
reason:
|
|
4935
|
-
}), t == null || t({ type: me.failed, error:
|
|
4934
|
+
reason: i
|
|
4935
|
+
}), t == null || t({ type: me.failed, error: n }), n;
|
|
4936
4936
|
}
|
|
4937
4937
|
}
|
|
4938
4938
|
/**
|
|
@@ -4945,46 +4945,46 @@ const Wn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
4945
4945
|
u(Re, "_instance", null);
|
|
4946
4946
|
let qt = Re, be = null, Ht = null, jt = null, Kt = null, Yt = null, Xt = null;
|
|
4947
4947
|
const Qe = 2048, Zt = Qe - 1;
|
|
4948
|
-
function
|
|
4949
|
-
const
|
|
4950
|
-
(!be || be.length !==
|
|
4948
|
+
function Gi(r, e, t) {
|
|
4949
|
+
const i = r.length / 13;
|
|
4950
|
+
(!be || be.length !== i) && (be = new Float32Array(i), Ht = new Uint32Array(be.buffer), jt = new Uint32Array(i), Kt = new Uint32Array(i), Yt = new Uint32Array(i), Xt = new Uint32Array(Qe));
|
|
4951
4951
|
const a = be, s = Ht, o = jt, l = Kt, m = Yt, c = Xt, h = e[0], p = e[1], v = e[2], S = t[0], w = t[1], b = t[2];
|
|
4952
|
-
for (let P = 0; P <
|
|
4952
|
+
for (let P = 0; P < i; P++) {
|
|
4953
4953
|
const O = P * 13;
|
|
4954
4954
|
a[P] = (r[O] - h) * S + (r[O + 1] - p) * w + (r[O + 2] - v) * b, o[P] = P;
|
|
4955
4955
|
}
|
|
4956
|
-
for (let P = 0; P <
|
|
4956
|
+
for (let P = 0; P < i; P++) {
|
|
4957
4957
|
const O = s[P];
|
|
4958
4958
|
s[P] = O ^ (-(O >> 31) | 2147483648);
|
|
4959
4959
|
}
|
|
4960
|
-
qe(s, o, l, c, 0,
|
|
4961
|
-
for (let P = 0; P <
|
|
4962
|
-
m[P] = l[
|
|
4960
|
+
qe(s, o, l, c, 0, i), qe(s, l, o, c, 11, i), qe(s, o, l, c, 22, i);
|
|
4961
|
+
for (let P = 0; P < i; P++)
|
|
4962
|
+
m[P] = l[i - 1 - P];
|
|
4963
4963
|
return m;
|
|
4964
4964
|
}
|
|
4965
|
-
function qe(r, e, t,
|
|
4966
|
-
|
|
4965
|
+
function qe(r, e, t, n, i, a) {
|
|
4966
|
+
n.fill(0);
|
|
4967
4967
|
for (let o = 0; o < a; o++) {
|
|
4968
|
-
const l = r[e[o]] >>
|
|
4969
|
-
|
|
4968
|
+
const l = r[e[o]] >> i & Zt;
|
|
4969
|
+
n[l]++;
|
|
4970
4970
|
}
|
|
4971
4971
|
let s = 0;
|
|
4972
4972
|
for (let o = 0; o < Qe; o++) {
|
|
4973
|
-
const l =
|
|
4974
|
-
|
|
4973
|
+
const l = n[o];
|
|
4974
|
+
n[o] = s, s += l;
|
|
4975
4975
|
}
|
|
4976
4976
|
for (let o = 0; o < a; o++) {
|
|
4977
|
-
const l = e[o], m = r[l] >>
|
|
4978
|
-
t[
|
|
4977
|
+
const l = e[o], m = r[l] >> i & Zt;
|
|
4978
|
+
t[n[m]++] = l;
|
|
4979
4979
|
}
|
|
4980
4980
|
}
|
|
4981
4981
|
const Fe = 13;
|
|
4982
4982
|
let Ae = null;
|
|
4983
|
-
function
|
|
4984
|
-
const t = e.length,
|
|
4985
|
-
(!Ae || Ae.length !==
|
|
4986
|
-
for (let
|
|
4987
|
-
const s = e[
|
|
4983
|
+
function qi(r, e) {
|
|
4984
|
+
const t = e.length, n = t * Fe;
|
|
4985
|
+
(!Ae || Ae.length !== n) && (Ae = new Float32Array(n));
|
|
4986
|
+
for (let i = 0; i < t; i++) {
|
|
4987
|
+
const s = e[i] * Fe, o = i * Fe;
|
|
4988
4988
|
Ae.set(
|
|
4989
4989
|
r.subarray(s, s + Fe),
|
|
4990
4990
|
o
|
|
@@ -4992,7 +4992,7 @@ function qn(r, e) {
|
|
|
4992
4992
|
}
|
|
4993
4993
|
return Ae;
|
|
4994
4994
|
}
|
|
4995
|
-
const
|
|
4995
|
+
const Hi = `#version 300 es
|
|
4996
4996
|
precision highp float;
|
|
4997
4997
|
|
|
4998
4998
|
in vec2 v_relativePosition;
|
|
@@ -5019,10 +5019,15 @@ float splatFragmentAlpha(vec2 relativePosition, float splatAlpha) {
|
|
|
5019
5019
|
void main() {
|
|
5020
5020
|
float alpha = splatFragmentAlpha(v_relativePosition, v_color.a);
|
|
5021
5021
|
|
|
5022
|
+
// ✅ 优化:提前丢弃几乎透明的片段(提升性能和质量,对齐 Android SDK)
|
|
5023
|
+
if (alpha < 0.001) {
|
|
5024
|
+
discard;
|
|
5025
|
+
}
|
|
5026
|
+
|
|
5022
5027
|
// 预乘 alpha 输出(匹配 premultipliedAlpha: true)
|
|
5023
5028
|
// 颜色值需要乘以 alpha,这样 WebGL 才能正确混合
|
|
5024
5029
|
fragColor = vec4(v_color.rgb * alpha, alpha);
|
|
5025
|
-
}`,
|
|
5030
|
+
}`, ji = `#version 300 es
|
|
5026
5031
|
precision highp float;
|
|
5027
5032
|
|
|
5028
5033
|
// 基础四边形顶点属性(共享4个顶点)
|
|
@@ -5074,8 +5079,8 @@ vec3 calcCovariance2D(vec3 viewPos, vec3 cov3Da, vec3 cov3Db, mat4 viewMatrix, m
|
|
|
5074
5079
|
-(focalX * viewPos.x) * invViewPosZSquared, -(focalY * viewPos.y) * invViewPosZSquared, 0.0
|
|
5075
5080
|
);
|
|
5076
5081
|
|
|
5077
|
-
// 视图变换矩阵 W (仅旋转部分) -
|
|
5078
|
-
mat3 W =
|
|
5082
|
+
// 视图变换矩阵 W (仅旋转部分) - 对齐 Android SDK,不使用转置
|
|
5083
|
+
mat3 W = mat3(viewMatrix[0].xyz, viewMatrix[1].xyz, viewMatrix[2].xyz);
|
|
5079
5084
|
|
|
5080
5085
|
// 投影变换 T = J * W
|
|
5081
5086
|
mat3 T = J * W;
|
|
@@ -5190,7 +5195,7 @@ void main() {
|
|
|
5190
5195
|
v_relativePosition = relativeCoord * BOUNDS_RADIUS;
|
|
5191
5196
|
v_color = a_color;
|
|
5192
5197
|
}`;
|
|
5193
|
-
class
|
|
5198
|
+
class Ki {
|
|
5194
5199
|
// 跟踪当前 buffer 大小
|
|
5195
5200
|
constructor(e, t) {
|
|
5196
5201
|
u(this, "canvas");
|
|
@@ -5304,7 +5309,7 @@ class Kn {
|
|
|
5304
5309
|
* @param pointCount 点数
|
|
5305
5310
|
* @param _sortOrder WebGL 忽略此参数(已在 RenderSystem 中重排序)
|
|
5306
5311
|
*/
|
|
5307
|
-
loadSplatsFromPackedData(e, t,
|
|
5312
|
+
loadSplatsFromPackedData(e, t, n) {
|
|
5308
5313
|
if (!this.isInitialized)
|
|
5309
5314
|
throw new Error("Renderer not initialized");
|
|
5310
5315
|
this.splatCount = t, this.uploadToGPU(e);
|
|
@@ -5333,47 +5338,47 @@ class Kn {
|
|
|
5333
5338
|
0,
|
|
5334
5339
|
0
|
|
5335
5340
|
), e.bindBuffer(e.ARRAY_BUFFER, this.splatBuffer);
|
|
5336
|
-
const t = 13,
|
|
5341
|
+
const t = 13, n = 4, i = t * n;
|
|
5337
5342
|
e.enableVertexAttribArray(this.attributeLocations.position), e.vertexAttribPointer(
|
|
5338
5343
|
this.attributeLocations.position,
|
|
5339
5344
|
3,
|
|
5340
5345
|
e.FLOAT,
|
|
5341
5346
|
!1,
|
|
5342
|
-
|
|
5347
|
+
i,
|
|
5343
5348
|
0
|
|
5344
5349
|
), e.vertexAttribDivisor(this.attributeLocations.position, 1), e.enableVertexAttribArray(this.attributeLocations.color), e.vertexAttribPointer(
|
|
5345
5350
|
this.attributeLocations.color,
|
|
5346
5351
|
4,
|
|
5347
5352
|
e.FLOAT,
|
|
5348
5353
|
!1,
|
|
5349
|
-
|
|
5350
|
-
3 *
|
|
5354
|
+
i,
|
|
5355
|
+
3 * n
|
|
5351
5356
|
), e.vertexAttribDivisor(this.attributeLocations.color, 1), e.enableVertexAttribArray(this.attributeLocations.covA), e.vertexAttribPointer(
|
|
5352
5357
|
this.attributeLocations.covA,
|
|
5353
5358
|
3,
|
|
5354
5359
|
e.FLOAT,
|
|
5355
5360
|
!1,
|
|
5356
|
-
|
|
5357
|
-
7 *
|
|
5361
|
+
i,
|
|
5362
|
+
7 * n
|
|
5358
5363
|
), e.vertexAttribDivisor(this.attributeLocations.covA, 1), e.enableVertexAttribArray(this.attributeLocations.covB), e.vertexAttribPointer(
|
|
5359
5364
|
this.attributeLocations.covB,
|
|
5360
5365
|
3,
|
|
5361
5366
|
e.FLOAT,
|
|
5362
5367
|
!1,
|
|
5363
|
-
|
|
5364
|
-
10 *
|
|
5368
|
+
i,
|
|
5369
|
+
10 * n
|
|
5365
5370
|
), e.vertexAttribDivisor(this.attributeLocations.covB, 1);
|
|
5366
5371
|
}
|
|
5367
5372
|
/**
|
|
5368
5373
|
* 渲染一帧
|
|
5369
5374
|
*/
|
|
5370
|
-
render(e, t,
|
|
5375
|
+
render(e, t, n) {
|
|
5371
5376
|
if (!this.isInitialized || this.splatCount === 0)
|
|
5372
5377
|
return;
|
|
5373
|
-
const
|
|
5374
|
-
if (!
|
|
5378
|
+
const i = this.gl;
|
|
5379
|
+
if (!i)
|
|
5375
5380
|
throw new Error("WebGL context not initialized");
|
|
5376
|
-
|
|
5381
|
+
i.viewport(0, 0, n[0], n[1]), i.clear(i.COLOR_BUFFER_BIT | i.DEPTH_BUFFER_BIT), i.useProgram(this.shaderProgram), i.uniformMatrix4fv(this.uniformLocations.viewMatrix, !1, e), i.uniformMatrix4fv(this.uniformLocations.projectionMatrix, !1, t), i.uniform2fv(this.uniformLocations.screenSize, n), i.uniform1i(this.uniformLocations.enableFrustumCulling, 1), this.setupVertexAttributes(), i.drawArraysInstanced(i.TRIANGLE_STRIP, 0, 4, this.splatCount);
|
|
5377
5382
|
}
|
|
5378
5383
|
/**
|
|
5379
5384
|
* 创建着色器程序
|
|
@@ -5382,25 +5387,25 @@ class Kn {
|
|
|
5382
5387
|
const t = e.createShader(e.VERTEX_SHADER);
|
|
5383
5388
|
if (!t)
|
|
5384
5389
|
throw new Error("Failed to create vertex shader");
|
|
5385
|
-
if (e.shaderSource(t,
|
|
5390
|
+
if (e.shaderSource(t, ji), e.compileShader(t), !e.getShaderParameter(t, e.COMPILE_STATUS)) {
|
|
5386
5391
|
const a = e.getShaderInfoLog(t);
|
|
5387
5392
|
throw e.deleteShader(t), new Error(`Vertex shader compilation failed: ${a}`);
|
|
5388
5393
|
}
|
|
5389
|
-
const
|
|
5390
|
-
if (!
|
|
5394
|
+
const n = e.createShader(e.FRAGMENT_SHADER);
|
|
5395
|
+
if (!n)
|
|
5391
5396
|
throw e.deleteShader(t), new Error("Failed to create fragment shader");
|
|
5392
|
-
if (e.shaderSource(
|
|
5393
|
-
const a = e.getShaderInfoLog(
|
|
5394
|
-
throw e.deleteShader(t), e.deleteShader(
|
|
5397
|
+
if (e.shaderSource(n, Hi), e.compileShader(n), !e.getShaderParameter(n, e.COMPILE_STATUS)) {
|
|
5398
|
+
const a = e.getShaderInfoLog(n);
|
|
5399
|
+
throw e.deleteShader(t), e.deleteShader(n), new Error(`Fragment shader compilation failed: ${a}`);
|
|
5395
5400
|
}
|
|
5396
|
-
const
|
|
5397
|
-
if (!
|
|
5398
|
-
throw e.deleteShader(t), e.deleteShader(
|
|
5399
|
-
if (e.attachShader(
|
|
5400
|
-
const a = e.getProgramInfoLog(
|
|
5401
|
-
throw e.deleteShader(t), e.deleteShader(
|
|
5401
|
+
const i = e.createProgram();
|
|
5402
|
+
if (!i)
|
|
5403
|
+
throw e.deleteShader(t), e.deleteShader(n), new Error("Failed to create shader program");
|
|
5404
|
+
if (e.attachShader(i, t), e.attachShader(i, n), e.linkProgram(i), !e.getProgramParameter(i, e.LINK_STATUS)) {
|
|
5405
|
+
const a = e.getProgramInfoLog(i);
|
|
5406
|
+
throw e.deleteShader(t), e.deleteShader(n), e.deleteProgram(i), new Error(`Shader program linking failed: ${a}`);
|
|
5402
5407
|
}
|
|
5403
|
-
return e.deleteShader(t), e.deleteShader(
|
|
5408
|
+
return e.deleteShader(t), e.deleteShader(n), i;
|
|
5404
5409
|
}
|
|
5405
5410
|
/**
|
|
5406
5411
|
* 清理资源
|
|
@@ -5418,7 +5423,7 @@ class Kn {
|
|
|
5418
5423
|
this.gl = null, this.isInitialized = !1;
|
|
5419
5424
|
}
|
|
5420
5425
|
}
|
|
5421
|
-
const
|
|
5426
|
+
const Yi = `/**
|
|
5422
5427
|
* WebGPU 3DGS 渲染着色器
|
|
5423
5428
|
*
|
|
5424
5429
|
* 实例化渲染:每个 splat 绘制一个四边形
|
|
@@ -5492,12 +5497,12 @@ fn calcCovariance2D(
|
|
|
5492
5497
|
0.0, 0.0, 0.0
|
|
5493
5498
|
);
|
|
5494
5499
|
|
|
5495
|
-
// 视图变换矩阵 W (仅旋转部分) -
|
|
5496
|
-
let W =
|
|
5500
|
+
// 视图变换矩阵 W (仅旋转部分) - 对齐 Android SDK,不使用转置
|
|
5501
|
+
let W = mat3x3f(
|
|
5497
5502
|
viewMatrix[0].xyz,
|
|
5498
5503
|
viewMatrix[1].xyz,
|
|
5499
5504
|
viewMatrix[2].xyz
|
|
5500
|
-
)
|
|
5505
|
+
);
|
|
5501
5506
|
|
|
5502
5507
|
// 投影变换 T = J * W
|
|
5503
5508
|
let T = J * W;
|
|
@@ -5677,11 +5682,16 @@ fn splatFragmentAlpha(relativePosition: vec2f, splatAlpha: f32) -> f32 {
|
|
|
5677
5682
|
fn fragmentMain(input: VertexOutput) -> @location(0) vec4f {
|
|
5678
5683
|
let alpha = splatFragmentAlpha(input.relativePosition, input.color.a);
|
|
5679
5684
|
|
|
5685
|
+
// ✅ 优化:提前丢弃几乎透明的片段(提升性能和质量,对齐 Android SDK)
|
|
5686
|
+
if (alpha < 0.001) {
|
|
5687
|
+
discard;
|
|
5688
|
+
}
|
|
5689
|
+
|
|
5680
5690
|
// 预乘 alpha 输出(匹配 alphaMode: 'premultiplied')
|
|
5681
5691
|
return vec4f(input.color.rgb * alpha, alpha);
|
|
5682
5692
|
}
|
|
5683
5693
|
`;
|
|
5684
|
-
class
|
|
5694
|
+
class Xi {
|
|
5685
5695
|
constructor(e, t) {
|
|
5686
5696
|
u(this, "canvas");
|
|
5687
5697
|
u(this, "backgroundColor");
|
|
@@ -5768,7 +5778,7 @@ class Xn {
|
|
|
5768
5778
|
return;
|
|
5769
5779
|
const e = this.device.createShaderModule({
|
|
5770
5780
|
label: "3DGS Render Shader",
|
|
5771
|
-
code:
|
|
5781
|
+
code: Yi
|
|
5772
5782
|
}), t = this.device.createBindGroupLayout({
|
|
5773
5783
|
label: "Uniform Bind Group Layout",
|
|
5774
5784
|
entries: [
|
|
@@ -5778,7 +5788,7 @@ class Xn {
|
|
|
5778
5788
|
buffer: { type: "uniform" }
|
|
5779
5789
|
}
|
|
5780
5790
|
]
|
|
5781
|
-
}),
|
|
5791
|
+
}), n = this.device.createBindGroupLayout({
|
|
5782
5792
|
label: "Storage Bind Group Layout",
|
|
5783
5793
|
entries: [
|
|
5784
5794
|
{
|
|
@@ -5794,9 +5804,9 @@ class Xn {
|
|
|
5794
5804
|
buffer: { type: "read-only-storage" }
|
|
5795
5805
|
}
|
|
5796
5806
|
]
|
|
5797
|
-
}),
|
|
5807
|
+
}), i = this.device.createPipelineLayout({
|
|
5798
5808
|
label: "Render Pipeline Layout",
|
|
5799
|
-
bindGroupLayouts: [t,
|
|
5809
|
+
bindGroupLayouts: [t, n]
|
|
5800
5810
|
}), a = [
|
|
5801
5811
|
// Buffer 0: Quad vertices (per-vertex)
|
|
5802
5812
|
{
|
|
@@ -5815,7 +5825,7 @@ class Xn {
|
|
|
5815
5825
|
];
|
|
5816
5826
|
this.renderPipeline = this.device.createRenderPipeline({
|
|
5817
5827
|
label: "3DGS Render Pipeline",
|
|
5818
|
-
layout:
|
|
5828
|
+
layout: i,
|
|
5819
5829
|
vertex: {
|
|
5820
5830
|
module: e,
|
|
5821
5831
|
entryPoint: "vertexMain",
|
|
@@ -5865,7 +5875,7 @@ class Xn {
|
|
|
5865
5875
|
* 🚀 间接索引渲染:packedData 是原始数据,sortOrder 是排序索引
|
|
5866
5876
|
* 🚀 完全消除 CPU 重排序开销
|
|
5867
5877
|
*/
|
|
5868
|
-
loadSplatsFromPackedData(e, t,
|
|
5878
|
+
loadSplatsFromPackedData(e, t, n) {
|
|
5869
5879
|
if (!this.device)
|
|
5870
5880
|
throw new Error("Device not initialized");
|
|
5871
5881
|
if (this.splatCount = t, (!this.splatDataBuffer || this.splatDataBuffer.size !== e.byteLength) && (this.splatDataBuffer && this.splatDataBuffer.destroy(), this.splatDataBuffer = this.device.createBuffer({
|
|
@@ -5878,19 +5888,19 @@ class Xn {
|
|
|
5878
5888
|
e.buffer,
|
|
5879
5889
|
e.byteOffset,
|
|
5880
5890
|
e.byteLength
|
|
5881
|
-
),
|
|
5882
|
-
const
|
|
5883
|
-
if ((!this.sortIndexBuffer || this.sortIndexBuffer.size !==
|
|
5891
|
+
), n) {
|
|
5892
|
+
const i = n.byteLength, a = !this.lastSortOrder || n !== this.lastSortOrder;
|
|
5893
|
+
if ((!this.sortIndexBuffer || this.sortIndexBuffer.size !== i) && (this.sortIndexBuffer && this.sortIndexBuffer.destroy(), this.sortIndexBuffer = this.device.createBuffer({
|
|
5884
5894
|
label: "Sort Index Buffer",
|
|
5885
|
-
size:
|
|
5895
|
+
size: i,
|
|
5886
5896
|
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST
|
|
5887
5897
|
}), this.bindGroupNeedsUpdate = !0), a && (this.device.queue.writeBuffer(
|
|
5888
5898
|
this.sortIndexBuffer,
|
|
5889
5899
|
0,
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
), this.lastSortOrder =
|
|
5900
|
+
n.buffer,
|
|
5901
|
+
n.byteOffset,
|
|
5902
|
+
n.byteLength
|
|
5903
|
+
), this.lastSortOrder = n), this.bindGroupNeedsUpdate && this.renderPipeline && this.sortIndexBuffer && this.splatDataBuffer) {
|
|
5894
5904
|
const s = this.renderPipeline.getBindGroupLayout(1);
|
|
5895
5905
|
this.storageBindGroup = this.device.createBindGroup({
|
|
5896
5906
|
label: "Storage Bind Group",
|
|
@@ -5912,17 +5922,17 @@ class Xn {
|
|
|
5912
5922
|
/**
|
|
5913
5923
|
* 渲染一帧
|
|
5914
5924
|
*/
|
|
5915
|
-
render(e, t,
|
|
5925
|
+
render(e, t, n) {
|
|
5916
5926
|
if (!this.device || !this.context || !this.renderPipeline || this.splatCount === 0 || !this.storageBindGroup)
|
|
5917
5927
|
return;
|
|
5918
|
-
this.updateUniforms(e, t,
|
|
5919
|
-
const
|
|
5928
|
+
this.updateUniforms(e, t, n);
|
|
5929
|
+
const i = this.context.getCurrentTexture().createView(), a = this.device.createCommandEncoder({
|
|
5920
5930
|
label: "Render Command Encoder"
|
|
5921
5931
|
}), s = a.beginRenderPass({
|
|
5922
5932
|
label: "Render Pass",
|
|
5923
5933
|
colorAttachments: [
|
|
5924
5934
|
{
|
|
5925
|
-
view:
|
|
5935
|
+
view: i,
|
|
5926
5936
|
// 透明清屏以便 CSS 背景透出
|
|
5927
5937
|
clearValue: { r: 0, g: 0, b: 0, a: 0 },
|
|
5928
5938
|
loadOp: "clear",
|
|
@@ -5935,21 +5945,21 @@ class Xn {
|
|
|
5935
5945
|
/**
|
|
5936
5946
|
* 更新 Uniform Buffer
|
|
5937
5947
|
*/
|
|
5938
|
-
updateUniforms(e, t,
|
|
5948
|
+
updateUniforms(e, t, n) {
|
|
5939
5949
|
if (!this.device || !this.uniformBuffer)
|
|
5940
5950
|
return;
|
|
5941
|
-
const
|
|
5942
|
-
a.set(e, 0), a.set(t, 16), a[32] =
|
|
5951
|
+
const i = new ArrayBuffer(160), a = new Float32Array(i), s = new Uint32Array(i);
|
|
5952
|
+
a.set(e, 0), a.set(t, 16), a[32] = n[0], a[33] = n[1], s[36] = 1, this.device.queue.writeBuffer(this.uniformBuffer, 0, i);
|
|
5943
5953
|
}
|
|
5944
5954
|
/**
|
|
5945
5955
|
* 清理资源
|
|
5946
5956
|
*/
|
|
5947
5957
|
dispose() {
|
|
5948
|
-
var e, t,
|
|
5949
|
-
(e = this.sortIndexBuffer) == null || e.destroy(), (t = this.splatDataBuffer) == null || t.destroy(), (
|
|
5958
|
+
var e, t, n, i, a;
|
|
5959
|
+
(e = this.sortIndexBuffer) == null || e.destroy(), (t = this.splatDataBuffer) == null || t.destroy(), (n = this.quadVertexBuffer) == null || n.destroy(), (i = this.uniformBuffer) == null || i.destroy(), (a = this.device) == null || a.destroy(), this.sortIndexBuffer = null, this.splatDataBuffer = null, this.quadVertexBuffer = null, this.uniformBuffer = null, this.uniformBindGroup = null, this.storageBindGroup = null, this.device = null, this.context = null, this.renderPipeline = null;
|
|
5950
5960
|
}
|
|
5951
5961
|
}
|
|
5952
|
-
class
|
|
5962
|
+
class Zi {
|
|
5953
5963
|
// 排序耗时
|
|
5954
5964
|
constructor(e) {
|
|
5955
5965
|
u(this, "renderer", null);
|
|
@@ -5998,12 +6008,12 @@ class Zn {
|
|
|
5998
6008
|
const { preferBackend: e, backgroundColor: t = [0, 0, 0, 0] } = this.options;
|
|
5999
6009
|
if (e !== "webgl" && await this.checkWebGPUSupport())
|
|
6000
6010
|
try {
|
|
6001
|
-
this.renderer = new
|
|
6011
|
+
this.renderer = new Xi(this.canvas, t), await this.renderer.initialize(), this.backend = "webgpu", d.log("✅ Using WebGPU renderer"), this.updateCameraAspect();
|
|
6002
6012
|
return;
|
|
6003
|
-
} catch (
|
|
6004
|
-
d.warn("⚠️ WebGPU init failed, fallback to WebGL:",
|
|
6013
|
+
} catch (i) {
|
|
6014
|
+
d.warn("⚠️ WebGPU init failed, fallback to WebGL:", i);
|
|
6005
6015
|
}
|
|
6006
|
-
this.renderer = new
|
|
6016
|
+
this.renderer = new Ki(this.canvas, t), await this.renderer.initialize(), this.backend = "webgl", d.log("✅ Using WebGL renderer"), this.updateCameraAspect();
|
|
6007
6017
|
}
|
|
6008
6018
|
/**
|
|
6009
6019
|
* Load packed Splat data (zero-copy, GPU format)
|
|
@@ -6023,15 +6033,15 @@ class Zn {
|
|
|
6023
6033
|
if (!this.renderer || !this.originalPackedData)
|
|
6024
6034
|
return;
|
|
6025
6035
|
this.updateCameraMatrices();
|
|
6026
|
-
const e = Math.floor(this.originalPackedData.length / 13), t = performance.now(),
|
|
6036
|
+
const e = Math.floor(this.originalPackedData.length / 13), t = performance.now(), n = Gi(
|
|
6027
6037
|
this.originalPackedData,
|
|
6028
6038
|
this.camera.position,
|
|
6029
6039
|
this.getCameraForward()
|
|
6030
|
-
),
|
|
6031
|
-
if (this.sortTime =
|
|
6032
|
-
this.renderer.loadSplatsFromPackedData(this.originalPackedData, e,
|
|
6040
|
+
), i = performance.now() - t;
|
|
6041
|
+
if (this.sortTime = i, this.backend === "webgpu")
|
|
6042
|
+
this.renderer.loadSplatsFromPackedData(this.originalPackedData, e, n);
|
|
6033
6043
|
else {
|
|
6034
|
-
const o =
|
|
6044
|
+
const o = qi(this.originalPackedData, n);
|
|
6035
6045
|
this.renderer.loadSplatsFromPackedData(o, e);
|
|
6036
6046
|
}
|
|
6037
6047
|
const a = performance.now();
|
|
@@ -6091,16 +6101,16 @@ class Zn {
|
|
|
6091
6101
|
* Update camera matrices (with caching to avoid unnecessary updates)
|
|
6092
6102
|
*/
|
|
6093
6103
|
updateCameraMatrices() {
|
|
6094
|
-
const { position: e, target: t, up:
|
|
6095
|
-
!(!this.cachedCameraParams || this.cachedCameraParams.position[0] !== e[0] || this.cachedCameraParams.position[1] !== e[1] || this.cachedCameraParams.position[2] !== e[2] || this.cachedCameraParams.target[0] !== t[0] || this.cachedCameraParams.target[1] !== t[1] || this.cachedCameraParams.target[2] !== t[2] || this.cachedCameraParams.up[0] !==
|
|
6104
|
+
const { position: e, target: t, up: n, fov: i, aspect: a, near: s, far: o } = this.camera;
|
|
6105
|
+
!(!this.cachedCameraParams || this.cachedCameraParams.position[0] !== e[0] || this.cachedCameraParams.position[1] !== e[1] || this.cachedCameraParams.position[2] !== e[2] || this.cachedCameraParams.target[0] !== t[0] || this.cachedCameraParams.target[1] !== t[1] || this.cachedCameraParams.target[2] !== t[2] || this.cachedCameraParams.up[0] !== n[0] || this.cachedCameraParams.up[1] !== n[1] || this.cachedCameraParams.up[2] !== n[2] || this.cachedCameraParams.fov !== i || this.cachedCameraParams.aspect !== a || this.cachedCameraParams.near !== s || this.cachedCameraParams.far !== o) && this.matricesCacheValid || (this.cachedCameraParams ? (this.cachedCameraParams.position[0] = e[0], this.cachedCameraParams.position[1] = e[1], this.cachedCameraParams.position[2] = e[2], this.cachedCameraParams.target[0] = t[0], this.cachedCameraParams.target[1] = t[1], this.cachedCameraParams.target[2] = t[2], this.cachedCameraParams.up[0] = n[0], this.cachedCameraParams.up[1] = n[1], this.cachedCameraParams.up[2] = n[2], this.cachedCameraParams.fov = i, this.cachedCameraParams.aspect = a, this.cachedCameraParams.near = s, this.cachedCameraParams.far = o) : this.cachedCameraParams = {
|
|
6096
6106
|
position: [e[0], e[1], e[2]],
|
|
6097
6107
|
target: [t[0], t[1], t[2]],
|
|
6098
|
-
up: [
|
|
6099
|
-
fov:
|
|
6108
|
+
up: [n[0], n[1], n[2]],
|
|
6109
|
+
fov: i,
|
|
6100
6110
|
aspect: a,
|
|
6101
6111
|
near: s,
|
|
6102
6112
|
far: o
|
|
6103
|
-
}, this.updatePerspectiveMatrix(
|
|
6113
|
+
}, this.updatePerspectiveMatrix(i, a, s, o), this.forwardCacheValid = !1, this.updateViewMatrix(e, t, n), this.matricesCacheValid = !0);
|
|
6104
6114
|
}
|
|
6105
6115
|
/**
|
|
6106
6116
|
* Get camera forward vector (cached version)
|
|
@@ -6119,9 +6129,9 @@ class Zn {
|
|
|
6119
6129
|
/**
|
|
6120
6130
|
* Update perspective projection matrix (reuse buffer)
|
|
6121
6131
|
*/
|
|
6122
|
-
updatePerspectiveMatrix(e, t,
|
|
6123
|
-
const a = e * Math.PI / 180, s = 1 / Math.tan(a / 2), o =
|
|
6124
|
-
l[0] = s / t, l[1] = 0, l[2] = 0, l[3] = 0, l[4] = 0, l[5] = s, l[6] = 0, l[7] = 0, l[8] = 0, l[9] = 0, l[10] = o, l[11] = -1, l[12] = 0, l[13] = 0, l[14] = o *
|
|
6132
|
+
updatePerspectiveMatrix(e, t, n, i) {
|
|
6133
|
+
const a = e * Math.PI / 180, s = 1 / Math.tan(a / 2), o = i / (n - i), l = this.projectionMatrix;
|
|
6134
|
+
l[0] = s / t, l[1] = 0, l[2] = 0, l[3] = 0, l[4] = 0, l[5] = s, l[6] = 0, l[7] = 0, l[8] = 0, l[9] = 0, l[10] = o, l[11] = -1, l[12] = 0, l[13] = 0, l[14] = o * n, l[15] = 0;
|
|
6125
6135
|
}
|
|
6126
6136
|
/**
|
|
6127
6137
|
* Update view matrix (directly update pre-allocated buffer to avoid per-frame allocation)
|
|
@@ -6129,10 +6139,10 @@ class Zn {
|
|
|
6129
6139
|
* Where T is translation matrix, R is rotation matrix
|
|
6130
6140
|
* Uses reusable temporary vector buffers to avoid allocations
|
|
6131
6141
|
*/
|
|
6132
|
-
updateViewMatrix(e, t,
|
|
6142
|
+
updateViewMatrix(e, t, n) {
|
|
6133
6143
|
this.tempForward[0] = t[0] - e[0], this.tempForward[1] = t[1] - e[1], this.tempForward[2] = t[2] - e[2];
|
|
6134
|
-
const
|
|
6135
|
-
this.tempForward[0] /=
|
|
6144
|
+
const i = Math.hypot(this.tempForward[0], this.tempForward[1], this.tempForward[2]) || 1;
|
|
6145
|
+
this.tempForward[0] /= i, this.tempForward[1] /= i, this.tempForward[2] /= i, this.tempRight[0] = this.tempForward[1] * n[2] - this.tempForward[2] * n[1], this.tempRight[1] = this.tempForward[2] * n[0] - this.tempForward[0] * n[2], this.tempRight[2] = this.tempForward[0] * n[1] - this.tempForward[1] * n[0];
|
|
6136
6146
|
const a = Math.hypot(this.tempRight[0], this.tempRight[1], this.tempRight[2]) || 1;
|
|
6137
6147
|
this.tempRight[0] /= a, this.tempRight[1] /= a, this.tempRight[2] /= a, this.tempUp[0] = this.tempRight[1] * this.tempForward[2] - this.tempRight[2] * this.tempForward[1], this.tempUp[1] = this.tempRight[2] * this.tempForward[0] - this.tempRight[0] * this.tempForward[2], this.tempUp[2] = this.tempRight[0] * this.tempForward[1] - this.tempRight[1] * this.tempForward[0];
|
|
6138
6148
|
const s = this.viewMatrix, o = -e[0], l = -e[1], m = -e[2];
|
|
@@ -6140,31 +6150,31 @@ class Zn {
|
|
|
6140
6150
|
}
|
|
6141
6151
|
}
|
|
6142
6152
|
function ce(r, e, t) {
|
|
6143
|
-
const
|
|
6144
|
-
for (let a = 0; a <
|
|
6145
|
-
|
|
6146
|
-
return
|
|
6153
|
+
const n = Math.min(r.length, e.length), i = Array.from({ length: n });
|
|
6154
|
+
for (let a = 0; a < n; a++)
|
|
6155
|
+
i[a] = r[a] + (e[a] - r[a]) * t;
|
|
6156
|
+
return i;
|
|
6147
6157
|
}
|
|
6148
|
-
function
|
|
6149
|
-
const
|
|
6158
|
+
function Ji(r, e, t) {
|
|
6159
|
+
const n = 0.5 - Math.cos(t * Math.PI) * 0.5;
|
|
6150
6160
|
return {
|
|
6151
|
-
translation: ce(r.translation || [0, 0, 0], e.translation || [0, 0, 0],
|
|
6152
|
-
rotation: ce(r.rotation || [0, 0, 0], e.rotation || [0, 0, 0],
|
|
6153
|
-
neckPose: ce(r.neckPose || [0, 0, 0], e.neckPose || [0, 0, 0],
|
|
6154
|
-
jawPose: ce(r.jawPose || [0, 0, 0], e.jawPose || [0, 0, 0],
|
|
6155
|
-
eyePose: ce(r.eyePose || [0, 0, 0, 0, 0, 0], e.eyePose || [0, 0, 0, 0, 0, 0],
|
|
6161
|
+
translation: ce(r.translation || [0, 0, 0], e.translation || [0, 0, 0], n),
|
|
6162
|
+
rotation: ce(r.rotation || [0, 0, 0], e.rotation || [0, 0, 0], n),
|
|
6163
|
+
neckPose: ce(r.neckPose || [0, 0, 0], e.neckPose || [0, 0, 0], n),
|
|
6164
|
+
jawPose: ce(r.jawPose || [0, 0, 0], e.jawPose || [0, 0, 0], n),
|
|
6165
|
+
eyePose: ce(r.eyePose || [0, 0, 0, 0, 0, 0], e.eyePose || [0, 0, 0, 0, 0, 0], n),
|
|
6156
6166
|
eyeLid: (() => {
|
|
6157
|
-
const
|
|
6158
|
-
return
|
|
6167
|
+
const i = r.eyeLid, a = e.eyeLid;
|
|
6168
|
+
return i && i.length > 0 && a && a.length > 0 ? ce(i, a, n) : i || a || [];
|
|
6159
6169
|
})(),
|
|
6160
|
-
expression: ce(r.expression || [], e.expression || [],
|
|
6170
|
+
expression: ce(r.expression || [], e.expression || [], n)
|
|
6161
6171
|
};
|
|
6162
6172
|
}
|
|
6163
|
-
function
|
|
6164
|
-
const
|
|
6165
|
-
for (let s = 0; s <
|
|
6166
|
-
const o = s / (
|
|
6167
|
-
a[s] =
|
|
6173
|
+
function Qi(r, e, t, n = 25) {
|
|
6174
|
+
const i = Math.max(1, Math.floor(t / 1e3 * n)), a = Array.from({ length: i });
|
|
6175
|
+
for (let s = 0; s < i; s++) {
|
|
6176
|
+
const o = s / (i - 1);
|
|
6177
|
+
a[s] = Ji(r, e, o);
|
|
6168
6178
|
}
|
|
6169
6179
|
return a;
|
|
6170
6180
|
}
|
|
@@ -6214,12 +6224,12 @@ class ra {
|
|
|
6214
6224
|
u(this, "characterHandle", null);
|
|
6215
6225
|
u(this, "characterId");
|
|
6216
6226
|
if (this.avatar = e, this.characterId = `${e.id}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, !L.configuration)
|
|
6217
|
-
throw new Error("
|
|
6218
|
-
const
|
|
6219
|
-
this.avatarController = new
|
|
6220
|
-
playbackMode:
|
|
6221
|
-
}), this.avatarController.setRenderCallback((
|
|
6222
|
-
this.renderRealtimeFrame(
|
|
6227
|
+
throw new Error("AvatarSDK must be initialized before creating AvatarView. Call AvatarSDK.initialize() first.");
|
|
6228
|
+
const n = L.getPlaybackMode();
|
|
6229
|
+
this.avatarController = new Vi(e, {
|
|
6230
|
+
playbackMode: n
|
|
6231
|
+
}), this.avatarController.setRenderCallback((i, a) => {
|
|
6232
|
+
this.renderRealtimeFrame(i, a);
|
|
6223
6233
|
}), this.canvas = this.createCanvas(t), this.ready = this.initializeView(e), this.setupControllerEventListeners();
|
|
6224
6234
|
}
|
|
6225
6235
|
// Unique ID for this character instance
|
|
@@ -6227,40 +6237,40 @@ class ra {
|
|
|
6227
6237
|
* 对齐两端 Flame 维度:标量统一长度,expression 取最大长度并零填充
|
|
6228
6238
|
*/
|
|
6229
6239
|
alignFlamePair(e, t) {
|
|
6230
|
-
const
|
|
6240
|
+
const n = (o, l) => {
|
|
6231
6241
|
const m = Array.isArray(o) ? o.slice(0, l) : [];
|
|
6232
6242
|
return m.length < l ? Array.from({ length: l }, (c, h) => m[h] ?? 0) : m;
|
|
6233
|
-
},
|
|
6234
|
-
translation:
|
|
6235
|
-
rotation:
|
|
6236
|
-
neckPose:
|
|
6237
|
-
jawPose:
|
|
6238
|
-
eyePose:
|
|
6239
|
-
eyeLid:
|
|
6243
|
+
}, i = {
|
|
6244
|
+
translation: n(e == null ? void 0 : e.translation, 3),
|
|
6245
|
+
rotation: n(e == null ? void 0 : e.rotation, 3),
|
|
6246
|
+
neckPose: n(e == null ? void 0 : e.neckPose, 3),
|
|
6247
|
+
jawPose: n(e == null ? void 0 : e.jawPose, 3),
|
|
6248
|
+
eyePose: n(e == null ? void 0 : e.eyePose, 6),
|
|
6249
|
+
eyeLid: n(e == null ? void 0 : e.eyeLid, 2),
|
|
6240
6250
|
expression: Array.isArray(e == null ? void 0 : e.expression) ? e.expression.slice() : []
|
|
6241
6251
|
}, a = {
|
|
6242
|
-
translation:
|
|
6243
|
-
rotation:
|
|
6244
|
-
neckPose:
|
|
6245
|
-
jawPose:
|
|
6246
|
-
eyePose:
|
|
6247
|
-
eyeLid:
|
|
6252
|
+
translation: n(t == null ? void 0 : t.translation, 3),
|
|
6253
|
+
rotation: n(t == null ? void 0 : t.rotation, 3),
|
|
6254
|
+
neckPose: n(t == null ? void 0 : t.neckPose, 3),
|
|
6255
|
+
jawPose: n(t == null ? void 0 : t.jawPose, 3),
|
|
6256
|
+
eyePose: n(t == null ? void 0 : t.eyePose, 6),
|
|
6257
|
+
eyeLid: n(t == null ? void 0 : t.eyeLid, 2),
|
|
6248
6258
|
expression: Array.isArray(t == null ? void 0 : t.expression) ? t.expression.slice() : []
|
|
6249
|
-
}, s = Math.max(
|
|
6250
|
-
return
|
|
6259
|
+
}, s = Math.max(i.expression.length, a.expression.length);
|
|
6260
|
+
return i.expression = n(i.expression, s), a.expression = n(a.expression, s), { from: i, to: a };
|
|
6251
6261
|
}
|
|
6252
6262
|
/**
|
|
6253
6263
|
* 生成并对齐过渡帧,确保首尾帧与起止帧完全一致
|
|
6254
6264
|
*/
|
|
6255
6265
|
generateAndAlignTransitionFrames(e, t) {
|
|
6256
|
-
const
|
|
6257
|
-
let
|
|
6258
|
-
|
|
6259
|
-
|
|
6266
|
+
const n = this.alignFlamePair(e, t);
|
|
6267
|
+
let i = Qi(
|
|
6268
|
+
n.from,
|
|
6269
|
+
n.to,
|
|
6260
6270
|
this.transitionDurationMs,
|
|
6261
6271
|
M.animation.fps
|
|
6262
6272
|
);
|
|
6263
|
-
return
|
|
6273
|
+
return i.length < 2 && (i = [n.from, n.to]), i[0] = n.from, i[i.length - 1] = n.to, i;
|
|
6264
6274
|
}
|
|
6265
6275
|
/**
|
|
6266
6276
|
* 获取缓存的 Idle 首帧,如果未缓存则获取并缓存
|
|
@@ -6288,8 +6298,8 @@ class ra {
|
|
|
6288
6298
|
* 创建canvas元素
|
|
6289
6299
|
*/
|
|
6290
6300
|
createCanvas(e) {
|
|
6291
|
-
const t = document.createElement("canvas"),
|
|
6292
|
-
return t.width = Math.floor(
|
|
6301
|
+
const t = document.createElement("canvas"), n = e.offsetWidth || 800, i = e.offsetHeight || 600, a = window.devicePixelRatio || 1;
|
|
6302
|
+
return t.width = Math.floor(n * a), t.height = Math.floor(i * a), t.style.width = `${n}px`, t.style.height = `${i}px`, t.style.display = "block", t.style.margin = "0 auto", t.style.position = "", t.style.top = "", t.style.left = "", t.style.zIndex = "", t.style.background = "none", t.style.border = "none", e.appendChild(t), e.style.display = "flex", e.style.justifyContent = "center", e.style.alignItems = "center", e.style.position = "relative", this.resizeObserver = new ResizeObserver(() => {
|
|
6293
6303
|
const s = window.devicePixelRatio || 1, o = Math.floor(e.offsetWidth || 0), l = Math.floor(e.offsetHeight || 0);
|
|
6294
6304
|
t.width = Math.floor(o * s), t.height = Math.floor(l * s), t.style.width = `${o}px`, t.style.height = `${l}px`, this.handleResize();
|
|
6295
6305
|
}), this.resizeObserver.observe(e), window.addEventListener("resize", this.onWindowResize), t;
|
|
@@ -6309,20 +6319,20 @@ class ra {
|
|
|
6309
6319
|
M.debug && d.log("[AvatarView] Initializing avatar view...");
|
|
6310
6320
|
const t = L.getAvatarCore();
|
|
6311
6321
|
if (!t)
|
|
6312
|
-
throw new Error("AvatarCore not available.
|
|
6313
|
-
const
|
|
6322
|
+
throw new Error("AvatarCore not available. AvatarSDK initialization may have failed.");
|
|
6323
|
+
const n = e.getResources();
|
|
6314
6324
|
M.debug && d.log("[AvatarView] Loading character data..."), this.characterHandle = await t.loadCharacterFromBuffers(
|
|
6315
|
-
|
|
6316
|
-
|
|
6325
|
+
n.characterData.shape,
|
|
6326
|
+
n.characterData.pointCloud,
|
|
6317
6327
|
this.characterId
|
|
6318
|
-
),
|
|
6328
|
+
), n.characterData.idleAnimation && (M.debug && d.log("[AvatarView] Loading idle animation..."), await t.loadAnimationFromBuffer(n.characterData.idleAnimation, this.characterId)), n.characterData.shape = new ArrayBuffer(0), n.characterData.pointCloud = new ArrayBuffer(0), n.characterData.idleAnimation && (n.characterData.idleAnimation = new ArrayBuffer(0)), this.avatarController.setRenderCallback(
|
|
6319
6329
|
(a, s) => {
|
|
6320
6330
|
this.renderRealtimeFrame(a, s);
|
|
6321
6331
|
},
|
|
6322
6332
|
this.characterHandle
|
|
6323
6333
|
), M.debug && d.log("[AvatarView] Initializing render system...");
|
|
6324
|
-
const
|
|
6325
|
-
await this.initializeRenderSystem(
|
|
6334
|
+
const i = this.resolveCameraConfig(n);
|
|
6335
|
+
await this.initializeRenderSystem(i), M.debug && d.log("[AvatarView] Starting rendering..."), await this.renderFirstFrame(), this.startIdleAnimationLoop(), this.isInitialized = !0, M.debug && d.log("[AvatarView] Avatar view initialized successfully");
|
|
6326
6336
|
} catch (t) {
|
|
6327
6337
|
throw d.error("[AvatarView] Failed to initialize avatar view:", t instanceof Error ? t.message : String(t)), t;
|
|
6328
6338
|
}
|
|
@@ -6331,7 +6341,7 @@ class ra {
|
|
|
6331
6341
|
* 初始化渲染系统
|
|
6332
6342
|
*/
|
|
6333
6343
|
async initializeRenderSystem(e) {
|
|
6334
|
-
this.cameraConfig = e || this.getDefaultCameraConfig(), e ? d.log("[AvatarView] Using resolved camera config:", e) : d.log("[AvatarView] No camera config in resources, using default static config:", this.cameraConfig), this.renderSystem = new
|
|
6344
|
+
this.cameraConfig = e || this.getDefaultCameraConfig(), e ? d.log("[AvatarView] Using resolved camera config:", e) : d.log("[AvatarView] No camera config in resources, using default static config:", this.cameraConfig), this.renderSystem = new Zi({
|
|
6335
6345
|
canvas: this.canvas,
|
|
6336
6346
|
camera: this.cameraConfig,
|
|
6337
6347
|
backgroundColor: [0, 0, 0, 0]
|
|
@@ -6349,19 +6359,19 @@ class ra {
|
|
|
6349
6359
|
*/
|
|
6350
6360
|
resolveCameraConfig(e) {
|
|
6351
6361
|
var o, l;
|
|
6352
|
-
const t = this.getDefaultCameraConfig(),
|
|
6362
|
+
const t = this.getDefaultCameraConfig(), n = ((o = e.characterSettings) == null ? void 0 : o.camera) ?? null, i = ((l = e.preloadCameraSettings) == null ? void 0 : l.camera) ?? null, a = n ?? i;
|
|
6353
6363
|
if (!a)
|
|
6354
6364
|
return d.warn("[AvatarView] Camera settings not found in resources, falling back to default camera config"), t;
|
|
6355
|
-
const s =
|
|
6365
|
+
const s = n ? "characterSettings" : "camera.json";
|
|
6356
6366
|
return this.deriveCameraConfigFromSettings(a, t, s);
|
|
6357
6367
|
}
|
|
6358
6368
|
/**
|
|
6359
6369
|
* 从角色设置中推导相机配置
|
|
6360
6370
|
*/
|
|
6361
|
-
deriveCameraConfigFromSettings(e, t,
|
|
6362
|
-
const
|
|
6371
|
+
deriveCameraConfigFromSettings(e, t, n) {
|
|
6372
|
+
const i = (W, j) => Number.isFinite(W) ? W : j, a = i(e.translationX, t.position[0]), s = i(e.translationY, t.position[1]), o = i(e.translationZ, t.position[2]), l = i(e.rotation, 0), m = i(e.fovYRadians, 0), c = Math.hypot(a, s, o) > 1e-4, h = m > 0, p = Math.abs(l) > 1e-4;
|
|
6363
6373
|
if (!c && !h && !p)
|
|
6364
|
-
return d.warn(`[AvatarView] Camera settings from ${
|
|
6374
|
+
return d.warn(`[AvatarView] Camera settings from ${n} appear empty, falling back to default config`), t;
|
|
6365
6375
|
const v = Math.sin(l), S = Math.cos(l), w = c ? [a, s, o] : [...t.position], b = [
|
|
6366
6376
|
-v,
|
|
6367
6377
|
0,
|
|
@@ -6384,7 +6394,7 @@ class ra {
|
|
|
6384
6394
|
// near/far 从 fallback 继承,无需硬编码
|
|
6385
6395
|
};
|
|
6386
6396
|
return d.log("[AvatarView] Applied camera settings from resources", {
|
|
6387
|
-
source:
|
|
6397
|
+
source: n,
|
|
6388
6398
|
translation: [a, s, o],
|
|
6389
6399
|
yawRadians: l,
|
|
6390
6400
|
position: w,
|
|
@@ -6411,9 +6421,9 @@ class ra {
|
|
|
6411
6421
|
neck_pose: [0, 0, 0],
|
|
6412
6422
|
jaw_pose: [0, 0, 0],
|
|
6413
6423
|
eyes_pose: [0, 0, 0, 0, 0, 0]
|
|
6414
|
-
},
|
|
6415
|
-
if (
|
|
6416
|
-
this.renderSystem.loadSplatsFromPackedData(
|
|
6424
|
+
}, n = await e.computeFrameFlatFromParams(t, this.characterHandle ?? void 0);
|
|
6425
|
+
if (n)
|
|
6426
|
+
this.renderSystem.loadSplatsFromPackedData(n), this.renderSystem.renderFrame(), M.debug && d.log("[AvatarView] First frame rendered successfully");
|
|
6417
6427
|
else
|
|
6418
6428
|
throw new Error("Failed to compute first frame splat data");
|
|
6419
6429
|
}
|
|
@@ -6441,18 +6451,18 @@ class ra {
|
|
|
6441
6451
|
}
|
|
6442
6452
|
this.idleCurrentFrameIndex = 0;
|
|
6443
6453
|
let e = 0;
|
|
6444
|
-
const
|
|
6454
|
+
const n = 1e3 / M.animation.fps;
|
|
6445
6455
|
this.initFPS();
|
|
6446
|
-
const
|
|
6456
|
+
const i = async (a) => {
|
|
6447
6457
|
try {
|
|
6448
6458
|
if (!this.renderSystem)
|
|
6449
6459
|
return;
|
|
6450
6460
|
if (this.updateFPS(), this.renderingState !== "idle") {
|
|
6451
|
-
this.idleAnimationLoopId = requestAnimationFrame(
|
|
6461
|
+
this.idleAnimationLoopId = requestAnimationFrame(i);
|
|
6452
6462
|
return;
|
|
6453
6463
|
}
|
|
6454
|
-
if (a - e <
|
|
6455
|
-
this.idleAnimationLoopId = requestAnimationFrame(
|
|
6464
|
+
if (a - e < n) {
|
|
6465
|
+
this.idleAnimationLoopId = requestAnimationFrame(i);
|
|
6456
6466
|
return;
|
|
6457
6467
|
}
|
|
6458
6468
|
e = a;
|
|
@@ -6465,12 +6475,12 @@ class ra {
|
|
|
6465
6475
|
return;
|
|
6466
6476
|
this.renderSystem.loadSplatsFromPackedData(o), this.renderSystem.renderFrame();
|
|
6467
6477
|
}
|
|
6468
|
-
this.idleAnimationLoopId = requestAnimationFrame(
|
|
6478
|
+
this.idleAnimationLoopId = requestAnimationFrame(i);
|
|
6469
6479
|
} catch (s) {
|
|
6470
6480
|
d.error("[AvatarView] Idle animation loop error:", s instanceof Error ? s.message : String(s)), this.stopIdleAnimationLoop();
|
|
6471
6481
|
}
|
|
6472
6482
|
};
|
|
6473
|
-
this.idleAnimationLoopId = requestAnimationFrame(
|
|
6483
|
+
this.idleAnimationLoopId = requestAnimationFrame(i), M.debug && d.log("[AvatarView] Idle animation loop started");
|
|
6474
6484
|
}
|
|
6475
6485
|
/**
|
|
6476
6486
|
* 开始实时对话动画循环
|
|
@@ -6478,22 +6488,22 @@ class ra {
|
|
|
6478
6488
|
startRealtimeAnimationLoop() {
|
|
6479
6489
|
this.realtimeAnimationLoopId && this.stopRealtimeAnimationLoop();
|
|
6480
6490
|
let e = 0;
|
|
6481
|
-
const
|
|
6491
|
+
const n = 1e3 / M.animation.fps;
|
|
6482
6492
|
this.initFPS();
|
|
6483
|
-
const
|
|
6493
|
+
const i = async (a) => {
|
|
6484
6494
|
try {
|
|
6485
6495
|
const s = this.renderingState;
|
|
6486
6496
|
if (this.updateFPS(), !this.renderSystem || s === "idle") {
|
|
6487
6497
|
this.realtimeAnimationLoopId = null;
|
|
6488
6498
|
return;
|
|
6489
6499
|
}
|
|
6490
|
-
if (a - e <
|
|
6491
|
-
this.realtimeAnimationLoopId = requestAnimationFrame(
|
|
6500
|
+
if (a - e < n) {
|
|
6501
|
+
this.realtimeAnimationLoopId = requestAnimationFrame(i);
|
|
6492
6502
|
return;
|
|
6493
6503
|
}
|
|
6494
6504
|
if (e = a, s === "transitioningToSpeaking" || s === "transitioningToIdle") {
|
|
6495
6505
|
if (this.transitionKeyframes.length === 0) {
|
|
6496
|
-
this.realtimeAnimationLoopId = requestAnimationFrame(
|
|
6506
|
+
this.realtimeAnimationLoopId = requestAnimationFrame(i);
|
|
6497
6507
|
return;
|
|
6498
6508
|
}
|
|
6499
6509
|
const o = performance.now() - this.transitionStartTime, l = Math.min(1, Math.max(0, o / this.transitionDurationMs)), m = this.transitionKeyframes.length, c = Math.min(m - 1, Math.floor(l * (m - 1))), h = this.transitionKeyframes[c], p = Jt(h), v = L.getAvatarCore();
|
|
@@ -6515,18 +6525,18 @@ class ra {
|
|
|
6515
6525
|
return;
|
|
6516
6526
|
}
|
|
6517
6527
|
}
|
|
6518
|
-
this.realtimeAnimationLoopId = requestAnimationFrame(
|
|
6528
|
+
this.realtimeAnimationLoopId = requestAnimationFrame(i);
|
|
6519
6529
|
return;
|
|
6520
6530
|
}
|
|
6521
6531
|
if (s === "speaking") {
|
|
6522
|
-
this.realtimeAnimationLoopId = requestAnimationFrame(
|
|
6532
|
+
this.realtimeAnimationLoopId = requestAnimationFrame(i);
|
|
6523
6533
|
return;
|
|
6524
6534
|
}
|
|
6525
6535
|
} catch (s) {
|
|
6526
6536
|
d.error("[AvatarView] Realtime animation loop error:", s instanceof Error ? s.message : String(s)), this.stopRealtimeAnimationLoop();
|
|
6527
6537
|
}
|
|
6528
6538
|
};
|
|
6529
|
-
this.realtimeAnimationLoopId = requestAnimationFrame(
|
|
6539
|
+
this.realtimeAnimationLoopId = requestAnimationFrame(i), M.debug && d.log("[AvatarView] Realtime animation loop started");
|
|
6530
6540
|
}
|
|
6531
6541
|
/**
|
|
6532
6542
|
* 停止idle动画循环
|
|
@@ -6622,11 +6632,11 @@ class ra {
|
|
|
6622
6632
|
/* TransitioningToSpeaking */
|
|
6623
6633
|
);
|
|
6624
6634
|
try {
|
|
6625
|
-
const
|
|
6626
|
-
if (
|
|
6635
|
+
const n = L.getAvatarCore();
|
|
6636
|
+
if (n && e.length > 0) {
|
|
6627
6637
|
if (this.renderingState !== "transitioningToSpeaking")
|
|
6628
6638
|
return;
|
|
6629
|
-
const
|
|
6639
|
+
const i = await n.getCurrentFrameParams(this.idleCurrentFrameIndex, this.characterId), a = vt(i);
|
|
6630
6640
|
await this.getCachedIdleFirstFrame();
|
|
6631
6641
|
const s = e[0];
|
|
6632
6642
|
this.transitionKeyframes = this.generateAndAlignTransitionFrames(a, s), this.transitionStartTime = performance.now(), this.transitionKeyframes.length === 0 ? (this.setState(
|
|
@@ -6634,8 +6644,8 @@ class ra {
|
|
|
6634
6644
|
/* Speaking */
|
|
6635
6645
|
), this.avatarController.onTransitionComplete()) : M.debug && d.log("[AvatarView] Transition started:", this.transitionKeyframes.length, "frames");
|
|
6636
6646
|
}
|
|
6637
|
-
} catch (
|
|
6638
|
-
d.warn("[AvatarView] Transition generation failed:",
|
|
6647
|
+
} catch (n) {
|
|
6648
|
+
d.warn("[AvatarView] Transition generation failed:", n instanceof Error ? n.message : String(n)), this.renderingState === "transitioningToSpeaking" && (this.setState(
|
|
6639
6649
|
"speaking"
|
|
6640
6650
|
/* Speaking */
|
|
6641
6651
|
), this.avatarController.onTransitionComplete());
|
|
@@ -6656,7 +6666,7 @@ class ra {
|
|
|
6656
6666
|
* 停止实时对话渲染
|
|
6657
6667
|
*/
|
|
6658
6668
|
stopRealtimeRendering() {
|
|
6659
|
-
var t,
|
|
6669
|
+
var t, n;
|
|
6660
6670
|
const e = this.renderingState;
|
|
6661
6671
|
if (!(e === "idle" || e === "transitioningToIdle")) {
|
|
6662
6672
|
if (e !== "speaking") {
|
|
@@ -6669,7 +6679,7 @@ class ra {
|
|
|
6669
6679
|
this.setState(
|
|
6670
6680
|
"transitioningToIdle"
|
|
6671
6681
|
/* TransitioningToIdle */
|
|
6672
|
-
), (
|
|
6682
|
+
), (n = (t = this.avatarController).onConversationState) == null || n.call(t, de.idle), (async () => {
|
|
6673
6683
|
try {
|
|
6674
6684
|
if (this.renderingState !== "transitioningToIdle")
|
|
6675
6685
|
return;
|
|
@@ -6680,8 +6690,8 @@ class ra {
|
|
|
6680
6690
|
return;
|
|
6681
6691
|
}
|
|
6682
6692
|
}
|
|
6683
|
-
} catch (
|
|
6684
|
-
d.warn("[AvatarView] Return transition generation failed:",
|
|
6693
|
+
} catch (i) {
|
|
6694
|
+
d.warn("[AvatarView] Return transition generation failed:", i instanceof Error ? i.message : String(i));
|
|
6685
6695
|
}
|
|
6686
6696
|
this.renderingState === "transitioningToIdle" && (this.setState(
|
|
6687
6697
|
"idle"
|
|
@@ -6748,15 +6758,15 @@ class ra {
|
|
|
6748
6758
|
}
|
|
6749
6759
|
export {
|
|
6750
6760
|
M as A,
|
|
6751
|
-
|
|
6761
|
+
ie as C,
|
|
6752
6762
|
Y as D,
|
|
6753
6763
|
se as E,
|
|
6754
6764
|
Ce as L,
|
|
6755
|
-
|
|
6765
|
+
vn as R,
|
|
6756
6766
|
X as S,
|
|
6757
6767
|
d as a,
|
|
6758
|
-
|
|
6759
|
-
|
|
6768
|
+
gn as b,
|
|
6769
|
+
Vi as c,
|
|
6760
6770
|
L as d,
|
|
6761
6771
|
mr as e,
|
|
6762
6772
|
qt as f,
|
|
@@ -6764,7 +6774,7 @@ export {
|
|
|
6764
6774
|
me as h,
|
|
6765
6775
|
de as i,
|
|
6766
6776
|
x as j,
|
|
6767
|
-
|
|
6777
|
+
yn as k,
|
|
6768
6778
|
C as l,
|
|
6769
6779
|
ta as m
|
|
6770
6780
|
};
|