@streamoji/avatar-widget 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/avatar-widget.js +2264 -560
- package/dist/avatar-widget.js.map +1 -1
- package/dist/avatar-widget.umd.cjs +9 -0
- package/dist/avatar-widget.umd.cjs.map +1 -0
- package/dist/avatar-widget.umd.js +2 -2
- package/dist/avatar-widget.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/avatar-widget.cjs +0 -8
- package/dist/avatar-widget.cjs.map +0 -1
- /package/dist/{avatar-widget.css → style.css} +0 -0
package/dist/avatar-widget.js
CHANGED
|
@@ -1,87 +1,1788 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { memo as
|
|
3
|
-
import { useFrame as
|
|
4
|
-
import { useGLTF as
|
|
5
|
-
import * as
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
import { jsx as N, jsxs as de } from "react/jsx-runtime";
|
|
2
|
+
import { memo as bn, useMemo as gt, useRef as L, useState as K, useEffect as ie, useCallback as Ye, useLayoutEffect as _n, Suspense as xn } from "react";
|
|
3
|
+
import { useFrame as wn, Canvas as Rn, useThree as Sn } from "@react-three/fiber";
|
|
4
|
+
import { useGLTF as ct, Environment as yn } from "@react-three/drei";
|
|
5
|
+
import * as Ge from "three";
|
|
6
|
+
import { TrianglesDrawMode as An, TriangleFanDrawMode as Tt, TriangleStripDrawMode as Wt, Loader as En, LoaderUtils as Ke, FileLoader as Xt, MeshPhysicalMaterial as ge, Vector2 as zt, Color as ve, LinearSRGBColorSpace as Re, SRGBColorSpace as We, SpotLight as Ln, PointLight as Mn, DirectionalLight as In, Matrix4 as Qe, Vector3 as Oe, Quaternion as $t, InstancedMesh as vn, InstancedBufferAttribute as kn, Object3D as qt, TextureLoader as Nn, ImageBitmapLoader as Cn, BufferAttribute as ut, InterleavedBuffer as On, InterleavedBufferAttribute as Dn, LinearMipmapLinearFilter as Yt, NearestMipmapLinearFilter as Fn, LinearMipmapNearestFilter as Pn, NearestMipmapNearestFilter as Un, LinearFilter as bt, NearestFilter as Jt, RepeatWrapping as _t, MirroredRepeatWrapping as Hn, ClampToEdgeWrapping as Bn, PointsMaterial as Gn, Material as lt, LineBasicMaterial as jn, MeshStandardMaterial as Qt, DoubleSide as Vn, MeshBasicMaterial as Ve, PropertyBinding as Kn, BufferGeometry as Wn, SkinnedMesh as Xn, Mesh as zn, LineSegments as $n, Line as qn, LineLoop as Yn, Points as Jn, Group as dt, PerspectiveCamera as Qn, MathUtils as Zn, OrthographicCamera as es, Skeleton as ts, AnimationClip as ns, Bone as ss, InterpolateDiscrete as rs, InterpolateLinear as Zt, Texture as Nt, VectorKeyframeTrack as Ct, NumberKeyframeTrack as Ot, QuaternionKeyframeTrack as Dt, ColorManagement as Ft, FrontSide as is, Interpolant as os, Box3 as as, Sphere as cs } from "three";
|
|
7
|
+
function Pt(d, t) {
|
|
8
|
+
if (t === An)
|
|
9
|
+
return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), d;
|
|
10
|
+
if (t === Tt || t === Wt) {
|
|
11
|
+
let e = d.getIndex();
|
|
12
|
+
if (e === null) {
|
|
13
|
+
const s = [], a = d.getAttribute("position");
|
|
14
|
+
if (a !== void 0) {
|
|
15
|
+
for (let o = 0; o < a.count; o++)
|
|
16
|
+
s.push(o);
|
|
17
|
+
d.setIndex(s), e = d.getIndex();
|
|
18
|
+
} else
|
|
19
|
+
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), d;
|
|
20
|
+
}
|
|
21
|
+
const r = e.count - 2, n = [];
|
|
22
|
+
if (t === Tt)
|
|
23
|
+
for (let s = 1; s <= r; s++)
|
|
24
|
+
n.push(e.getX(0)), n.push(e.getX(s)), n.push(e.getX(s + 1));
|
|
25
|
+
else
|
|
26
|
+
for (let s = 0; s < r; s++)
|
|
27
|
+
s % 2 === 0 ? (n.push(e.getX(s)), n.push(e.getX(s + 1)), n.push(e.getX(s + 2))) : (n.push(e.getX(s + 2)), n.push(e.getX(s + 1)), n.push(e.getX(s)));
|
|
28
|
+
n.length / 3 !== r && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
|
|
29
|
+
const i = d.clone();
|
|
30
|
+
return i.setIndex(n), i.clearGroups(), i;
|
|
31
|
+
} else
|
|
32
|
+
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", t), d;
|
|
33
|
+
}
|
|
34
|
+
class us extends En {
|
|
35
|
+
/**
|
|
36
|
+
* Constructs a new glTF loader.
|
|
37
|
+
*
|
|
38
|
+
* @param {LoadingManager} [manager] - The loading manager.
|
|
39
|
+
*/
|
|
40
|
+
constructor(t) {
|
|
41
|
+
super(t), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(e) {
|
|
42
|
+
return new ps(e);
|
|
43
|
+
}), this.register(function(e) {
|
|
44
|
+
return new ms(e);
|
|
45
|
+
}), this.register(function(e) {
|
|
46
|
+
return new ys(e);
|
|
47
|
+
}), this.register(function(e) {
|
|
48
|
+
return new As(e);
|
|
49
|
+
}), this.register(function(e) {
|
|
50
|
+
return new Es(e);
|
|
51
|
+
}), this.register(function(e) {
|
|
52
|
+
return new Ts(e);
|
|
53
|
+
}), this.register(function(e) {
|
|
54
|
+
return new bs(e);
|
|
55
|
+
}), this.register(function(e) {
|
|
56
|
+
return new _s(e);
|
|
57
|
+
}), this.register(function(e) {
|
|
58
|
+
return new xs(e);
|
|
59
|
+
}), this.register(function(e) {
|
|
60
|
+
return new hs(e);
|
|
61
|
+
}), this.register(function(e) {
|
|
62
|
+
return new ws(e);
|
|
63
|
+
}), this.register(function(e) {
|
|
64
|
+
return new gs(e);
|
|
65
|
+
}), this.register(function(e) {
|
|
66
|
+
return new Ss(e);
|
|
67
|
+
}), this.register(function(e) {
|
|
68
|
+
return new Rs(e);
|
|
69
|
+
}), this.register(function(e) {
|
|
70
|
+
return new ds(e);
|
|
71
|
+
}), this.register(function(e) {
|
|
72
|
+
return new Ls(e);
|
|
73
|
+
}), this.register(function(e) {
|
|
74
|
+
return new Ms(e);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Starts loading from the given URL and passes the loaded glTF asset
|
|
79
|
+
* to the `onLoad()` callback.
|
|
80
|
+
*
|
|
81
|
+
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
|
|
82
|
+
* @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
|
|
83
|
+
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
|
|
84
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
85
|
+
*/
|
|
86
|
+
load(t, e, r, n) {
|
|
87
|
+
const i = this;
|
|
88
|
+
let s;
|
|
89
|
+
if (this.resourcePath !== "")
|
|
90
|
+
s = this.resourcePath;
|
|
91
|
+
else if (this.path !== "") {
|
|
92
|
+
const c = Ke.extractUrlBase(t);
|
|
93
|
+
s = Ke.resolveURL(c, this.path);
|
|
94
|
+
} else
|
|
95
|
+
s = Ke.extractUrlBase(t);
|
|
96
|
+
this.manager.itemStart(t);
|
|
97
|
+
const a = function(c) {
|
|
98
|
+
n ? n(c) : console.error(c), i.manager.itemError(t), i.manager.itemEnd(t);
|
|
99
|
+
}, o = new Xt(this.manager);
|
|
100
|
+
o.setPath(this.path), o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(t, function(c) {
|
|
101
|
+
try {
|
|
102
|
+
i.parse(c, s, function(u) {
|
|
103
|
+
e(u), i.manager.itemEnd(t);
|
|
104
|
+
}, a);
|
|
105
|
+
} catch (u) {
|
|
106
|
+
a(u);
|
|
107
|
+
}
|
|
108
|
+
}, r, a);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Sets the given Draco loader to this loader. Required for decoding assets
|
|
112
|
+
* compressed with the `KHR_draco_mesh_compression` extension.
|
|
113
|
+
*
|
|
114
|
+
* @param {DRACOLoader} dracoLoader - The Draco loader to set.
|
|
115
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
116
|
+
*/
|
|
117
|
+
setDRACOLoader(t) {
|
|
118
|
+
return this.dracoLoader = t, this;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Sets the given KTX2 loader to this loader. Required for loading KTX2
|
|
122
|
+
* compressed textures.
|
|
123
|
+
*
|
|
124
|
+
* @param {KTX2Loader} ktx2Loader - The KTX2 loader to set.
|
|
125
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
126
|
+
*/
|
|
127
|
+
setKTX2Loader(t) {
|
|
128
|
+
return this.ktx2Loader = t, this;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Sets the given meshopt decoder. Required for decoding assets
|
|
132
|
+
* compressed with the `EXT_meshopt_compression` extension.
|
|
133
|
+
*
|
|
134
|
+
* @param {Object} meshoptDecoder - The meshopt decoder to set.
|
|
135
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
136
|
+
*/
|
|
137
|
+
setMeshoptDecoder(t) {
|
|
138
|
+
return this.meshoptDecoder = t, this;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Registers a plugin callback. This API is internally used to implement the various
|
|
142
|
+
* glTF extensions but can also used by third-party code to add additional logic
|
|
143
|
+
* to the loader.
|
|
144
|
+
*
|
|
145
|
+
* @param {function(parser:GLTFParser)} callback - The callback function to register.
|
|
146
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
147
|
+
*/
|
|
148
|
+
register(t) {
|
|
149
|
+
return this.pluginCallbacks.indexOf(t) === -1 && this.pluginCallbacks.push(t), this;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Unregisters a plugin callback.
|
|
153
|
+
*
|
|
154
|
+
* @param {Function} callback - The callback function to unregister.
|
|
155
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
156
|
+
*/
|
|
157
|
+
unregister(t) {
|
|
158
|
+
return this.pluginCallbacks.indexOf(t) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t), 1), this;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Parses the given FBX data and returns the resulting group.
|
|
162
|
+
*
|
|
163
|
+
* @param {string|ArrayBuffer} data - The raw glTF data.
|
|
164
|
+
* @param {string} path - The URL base path.
|
|
165
|
+
* @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
|
|
166
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
167
|
+
*/
|
|
168
|
+
parse(t, e, r, n) {
|
|
169
|
+
let i;
|
|
170
|
+
const s = {}, a = {}, o = new TextDecoder();
|
|
171
|
+
if (typeof t == "string")
|
|
172
|
+
i = JSON.parse(t);
|
|
173
|
+
else if (t instanceof ArrayBuffer)
|
|
174
|
+
if (o.decode(new Uint8Array(t, 0, 4)) === en) {
|
|
175
|
+
try {
|
|
176
|
+
s[k.KHR_BINARY_GLTF] = new Is(t);
|
|
177
|
+
} catch (l) {
|
|
178
|
+
n && n(l);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
i = JSON.parse(s[k.KHR_BINARY_GLTF].content);
|
|
182
|
+
} else
|
|
183
|
+
i = JSON.parse(o.decode(t));
|
|
184
|
+
else
|
|
185
|
+
i = t;
|
|
186
|
+
if (i.asset === void 0 || i.asset.version[0] < 2) {
|
|
187
|
+
n && n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const c = new js(i, {
|
|
191
|
+
path: e || this.resourcePath || "",
|
|
192
|
+
crossOrigin: this.crossOrigin,
|
|
193
|
+
requestHeader: this.requestHeader,
|
|
194
|
+
manager: this.manager,
|
|
195
|
+
ktx2Loader: this.ktx2Loader,
|
|
196
|
+
meshoptDecoder: this.meshoptDecoder
|
|
197
|
+
});
|
|
198
|
+
c.fileLoader.setRequestHeader(this.requestHeader);
|
|
199
|
+
for (let u = 0; u < this.pluginCallbacks.length; u++) {
|
|
200
|
+
const l = this.pluginCallbacks[u](c);
|
|
201
|
+
l.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), a[l.name] = l, s[l.name] = !0;
|
|
202
|
+
}
|
|
203
|
+
if (i.extensionsUsed)
|
|
204
|
+
for (let u = 0; u < i.extensionsUsed.length; ++u) {
|
|
205
|
+
const l = i.extensionsUsed[u], f = i.extensionsRequired || [];
|
|
206
|
+
switch (l) {
|
|
207
|
+
case k.KHR_MATERIALS_UNLIT:
|
|
208
|
+
s[l] = new fs();
|
|
209
|
+
break;
|
|
210
|
+
case k.KHR_DRACO_MESH_COMPRESSION:
|
|
211
|
+
s[l] = new vs(i, this.dracoLoader);
|
|
212
|
+
break;
|
|
213
|
+
case k.KHR_TEXTURE_TRANSFORM:
|
|
214
|
+
s[l] = new ks();
|
|
215
|
+
break;
|
|
216
|
+
case k.KHR_MESH_QUANTIZATION:
|
|
217
|
+
s[l] = new Ns();
|
|
218
|
+
break;
|
|
219
|
+
default:
|
|
220
|
+
f.indexOf(l) >= 0 && a[l] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + l + '".');
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
c.setExtensions(s), c.setPlugins(a), c.parse(r, n);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Async version of {@link GLTFLoader#parse}.
|
|
227
|
+
*
|
|
228
|
+
* @async
|
|
229
|
+
* @param {string|ArrayBuffer} data - The raw glTF data.
|
|
230
|
+
* @param {string} path - The URL base path.
|
|
231
|
+
* @return {Promise<GLTFLoader~LoadObject>} A Promise that resolves with the loaded glTF when the parsing has been finished.
|
|
232
|
+
*/
|
|
233
|
+
parseAsync(t, e) {
|
|
234
|
+
const r = this;
|
|
235
|
+
return new Promise(function(n, i) {
|
|
236
|
+
r.parse(t, e, n, i);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function ls() {
|
|
241
|
+
let d = {};
|
|
242
|
+
return {
|
|
243
|
+
get: function(t) {
|
|
244
|
+
return d[t];
|
|
245
|
+
},
|
|
246
|
+
add: function(t, e) {
|
|
247
|
+
d[t] = e;
|
|
248
|
+
},
|
|
249
|
+
remove: function(t) {
|
|
250
|
+
delete d[t];
|
|
251
|
+
},
|
|
252
|
+
removeAll: function() {
|
|
253
|
+
d = {};
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
const k = {
|
|
258
|
+
KHR_BINARY_GLTF: "KHR_binary_glTF",
|
|
259
|
+
KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
|
|
260
|
+
KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
|
|
261
|
+
KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
|
|
262
|
+
KHR_MATERIALS_DISPERSION: "KHR_materials_dispersion",
|
|
263
|
+
KHR_MATERIALS_IOR: "KHR_materials_ior",
|
|
264
|
+
KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
|
|
265
|
+
KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
|
|
266
|
+
KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
|
|
267
|
+
KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
|
|
268
|
+
KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy",
|
|
269
|
+
KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
|
|
270
|
+
KHR_MATERIALS_VOLUME: "KHR_materials_volume",
|
|
271
|
+
KHR_TEXTURE_BASISU: "KHR_texture_basisu",
|
|
272
|
+
KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
|
|
273
|
+
KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
|
|
274
|
+
KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
|
|
275
|
+
EXT_MATERIALS_BUMP: "EXT_materials_bump",
|
|
276
|
+
EXT_TEXTURE_WEBP: "EXT_texture_webp",
|
|
277
|
+
EXT_TEXTURE_AVIF: "EXT_texture_avif",
|
|
278
|
+
EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
|
|
279
|
+
EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
|
|
280
|
+
};
|
|
281
|
+
class ds {
|
|
282
|
+
constructor(t) {
|
|
283
|
+
this.parser = t, this.name = k.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} };
|
|
284
|
+
}
|
|
285
|
+
_markDefs() {
|
|
286
|
+
const t = this.parser, e = this.parser.json.nodes || [];
|
|
287
|
+
for (let r = 0, n = e.length; r < n; r++) {
|
|
288
|
+
const i = e[r];
|
|
289
|
+
i.extensions && i.extensions[this.name] && i.extensions[this.name].light !== void 0 && t._addNodeRef(this.cache, i.extensions[this.name].light);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
_loadLight(t) {
|
|
293
|
+
const e = this.parser, r = "light:" + t;
|
|
294
|
+
let n = e.cache.get(r);
|
|
295
|
+
if (n) return n;
|
|
296
|
+
const i = e.json, o = ((i.extensions && i.extensions[this.name] || {}).lights || [])[t];
|
|
297
|
+
let c;
|
|
298
|
+
const u = new ve(16777215);
|
|
299
|
+
o.color !== void 0 && u.setRGB(o.color[0], o.color[1], o.color[2], Re);
|
|
300
|
+
const l = o.range !== void 0 ? o.range : 0;
|
|
301
|
+
switch (o.type) {
|
|
302
|
+
case "directional":
|
|
303
|
+
c = new In(u), c.target.position.set(0, 0, -1), c.add(c.target);
|
|
304
|
+
break;
|
|
305
|
+
case "point":
|
|
306
|
+
c = new Mn(u), c.distance = l;
|
|
307
|
+
break;
|
|
308
|
+
case "spot":
|
|
309
|
+
c = new Ln(u), c.distance = l, o.spot = o.spot || {}, o.spot.innerConeAngle = o.spot.innerConeAngle !== void 0 ? o.spot.innerConeAngle : 0, o.spot.outerConeAngle = o.spot.outerConeAngle !== void 0 ? o.spot.outerConeAngle : Math.PI / 4, c.angle = o.spot.outerConeAngle, c.penumbra = 1 - o.spot.innerConeAngle / o.spot.outerConeAngle, c.target.position.set(0, 0, -1), c.add(c.target);
|
|
310
|
+
break;
|
|
311
|
+
default:
|
|
312
|
+
throw new Error("THREE.GLTFLoader: Unexpected light type: " + o.type);
|
|
313
|
+
}
|
|
314
|
+
return c.position.set(0, 0, 0), me(c, o), o.intensity !== void 0 && (c.intensity = o.intensity), c.name = e.createUniqueName(o.name || "light_" + t), n = Promise.resolve(c), e.cache.add(r, n), n;
|
|
315
|
+
}
|
|
316
|
+
getDependency(t, e) {
|
|
317
|
+
if (t === "light")
|
|
318
|
+
return this._loadLight(e);
|
|
319
|
+
}
|
|
320
|
+
createNodeAttachment(t) {
|
|
321
|
+
const e = this, r = this.parser, i = r.json.nodes[t], a = (i.extensions && i.extensions[this.name] || {}).light;
|
|
322
|
+
return a === void 0 ? null : this._loadLight(a).then(function(o) {
|
|
323
|
+
return r._getNodeRef(e.cache, a, o);
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
class fs {
|
|
328
|
+
constructor() {
|
|
329
|
+
this.name = k.KHR_MATERIALS_UNLIT;
|
|
330
|
+
}
|
|
331
|
+
getMaterialType() {
|
|
332
|
+
return Ve;
|
|
333
|
+
}
|
|
334
|
+
extendParams(t, e, r) {
|
|
335
|
+
const n = [];
|
|
336
|
+
t.color = new ve(1, 1, 1), t.opacity = 1;
|
|
337
|
+
const i = e.pbrMetallicRoughness;
|
|
338
|
+
if (i) {
|
|
339
|
+
if (Array.isArray(i.baseColorFactor)) {
|
|
340
|
+
const s = i.baseColorFactor;
|
|
341
|
+
t.color.setRGB(s[0], s[1], s[2], Re), t.opacity = s[3];
|
|
342
|
+
}
|
|
343
|
+
i.baseColorTexture !== void 0 && n.push(r.assignTexture(t, "map", i.baseColorTexture, We));
|
|
344
|
+
}
|
|
345
|
+
return Promise.all(n);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
class hs {
|
|
349
|
+
constructor(t) {
|
|
350
|
+
this.parser = t, this.name = k.KHR_MATERIALS_EMISSIVE_STRENGTH;
|
|
351
|
+
}
|
|
352
|
+
extendMaterialParams(t, e) {
|
|
353
|
+
const n = this.parser.json.materials[t];
|
|
354
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
355
|
+
return Promise.resolve();
|
|
356
|
+
const i = n.extensions[this.name].emissiveStrength;
|
|
357
|
+
return i !== void 0 && (e.emissiveIntensity = i), Promise.resolve();
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
class ps {
|
|
361
|
+
constructor(t) {
|
|
362
|
+
this.parser = t, this.name = k.KHR_MATERIALS_CLEARCOAT;
|
|
363
|
+
}
|
|
364
|
+
getMaterialType(t) {
|
|
365
|
+
const r = this.parser.json.materials[t];
|
|
366
|
+
return !r.extensions || !r.extensions[this.name] ? null : ge;
|
|
367
|
+
}
|
|
368
|
+
extendMaterialParams(t, e) {
|
|
369
|
+
const r = this.parser, n = r.json.materials[t];
|
|
370
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
371
|
+
return Promise.resolve();
|
|
372
|
+
const i = [], s = n.extensions[this.name];
|
|
373
|
+
if (s.clearcoatFactor !== void 0 && (e.clearcoat = s.clearcoatFactor), s.clearcoatTexture !== void 0 && i.push(r.assignTexture(e, "clearcoatMap", s.clearcoatTexture)), s.clearcoatRoughnessFactor !== void 0 && (e.clearcoatRoughness = s.clearcoatRoughnessFactor), s.clearcoatRoughnessTexture !== void 0 && i.push(r.assignTexture(e, "clearcoatRoughnessMap", s.clearcoatRoughnessTexture)), s.clearcoatNormalTexture !== void 0 && (i.push(r.assignTexture(e, "clearcoatNormalMap", s.clearcoatNormalTexture)), s.clearcoatNormalTexture.scale !== void 0)) {
|
|
374
|
+
const a = s.clearcoatNormalTexture.scale;
|
|
375
|
+
e.clearcoatNormalScale = new zt(a, a);
|
|
376
|
+
}
|
|
377
|
+
return Promise.all(i);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
class ms {
|
|
381
|
+
constructor(t) {
|
|
382
|
+
this.parser = t, this.name = k.KHR_MATERIALS_DISPERSION;
|
|
383
|
+
}
|
|
384
|
+
getMaterialType(t) {
|
|
385
|
+
const r = this.parser.json.materials[t];
|
|
386
|
+
return !r.extensions || !r.extensions[this.name] ? null : ge;
|
|
387
|
+
}
|
|
388
|
+
extendMaterialParams(t, e) {
|
|
389
|
+
const n = this.parser.json.materials[t];
|
|
390
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
391
|
+
return Promise.resolve();
|
|
392
|
+
const i = n.extensions[this.name];
|
|
393
|
+
return e.dispersion = i.dispersion !== void 0 ? i.dispersion : 0, Promise.resolve();
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
class gs {
|
|
397
|
+
constructor(t) {
|
|
398
|
+
this.parser = t, this.name = k.KHR_MATERIALS_IRIDESCENCE;
|
|
399
|
+
}
|
|
400
|
+
getMaterialType(t) {
|
|
401
|
+
const r = this.parser.json.materials[t];
|
|
402
|
+
return !r.extensions || !r.extensions[this.name] ? null : ge;
|
|
403
|
+
}
|
|
404
|
+
extendMaterialParams(t, e) {
|
|
405
|
+
const r = this.parser, n = r.json.materials[t];
|
|
406
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
407
|
+
return Promise.resolve();
|
|
408
|
+
const i = [], s = n.extensions[this.name];
|
|
409
|
+
return s.iridescenceFactor !== void 0 && (e.iridescence = s.iridescenceFactor), s.iridescenceTexture !== void 0 && i.push(r.assignTexture(e, "iridescenceMap", s.iridescenceTexture)), s.iridescenceIor !== void 0 && (e.iridescenceIOR = s.iridescenceIor), e.iridescenceThicknessRange === void 0 && (e.iridescenceThicknessRange = [100, 400]), s.iridescenceThicknessMinimum !== void 0 && (e.iridescenceThicknessRange[0] = s.iridescenceThicknessMinimum), s.iridescenceThicknessMaximum !== void 0 && (e.iridescenceThicknessRange[1] = s.iridescenceThicknessMaximum), s.iridescenceThicknessTexture !== void 0 && i.push(r.assignTexture(e, "iridescenceThicknessMap", s.iridescenceThicknessTexture)), Promise.all(i);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
class Ts {
|
|
413
|
+
constructor(t) {
|
|
414
|
+
this.parser = t, this.name = k.KHR_MATERIALS_SHEEN;
|
|
415
|
+
}
|
|
416
|
+
getMaterialType(t) {
|
|
417
|
+
const r = this.parser.json.materials[t];
|
|
418
|
+
return !r.extensions || !r.extensions[this.name] ? null : ge;
|
|
419
|
+
}
|
|
420
|
+
extendMaterialParams(t, e) {
|
|
421
|
+
const r = this.parser, n = r.json.materials[t];
|
|
422
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
423
|
+
return Promise.resolve();
|
|
424
|
+
const i = [];
|
|
425
|
+
e.sheenColor = new ve(0, 0, 0), e.sheenRoughness = 0, e.sheen = 1;
|
|
426
|
+
const s = n.extensions[this.name];
|
|
427
|
+
if (s.sheenColorFactor !== void 0) {
|
|
428
|
+
const a = s.sheenColorFactor;
|
|
429
|
+
e.sheenColor.setRGB(a[0], a[1], a[2], Re);
|
|
430
|
+
}
|
|
431
|
+
return s.sheenRoughnessFactor !== void 0 && (e.sheenRoughness = s.sheenRoughnessFactor), s.sheenColorTexture !== void 0 && i.push(r.assignTexture(e, "sheenColorMap", s.sheenColorTexture, We)), s.sheenRoughnessTexture !== void 0 && i.push(r.assignTexture(e, "sheenRoughnessMap", s.sheenRoughnessTexture)), Promise.all(i);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
class bs {
|
|
435
|
+
constructor(t) {
|
|
436
|
+
this.parser = t, this.name = k.KHR_MATERIALS_TRANSMISSION;
|
|
437
|
+
}
|
|
438
|
+
getMaterialType(t) {
|
|
439
|
+
const r = this.parser.json.materials[t];
|
|
440
|
+
return !r.extensions || !r.extensions[this.name] ? null : ge;
|
|
441
|
+
}
|
|
442
|
+
extendMaterialParams(t, e) {
|
|
443
|
+
const r = this.parser, n = r.json.materials[t];
|
|
444
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
445
|
+
return Promise.resolve();
|
|
446
|
+
const i = [], s = n.extensions[this.name];
|
|
447
|
+
return s.transmissionFactor !== void 0 && (e.transmission = s.transmissionFactor), s.transmissionTexture !== void 0 && i.push(r.assignTexture(e, "transmissionMap", s.transmissionTexture)), Promise.all(i);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
class _s {
|
|
451
|
+
constructor(t) {
|
|
452
|
+
this.parser = t, this.name = k.KHR_MATERIALS_VOLUME;
|
|
453
|
+
}
|
|
454
|
+
getMaterialType(t) {
|
|
455
|
+
const r = this.parser.json.materials[t];
|
|
456
|
+
return !r.extensions || !r.extensions[this.name] ? null : ge;
|
|
457
|
+
}
|
|
458
|
+
extendMaterialParams(t, e) {
|
|
459
|
+
const r = this.parser, n = r.json.materials[t];
|
|
460
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
461
|
+
return Promise.resolve();
|
|
462
|
+
const i = [], s = n.extensions[this.name];
|
|
463
|
+
e.thickness = s.thicknessFactor !== void 0 ? s.thicknessFactor : 0, s.thicknessTexture !== void 0 && i.push(r.assignTexture(e, "thicknessMap", s.thicknessTexture)), e.attenuationDistance = s.attenuationDistance || 1 / 0;
|
|
464
|
+
const a = s.attenuationColor || [1, 1, 1];
|
|
465
|
+
return e.attenuationColor = new ve().setRGB(a[0], a[1], a[2], Re), Promise.all(i);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
class xs {
|
|
469
|
+
constructor(t) {
|
|
470
|
+
this.parser = t, this.name = k.KHR_MATERIALS_IOR;
|
|
471
|
+
}
|
|
472
|
+
getMaterialType(t) {
|
|
473
|
+
const r = this.parser.json.materials[t];
|
|
474
|
+
return !r.extensions || !r.extensions[this.name] ? null : ge;
|
|
475
|
+
}
|
|
476
|
+
extendMaterialParams(t, e) {
|
|
477
|
+
const n = this.parser.json.materials[t];
|
|
478
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
479
|
+
return Promise.resolve();
|
|
480
|
+
const i = n.extensions[this.name];
|
|
481
|
+
return e.ior = i.ior !== void 0 ? i.ior : 1.5, Promise.resolve();
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
class ws {
|
|
485
|
+
constructor(t) {
|
|
486
|
+
this.parser = t, this.name = k.KHR_MATERIALS_SPECULAR;
|
|
487
|
+
}
|
|
488
|
+
getMaterialType(t) {
|
|
489
|
+
const r = this.parser.json.materials[t];
|
|
490
|
+
return !r.extensions || !r.extensions[this.name] ? null : ge;
|
|
491
|
+
}
|
|
492
|
+
extendMaterialParams(t, e) {
|
|
493
|
+
const r = this.parser, n = r.json.materials[t];
|
|
494
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
495
|
+
return Promise.resolve();
|
|
496
|
+
const i = [], s = n.extensions[this.name];
|
|
497
|
+
e.specularIntensity = s.specularFactor !== void 0 ? s.specularFactor : 1, s.specularTexture !== void 0 && i.push(r.assignTexture(e, "specularIntensityMap", s.specularTexture));
|
|
498
|
+
const a = s.specularColorFactor || [1, 1, 1];
|
|
499
|
+
return e.specularColor = new ve().setRGB(a[0], a[1], a[2], Re), s.specularColorTexture !== void 0 && i.push(r.assignTexture(e, "specularColorMap", s.specularColorTexture, We)), Promise.all(i);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
class Rs {
|
|
503
|
+
constructor(t) {
|
|
504
|
+
this.parser = t, this.name = k.EXT_MATERIALS_BUMP;
|
|
505
|
+
}
|
|
506
|
+
getMaterialType(t) {
|
|
507
|
+
const r = this.parser.json.materials[t];
|
|
508
|
+
return !r.extensions || !r.extensions[this.name] ? null : ge;
|
|
509
|
+
}
|
|
510
|
+
extendMaterialParams(t, e) {
|
|
511
|
+
const r = this.parser, n = r.json.materials[t];
|
|
512
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
513
|
+
return Promise.resolve();
|
|
514
|
+
const i = [], s = n.extensions[this.name];
|
|
515
|
+
return e.bumpScale = s.bumpFactor !== void 0 ? s.bumpFactor : 1, s.bumpTexture !== void 0 && i.push(r.assignTexture(e, "bumpMap", s.bumpTexture)), Promise.all(i);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
class Ss {
|
|
519
|
+
constructor(t) {
|
|
520
|
+
this.parser = t, this.name = k.KHR_MATERIALS_ANISOTROPY;
|
|
521
|
+
}
|
|
522
|
+
getMaterialType(t) {
|
|
523
|
+
const r = this.parser.json.materials[t];
|
|
524
|
+
return !r.extensions || !r.extensions[this.name] ? null : ge;
|
|
525
|
+
}
|
|
526
|
+
extendMaterialParams(t, e) {
|
|
527
|
+
const r = this.parser, n = r.json.materials[t];
|
|
528
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
529
|
+
return Promise.resolve();
|
|
530
|
+
const i = [], s = n.extensions[this.name];
|
|
531
|
+
return s.anisotropyStrength !== void 0 && (e.anisotropy = s.anisotropyStrength), s.anisotropyRotation !== void 0 && (e.anisotropyRotation = s.anisotropyRotation), s.anisotropyTexture !== void 0 && i.push(r.assignTexture(e, "anisotropyMap", s.anisotropyTexture)), Promise.all(i);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
class ys {
|
|
535
|
+
constructor(t) {
|
|
536
|
+
this.parser = t, this.name = k.KHR_TEXTURE_BASISU;
|
|
537
|
+
}
|
|
538
|
+
loadTexture(t) {
|
|
539
|
+
const e = this.parser, r = e.json, n = r.textures[t];
|
|
540
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
541
|
+
return null;
|
|
542
|
+
const i = n.extensions[this.name], s = e.options.ktx2Loader;
|
|
543
|
+
if (!s) {
|
|
544
|
+
if (r.extensionsRequired && r.extensionsRequired.indexOf(this.name) >= 0)
|
|
545
|
+
throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
|
|
546
|
+
return null;
|
|
547
|
+
}
|
|
548
|
+
return e.loadTextureImage(t, i.source, s);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
class As {
|
|
552
|
+
constructor(t) {
|
|
553
|
+
this.parser = t, this.name = k.EXT_TEXTURE_WEBP;
|
|
554
|
+
}
|
|
555
|
+
loadTexture(t) {
|
|
556
|
+
const e = this.name, r = this.parser, n = r.json, i = n.textures[t];
|
|
557
|
+
if (!i.extensions || !i.extensions[e])
|
|
558
|
+
return null;
|
|
559
|
+
const s = i.extensions[e], a = n.images[s.source];
|
|
560
|
+
let o = r.textureLoader;
|
|
561
|
+
if (a.uri) {
|
|
562
|
+
const c = r.options.manager.getHandler(a.uri);
|
|
563
|
+
c !== null && (o = c);
|
|
564
|
+
}
|
|
565
|
+
return r.loadTextureImage(t, s.source, o);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
class Es {
|
|
569
|
+
constructor(t) {
|
|
570
|
+
this.parser = t, this.name = k.EXT_TEXTURE_AVIF;
|
|
571
|
+
}
|
|
572
|
+
loadTexture(t) {
|
|
573
|
+
const e = this.name, r = this.parser, n = r.json, i = n.textures[t];
|
|
574
|
+
if (!i.extensions || !i.extensions[e])
|
|
575
|
+
return null;
|
|
576
|
+
const s = i.extensions[e], a = n.images[s.source];
|
|
577
|
+
let o = r.textureLoader;
|
|
578
|
+
if (a.uri) {
|
|
579
|
+
const c = r.options.manager.getHandler(a.uri);
|
|
580
|
+
c !== null && (o = c);
|
|
581
|
+
}
|
|
582
|
+
return r.loadTextureImage(t, s.source, o);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
class Ls {
|
|
586
|
+
constructor(t) {
|
|
587
|
+
this.name = k.EXT_MESHOPT_COMPRESSION, this.parser = t;
|
|
588
|
+
}
|
|
589
|
+
loadBufferView(t) {
|
|
590
|
+
const e = this.parser.json, r = e.bufferViews[t];
|
|
591
|
+
if (r.extensions && r.extensions[this.name]) {
|
|
592
|
+
const n = r.extensions[this.name], i = this.parser.getDependency("buffer", n.buffer), s = this.parser.options.meshoptDecoder;
|
|
593
|
+
if (!s || !s.supported) {
|
|
594
|
+
if (e.extensionsRequired && e.extensionsRequired.indexOf(this.name) >= 0)
|
|
595
|
+
throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
|
|
596
|
+
return null;
|
|
597
|
+
}
|
|
598
|
+
return i.then(function(a) {
|
|
599
|
+
const o = n.byteOffset || 0, c = n.byteLength || 0, u = n.count, l = n.byteStride, f = new Uint8Array(a, o, c);
|
|
600
|
+
return s.decodeGltfBufferAsync ? s.decodeGltfBufferAsync(u, l, f, n.mode, n.filter).then(function(h) {
|
|
601
|
+
return h.buffer;
|
|
602
|
+
}) : s.ready.then(function() {
|
|
603
|
+
const h = new ArrayBuffer(u * l);
|
|
604
|
+
return s.decodeGltfBuffer(new Uint8Array(h), u, l, f, n.mode, n.filter), h;
|
|
605
|
+
});
|
|
606
|
+
});
|
|
607
|
+
} else
|
|
608
|
+
return null;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
class Ms {
|
|
612
|
+
constructor(t) {
|
|
613
|
+
this.name = k.EXT_MESH_GPU_INSTANCING, this.parser = t;
|
|
614
|
+
}
|
|
615
|
+
createNodeMesh(t) {
|
|
616
|
+
const e = this.parser.json, r = e.nodes[t];
|
|
617
|
+
if (!r.extensions || !r.extensions[this.name] || r.mesh === void 0)
|
|
618
|
+
return null;
|
|
619
|
+
const n = e.meshes[r.mesh];
|
|
620
|
+
for (const c of n.primitives)
|
|
621
|
+
if (c.mode !== ce.TRIANGLES && c.mode !== ce.TRIANGLE_STRIP && c.mode !== ce.TRIANGLE_FAN && c.mode !== void 0)
|
|
622
|
+
return null;
|
|
623
|
+
const s = r.extensions[this.name].attributes, a = [], o = {};
|
|
624
|
+
for (const c in s)
|
|
625
|
+
a.push(this.parser.getDependency("accessor", s[c]).then((u) => (o[c] = u, o[c])));
|
|
626
|
+
return a.length < 1 ? null : (a.push(this.parser.createNodeMesh(t)), Promise.all(a).then((c) => {
|
|
627
|
+
const u = c.pop(), l = u.isGroup ? u.children : [u], f = c[0].count, h = [];
|
|
628
|
+
for (const T of l) {
|
|
629
|
+
const m = new Qe(), b = new Oe(), S = new $t(), P = new Oe(1, 1, 1), D = new vn(T.geometry, T.material, f);
|
|
630
|
+
for (let y = 0; y < f; y++)
|
|
631
|
+
o.TRANSLATION && b.fromBufferAttribute(o.TRANSLATION, y), o.ROTATION && S.fromBufferAttribute(o.ROTATION, y), o.SCALE && P.fromBufferAttribute(o.SCALE, y), D.setMatrixAt(y, m.compose(b, S, P));
|
|
632
|
+
for (const y in o)
|
|
633
|
+
if (y === "_COLOR_0") {
|
|
634
|
+
const F = o[y];
|
|
635
|
+
D.instanceColor = new kn(F.array, F.itemSize, F.normalized);
|
|
636
|
+
} else y !== "TRANSLATION" && y !== "ROTATION" && y !== "SCALE" && T.geometry.setAttribute(y, o[y]);
|
|
637
|
+
qt.prototype.copy.call(D, T), this.parser.assignFinalMaterial(D), h.push(D);
|
|
638
|
+
}
|
|
639
|
+
return u.isGroup ? (u.clear(), u.add(...h), u) : h[0];
|
|
640
|
+
}));
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
const en = "glTF", je = 12, Ut = { JSON: 1313821514, BIN: 5130562 };
|
|
644
|
+
class Is {
|
|
645
|
+
constructor(t) {
|
|
646
|
+
this.name = k.KHR_BINARY_GLTF, this.content = null, this.body = null;
|
|
647
|
+
const e = new DataView(t, 0, je), r = new TextDecoder();
|
|
648
|
+
if (this.header = {
|
|
649
|
+
magic: r.decode(new Uint8Array(t.slice(0, 4))),
|
|
650
|
+
version: e.getUint32(4, !0),
|
|
651
|
+
length: e.getUint32(8, !0)
|
|
652
|
+
}, this.header.magic !== en)
|
|
653
|
+
throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
|
|
654
|
+
if (this.header.version < 2)
|
|
655
|
+
throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
|
|
656
|
+
const n = this.header.length - je, i = new DataView(t, je);
|
|
657
|
+
let s = 0;
|
|
658
|
+
for (; s < n; ) {
|
|
659
|
+
const a = i.getUint32(s, !0);
|
|
660
|
+
s += 4;
|
|
661
|
+
const o = i.getUint32(s, !0);
|
|
662
|
+
if (s += 4, o === Ut.JSON) {
|
|
663
|
+
const c = new Uint8Array(t, je + s, a);
|
|
664
|
+
this.content = r.decode(c);
|
|
665
|
+
} else if (o === Ut.BIN) {
|
|
666
|
+
const c = je + s;
|
|
667
|
+
this.body = t.slice(c, c + a);
|
|
668
|
+
}
|
|
669
|
+
s += a;
|
|
670
|
+
}
|
|
671
|
+
if (this.content === null)
|
|
672
|
+
throw new Error("THREE.GLTFLoader: JSON content not found.");
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
class vs {
|
|
676
|
+
constructor(t, e) {
|
|
677
|
+
if (!e)
|
|
678
|
+
throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
|
|
679
|
+
this.name = k.KHR_DRACO_MESH_COMPRESSION, this.json = t, this.dracoLoader = e, this.dracoLoader.preload();
|
|
680
|
+
}
|
|
681
|
+
decodePrimitive(t, e) {
|
|
682
|
+
const r = this.json, n = this.dracoLoader, i = t.extensions[this.name].bufferView, s = t.extensions[this.name].attributes, a = {}, o = {}, c = {};
|
|
683
|
+
for (const u in s) {
|
|
684
|
+
const l = xt[u] || u.toLowerCase();
|
|
685
|
+
a[l] = s[u];
|
|
686
|
+
}
|
|
687
|
+
for (const u in t.attributes) {
|
|
688
|
+
const l = xt[u] || u.toLowerCase();
|
|
689
|
+
if (s[u] !== void 0) {
|
|
690
|
+
const f = r.accessors[t.attributes[u]], h = De[f.componentType];
|
|
691
|
+
c[l] = h.name, o[l] = f.normalized === !0;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
return e.getDependency("bufferView", i).then(function(u) {
|
|
695
|
+
return new Promise(function(l, f) {
|
|
696
|
+
n.decodeDracoFile(u, function(h) {
|
|
697
|
+
for (const T in h.attributes) {
|
|
698
|
+
const m = h.attributes[T], b = o[T];
|
|
699
|
+
b !== void 0 && (m.normalized = b);
|
|
700
|
+
}
|
|
701
|
+
l(h);
|
|
702
|
+
}, a, c, Re, f);
|
|
703
|
+
});
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
class ks {
|
|
708
|
+
constructor() {
|
|
709
|
+
this.name = k.KHR_TEXTURE_TRANSFORM;
|
|
710
|
+
}
|
|
711
|
+
extendTexture(t, e) {
|
|
712
|
+
return (e.texCoord === void 0 || e.texCoord === t.channel) && e.offset === void 0 && e.rotation === void 0 && e.scale === void 0 || (t = t.clone(), e.texCoord !== void 0 && (t.channel = e.texCoord), e.offset !== void 0 && t.offset.fromArray(e.offset), e.rotation !== void 0 && (t.rotation = e.rotation), e.scale !== void 0 && t.repeat.fromArray(e.scale), t.needsUpdate = !0), t;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
class Ns {
|
|
716
|
+
constructor() {
|
|
717
|
+
this.name = k.KHR_MESH_QUANTIZATION;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
class tn extends os {
|
|
721
|
+
constructor(t, e, r, n) {
|
|
722
|
+
super(t, e, r, n);
|
|
723
|
+
}
|
|
724
|
+
copySampleValue_(t) {
|
|
725
|
+
const e = this.resultBuffer, r = this.sampleValues, n = this.valueSize, i = t * n * 3 + n;
|
|
726
|
+
for (let s = 0; s !== n; s++)
|
|
727
|
+
e[s] = r[i + s];
|
|
728
|
+
return e;
|
|
729
|
+
}
|
|
730
|
+
interpolate_(t, e, r, n) {
|
|
731
|
+
const i = this.resultBuffer, s = this.sampleValues, a = this.valueSize, o = a * 2, c = a * 3, u = n - e, l = (r - e) / u, f = l * l, h = f * l, T = t * c, m = T - c, b = -2 * h + 3 * f, S = h - f, P = 1 - b, D = S - f + l;
|
|
732
|
+
for (let y = 0; y !== a; y++) {
|
|
733
|
+
const F = s[m + y + a], C = s[m + y + o] * u, H = s[T + y + a], B = s[T + y] * u;
|
|
734
|
+
i[y] = P * F + D * C + b * H + S * B;
|
|
735
|
+
}
|
|
736
|
+
return i;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
const Cs = new $t();
|
|
740
|
+
class Os extends tn {
|
|
741
|
+
interpolate_(t, e, r, n) {
|
|
742
|
+
const i = super.interpolate_(t, e, r, n);
|
|
743
|
+
return Cs.fromArray(i).normalize().toArray(i), i;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
const ce = {
|
|
747
|
+
POINTS: 0,
|
|
748
|
+
LINES: 1,
|
|
749
|
+
LINE_LOOP: 2,
|
|
750
|
+
LINE_STRIP: 3,
|
|
751
|
+
TRIANGLES: 4,
|
|
752
|
+
TRIANGLE_STRIP: 5,
|
|
753
|
+
TRIANGLE_FAN: 6
|
|
754
|
+
}, De = {
|
|
755
|
+
5120: Int8Array,
|
|
756
|
+
5121: Uint8Array,
|
|
757
|
+
5122: Int16Array,
|
|
758
|
+
5123: Uint16Array,
|
|
759
|
+
5125: Uint32Array,
|
|
760
|
+
5126: Float32Array
|
|
761
|
+
}, Ht = {
|
|
762
|
+
9728: Jt,
|
|
763
|
+
9729: bt,
|
|
764
|
+
9984: Un,
|
|
765
|
+
9985: Pn,
|
|
766
|
+
9986: Fn,
|
|
767
|
+
9987: Yt
|
|
768
|
+
}, Bt = {
|
|
769
|
+
33071: Bn,
|
|
770
|
+
33648: Hn,
|
|
771
|
+
10497: _t
|
|
772
|
+
}, ft = {
|
|
773
|
+
SCALAR: 1,
|
|
774
|
+
VEC2: 2,
|
|
775
|
+
VEC3: 3,
|
|
776
|
+
VEC4: 4,
|
|
777
|
+
MAT2: 4,
|
|
778
|
+
MAT3: 9,
|
|
779
|
+
MAT4: 16
|
|
780
|
+
}, xt = {
|
|
781
|
+
POSITION: "position",
|
|
782
|
+
NORMAL: "normal",
|
|
783
|
+
TANGENT: "tangent",
|
|
784
|
+
TEXCOORD_0: "uv",
|
|
785
|
+
TEXCOORD_1: "uv1",
|
|
786
|
+
TEXCOORD_2: "uv2",
|
|
787
|
+
TEXCOORD_3: "uv3",
|
|
788
|
+
COLOR_0: "color",
|
|
789
|
+
WEIGHTS_0: "skinWeight",
|
|
790
|
+
JOINTS_0: "skinIndex"
|
|
791
|
+
}, Se = {
|
|
792
|
+
scale: "scale",
|
|
793
|
+
translation: "position",
|
|
794
|
+
rotation: "quaternion",
|
|
795
|
+
weights: "morphTargetInfluences"
|
|
796
|
+
}, Ds = {
|
|
797
|
+
CUBICSPLINE: void 0,
|
|
798
|
+
// We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
|
|
799
|
+
// keyframe track will be initialized with a default interpolation type, then modified.
|
|
800
|
+
LINEAR: Zt,
|
|
801
|
+
STEP: rs
|
|
802
|
+
}, ht = {
|
|
803
|
+
OPAQUE: "OPAQUE",
|
|
804
|
+
MASK: "MASK",
|
|
805
|
+
BLEND: "BLEND"
|
|
806
|
+
};
|
|
807
|
+
function Fs(d) {
|
|
808
|
+
return d.DefaultMaterial === void 0 && (d.DefaultMaterial = new Qt({
|
|
809
|
+
color: 16777215,
|
|
810
|
+
emissive: 0,
|
|
811
|
+
metalness: 1,
|
|
812
|
+
roughness: 1,
|
|
813
|
+
transparent: !1,
|
|
814
|
+
depthTest: !0,
|
|
815
|
+
side: is
|
|
816
|
+
})), d.DefaultMaterial;
|
|
817
|
+
}
|
|
818
|
+
function Ie(d, t, e) {
|
|
819
|
+
for (const r in e.extensions)
|
|
820
|
+
d[r] === void 0 && (t.userData.gltfExtensions = t.userData.gltfExtensions || {}, t.userData.gltfExtensions[r] = e.extensions[r]);
|
|
821
|
+
}
|
|
822
|
+
function me(d, t) {
|
|
823
|
+
t.extras !== void 0 && (typeof t.extras == "object" ? Object.assign(d.userData, t.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + t.extras));
|
|
824
|
+
}
|
|
825
|
+
function Ps(d, t, e) {
|
|
826
|
+
let r = !1, n = !1, i = !1;
|
|
827
|
+
for (let c = 0, u = t.length; c < u; c++) {
|
|
828
|
+
const l = t[c];
|
|
829
|
+
if (l.POSITION !== void 0 && (r = !0), l.NORMAL !== void 0 && (n = !0), l.COLOR_0 !== void 0 && (i = !0), r && n && i) break;
|
|
830
|
+
}
|
|
831
|
+
if (!r && !n && !i) return Promise.resolve(d);
|
|
832
|
+
const s = [], a = [], o = [];
|
|
833
|
+
for (let c = 0, u = t.length; c < u; c++) {
|
|
834
|
+
const l = t[c];
|
|
835
|
+
if (r) {
|
|
836
|
+
const f = l.POSITION !== void 0 ? e.getDependency("accessor", l.POSITION) : d.attributes.position;
|
|
837
|
+
s.push(f);
|
|
838
|
+
}
|
|
839
|
+
if (n) {
|
|
840
|
+
const f = l.NORMAL !== void 0 ? e.getDependency("accessor", l.NORMAL) : d.attributes.normal;
|
|
841
|
+
a.push(f);
|
|
842
|
+
}
|
|
843
|
+
if (i) {
|
|
844
|
+
const f = l.COLOR_0 !== void 0 ? e.getDependency("accessor", l.COLOR_0) : d.attributes.color;
|
|
845
|
+
o.push(f);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
return Promise.all([
|
|
849
|
+
Promise.all(s),
|
|
850
|
+
Promise.all(a),
|
|
851
|
+
Promise.all(o)
|
|
852
|
+
]).then(function(c) {
|
|
853
|
+
const u = c[0], l = c[1], f = c[2];
|
|
854
|
+
return r && (d.morphAttributes.position = u), n && (d.morphAttributes.normal = l), i && (d.morphAttributes.color = f), d.morphTargetsRelative = !0, d;
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
function Us(d, t) {
|
|
858
|
+
if (d.updateMorphTargets(), t.weights !== void 0)
|
|
859
|
+
for (let e = 0, r = t.weights.length; e < r; e++)
|
|
860
|
+
d.morphTargetInfluences[e] = t.weights[e];
|
|
861
|
+
if (t.extras && Array.isArray(t.extras.targetNames)) {
|
|
862
|
+
const e = t.extras.targetNames;
|
|
863
|
+
if (d.morphTargetInfluences.length === e.length) {
|
|
864
|
+
d.morphTargetDictionary = {};
|
|
865
|
+
for (let r = 0, n = e.length; r < n; r++)
|
|
866
|
+
d.morphTargetDictionary[e[r]] = r;
|
|
867
|
+
} else
|
|
868
|
+
console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
function Hs(d) {
|
|
872
|
+
let t;
|
|
873
|
+
const e = d.extensions && d.extensions[k.KHR_DRACO_MESH_COMPRESSION];
|
|
874
|
+
if (e ? t = "draco:" + e.bufferView + ":" + e.indices + ":" + pt(e.attributes) : t = d.indices + ":" + pt(d.attributes) + ":" + d.mode, d.targets !== void 0)
|
|
875
|
+
for (let r = 0, n = d.targets.length; r < n; r++)
|
|
876
|
+
t += ":" + pt(d.targets[r]);
|
|
877
|
+
return t;
|
|
878
|
+
}
|
|
879
|
+
function pt(d) {
|
|
880
|
+
let t = "";
|
|
881
|
+
const e = Object.keys(d).sort();
|
|
882
|
+
for (let r = 0, n = e.length; r < n; r++)
|
|
883
|
+
t += e[r] + ":" + d[e[r]] + ";";
|
|
884
|
+
return t;
|
|
885
|
+
}
|
|
886
|
+
function wt(d) {
|
|
887
|
+
switch (d) {
|
|
888
|
+
case Int8Array:
|
|
889
|
+
return 1 / 127;
|
|
890
|
+
case Uint8Array:
|
|
891
|
+
return 1 / 255;
|
|
892
|
+
case Int16Array:
|
|
893
|
+
return 1 / 32767;
|
|
894
|
+
case Uint16Array:
|
|
895
|
+
return 1 / 65535;
|
|
896
|
+
default:
|
|
897
|
+
throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
function Bs(d) {
|
|
901
|
+
return d.search(/\.jpe?g($|\?)/i) > 0 || d.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : d.search(/\.webp($|\?)/i) > 0 || d.search(/^data\:image\/webp/) === 0 ? "image/webp" : d.search(/\.ktx2($|\?)/i) > 0 || d.search(/^data\:image\/ktx2/) === 0 ? "image/ktx2" : "image/png";
|
|
902
|
+
}
|
|
903
|
+
const Gs = new Qe();
|
|
904
|
+
class js {
|
|
905
|
+
constructor(t = {}, e = {}) {
|
|
906
|
+
this.json = t, this.extensions = {}, this.plugins = {}, this.options = e, this.cache = new ls(), this.associations = /* @__PURE__ */ new Map(), this.primitiveCache = {}, this.nodeCache = {}, this.meshCache = { refs: {}, uses: {} }, this.cameraCache = { refs: {}, uses: {} }, this.lightCache = { refs: {}, uses: {} }, this.sourceCache = {}, this.textureCache = {}, this.nodeNamesUsed = {};
|
|
907
|
+
let r = !1, n = -1, i = !1, s = -1;
|
|
908
|
+
if (typeof navigator < "u") {
|
|
909
|
+
const a = navigator.userAgent;
|
|
910
|
+
r = /^((?!chrome|android).)*safari/i.test(a) === !0;
|
|
911
|
+
const o = a.match(/Version\/(\d+)/);
|
|
912
|
+
n = r && o ? parseInt(o[1], 10) : -1, i = a.indexOf("Firefox") > -1, s = i ? a.match(/Firefox\/([0-9]+)\./)[1] : -1;
|
|
913
|
+
}
|
|
914
|
+
typeof createImageBitmap > "u" || r && n < 17 || i && s < 98 ? this.textureLoader = new Nn(this.options.manager) : this.textureLoader = new Cn(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new Xt(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0);
|
|
915
|
+
}
|
|
916
|
+
setExtensions(t) {
|
|
917
|
+
this.extensions = t;
|
|
918
|
+
}
|
|
919
|
+
setPlugins(t) {
|
|
920
|
+
this.plugins = t;
|
|
921
|
+
}
|
|
922
|
+
parse(t, e) {
|
|
923
|
+
const r = this, n = this.json, i = this.extensions;
|
|
924
|
+
this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(s) {
|
|
925
|
+
return s._markDefs && s._markDefs();
|
|
926
|
+
}), Promise.all(this._invokeAll(function(s) {
|
|
927
|
+
return s.beforeRoot && s.beforeRoot();
|
|
928
|
+
})).then(function() {
|
|
929
|
+
return Promise.all([
|
|
930
|
+
r.getDependencies("scene"),
|
|
931
|
+
r.getDependencies("animation"),
|
|
932
|
+
r.getDependencies("camera")
|
|
933
|
+
]);
|
|
934
|
+
}).then(function(s) {
|
|
935
|
+
const a = {
|
|
936
|
+
scene: s[0][n.scene || 0],
|
|
937
|
+
scenes: s[0],
|
|
938
|
+
animations: s[1],
|
|
939
|
+
cameras: s[2],
|
|
940
|
+
asset: n.asset,
|
|
941
|
+
parser: r,
|
|
942
|
+
userData: {}
|
|
943
|
+
};
|
|
944
|
+
return Ie(i, a, n), me(a, n), Promise.all(r._invokeAll(function(o) {
|
|
945
|
+
return o.afterRoot && o.afterRoot(a);
|
|
946
|
+
})).then(function() {
|
|
947
|
+
for (const o of a.scenes)
|
|
948
|
+
o.updateMatrixWorld();
|
|
949
|
+
t(a);
|
|
950
|
+
});
|
|
951
|
+
}).catch(e);
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Marks the special nodes/meshes in json for efficient parse.
|
|
955
|
+
*
|
|
956
|
+
* @private
|
|
957
|
+
*/
|
|
958
|
+
_markDefs() {
|
|
959
|
+
const t = this.json.nodes || [], e = this.json.skins || [], r = this.json.meshes || [];
|
|
960
|
+
for (let n = 0, i = e.length; n < i; n++) {
|
|
961
|
+
const s = e[n].joints;
|
|
962
|
+
for (let a = 0, o = s.length; a < o; a++)
|
|
963
|
+
t[s[a]].isBone = !0;
|
|
964
|
+
}
|
|
965
|
+
for (let n = 0, i = t.length; n < i; n++) {
|
|
966
|
+
const s = t[n];
|
|
967
|
+
s.mesh !== void 0 && (this._addNodeRef(this.meshCache, s.mesh), s.skin !== void 0 && (r[s.mesh].isSkinnedMesh = !0)), s.camera !== void 0 && this._addNodeRef(this.cameraCache, s.camera);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* Counts references to shared node / Object3D resources. These resources
|
|
972
|
+
* can be reused, or "instantiated", at multiple nodes in the scene
|
|
973
|
+
* hierarchy. Mesh, Camera, and Light instances are instantiated and must
|
|
974
|
+
* be marked. Non-scenegraph resources (like Materials, Geometries, and
|
|
975
|
+
* Textures) can be reused directly and are not marked here.
|
|
976
|
+
*
|
|
977
|
+
* Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
|
|
978
|
+
*
|
|
979
|
+
* @private
|
|
980
|
+
* @param {Object} cache
|
|
981
|
+
* @param {Object3D} index
|
|
982
|
+
*/
|
|
983
|
+
_addNodeRef(t, e) {
|
|
984
|
+
e !== void 0 && (t.refs[e] === void 0 && (t.refs[e] = t.uses[e] = 0), t.refs[e]++);
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Returns a reference to a shared resource, cloning it if necessary.
|
|
988
|
+
*
|
|
989
|
+
* @private
|
|
990
|
+
* @param {Object} cache
|
|
991
|
+
* @param {number} index
|
|
992
|
+
* @param {Object} object
|
|
993
|
+
* @return {Object}
|
|
994
|
+
*/
|
|
995
|
+
_getNodeRef(t, e, r) {
|
|
996
|
+
if (t.refs[e] <= 1) return r;
|
|
997
|
+
const n = r.clone(), i = (s, a) => {
|
|
998
|
+
const o = this.associations.get(s);
|
|
999
|
+
o != null && this.associations.set(a, o);
|
|
1000
|
+
for (const [c, u] of s.children.entries())
|
|
1001
|
+
i(u, a.children[c]);
|
|
1002
|
+
};
|
|
1003
|
+
return i(r, n), n.name += "_instance_" + t.uses[e]++, n;
|
|
1004
|
+
}
|
|
1005
|
+
_invokeOne(t) {
|
|
1006
|
+
const e = Object.values(this.plugins);
|
|
1007
|
+
e.push(this);
|
|
1008
|
+
for (let r = 0; r < e.length; r++) {
|
|
1009
|
+
const n = t(e[r]);
|
|
1010
|
+
if (n) return n;
|
|
1011
|
+
}
|
|
1012
|
+
return null;
|
|
1013
|
+
}
|
|
1014
|
+
_invokeAll(t) {
|
|
1015
|
+
const e = Object.values(this.plugins);
|
|
1016
|
+
e.unshift(this);
|
|
1017
|
+
const r = [];
|
|
1018
|
+
for (let n = 0; n < e.length; n++) {
|
|
1019
|
+
const i = t(e[n]);
|
|
1020
|
+
i && r.push(i);
|
|
1021
|
+
}
|
|
1022
|
+
return r;
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Requests the specified dependency asynchronously, with caching.
|
|
1026
|
+
*
|
|
1027
|
+
* @private
|
|
1028
|
+
* @param {string} type
|
|
1029
|
+
* @param {number} index
|
|
1030
|
+
* @return {Promise<Object3D|Material|Texture|AnimationClip|ArrayBuffer|Object>}
|
|
1031
|
+
*/
|
|
1032
|
+
getDependency(t, e) {
|
|
1033
|
+
const r = t + ":" + e;
|
|
1034
|
+
let n = this.cache.get(r);
|
|
1035
|
+
if (!n) {
|
|
1036
|
+
switch (t) {
|
|
1037
|
+
case "scene":
|
|
1038
|
+
n = this.loadScene(e);
|
|
1039
|
+
break;
|
|
1040
|
+
case "node":
|
|
1041
|
+
n = this._invokeOne(function(i) {
|
|
1042
|
+
return i.loadNode && i.loadNode(e);
|
|
1043
|
+
});
|
|
1044
|
+
break;
|
|
1045
|
+
case "mesh":
|
|
1046
|
+
n = this._invokeOne(function(i) {
|
|
1047
|
+
return i.loadMesh && i.loadMesh(e);
|
|
1048
|
+
});
|
|
1049
|
+
break;
|
|
1050
|
+
case "accessor":
|
|
1051
|
+
n = this.loadAccessor(e);
|
|
1052
|
+
break;
|
|
1053
|
+
case "bufferView":
|
|
1054
|
+
n = this._invokeOne(function(i) {
|
|
1055
|
+
return i.loadBufferView && i.loadBufferView(e);
|
|
1056
|
+
});
|
|
1057
|
+
break;
|
|
1058
|
+
case "buffer":
|
|
1059
|
+
n = this.loadBuffer(e);
|
|
1060
|
+
break;
|
|
1061
|
+
case "material":
|
|
1062
|
+
n = this._invokeOne(function(i) {
|
|
1063
|
+
return i.loadMaterial && i.loadMaterial(e);
|
|
1064
|
+
});
|
|
1065
|
+
break;
|
|
1066
|
+
case "texture":
|
|
1067
|
+
n = this._invokeOne(function(i) {
|
|
1068
|
+
return i.loadTexture && i.loadTexture(e);
|
|
1069
|
+
});
|
|
1070
|
+
break;
|
|
1071
|
+
case "skin":
|
|
1072
|
+
n = this.loadSkin(e);
|
|
1073
|
+
break;
|
|
1074
|
+
case "animation":
|
|
1075
|
+
n = this._invokeOne(function(i) {
|
|
1076
|
+
return i.loadAnimation && i.loadAnimation(e);
|
|
1077
|
+
});
|
|
1078
|
+
break;
|
|
1079
|
+
case "camera":
|
|
1080
|
+
n = this.loadCamera(e);
|
|
1081
|
+
break;
|
|
1082
|
+
default:
|
|
1083
|
+
if (n = this._invokeOne(function(i) {
|
|
1084
|
+
return i != this && i.getDependency && i.getDependency(t, e);
|
|
1085
|
+
}), !n)
|
|
1086
|
+
throw new Error("Unknown type: " + t);
|
|
1087
|
+
break;
|
|
1088
|
+
}
|
|
1089
|
+
this.cache.add(r, n);
|
|
1090
|
+
}
|
|
1091
|
+
return n;
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* Requests all dependencies of the specified type asynchronously, with caching.
|
|
1095
|
+
*
|
|
1096
|
+
* @private
|
|
1097
|
+
* @param {string} type
|
|
1098
|
+
* @return {Promise<Array<Object>>}
|
|
1099
|
+
*/
|
|
1100
|
+
getDependencies(t) {
|
|
1101
|
+
let e = this.cache.get(t);
|
|
1102
|
+
if (!e) {
|
|
1103
|
+
const r = this, n = this.json[t + (t === "mesh" ? "es" : "s")] || [];
|
|
1104
|
+
e = Promise.all(n.map(function(i, s) {
|
|
1105
|
+
return r.getDependency(t, s);
|
|
1106
|
+
})), this.cache.add(t, e);
|
|
1107
|
+
}
|
|
1108
|
+
return e;
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
1112
|
+
*
|
|
1113
|
+
* @private
|
|
1114
|
+
* @param {number} bufferIndex
|
|
1115
|
+
* @return {Promise<ArrayBuffer>}
|
|
1116
|
+
*/
|
|
1117
|
+
loadBuffer(t) {
|
|
1118
|
+
const e = this.json.buffers[t], r = this.fileLoader;
|
|
1119
|
+
if (e.type && e.type !== "arraybuffer")
|
|
1120
|
+
throw new Error("THREE.GLTFLoader: " + e.type + " buffer type is not supported.");
|
|
1121
|
+
if (e.uri === void 0 && t === 0)
|
|
1122
|
+
return Promise.resolve(this.extensions[k.KHR_BINARY_GLTF].body);
|
|
1123
|
+
const n = this.options;
|
|
1124
|
+
return new Promise(function(i, s) {
|
|
1125
|
+
r.load(Ke.resolveURL(e.uri, n.path), i, void 0, function() {
|
|
1126
|
+
s(new Error('THREE.GLTFLoader: Failed to load buffer "' + e.uri + '".'));
|
|
1127
|
+
});
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
1132
|
+
*
|
|
1133
|
+
* @private
|
|
1134
|
+
* @param {number} bufferViewIndex
|
|
1135
|
+
* @return {Promise<ArrayBuffer>}
|
|
1136
|
+
*/
|
|
1137
|
+
loadBufferView(t) {
|
|
1138
|
+
const e = this.json.bufferViews[t];
|
|
1139
|
+
return this.getDependency("buffer", e.buffer).then(function(r) {
|
|
1140
|
+
const n = e.byteLength || 0, i = e.byteOffset || 0;
|
|
1141
|
+
return r.slice(i, i + n);
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
/**
|
|
1145
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
|
|
1146
|
+
*
|
|
1147
|
+
* @private
|
|
1148
|
+
* @param {number} accessorIndex
|
|
1149
|
+
* @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
|
|
1150
|
+
*/
|
|
1151
|
+
loadAccessor(t) {
|
|
1152
|
+
const e = this, r = this.json, n = this.json.accessors[t];
|
|
1153
|
+
if (n.bufferView === void 0 && n.sparse === void 0) {
|
|
1154
|
+
const s = ft[n.type], a = De[n.componentType], o = n.normalized === !0, c = new a(n.count * s);
|
|
1155
|
+
return Promise.resolve(new ut(c, s, o));
|
|
1156
|
+
}
|
|
1157
|
+
const i = [];
|
|
1158
|
+
return n.bufferView !== void 0 ? i.push(this.getDependency("bufferView", n.bufferView)) : i.push(null), n.sparse !== void 0 && (i.push(this.getDependency("bufferView", n.sparse.indices.bufferView)), i.push(this.getDependency("bufferView", n.sparse.values.bufferView))), Promise.all(i).then(function(s) {
|
|
1159
|
+
const a = s[0], o = ft[n.type], c = De[n.componentType], u = c.BYTES_PER_ELEMENT, l = u * o, f = n.byteOffset || 0, h = n.bufferView !== void 0 ? r.bufferViews[n.bufferView].byteStride : void 0, T = n.normalized === !0;
|
|
1160
|
+
let m, b;
|
|
1161
|
+
if (h && h !== l) {
|
|
1162
|
+
const S = Math.floor(f / h), P = "InterleavedBuffer:" + n.bufferView + ":" + n.componentType + ":" + S + ":" + n.count;
|
|
1163
|
+
let D = e.cache.get(P);
|
|
1164
|
+
D || (m = new c(a, S * h, n.count * h / u), D = new On(m, h / u), e.cache.add(P, D)), b = new Dn(D, o, f % h / u, T);
|
|
1165
|
+
} else
|
|
1166
|
+
a === null ? m = new c(n.count * o) : m = new c(a, f, n.count * o), b = new ut(m, o, T);
|
|
1167
|
+
if (n.sparse !== void 0) {
|
|
1168
|
+
const S = ft.SCALAR, P = De[n.sparse.indices.componentType], D = n.sparse.indices.byteOffset || 0, y = n.sparse.values.byteOffset || 0, F = new P(s[1], D, n.sparse.count * S), C = new c(s[2], y, n.sparse.count * o);
|
|
1169
|
+
a !== null && (b = new ut(b.array.slice(), b.itemSize, b.normalized)), b.normalized = !1;
|
|
1170
|
+
for (let H = 0, B = F.length; H < B; H++) {
|
|
1171
|
+
const O = F[H];
|
|
1172
|
+
if (b.setX(O, C[H * o]), o >= 2 && b.setY(O, C[H * o + 1]), o >= 3 && b.setZ(O, C[H * o + 2]), o >= 4 && b.setW(O, C[H * o + 3]), o >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
|
|
1173
|
+
}
|
|
1174
|
+
b.normalized = T;
|
|
1175
|
+
}
|
|
1176
|
+
return b;
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
|
|
1181
|
+
*
|
|
1182
|
+
* @private
|
|
1183
|
+
* @param {number} textureIndex
|
|
1184
|
+
* @return {Promise<?Texture>}
|
|
1185
|
+
*/
|
|
1186
|
+
loadTexture(t) {
|
|
1187
|
+
const e = this.json, r = this.options, i = e.textures[t].source, s = e.images[i];
|
|
1188
|
+
let a = this.textureLoader;
|
|
1189
|
+
if (s.uri) {
|
|
1190
|
+
const o = r.manager.getHandler(s.uri);
|
|
1191
|
+
o !== null && (a = o);
|
|
1192
|
+
}
|
|
1193
|
+
return this.loadTextureImage(t, i, a);
|
|
1194
|
+
}
|
|
1195
|
+
loadTextureImage(t, e, r) {
|
|
1196
|
+
const n = this, i = this.json, s = i.textures[t], a = i.images[e], o = (a.uri || a.bufferView) + ":" + s.sampler;
|
|
1197
|
+
if (this.textureCache[o])
|
|
1198
|
+
return this.textureCache[o];
|
|
1199
|
+
const c = this.loadImageSource(e, r).then(function(u) {
|
|
1200
|
+
u.flipY = !1, u.name = s.name || a.name || "", u.name === "" && typeof a.uri == "string" && a.uri.startsWith("data:image/") === !1 && (u.name = a.uri);
|
|
1201
|
+
const f = (i.samplers || {})[s.sampler] || {};
|
|
1202
|
+
return u.magFilter = Ht[f.magFilter] || bt, u.minFilter = Ht[f.minFilter] || Yt, u.wrapS = Bt[f.wrapS] || _t, u.wrapT = Bt[f.wrapT] || _t, u.generateMipmaps = !u.isCompressedTexture && u.minFilter !== Jt && u.minFilter !== bt, n.associations.set(u, { textures: t }), u;
|
|
1203
|
+
}).catch(function() {
|
|
1204
|
+
return null;
|
|
1205
|
+
});
|
|
1206
|
+
return this.textureCache[o] = c, c;
|
|
1207
|
+
}
|
|
1208
|
+
loadImageSource(t, e) {
|
|
1209
|
+
const r = this, n = this.json, i = this.options;
|
|
1210
|
+
if (this.sourceCache[t] !== void 0)
|
|
1211
|
+
return this.sourceCache[t].then((l) => l.clone());
|
|
1212
|
+
const s = n.images[t], a = self.URL || self.webkitURL;
|
|
1213
|
+
let o = s.uri || "", c = !1;
|
|
1214
|
+
if (s.bufferView !== void 0)
|
|
1215
|
+
o = r.getDependency("bufferView", s.bufferView).then(function(l) {
|
|
1216
|
+
c = !0;
|
|
1217
|
+
const f = new Blob([l], { type: s.mimeType });
|
|
1218
|
+
return o = a.createObjectURL(f), o;
|
|
1219
|
+
});
|
|
1220
|
+
else if (s.uri === void 0)
|
|
1221
|
+
throw new Error("THREE.GLTFLoader: Image " + t + " is missing URI and bufferView");
|
|
1222
|
+
const u = Promise.resolve(o).then(function(l) {
|
|
1223
|
+
return new Promise(function(f, h) {
|
|
1224
|
+
let T = f;
|
|
1225
|
+
e.isImageBitmapLoader === !0 && (T = function(m) {
|
|
1226
|
+
const b = new Nt(m);
|
|
1227
|
+
b.needsUpdate = !0, f(b);
|
|
1228
|
+
}), e.load(Ke.resolveURL(l, i.path), T, void 0, h);
|
|
1229
|
+
});
|
|
1230
|
+
}).then(function(l) {
|
|
1231
|
+
return c === !0 && a.revokeObjectURL(o), me(l, s), l.userData.mimeType = s.mimeType || Bs(s.uri), l;
|
|
1232
|
+
}).catch(function(l) {
|
|
1233
|
+
throw console.error("THREE.GLTFLoader: Couldn't load texture", o), l;
|
|
1234
|
+
});
|
|
1235
|
+
return this.sourceCache[t] = u, u;
|
|
1236
|
+
}
|
|
1237
|
+
/**
|
|
1238
|
+
* Asynchronously assigns a texture to the given material parameters.
|
|
1239
|
+
*
|
|
1240
|
+
* @private
|
|
1241
|
+
* @param {Object} materialParams
|
|
1242
|
+
* @param {string} mapName
|
|
1243
|
+
* @param {Object} mapDef
|
|
1244
|
+
* @param {string} [colorSpace]
|
|
1245
|
+
* @return {Promise<Texture>}
|
|
1246
|
+
*/
|
|
1247
|
+
assignTexture(t, e, r, n) {
|
|
1248
|
+
const i = this;
|
|
1249
|
+
return this.getDependency("texture", r.index).then(function(s) {
|
|
1250
|
+
if (!s) return null;
|
|
1251
|
+
if (r.texCoord !== void 0 && r.texCoord > 0 && (s = s.clone(), s.channel = r.texCoord), i.extensions[k.KHR_TEXTURE_TRANSFORM]) {
|
|
1252
|
+
const a = r.extensions !== void 0 ? r.extensions[k.KHR_TEXTURE_TRANSFORM] : void 0;
|
|
1253
|
+
if (a) {
|
|
1254
|
+
const o = i.associations.get(s);
|
|
1255
|
+
s = i.extensions[k.KHR_TEXTURE_TRANSFORM].extendTexture(s, a), i.associations.set(s, o);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
return n !== void 0 && (s.colorSpace = n), t[e] = s, s;
|
|
1259
|
+
});
|
|
1260
|
+
}
|
|
1261
|
+
/**
|
|
1262
|
+
* Assigns final material to a Mesh, Line, or Points instance. The instance
|
|
1263
|
+
* already has a material (generated from the glTF material options alone)
|
|
1264
|
+
* but reuse of the same glTF material may require multiple threejs materials
|
|
1265
|
+
* to accommodate different primitive types, defines, etc. New materials will
|
|
1266
|
+
* be created if necessary, and reused from a cache.
|
|
1267
|
+
*
|
|
1268
|
+
* @private
|
|
1269
|
+
* @param {Object3D} mesh Mesh, Line, or Points instance.
|
|
1270
|
+
*/
|
|
1271
|
+
assignFinalMaterial(t) {
|
|
1272
|
+
const e = t.geometry;
|
|
1273
|
+
let r = t.material;
|
|
1274
|
+
const n = e.attributes.tangent === void 0, i = e.attributes.color !== void 0, s = e.attributes.normal === void 0;
|
|
1275
|
+
if (t.isPoints) {
|
|
1276
|
+
const a = "PointsMaterial:" + r.uuid;
|
|
1277
|
+
let o = this.cache.get(a);
|
|
1278
|
+
o || (o = new Gn(), lt.prototype.copy.call(o, r), o.color.copy(r.color), o.map = r.map, o.sizeAttenuation = !1, this.cache.add(a, o)), r = o;
|
|
1279
|
+
} else if (t.isLine) {
|
|
1280
|
+
const a = "LineBasicMaterial:" + r.uuid;
|
|
1281
|
+
let o = this.cache.get(a);
|
|
1282
|
+
o || (o = new jn(), lt.prototype.copy.call(o, r), o.color.copy(r.color), o.map = r.map, this.cache.add(a, o)), r = o;
|
|
1283
|
+
}
|
|
1284
|
+
if (n || i || s) {
|
|
1285
|
+
let a = "ClonedMaterial:" + r.uuid + ":";
|
|
1286
|
+
n && (a += "derivative-tangents:"), i && (a += "vertex-colors:"), s && (a += "flat-shading:");
|
|
1287
|
+
let o = this.cache.get(a);
|
|
1288
|
+
o || (o = r.clone(), i && (o.vertexColors = !0), s && (o.flatShading = !0), n && (o.normalScale && (o.normalScale.y *= -1), o.clearcoatNormalScale && (o.clearcoatNormalScale.y *= -1)), this.cache.add(a, o), this.associations.set(o, this.associations.get(r))), r = o;
|
|
1289
|
+
}
|
|
1290
|
+
t.material = r;
|
|
1291
|
+
}
|
|
1292
|
+
getMaterialType() {
|
|
1293
|
+
return Qt;
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
|
|
1297
|
+
*
|
|
1298
|
+
* @private
|
|
1299
|
+
* @param {number} materialIndex
|
|
1300
|
+
* @return {Promise<Material>}
|
|
1301
|
+
*/
|
|
1302
|
+
loadMaterial(t) {
|
|
1303
|
+
const e = this, r = this.json, n = this.extensions, i = r.materials[t];
|
|
1304
|
+
let s;
|
|
1305
|
+
const a = {}, o = i.extensions || {}, c = [];
|
|
1306
|
+
if (o[k.KHR_MATERIALS_UNLIT]) {
|
|
1307
|
+
const l = n[k.KHR_MATERIALS_UNLIT];
|
|
1308
|
+
s = l.getMaterialType(), c.push(l.extendParams(a, i, e));
|
|
1309
|
+
} else {
|
|
1310
|
+
const l = i.pbrMetallicRoughness || {};
|
|
1311
|
+
if (a.color = new ve(1, 1, 1), a.opacity = 1, Array.isArray(l.baseColorFactor)) {
|
|
1312
|
+
const f = l.baseColorFactor;
|
|
1313
|
+
a.color.setRGB(f[0], f[1], f[2], Re), a.opacity = f[3];
|
|
1314
|
+
}
|
|
1315
|
+
l.baseColorTexture !== void 0 && c.push(e.assignTexture(a, "map", l.baseColorTexture, We)), a.metalness = l.metallicFactor !== void 0 ? l.metallicFactor : 1, a.roughness = l.roughnessFactor !== void 0 ? l.roughnessFactor : 1, l.metallicRoughnessTexture !== void 0 && (c.push(e.assignTexture(a, "metalnessMap", l.metallicRoughnessTexture)), c.push(e.assignTexture(a, "roughnessMap", l.metallicRoughnessTexture))), s = this._invokeOne(function(f) {
|
|
1316
|
+
return f.getMaterialType && f.getMaterialType(t);
|
|
1317
|
+
}), c.push(Promise.all(this._invokeAll(function(f) {
|
|
1318
|
+
return f.extendMaterialParams && f.extendMaterialParams(t, a);
|
|
1319
|
+
})));
|
|
1320
|
+
}
|
|
1321
|
+
i.doubleSided === !0 && (a.side = Vn);
|
|
1322
|
+
const u = i.alphaMode || ht.OPAQUE;
|
|
1323
|
+
if (u === ht.BLEND ? (a.transparent = !0, a.depthWrite = !1) : (a.transparent = !1, u === ht.MASK && (a.alphaTest = i.alphaCutoff !== void 0 ? i.alphaCutoff : 0.5)), i.normalTexture !== void 0 && s !== Ve && (c.push(e.assignTexture(a, "normalMap", i.normalTexture)), a.normalScale = new zt(1, 1), i.normalTexture.scale !== void 0)) {
|
|
1324
|
+
const l = i.normalTexture.scale;
|
|
1325
|
+
a.normalScale.set(l, l);
|
|
1326
|
+
}
|
|
1327
|
+
if (i.occlusionTexture !== void 0 && s !== Ve && (c.push(e.assignTexture(a, "aoMap", i.occlusionTexture)), i.occlusionTexture.strength !== void 0 && (a.aoMapIntensity = i.occlusionTexture.strength)), i.emissiveFactor !== void 0 && s !== Ve) {
|
|
1328
|
+
const l = i.emissiveFactor;
|
|
1329
|
+
a.emissive = new ve().setRGB(l[0], l[1], l[2], Re);
|
|
1330
|
+
}
|
|
1331
|
+
return i.emissiveTexture !== void 0 && s !== Ve && c.push(e.assignTexture(a, "emissiveMap", i.emissiveTexture, We)), Promise.all(c).then(function() {
|
|
1332
|
+
const l = new s(a);
|
|
1333
|
+
return i.name && (l.name = i.name), me(l, i), e.associations.set(l, { materials: t }), i.extensions && Ie(n, l, i), l;
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* When Object3D instances are targeted by animation, they need unique names.
|
|
1338
|
+
*
|
|
1339
|
+
* @private
|
|
1340
|
+
* @param {string} originalName
|
|
1341
|
+
* @return {string}
|
|
1342
|
+
*/
|
|
1343
|
+
createUniqueName(t) {
|
|
1344
|
+
const e = Kn.sanitizeNodeName(t || "");
|
|
1345
|
+
return e in this.nodeNamesUsed ? e + "_" + ++this.nodeNamesUsed[e] : (this.nodeNamesUsed[e] = 0, e);
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
|
|
1349
|
+
*
|
|
1350
|
+
* Creates BufferGeometries from primitives.
|
|
1351
|
+
*
|
|
1352
|
+
* @private
|
|
1353
|
+
* @param {Array<GLTF.Primitive>} primitives
|
|
1354
|
+
* @return {Promise<Array<BufferGeometry>>}
|
|
1355
|
+
*/
|
|
1356
|
+
loadGeometries(t) {
|
|
1357
|
+
const e = this, r = this.extensions, n = this.primitiveCache;
|
|
1358
|
+
function i(a) {
|
|
1359
|
+
return r[k.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a, e).then(function(o) {
|
|
1360
|
+
return Gt(o, a, e);
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
const s = [];
|
|
1364
|
+
for (let a = 0, o = t.length; a < o; a++) {
|
|
1365
|
+
const c = t[a], u = Hs(c), l = n[u];
|
|
1366
|
+
if (l)
|
|
1367
|
+
s.push(l.promise);
|
|
1368
|
+
else {
|
|
1369
|
+
let f;
|
|
1370
|
+
c.extensions && c.extensions[k.KHR_DRACO_MESH_COMPRESSION] ? f = i(c) : f = Gt(new Wn(), c, e), n[u] = { primitive: c, promise: f }, s.push(f);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
return Promise.all(s);
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
|
|
1377
|
+
*
|
|
1378
|
+
* @private
|
|
1379
|
+
* @param {number} meshIndex
|
|
1380
|
+
* @return {Promise<Group|Mesh|SkinnedMesh|Line|Points>}
|
|
1381
|
+
*/
|
|
1382
|
+
loadMesh(t) {
|
|
1383
|
+
const e = this, r = this.json, n = this.extensions, i = r.meshes[t], s = i.primitives, a = [];
|
|
1384
|
+
for (let o = 0, c = s.length; o < c; o++) {
|
|
1385
|
+
const u = s[o].material === void 0 ? Fs(this.cache) : this.getDependency("material", s[o].material);
|
|
1386
|
+
a.push(u);
|
|
1387
|
+
}
|
|
1388
|
+
return a.push(e.loadGeometries(s)), Promise.all(a).then(function(o) {
|
|
1389
|
+
const c = o.slice(0, o.length - 1), u = o[o.length - 1], l = [];
|
|
1390
|
+
for (let h = 0, T = u.length; h < T; h++) {
|
|
1391
|
+
const m = u[h], b = s[h];
|
|
1392
|
+
let S;
|
|
1393
|
+
const P = c[h];
|
|
1394
|
+
if (b.mode === ce.TRIANGLES || b.mode === ce.TRIANGLE_STRIP || b.mode === ce.TRIANGLE_FAN || b.mode === void 0)
|
|
1395
|
+
S = i.isSkinnedMesh === !0 ? new Xn(m, P) : new zn(m, P), S.isSkinnedMesh === !0 && S.normalizeSkinWeights(), b.mode === ce.TRIANGLE_STRIP ? S.geometry = Pt(S.geometry, Wt) : b.mode === ce.TRIANGLE_FAN && (S.geometry = Pt(S.geometry, Tt));
|
|
1396
|
+
else if (b.mode === ce.LINES)
|
|
1397
|
+
S = new $n(m, P);
|
|
1398
|
+
else if (b.mode === ce.LINE_STRIP)
|
|
1399
|
+
S = new qn(m, P);
|
|
1400
|
+
else if (b.mode === ce.LINE_LOOP)
|
|
1401
|
+
S = new Yn(m, P);
|
|
1402
|
+
else if (b.mode === ce.POINTS)
|
|
1403
|
+
S = new Jn(m, P);
|
|
1404
|
+
else
|
|
1405
|
+
throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + b.mode);
|
|
1406
|
+
Object.keys(S.geometry.morphAttributes).length > 0 && Us(S, i), S.name = e.createUniqueName(i.name || "mesh_" + t), me(S, i), b.extensions && Ie(n, S, b), e.assignFinalMaterial(S), l.push(S);
|
|
1407
|
+
}
|
|
1408
|
+
for (let h = 0, T = l.length; h < T; h++)
|
|
1409
|
+
e.associations.set(l[h], {
|
|
1410
|
+
meshes: t,
|
|
1411
|
+
primitives: h
|
|
1412
|
+
});
|
|
1413
|
+
if (l.length === 1)
|
|
1414
|
+
return i.extensions && Ie(n, l[0], i), l[0];
|
|
1415
|
+
const f = new dt();
|
|
1416
|
+
i.extensions && Ie(n, f, i), e.associations.set(f, { meshes: t });
|
|
1417
|
+
for (let h = 0, T = l.length; h < T; h++)
|
|
1418
|
+
f.add(l[h]);
|
|
1419
|
+
return f;
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
/**
|
|
1423
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
|
|
1424
|
+
*
|
|
1425
|
+
* @private
|
|
1426
|
+
* @param {number} cameraIndex
|
|
1427
|
+
* @return {Promise<Camera>|undefined}
|
|
1428
|
+
*/
|
|
1429
|
+
loadCamera(t) {
|
|
1430
|
+
let e;
|
|
1431
|
+
const r = this.json.cameras[t], n = r[r.type];
|
|
1432
|
+
if (!n) {
|
|
1433
|
+
console.warn("THREE.GLTFLoader: Missing camera parameters.");
|
|
1434
|
+
return;
|
|
1435
|
+
}
|
|
1436
|
+
return r.type === "perspective" ? e = new Qn(Zn.radToDeg(n.yfov), n.aspectRatio || 1, n.znear || 1, n.zfar || 2e6) : r.type === "orthographic" && (e = new es(-n.xmag, n.xmag, n.ymag, -n.ymag, n.znear, n.zfar)), r.name && (e.name = this.createUniqueName(r.name)), me(e, r), Promise.resolve(e);
|
|
1437
|
+
}
|
|
1438
|
+
/**
|
|
1439
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
|
|
1440
|
+
*
|
|
1441
|
+
* @private
|
|
1442
|
+
* @param {number} skinIndex
|
|
1443
|
+
* @return {Promise<Skeleton>}
|
|
1444
|
+
*/
|
|
1445
|
+
loadSkin(t) {
|
|
1446
|
+
const e = this.json.skins[t], r = [];
|
|
1447
|
+
for (let n = 0, i = e.joints.length; n < i; n++)
|
|
1448
|
+
r.push(this._loadNodeShallow(e.joints[n]));
|
|
1449
|
+
return e.inverseBindMatrices !== void 0 ? r.push(this.getDependency("accessor", e.inverseBindMatrices)) : r.push(null), Promise.all(r).then(function(n) {
|
|
1450
|
+
const i = n.pop(), s = n, a = [], o = [];
|
|
1451
|
+
for (let c = 0, u = s.length; c < u; c++) {
|
|
1452
|
+
const l = s[c];
|
|
1453
|
+
if (l) {
|
|
1454
|
+
a.push(l);
|
|
1455
|
+
const f = new Qe();
|
|
1456
|
+
i !== null && f.fromArray(i.array, c * 16), o.push(f);
|
|
1457
|
+
} else
|
|
1458
|
+
console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', e.joints[c]);
|
|
1459
|
+
}
|
|
1460
|
+
return new ts(a, o);
|
|
1461
|
+
});
|
|
1462
|
+
}
|
|
1463
|
+
/**
|
|
1464
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
|
|
1465
|
+
*
|
|
1466
|
+
* @private
|
|
1467
|
+
* @param {number} animationIndex
|
|
1468
|
+
* @return {Promise<AnimationClip>}
|
|
1469
|
+
*/
|
|
1470
|
+
loadAnimation(t) {
|
|
1471
|
+
const e = this.json, r = this, n = e.animations[t], i = n.name ? n.name : "animation_" + t, s = [], a = [], o = [], c = [], u = [];
|
|
1472
|
+
for (let l = 0, f = n.channels.length; l < f; l++) {
|
|
1473
|
+
const h = n.channels[l], T = n.samplers[h.sampler], m = h.target, b = m.node, S = n.parameters !== void 0 ? n.parameters[T.input] : T.input, P = n.parameters !== void 0 ? n.parameters[T.output] : T.output;
|
|
1474
|
+
m.node !== void 0 && (s.push(this.getDependency("node", b)), a.push(this.getDependency("accessor", S)), o.push(this.getDependency("accessor", P)), c.push(T), u.push(m));
|
|
1475
|
+
}
|
|
1476
|
+
return Promise.all([
|
|
1477
|
+
Promise.all(s),
|
|
1478
|
+
Promise.all(a),
|
|
1479
|
+
Promise.all(o),
|
|
1480
|
+
Promise.all(c),
|
|
1481
|
+
Promise.all(u)
|
|
1482
|
+
]).then(function(l) {
|
|
1483
|
+
const f = l[0], h = l[1], T = l[2], m = l[3], b = l[4], S = [];
|
|
1484
|
+
for (let D = 0, y = f.length; D < y; D++) {
|
|
1485
|
+
const F = f[D], C = h[D], H = T[D], B = m[D], O = b[D];
|
|
1486
|
+
if (F === void 0) continue;
|
|
1487
|
+
F.updateMatrix && F.updateMatrix();
|
|
1488
|
+
const U = r._createAnimationTracks(F, C, H, B, O);
|
|
1489
|
+
if (U)
|
|
1490
|
+
for (let Z = 0; Z < U.length; Z++)
|
|
1491
|
+
S.push(U[Z]);
|
|
1492
|
+
}
|
|
1493
|
+
const P = new ns(i, void 0, S);
|
|
1494
|
+
return me(P, n), P;
|
|
1495
|
+
});
|
|
1496
|
+
}
|
|
1497
|
+
createNodeMesh(t) {
|
|
1498
|
+
const e = this.json, r = this, n = e.nodes[t];
|
|
1499
|
+
return n.mesh === void 0 ? null : r.getDependency("mesh", n.mesh).then(function(i) {
|
|
1500
|
+
const s = r._getNodeRef(r.meshCache, n.mesh, i);
|
|
1501
|
+
return n.weights !== void 0 && s.traverse(function(a) {
|
|
1502
|
+
if (a.isMesh)
|
|
1503
|
+
for (let o = 0, c = n.weights.length; o < c; o++)
|
|
1504
|
+
a.morphTargetInfluences[o] = n.weights[o];
|
|
1505
|
+
}), s;
|
|
1506
|
+
});
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
|
|
1510
|
+
*
|
|
1511
|
+
* @private
|
|
1512
|
+
* @param {number} nodeIndex
|
|
1513
|
+
* @return {Promise<Object3D>}
|
|
1514
|
+
*/
|
|
1515
|
+
loadNode(t) {
|
|
1516
|
+
const e = this.json, r = this, n = e.nodes[t], i = r._loadNodeShallow(t), s = [], a = n.children || [];
|
|
1517
|
+
for (let c = 0, u = a.length; c < u; c++)
|
|
1518
|
+
s.push(r.getDependency("node", a[c]));
|
|
1519
|
+
const o = n.skin === void 0 ? Promise.resolve(null) : r.getDependency("skin", n.skin);
|
|
1520
|
+
return Promise.all([
|
|
1521
|
+
i,
|
|
1522
|
+
Promise.all(s),
|
|
1523
|
+
o
|
|
1524
|
+
]).then(function(c) {
|
|
1525
|
+
const u = c[0], l = c[1], f = c[2];
|
|
1526
|
+
f !== null && u.traverse(function(h) {
|
|
1527
|
+
h.isSkinnedMesh && h.bind(f, Gs);
|
|
1528
|
+
});
|
|
1529
|
+
for (let h = 0, T = l.length; h < T; h++)
|
|
1530
|
+
u.add(l[h]);
|
|
1531
|
+
return u;
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
// ._loadNodeShallow() parses a single node.
|
|
1535
|
+
// skin and child nodes are created and added in .loadNode() (no '_' prefix).
|
|
1536
|
+
_loadNodeShallow(t) {
|
|
1537
|
+
const e = this.json, r = this.extensions, n = this;
|
|
1538
|
+
if (this.nodeCache[t] !== void 0)
|
|
1539
|
+
return this.nodeCache[t];
|
|
1540
|
+
const i = e.nodes[t], s = i.name ? n.createUniqueName(i.name) : "", a = [], o = n._invokeOne(function(c) {
|
|
1541
|
+
return c.createNodeMesh && c.createNodeMesh(t);
|
|
1542
|
+
});
|
|
1543
|
+
return o && a.push(o), i.camera !== void 0 && a.push(n.getDependency("camera", i.camera).then(function(c) {
|
|
1544
|
+
return n._getNodeRef(n.cameraCache, i.camera, c);
|
|
1545
|
+
})), n._invokeAll(function(c) {
|
|
1546
|
+
return c.createNodeAttachment && c.createNodeAttachment(t);
|
|
1547
|
+
}).forEach(function(c) {
|
|
1548
|
+
a.push(c);
|
|
1549
|
+
}), this.nodeCache[t] = Promise.all(a).then(function(c) {
|
|
1550
|
+
let u;
|
|
1551
|
+
if (i.isBone === !0 ? u = new ss() : c.length > 1 ? u = new dt() : c.length === 1 ? u = c[0] : u = new qt(), u !== c[0])
|
|
1552
|
+
for (let l = 0, f = c.length; l < f; l++)
|
|
1553
|
+
u.add(c[l]);
|
|
1554
|
+
if (i.name && (u.userData.name = i.name, u.name = s), me(u, i), i.extensions && Ie(r, u, i), i.matrix !== void 0) {
|
|
1555
|
+
const l = new Qe();
|
|
1556
|
+
l.fromArray(i.matrix), u.applyMatrix4(l);
|
|
1557
|
+
} else
|
|
1558
|
+
i.translation !== void 0 && u.position.fromArray(i.translation), i.rotation !== void 0 && u.quaternion.fromArray(i.rotation), i.scale !== void 0 && u.scale.fromArray(i.scale);
|
|
1559
|
+
if (!n.associations.has(u))
|
|
1560
|
+
n.associations.set(u, {});
|
|
1561
|
+
else if (i.mesh !== void 0 && n.meshCache.refs[i.mesh] > 1) {
|
|
1562
|
+
const l = n.associations.get(u);
|
|
1563
|
+
n.associations.set(u, { ...l });
|
|
1564
|
+
}
|
|
1565
|
+
return n.associations.get(u).nodes = t, u;
|
|
1566
|
+
}), this.nodeCache[t];
|
|
1567
|
+
}
|
|
1568
|
+
/**
|
|
1569
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
|
|
1570
|
+
*
|
|
1571
|
+
* @private
|
|
1572
|
+
* @param {number} sceneIndex
|
|
1573
|
+
* @return {Promise<Group>}
|
|
1574
|
+
*/
|
|
1575
|
+
loadScene(t) {
|
|
1576
|
+
const e = this.extensions, r = this.json.scenes[t], n = this, i = new dt();
|
|
1577
|
+
r.name && (i.name = n.createUniqueName(r.name)), me(i, r), r.extensions && Ie(e, i, r);
|
|
1578
|
+
const s = r.nodes || [], a = [];
|
|
1579
|
+
for (let o = 0, c = s.length; o < c; o++)
|
|
1580
|
+
a.push(n.getDependency("node", s[o]));
|
|
1581
|
+
return Promise.all(a).then(function(o) {
|
|
1582
|
+
for (let u = 0, l = o.length; u < l; u++)
|
|
1583
|
+
i.add(o[u]);
|
|
1584
|
+
const c = (u) => {
|
|
1585
|
+
const l = /* @__PURE__ */ new Map();
|
|
1586
|
+
for (const [f, h] of n.associations)
|
|
1587
|
+
(f instanceof lt || f instanceof Nt) && l.set(f, h);
|
|
1588
|
+
return u.traverse((f) => {
|
|
1589
|
+
const h = n.associations.get(f);
|
|
1590
|
+
h != null && l.set(f, h);
|
|
1591
|
+
}), l;
|
|
1592
|
+
};
|
|
1593
|
+
return n.associations = c(i), i;
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
_createAnimationTracks(t, e, r, n, i) {
|
|
1597
|
+
const s = [], a = t.name ? t.name : t.uuid, o = [];
|
|
1598
|
+
Se[i.path] === Se.weights ? t.traverse(function(f) {
|
|
1599
|
+
f.morphTargetInfluences && o.push(f.name ? f.name : f.uuid);
|
|
1600
|
+
}) : o.push(a);
|
|
1601
|
+
let c;
|
|
1602
|
+
switch (Se[i.path]) {
|
|
1603
|
+
case Se.weights:
|
|
1604
|
+
c = Ot;
|
|
1605
|
+
break;
|
|
1606
|
+
case Se.rotation:
|
|
1607
|
+
c = Dt;
|
|
1608
|
+
break;
|
|
1609
|
+
case Se.translation:
|
|
1610
|
+
case Se.scale:
|
|
1611
|
+
c = Ct;
|
|
1612
|
+
break;
|
|
1613
|
+
default:
|
|
1614
|
+
r.itemSize === 1 ? c = Ot : c = Ct;
|
|
1615
|
+
break;
|
|
1616
|
+
}
|
|
1617
|
+
const u = n.interpolation !== void 0 ? Ds[n.interpolation] : Zt, l = this._getArrayFromAccessor(r);
|
|
1618
|
+
for (let f = 0, h = o.length; f < h; f++) {
|
|
1619
|
+
const T = new c(
|
|
1620
|
+
o[f] + "." + Se[i.path],
|
|
1621
|
+
e.array,
|
|
1622
|
+
l,
|
|
1623
|
+
u
|
|
1624
|
+
);
|
|
1625
|
+
n.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(T), s.push(T);
|
|
1626
|
+
}
|
|
1627
|
+
return s;
|
|
1628
|
+
}
|
|
1629
|
+
_getArrayFromAccessor(t) {
|
|
1630
|
+
let e = t.array;
|
|
1631
|
+
if (t.normalized) {
|
|
1632
|
+
const r = wt(e.constructor), n = new Float32Array(e.length);
|
|
1633
|
+
for (let i = 0, s = e.length; i < s; i++)
|
|
1634
|
+
n[i] = e[i] * r;
|
|
1635
|
+
e = n;
|
|
1636
|
+
}
|
|
1637
|
+
return e;
|
|
1638
|
+
}
|
|
1639
|
+
_createCubicSplineTrackInterpolant(t) {
|
|
1640
|
+
t.createInterpolant = function(r) {
|
|
1641
|
+
const n = this instanceof Dt ? Os : tn;
|
|
1642
|
+
return new n(this.times, this.values, this.getValueSize() / 3, r);
|
|
1643
|
+
}, t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
function Vs(d, t, e) {
|
|
1647
|
+
const r = t.attributes, n = new as();
|
|
1648
|
+
if (r.POSITION !== void 0) {
|
|
1649
|
+
const a = e.json.accessors[r.POSITION], o = a.min, c = a.max;
|
|
1650
|
+
if (o !== void 0 && c !== void 0) {
|
|
1651
|
+
if (n.set(
|
|
1652
|
+
new Oe(o[0], o[1], o[2]),
|
|
1653
|
+
new Oe(c[0], c[1], c[2])
|
|
1654
|
+
), a.normalized) {
|
|
1655
|
+
const u = wt(De[a.componentType]);
|
|
1656
|
+
n.min.multiplyScalar(u), n.max.multiplyScalar(u);
|
|
1657
|
+
}
|
|
1658
|
+
} else {
|
|
1659
|
+
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
|
|
1660
|
+
return;
|
|
1661
|
+
}
|
|
1662
|
+
} else
|
|
1663
|
+
return;
|
|
1664
|
+
const i = t.targets;
|
|
1665
|
+
if (i !== void 0) {
|
|
1666
|
+
const a = new Oe(), o = new Oe();
|
|
1667
|
+
for (let c = 0, u = i.length; c < u; c++) {
|
|
1668
|
+
const l = i[c];
|
|
1669
|
+
if (l.POSITION !== void 0) {
|
|
1670
|
+
const f = e.json.accessors[l.POSITION], h = f.min, T = f.max;
|
|
1671
|
+
if (h !== void 0 && T !== void 0) {
|
|
1672
|
+
if (o.setX(Math.max(Math.abs(h[0]), Math.abs(T[0]))), o.setY(Math.max(Math.abs(h[1]), Math.abs(T[1]))), o.setZ(Math.max(Math.abs(h[2]), Math.abs(T[2]))), f.normalized) {
|
|
1673
|
+
const m = wt(De[f.componentType]);
|
|
1674
|
+
o.multiplyScalar(m);
|
|
1675
|
+
}
|
|
1676
|
+
a.max(o);
|
|
1677
|
+
} else
|
|
1678
|
+
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
n.expandByVector(a);
|
|
1682
|
+
}
|
|
1683
|
+
d.boundingBox = n;
|
|
1684
|
+
const s = new cs();
|
|
1685
|
+
n.getCenter(s.center), s.radius = n.min.distanceTo(n.max) / 2, d.boundingSphere = s;
|
|
1686
|
+
}
|
|
1687
|
+
function Gt(d, t, e) {
|
|
1688
|
+
const r = t.attributes, n = [];
|
|
1689
|
+
function i(s, a) {
|
|
1690
|
+
return e.getDependency("accessor", s).then(function(o) {
|
|
1691
|
+
d.setAttribute(a, o);
|
|
1692
|
+
});
|
|
1693
|
+
}
|
|
1694
|
+
for (const s in r) {
|
|
1695
|
+
const a = xt[s] || s.toLowerCase();
|
|
1696
|
+
a in d.attributes || n.push(i(r[s], a));
|
|
1697
|
+
}
|
|
1698
|
+
if (t.indices !== void 0 && !d.index) {
|
|
1699
|
+
const s = e.getDependency("accessor", t.indices).then(function(a) {
|
|
1700
|
+
d.setIndex(a);
|
|
1701
|
+
});
|
|
1702
|
+
n.push(s);
|
|
1703
|
+
}
|
|
1704
|
+
return Ft.workingColorSpace !== Re && "COLOR_0" in r && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Ft.workingColorSpace}" not supported.`), me(d, t), Vs(d, t, e), Promise.all(n).then(function() {
|
|
1705
|
+
return t.targets !== void 0 ? Ps(d, t.targets, e) : d;
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
const Q = (...d) => {
|
|
1709
|
+
}, Ks = (...d) => {
|
|
1710
|
+
}, jt = ({ analyser: d }) => {
|
|
1711
|
+
const t = L(null), e = L(null);
|
|
1712
|
+
return ie(() => {
|
|
1713
|
+
const r = t.current;
|
|
1714
|
+
if (!r) return;
|
|
1715
|
+
const n = r.getContext("2d", { alpha: !0 });
|
|
1716
|
+
if (!n) return;
|
|
1717
|
+
let i, s = null;
|
|
1718
|
+
d && (d.fftSize = 128, s = new Uint8Array(d.frequencyBinCount));
|
|
1719
|
+
const a = () => {
|
|
1720
|
+
i = requestAnimationFrame(a), (r.width !== r.offsetWidth || r.height !== r.offsetHeight) && (r.width = r.offsetWidth, r.height = r.offsetHeight);
|
|
1721
|
+
const o = r.width, c = r.height;
|
|
1722
|
+
if (o === 0 || c === 0) return;
|
|
1723
|
+
const u = c / 2;
|
|
1724
|
+
n.clearRect(0, 0, o, c), n.fillStyle = "#1e293b";
|
|
1725
|
+
const l = 2, h = l + 2, T = o * 0.95, m = Math.floor(T / h);
|
|
1726
|
+
(!e.current || e.current.length !== m) && (e.current = new Float32Array(m).fill(2));
|
|
1727
|
+
const b = m * h, S = (o - b) / 2;
|
|
1728
|
+
d && s && d.getByteFrequencyData(s);
|
|
1729
|
+
const P = s ? s.length : 0, y = Math.floor(P * 0.7) / m, F = new Float32Array(m);
|
|
1730
|
+
for (let C = 0; C < m; C++) {
|
|
1731
|
+
let H = 0;
|
|
1732
|
+
if (s && y > 0) {
|
|
1733
|
+
const U = Math.floor(C * y), Z = Math.floor((C + 1) * y);
|
|
1734
|
+
for (let ue = U; ue < Z; ue++) {
|
|
1735
|
+
const Te = s[ue] || 0;
|
|
1736
|
+
Te > H && (H = Te);
|
|
36
1737
|
}
|
|
37
1738
|
}
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
1739
|
+
H < 10 && (H = 0);
|
|
1740
|
+
const B = H / 255, O = H > 0 ? Math.max(2, Math.pow(B, 1.4) * c * 0.25) : 2;
|
|
1741
|
+
F[C] = O;
|
|
41
1742
|
}
|
|
42
|
-
for (let
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
1743
|
+
for (let C = 0; C < m; C++) {
|
|
1744
|
+
const H = m - 1 - C, B = Math.max(F[C], F[H]), O = e.current[C] + (B - e.current[C]) * 0.3;
|
|
1745
|
+
e.current[C] = O;
|
|
1746
|
+
const U = S + C * h, Z = u - O / 2;
|
|
1747
|
+
n.beginPath(), n.roundRect ? n.roundRect(U, Z, l, O, 4) : n.fillRect(U, Z, l, O), n.fill();
|
|
47
1748
|
}
|
|
48
1749
|
};
|
|
49
|
-
return
|
|
50
|
-
cancelAnimationFrame(
|
|
1750
|
+
return a(), () => {
|
|
1751
|
+
cancelAnimationFrame(i);
|
|
51
1752
|
};
|
|
52
|
-
}, [d]), /* @__PURE__ */
|
|
53
|
-
},
|
|
54
|
-
async function
|
|
55
|
-
const
|
|
56
|
-
return Array.from(new Uint8Array(
|
|
1753
|
+
}, [d]), /* @__PURE__ */ N("canvas", { ref: t, style: { width: "100%", height: "100%", display: "block" } });
|
|
1754
|
+
}, Vt = "https://ai.streamoji.com", Ws = "https://pub-48df6f7d60d6440bbd01676ea5d90e55.r2.dev";
|
|
1755
|
+
async function Xs(d) {
|
|
1756
|
+
const t = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(d));
|
|
1757
|
+
return Array.from(new Uint8Array(t)).map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
57
1758
|
}
|
|
58
|
-
function
|
|
59
|
-
const [
|
|
60
|
-
return
|
|
1759
|
+
function zs(d) {
|
|
1760
|
+
const [t, e] = K(null);
|
|
1761
|
+
return ie(() => {
|
|
61
1762
|
if (!d) {
|
|
62
|
-
|
|
1763
|
+
e(null);
|
|
63
1764
|
return;
|
|
64
1765
|
}
|
|
65
|
-
let
|
|
66
|
-
return
|
|
67
|
-
if (
|
|
68
|
-
const
|
|
69
|
-
fetch(
|
|
70
|
-
|
|
1766
|
+
let r = !1;
|
|
1767
|
+
return Xs(d).then((n) => {
|
|
1768
|
+
if (r) return;
|
|
1769
|
+
const i = `${Ws}/${n}.glb`;
|
|
1770
|
+
fetch(i, { method: "HEAD" }).then((s) => {
|
|
1771
|
+
r || e(s.ok ? i : null);
|
|
71
1772
|
}).catch(() => {
|
|
72
|
-
|
|
1773
|
+
r || e(null);
|
|
73
1774
|
});
|
|
74
1775
|
}), () => {
|
|
75
|
-
|
|
1776
|
+
r = !0;
|
|
76
1777
|
};
|
|
77
|
-
}, [d]),
|
|
1778
|
+
}, [d]), t;
|
|
78
1779
|
}
|
|
79
|
-
const
|
|
1780
|
+
const $s = [
|
|
80
1781
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_Variations_001.glb",
|
|
81
1782
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_Variations_002.glb",
|
|
82
1783
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_002.glb",
|
|
83
1784
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_Variations_005.glb"
|
|
84
|
-
],
|
|
1785
|
+
], qs = [
|
|
85
1786
|
{
|
|
86
1787
|
id: "m_expr_01",
|
|
87
1788
|
name: "Friendly Wave",
|
|
@@ -247,17 +1948,17 @@ const Ut = [
|
|
|
247
1948
|
name: "Take It Easy",
|
|
248
1949
|
url: "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/F_Talking_Variations_006.glb"
|
|
249
1950
|
}
|
|
250
|
-
],
|
|
1951
|
+
], Ys = [
|
|
251
1952
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/M_Talking_Variations_005.glb",
|
|
252
1953
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/M_Talking_Variations_007.glb"
|
|
253
|
-
],
|
|
1954
|
+
], Js = {
|
|
254
1955
|
zoom: 0.85,
|
|
255
1956
|
position: [0.15, -0.8, 0],
|
|
256
1957
|
scale: 1.5,
|
|
257
1958
|
rotation: [0.15, 0.02, 0]
|
|
258
|
-
},
|
|
1959
|
+
}, Qs = [-0.45, 1.9, 0.1], Zs = {
|
|
259
1960
|
browInnerUp: 0.2
|
|
260
|
-
},
|
|
1961
|
+
}, mt = 0.18, er = 1, Je = {
|
|
261
1962
|
neutral: { eyeLookDownLeft: 0.1, eyeLookDownRight: 0.1 },
|
|
262
1963
|
happy: { mouthSmileLeft: 0.2, mouthSmileRight: 0.2, eyeLookDownLeft: 0.1, eyeLookDownRight: 0.1 },
|
|
263
1964
|
sad: { eyeLookDownLeft: 0.2, eyeLookDownRight: 0.2, browDownRight: 0.1, browInnerUp: 0.6, browOuterUpRight: 0.2, eyeSquintLeft: 0.7, eyeSquintRight: 0.7, mouthFrownLeft: 0.8, mouthFrownRight: 0.8, mouthLeft: 0.2, mouthPucker: 0.5, mouthRollLower: 0.2, mouthRollUpper: 0.2, mouthShrugLower: 0.2, mouthShrugUpper: 0.2, mouthStretchLeft: 0.4 },
|
|
@@ -265,7 +1966,7 @@ const Ut = [
|
|
|
265
1966
|
fear: { browInnerUp: 0.7, eyeSquintLeft: 0.5, eyeSquintRight: 0.5, eyeWideLeft: 0.6, eyeWideRight: 0.6, mouthClose: 0.1, mouthFunnel: 0.3, mouthShrugLower: 0.5, mouthShrugUpper: 0.5 },
|
|
266
1967
|
disgust: { browDownLeft: 0.7, browDownRight: 0.1, browInnerUp: 0.3, eyeSquintLeft: 1, eyeSquintRight: 1, eyeWideLeft: 0.5, eyeWideRight: 0.5, mouthLeft: 0.4, mouthPressLeft: 0.3, mouthRollLower: 0.3, mouthShrugLower: 0.3, mouthShrugUpper: 0.8, mouthUpperUpLeft: 0.3, noseSneerLeft: 1, noseSneerRight: 0.7 },
|
|
267
1968
|
love: { browInnerUp: 0.4, browOuterUpLeft: 0.2, browOuterUpRight: 0.2, mouthSmileLeft: 0.2, mouthSmileRight: 0.2, eyeBlinkLeft: 0.6, eyeBlinkRight: 0.6, eyeWideLeft: 0.7, eyeWideRight: 0.7, mouthDimpleLeft: 0.1, mouthDimpleRight: 0.1, mouthPressLeft: 0.2, mouthShrugUpper: 0.2, mouthUpperUpLeft: 0.1, mouthUpperUpRight: 0.1 }
|
|
268
|
-
},
|
|
1969
|
+
}, tr = [
|
|
269
1970
|
{ key: "viseme_aa", mix: { jawOpen: 0.6 } },
|
|
270
1971
|
{ key: "viseme_E", mix: { mouthPressLeft: 0.8, mouthPressRight: 0.8, mouthDimpleLeft: 1, mouthDimpleRight: 1, jawOpen: 0.3 } },
|
|
271
1972
|
{ key: "viseme_I", mix: { mouthPressLeft: 0.6, mouthPressRight: 0.6, mouthDimpleLeft: 0.6, mouthDimpleRight: 0.6, jawOpen: 0.2 } },
|
|
@@ -281,7 +1982,7 @@ const Ut = [
|
|
|
281
1982
|
{ key: "viseme_kk", mix: { mouthLowerDownLeft: 0.4, mouthLowerDownRight: 0.4, mouthDimpleLeft: 0.3, mouthDimpleRight: 0.3, mouthFunnel: 0.3, mouthPucker: 0.3, jawOpen: 0.15 } },
|
|
282
1983
|
{ key: "viseme_nn", mix: { mouthLowerDownLeft: 0.4, mouthLowerDownRight: 0.4, mouthDimpleLeft: 0.3, mouthDimpleRight: 0.3, mouthFunnel: 0.3, mouthPucker: 0.3, jawOpen: 0.15, tongueOut: 0.2 } },
|
|
283
1984
|
{ key: "viseme_sil", mix: {} }
|
|
284
|
-
],
|
|
1985
|
+
], nr = {
|
|
285
1986
|
aei: [{ v: "E", w: 0.8 }, { v: "I", w: 0.2 }],
|
|
286
1987
|
ee: [{ v: "I", w: 1 }],
|
|
287
1988
|
oo: [{ v: "O", w: 1 }],
|
|
@@ -298,466 +1999,466 @@ const Ut = [
|
|
|
298
1999
|
cdgknstxyz: [{ v: "DD", w: 0.6 }, { v: "SS", w: 0.4 }],
|
|
299
2000
|
sil: [{ v: "sil", w: 1 }]
|
|
300
2001
|
};
|
|
301
|
-
function
|
|
2002
|
+
function sr(d) {
|
|
302
2003
|
if (!d) return [{ v: "sil", w: 1 }];
|
|
303
|
-
const
|
|
304
|
-
return
|
|
2004
|
+
const t = d.toLowerCase();
|
|
2005
|
+
return nr[t] ?? [{ v: "sil", w: 1 }];
|
|
305
2006
|
}
|
|
306
|
-
function
|
|
307
|
-
const { camera:
|
|
308
|
-
return
|
|
309
|
-
|
|
310
|
-
}, [
|
|
2007
|
+
function rr({ target: d }) {
|
|
2008
|
+
const { camera: t } = Sn();
|
|
2009
|
+
return ie(() => {
|
|
2010
|
+
t.lookAt(...d);
|
|
2011
|
+
}, [t, d]), null;
|
|
311
2012
|
}
|
|
312
|
-
function
|
|
2013
|
+
function ne(d, t, e) {
|
|
313
2014
|
if (!d || !d.morphTargetDictionary) return;
|
|
314
|
-
const
|
|
315
|
-
if (
|
|
316
|
-
for (const
|
|
317
|
-
|
|
2015
|
+
const r = d, n = r.morphTargetDictionary, i = r.morphTargetInfluences;
|
|
2016
|
+
if (i)
|
|
2017
|
+
for (const s in n)
|
|
2018
|
+
s.toLowerCase() === t.toLowerCase() && (i[n[s]] = e);
|
|
318
2019
|
}
|
|
319
|
-
function
|
|
2020
|
+
function Kt(d, t = 0.97) {
|
|
320
2021
|
if (!d) return;
|
|
321
|
-
const
|
|
322
|
-
if (
|
|
323
|
-
for (let
|
|
324
|
-
|
|
2022
|
+
const e = d;
|
|
2023
|
+
if (e.morphTargetInfluences)
|
|
2024
|
+
for (let r = 0; r < e.morphTargetInfluences.length; r++)
|
|
2025
|
+
e.morphTargetInfluences[r] *= t;
|
|
325
2026
|
}
|
|
326
|
-
const
|
|
327
|
-
const { scene: m } =
|
|
328
|
-
|
|
329
|
-
if (!(!
|
|
330
|
-
if (
|
|
331
|
-
const
|
|
332
|
-
if (!
|
|
333
|
-
const
|
|
334
|
-
|
|
2027
|
+
const ir = bn(({ avatarUrl: d, isPlayingRef: t, visemeQueueRef: e, audioContextRef: r, responseAudioStartTimeRef: n, adjustments: i, mood: s, expression: a, agentResponse: o, isSpeaking: c, nextStartTimeRef: u, stopPlayback: l, setIsSpeaking: f, expressionUrl: h, onExpressionFinished: T }) => {
|
|
2028
|
+
const { scene: m } = ct(d), b = ct($s), S = gt(() => b.flatMap((v) => v.animations), [b]), P = ct(Ys), D = gt(() => P.flatMap((v) => v.animations), [P]), y = L(null), F = L(null), C = L(null), H = L([]), [B] = K(() => new Ge.AnimationMixer(m)), O = L({}), U = L(null), Z = L(0), ue = L(!1), Te = L(0), ye = L(null);
|
|
2029
|
+
ie(() => {
|
|
2030
|
+
if (!(!S || !m)) {
|
|
2031
|
+
if (S.forEach((v, A) => {
|
|
2032
|
+
const x = `idle_${A}`;
|
|
2033
|
+
if (!O.current[x]) {
|
|
2034
|
+
const g = B.clipAction(v, m);
|
|
2035
|
+
g.name = x, g.setLoop(Ge.LoopOnce, 1), g.clampWhenFinished = !0, O.current[x] = g;
|
|
335
2036
|
}
|
|
336
|
-
}),
|
|
337
|
-
const
|
|
338
|
-
if (!
|
|
339
|
-
const
|
|
340
|
-
|
|
2037
|
+
}), D.forEach((v, A) => {
|
|
2038
|
+
const x = `talk_${A}`;
|
|
2039
|
+
if (!O.current[x]) {
|
|
2040
|
+
const g = B.clipAction(v, m);
|
|
2041
|
+
g.name = x, g.setLoop(Ge.LoopOnce, 1), g.clampWhenFinished = !0, O.current[x] = g;
|
|
341
2042
|
}
|
|
342
|
-
}),
|
|
343
|
-
const
|
|
344
|
-
|
|
2043
|
+
}), S.length > 0) {
|
|
2044
|
+
const v = O.current.idle_0, A = U.current && B.existingAction(U.current.getClip());
|
|
2045
|
+
v && !A && (v.reset().fadeIn(0.5).play(), U.current = v);
|
|
345
2046
|
}
|
|
346
2047
|
return () => {
|
|
347
|
-
|
|
2048
|
+
B.stopAllAction(), O.current = {}, U.current = null;
|
|
348
2049
|
};
|
|
349
2050
|
}
|
|
350
|
-
}, [
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
if (!
|
|
354
|
-
|
|
355
|
-
if (
|
|
356
|
-
const
|
|
357
|
-
if (
|
|
358
|
-
const
|
|
359
|
-
|
|
2051
|
+
}, [S, D, m, B]);
|
|
2052
|
+
const Xe = L("");
|
|
2053
|
+
ie(() => {
|
|
2054
|
+
if (!h || !m || h === Xe.current) return;
|
|
2055
|
+
Xe.current = h, ye.current = h, new us().load(h, (A) => {
|
|
2056
|
+
if (A.animations && A.animations.length > 0) {
|
|
2057
|
+
const x = A.animations[0], g = B.clipAction(x, m);
|
|
2058
|
+
if (g.name = `EXPR_${h}`, g.setLoop(Ge.LoopOnce, 1), g.clampWhenFinished = !0, O.current[`EXPR_${h}`] = g, c && ye.current === h) {
|
|
2059
|
+
const M = U.current;
|
|
2060
|
+
g.reset().fadeIn(0.3).play(), M && M !== g && M.crossFadeTo(g, 0.3, !0), U.current = g, ye.current = null;
|
|
360
2061
|
}
|
|
361
2062
|
}
|
|
362
|
-
}, void 0, (
|
|
363
|
-
console.error(`[ANIMATION] Failed to load ${
|
|
2063
|
+
}, void 0, (A) => {
|
|
2064
|
+
console.error(`[ANIMATION] Failed to load ${h}`, A);
|
|
364
2065
|
});
|
|
365
|
-
}, [
|
|
366
|
-
const
|
|
367
|
-
const
|
|
368
|
-
if (
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
} else if (
|
|
372
|
-
if (
|
|
373
|
-
const
|
|
374
|
-
|
|
2066
|
+
}, [h, m, B, c]), ie(() => {
|
|
2067
|
+
const v = (A) => {
|
|
2068
|
+
const x = A.action, g = x.name || "";
|
|
2069
|
+
if (g.startsWith("idle_")) {
|
|
2070
|
+
const ee = (parseInt(g.split("_")[1]) + 1) % S.length, X = O.current[`idle_${ee}`];
|
|
2071
|
+
X && (X.reset().fadeIn(0.5).play(), x.crossFadeTo(X, 0.5, !0), U.current = X);
|
|
2072
|
+
} else if (g.startsWith("EXPR_")) {
|
|
2073
|
+
if (c) {
|
|
2074
|
+
const M = O.current.talk_0;
|
|
2075
|
+
M && (M.reset().fadeIn(0.5).play(), x.crossFadeTo(M, 0.5, !0), U.current = M);
|
|
375
2076
|
} else {
|
|
376
|
-
const
|
|
377
|
-
|
|
2077
|
+
const M = O.current.idle_0;
|
|
2078
|
+
M && (M.reset().fadeIn(0.5).play(), x.crossFadeTo(M, 0.5, !0), U.current = M);
|
|
378
2079
|
}
|
|
379
|
-
|
|
380
|
-
} else if (
|
|
381
|
-
if (
|
|
382
|
-
const
|
|
383
|
-
|
|
2080
|
+
T && T();
|
|
2081
|
+
} else if (g.startsWith("talk_"))
|
|
2082
|
+
if (c) {
|
|
2083
|
+
const ee = (parseInt(g.split("_")[1]) + 1) % D.length, X = O.current[`talk_${ee}`];
|
|
2084
|
+
X && (X.reset().fadeIn(0.3).play(), x.crossFadeTo(X, 0.3, !0), U.current = X);
|
|
384
2085
|
} else {
|
|
385
|
-
const
|
|
386
|
-
|
|
2086
|
+
const M = O.current.idle_0;
|
|
2087
|
+
M && (M.reset().fadeIn(0.5).play(), x.crossFadeTo(M, 0.5, !0), U.current = M);
|
|
387
2088
|
}
|
|
388
2089
|
};
|
|
389
|
-
return
|
|
390
|
-
}, [
|
|
391
|
-
if (
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
394
|
-
const
|
|
395
|
-
if (
|
|
396
|
-
const
|
|
397
|
-
if (
|
|
398
|
-
|
|
2090
|
+
return B.addEventListener("finished", v), () => B.removeEventListener("finished", v);
|
|
2091
|
+
}, [B, S, D, c, T]), ie(() => {
|
|
2092
|
+
if (c && m) {
|
|
2093
|
+
const v = U.current, A = v?.name || "";
|
|
2094
|
+
if (A.startsWith("idle_") || A.startsWith("talk_") || A === "") {
|
|
2095
|
+
const x = ye.current;
|
|
2096
|
+
if (x) {
|
|
2097
|
+
const g = O.current[`EXPR_${x}`];
|
|
2098
|
+
if (g) {
|
|
2099
|
+
g.reset().fadeIn(0.3).play(), v && v !== g && v.crossFadeTo(g, 0.3, !0), U.current = g, ye.current = null;
|
|
399
2100
|
return;
|
|
400
2101
|
}
|
|
401
2102
|
}
|
|
402
|
-
if (
|
|
403
|
-
const
|
|
404
|
-
|
|
2103
|
+
if (A.startsWith("idle_") || A === "") {
|
|
2104
|
+
const g = O.current.talk_0;
|
|
2105
|
+
g && (g.reset().fadeIn(0.5).play(), v && v.crossFadeTo(g, 0.5, !0), U.current = g);
|
|
405
2106
|
}
|
|
406
2107
|
}
|
|
407
|
-
} else if (!
|
|
408
|
-
const
|
|
409
|
-
if (
|
|
410
|
-
const
|
|
411
|
-
|
|
2108
|
+
} else if (!c && m) {
|
|
2109
|
+
const v = U.current, A = v?.name || "";
|
|
2110
|
+
if (A.startsWith("talk_") || A.startsWith("EXPR_")) {
|
|
2111
|
+
const x = O.current.idle_0;
|
|
2112
|
+
x && (x.reset().fadeIn(0.5).play(), v && v.crossFadeTo(x, 0.5, !0), U.current = x);
|
|
412
2113
|
}
|
|
413
2114
|
}
|
|
414
|
-
}, [
|
|
2115
|
+
}, [c, m, h]), ie(() => {
|
|
415
2116
|
if (!m) return;
|
|
416
|
-
m.traverse((
|
|
417
|
-
if (
|
|
418
|
-
const
|
|
419
|
-
(
|
|
2117
|
+
m.traverse((x) => {
|
|
2118
|
+
if (x.isMesh && x.morphTargetDictionary) {
|
|
2119
|
+
const g = x.name.toLowerCase();
|
|
2120
|
+
(g.includes("head") || g.includes("avatar")) && (F.current = x, Q(`[ANIMATION] Found head mesh: ${x.name}`)), g.includes("teeth") && (C.current = x, Q(`[ANIMATION] Found teeth mesh: ${x.name}`));
|
|
420
2121
|
}
|
|
421
2122
|
});
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
const
|
|
425
|
-
m.traverse((
|
|
426
|
-
if (
|
|
427
|
-
const
|
|
428
|
-
|
|
2123
|
+
const v = F.current?.morphTargetDictionary;
|
|
2124
|
+
v && Object.keys(v).filter((x) => x.toLowerCase().includes("brow"));
|
|
2125
|
+
const A = [];
|
|
2126
|
+
m.traverse((x) => {
|
|
2127
|
+
if (x.isMesh) {
|
|
2128
|
+
const M = x.morphTargetDictionary;
|
|
2129
|
+
M && Object.keys(M).some((ee) => ee.toLowerCase().includes("brow")) && A.push(x);
|
|
429
2130
|
}
|
|
430
|
-
}),
|
|
2131
|
+
}), H.current = A, A.length > 0 && Q("[ANIMATION] Meshes with brow morphs:", A.length);
|
|
431
2132
|
}, [m]);
|
|
432
|
-
const
|
|
433
|
-
const
|
|
434
|
-
if (
|
|
435
|
-
for (const
|
|
436
|
-
const
|
|
437
|
-
|
|
2133
|
+
const Ze = (v, A = 1) => {
|
|
2134
|
+
const x = `viseme_${v}`.toLowerCase(), g = tr.find((M) => M.key.toLowerCase() === x);
|
|
2135
|
+
if (g)
|
|
2136
|
+
for (const M in g.mix) {
|
|
2137
|
+
const ee = g.mix[M] * A;
|
|
2138
|
+
ne(F.current, M, ee), ne(C.current, M, ee);
|
|
438
2139
|
}
|
|
439
|
-
},
|
|
440
|
-
const
|
|
441
|
-
for (const
|
|
442
|
-
|
|
2140
|
+
}, et = (v) => {
|
|
2141
|
+
const A = Je[v] ?? Je.neutral;
|
|
2142
|
+
for (const x in A)
|
|
2143
|
+
ne(F.current, x, A[x]), ne(C.current, x, A[x]);
|
|
443
2144
|
};
|
|
444
|
-
return
|
|
445
|
-
const
|
|
446
|
-
|
|
447
|
-
const
|
|
448
|
-
let
|
|
449
|
-
if (Math.floor(
|
|
450
|
-
let
|
|
451
|
-
m.traverse((
|
|
452
|
-
|
|
2145
|
+
return wn((v, A) => {
|
|
2146
|
+
const x = Math.pow(0.88, 60 * A);
|
|
2147
|
+
Kt(F.current, x), Kt(C.current, x), et(s);
|
|
2148
|
+
const g = v.clock.elapsedTime;
|
|
2149
|
+
let M = 0;
|
|
2150
|
+
if (Math.floor(g) % 5 === 0 && Math.floor((g - A) % 5) !== 0) {
|
|
2151
|
+
let te = null;
|
|
2152
|
+
m.traverse((se) => {
|
|
2153
|
+
se.name.toLowerCase().includes("hips") && (te = se);
|
|
453
2154
|
});
|
|
454
|
-
const
|
|
455
|
-
|
|
2155
|
+
const _e = te ? `Hips Y: ${te.position.y.toFixed(4)}` : "Hips not found";
|
|
2156
|
+
Q(`[ANIMATION] Mixer Time: ${B.time.toFixed(2)}, ${_e}`);
|
|
456
2157
|
}
|
|
457
|
-
if (
|
|
458
|
-
const
|
|
459
|
-
if (
|
|
460
|
-
|
|
2158
|
+
if (B.update(A), g > Z.current && !ue.current && (ue.current = !0, Te.current = g), ue.current) {
|
|
2159
|
+
const _e = (g - Te.current) / 0.3;
|
|
2160
|
+
if (_e >= 1)
|
|
2161
|
+
ue.current = !1, Z.current = g + 2 + Math.random() * 5;
|
|
461
2162
|
else {
|
|
462
|
-
const
|
|
463
|
-
|
|
2163
|
+
const se = _e < 0.5 ? _e * 2 : (1 - _e) * 2;
|
|
2164
|
+
ne(F.current, "eyeBlinkLeft", se), ne(F.current, "eyeBlinkRight", se), ne(C.current, "eyeBlinkLeft", se), ne(C.current, "eyeBlinkRight", se), M = se * Zs.browInnerUp;
|
|
464
2165
|
}
|
|
465
2166
|
}
|
|
466
|
-
const
|
|
467
|
-
if (
|
|
468
|
-
const
|
|
469
|
-
|
|
2167
|
+
const ee = Je[s] ?? Je.neutral, X = ee.browInnerUp ?? 0, Ae = ee.browOuterUpLeft ?? 0, Fe = ee.browOuterUpRight ?? 0, ke = g * er, Pe = mt * Math.sin(ke), Ue = mt * 0.7 * Math.sin(ke + 0.7), Rt = mt * 0.7 * Math.sin(ke + 1.3), Ne = (te) => Math.max(0, Math.min(1, te)), He = Ne(X + Pe), Be = Ne(Ae + Ue), be = Ne(Fe + Rt), Ee = Ne(He + M);
|
|
2168
|
+
if (ne(F.current, "browInnerUp", Ee), ne(C.current, "browInnerUp", Ee), ne(F.current, "browOuterUpLeft", Be), ne(C.current, "browOuterUpLeft", Be), ne(F.current, "browOuterUpRight", be), ne(C.current, "browOuterUpRight", be), y.current) {
|
|
2169
|
+
const te = t.current ? 0 : i.rotation[1];
|
|
2170
|
+
y.current.rotation.y = Ge.MathUtils.lerp(y.current.rotation.y, te, 0.1), y.current.position.set(...i.position), y.current.scale.setScalar(i.scale), y.current.rotation.x = i.rotation[0], y.current.rotation.z = i.rotation[2];
|
|
470
2171
|
}
|
|
471
|
-
if (
|
|
472
|
-
const
|
|
473
|
-
for (let
|
|
474
|
-
const
|
|
475
|
-
|
|
2172
|
+
if (t.current && r.current) {
|
|
2173
|
+
const te = r.current.currentTime, oe = (te - n.current) * 1e3 - -150;
|
|
2174
|
+
for (let fe = 0; fe < e.current.length; fe++) {
|
|
2175
|
+
const ae = e.current[fe];
|
|
2176
|
+
oe >= ae.vtime && oe < ae.vtime + ae.vduration && Ze(ae.viseme, ae.weight ?? 1);
|
|
476
2177
|
}
|
|
477
|
-
|
|
2178
|
+
te > u.current + 0.5 && (l(), f(!1));
|
|
478
2179
|
}
|
|
479
|
-
}), /* @__PURE__ */
|
|
2180
|
+
}), /* @__PURE__ */ N("group", { ref: y, children: /* @__PURE__ */ N("primitive", { object: m }) });
|
|
480
2181
|
});
|
|
481
|
-
function
|
|
2182
|
+
function or(d) {
|
|
482
2183
|
return d ? d.charAt(0).toUpperCase() + d.slice(1).toLowerCase() : "";
|
|
483
2184
|
}
|
|
484
|
-
const
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
const [
|
|
490
|
-
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
const
|
|
494
|
-
if (!(
|
|
495
|
-
if (
|
|
496
|
-
|
|
2185
|
+
const ar = ({ token: d, agentToken: t, onNavigationRequested: e } = {}) => {
|
|
2186
|
+
const r = d ?? t ?? "", n = zs(r || void 0), [i, s] = K(""), [a, o] = K(""), [c, u] = K("Ready"), [l, f] = K(!1), [h, T] = K(!1), m = L(!1), b = L([]), S = L(0), P = L(!1), D = L([]), y = L(null), F = L([]);
|
|
2187
|
+
L([]);
|
|
2188
|
+
const C = L([]), H = L(0), B = L(0), O = L(0), U = L(0), [Z, ue] = K(null), Te = L(null), [ye, Xe] = K("neutral"), [Ze, et] = K(""), [v, A] = K(""), [x, g] = K("Chat with us"), [M, ee] = K(null), [X, Ae] = K("hidden"), [Fe, ke] = K(""), Pe = L(null), Ue = L(X);
|
|
2189
|
+
Ue.current = X;
|
|
2190
|
+
const [Rt, Ne] = K(null), He = L(null), Be = L(null), [be, Ee] = K("hidden"), [te, _e] = K(""), se = L(be);
|
|
2191
|
+
se.current = be;
|
|
2192
|
+
const oe = L(""), fe = L(!1), ae = L(""), Ce = gt(() => c === "Thinking..." || c === "Processing Voice..." ? c : M != null && M !== "" && M !== "none" && M !== "<none>" ? `Enter ${or(M)}` : null, [c, M]), ze = Ce != null && Ce !== "";
|
|
2193
|
+
ie(() => {
|
|
2194
|
+
const p = Ue.current;
|
|
2195
|
+
if (!(p === "exiting" || p === "entering")) {
|
|
2196
|
+
if (p === "hidden") {
|
|
2197
|
+
ze && (ke(Ce ?? ""), Ae("entering"));
|
|
497
2198
|
return;
|
|
498
2199
|
}
|
|
499
|
-
|
|
2200
|
+
p === "visible" && (!ze || Ce !== Fe) && (Pe.current = ze ? Ce : null, Ae("exiting"));
|
|
500
2201
|
}
|
|
501
|
-
}, [
|
|
502
|
-
const
|
|
503
|
-
const
|
|
504
|
-
if (
|
|
505
|
-
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
} else
|
|
509
|
-
}, []),
|
|
510
|
-
if (!
|
|
511
|
-
if (
|
|
512
|
-
const
|
|
513
|
-
|
|
2202
|
+
}, [ze, Ce, X, Fe]);
|
|
2203
|
+
const nn = Ye(() => {
|
|
2204
|
+
const p = Ue.current;
|
|
2205
|
+
if (p === "exiting") {
|
|
2206
|
+
Ae("hidden");
|
|
2207
|
+
const w = Pe.current;
|
|
2208
|
+
Pe.current = null, w != null && w !== "" && (ke(w), Ae("entering"));
|
|
2209
|
+
} else p === "entering" && Ae("visible");
|
|
2210
|
+
}, []), sn = (p) => {
|
|
2211
|
+
if (!p) return;
|
|
2212
|
+
if (p.mood != null) {
|
|
2213
|
+
const _ = String(p.mood).toLowerCase();
|
|
2214
|
+
Xe(_);
|
|
514
2215
|
}
|
|
515
|
-
if (
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
const
|
|
519
|
-
|
|
2216
|
+
if (p.expression != null) {
|
|
2217
|
+
const _ = String(p.expression).trim();
|
|
2218
|
+
et(_);
|
|
2219
|
+
const I = qs.find((G) => G.name.toLowerCase() === _.toLowerCase());
|
|
2220
|
+
Q(`[STREAM] Animation match for "${_}": ${I ? I.name : "NONE"}`), A(I?.url ?? "");
|
|
520
2221
|
}
|
|
521
|
-
if (
|
|
522
|
-
const
|
|
523
|
-
|
|
2222
|
+
if (p.navigation != null) {
|
|
2223
|
+
const _ = String(p.navigation).trim();
|
|
2224
|
+
_ !== "" && (e ? e(_) : window.location.href = _);
|
|
524
2225
|
}
|
|
525
|
-
const
|
|
526
|
-
if (
|
|
527
|
-
const
|
|
528
|
-
|
|
529
|
-
} else (
|
|
530
|
-
|
|
531
|
-
},
|
|
532
|
-
const
|
|
533
|
-
if (!
|
|
534
|
-
if (
|
|
2226
|
+
const w = p.ask_for || p.lead_capture?.ask_for, R = w ? String(w).trim().toLowerCase() : "", E = R === "none" || R === "<none>";
|
|
2227
|
+
if (w && !E) {
|
|
2228
|
+
const _ = R;
|
|
2229
|
+
ee(_ || null), g(_ === "email" ? "Enter your email" : _ === "name" ? "Enter your name" : _ === "phone" ? "Enter your phone number" : "Chat with us");
|
|
2230
|
+
} else (E || p.ask_for === null || p.lead_capture && p.lead_capture.ask_for === null || p.ask_for === "none") && (ee(null), x !== "Chat with us" && g("Chat with us"));
|
|
2231
|
+
p.collected, p.valid;
|
|
2232
|
+
}, rn = (p) => {
|
|
2233
|
+
const w = p.trim();
|
|
2234
|
+
if (!w) return null;
|
|
2235
|
+
if (w.startsWith("{"))
|
|
535
2236
|
try {
|
|
536
|
-
return JSON.parse(
|
|
2237
|
+
return JSON.parse(w);
|
|
537
2238
|
} catch {
|
|
538
2239
|
return null;
|
|
539
2240
|
}
|
|
540
|
-
if (
|
|
541
|
-
const
|
|
542
|
-
return { [
|
|
2241
|
+
if (w.includes(":")) {
|
|
2242
|
+
const R = w.split(":"), E = R[0].trim().toLowerCase(), _ = R.slice(1).join(":").trim();
|
|
2243
|
+
return { [E]: _ };
|
|
543
2244
|
}
|
|
544
2245
|
return null;
|
|
545
|
-
},
|
|
546
|
-
}, []),
|
|
547
|
-
if (
|
|
548
|
-
|
|
549
|
-
else if (
|
|
550
|
-
|
|
2246
|
+
}, on = Ye(() => {
|
|
2247
|
+
}, []), St = (p) => {
|
|
2248
|
+
if (fe.current)
|
|
2249
|
+
p === "§" ? fe.current = !1 : (ae.current += p, o((w) => w + p));
|
|
2250
|
+
else if (p === "§") {
|
|
2251
|
+
fe.current = !0;
|
|
551
2252
|
return;
|
|
552
2253
|
} else
|
|
553
|
-
for (
|
|
2254
|
+
for (oe.current += p; oe.current.includes(`
|
|
554
2255
|
`); ) {
|
|
555
|
-
const
|
|
556
|
-
`),
|
|
557
|
-
|
|
558
|
-
const
|
|
559
|
-
|
|
2256
|
+
const w = oe.current.indexOf(`
|
|
2257
|
+
`), R = oe.current.slice(0, w).trim();
|
|
2258
|
+
oe.current = oe.current.slice(w + 1);
|
|
2259
|
+
const E = rn(R);
|
|
2260
|
+
E && sn(E);
|
|
560
2261
|
}
|
|
561
2262
|
};
|
|
562
|
-
|
|
2263
|
+
ie(() => {
|
|
563
2264
|
(async () => {
|
|
564
2265
|
if (!sessionStorage.getItem("STREAMOJI_LEADS_SESSION_LEAD_ID")) {
|
|
565
|
-
const
|
|
2266
|
+
const R = "secret", E = Math.floor(Date.now() / 1e3).toString();
|
|
566
2267
|
try {
|
|
567
|
-
const
|
|
2268
|
+
const _ = new TextEncoder(), I = await crypto.subtle.importKey(
|
|
568
2269
|
"raw",
|
|
569
|
-
|
|
2270
|
+
_.encode(R),
|
|
570
2271
|
{ name: "HMAC", hash: "SHA-256" },
|
|
571
2272
|
!1,
|
|
572
2273
|
["sign"]
|
|
573
|
-
),
|
|
2274
|
+
), G = await crypto.subtle.sign(
|
|
574
2275
|
"HMAC",
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
),
|
|
578
|
-
sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID",
|
|
579
|
-
} catch (
|
|
580
|
-
console.error("[SESSION] HMAC generation failed:",
|
|
581
|
-
const
|
|
582
|
-
sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID",
|
|
2276
|
+
I,
|
|
2277
|
+
_.encode(E)
|
|
2278
|
+
), q = Array.from(new Uint8Array(G)).map((j) => j.toString(16).padStart(2, "0")).join("");
|
|
2279
|
+
sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", q), Q("[SESSION] New HMAC UID generated and saved:", q);
|
|
2280
|
+
} catch (_) {
|
|
2281
|
+
console.error("[SESSION] HMAC generation failed:", _);
|
|
2282
|
+
const I = Math.random().toString(36) + Date.now().toString();
|
|
2283
|
+
sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", I);
|
|
583
2284
|
}
|
|
584
2285
|
}
|
|
585
2286
|
sessionStorage.getItem("STREAMOJI_LEADS_SESSION_MESSAGES") || sessionStorage.setItem("STREAMOJI_LEADS_SESSION_MESSAGES", JSON.stringify([]));
|
|
586
2287
|
})();
|
|
587
2288
|
}, []);
|
|
588
|
-
const
|
|
2289
|
+
const yt = () => {
|
|
589
2290
|
try {
|
|
590
2291
|
return JSON.parse(sessionStorage.getItem("STREAMOJI_LEADS_SESSION_MESSAGES") || "[]");
|
|
591
2292
|
} catch {
|
|
592
2293
|
return [];
|
|
593
2294
|
}
|
|
594
|
-
},
|
|
595
|
-
sessionStorage.setItem("STREAMOJI_LEADS_SESSION_MESSAGES", JSON.stringify(
|
|
596
|
-
}, [
|
|
597
|
-
|
|
2295
|
+
}, an = (p) => {
|
|
2296
|
+
sessionStorage.setItem("STREAMOJI_LEADS_SESSION_MESSAGES", JSON.stringify(p));
|
|
2297
|
+
}, [tt, nt] = K(!1), [At, st] = K(0), he = L(null), $e = L([]), Et = L(0), [Lt, cn] = K(null), [un, rt] = K(null), xe = L(null), Le = L(null), it = Ye(() => {
|
|
2298
|
+
D.current = [], P.current = !1, T(!1), H.current = 0, B.current = 0, O.current = 0, F.current.forEach((p) => {
|
|
598
2299
|
try {
|
|
599
|
-
|
|
2300
|
+
p.stop();
|
|
600
2301
|
} catch {
|
|
601
2302
|
}
|
|
602
|
-
}),
|
|
603
|
-
}, []),
|
|
2303
|
+
}), He.current && (clearTimeout(He.current), He.current = null), Ne(null), A(""), F.current = [];
|
|
2304
|
+
}, []), ln = async () => {
|
|
604
2305
|
try {
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
const
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
},
|
|
611
|
-
const
|
|
612
|
-
if (
|
|
613
|
-
|
|
2306
|
+
const p = await navigator.mediaDevices.getUserMedia({ audio: !0 }), w = window.AudioContext || window.webkitAudioContext, R = new w(), E = R.createMediaStreamSource(p), _ = R.createAnalyser();
|
|
2307
|
+
_.fftSize = 64, E.connect(_), xe.current = R, Le.current = E, rt(_);
|
|
2308
|
+
const I = new MediaRecorder(p);
|
|
2309
|
+
he.current = I, $e.current = [], I.ondataavailable = (G) => {
|
|
2310
|
+
G.data.size > 0 && $e.current.push(G.data);
|
|
2311
|
+
}, I.onstop = async () => {
|
|
2312
|
+
const G = Date.now() - Et.current;
|
|
2313
|
+
if (rt(null), Le.current && (Le.current.disconnect(), Le.current = null), xe.current && xe.current.state !== "closed" && (xe.current.close(), xe.current = null), G < 1e3) {
|
|
2314
|
+
u("Recording too short. Hold or click longer."), f(!1);
|
|
614
2315
|
return;
|
|
615
2316
|
}
|
|
616
|
-
const
|
|
617
|
-
await
|
|
618
|
-
},
|
|
619
|
-
} catch (
|
|
620
|
-
console.error("Error accessing microphone:",
|
|
2317
|
+
const V = new Blob($e.current, { type: "audio/wav" });
|
|
2318
|
+
await pn(V);
|
|
2319
|
+
}, Et.current = Date.now(), I.start(100), nt(!0), u("Listening...");
|
|
2320
|
+
} catch (p) {
|
|
2321
|
+
console.error("Error accessing microphone:", p), u("Mic Access Error");
|
|
621
2322
|
}
|
|
622
|
-
},
|
|
623
|
-
|
|
624
|
-
},
|
|
625
|
-
|
|
2323
|
+
}, dn = () => {
|
|
2324
|
+
he.current && he.current.state !== "inactive" && (he.current.stop(), he.current.stream.getTracks().forEach((p) => p.stop()), nt(!1));
|
|
2325
|
+
}, fn = () => {
|
|
2326
|
+
he.current && he.current.state !== "inactive" && (he.current.onstop = null, he.current.stop(), he.current.stream.getTracks().forEach((p) => p.stop()), rt(null), Le.current && (Le.current.disconnect(), Le.current = null), xe.current && xe.current.state !== "closed" && (xe.current.close(), xe.current = null), nt(!1), $e.current = [], u("Ready"));
|
|
626
2327
|
};
|
|
627
|
-
|
|
628
|
-
if (!
|
|
629
|
-
const
|
|
630
|
-
const
|
|
631
|
-
if (i <= 0) return;
|
|
632
|
-
const s = N.current, a = P.current;
|
|
633
|
-
if (!s) return;
|
|
634
|
-
const n = s.currentTime - a, u = Math.min(Math.max(0, n), i), w = ge.trim().length;
|
|
2328
|
+
ie(() => {
|
|
2329
|
+
if (!h) return;
|
|
2330
|
+
const p = () => {
|
|
2331
|
+
const w = O.current;
|
|
635
2332
|
if (w <= 0) return;
|
|
636
|
-
const
|
|
637
|
-
|
|
638
|
-
|
|
2333
|
+
const R = y.current, E = H.current;
|
|
2334
|
+
if (!R) return;
|
|
2335
|
+
const _ = R.currentTime - E, I = Math.min(Math.max(0, _), w), G = a.trim().length;
|
|
2336
|
+
if (G <= 0) return;
|
|
2337
|
+
const V = Math.min(
|
|
2338
|
+
Math.round(I / w * G),
|
|
2339
|
+
G
|
|
639
2340
|
);
|
|
640
|
-
|
|
2341
|
+
ue(V);
|
|
641
2342
|
};
|
|
642
|
-
return clearInterval(
|
|
643
|
-
}, [
|
|
644
|
-
let
|
|
645
|
-
return
|
|
646
|
-
|
|
647
|
-
}, 1e3)) :
|
|
648
|
-
}, [
|
|
649
|
-
const
|
|
650
|
-
const
|
|
651
|
-
let
|
|
652
|
-
const
|
|
653
|
-
|
|
654
|
-
},
|
|
655
|
-
|
|
2343
|
+
return clearInterval(Te.current ?? void 0), Te.current = setInterval(p, 90), () => clearInterval(Te.current ?? void 0);
|
|
2344
|
+
}, [h, a, O.current]), ie(() => {
|
|
2345
|
+
let p;
|
|
2346
|
+
return tt ? (st(0), p = window.setInterval(() => {
|
|
2347
|
+
st((w) => w + 1);
|
|
2348
|
+
}, 1e3)) : st(0), () => clearInterval(p);
|
|
2349
|
+
}, [tt]);
|
|
2350
|
+
const hn = (p) => {
|
|
2351
|
+
const w = p.numberOfChannels, R = p.length * w * 2 + 44, E = new ArrayBuffer(R), _ = new DataView(E);
|
|
2352
|
+
let I = 0;
|
|
2353
|
+
const G = (z) => {
|
|
2354
|
+
_.setUint16(I, z, !0), I += 2;
|
|
2355
|
+
}, V = (z) => {
|
|
2356
|
+
_.setUint32(I, z, !0), I += 4;
|
|
656
2357
|
};
|
|
657
|
-
|
|
658
|
-
const
|
|
659
|
-
for (let
|
|
660
|
-
let
|
|
661
|
-
for (;
|
|
662
|
-
for (let
|
|
663
|
-
let
|
|
664
|
-
|
|
2358
|
+
V(1179011410), V(R - 8), V(1163280727), V(544501094), V(16), G(1), G(w), V(p.sampleRate), V(p.sampleRate * 2 * w), G(w * 2), G(16), V(1635017060), V(R - I - 4);
|
|
2359
|
+
const q = [];
|
|
2360
|
+
for (let z = 0; z < w; z++) q.push(p.getChannelData(z));
|
|
2361
|
+
let j = 0;
|
|
2362
|
+
for (; I < R; ) {
|
|
2363
|
+
for (let z = 0; z < w; z++) {
|
|
2364
|
+
let Y = Math.max(-1, Math.min(1, q[z][j]));
|
|
2365
|
+
Y = Y < 0 ? Y * 32768 : Y * 32767, _.setInt16(I, Y, !0), I += 2;
|
|
665
2366
|
}
|
|
666
|
-
|
|
2367
|
+
j++;
|
|
667
2368
|
}
|
|
668
|
-
return new Blob([
|
|
669
|
-
},
|
|
2369
|
+
return new Blob([E], { type: "audio/wav" });
|
|
2370
|
+
}, ot = async (p, w, R = !1) => {
|
|
670
2371
|
if (m.current) {
|
|
671
|
-
|
|
2372
|
+
b.current.push({ audio: p, visemes: w, isNewSegment: R });
|
|
672
2373
|
return;
|
|
673
2374
|
}
|
|
674
2375
|
m.current = !0;
|
|
675
2376
|
try {
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
const
|
|
679
|
-
for (let
|
|
680
|
-
const
|
|
681
|
-
|
|
682
|
-
const
|
|
683
|
-
let
|
|
684
|
-
const
|
|
685
|
-
|
|
686
|
-
const
|
|
687
|
-
|
|
688
|
-
let
|
|
689
|
-
if ((
|
|
690
|
-
|
|
691
|
-
const
|
|
692
|
-
|
|
2377
|
+
const E = window.AudioContext || window.webkitAudioContext, _ = y.current ?? new E();
|
|
2378
|
+
_.state === "suspended" && await _.resume(), y.current = _;
|
|
2379
|
+
const I = window.atob(p), G = new Uint8Array(I.length);
|
|
2380
|
+
for (let $ = 0; $ < I.length; $++) G[$] = I.charCodeAt($);
|
|
2381
|
+
const V = await _.decodeAudioData(G.buffer.slice(0));
|
|
2382
|
+
O.current += V.duration;
|
|
2383
|
+
const q = _.currentTime;
|
|
2384
|
+
let j = B.current;
|
|
2385
|
+
const z = !P.current;
|
|
2386
|
+
j < q && (j = q + 0.1), B.current = j + V.duration;
|
|
2387
|
+
const Y = _.createBufferSource();
|
|
2388
|
+
Y.buffer = V;
|
|
2389
|
+
let J = Lt;
|
|
2390
|
+
if ((!J || J.context !== _) && (J = _.createAnalyser(), J.fftSize = 64, J.connect(_.destination), cn(J)), Y.connect(J), F.current.push(Y), z) {
|
|
2391
|
+
P.current = !0, T(!0), Q(`[AUDIO] setIsSpeaking(true) - First chunk starting at ${j.toFixed(3)}`), H.current = j;
|
|
2392
|
+
const $ = (j - q) * 1e3;
|
|
2393
|
+
S.current = performance.now() + $, Q(`[AUDIO] Response started. Initial startTime: ${j.toFixed(3)}, CT: ${q.toFixed(3)}`);
|
|
693
2394
|
}
|
|
694
|
-
|
|
695
|
-
const
|
|
696
|
-
|
|
697
|
-
const
|
|
698
|
-
if (
|
|
699
|
-
const
|
|
700
|
-
|
|
701
|
-
|
|
2395
|
+
Y.start(j);
|
|
2396
|
+
const re = (j - H.current) * 1e3;
|
|
2397
|
+
R && (U.current = re, Q(`[AUDIO] New segment detected at +${re.toFixed(0)}ms. Resetting segment offset.`)), w.forEach(($, we) => {
|
|
2398
|
+
const W = $.symbol ?? "";
|
|
2399
|
+
if (W) {
|
|
2400
|
+
const le = sr(W), pe = Math.round($.start * 1e3), Me = Math.round(($.duration ?? 0) * 1e3), vt = U.current + pe;
|
|
2401
|
+
we < 3 && Q(`[AUDIO] Viseme "${W}": segment_relative=${pe}ms, segment_offset=${U.current.toFixed(0)}ms => vtime=${vt}ms`), le.forEach((kt) => {
|
|
2402
|
+
D.current.push({ viseme: kt.v, weight: kt.w, vtime: vt, vduration: Me });
|
|
702
2403
|
});
|
|
703
2404
|
}
|
|
704
|
-
}),
|
|
2405
|
+
}), u("Speaking...");
|
|
705
2406
|
} finally {
|
|
706
|
-
if (m.current = !1,
|
|
707
|
-
const
|
|
708
|
-
|
|
2407
|
+
if (m.current = !1, b.current.length > 0) {
|
|
2408
|
+
const E = b.current.shift();
|
|
2409
|
+
E && ot(E.audio, E.visemes, E.isNewSegment);
|
|
709
2410
|
}
|
|
710
2411
|
}
|
|
711
|
-
},
|
|
2412
|
+
}, pn = async (p) => {
|
|
712
2413
|
try {
|
|
713
|
-
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
const
|
|
717
|
-
|
|
718
|
-
const
|
|
2414
|
+
f(!0), ae.current = "", o(""), u("Processing Voice...");
|
|
2415
|
+
const w = await p.arrayBuffer(), E = await new (window.AudioContext || window.webkitAudioContext)().decodeAudioData(w), _ = hn(E), I = new FileReader();
|
|
2416
|
+
I.readAsDataURL(_), I.onloadend = async () => {
|
|
2417
|
+
const G = I.result.split(",")[1];
|
|
2418
|
+
it(), s(""), oe.current = "", fe.current = !1;
|
|
2419
|
+
const V = `${Vt}/stt?token=${encodeURIComponent(r)}`, q = await fetch(V, {
|
|
719
2420
|
method: "POST",
|
|
720
2421
|
headers: { "Content-Type": "application/json" },
|
|
721
|
-
body: JSON.stringify({ audio_base64:
|
|
2422
|
+
body: JSON.stringify({ audio_base64: G, audio_format: "wav" })
|
|
722
2423
|
});
|
|
723
|
-
if (!
|
|
724
|
-
const
|
|
725
|
-
let
|
|
2424
|
+
if (!q.ok) {
|
|
2425
|
+
const we = await q.text();
|
|
2426
|
+
let W = "STT Failed";
|
|
726
2427
|
try {
|
|
727
|
-
|
|
2428
|
+
W = JSON.parse(we).error || W;
|
|
728
2429
|
} catch {
|
|
729
|
-
|
|
2430
|
+
we && (W = we.slice(0, 200));
|
|
730
2431
|
}
|
|
731
|
-
throw new Error(
|
|
2432
|
+
throw new Error(W);
|
|
732
2433
|
}
|
|
733
|
-
const
|
|
734
|
-
if (
|
|
735
|
-
|
|
2434
|
+
const j = q.body;
|
|
2435
|
+
if (Q("this is body" + j), !j) {
|
|
2436
|
+
u("STT Failed"), f(!1);
|
|
736
2437
|
return;
|
|
737
2438
|
}
|
|
738
|
-
const
|
|
739
|
-
let
|
|
740
|
-
const
|
|
741
|
-
switch (
|
|
2439
|
+
const z = j.getReader(), Y = new TextDecoder();
|
|
2440
|
+
let J = "", re = !1;
|
|
2441
|
+
const $ = async (we, W) => {
|
|
2442
|
+
switch (we) {
|
|
742
2443
|
case "transcript":
|
|
743
|
-
|
|
2444
|
+
W.transcript != null && s(String(W.transcript));
|
|
744
2445
|
break;
|
|
745
2446
|
case "text": {
|
|
746
|
-
const
|
|
747
|
-
|
|
2447
|
+
const le = W.delta ?? W.text ?? "";
|
|
2448
|
+
le && St(le);
|
|
748
2449
|
break;
|
|
749
2450
|
}
|
|
750
2451
|
case "audio": {
|
|
751
|
-
const
|
|
752
|
-
|
|
2452
|
+
const le = W.chunk, pe = W.visemes ?? [], Me = !!W.is_new_segment;
|
|
2453
|
+
le && await ot(le, pe, Me);
|
|
753
2454
|
break;
|
|
754
2455
|
}
|
|
755
2456
|
case "done": {
|
|
756
|
-
|
|
2457
|
+
re = !0, u("Ready"), f(!1);
|
|
757
2458
|
break;
|
|
758
2459
|
}
|
|
759
2460
|
case "error": {
|
|
760
|
-
|
|
2461
|
+
re = !0, u("STT Failed"), f(!1);
|
|
761
2462
|
break;
|
|
762
2463
|
}
|
|
763
2464
|
default:
|
|
@@ -765,165 +2466,168 @@ const zt = ({ token: d, agentToken: y, onNavigationRequested: v } = {}) => {
|
|
|
765
2466
|
}
|
|
766
2467
|
};
|
|
767
2468
|
for (; ; ) {
|
|
768
|
-
const { done:
|
|
769
|
-
|
|
770
|
-
const
|
|
2469
|
+
const { done: we, value: W } = await z.read();
|
|
2470
|
+
W && (J += Y.decode(W, { stream: !0 }));
|
|
2471
|
+
const le = J.split(`
|
|
771
2472
|
|
|
772
2473
|
`);
|
|
773
|
-
|
|
774
|
-
for (const
|
|
775
|
-
const
|
|
776
|
-
|
|
2474
|
+
J = le.pop() ?? "";
|
|
2475
|
+
for (const pe of le) {
|
|
2476
|
+
const Me = qe(pe);
|
|
2477
|
+
Me && await $(Me.event, Me.data);
|
|
777
2478
|
}
|
|
778
|
-
if (
|
|
779
|
-
if (
|
|
780
|
-
const
|
|
781
|
-
|
|
2479
|
+
if (we) {
|
|
2480
|
+
if (J.trim()) {
|
|
2481
|
+
const pe = qe(J.trim());
|
|
2482
|
+
pe && await $(pe.event, pe.data);
|
|
782
2483
|
}
|
|
783
|
-
|
|
2484
|
+
re || (u("Ready"), f(!1));
|
|
784
2485
|
break;
|
|
785
2486
|
}
|
|
786
2487
|
}
|
|
787
2488
|
};
|
|
788
|
-
} catch (
|
|
789
|
-
console.error("Audio Submission Error:",
|
|
2489
|
+
} catch (w) {
|
|
2490
|
+
console.error("Audio Submission Error:", w), u("STT Failed"), f(!1);
|
|
790
2491
|
}
|
|
791
|
-
},
|
|
792
|
-
|
|
793
|
-
},
|
|
794
|
-
const
|
|
795
|
-
let
|
|
796
|
-
for (const
|
|
797
|
-
|
|
798
|
-
if (!
|
|
799
|
-
let
|
|
800
|
-
if (
|
|
2492
|
+
}, mn = async (p) => {
|
|
2493
|
+
p && p.preventDefault(), ae.current = "", o(""), !(!i || l) && await gn(i);
|
|
2494
|
+
}, qe = (p) => {
|
|
2495
|
+
const w = p.split(/\r?\n/);
|
|
2496
|
+
let R = "", E = "";
|
|
2497
|
+
for (const I of w)
|
|
2498
|
+
I.startsWith("event:") ? R = I.slice(6).trim() : I.startsWith("data:") && (E = I.slice(5).trim());
|
|
2499
|
+
if (!R) return null;
|
|
2500
|
+
let _ = {};
|
|
2501
|
+
if (E)
|
|
801
2502
|
try {
|
|
802
|
-
|
|
2503
|
+
_ = JSON.parse(E);
|
|
803
2504
|
} catch {
|
|
804
|
-
|
|
2505
|
+
_ = { raw: E };
|
|
805
2506
|
}
|
|
806
|
-
return { event:
|
|
807
|
-
},
|
|
808
|
-
switch (
|
|
2507
|
+
return { event: R, data: _ };
|
|
2508
|
+
}, Mt = (p, w) => {
|
|
2509
|
+
switch (p) {
|
|
809
2510
|
case "connected":
|
|
810
|
-
|
|
2511
|
+
oe.current = "", fe.current = !1;
|
|
811
2512
|
break;
|
|
812
2513
|
case "text": {
|
|
813
|
-
const
|
|
814
|
-
|
|
2514
|
+
const R = w.delta ?? "";
|
|
2515
|
+
R && St(R);
|
|
815
2516
|
break;
|
|
816
2517
|
}
|
|
817
2518
|
case "audio": {
|
|
818
|
-
const
|
|
819
|
-
|
|
2519
|
+
const R = w.chunk, E = w.visemes ?? [];
|
|
2520
|
+
R && ot(R, E);
|
|
820
2521
|
break;
|
|
821
2522
|
}
|
|
822
2523
|
case "done": {
|
|
823
|
-
const
|
|
824
|
-
...
|
|
825
|
-
{ role: "user", content:
|
|
826
|
-
{ role: "assistant", content:
|
|
2524
|
+
const R = yt(), E = ae.current.trim(), _ = [
|
|
2525
|
+
...R,
|
|
2526
|
+
{ role: "user", content: i || "..." },
|
|
2527
|
+
{ role: "assistant", content: E }
|
|
827
2528
|
];
|
|
828
|
-
|
|
2529
|
+
an(_), C.current = [...D.current], u("Ready"), f(!1), s("");
|
|
829
2530
|
break;
|
|
830
2531
|
}
|
|
831
2532
|
case "error": {
|
|
832
|
-
const
|
|
833
|
-
|
|
2533
|
+
const R = w.message ?? "Unknown error";
|
|
2534
|
+
ae.current = R, o(R), u("Agent Failed"), f(!1);
|
|
834
2535
|
break;
|
|
835
2536
|
}
|
|
836
2537
|
}
|
|
837
|
-
},
|
|
838
|
-
|
|
839
|
-
const
|
|
2538
|
+
}, gn = async (p) => {
|
|
2539
|
+
f(!0), u("Thinking..."), ae.current = "", oe.current = "", fe.current = !1, it(), O.current = 0, ue(0);
|
|
2540
|
+
const w = `${Vt}/agent/chat?token=${encodeURIComponent(r)}`;
|
|
840
2541
|
try {
|
|
841
|
-
const
|
|
842
|
-
let
|
|
843
|
-
|
|
844
|
-
const
|
|
845
|
-
history:
|
|
846
|
-
question:
|
|
847
|
-
lead_id:
|
|
2542
|
+
const R = yt();
|
|
2543
|
+
let E = sessionStorage.getItem("STREAMOJI_LEADS_SESSION_LEAD_ID");
|
|
2544
|
+
E || (Ks("[CHAT] Session UID missing at send time! Generating emergency backup."), E = "emergency-" + Math.random().toString(36).substring(7), sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", E));
|
|
2545
|
+
const _ = {
|
|
2546
|
+
history: R,
|
|
2547
|
+
question: p,
|
|
2548
|
+
lead_id: E
|
|
848
2549
|
};
|
|
849
|
-
|
|
850
|
-
const
|
|
2550
|
+
Q("[CHAT] Sending payload:", _);
|
|
2551
|
+
const I = await fetch(w, {
|
|
851
2552
|
method: "POST",
|
|
852
|
-
headers: {
|
|
853
|
-
|
|
2553
|
+
headers: {
|
|
2554
|
+
"Content-Type": "application/json"
|
|
2555
|
+
},
|
|
2556
|
+
body: JSON.stringify(_),
|
|
2557
|
+
cache: "default"
|
|
854
2558
|
});
|
|
855
|
-
if (!
|
|
2559
|
+
if (!I.ok)
|
|
856
2560
|
throw new Error("Agent request failed");
|
|
857
|
-
const
|
|
858
|
-
if (!
|
|
859
|
-
|
|
2561
|
+
const G = I.body;
|
|
2562
|
+
if (!G) {
|
|
2563
|
+
u("Agent Failed"), f(!1);
|
|
860
2564
|
return;
|
|
861
2565
|
}
|
|
862
|
-
const
|
|
863
|
-
let
|
|
2566
|
+
const V = G.getReader(), q = new TextDecoder();
|
|
2567
|
+
let j = "";
|
|
864
2568
|
for (; ; ) {
|
|
865
|
-
const { done:
|
|
866
|
-
|
|
867
|
-
const
|
|
2569
|
+
const { done: z, value: Y } = await V.read();
|
|
2570
|
+
Q(`[SSE] Chunk received. done=${z}, length=${Y?.length || 0}`), Y && (j += q.decode(Y, { stream: !0 }));
|
|
2571
|
+
const J = j.split(`
|
|
868
2572
|
|
|
869
2573
|
`);
|
|
870
|
-
|
|
871
|
-
for (const
|
|
872
|
-
|
|
873
|
-
const
|
|
874
|
-
|
|
2574
|
+
j = J.pop() ?? "";
|
|
2575
|
+
for (const re of J) {
|
|
2576
|
+
Q(`[SSE] Processing block: ${re.slice(0, 50)}...`);
|
|
2577
|
+
const $ = qe(re);
|
|
2578
|
+
$ && (Q(`[SSE] Event: ${$.event}`), Mt($.event, $.data));
|
|
875
2579
|
}
|
|
876
|
-
if (
|
|
877
|
-
if (
|
|
878
|
-
const
|
|
879
|
-
|
|
2580
|
+
if (z) {
|
|
2581
|
+
if (Q("[SSE] Stream finished"), j.trim()) {
|
|
2582
|
+
const re = qe(j.trim());
|
|
2583
|
+
re && Mt(re.event, re.data);
|
|
880
2584
|
}
|
|
881
|
-
|
|
2585
|
+
u("Ready"), f(!1), s("");
|
|
882
2586
|
break;
|
|
883
2587
|
}
|
|
884
2588
|
}
|
|
885
|
-
} catch (
|
|
886
|
-
console.error("Chat Error:",
|
|
2589
|
+
} catch (R) {
|
|
2590
|
+
console.error("Chat Error:", R), u("Agent Failed"), f(!1);
|
|
887
2591
|
}
|
|
888
|
-
},
|
|
889
|
-
|
|
890
|
-
const
|
|
891
|
-
|
|
892
|
-
}, [
|
|
893
|
-
const
|
|
894
|
-
const
|
|
895
|
-
|
|
2592
|
+
}, It = a.trim(), at = It && h ? It.slice(0, Z != null && Z > 0 ? Z : 0) : "";
|
|
2593
|
+
ie(() => {
|
|
2594
|
+
const p = se.current;
|
|
2595
|
+
p !== "exiting" && (at ? (_e(at), p === "hidden" && Ee("entering")) : (p === "visible" || p === "entering") && Ee("exiting"));
|
|
2596
|
+
}, [at, be]);
|
|
2597
|
+
const Tn = Ye(() => {
|
|
2598
|
+
const p = se.current;
|
|
2599
|
+
p === "entering" ? Ee("visible") : p === "exiting" && Ee("hidden");
|
|
896
2600
|
}, []);
|
|
897
|
-
return
|
|
898
|
-
const
|
|
899
|
-
|
|
900
|
-
}, [
|
|
901
|
-
/* @__PURE__ */
|
|
902
|
-
|
|
2601
|
+
return _n(() => {
|
|
2602
|
+
const p = Be.current;
|
|
2603
|
+
p && (p.scrollTop = p.scrollHeight);
|
|
2604
|
+
}, [te]), /* @__PURE__ */ de("div", { className: "avatar-widget-container", children: [
|
|
2605
|
+
/* @__PURE__ */ de("div", { className: "avatar-input-area", children: [
|
|
2606
|
+
X !== "hidden" ? /* @__PURE__ */ N(
|
|
903
2607
|
"div",
|
|
904
2608
|
{
|
|
905
|
-
className: `avatar-thinking-tab${
|
|
906
|
-
onAnimationEnd:
|
|
907
|
-
children:
|
|
2609
|
+
className: `avatar-thinking-tab${X === "exiting" ? " avatar-thinking-tab--exiting" : X === "entering" ? " avatar-thinking-tab--entering" : ""}`,
|
|
2610
|
+
onAnimationEnd: nn,
|
|
2611
|
+
children: Fe
|
|
908
2612
|
}
|
|
909
2613
|
) : null,
|
|
910
|
-
/* @__PURE__ */
|
|
911
|
-
/* @__PURE__ */
|
|
2614
|
+
/* @__PURE__ */ N("div", { className: "avatar-input-container", children: /* @__PURE__ */ N("div", { style: { display: "flex", alignItems: "center", width: "100%", height: "100%" }, children: tt ? /* @__PURE__ */ de("div", { className: "avatar-input-recording", children: [
|
|
2615
|
+
/* @__PURE__ */ N(
|
|
912
2616
|
"button",
|
|
913
2617
|
{
|
|
914
2618
|
type: "button",
|
|
915
2619
|
className: "avatar-recording-cancel",
|
|
916
|
-
onClick:
|
|
2620
|
+
onClick: fn,
|
|
917
2621
|
title: "Cancel",
|
|
918
|
-
children: /* @__PURE__ */
|
|
919
|
-
/* @__PURE__ */
|
|
920
|
-
/* @__PURE__ */
|
|
2622
|
+
children: /* @__PURE__ */ de("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", style: { display: "block" }, children: [
|
|
2623
|
+
/* @__PURE__ */ N("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
2624
|
+
/* @__PURE__ */ N("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
921
2625
|
] })
|
|
922
2626
|
}
|
|
923
2627
|
),
|
|
924
|
-
/* @__PURE__ */
|
|
925
|
-
/* @__PURE__ */
|
|
926
|
-
/* @__PURE__ */
|
|
2628
|
+
/* @__PURE__ */ de("div", { style: { flex: 1, height: "100%", position: "relative", display: "flex", alignItems: "center", minWidth: 0 }, children: [
|
|
2629
|
+
/* @__PURE__ */ N("div", { style: { flex: 1, height: "100%" }, children: /* @__PURE__ */ N(jt, { analyser: un }) }),
|
|
2630
|
+
/* @__PURE__ */ de("span", { style: {
|
|
927
2631
|
fontSize: "0.75rem",
|
|
928
2632
|
color: "#64748b",
|
|
929
2633
|
fontWeight: 500,
|
|
@@ -932,75 +2636,75 @@ const zt = ({ token: d, agentToken: y, onNavigationRequested: v } = {}) => {
|
|
|
932
2636
|
textAlign: "right",
|
|
933
2637
|
fontVariantNumeric: "tabular-nums"
|
|
934
2638
|
}, children: [
|
|
935
|
-
Math.floor(
|
|
2639
|
+
Math.floor(At / 60),
|
|
936
2640
|
":",
|
|
937
|
-
String(
|
|
2641
|
+
String(At % 60).padStart(2, "0")
|
|
938
2642
|
] })
|
|
939
2643
|
] }),
|
|
940
|
-
/* @__PURE__ */
|
|
2644
|
+
/* @__PURE__ */ N(
|
|
941
2645
|
"button",
|
|
942
2646
|
{
|
|
943
2647
|
type: "button",
|
|
944
2648
|
className: "avatar-recording-confirm",
|
|
945
|
-
onClick:
|
|
2649
|
+
onClick: dn,
|
|
946
2650
|
title: "Send",
|
|
947
|
-
children: /* @__PURE__ */
|
|
2651
|
+
children: /* @__PURE__ */ N("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", style: { display: "block" }, children: /* @__PURE__ */ N("polyline", { points: "20 6 9 17 4 12" }) })
|
|
948
2652
|
}
|
|
949
2653
|
)
|
|
950
|
-
] }) :
|
|
951
|
-
/* @__PURE__ */
|
|
2654
|
+
] }) : h ? /* @__PURE__ */ N("div", { style: { flex: 1, height: "100%", display: "flex", alignItems: "center", paddingRight: "8px" }, children: /* @__PURE__ */ N(jt, { analyser: Lt }) }) : l ? /* @__PURE__ */ N("div", { style: { flex: 1, height: "100%", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ N("div", { className: "avatar-input-loader" }) }) : /* @__PURE__ */ de("form", { onSubmit: mn, style: { flex: 1, display: "flex", height: "100%", alignItems: "center" }, children: [
|
|
2655
|
+
/* @__PURE__ */ N(
|
|
952
2656
|
"input",
|
|
953
2657
|
{
|
|
954
2658
|
id: "avatar-text-input",
|
|
955
2659
|
type: "text",
|
|
956
|
-
value:
|
|
957
|
-
onChange: (
|
|
2660
|
+
value: i,
|
|
2661
|
+
onChange: (p) => s(p.target.value),
|
|
958
2662
|
placeholder: "Ask me anything",
|
|
959
|
-
disabled:
|
|
2663
|
+
disabled: l,
|
|
960
2664
|
autoComplete: "off",
|
|
961
2665
|
style: { width: "100%", height: "100%" }
|
|
962
2666
|
}
|
|
963
2667
|
),
|
|
964
|
-
|
|
2668
|
+
i.trim() === "" ? /* @__PURE__ */ N(
|
|
965
2669
|
"button",
|
|
966
2670
|
{
|
|
967
2671
|
type: "button",
|
|
968
2672
|
className: "mic-button",
|
|
969
|
-
onClick:
|
|
970
|
-
disabled:
|
|
2673
|
+
onClick: ln,
|
|
2674
|
+
disabled: l,
|
|
971
2675
|
style: { backgroundColor: "#1e4a5e" },
|
|
972
|
-
children: /* @__PURE__ */
|
|
973
|
-
/* @__PURE__ */
|
|
974
|
-
/* @__PURE__ */
|
|
2676
|
+
children: /* @__PURE__ */ de("svg", { width: "28", height: "28", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
2677
|
+
/* @__PURE__ */ N("path", { d: "M12 14C13.66 14 15 12.66 15 11V5C15 3.34 13.66 2 12 2C10.34 2 9 3.34 9 5V11C9 12.66 10.34 14 12 14Z", fill: "white" }),
|
|
2678
|
+
/* @__PURE__ */ N("path", { d: "M17 11C17 13.76 14.76 16 12 16C9.24 16 7 13.76 7 11H5C5 14.53 7.61 17.43 11 17.93V21H13V17.93C16.39 17.43 19 14.53 19 11H17Z", fill: "white" })
|
|
975
2679
|
] })
|
|
976
2680
|
}
|
|
977
|
-
) : /* @__PURE__ */
|
|
2681
|
+
) : /* @__PURE__ */ N(
|
|
978
2682
|
"button",
|
|
979
2683
|
{
|
|
980
2684
|
type: "submit",
|
|
981
2685
|
className: "mic-button",
|
|
982
|
-
disabled:
|
|
2686
|
+
disabled: l,
|
|
983
2687
|
style: { backgroundColor: "#1e4a5e" },
|
|
984
2688
|
title: "Send",
|
|
985
|
-
children: /* @__PURE__ */
|
|
986
|
-
/* @__PURE__ */
|
|
987
|
-
/* @__PURE__ */
|
|
2689
|
+
children: /* @__PURE__ */ de("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
|
|
2690
|
+
/* @__PURE__ */ N("path", { d: "M22 2L11 13", stroke: "white", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
2691
|
+
/* @__PURE__ */ N("path", { d: "M22 2L15 22L11 13L2 9L22 2Z", stroke: "white", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
988
2692
|
] })
|
|
989
2693
|
}
|
|
990
2694
|
)
|
|
991
2695
|
] }) }) })
|
|
992
2696
|
] }),
|
|
993
|
-
/* @__PURE__ */
|
|
994
|
-
|
|
2697
|
+
/* @__PURE__ */ N("div", { className: "avatar-wrapper", children: /* @__PURE__ */ de("div", { className: "avatar-scene-wrapper", children: [
|
|
2698
|
+
be !== "hidden" && /* @__PURE__ */ N(
|
|
995
2699
|
"div",
|
|
996
2700
|
{
|
|
997
|
-
className: `avatar-bubble${
|
|
998
|
-
onAnimationEnd:
|
|
999
|
-
children: /* @__PURE__ */
|
|
2701
|
+
className: `avatar-bubble${be === "entering" ? " avatar-bubble--entering" : be === "exiting" ? " avatar-bubble--exiting" : ""}`,
|
|
2702
|
+
onAnimationEnd: Tn,
|
|
2703
|
+
children: /* @__PURE__ */ N("div", { ref: Be, className: "avatar-bubble__content", children: te })
|
|
1000
2704
|
}
|
|
1001
2705
|
),
|
|
1002
|
-
/* @__PURE__ */
|
|
1003
|
-
|
|
2706
|
+
/* @__PURE__ */ N("div", { className: "avatar-canvas-layer", style: { width: 600, height: 600 }, children: /* @__PURE__ */ de(
|
|
2707
|
+
Rn,
|
|
1004
2708
|
{
|
|
1005
2709
|
shadows: !0,
|
|
1006
2710
|
camera: { position: [0.2, 1.4, 3], fov: 42 },
|
|
@@ -1008,28 +2712,28 @@ const zt = ({ token: d, agentToken: y, onNavigationRequested: v } = {}) => {
|
|
|
1008
2712
|
dpr: 1.8,
|
|
1009
2713
|
style: { pointerEvents: "none", width: "100%", height: "100%" },
|
|
1010
2714
|
children: [
|
|
1011
|
-
/* @__PURE__ */
|
|
1012
|
-
/* @__PURE__ */
|
|
1013
|
-
/* @__PURE__ */
|
|
1014
|
-
/* @__PURE__ */
|
|
1015
|
-
/* @__PURE__ */
|
|
1016
|
-
|
|
2715
|
+
/* @__PURE__ */ N(rr, { target: Qs }),
|
|
2716
|
+
/* @__PURE__ */ N("ambientLight", { intensity: 0.7 }),
|
|
2717
|
+
/* @__PURE__ */ N("directionalLight", { position: [0, 2, 2], intensity: 1 }),
|
|
2718
|
+
/* @__PURE__ */ N(yn, { preset: "city" }),
|
|
2719
|
+
/* @__PURE__ */ N(xn, { fallback: null, children: n !== null && /* @__PURE__ */ N(
|
|
2720
|
+
ir,
|
|
1017
2721
|
{
|
|
1018
|
-
avatarUrl:
|
|
1019
|
-
isPlayingRef:
|
|
1020
|
-
visemeQueueRef:
|
|
1021
|
-
audioContextRef:
|
|
1022
|
-
responseAudioStartTimeRef:
|
|
1023
|
-
adjustments:
|
|
1024
|
-
mood:
|
|
1025
|
-
expression:
|
|
1026
|
-
agentResponse:
|
|
1027
|
-
isSpeaking:
|
|
1028
|
-
nextStartTimeRef:
|
|
1029
|
-
stopPlayback:
|
|
1030
|
-
setIsSpeaking:
|
|
1031
|
-
expressionUrl:
|
|
1032
|
-
onExpressionFinished:
|
|
2722
|
+
avatarUrl: n,
|
|
2723
|
+
isPlayingRef: P,
|
|
2724
|
+
visemeQueueRef: D,
|
|
2725
|
+
audioContextRef: y,
|
|
2726
|
+
responseAudioStartTimeRef: H,
|
|
2727
|
+
adjustments: Js,
|
|
2728
|
+
mood: ye,
|
|
2729
|
+
expression: Ze,
|
|
2730
|
+
agentResponse: a,
|
|
2731
|
+
isSpeaking: h,
|
|
2732
|
+
nextStartTimeRef: B,
|
|
2733
|
+
stopPlayback: it,
|
|
2734
|
+
setIsSpeaking: T,
|
|
2735
|
+
expressionUrl: v,
|
|
2736
|
+
onExpressionFinished: on
|
|
1033
2737
|
}
|
|
1034
2738
|
) })
|
|
1035
2739
|
]
|
|
@@ -1037,17 +2741,17 @@ const zt = ({ token: d, agentToken: y, onNavigationRequested: v } = {}) => {
|
|
|
1037
2741
|
) })
|
|
1038
2742
|
] }) })
|
|
1039
2743
|
] });
|
|
1040
|
-
},
|
|
2744
|
+
}, hr = ({
|
|
1041
2745
|
token: d,
|
|
1042
|
-
onNavigationRequested:
|
|
1043
|
-
}) => /* @__PURE__ */
|
|
1044
|
-
|
|
2746
|
+
onNavigationRequested: t
|
|
2747
|
+
}) => /* @__PURE__ */ N(
|
|
2748
|
+
ar,
|
|
1045
2749
|
{
|
|
1046
2750
|
token: d,
|
|
1047
|
-
onNavigationRequested:
|
|
2751
|
+
onNavigationRequested: t
|
|
1048
2752
|
}
|
|
1049
2753
|
);
|
|
1050
2754
|
export {
|
|
1051
|
-
|
|
2755
|
+
hr as AvatarWidget
|
|
1052
2756
|
};
|
|
1053
2757
|
//# sourceMappingURL=avatar-widget.js.map
|