@j-kyoda/vue-three-vrm 0.8.1 → 0.9.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/README.md +9 -7
- package/dist/index.css +1 -1
- package/dist/vue-three-vrm.es.js +126 -108
- package/dist/vue-three-vrm.umd.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -89,13 +89,15 @@ const model_loaded = (name, vrm_model) => {
|
|
|
89
89
|
|
|
90
90
|
### Props
|
|
91
91
|
|
|
92
|
-
| ID | Type | Default | Description
|
|
93
|
-
| :--------------- | :------- | :------ |
|
|
94
|
-
| animation | Boolean | false | Controls animation loop execution.
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
-
|
|
|
92
|
+
| ID | Type | Default | Description |
|
|
93
|
+
| :--------------- | :------- | :------ | :------------------------------------- |
|
|
94
|
+
| animation | Boolean | false | Controls animation loop execution. |
|
|
95
|
+
| clearAlpha | Number | 1.0 | Clear Alpha value. Ranges from 0 to 1. |
|
|
96
|
+
| clearColor | String | #7fbfff | Clear color value. |
|
|
97
|
+
| useOrbitControls | Boolean | false | Enables/disables `OrbitControls`. |
|
|
98
|
+
| useGridHelper | Boolean | false | Shows/hides the grid. |
|
|
99
|
+
| useAxesHelper | Boolean | false | Shows/hides the 3D axis arrows. |
|
|
100
|
+
| useDefaultLight | Boolean | false | Sets up default lighting. |
|
|
99
101
|
|
|
100
102
|
### Events (Emits)
|
|
101
103
|
|
package/dist/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.box[data-v-
|
|
1
|
+
.box[data-v-81e1dabc]{display:block;width:100%;height:100%}
|
package/dist/vue-three-vrm.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getCurrentInstance as Ve, useTemplateRef as Xe, watch as
|
|
2
|
-
import * as
|
|
3
|
-
import { TrianglesDrawMode as Ze, TriangleFanDrawMode as ce, TriangleStripDrawMode as Ie, Loader as qe, LoaderUtils as X, FileLoader as ve, MeshPhysicalMaterial as O, Vector2 as S, Color as H, LinearSRGBColorSpace as
|
|
1
|
+
import { getCurrentInstance as Ve, useTemplateRef as Xe, watch as C, onMounted as $, createElementBlock as Ce, openBlock as me, ref as Z, Fragment as Ye, createVNode as ee, createBlock as We } from "vue";
|
|
2
|
+
import * as L from "three";
|
|
3
|
+
import { TrianglesDrawMode as Ze, TriangleFanDrawMode as ce, TriangleStripDrawMode as Ie, Loader as qe, LoaderUtils as X, FileLoader as ve, MeshPhysicalMaterial as O, Vector2 as S, Color as H, LinearSRGBColorSpace as I, SRGBColorSpace as Y, SpotLight as Qe, PointLight as $e, DirectionalLight as Je, Matrix4 as q, Vector3 as M, Quaternion as Q, InstancedMesh as et, InstancedBufferAttribute as tt, Object3D as ke, TextureLoader as st, ImageBitmapLoader as nt, BufferAttribute as te, InterleavedBuffer as it, InterleavedBufferAttribute as ot, LinearMipmapLinearFilter as je, NearestMipmapLinearFilter as rt, LinearMipmapNearestFilter as at, NearestMipmapNearestFilter as ct, LinearFilter as le, NearestFilter as Fe, RepeatWrapping as he, MirroredRepeatWrapping as lt, ClampToEdgeWrapping as ht, PointsMaterial as ut, Material as se, LineBasicMaterial as dt, MeshStandardMaterial as He, DoubleSide as pt, MeshBasicMaterial as V, PropertyBinding as ft, BufferGeometry as mt, SkinnedMesh as gt, Mesh as _t, LineSegments as Tt, Line as yt, LineLoop as xt, Points as Et, Group as ne, PerspectiveCamera as bt, MathUtils as Ge, OrthographicCamera as Rt, Skeleton as Mt, AnimationClip as wt, Bone as St, InterpolateDiscrete as At, InterpolateLinear as Ue, Texture as _e, VectorKeyframeTrack as Te, NumberKeyframeTrack as ye, QuaternionKeyframeTrack as xe, ColorManagement as Ee, FrontSide as Lt, Interpolant as Pt, Box3 as Nt, Sphere as Ot, Controls as Dt, MOUSE as U, TOUCH as G, Spherical as be, Ray as Ct, Plane as It } from "three";
|
|
4
4
|
import { VRMHumanBoneName as Re, VRMExpressionPresetName as Me, VRMLoaderPlugin as vt, VRMUtils as kt } from "@pixiv/three-vrm";
|
|
5
5
|
class ue {
|
|
6
6
|
constructor() {
|
|
@@ -97,6 +97,9 @@ class jt {
|
|
|
97
97
|
updateExpression() {
|
|
98
98
|
return this.vrm ? this.vrm.expressionManager.update() : null;
|
|
99
99
|
}
|
|
100
|
+
resetExpression() {
|
|
101
|
+
return this.vrm ? this.vrm.expressionManager.resetValues() : null;
|
|
102
|
+
}
|
|
100
103
|
getExpressionNames() {
|
|
101
104
|
if (this.vrm) {
|
|
102
105
|
let e = [];
|
|
@@ -370,7 +373,7 @@ class de extends qe {
|
|
|
370
373
|
n && n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
|
|
371
374
|
return;
|
|
372
375
|
}
|
|
373
|
-
const c = new
|
|
376
|
+
const c = new gs(i, {
|
|
374
377
|
path: t || this.resourcePath || "",
|
|
375
378
|
crossOrigin: this.crossOrigin,
|
|
376
379
|
requestHeader: this.requestHeader,
|
|
@@ -479,7 +482,7 @@ class Ht {
|
|
|
479
482
|
const i = t.json, r = ((i.extensions && i.extensions[this.name] || {}).lights || [])[e];
|
|
480
483
|
let c;
|
|
481
484
|
const u = new H(16777215);
|
|
482
|
-
r.color !== void 0 && u.setRGB(r.color[0], r.color[1], r.color[2],
|
|
485
|
+
r.color !== void 0 && u.setRGB(r.color[0], r.color[1], r.color[2], I);
|
|
483
486
|
const h = r.range !== void 0 ? r.range : 0;
|
|
484
487
|
switch (r.type) {
|
|
485
488
|
case "directional":
|
|
@@ -521,7 +524,7 @@ class Gt {
|
|
|
521
524
|
if (i) {
|
|
522
525
|
if (Array.isArray(i.baseColorFactor)) {
|
|
523
526
|
const o = i.baseColorFactor;
|
|
524
|
-
e.color.setRGB(o[0], o[1], o[2],
|
|
527
|
+
e.color.setRGB(o[0], o[1], o[2], I), e.opacity = o[3];
|
|
525
528
|
}
|
|
526
529
|
i.baseColorTexture !== void 0 && n.push(s.assignTexture(e, "map", i.baseColorTexture, Y));
|
|
527
530
|
}
|
|
@@ -609,7 +612,7 @@ class Vt {
|
|
|
609
612
|
const o = n.extensions[this.name];
|
|
610
613
|
if (o.sheenColorFactor !== void 0) {
|
|
611
614
|
const a = o.sheenColorFactor;
|
|
612
|
-
t.sheenColor.setRGB(a[0], a[1], a[2],
|
|
615
|
+
t.sheenColor.setRGB(a[0], a[1], a[2], I);
|
|
613
616
|
}
|
|
614
617
|
return o.sheenRoughnessFactor !== void 0 && (t.sheenRoughness = o.sheenRoughnessFactor), o.sheenColorTexture !== void 0 && i.push(s.assignTexture(t, "sheenColorMap", o.sheenColorTexture, Y)), o.sheenRoughnessTexture !== void 0 && i.push(s.assignTexture(t, "sheenRoughnessMap", o.sheenRoughnessTexture)), Promise.all(i);
|
|
615
618
|
}
|
|
@@ -645,7 +648,7 @@ class Yt {
|
|
|
645
648
|
const i = [], o = n.extensions[this.name];
|
|
646
649
|
t.thickness = o.thicknessFactor !== void 0 ? o.thicknessFactor : 0, o.thicknessTexture !== void 0 && i.push(s.assignTexture(t, "thicknessMap", o.thicknessTexture)), t.attenuationDistance = o.attenuationDistance || 1 / 0;
|
|
647
650
|
const a = o.attenuationColor || [1, 1, 1];
|
|
648
|
-
return t.attenuationColor = new H().setRGB(a[0], a[1], a[2],
|
|
651
|
+
return t.attenuationColor = new H().setRGB(a[0], a[1], a[2], I), Promise.all(i);
|
|
649
652
|
}
|
|
650
653
|
}
|
|
651
654
|
class Wt {
|
|
@@ -679,7 +682,7 @@ class Zt {
|
|
|
679
682
|
const i = [], o = n.extensions[this.name];
|
|
680
683
|
t.specularIntensity = o.specularFactor !== void 0 ? o.specularFactor : 1, o.specularTexture !== void 0 && i.push(s.assignTexture(t, "specularIntensityMap", o.specularTexture));
|
|
681
684
|
const a = o.specularColorFactor || [1, 1, 1];
|
|
682
|
-
return t.specularColor = new H().setRGB(a[0], a[1], a[2],
|
|
685
|
+
return t.specularColor = new H().setRGB(a[0], a[1], a[2], I), o.specularColorTexture !== void 0 && i.push(s.assignTexture(t, "specularColorMap", o.specularColorTexture, Y)), Promise.all(i);
|
|
683
686
|
}
|
|
684
687
|
}
|
|
685
688
|
class qt {
|
|
@@ -801,7 +804,7 @@ class ss {
|
|
|
801
804
|
return null;
|
|
802
805
|
const n = t.meshes[s.mesh];
|
|
803
806
|
for (const c of n.primitives)
|
|
804
|
-
if (c.mode !==
|
|
807
|
+
if (c.mode !== P.TRIANGLES && c.mode !== P.TRIANGLE_STRIP && c.mode !== P.TRIANGLE_FAN && c.mode !== void 0)
|
|
805
808
|
return null;
|
|
806
809
|
const o = s.extensions[this.name].attributes, a = [], r = {};
|
|
807
810
|
for (const c in o)
|
|
@@ -809,9 +812,9 @@ class ss {
|
|
|
809
812
|
return a.length < 1 ? null : (a.push(this.parser.createNodeMesh(e)), Promise.all(a).then((c) => {
|
|
810
813
|
const u = c.pop(), h = u.isGroup ? u.children : [u], d = c[0].count, p = [];
|
|
811
814
|
for (const m of h) {
|
|
812
|
-
const
|
|
815
|
+
const _ = new q(), f = new M(), g = new Q(), x = new M(1, 1, 1), b = new et(m.geometry, m.material, d);
|
|
813
816
|
for (let T = 0; T < d; T++)
|
|
814
|
-
r.TRANSLATION && f.fromBufferAttribute(r.TRANSLATION, T), r.ROTATION &&
|
|
817
|
+
r.TRANSLATION && f.fromBufferAttribute(r.TRANSLATION, T), r.ROTATION && g.fromBufferAttribute(r.ROTATION, T), r.SCALE && x.fromBufferAttribute(r.SCALE, T), b.setMatrixAt(T, _.compose(f, g, x));
|
|
815
818
|
for (const T in r)
|
|
816
819
|
if (T === "_COLOR_0") {
|
|
817
820
|
const A = r[T];
|
|
@@ -878,11 +881,11 @@ class is {
|
|
|
878
881
|
return new Promise(function(h, d) {
|
|
879
882
|
n.decodeDracoFile(u, function(p) {
|
|
880
883
|
for (const m in p.attributes) {
|
|
881
|
-
const
|
|
882
|
-
f !== void 0 && (
|
|
884
|
+
const _ = p.attributes[m], f = r[m];
|
|
885
|
+
f !== void 0 && (_.normalized = f);
|
|
883
886
|
}
|
|
884
887
|
h(p);
|
|
885
|
-
}, a, c,
|
|
888
|
+
}, a, c, I, d);
|
|
886
889
|
});
|
|
887
890
|
});
|
|
888
891
|
}
|
|
@@ -911,10 +914,10 @@ class Be extends Pt {
|
|
|
911
914
|
return t;
|
|
912
915
|
}
|
|
913
916
|
interpolate_(e, t, s, n) {
|
|
914
|
-
const i = this.resultBuffer, o = this.sampleValues, a = this.valueSize, r = a * 2, c = a * 3, u = n - t, h = (s - t) / u, d = h * h, p = d * h, m = e * c,
|
|
917
|
+
const i = this.resultBuffer, o = this.sampleValues, a = this.valueSize, r = a * 2, c = a * 3, u = n - t, h = (s - t) / u, d = h * h, p = d * h, m = e * c, _ = m - c, f = -2 * p + 3 * d, g = p - d, x = 1 - f, b = g - d + h;
|
|
915
918
|
for (let T = 0; T !== a; T++) {
|
|
916
|
-
const A = o[
|
|
917
|
-
i[T] = x * A + b *
|
|
919
|
+
const A = o[_ + T + a], v = o[_ + T + r] * u, N = o[m + T + a], B = o[m + T] * u;
|
|
920
|
+
i[T] = x * A + b * v + f * N + g * B;
|
|
918
921
|
}
|
|
919
922
|
return i;
|
|
920
923
|
}
|
|
@@ -926,7 +929,7 @@ class cs extends Be {
|
|
|
926
929
|
return as.fromArray(i).normalize().toArray(i), i;
|
|
927
930
|
}
|
|
928
931
|
}
|
|
929
|
-
const
|
|
932
|
+
const P = {
|
|
930
933
|
POINTS: 0,
|
|
931
934
|
LINES: 1,
|
|
932
935
|
LINE_LOOP: 2,
|
|
@@ -971,7 +974,7 @@ const L = {
|
|
|
971
974
|
COLOR_0: "color",
|
|
972
975
|
WEIGHTS_0: "skinWeight",
|
|
973
976
|
JOINTS_0: "skinIndex"
|
|
974
|
-
},
|
|
977
|
+
}, j = {
|
|
975
978
|
scale: "scale",
|
|
976
979
|
translation: "position",
|
|
977
980
|
rotation: "quaternion",
|
|
@@ -998,7 +1001,7 @@ function hs(l) {
|
|
|
998
1001
|
side: Lt
|
|
999
1002
|
})), l.DefaultMaterial;
|
|
1000
1003
|
}
|
|
1001
|
-
function
|
|
1004
|
+
function F(l, e, t) {
|
|
1002
1005
|
for (const s in t.extensions)
|
|
1003
1006
|
l[s] === void 0 && (e.userData.gltfExtensions = e.userData.gltfExtensions || {}, e.userData.gltfExtensions[s] = t.extensions[s]);
|
|
1004
1007
|
}
|
|
@@ -1084,7 +1087,7 @@ function fs(l) {
|
|
|
1084
1087
|
return l.search(/\.jpe?g($|\?)/i) > 0 || l.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : l.search(/\.webp($|\?)/i) > 0 || l.search(/^data\:image\/webp/) === 0 ? "image/webp" : l.search(/\.ktx2($|\?)/i) > 0 || l.search(/^data\:image\/ktx2/) === 0 ? "image/ktx2" : "image/png";
|
|
1085
1088
|
}
|
|
1086
1089
|
const ms = new q();
|
|
1087
|
-
class
|
|
1090
|
+
class gs {
|
|
1088
1091
|
constructor(e = {}, t = {}) {
|
|
1089
1092
|
this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new Ft(), 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 = {};
|
|
1090
1093
|
let s = !1, n = -1, i = !1, o = -1;
|
|
@@ -1124,7 +1127,7 @@ class _s {
|
|
|
1124
1127
|
parser: s,
|
|
1125
1128
|
userData: {}
|
|
1126
1129
|
};
|
|
1127
|
-
return
|
|
1130
|
+
return F(i, a, n), D(a, n), Promise.all(s._invokeAll(function(r) {
|
|
1128
1131
|
return r.afterRoot && r.afterRoot(a);
|
|
1129
1132
|
})).then(function() {
|
|
1130
1133
|
for (const r of a.scenes)
|
|
@@ -1340,19 +1343,19 @@ class _s {
|
|
|
1340
1343
|
const i = [];
|
|
1341
1344
|
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(o) {
|
|
1342
1345
|
const a = o[0], r = ie[n.type], c = K[n.componentType], u = c.BYTES_PER_ELEMENT, h = u * r, d = n.byteOffset || 0, p = n.bufferView !== void 0 ? s.bufferViews[n.bufferView].byteStride : void 0, m = n.normalized === !0;
|
|
1343
|
-
let
|
|
1346
|
+
let _, f;
|
|
1344
1347
|
if (p && p !== h) {
|
|
1345
|
-
const
|
|
1348
|
+
const g = Math.floor(d / p), x = "InterleavedBuffer:" + n.bufferView + ":" + n.componentType + ":" + g + ":" + n.count;
|
|
1346
1349
|
let b = t.cache.get(x);
|
|
1347
|
-
b || (
|
|
1350
|
+
b || (_ = new c(a, g * p, n.count * p / u), b = new it(_, p / u), t.cache.add(x, b)), f = new ot(b, r, d % p / u, m);
|
|
1348
1351
|
} else
|
|
1349
|
-
a === null ?
|
|
1352
|
+
a === null ? _ = new c(n.count * r) : _ = new c(a, d, n.count * r), f = new te(_, r, m);
|
|
1350
1353
|
if (n.sparse !== void 0) {
|
|
1351
|
-
const
|
|
1354
|
+
const g = ie.SCALAR, x = K[n.sparse.indices.componentType], b = n.sparse.indices.byteOffset || 0, T = n.sparse.values.byteOffset || 0, A = new x(o[1], b, n.sparse.count * g), v = new c(o[2], T, n.sparse.count * r);
|
|
1352
1355
|
a !== null && (f = new te(f.array.slice(), f.itemSize, f.normalized)), f.normalized = !1;
|
|
1353
|
-
for (let
|
|
1354
|
-
const
|
|
1355
|
-
if (f.setX(
|
|
1356
|
+
for (let N = 0, B = A.length; N < B; N++) {
|
|
1357
|
+
const k = A[N];
|
|
1358
|
+
if (f.setX(k, v[N * r]), r >= 2 && f.setY(k, v[N * r + 1]), r >= 3 && f.setZ(k, v[N * r + 2]), r >= 4 && f.setW(k, v[N * r + 3]), r >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
|
|
1356
1359
|
}
|
|
1357
1360
|
f.normalized = m;
|
|
1358
1361
|
}
|
|
@@ -1405,8 +1408,8 @@ class _s {
|
|
|
1405
1408
|
const u = Promise.resolve(r).then(function(h) {
|
|
1406
1409
|
return new Promise(function(d, p) {
|
|
1407
1410
|
let m = d;
|
|
1408
|
-
t.isImageBitmapLoader === !0 && (m = function(
|
|
1409
|
-
const f = new
|
|
1411
|
+
t.isImageBitmapLoader === !0 && (m = function(_) {
|
|
1412
|
+
const f = new _e(_);
|
|
1410
1413
|
f.needsUpdate = !0, d(f);
|
|
1411
1414
|
}), t.load(X.resolveURL(h, i.path), m, void 0, p);
|
|
1412
1415
|
});
|
|
@@ -1493,7 +1496,7 @@ class _s {
|
|
|
1493
1496
|
const h = i.pbrMetallicRoughness || {};
|
|
1494
1497
|
if (a.color = new H(1, 1, 1), a.opacity = 1, Array.isArray(h.baseColorFactor)) {
|
|
1495
1498
|
const d = h.baseColorFactor;
|
|
1496
|
-
a.color.setRGB(d[0], d[1], d[2],
|
|
1499
|
+
a.color.setRGB(d[0], d[1], d[2], I), a.opacity = d[3];
|
|
1497
1500
|
}
|
|
1498
1501
|
h.baseColorTexture !== void 0 && c.push(t.assignTexture(a, "map", h.baseColorTexture, Y)), a.metalness = h.metallicFactor !== void 0 ? h.metallicFactor : 1, a.roughness = h.roughnessFactor !== void 0 ? h.roughnessFactor : 1, h.metallicRoughnessTexture !== void 0 && (c.push(t.assignTexture(a, "metalnessMap", h.metallicRoughnessTexture)), c.push(t.assignTexture(a, "roughnessMap", h.metallicRoughnessTexture))), o = this._invokeOne(function(d) {
|
|
1499
1502
|
return d.getMaterialType && d.getMaterialType(e);
|
|
@@ -1509,11 +1512,11 @@ class _s {
|
|
|
1509
1512
|
}
|
|
1510
1513
|
if (i.occlusionTexture !== void 0 && o !== V && (c.push(t.assignTexture(a, "aoMap", i.occlusionTexture)), i.occlusionTexture.strength !== void 0 && (a.aoMapIntensity = i.occlusionTexture.strength)), i.emissiveFactor !== void 0 && o !== V) {
|
|
1511
1514
|
const h = i.emissiveFactor;
|
|
1512
|
-
a.emissive = new H().setRGB(h[0], h[1], h[2],
|
|
1515
|
+
a.emissive = new H().setRGB(h[0], h[1], h[2], I);
|
|
1513
1516
|
}
|
|
1514
1517
|
return i.emissiveTexture !== void 0 && o !== V && c.push(t.assignTexture(a, "emissiveMap", i.emissiveTexture, Y)), Promise.all(c).then(function() {
|
|
1515
1518
|
const h = new o(a);
|
|
1516
|
-
return i.name && (h.name = i.name), D(h, i), t.associations.set(h, { materials: e }), i.extensions &&
|
|
1519
|
+
return i.name && (h.name = i.name), D(h, i), t.associations.set(h, { materials: e }), i.extensions && F(n, h, i), h;
|
|
1517
1520
|
});
|
|
1518
1521
|
}
|
|
1519
1522
|
/**
|
|
@@ -1571,22 +1574,22 @@ class _s {
|
|
|
1571
1574
|
return a.push(t.loadGeometries(o)), Promise.all(a).then(function(r) {
|
|
1572
1575
|
const c = r.slice(0, r.length - 1), u = r[r.length - 1], h = [];
|
|
1573
1576
|
for (let p = 0, m = u.length; p < m; p++) {
|
|
1574
|
-
const
|
|
1575
|
-
let
|
|
1577
|
+
const _ = u[p], f = o[p];
|
|
1578
|
+
let g;
|
|
1576
1579
|
const x = c[p];
|
|
1577
|
-
if (f.mode ===
|
|
1578
|
-
|
|
1579
|
-
else if (f.mode ===
|
|
1580
|
-
|
|
1581
|
-
else if (f.mode ===
|
|
1582
|
-
|
|
1583
|
-
else if (f.mode ===
|
|
1584
|
-
|
|
1585
|
-
else if (f.mode ===
|
|
1586
|
-
|
|
1580
|
+
if (f.mode === P.TRIANGLES || f.mode === P.TRIANGLE_STRIP || f.mode === P.TRIANGLE_FAN || f.mode === void 0)
|
|
1581
|
+
g = i.isSkinnedMesh === !0 ? new gt(_, x) : new _t(_, x), g.isSkinnedMesh === !0 && g.normalizeSkinWeights(), f.mode === P.TRIANGLE_STRIP ? g.geometry = Se(g.geometry, Ie) : f.mode === P.TRIANGLE_FAN && (g.geometry = Se(g.geometry, ce));
|
|
1582
|
+
else if (f.mode === P.LINES)
|
|
1583
|
+
g = new Tt(_, x);
|
|
1584
|
+
else if (f.mode === P.LINE_STRIP)
|
|
1585
|
+
g = new yt(_, x);
|
|
1586
|
+
else if (f.mode === P.LINE_LOOP)
|
|
1587
|
+
g = new xt(_, x);
|
|
1588
|
+
else if (f.mode === P.POINTS)
|
|
1589
|
+
g = new Et(_, x);
|
|
1587
1590
|
else
|
|
1588
1591
|
throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + f.mode);
|
|
1589
|
-
Object.keys(
|
|
1592
|
+
Object.keys(g.geometry.morphAttributes).length > 0 && ds(g, i), g.name = t.createUniqueName(i.name || "mesh_" + e), D(g, i), f.extensions && F(n, g, f), t.assignFinalMaterial(g), h.push(g);
|
|
1590
1593
|
}
|
|
1591
1594
|
for (let p = 0, m = h.length; p < m; p++)
|
|
1592
1595
|
t.associations.set(h[p], {
|
|
@@ -1594,9 +1597,9 @@ class _s {
|
|
|
1594
1597
|
primitives: p
|
|
1595
1598
|
});
|
|
1596
1599
|
if (h.length === 1)
|
|
1597
|
-
return i.extensions &&
|
|
1600
|
+
return i.extensions && F(n, h[0], i), h[0];
|
|
1598
1601
|
const d = new ne();
|
|
1599
|
-
i.extensions &&
|
|
1602
|
+
i.extensions && F(n, d, i), t.associations.set(d, { meshes: e });
|
|
1600
1603
|
for (let p = 0, m = h.length; p < m; p++)
|
|
1601
1604
|
d.add(h[p]);
|
|
1602
1605
|
return d;
|
|
@@ -1653,8 +1656,8 @@ class _s {
|
|
|
1653
1656
|
loadAnimation(e) {
|
|
1654
1657
|
const t = this.json, s = this, n = t.animations[e], i = n.name ? n.name : "animation_" + e, o = [], a = [], r = [], c = [], u = [];
|
|
1655
1658
|
for (let h = 0, d = n.channels.length; h < d; h++) {
|
|
1656
|
-
const p = n.channels[h], m = n.samplers[p.sampler],
|
|
1657
|
-
|
|
1659
|
+
const p = n.channels[h], m = n.samplers[p.sampler], _ = p.target, f = _.node, g = n.parameters !== void 0 ? n.parameters[m.input] : m.input, x = n.parameters !== void 0 ? n.parameters[m.output] : m.output;
|
|
1660
|
+
_.node !== void 0 && (o.push(this.getDependency("node", f)), a.push(this.getDependency("accessor", g)), r.push(this.getDependency("accessor", x)), c.push(m), u.push(_));
|
|
1658
1661
|
}
|
|
1659
1662
|
return Promise.all([
|
|
1660
1663
|
Promise.all(o),
|
|
@@ -1663,17 +1666,17 @@ class _s {
|
|
|
1663
1666
|
Promise.all(c),
|
|
1664
1667
|
Promise.all(u)
|
|
1665
1668
|
]).then(function(h) {
|
|
1666
|
-
const d = h[0], p = h[1], m = h[2],
|
|
1669
|
+
const d = h[0], p = h[1], m = h[2], _ = h[3], f = h[4], g = [];
|
|
1667
1670
|
for (let x = 0, b = d.length; x < b; x++) {
|
|
1668
|
-
const T = d[x], A = p[x],
|
|
1671
|
+
const T = d[x], A = p[x], v = m[x], N = _[x], B = f[x];
|
|
1669
1672
|
if (T === void 0) continue;
|
|
1670
1673
|
T.updateMatrix && T.updateMatrix();
|
|
1671
|
-
const
|
|
1672
|
-
if (
|
|
1673
|
-
for (let J = 0; J <
|
|
1674
|
-
|
|
1674
|
+
const k = s._createAnimationTracks(T, A, v, N, B);
|
|
1675
|
+
if (k)
|
|
1676
|
+
for (let J = 0; J < k.length; J++)
|
|
1677
|
+
g.push(k[J]);
|
|
1675
1678
|
}
|
|
1676
|
-
return new wt(i, void 0,
|
|
1679
|
+
return new wt(i, void 0, g);
|
|
1677
1680
|
});
|
|
1678
1681
|
}
|
|
1679
1682
|
createNodeMesh(e) {
|
|
@@ -1733,7 +1736,7 @@ class _s {
|
|
|
1733
1736
|
if (i.isBone === !0 ? u = new St() : c.length > 1 ? u = new ne() : c.length === 1 ? u = c[0] : u = new ke(), u !== c[0])
|
|
1734
1737
|
for (let h = 0, d = c.length; h < d; h++)
|
|
1735
1738
|
u.add(c[h]);
|
|
1736
|
-
if (i.name && (u.userData.name = i.name, u.name = o), D(u, i), i.extensions &&
|
|
1739
|
+
if (i.name && (u.userData.name = i.name, u.name = o), D(u, i), i.extensions && F(s, u, i), i.matrix !== void 0) {
|
|
1737
1740
|
const h = new q();
|
|
1738
1741
|
h.fromArray(i.matrix), u.applyMatrix4(h);
|
|
1739
1742
|
} else
|
|
@@ -1756,7 +1759,7 @@ class _s {
|
|
|
1756
1759
|
*/
|
|
1757
1760
|
loadScene(e) {
|
|
1758
1761
|
const t = this.extensions, s = this.json.scenes[e], n = this, i = new ne();
|
|
1759
|
-
s.name && (i.name = n.createUniqueName(s.name)), D(i, s), s.extensions &&
|
|
1762
|
+
s.name && (i.name = n.createUniqueName(s.name)), D(i, s), s.extensions && F(t, i, s);
|
|
1760
1763
|
const o = s.nodes || [], a = [];
|
|
1761
1764
|
for (let r = 0, c = o.length; r < c; r++)
|
|
1762
1765
|
a.push(n.getDependency("node", o[r]));
|
|
@@ -1766,7 +1769,7 @@ class _s {
|
|
|
1766
1769
|
const c = (u) => {
|
|
1767
1770
|
const h = /* @__PURE__ */ new Map();
|
|
1768
1771
|
for (const [d, p] of n.associations)
|
|
1769
|
-
(d instanceof se || d instanceof
|
|
1772
|
+
(d instanceof se || d instanceof _e) && h.set(d, p);
|
|
1770
1773
|
return u.traverse((d) => {
|
|
1771
1774
|
const p = n.associations.get(d);
|
|
1772
1775
|
p != null && h.set(d, p);
|
|
@@ -1777,19 +1780,19 @@ class _s {
|
|
|
1777
1780
|
}
|
|
1778
1781
|
_createAnimationTracks(e, t, s, n, i) {
|
|
1779
1782
|
const o = [], a = e.name ? e.name : e.uuid, r = [];
|
|
1780
|
-
|
|
1783
|
+
j[i.path] === j.weights ? e.traverse(function(d) {
|
|
1781
1784
|
d.morphTargetInfluences && r.push(d.name ? d.name : d.uuid);
|
|
1782
1785
|
}) : r.push(a);
|
|
1783
1786
|
let c;
|
|
1784
|
-
switch (
|
|
1785
|
-
case
|
|
1787
|
+
switch (j[i.path]) {
|
|
1788
|
+
case j.weights:
|
|
1786
1789
|
c = ye;
|
|
1787
1790
|
break;
|
|
1788
|
-
case
|
|
1791
|
+
case j.rotation:
|
|
1789
1792
|
c = xe;
|
|
1790
1793
|
break;
|
|
1791
|
-
case
|
|
1792
|
-
case
|
|
1794
|
+
case j.translation:
|
|
1795
|
+
case j.scale:
|
|
1793
1796
|
c = Te;
|
|
1794
1797
|
break;
|
|
1795
1798
|
default:
|
|
@@ -1808,7 +1811,7 @@ class _s {
|
|
|
1808
1811
|
const u = n.interpolation !== void 0 ? ls[n.interpolation] : Ue, h = this._getArrayFromAccessor(s);
|
|
1809
1812
|
for (let d = 0, p = r.length; d < p; d++) {
|
|
1810
1813
|
const m = new c(
|
|
1811
|
-
r[d] + "." +
|
|
1814
|
+
r[d] + "." + j[i.path],
|
|
1812
1815
|
t.array,
|
|
1813
1816
|
h,
|
|
1814
1817
|
u
|
|
@@ -1834,7 +1837,7 @@ class _s {
|
|
|
1834
1837
|
}, e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;
|
|
1835
1838
|
}
|
|
1836
1839
|
}
|
|
1837
|
-
function
|
|
1840
|
+
function _s(l, e, t) {
|
|
1838
1841
|
const s = e.attributes, n = new Nt();
|
|
1839
1842
|
if (s.POSITION !== void 0) {
|
|
1840
1843
|
const a = t.json.accessors[s.POSITION], r = a.min, c = a.max;
|
|
@@ -1861,8 +1864,8 @@ function gs(l, e, t) {
|
|
|
1861
1864
|
const d = t.json.accessors[h.POSITION], p = d.min, m = d.max;
|
|
1862
1865
|
if (p !== void 0 && m !== void 0) {
|
|
1863
1866
|
if (r.setX(Math.max(Math.abs(p[0]), Math.abs(m[0]))), r.setY(Math.max(Math.abs(p[1]), Math.abs(m[1]))), r.setZ(Math.max(Math.abs(p[2]), Math.abs(m[2]))), d.normalized) {
|
|
1864
|
-
const
|
|
1865
|
-
r.multiplyScalar(
|
|
1867
|
+
const _ = fe(K[d.componentType]);
|
|
1868
|
+
r.multiplyScalar(_);
|
|
1866
1869
|
}
|
|
1867
1870
|
a.max(r);
|
|
1868
1871
|
} else
|
|
@@ -1892,11 +1895,11 @@ function Ne(l, e, t) {
|
|
|
1892
1895
|
});
|
|
1893
1896
|
n.push(o);
|
|
1894
1897
|
}
|
|
1895
|
-
return Ee.workingColorSpace !==
|
|
1898
|
+
return Ee.workingColorSpace !== I && "COLOR_0" in s && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Ee.workingColorSpace}" not supported.`), D(l, e), _s(l, e, t), Promise.all(n).then(function() {
|
|
1896
1899
|
return e.targets !== void 0 ? us(l, e.targets, t) : l;
|
|
1897
1900
|
});
|
|
1898
1901
|
}
|
|
1899
|
-
const Oe = { type: "change" },
|
|
1902
|
+
const Oe = { type: "change" }, ge = { type: "start" }, ze = { type: "end" }, W = new Ct(), De = new It(), Ts = Math.cos(70 * Ge.DEG2RAD), R = new M(), w = 2 * Math.PI, E = {
|
|
1900
1903
|
NONE: -1,
|
|
1901
1904
|
ROTATE: 0,
|
|
1902
1905
|
DOLLY: 1,
|
|
@@ -2260,7 +2263,7 @@ function Rs(l) {
|
|
|
2260
2263
|
default:
|
|
2261
2264
|
this.state = E.NONE;
|
|
2262
2265
|
}
|
|
2263
|
-
this.state !== E.NONE && this.dispatchEvent(
|
|
2266
|
+
this.state !== E.NONE && this.dispatchEvent(ge);
|
|
2264
2267
|
}
|
|
2265
2268
|
function Ms(l) {
|
|
2266
2269
|
switch (this.state) {
|
|
@@ -2279,7 +2282,7 @@ function Ms(l) {
|
|
|
2279
2282
|
}
|
|
2280
2283
|
}
|
|
2281
2284
|
function ws(l) {
|
|
2282
|
-
this.enabled === !1 || this.enableZoom === !1 || this.state !== E.NONE || (l.preventDefault(), this.dispatchEvent(
|
|
2285
|
+
this.enabled === !1 || this.enableZoom === !1 || this.state !== E.NONE || (l.preventDefault(), this.dispatchEvent(ge), this._handleMouseWheel(this._customWheelEvent(l)), this.dispatchEvent(ze));
|
|
2283
2286
|
}
|
|
2284
2287
|
function Ss(l) {
|
|
2285
2288
|
this.enabled !== !1 && this._handleKeyDown(l);
|
|
@@ -2317,7 +2320,7 @@ function As(l) {
|
|
|
2317
2320
|
default:
|
|
2318
2321
|
this.state = E.NONE;
|
|
2319
2322
|
}
|
|
2320
|
-
this.state !== E.NONE && this.dispatchEvent(
|
|
2323
|
+
this.state !== E.NONE && this.dispatchEvent(ge);
|
|
2321
2324
|
}
|
|
2322
2325
|
function Ls(l) {
|
|
2323
2326
|
switch (this._trackPointer(l), this.state) {
|
|
@@ -2362,6 +2365,14 @@ const Ds = (l, e) => {
|
|
|
2362
2365
|
type: Boolean,
|
|
2363
2366
|
default: !1
|
|
2364
2367
|
},
|
|
2368
|
+
clearAlpha: {
|
|
2369
|
+
type: [String, Number],
|
|
2370
|
+
default: 1
|
|
2371
|
+
},
|
|
2372
|
+
clearColor: {
|
|
2373
|
+
type: String,
|
|
2374
|
+
default: "#7fbfff"
|
|
2375
|
+
},
|
|
2365
2376
|
useOrbitControls: {
|
|
2366
2377
|
type: Boolean,
|
|
2367
2378
|
default: !1
|
|
@@ -2386,7 +2397,7 @@ const Ds = (l, e) => {
|
|
|
2386
2397
|
const h = () => {
|
|
2387
2398
|
t("animate", {
|
|
2388
2399
|
GLTFLoader: de,
|
|
2389
|
-
THREE:
|
|
2400
|
+
THREE: L,
|
|
2390
2401
|
VRMExpressionPresetName: Me,
|
|
2391
2402
|
VRMHumanBoneName: Re,
|
|
2392
2403
|
camera: r,
|
|
@@ -2399,36 +2410,43 @@ const Ds = (l, e) => {
|
|
|
2399
2410
|
}, p = () => {
|
|
2400
2411
|
o != null && (cancelAnimationFrame(o), o = null);
|
|
2401
2412
|
};
|
|
2402
|
-
|
|
2403
|
-
|
|
2413
|
+
C(() => s.animation, (_) => {
|
|
2414
|
+
_ == !0 ? d() : p();
|
|
2415
|
+
}), C(() => s.clearAlpha, (_) => {
|
|
2416
|
+
c && c.setClearAlpha(parseFloat(_));
|
|
2417
|
+
}), C(() => s.clearColor, (_) => {
|
|
2418
|
+
if (c) {
|
|
2419
|
+
const f = new L.Color(_), g = c.getClearAlpha();
|
|
2420
|
+
c.setClearColor(f, g);
|
|
2421
|
+
}
|
|
2404
2422
|
});
|
|
2405
2423
|
const m = () => {
|
|
2406
|
-
const
|
|
2424
|
+
const _ = i.value, f = _.clientWidth, g = _.clientHeight, x = {
|
|
2407
2425
|
antialias: !0,
|
|
2408
2426
|
alpha: !1
|
|
2409
2427
|
};
|
|
2410
|
-
if (
|
|
2428
|
+
if (L.ColorManagement.enabled = !1, c = new L.WebGLRenderer(x), c.setPixelRatio(window.devicePixelRatio), c.setSize(f, g), c.setClearColor(s.clearColor, s.clearAlpha), c.outputColorSpace = L.SRGBColorSpace, _.appendChild(c.domElement), a = new L.Scene(), r = new L.PerspectiveCamera(
|
|
2411
2429
|
45,
|
|
2412
|
-
f /
|
|
2430
|
+
f / g,
|
|
2413
2431
|
0.1,
|
|
2414
2432
|
1e3
|
|
2415
|
-
), r.position.set(0, 1.25, 1), s.useOrbitControls && (u = new ys(r,
|
|
2416
|
-
const T = new
|
|
2433
|
+
), r.position.set(0, 1.25, 1), s.useOrbitControls && (u = new ys(r, _), u.screenSpacePanning = !0, u.target.set(0, 1.25, 0), u.update()), s.useGridHelper) {
|
|
2434
|
+
const T = new L.GridHelper(10, 10);
|
|
2417
2435
|
a.add(T), T.visible = !0;
|
|
2418
2436
|
}
|
|
2419
2437
|
if (s.useAxesHelper) {
|
|
2420
|
-
const T = new
|
|
2438
|
+
const T = new L.AxesHelper(5);
|
|
2421
2439
|
a.add(T);
|
|
2422
2440
|
}
|
|
2423
2441
|
if (s.useDefaultLight) {
|
|
2424
|
-
const T = new
|
|
2442
|
+
const T = new L.DirectionalLight(16777215);
|
|
2425
2443
|
T.intensity = 3, T.position.set(1, 1, 1).normalize(), a.add(T);
|
|
2426
|
-
const A = new
|
|
2444
|
+
const A = new L.AmbientLight(4210752);
|
|
2427
2445
|
a.add(A);
|
|
2428
2446
|
}
|
|
2429
2447
|
t("initialized", {
|
|
2430
2448
|
GLTFLoader: de,
|
|
2431
|
-
THREE:
|
|
2449
|
+
THREE: L,
|
|
2432
2450
|
VRMExpressionPresetName: Me,
|
|
2433
2451
|
VRMHumanBoneName: Re,
|
|
2434
2452
|
camera: r,
|
|
@@ -2443,17 +2461,17 @@ const Ds = (l, e) => {
|
|
|
2443
2461
|
console.error(f);
|
|
2444
2462
|
return;
|
|
2445
2463
|
}
|
|
2446
|
-
const
|
|
2447
|
-
const f = i.value,
|
|
2448
|
-
c.setPixelRatio(window.devicePixelRatio), c.setSize(
|
|
2464
|
+
const _ = () => {
|
|
2465
|
+
const f = i.value, g = f.clientWidth, x = f.clientHeight;
|
|
2466
|
+
c.setPixelRatio(window.devicePixelRatio), c.setSize(g, x), r.aspect = g / x, r.updateProjectionMatrix();
|
|
2449
2467
|
};
|
|
2450
|
-
window.addEventListener("resize",
|
|
2451
|
-
}), (
|
|
2468
|
+
window.addEventListener("resize", _), m();
|
|
2469
|
+
}), (_, f) => (me(), Ce("div", {
|
|
2452
2470
|
ref: n,
|
|
2453
2471
|
class: "box"
|
|
2454
2472
|
}));
|
|
2455
2473
|
}
|
|
2456
|
-
}, Us = /* @__PURE__ */ Ds(Cs, [["__scopeId", "data-v-
|
|
2474
|
+
}, Us = /* @__PURE__ */ Ds(Cs, [["__scopeId", "data-v-81e1dabc"]]), Is = {
|
|
2457
2475
|
__name: "VroidExpression",
|
|
2458
2476
|
props: {
|
|
2459
2477
|
command: {
|
|
@@ -2486,9 +2504,9 @@ const Ds = (l, e) => {
|
|
|
2486
2504
|
};
|
|
2487
2505
|
return $(async () => {
|
|
2488
2506
|
s.data != null ? i(s.data) : n(s.url);
|
|
2489
|
-
}),
|
|
2507
|
+
}), C(() => s.data, () => {
|
|
2490
2508
|
s.data != null && i(s.data);
|
|
2491
|
-
}),
|
|
2509
|
+
}), C(() => s.url, () => {
|
|
2492
2510
|
s.url && n(s.url);
|
|
2493
2511
|
}), (o, a) => null;
|
|
2494
2512
|
}
|
|
@@ -2526,9 +2544,9 @@ const Ds = (l, e) => {
|
|
|
2526
2544
|
};
|
|
2527
2545
|
return $(async () => {
|
|
2528
2546
|
s.data != null ? i(s.data) : n(s.url);
|
|
2529
|
-
}),
|
|
2547
|
+
}), C(() => s.data, () => {
|
|
2530
2548
|
s.data != null && i(s.data);
|
|
2531
|
-
}),
|
|
2549
|
+
}), C(() => s.url, () => {
|
|
2532
2550
|
s.url && n(s.url);
|
|
2533
2551
|
}), (o, a) => null;
|
|
2534
2552
|
}
|
|
@@ -2571,9 +2589,9 @@ const Ds = (l, e) => {
|
|
|
2571
2589
|
};
|
|
2572
2590
|
return $(async () => {
|
|
2573
2591
|
s.data != null ? o(s.data) : i(s.url);
|
|
2574
|
-
}),
|
|
2592
|
+
}), C(() => s.data, () => {
|
|
2575
2593
|
s.data != null && o(s.data);
|
|
2576
|
-
}),
|
|
2594
|
+
}), C(() => s.url, () => {
|
|
2577
2595
|
s.url && i(s.url);
|
|
2578
2596
|
}), (a, r) => null;
|
|
2579
2597
|
}
|
|
@@ -2622,16 +2640,16 @@ const Ds = (l, e) => {
|
|
|
2622
2640
|
const m = Object.keys(n).length;
|
|
2623
2641
|
p == 0 && m && t("loading", s.name);
|
|
2624
2642
|
}, u = (h, d, p, m) => {
|
|
2625
|
-
const
|
|
2643
|
+
const _ = Object.keys(n).length;
|
|
2626
2644
|
p && (d == "load_expression" && (o.value = m), d == "load_pose" && (a.value = m), d == "load_vrm" && (r.value = m), i[h] = d), delete n[h];
|
|
2627
2645
|
const f = Object.keys(n).length;
|
|
2628
|
-
if (
|
|
2629
|
-
const
|
|
2646
|
+
if (_ && f == 0) {
|
|
2647
|
+
const g = {};
|
|
2630
2648
|
for (const b in i) {
|
|
2631
2649
|
const T = i[b];
|
|
2632
|
-
T == "load_expression" && (
|
|
2650
|
+
T == "load_expression" && (g.expression = o.value), T == "load_pose" && (g.pose = a.value), T == "load_vrm" && (g.vrm = r.value);
|
|
2633
2651
|
}
|
|
2634
|
-
t("loaded", s.name,
|
|
2652
|
+
t("loaded", s.name, g);
|
|
2635
2653
|
const x = Object.keys(i);
|
|
2636
2654
|
for (const b of x)
|
|
2637
2655
|
delete i[b];
|
|
@@ -2715,7 +2733,7 @@ const Ds = (l, e) => {
|
|
|
2715
2733
|
const n = (o) => {
|
|
2716
2734
|
t("loading", o);
|
|
2717
2735
|
}, i = (o, a) => {
|
|
2718
|
-
"vrm" in a && s.value.setModel(a.vrm), "pose" in a && (s.value.setPose(a.pose), s.value.updatePose()), "expression" in a && (s.value.importExpression(a.expression), s.value.updateExpression()), t("loaded", o, s.value);
|
|
2736
|
+
"vrm" in a && s.value.setModel(a.vrm), "pose" in a && (s.value.resetPose(), s.value.setPose(a.pose), s.value.updatePose()), "expression" in a && (s.value.resetExpression(), s.value.importExpression(a.expression), s.value.updateExpression()), t("loaded", o, s.value);
|
|
2719
2737
|
};
|
|
2720
2738
|
return (o, a) => (me(), We(js, {
|
|
2721
2739
|
name: l.model_name,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(A,
|
|
2
|
-
/*$vite$:1*/`,document.head.appendChild(J);function me(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>l[t]})}}return e.default=l,Object.freeze(e)}const C=me(h);class V{constructor(){}async fetchJSON(e){const t=await fetch(e);return t.ok?await t.json():null}normalizePose(e){return e==null?null:"pose"in e?e.pose:e}async fetchPose(e){const t=await this.fetchJSON(e);return this.normalizePose(t)}async fetchExpression(e){const t=await this.fetchJSON(e);return t==null?null:"expressions"in t?t.expressions:t}}class H{constructor(){this.vrm=null}get scene(){return this.vrm?this.vrm.scene:null}setModel(e){this.vrm=e}setPosition(e){this.vrm.scene.position.x=e.x,this.vrm.scene.position.y=e.y,this.vrm.scene.position.z=e.z}getPosition(){return{x:this.vrm.scene.position.x,y:this.vrm.scene.position.y,z:this.vrm.scene.position.z}}setPose(e){this.vrm&&this.vrm.humanoid.setNormalizedPose(e)}getPose(){return this.vrm?this.vrm.humanoid.getNormalizedPose():null}updatePose(){this.vrm&&this.vrm.humanoid.update()}resetPose(){this.vrm&&this.vrm.humanoid.resetNormalizedPose()}getBoneNode(e){return this.vrm?this.vrm.humanoid.getNormalizedBoneNode(e):null}isValid(){return!!this.vrm}getBoneRotate(e){const t=this.getBoneNode(e);return t?{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z}:null}setBoneRotate(e,t,s,n){const i=this.getBoneNode(e);i&&(i.rotation.x=t,i.rotation.y=s,i.rotation.z=n)}getBonePosition(e){const t=this.getBoneNode(e);return t?{x:t.position.x,y:t.position.y,z:t.position.z}:null}setBonePosition(e,t,s,n){const i=this.getBoneNode(e);i&&(i.position.x=t,i.position.y=s,i.position.z=n)}getMetaVersion(){return this.vrm?this.vrm.meta.metaVersion:null}setExpression(e,t){this.vrm&&this.vrm.expressionManager.setValue(e,t)}getExpression(e){return this.vrm?this.vrm.expressionManager.getValue(e):null}updateExpression(){return this.vrm?this.vrm.expressionManager.update():null}getExpressionNames(){if(this.vrm){let e=[];for(const t in this.vrm.expressionManager.expressionMap)e.push(t);return e}return null}importExpression(e){if(this.vrm)for(const t in e)this.vrm.expressionManager.setValue(t,e[t])}exportExpression(){if(this.vrm){let e={};const t=this.getExpressionNames();for(const s in t)e[s]=this.getExpression(s);return e}return null}}class ee{static isWebGL2Available(){try{const e=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&e.getContext("webgl2"))}catch{return!1}}static isColorSpaceAvailable(e){try{const t=document.createElement("canvas"),s=window.WebGL2RenderingContext&&t.getContext("webgl2");return s.drawingBufferColorSpace=e,s.drawingBufferColorSpace===e}catch{return!1}}static getWebGL2ErrorMessage(){return this._getErrorMessage(2)}static _getErrorMessage(e){const t={1:"WebGL",2:"WebGL 2"},s={1:window.WebGLRenderingContext,2:window.WebGL2RenderingContext};let n='Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';const i=document.createElement("div");return i.id="webglmessage",i.style.fontFamily="monospace",i.style.fontSize="13px",i.style.fontWeight="normal",i.style.textAlign="center",i.style.background="#fff",i.style.color="#000",i.style.padding="1.5em",i.style.width="400px",i.style.margin="5em auto 0",s[e]?n=n.replace("$0","graphics card"):n=n.replace("$0","browser"),n=n.replace("$1",t[e]),i.innerHTML=n,i}static isWebGLAvailable(){console.warn("isWebGLAvailable() has been deprecated and will be removed in r178. Use isWebGL2Available() instead.");try{const e=document.createElement("canvas");return!!(window.WebGLRenderingContext&&(e.getContext("webgl")||e.getContext("experimental-webgl")))}catch{return!1}}static getWebGLErrorMessage(){return console.warn("getWebGLErrorMessage() has been deprecated and will be removed in r178. Use getWebGL2ErrorMessage() instead."),this._getErrorMessage(1)}}function te(l,e){if(e===h.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(e===h.TriangleFanDrawMode||e===h.TriangleStripDrawMode){let t=l.getIndex();if(t===null){const o=[],a=l.getAttribute("position");if(a!==void 0){for(let r=0;r<a.count;r++)o.push(r);l.setIndex(o),t=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const s=t.count-2,n=[];if(e===h.TriangleFanDrawMode)for(let o=1;o<=s;o++)n.push(t.getX(0)),n.push(t.getX(o)),n.push(t.getX(o+1));else for(let o=0;o<s;o++)o%2===0?(n.push(t.getX(o)),n.push(t.getX(o+1)),n.push(t.getX(o+2))):(n.push(t.getX(o+2)),n.push(t.getX(o+1)),n.push(t.getX(o)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=l.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),l}class K extends h.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new be(t)}),this.register(function(t){return new Me(t)}),this.register(function(t){return new Ce(t)}),this.register(function(t){return new De(t)}),this.register(function(t){return new Re(t)}),this.register(function(t){return new Se(t)}),this.register(function(t){return new we(t)}),this.register(function(t){return new Le(t)}),this.register(function(t){return new Ae(t)}),this.register(function(t){return new xe(t)}),this.register(function(t){return new Pe(t)}),this.register(function(t){return new Te(t)}),this.register(function(t){return new Ne(t)}),this.register(function(t){return new Oe(t)}),this.register(function(t){return new ge(t)}),this.register(function(t){return new Ie(t)}),this.register(function(t){return new ke(t)})}load(e,t,s,n){const i=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=h.LoaderUtils.extractUrlBase(e);o=h.LoaderUtils.resolveURL(c,this.path)}else o=h.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){n?n(c):console.error(c),i.manager.itemError(e),i.manager.itemEnd(e)},r=new h.FileLoader(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,function(c){try{i.parse(c,o,function(d){t(d),i.manager.itemEnd(e)},a)}catch(d){a(d)}},s,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,n){let i;const o={},a={},r=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(r.decode(new Uint8Array(e,0,4))===se){try{o[b.KHR_BINARY_GLTF]=new ve(e)}catch(u){n&&n(u);return}i=JSON.parse(o[b.KHR_BINARY_GLTF].content)}else i=JSON.parse(r.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new qe(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d<this.pluginCallbacks.length;d++){const u=this.pluginCallbacks[d](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,o[u.name]=!0}if(i.extensionsUsed)for(let d=0;d<i.extensionsUsed.length;++d){const u=i.extensionsUsed[d],p=i.extensionsRequired||[];switch(u){case b.KHR_MATERIALS_UNLIT:o[u]=new ye;break;case b.KHR_DRACO_MESH_COMPRESSION:o[u]=new je(i,this.dracoLoader);break;case b.KHR_TEXTURE_TRANSFORM:o[u]=new Fe;break;case b.KHR_MESH_QUANTIZATION:o[u]=new Ue;break;default:p.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,i){s.parse(e,t,n,i)})}}function _e(){let l={};return{get:function(e){return l[e]},add:function(e,t){l[e]=t},remove:function(e){delete l[e]},removeAll:function(){l={}}}}const b={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ge{constructor(e){this.parser=e,this.name=b.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const i=t[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let n=t.cache.get(s);if(n)return n;const i=t.json,r=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let c;const d=new h.Color(16777215);r.color!==void 0&&d.setRGB(r.color[0],r.color[1],r.color[2],h.LinearSRGBColorSpace);const u=r.range!==void 0?r.range:0;switch(r.type){case"directional":c=new h.DirectionalLight(d),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new h.PointLight(d),c.distance=u;break;case"spot":c=new h.SpotLight(d),c.distance=u,r.spot=r.spot||{},r.spot.innerConeAngle=r.spot.innerConeAngle!==void 0?r.spot.innerConeAngle:0,r.spot.outerConeAngle=r.spot.outerConeAngle!==void 0?r.spot.outerConeAngle:Math.PI/4,c.angle=r.spot.outerConeAngle,c.penumbra=1-r.spot.innerConeAngle/r.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+r.type)}return c.position.set(0,0,0),R(c,r),r.intensity!==void 0&&(c.intensity=r.intensity),c.name=t.createUniqueName(r.name||"light_"+e),n=Promise.resolve(c),t.cache.add(s,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,i=s.json.nodes[e],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(r){return s._getNodeRef(t.cache,a,r)})}}class ye{constructor(){this.name=b.KHR_MATERIALS_UNLIT}getMaterialType(){return h.MeshBasicMaterial}extendParams(e,t,s){const n=[];e.color=new h.Color(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const o=i.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],h.LinearSRGBColorSpace),e.opacity=o[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",i.baseColorTexture,h.SRGBColorSpace))}return Promise.all(n)}}class xe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(t.emissiveIntensity=i),Promise.resolve()}}class be{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(i.push(s.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new h.Vector2(a,a)}return Promise.all(i)}}class Me{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_DISPERSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class Te{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(i)}}class Se{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new h.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=n.extensions[this.name];if(o.sheenColorFactor!==void 0){const a=o.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],h.LinearSRGBColorSpace)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&i.push(s.assignTexture(t,"sheenColorMap",o.sheenColorTexture,h.SRGBColorSpace)),o.sheenRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class we{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&i.push(s.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(i)}}class Le{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&i.push(s.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return t.attenuationColor=new h.Color().setRGB(a[0],a[1],a[2],h.LinearSRGBColorSpace),Promise.all(i)}}class Ae{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class Pe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&i.push(s.assignTexture(t,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return t.specularColor=new h.Color().setRGB(a[0],a[1],a[2],h.LinearSRGBColorSpace),o.specularColorTexture!==void 0&&i.push(s.assignTexture(t,"specularColorMap",o.specularColorTexture,h.SRGBColorSpace)),Promise.all(i)}}class Oe{constructor(e){this.parser=e,this.name=b.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&i.push(s.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(i)}}class Ne{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&i.push(s.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(i)}}class Ce{constructor(e){this.parser=e,this.name=b.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,o)}}class De{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],a=n.images[o.source];let r=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(r=c)}return s.loadTextureImage(e,o.source,r)}}class Re{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],a=n.images[o.source];let r=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(r=c)}return s.loadTextureImage(e,o.source,r)}}class Ie{constructor(e){this.name=b.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(a){const r=n.byteOffset||0,c=n.byteLength||0,d=n.count,u=n.byteStride,p=new Uint8Array(a,r,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(d,u,p,n.mode,n.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(d*u);return o.decodeGltfBuffer(new Uint8Array(f),d,u,p,n.mode,n.filter),f})})}else return null}}class ke{constructor(e){this.name=b.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=t.meshes[s.mesh];for(const c of n.primitives)if(c.mode!==O.TRIANGLES&&c.mode!==O.TRIANGLE_STRIP&&c.mode!==O.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=s.extensions[this.name].attributes,a=[],r={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(d=>(r[c]=d,r[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const d=c.pop(),u=d.isGroup?d.children:[d],p=c[0].count,f=[];for(const _ of u){const y=new h.Matrix4,m=new h.Vector3,g=new h.Quaternion,M=new h.Vector3(1,1,1),w=new h.InstancedMesh(_.geometry,_.material,p);for(let x=0;x<p;x++)r.TRANSLATION&&m.fromBufferAttribute(r.TRANSLATION,x),r.ROTATION&&g.fromBufferAttribute(r.ROTATION,x),r.SCALE&&M.fromBufferAttribute(r.SCALE,x),w.setMatrixAt(x,y.compose(m,g,M));for(const x in r)if(x==="_COLOR_0"){const N=r[x];w.instanceColor=new h.InstancedBufferAttribute(N.array,N.itemSize,N.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&_.geometry.setAttribute(x,r[x]);h.Object3D.prototype.copy.call(w,_),this.parser.assignFinalMaterial(w),f.push(w)}return d.isGroup?(d.clear(),d.add(...f),d):f[0]}))}}const se="glTF",G=12,ne={JSON:1313821514,BIN:5130562};class ve{constructor(e){this.name=b.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,G),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==se)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-G,i=new DataView(e,G);let o=0;for(;o<n;){const a=i.getUint32(o,!0);o+=4;const r=i.getUint32(o,!0);if(o+=4,r===ne.JSON){const c=new Uint8Array(e,G+o,a);this.content=s.decode(c)}else if(r===ne.BIN){const c=G+o;this.body=e.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class je{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=b.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,n=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},r={},c={};for(const d in o){const u=X[d]||d.toLowerCase();a[u]=o[d]}for(const d in e.attributes){const u=X[d]||d.toLowerCase();if(o[d]!==void 0){const p=s.accessors[e.attributes[d]],f=U[p.componentType];c[u]=f.name,r[u]=p.normalized===!0}}return t.getDependency("bufferView",i).then(function(d){return new Promise(function(u,p){n.decodeDracoFile(d,function(f){for(const _ in f.attributes){const y=f.attributes[_],m=r[_];m!==void 0&&(y.normalized=m)}u(f)},a,c,h.LinearSRGBColorSpace,p)})})}}class Fe{constructor(){this.name=b.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Ue{constructor(){this.name=b.KHR_MESH_QUANTIZATION}}class ie extends h.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,i=e*n*3+n;for(let o=0;o!==n;o++)t[o]=s[i+o];return t}interpolate_(e,t,s,n){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,r=a*2,c=a*3,d=n-t,u=(s-t)/d,p=u*u,f=p*u,_=e*c,y=_-c,m=-2*f+3*p,g=f-p,M=1-m,w=g-p+u;for(let x=0;x!==a;x++){const N=o[y+x+a],k=o[y+x+r]*d,D=o[_+x+a],B=o[_+x]*d;i[x]=M*N+w*k+m*D+g*B}return i}}const Ge=new h.Quaternion;class Be extends ie{interpolate_(e,t,s,n){const i=super.interpolate_(e,t,s,n);return Ge.fromArray(i).normalize().toArray(i),i}}const O={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},U={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},oe={9728:h.NearestFilter,9729:h.LinearFilter,9984:h.NearestMipmapNearestFilter,9985:h.LinearMipmapNearestFilter,9986:h.NearestMipmapLinearFilter,9987:h.LinearMipmapLinearFilter},re={33071:h.ClampToEdgeWrapping,33648:h.MirroredRepeatWrapping,10497:h.RepeatWrapping},z={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},X={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},I={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Ve={CUBICSPLINE:void 0,LINEAR:h.InterpolateLinear,STEP:h.InterpolateDiscrete},W={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Ee(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new h.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:h.FrontSide})),l.DefaultMaterial}function j(l,e,t){for(const s in t.extensions)l[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function R(l,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(l.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Ke(l,e,t){let s=!1,n=!1,i=!1;for(let c=0,d=e.length;c<d;c++){const u=e[c];if(u.POSITION!==void 0&&(s=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(l);const o=[],a=[],r=[];for(let c=0,d=e.length;c<d;c++){const u=e[c];if(s){const p=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):l.attributes.position;o.push(p)}if(n){const p=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):l.attributes.normal;a.push(p)}if(i){const p=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):l.attributes.color;r.push(p)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(r)]).then(function(c){const d=c[0],u=c[1],p=c[2];return s&&(l.morphAttributes.position=d),n&&(l.morphAttributes.normal=u),i&&(l.morphAttributes.color=p),l.morphTargetsRelative=!0,l})}function ze(l,e){if(l.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)l.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(l.morphTargetInfluences.length===t.length){l.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)l.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Xe(l){let e;const t=l.extensions&&l.extensions[b.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Y(t.attributes):e=l.indices+":"+Y(l.attributes)+":"+l.mode,l.targets!==void 0)for(let s=0,n=l.targets.length;s<n;s++)e+=":"+Y(l.targets[s]);return e}function Y(l){let e="";const t=Object.keys(l).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+l[t[s]]+";";return e}function q(l){switch(l){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function We(l){return l.search(/\.jpe?g($|\?)/i)>0||l.search(/^data\:image\/jpeg/)===0?"image/jpeg":l.search(/\.webp($|\?)/i)>0||l.search(/^data\:image\/webp/)===0?"image/webp":l.search(/\.ktx2($|\?)/i)>0||l.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Ye=new h.Matrix4;class qe{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new _e,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=-1,i=!1,o=-1;if(typeof navigator<"u"){const a=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(a)===!0;const r=a.match(/Version\/(\d+)/);n=s&&r?parseInt(r[1],10):-1,i=a.indexOf("Firefox")>-1,o=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||i&&o<98?this.textureLoader=new h.TextureLoader(this.options.manager):this.textureLoader=new h.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new h.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(o){const a={scene:o[0][n.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:n.asset,parser:s,userData:{}};return j(i,a,n),R(a,n),Promise.all(s._invokeAll(function(r){return r.afterRoot&&r.afterRoot(a)})).then(function(){for(const r of a.scenes)r.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const o=t[n].joints;for(let a=0,r=o.length;a<r;a++)e[o[a]].isBone=!0}for(let n=0,i=e.length;n<i;n++){const o=e[n];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(s[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),i=(o,a)=>{const r=this.associations.get(o);r!=null&&this.associations.set(a,r);for(const[c,d]of o.children.entries())i(d,a.children[c])};return i(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const i=e(t[n]);i&&s.push(i)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(i,o){return s.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[b.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,o){s.load(h.LoaderUtils.resolveURL(t.uri,n.path),i,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(s){const n=t.byteLength||0,i=t.byteOffset||0;return s.slice(i,i+n)})}loadAccessor(e){const t=this,s=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const o=z[n.type],a=U[n.componentType],r=n.normalized===!0,c=new a(n.count*o);return Promise.resolve(new h.BufferAttribute(c,o,r))}const i=[];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(o){const a=o[0],r=z[n.type],c=U[n.componentType],d=c.BYTES_PER_ELEMENT,u=d*r,p=n.byteOffset||0,f=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,_=n.normalized===!0;let y,m;if(f&&f!==u){const g=Math.floor(p/f),M="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+g+":"+n.count;let w=t.cache.get(M);w||(y=new c(a,g*f,n.count*f/d),w=new h.InterleavedBuffer(y,f/d),t.cache.add(M,w)),m=new h.InterleavedBufferAttribute(w,r,p%f/d,_)}else a===null?y=new c(n.count*r):y=new c(a,p,n.count*r),m=new h.BufferAttribute(y,r,_);if(n.sparse!==void 0){const g=z.SCALAR,M=U[n.sparse.indices.componentType],w=n.sparse.indices.byteOffset||0,x=n.sparse.values.byteOffset||0,N=new M(o[1],w,n.sparse.count*g),k=new c(o[2],x,n.sparse.count*r);a!==null&&(m=new h.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let D=0,B=N.length;D<B;D++){const v=N[D];if(m.setX(v,k[D*r]),r>=2&&m.setY(v,k[D*r+1]),r>=3&&m.setZ(v,k[D*r+2]),r>=4&&m.setW(v,k[D*r+3]),r>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=_}return m})}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,o=t.images[i];let a=this.textureLoader;if(o.uri){const r=s.manager.getHandler(o.uri);r!==null&&(a=r)}return this.loadTextureImage(e,i,a)}loadTextureImage(e,t,s){const n=this,i=this.json,o=i.textures[e],a=i.images[t],r=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[r])return this.textureCache[r];const c=this.loadImageSource(t,s).then(function(d){d.flipY=!1,d.name=o.name||a.name||"",d.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(d.name=a.uri);const p=(i.samplers||{})[o.sampler]||{};return d.magFilter=oe[p.magFilter]||h.LinearFilter,d.minFilter=oe[p.minFilter]||h.LinearMipmapLinearFilter,d.wrapS=re[p.wrapS]||h.RepeatWrapping,d.wrapT=re[p.wrapT]||h.RepeatWrapping,d.generateMipmaps=!d.isCompressedTexture&&d.minFilter!==h.NearestFilter&&d.minFilter!==h.LinearFilter,n.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[r]=c,c}loadImageSource(e,t){const s=this,n=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=n.images[e],a=self.URL||self.webkitURL;let r=o.uri||"",c=!1;if(o.bufferView!==void 0)r=s.getDependency("bufferView",o.bufferView).then(function(u){c=!0;const p=new Blob([u],{type:o.mimeType});return r=a.createObjectURL(p),r});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(r).then(function(u){return new Promise(function(p,f){let _=p;t.isImageBitmapLoader===!0&&(_=function(y){const m=new h.Texture(y);m.needsUpdate=!0,p(m)}),t.load(h.LoaderUtils.resolveURL(u,i.path),_,void 0,f)})}).then(function(u){return c===!0&&a.revokeObjectURL(r),R(u,o),u.userData.mimeType=o.mimeType||We(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",r),u});return this.sourceCache[e]=d,d}assignTexture(e,t,s,n){const i=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(o=o.clone(),o.channel=s.texCoord),i.extensions[b.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[b.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const r=i.associations.get(o);o=i.extensions[b.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),i.associations.set(o,r)}}return n!==void 0&&(o.colorSpace=n),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+s.uuid;let r=this.cache.get(a);r||(r=new h.PointsMaterial,h.Material.prototype.copy.call(r,s),r.color.copy(s.color),r.map=s.map,r.sizeAttenuation=!1,this.cache.add(a,r)),s=r}else if(e.isLine){const a="LineBasicMaterial:"+s.uuid;let r=this.cache.get(a);r||(r=new h.LineBasicMaterial,h.Material.prototype.copy.call(r,s),r.color.copy(s.color),r.map=s.map,this.cache.add(a,r)),s=r}if(n||i||o){let a="ClonedMaterial:"+s.uuid+":";n&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let r=this.cache.get(a);r||(r=s.clone(),i&&(r.vertexColors=!0),o&&(r.flatShading=!0),n&&(r.normalScale&&(r.normalScale.y*=-1),r.clearcoatNormalScale&&(r.clearcoatNormalScale.y*=-1)),this.cache.add(a,r),this.associations.set(r,this.associations.get(s))),s=r}e.material=s}getMaterialType(){return h.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,n=this.extensions,i=s.materials[e];let o;const a={},r=i.extensions||{},c=[];if(r[b.KHR_MATERIALS_UNLIT]){const u=n[b.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),c.push(u.extendParams(a,i,t))}else{const u=i.pbrMetallicRoughness||{};if(a.color=new h.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const p=u.baseColorFactor;a.color.setRGB(p[0],p[1],p[2],h.LinearSRGBColorSpace),a.opacity=p[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture,h.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,a)})))}i.doubleSided===!0&&(a.side=h.DoubleSide);const d=i.alphaMode||W.OPAQUE;if(d===W.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,d===W.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&o!==h.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new h.Vector2(1,1),i.normalTexture.scale!==void 0)){const u=i.normalTexture.scale;a.normalScale.set(u,u)}if(i.occlusionTexture!==void 0&&o!==h.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&o!==h.MeshBasicMaterial){const u=i.emissiveFactor;a.emissive=new h.Color().setRGB(u[0],u[1],u[2],h.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&o!==h.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",i.emissiveTexture,h.SRGBColorSpace)),Promise.all(c).then(function(){const u=new o(a);return i.name&&(u.name=i.name),R(u,i),t.associations.set(u,{materials:e}),i.extensions&&j(n,u,i),u})}createUniqueName(e){const t=h.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,n=this.primitiveCache;function i(a){return s[b.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(r){return ae(r,a,t)})}const o=[];for(let a=0,r=e.length;a<r;a++){const c=e[a],d=Xe(c),u=n[d];if(u)o.push(u.promise);else{let p;c.extensions&&c.extensions[b.KHR_DRACO_MESH_COMPRESSION]?p=i(c):p=ae(new h.BufferGeometry,c,t),n[d]={primitive:c,promise:p},o.push(p)}}return Promise.all(o)}loadMesh(e){const t=this,s=this.json,n=this.extensions,i=s.meshes[e],o=i.primitives,a=[];for(let r=0,c=o.length;r<c;r++){const d=o[r].material===void 0?Ee(this.cache):this.getDependency("material",o[r].material);a.push(d)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(r){const c=r.slice(0,r.length-1),d=r[r.length-1],u=[];for(let f=0,_=d.length;f<_;f++){const y=d[f],m=o[f];let g;const M=c[f];if(m.mode===O.TRIANGLES||m.mode===O.TRIANGLE_STRIP||m.mode===O.TRIANGLE_FAN||m.mode===void 0)g=i.isSkinnedMesh===!0?new h.SkinnedMesh(y,M):new h.Mesh(y,M),g.isSkinnedMesh===!0&&g.normalizeSkinWeights(),m.mode===O.TRIANGLE_STRIP?g.geometry=te(g.geometry,h.TriangleStripDrawMode):m.mode===O.TRIANGLE_FAN&&(g.geometry=te(g.geometry,h.TriangleFanDrawMode));else if(m.mode===O.LINES)g=new h.LineSegments(y,M);else if(m.mode===O.LINE_STRIP)g=new h.Line(y,M);else if(m.mode===O.LINE_LOOP)g=new h.LineLoop(y,M);else if(m.mode===O.POINTS)g=new h.Points(y,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(g.geometry.morphAttributes).length>0&&ze(g,i),g.name=t.createUniqueName(i.name||"mesh_"+e),R(g,i),m.extensions&&j(n,g,m),t.assignFinalMaterial(g),u.push(g)}for(let f=0,_=u.length;f<_;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return i.extensions&&j(n,u[0],i),u[0];const p=new h.Group;i.extensions&&j(n,p,i),t.associations.set(p,{meshes:e});for(let f=0,_=u.length;f<_;f++)p.add(u[f]);return p})}loadCamera(e){let t;const s=this.json.cameras[e],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new h.PerspectiveCamera(h.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new h.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),R(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let n=0,i=t.joints.length;n<i;n++)s.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const i=n.pop(),o=n,a=[],r=[];for(let c=0,d=o.length;c<d;c++){const u=o[c];if(u){a.push(u);const p=new h.Matrix4;i!==null&&p.fromArray(i.array,c*16),r.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new h.Skeleton(a,r)})}loadAnimation(e){const t=this.json,s=this,n=t.animations[e],i=n.name?n.name:"animation_"+e,o=[],a=[],r=[],c=[],d=[];for(let u=0,p=n.channels.length;u<p;u++){const f=n.channels[u],_=n.samplers[f.sampler],y=f.target,m=y.node,g=n.parameters!==void 0?n.parameters[_.input]:_.input,M=n.parameters!==void 0?n.parameters[_.output]:_.output;y.node!==void 0&&(o.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",g)),r.push(this.getDependency("accessor",M)),c.push(_),d.push(y))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(r),Promise.all(c),Promise.all(d)]).then(function(u){const p=u[0],f=u[1],_=u[2],y=u[3],m=u[4],g=[];for(let M=0,w=p.length;M<w;M++){const x=p[M],N=f[M],k=_[M],D=y[M],B=m[M];if(x===void 0)continue;x.updateMatrix&&x.updateMatrix();const v=s._createAnimationTracks(x,N,k,D,B);if(v)for(let $=0;$<v.length;$++)g.push(v[$])}return new h.AnimationClip(i,void 0,g)})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(i){const o=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let r=0,c=n.weights.length;r<c;r++)a.morphTargetInfluences[r]=n.weights[r]}),o})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],i=s._loadNodeShallow(e),o=[],a=n.children||[];for(let c=0,d=a.length;c<d;c++)o.push(s.getDependency("node",a[c]));const r=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(o),r]).then(function(c){const d=c[0],u=c[1],p=c[2];p!==null&&d.traverse(function(f){f.isSkinnedMesh&&f.bind(p,Ye)});for(let f=0,_=u.length;f<_;f++)d.add(u[f]);return d})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?n.createUniqueName(i.name):"",a=[],r=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return r&&a.push(r),i.camera!==void 0&&a.push(n.getDependency("camera",i.camera).then(function(c){return n._getNodeRef(n.cameraCache,i.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let d;if(i.isBone===!0?d=new h.Bone:c.length>1?d=new h.Group:c.length===1?d=c[0]:d=new h.Object3D,d!==c[0])for(let u=0,p=c.length;u<p;u++)d.add(c[u]);if(i.name&&(d.userData.name=i.name,d.name=o),R(d,i),i.extensions&&j(s,d,i),i.matrix!==void 0){const u=new h.Matrix4;u.fromArray(i.matrix),d.applyMatrix4(u)}else i.translation!==void 0&&d.position.fromArray(i.translation),i.rotation!==void 0&&d.quaternion.fromArray(i.rotation),i.scale!==void 0&&d.scale.fromArray(i.scale);if(!n.associations.has(d))n.associations.set(d,{});else if(i.mesh!==void 0&&n.meshCache.refs[i.mesh]>1){const u=n.associations.get(d);n.associations.set(d,{...u})}return n.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,i=new h.Group;s.name&&(i.name=n.createUniqueName(s.name)),R(i,s),s.extensions&&j(t,i,s);const o=s.nodes||[],a=[];for(let r=0,c=o.length;r<c;r++)a.push(n.getDependency("node",o[r]));return Promise.all(a).then(function(r){for(let d=0,u=r.length;d<u;d++)i.add(r[d]);const c=d=>{const u=new Map;for(const[p,f]of n.associations)(p instanceof h.Material||p instanceof h.Texture)&&u.set(p,f);return d.traverse(p=>{const f=n.associations.get(p);f!=null&&u.set(p,f)}),u};return n.associations=c(i),i})}_createAnimationTracks(e,t,s,n,i){const o=[],a=e.name?e.name:e.uuid,r=[];I[i.path]===I.weights?e.traverse(function(p){p.morphTargetInfluences&&r.push(p.name?p.name:p.uuid)}):r.push(a);let c;switch(I[i.path]){case I.weights:c=h.NumberKeyframeTrack;break;case I.rotation:c=h.QuaternionKeyframeTrack;break;case I.translation:case I.scale:c=h.VectorKeyframeTrack;break;default:switch(s.itemSize){case 1:c=h.NumberKeyframeTrack;break;case 2:case 3:default:c=h.VectorKeyframeTrack;break}break}const d=n.interpolation!==void 0?Ve[n.interpolation]:h.InterpolateLinear,u=this._getArrayFromAccessor(s);for(let p=0,f=r.length;p<f;p++){const _=new c(r[p]+"."+I[i.path],t.array,u,d);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(_),o.push(_)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=q(t.constructor),n=new Float32Array(t.length);for(let i=0,o=t.length;i<o;i++)n[i]=t[i]*s;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const n=this instanceof h.QuaternionKeyframeTrack?Be:ie;return new n(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Ze(l,e,t){const s=e.attributes,n=new h.Box3;if(s.POSITION!==void 0){const a=t.json.accessors[s.POSITION],r=a.min,c=a.max;if(r!==void 0&&c!==void 0){if(n.set(new h.Vector3(r[0],r[1],r[2]),new h.Vector3(c[0],c[1],c[2])),a.normalized){const d=q(U[a.componentType]);n.min.multiplyScalar(d),n.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const a=new h.Vector3,r=new h.Vector3;for(let c=0,d=i.length;c<d;c++){const u=i[c];if(u.POSITION!==void 0){const p=t.json.accessors[u.POSITION],f=p.min,_=p.max;if(f!==void 0&&_!==void 0){if(r.setX(Math.max(Math.abs(f[0]),Math.abs(_[0]))),r.setY(Math.max(Math.abs(f[1]),Math.abs(_[1]))),r.setZ(Math.max(Math.abs(f[2]),Math.abs(_[2]))),p.normalized){const y=q(U[p.componentType]);r.multiplyScalar(y)}a.max(r)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}l.boundingBox=n;const o=new h.Sphere;n.getCenter(o.center),o.radius=n.min.distanceTo(n.max)/2,l.boundingSphere=o}function ae(l,e,t){const s=e.attributes,n=[];function i(o,a){return t.getDependency("accessor",o).then(function(r){l.setAttribute(a,r)})}for(const o in s){const a=X[o]||o.toLowerCase();a in l.attributes||n.push(i(s[o],a))}if(e.indices!==void 0&&!l.index){const o=t.getDependency("accessor",e.indices).then(function(a){l.setIndex(a)});n.push(o)}return h.ColorManagement.workingColorSpace!==h.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${h.ColorManagement.workingColorSpace}" not supported.`),R(l,e),Ze(l,e,t),Promise.all(n).then(function(){return e.targets!==void 0?Ke(l,e.targets,t):l})}const ce={type:"change"},Z={type:"start"},le={type:"end"},E=new h.Ray,he=new h.Plane,Qe=Math.cos(70*h.MathUtils.DEG2RAD),L=new h.Vector3,P=2*Math.PI,S={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Q=1e-6;class $e extends h.Controls{constructor(e,t=null){super(e,t),this.state=S.NONE,this.target=new h.Vector3,this.cursor=new h.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:h.MOUSE.ROTATE,MIDDLE:h.MOUSE.DOLLY,RIGHT:h.MOUSE.PAN},this.touches={ONE:h.TOUCH.ROTATE,TWO:h.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new h.Vector3,this._lastQuaternion=new h.Quaternion,this._lastTargetPosition=new h.Vector3,this._quat=new h.Quaternion().setFromUnitVectors(e.up,new h.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new h.Spherical,this._sphericalDelta=new h.Spherical,this._scale=1,this._panOffset=new h.Vector3,this._rotateStart=new h.Vector2,this._rotateEnd=new h.Vector2,this._rotateDelta=new h.Vector2,this._panStart=new h.Vector2,this._panEnd=new h.Vector2,this._panDelta=new h.Vector2,this._dollyStart=new h.Vector2,this._dollyEnd=new h.Vector2,this._dollyDelta=new h.Vector2,this._dollyDirection=new h.Vector3,this._mouse=new h.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=He.bind(this),this._onPointerDown=Je.bind(this),this._onPointerUp=et.bind(this),this._onContextMenu=at.bind(this),this._onMouseWheel=nt.bind(this),this._onKeyDown=it.bind(this),this._onTouchStart=ot.bind(this),this._onTouchMove=rt.bind(this),this._onMouseDown=tt.bind(this),this._onMouseMove=st.bind(this),this._interceptControlDown=ct.bind(this),this._interceptControlUp=lt.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(ce),this.update(),this.state=S.NONE}update(e=null){const t=this.object.position;L.copy(t).sub(this.target),L.applyQuaternion(this._quat),this._spherical.setFromVector3(L),this.autoRotate&&this.state===S.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let s=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(s)&&isFinite(n)&&(s<-Math.PI?s+=P:s>Math.PI&&(s-=P),n<-Math.PI?n+=P:n>Math.PI&&(n-=P),s<=n?this._spherical.theta=Math.max(s,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+n)/2?Math.max(s,this._spherical.theta):Math.min(n,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=o!=this._spherical.radius}if(L.setFromSpherical(this._spherical),L.applyQuaternion(this._quatInverse),t.copy(this.target).add(L),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=L.length();o=this._clampDistance(a*this._scale);const r=a-o;this.object.position.addScaledVector(this._dollyDirection,r),this.object.updateMatrixWorld(),i=!!r}else if(this.object.isOrthographicCamera){const a=new h.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=r!==this.object.zoom;const c=new h.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=L.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(E.origin.copy(this.object.position),E.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(E.direction))<Qe?this.object.lookAt(this.target):(he.setFromNormalAndCoplanarPoint(this.object.up,this.target),E.intersectPlane(he,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),i=!0)}return this._scale=1,this._performCursorZoom=!1,i||this._lastPosition.distanceToSquared(this.object.position)>Q||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Q||this._lastTargetPosition.distanceToSquared(this.target)>Q?(this.dispatchEvent(ce),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?P/60*this.autoRotateSpeed*e:P/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){L.setFromMatrixColumn(t,0),L.multiplyScalar(-e),this._panOffset.add(L)}_panUp(e,t){this.screenSpacePanning===!0?L.setFromMatrixColumn(t,1):(L.setFromMatrixColumn(t,0),L.crossVectors(this.object.up,L)),L.multiplyScalar(e),this._panOffset.add(L)}_pan(e,t){const s=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;L.copy(n).sub(this.target);let i=L.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/s.clientHeight,this.object.matrix),this._panUp(2*t*i/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/s.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const s=this.domElement.getBoundingClientRect(),n=e-s.left,i=t-s.top,o=s.width,a=s.height;this._mouse.x=n/o*2-1,this._mouse.y=-(i/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(P*this._rotateDelta.x/t.clientHeight),this._rotateUp(P*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(P*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-P*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(P*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-P*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(s,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(s,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,i=Math.sqrt(s*s+n*n);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const s=this._getSecondPointerPosition(e),n=.5*(e.pageX+s.x),i=.5*(e.pageY+s.y);this._rotateEnd.set(n,i)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(P*this._rotateDelta.x/t.clientHeight),this._rotateUp(P*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(s,n)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,i=Math.sqrt(s*s+n*n);this._dollyEnd.set(0,i),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new h.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,s={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}}function Je(l){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(l.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(l)&&(this._addPointer(l),l.pointerType==="touch"?this._onTouchStart(l):this._onMouseDown(l)))}function He(l){this.enabled!==!1&&(l.pointerType==="touch"?this._onTouchMove(l):this._onMouseMove(l))}function et(l){switch(this._removePointer(l),this._pointers.length){case 0:this.domElement.releasePointerCapture(l.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(le),this.state=S.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function tt(l){let e;switch(l.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case h.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(l),this.state=S.DOLLY;break;case h.MOUSE.ROTATE:if(l.ctrlKey||l.metaKey||l.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(l),this.state=S.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(l),this.state=S.ROTATE}break;case h.MOUSE.PAN:if(l.ctrlKey||l.metaKey||l.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(l),this.state=S.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(l),this.state=S.PAN}break;default:this.state=S.NONE}this.state!==S.NONE&&this.dispatchEvent(Z)}function st(l){switch(this.state){case S.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(l);break;case S.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(l);break;case S.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(l);break}}function nt(l){this.enabled===!1||this.enableZoom===!1||this.state!==S.NONE||(l.preventDefault(),this.dispatchEvent(Z),this._handleMouseWheel(this._customWheelEvent(l)),this.dispatchEvent(le))}function it(l){this.enabled!==!1&&this._handleKeyDown(l)}function ot(l){switch(this._trackPointer(l),this._pointers.length){case 1:switch(this.touches.ONE){case h.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(l),this.state=S.TOUCH_ROTATE;break;case h.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(l),this.state=S.TOUCH_PAN;break;default:this.state=S.NONE}break;case 2:switch(this.touches.TWO){case h.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(l),this.state=S.TOUCH_DOLLY_PAN;break;case h.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(l),this.state=S.TOUCH_DOLLY_ROTATE;break;default:this.state=S.NONE}break;default:this.state=S.NONE}this.state!==S.NONE&&this.dispatchEvent(Z)}function rt(l){switch(this._trackPointer(l),this.state){case S.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(l),this.update();break;case S.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(l),this.update();break;case S.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(l),this.update();break;case S.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(l),this.update();break;default:this.state=S.NONE}}function at(l){this.enabled!==!1&&l.preventDefault()}function ct(l){l.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function lt(l){l.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const ht=((l,e)=>{const t=l.__vccOpts||l;for(const[s,n]of e)t[s]=n;return t})({__name:"ThreeFrame",props:{animation:{type:Boolean,default:!1},useOrbitControls:{type:Boolean,default:!1},useGridHelper:{type:Boolean,default:!1},useAxesHelper:{type:Boolean,default:!1},useDefaultLight:{type:Boolean,default:!1}},emits:["initialized","animate"],setup(l,{emit:e}){const t=e,s=l,n="dom"+T.getCurrentInstance().uid,i=T.useTemplateRef(n);let o=null,a=null,r=null,c=null,d=null;const u=()=>{const y={GLTFLoader:K,THREE:C,VRMExpressionPresetName:F.VRMExpressionPresetName,VRMHumanBoneName:F.VRMHumanBoneName,camera:r,controls:d,renderer:c,scene:a};t("animate",y),o!=null&&(cancelAnimationFrame(o),o=null),s.animation&&(o=requestAnimationFrame(u)),c.render(a,r)},p=()=>{o!=null&&(cancelAnimationFrame(o),o=null),o=requestAnimationFrame(u)},f=()=>{o!=null&&(cancelAnimationFrame(o),o=null)};T.watch(()=>s.animation,y=>{y==!0?p():f()});const _=()=>{const y=i.value,m=y.clientWidth,g=y.clientHeight,M={antialias:!0,alpha:!1};if(C.ColorManagement.enabled=!1,c=new C.WebGLRenderer(M),c.setPixelRatio(window.devicePixelRatio),c.setSize(m,g),c.setClearColor(8372223,1),c.outputColorSpace=C.SRGBColorSpace,y.appendChild(c.domElement),a=new C.Scene,r=new C.PerspectiveCamera(45,m/g,.1,1e3),r.position.set(0,1.25,1),s.useOrbitControls&&(d=new $e(r,y),d.screenSpacePanning=!0,d.target.set(0,1.25,0),d.update()),s.useGridHelper){const x=new C.GridHelper(10,10);a.add(x),x.visible=!0}if(s.useAxesHelper){const x=new C.AxesHelper(5);a.add(x)}if(s.useDefaultLight){const x=new C.DirectionalLight(16777215);x.intensity=3,x.position.set(1,1,1).normalize(),a.add(x);const N=new C.AmbientLight(4210752);a.add(N)}const w={GLTFLoader:K,THREE:C,VRMExpressionPresetName:F.VRMExpressionPresetName,VRMHumanBoneName:F.VRMHumanBoneName,camera:r,controls:d,renderer:c,scene:a};t("initialized",w)};return T.onMounted(async()=>{if(!ee.isWebGL2Available()){const m=ee.getWebGLErrorMessage();console.error(m);return}const y=()=>{const m=i.value,g=m.clientWidth,M=m.clientHeight;c.setPixelRatio(window.devicePixelRatio),c.setSize(g,M),r.aspect=g/M,r.updateProjectionMatrix()};window.addEventListener("resize",y),_()}),(y,m)=>(T.openBlock(),T.createElementBlock("div",{ref:n,class:"box"}))}},[["__scopeId","data-v-8fb60132"]]),ue={__name:"VroidExpression",props:{command:{type:String},name:{type:String},url:{type:String},data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,s=l,n=async o=>{if(!o)return;t("loading",s.name,s.command);const r=await new V().fetchExpression(o);let c=!1;r&&(c=!0),t("loaded",s.name,s.command,c,r)},i=o=>{t("loading",s.name,s.command);let a=!1;o&&(a=!0),t("loaded",s.name,s.command,a,o)};return T.onMounted(async()=>{s.data!=null?i(s.data):n(s.url)}),T.watch(()=>s.data,()=>{s.data!=null&&i(s.data)}),T.watch(()=>s.url,()=>{s.url&&n(s.url)}),(o,a)=>null}},de={__name:"VroidPose",props:{command:{type:String},name:{type:String},url:{type:String},data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,s=l,n=async o=>{if(!o)return;t("loading",s.name,s.command);const r=await new V().fetchPose(o);let c=!1;r&&(c=!0),t("loaded",s.name,s.command,c,r)},i=o=>{t("loading",s.name,s.command);const r=new V().normalizePose(o);let c=!1;r&&(c=!0),t("loaded",s.name,s.command,c,r)};return T.onMounted(async()=>{s.data!=null?i(s.data):n(s.url)}),T.watch(()=>s.data,()=>{s.data!=null&&i(s.data)}),T.watch(()=>s.url,()=>{s.url&&n(s.url)}),(o,a)=>null}},pe={__name:"VroidVrm",props:{url:{type:String},data:{type:[Object,null],default:null},name:{type:String},command:{type:String}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,s=l,n=async a=>{const r=new K;return r.register(c=>new F.VRMLoaderPlugin(c)),await r.loadAsync(a).then(c=>{const d=c.userData.vrm;return F.VRMUtils.rotateVRM0(d),d})},i=async a=>{if(!a)return;t("loading",s.name,s.command);const r=await n(a);let c=!1;r&&(c=!0),t("loaded",s.name,s.command,c,r)},o=a=>{t("loading",s.name,s.command);let r=!1;a&&(r=!0),t("loaded",s.name,s.command,r,a)};return T.onMounted(async()=>{s.data!=null?o(s.data):i(s.url)}),T.watch(()=>s.data,()=>{s.data!=null&&o(s.data)}),T.watch(()=>s.url,()=>{s.url&&i(s.url)}),(a,r)=>null}},fe={__name:"VroidModel",props:{name:{type:String},expression_name:{type:String},expression_url:{type:String},expression_data:{type:[Object,null],default:null},pose_name:{type:String},pose_url:{type:String},pose_data:{type:[Object,null],default:null},vrm_name:{type:String},vrm_url:{type:String},vrm_data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,s=l,n={},i={},o=T.ref(null),a=T.ref(null),r=T.ref(null),c=(u,p)=>{const f=Object.keys(n).length;n[u]=p;const _=Object.keys(n).length;f==0&&_&&t("loading",s.name)},d=(u,p,f,_)=>{const y=Object.keys(n).length;f&&(p=="load_expression"&&(o.value=_),p=="load_pose"&&(a.value=_),p=="load_vrm"&&(r.value=_),i[u]=p),delete n[u];const m=Object.keys(n).length;if(y&&m==0){const g={};for(const w in i){const x=i[w];x=="load_expression"&&(g.expression=o.value),x=="load_pose"&&(g.pose=a.value),x=="load_vrm"&&(g.vrm=r.value)}t("loaded",s.name,g);const M=Object.keys(i);for(const w of M)delete i[w]}};return(u,p)=>(T.openBlock(),T.createElementBlock(T.Fragment,null,[T.createVNode(ue,{command:"load_expression",name:s.expression_name,url:s.expression_url,data:s.expression_data,onLoading:c,onLoaded:d},null,8,["name","url","data"]),T.createVNode(de,{command:"load_pose",name:s.pose_name,url:s.pose_url,data:s.pose_data,onLoading:c,onLoaded:d},null,8,["name","url","data"]),T.createVNode(pe,{command:"load_vrm",name:s.vrm_name,url:s.vrm_url,data:s.vrm_data,onLoading:c,onLoaded:d},null,8,["name","url","data"])],64))}},ut={__name:"VroidControl",props:{model_name:{type:String,required:!0},expression_name:{type:String,default:"expression"},expression_url:{type:String,default:""},expression_data:{type:[Object,null],default:null},pose_name:{type:String,default:"pose"},pose_url:{type:String,default:""},pose_data:{type:[Object,null],default:null},vrm_name:{type:String,default:"vrm"},vrm_url:{type:String,default:""},vrm_data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,s=T.ref(null);s.value=new H;const n=o=>{t("loading",o)},i=(o,a)=>{"vrm"in a&&s.value.setModel(a.vrm),"pose"in a&&(s.value.setPose(a.pose),s.value.updatePose()),"expression"in a&&(s.value.importExpression(a.expression),s.value.updateExpression()),t("loaded",o,s.value)};return(o,a)=>(T.openBlock(),T.createBlock(fe,{name:l.model_name,expression_name:l.expression_name,expression_url:l.expression_url,expression_data:l.expression_data,pose_name:l.pose_name,pose_url:l.pose_url,pose_data:l.pose_data,vrm_name:l.vrm_name,vrm_url:l.vrm_url,vrm_data:l.vrm_data,onLoading:n,onLoaded:i},null,8,["name","expression_name","expression_url","expression_data","pose_name","pose_url","pose_data","vrm_name","vrm_url","vrm_data"]))}};A.ResourceLoader=V,A.ThreeFrame=ht,A.VrmModel=H,A.VroidControl=ut,A.VroidExpression=ue,A.VroidModel=fe,A.VroidPose=de,A.VroidVrm=pe,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(A,M){typeof exports=="object"&&typeof module<"u"?M(exports,require("vue"),require("three"),require("@pixiv/three-vrm")):typeof define=="function"&&define.amd?define(["exports","vue","three","@pixiv/three-vrm"],M):(A=typeof globalThis<"u"?globalThis:A||self,M(A.VueThreeVrm={},A.Vue,A.THREE,A.THREE_VRM))})(this,function(A,M,h,j){"use strict";var J=document.createElement("style");J.textContent=`.box[data-v-81e1dabc]{display:block;width:100%;height:100%}
|
|
2
|
+
/*$vite$:1*/`,document.head.appendChild(J);function me(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>l[t]})}}return e.default=l,Object.freeze(e)}const O=me(h);class V{constructor(){}async fetchJSON(e){const t=await fetch(e);return t.ok?await t.json():null}normalizePose(e){return e==null?null:"pose"in e?e.pose:e}async fetchPose(e){const t=await this.fetchJSON(e);return this.normalizePose(t)}async fetchExpression(e){const t=await this.fetchJSON(e);return t==null?null:"expressions"in t?t.expressions:t}}class H{constructor(){this.vrm=null}get scene(){return this.vrm?this.vrm.scene:null}setModel(e){this.vrm=e}setPosition(e){this.vrm.scene.position.x=e.x,this.vrm.scene.position.y=e.y,this.vrm.scene.position.z=e.z}getPosition(){return{x:this.vrm.scene.position.x,y:this.vrm.scene.position.y,z:this.vrm.scene.position.z}}setPose(e){this.vrm&&this.vrm.humanoid.setNormalizedPose(e)}getPose(){return this.vrm?this.vrm.humanoid.getNormalizedPose():null}updatePose(){this.vrm&&this.vrm.humanoid.update()}resetPose(){this.vrm&&this.vrm.humanoid.resetNormalizedPose()}getBoneNode(e){return this.vrm?this.vrm.humanoid.getNormalizedBoneNode(e):null}isValid(){return!!this.vrm}getBoneRotate(e){const t=this.getBoneNode(e);return t?{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z}:null}setBoneRotate(e,t,s,n){const i=this.getBoneNode(e);i&&(i.rotation.x=t,i.rotation.y=s,i.rotation.z=n)}getBonePosition(e){const t=this.getBoneNode(e);return t?{x:t.position.x,y:t.position.y,z:t.position.z}:null}setBonePosition(e,t,s,n){const i=this.getBoneNode(e);i&&(i.position.x=t,i.position.y=s,i.position.z=n)}getMetaVersion(){return this.vrm?this.vrm.meta.metaVersion:null}setExpression(e,t){this.vrm&&this.vrm.expressionManager.setValue(e,t)}getExpression(e){return this.vrm?this.vrm.expressionManager.getValue(e):null}updateExpression(){return this.vrm?this.vrm.expressionManager.update():null}resetExpression(){return this.vrm?this.vrm.expressionManager.resetValues():null}getExpressionNames(){if(this.vrm){let e=[];for(const t in this.vrm.expressionManager.expressionMap)e.push(t);return e}return null}importExpression(e){if(this.vrm)for(const t in e)this.vrm.expressionManager.setValue(t,e[t])}exportExpression(){if(this.vrm){let e={};const t=this.getExpressionNames();for(const s in t)e[s]=this.getExpression(s);return e}return null}}class ee{static isWebGL2Available(){try{const e=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&e.getContext("webgl2"))}catch{return!1}}static isColorSpaceAvailable(e){try{const t=document.createElement("canvas"),s=window.WebGL2RenderingContext&&t.getContext("webgl2");return s.drawingBufferColorSpace=e,s.drawingBufferColorSpace===e}catch{return!1}}static getWebGL2ErrorMessage(){return this._getErrorMessage(2)}static _getErrorMessage(e){const t={1:"WebGL",2:"WebGL 2"},s={1:window.WebGLRenderingContext,2:window.WebGL2RenderingContext};let n='Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';const i=document.createElement("div");return i.id="webglmessage",i.style.fontFamily="monospace",i.style.fontSize="13px",i.style.fontWeight="normal",i.style.textAlign="center",i.style.background="#fff",i.style.color="#000",i.style.padding="1.5em",i.style.width="400px",i.style.margin="5em auto 0",s[e]?n=n.replace("$0","graphics card"):n=n.replace("$0","browser"),n=n.replace("$1",t[e]),i.innerHTML=n,i}static isWebGLAvailable(){console.warn("isWebGLAvailable() has been deprecated and will be removed in r178. Use isWebGL2Available() instead.");try{const e=document.createElement("canvas");return!!(window.WebGLRenderingContext&&(e.getContext("webgl")||e.getContext("experimental-webgl")))}catch{return!1}}static getWebGLErrorMessage(){return console.warn("getWebGLErrorMessage() has been deprecated and will be removed in r178. Use getWebGL2ErrorMessage() instead."),this._getErrorMessage(1)}}function te(l,e){if(e===h.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(e===h.TriangleFanDrawMode||e===h.TriangleStripDrawMode){let t=l.getIndex();if(t===null){const o=[],a=l.getAttribute("position");if(a!==void 0){for(let r=0;r<a.count;r++)o.push(r);l.setIndex(o),t=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const s=t.count-2,n=[];if(e===h.TriangleFanDrawMode)for(let o=1;o<=s;o++)n.push(t.getX(0)),n.push(t.getX(o)),n.push(t.getX(o+1));else for(let o=0;o<s;o++)o%2===0?(n.push(t.getX(o)),n.push(t.getX(o+1)),n.push(t.getX(o+2))):(n.push(t.getX(o+2)),n.push(t.getX(o+1)),n.push(t.getX(o)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=l.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),l}class K extends h.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new be(t)}),this.register(function(t){return new Me(t)}),this.register(function(t){return new Ce(t)}),this.register(function(t){return new De(t)}),this.register(function(t){return new Re(t)}),this.register(function(t){return new Se(t)}),this.register(function(t){return new we(t)}),this.register(function(t){return new Le(t)}),this.register(function(t){return new Ae(t)}),this.register(function(t){return new xe(t)}),this.register(function(t){return new Pe(t)}),this.register(function(t){return new Te(t)}),this.register(function(t){return new Ne(t)}),this.register(function(t){return new Oe(t)}),this.register(function(t){return new _e(t)}),this.register(function(t){return new Ie(t)}),this.register(function(t){return new ke(t)})}load(e,t,s,n){const i=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=h.LoaderUtils.extractUrlBase(e);o=h.LoaderUtils.resolveURL(c,this.path)}else o=h.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){n?n(c):console.error(c),i.manager.itemError(e),i.manager.itemEnd(e)},r=new h.FileLoader(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,function(c){try{i.parse(c,o,function(d){t(d),i.manager.itemEnd(e)},a)}catch(d){a(d)}},s,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,n){let i;const o={},a={},r=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(r.decode(new Uint8Array(e,0,4))===se){try{o[b.KHR_BINARY_GLTF]=new ve(e)}catch(u){n&&n(u);return}i=JSON.parse(o[b.KHR_BINARY_GLTF].content)}else i=JSON.parse(r.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new qe(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d<this.pluginCallbacks.length;d++){const u=this.pluginCallbacks[d](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,o[u.name]=!0}if(i.extensionsUsed)for(let d=0;d<i.extensionsUsed.length;++d){const u=i.extensionsUsed[d],p=i.extensionsRequired||[];switch(u){case b.KHR_MATERIALS_UNLIT:o[u]=new ye;break;case b.KHR_DRACO_MESH_COMPRESSION:o[u]=new Fe(i,this.dracoLoader);break;case b.KHR_TEXTURE_TRANSFORM:o[u]=new je;break;case b.KHR_MESH_QUANTIZATION:o[u]=new Ue;break;default:p.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,i){s.parse(e,t,n,i)})}}function ge(){let l={};return{get:function(e){return l[e]},add:function(e,t){l[e]=t},remove:function(e){delete l[e]},removeAll:function(){l={}}}}const b={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class _e{constructor(e){this.parser=e,this.name=b.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const i=t[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let n=t.cache.get(s);if(n)return n;const i=t.json,r=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let c;const d=new h.Color(16777215);r.color!==void 0&&d.setRGB(r.color[0],r.color[1],r.color[2],h.LinearSRGBColorSpace);const u=r.range!==void 0?r.range:0;switch(r.type){case"directional":c=new h.DirectionalLight(d),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new h.PointLight(d),c.distance=u;break;case"spot":c=new h.SpotLight(d),c.distance=u,r.spot=r.spot||{},r.spot.innerConeAngle=r.spot.innerConeAngle!==void 0?r.spot.innerConeAngle:0,r.spot.outerConeAngle=r.spot.outerConeAngle!==void 0?r.spot.outerConeAngle:Math.PI/4,c.angle=r.spot.outerConeAngle,c.penumbra=1-r.spot.innerConeAngle/r.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+r.type)}return c.position.set(0,0,0),R(c,r),r.intensity!==void 0&&(c.intensity=r.intensity),c.name=t.createUniqueName(r.name||"light_"+e),n=Promise.resolve(c),t.cache.add(s,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,i=s.json.nodes[e],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(r){return s._getNodeRef(t.cache,a,r)})}}class ye{constructor(){this.name=b.KHR_MATERIALS_UNLIT}getMaterialType(){return h.MeshBasicMaterial}extendParams(e,t,s){const n=[];e.color=new h.Color(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const o=i.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],h.LinearSRGBColorSpace),e.opacity=o[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",i.baseColorTexture,h.SRGBColorSpace))}return Promise.all(n)}}class xe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(t.emissiveIntensity=i),Promise.resolve()}}class be{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(i.push(s.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new h.Vector2(a,a)}return Promise.all(i)}}class Me{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_DISPERSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class Te{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(i)}}class Se{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new h.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=n.extensions[this.name];if(o.sheenColorFactor!==void 0){const a=o.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],h.LinearSRGBColorSpace)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&i.push(s.assignTexture(t,"sheenColorMap",o.sheenColorTexture,h.SRGBColorSpace)),o.sheenRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class we{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&i.push(s.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(i)}}class Le{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&i.push(s.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return t.attenuationColor=new h.Color().setRGB(a[0],a[1],a[2],h.LinearSRGBColorSpace),Promise.all(i)}}class Ae{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class Pe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&i.push(s.assignTexture(t,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return t.specularColor=new h.Color().setRGB(a[0],a[1],a[2],h.LinearSRGBColorSpace),o.specularColorTexture!==void 0&&i.push(s.assignTexture(t,"specularColorMap",o.specularColorTexture,h.SRGBColorSpace)),Promise.all(i)}}class Oe{constructor(e){this.parser=e,this.name=b.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&i.push(s.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(i)}}class Ne{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&i.push(s.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(i)}}class Ce{constructor(e){this.parser=e,this.name=b.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,o)}}class De{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],a=n.images[o.source];let r=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(r=c)}return s.loadTextureImage(e,o.source,r)}}class Re{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],a=n.images[o.source];let r=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(r=c)}return s.loadTextureImage(e,o.source,r)}}class Ie{constructor(e){this.name=b.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(a){const r=n.byteOffset||0,c=n.byteLength||0,d=n.count,u=n.byteStride,p=new Uint8Array(a,r,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(d,u,p,n.mode,n.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(d*u);return o.decodeGltfBuffer(new Uint8Array(f),d,u,p,n.mode,n.filter),f})})}else return null}}class ke{constructor(e){this.name=b.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=t.meshes[s.mesh];for(const c of n.primitives)if(c.mode!==N.TRIANGLES&&c.mode!==N.TRIANGLE_STRIP&&c.mode!==N.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=s.extensions[this.name].attributes,a=[],r={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(d=>(r[c]=d,r[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const d=c.pop(),u=d.isGroup?d.children:[d],p=c[0].count,f=[];for(const g of u){const _=new h.Matrix4,m=new h.Vector3,y=new h.Quaternion,T=new h.Vector3(1,1,1),w=new h.InstancedMesh(g.geometry,g.material,p);for(let x=0;x<p;x++)r.TRANSLATION&&m.fromBufferAttribute(r.TRANSLATION,x),r.ROTATION&&y.fromBufferAttribute(r.ROTATION,x),r.SCALE&&T.fromBufferAttribute(r.SCALE,x),w.setMatrixAt(x,_.compose(m,y,T));for(const x in r)if(x==="_COLOR_0"){const C=r[x];w.instanceColor=new h.InstancedBufferAttribute(C.array,C.itemSize,C.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&g.geometry.setAttribute(x,r[x]);h.Object3D.prototype.copy.call(w,g),this.parser.assignFinalMaterial(w),f.push(w)}return d.isGroup?(d.clear(),d.add(...f),d):f[0]}))}}const se="glTF",G=12,ne={JSON:1313821514,BIN:5130562};class ve{constructor(e){this.name=b.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,G),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==se)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-G,i=new DataView(e,G);let o=0;for(;o<n;){const a=i.getUint32(o,!0);o+=4;const r=i.getUint32(o,!0);if(o+=4,r===ne.JSON){const c=new Uint8Array(e,G+o,a);this.content=s.decode(c)}else if(r===ne.BIN){const c=G+o;this.body=e.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Fe{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=b.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,n=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},r={},c={};for(const d in o){const u=X[d]||d.toLowerCase();a[u]=o[d]}for(const d in e.attributes){const u=X[d]||d.toLowerCase();if(o[d]!==void 0){const p=s.accessors[e.attributes[d]],f=U[p.componentType];c[u]=f.name,r[u]=p.normalized===!0}}return t.getDependency("bufferView",i).then(function(d){return new Promise(function(u,p){n.decodeDracoFile(d,function(f){for(const g in f.attributes){const _=f.attributes[g],m=r[g];m!==void 0&&(_.normalized=m)}u(f)},a,c,h.LinearSRGBColorSpace,p)})})}}class je{constructor(){this.name=b.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Ue{constructor(){this.name=b.KHR_MESH_QUANTIZATION}}class ie extends h.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,i=e*n*3+n;for(let o=0;o!==n;o++)t[o]=s[i+o];return t}interpolate_(e,t,s,n){const i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,r=a*2,c=a*3,d=n-t,u=(s-t)/d,p=u*u,f=p*u,g=e*c,_=g-c,m=-2*f+3*p,y=f-p,T=1-m,w=y-p+u;for(let x=0;x!==a;x++){const C=o[_+x+a],k=o[_+x+r]*d,D=o[g+x+a],B=o[g+x]*d;i[x]=T*C+w*k+m*D+y*B}return i}}const Ge=new h.Quaternion;class Be extends ie{interpolate_(e,t,s,n){const i=super.interpolate_(e,t,s,n);return Ge.fromArray(i).normalize().toArray(i),i}}const N={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},U={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},oe={9728:h.NearestFilter,9729:h.LinearFilter,9984:h.NearestMipmapNearestFilter,9985:h.LinearMipmapNearestFilter,9986:h.NearestMipmapLinearFilter,9987:h.LinearMipmapLinearFilter},re={33071:h.ClampToEdgeWrapping,33648:h.MirroredRepeatWrapping,10497:h.RepeatWrapping},z={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},X={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},I={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Ve={CUBICSPLINE:void 0,LINEAR:h.InterpolateLinear,STEP:h.InterpolateDiscrete},W={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Ee(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new h.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:h.FrontSide})),l.DefaultMaterial}function F(l,e,t){for(const s in t.extensions)l[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function R(l,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(l.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Ke(l,e,t){let s=!1,n=!1,i=!1;for(let c=0,d=e.length;c<d;c++){const u=e[c];if(u.POSITION!==void 0&&(s=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(l);const o=[],a=[],r=[];for(let c=0,d=e.length;c<d;c++){const u=e[c];if(s){const p=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):l.attributes.position;o.push(p)}if(n){const p=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):l.attributes.normal;a.push(p)}if(i){const p=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):l.attributes.color;r.push(p)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(r)]).then(function(c){const d=c[0],u=c[1],p=c[2];return s&&(l.morphAttributes.position=d),n&&(l.morphAttributes.normal=u),i&&(l.morphAttributes.color=p),l.morphTargetsRelative=!0,l})}function ze(l,e){if(l.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)l.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(l.morphTargetInfluences.length===t.length){l.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)l.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Xe(l){let e;const t=l.extensions&&l.extensions[b.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Y(t.attributes):e=l.indices+":"+Y(l.attributes)+":"+l.mode,l.targets!==void 0)for(let s=0,n=l.targets.length;s<n;s++)e+=":"+Y(l.targets[s]);return e}function Y(l){let e="";const t=Object.keys(l).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+l[t[s]]+";";return e}function q(l){switch(l){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function We(l){return l.search(/\.jpe?g($|\?)/i)>0||l.search(/^data\:image\/jpeg/)===0?"image/jpeg":l.search(/\.webp($|\?)/i)>0||l.search(/^data\:image\/webp/)===0?"image/webp":l.search(/\.ktx2($|\?)/i)>0||l.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Ye=new h.Matrix4;class qe{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new ge,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=-1,i=!1,o=-1;if(typeof navigator<"u"){const a=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(a)===!0;const r=a.match(/Version\/(\d+)/);n=s&&r?parseInt(r[1],10):-1,i=a.indexOf("Firefox")>-1,o=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||i&&o<98?this.textureLoader=new h.TextureLoader(this.options.manager):this.textureLoader=new h.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new h.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(o){const a={scene:o[0][n.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:n.asset,parser:s,userData:{}};return F(i,a,n),R(a,n),Promise.all(s._invokeAll(function(r){return r.afterRoot&&r.afterRoot(a)})).then(function(){for(const r of a.scenes)r.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const o=t[n].joints;for(let a=0,r=o.length;a<r;a++)e[o[a]].isBone=!0}for(let n=0,i=e.length;n<i;n++){const o=e[n];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(s[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),i=(o,a)=>{const r=this.associations.get(o);r!=null&&this.associations.set(a,r);for(const[c,d]of o.children.entries())i(d,a.children[c])};return i(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const i=e(t[n]);i&&s.push(i)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(i,o){return s.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[b.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,o){s.load(h.LoaderUtils.resolveURL(t.uri,n.path),i,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(s){const n=t.byteLength||0,i=t.byteOffset||0;return s.slice(i,i+n)})}loadAccessor(e){const t=this,s=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const o=z[n.type],a=U[n.componentType],r=n.normalized===!0,c=new a(n.count*o);return Promise.resolve(new h.BufferAttribute(c,o,r))}const i=[];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(o){const a=o[0],r=z[n.type],c=U[n.componentType],d=c.BYTES_PER_ELEMENT,u=d*r,p=n.byteOffset||0,f=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,g=n.normalized===!0;let _,m;if(f&&f!==u){const y=Math.floor(p/f),T="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+y+":"+n.count;let w=t.cache.get(T);w||(_=new c(a,y*f,n.count*f/d),w=new h.InterleavedBuffer(_,f/d),t.cache.add(T,w)),m=new h.InterleavedBufferAttribute(w,r,p%f/d,g)}else a===null?_=new c(n.count*r):_=new c(a,p,n.count*r),m=new h.BufferAttribute(_,r,g);if(n.sparse!==void 0){const y=z.SCALAR,T=U[n.sparse.indices.componentType],w=n.sparse.indices.byteOffset||0,x=n.sparse.values.byteOffset||0,C=new T(o[1],w,n.sparse.count*y),k=new c(o[2],x,n.sparse.count*r);a!==null&&(m=new h.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let D=0,B=C.length;D<B;D++){const v=C[D];if(m.setX(v,k[D*r]),r>=2&&m.setY(v,k[D*r+1]),r>=3&&m.setZ(v,k[D*r+2]),r>=4&&m.setW(v,k[D*r+3]),r>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=g}return m})}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,o=t.images[i];let a=this.textureLoader;if(o.uri){const r=s.manager.getHandler(o.uri);r!==null&&(a=r)}return this.loadTextureImage(e,i,a)}loadTextureImage(e,t,s){const n=this,i=this.json,o=i.textures[e],a=i.images[t],r=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[r])return this.textureCache[r];const c=this.loadImageSource(t,s).then(function(d){d.flipY=!1,d.name=o.name||a.name||"",d.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(d.name=a.uri);const p=(i.samplers||{})[o.sampler]||{};return d.magFilter=oe[p.magFilter]||h.LinearFilter,d.minFilter=oe[p.minFilter]||h.LinearMipmapLinearFilter,d.wrapS=re[p.wrapS]||h.RepeatWrapping,d.wrapT=re[p.wrapT]||h.RepeatWrapping,d.generateMipmaps=!d.isCompressedTexture&&d.minFilter!==h.NearestFilter&&d.minFilter!==h.LinearFilter,n.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[r]=c,c}loadImageSource(e,t){const s=this,n=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=n.images[e],a=self.URL||self.webkitURL;let r=o.uri||"",c=!1;if(o.bufferView!==void 0)r=s.getDependency("bufferView",o.bufferView).then(function(u){c=!0;const p=new Blob([u],{type:o.mimeType});return r=a.createObjectURL(p),r});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(r).then(function(u){return new Promise(function(p,f){let g=p;t.isImageBitmapLoader===!0&&(g=function(_){const m=new h.Texture(_);m.needsUpdate=!0,p(m)}),t.load(h.LoaderUtils.resolveURL(u,i.path),g,void 0,f)})}).then(function(u){return c===!0&&a.revokeObjectURL(r),R(u,o),u.userData.mimeType=o.mimeType||We(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",r),u});return this.sourceCache[e]=d,d}assignTexture(e,t,s,n){const i=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(o=o.clone(),o.channel=s.texCoord),i.extensions[b.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[b.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const r=i.associations.get(o);o=i.extensions[b.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),i.associations.set(o,r)}}return n!==void 0&&(o.colorSpace=n),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+s.uuid;let r=this.cache.get(a);r||(r=new h.PointsMaterial,h.Material.prototype.copy.call(r,s),r.color.copy(s.color),r.map=s.map,r.sizeAttenuation=!1,this.cache.add(a,r)),s=r}else if(e.isLine){const a="LineBasicMaterial:"+s.uuid;let r=this.cache.get(a);r||(r=new h.LineBasicMaterial,h.Material.prototype.copy.call(r,s),r.color.copy(s.color),r.map=s.map,this.cache.add(a,r)),s=r}if(n||i||o){let a="ClonedMaterial:"+s.uuid+":";n&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let r=this.cache.get(a);r||(r=s.clone(),i&&(r.vertexColors=!0),o&&(r.flatShading=!0),n&&(r.normalScale&&(r.normalScale.y*=-1),r.clearcoatNormalScale&&(r.clearcoatNormalScale.y*=-1)),this.cache.add(a,r),this.associations.set(r,this.associations.get(s))),s=r}e.material=s}getMaterialType(){return h.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,n=this.extensions,i=s.materials[e];let o;const a={},r=i.extensions||{},c=[];if(r[b.KHR_MATERIALS_UNLIT]){const u=n[b.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),c.push(u.extendParams(a,i,t))}else{const u=i.pbrMetallicRoughness||{};if(a.color=new h.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const p=u.baseColorFactor;a.color.setRGB(p[0],p[1],p[2],h.LinearSRGBColorSpace),a.opacity=p[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture,h.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,a)})))}i.doubleSided===!0&&(a.side=h.DoubleSide);const d=i.alphaMode||W.OPAQUE;if(d===W.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,d===W.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&o!==h.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new h.Vector2(1,1),i.normalTexture.scale!==void 0)){const u=i.normalTexture.scale;a.normalScale.set(u,u)}if(i.occlusionTexture!==void 0&&o!==h.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&o!==h.MeshBasicMaterial){const u=i.emissiveFactor;a.emissive=new h.Color().setRGB(u[0],u[1],u[2],h.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&o!==h.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",i.emissiveTexture,h.SRGBColorSpace)),Promise.all(c).then(function(){const u=new o(a);return i.name&&(u.name=i.name),R(u,i),t.associations.set(u,{materials:e}),i.extensions&&F(n,u,i),u})}createUniqueName(e){const t=h.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,n=this.primitiveCache;function i(a){return s[b.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(r){return ae(r,a,t)})}const o=[];for(let a=0,r=e.length;a<r;a++){const c=e[a],d=Xe(c),u=n[d];if(u)o.push(u.promise);else{let p;c.extensions&&c.extensions[b.KHR_DRACO_MESH_COMPRESSION]?p=i(c):p=ae(new h.BufferGeometry,c,t),n[d]={primitive:c,promise:p},o.push(p)}}return Promise.all(o)}loadMesh(e){const t=this,s=this.json,n=this.extensions,i=s.meshes[e],o=i.primitives,a=[];for(let r=0,c=o.length;r<c;r++){const d=o[r].material===void 0?Ee(this.cache):this.getDependency("material",o[r].material);a.push(d)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(r){const c=r.slice(0,r.length-1),d=r[r.length-1],u=[];for(let f=0,g=d.length;f<g;f++){const _=d[f],m=o[f];let y;const T=c[f];if(m.mode===N.TRIANGLES||m.mode===N.TRIANGLE_STRIP||m.mode===N.TRIANGLE_FAN||m.mode===void 0)y=i.isSkinnedMesh===!0?new h.SkinnedMesh(_,T):new h.Mesh(_,T),y.isSkinnedMesh===!0&&y.normalizeSkinWeights(),m.mode===N.TRIANGLE_STRIP?y.geometry=te(y.geometry,h.TriangleStripDrawMode):m.mode===N.TRIANGLE_FAN&&(y.geometry=te(y.geometry,h.TriangleFanDrawMode));else if(m.mode===N.LINES)y=new h.LineSegments(_,T);else if(m.mode===N.LINE_STRIP)y=new h.Line(_,T);else if(m.mode===N.LINE_LOOP)y=new h.LineLoop(_,T);else if(m.mode===N.POINTS)y=new h.Points(_,T);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(y.geometry.morphAttributes).length>0&&ze(y,i),y.name=t.createUniqueName(i.name||"mesh_"+e),R(y,i),m.extensions&&F(n,y,m),t.assignFinalMaterial(y),u.push(y)}for(let f=0,g=u.length;f<g;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return i.extensions&&F(n,u[0],i),u[0];const p=new h.Group;i.extensions&&F(n,p,i),t.associations.set(p,{meshes:e});for(let f=0,g=u.length;f<g;f++)p.add(u[f]);return p})}loadCamera(e){let t;const s=this.json.cameras[e],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new h.PerspectiveCamera(h.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new h.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),R(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let n=0,i=t.joints.length;n<i;n++)s.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const i=n.pop(),o=n,a=[],r=[];for(let c=0,d=o.length;c<d;c++){const u=o[c];if(u){a.push(u);const p=new h.Matrix4;i!==null&&p.fromArray(i.array,c*16),r.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new h.Skeleton(a,r)})}loadAnimation(e){const t=this.json,s=this,n=t.animations[e],i=n.name?n.name:"animation_"+e,o=[],a=[],r=[],c=[],d=[];for(let u=0,p=n.channels.length;u<p;u++){const f=n.channels[u],g=n.samplers[f.sampler],_=f.target,m=_.node,y=n.parameters!==void 0?n.parameters[g.input]:g.input,T=n.parameters!==void 0?n.parameters[g.output]:g.output;_.node!==void 0&&(o.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",y)),r.push(this.getDependency("accessor",T)),c.push(g),d.push(_))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(r),Promise.all(c),Promise.all(d)]).then(function(u){const p=u[0],f=u[1],g=u[2],_=u[3],m=u[4],y=[];for(let T=0,w=p.length;T<w;T++){const x=p[T],C=f[T],k=g[T],D=_[T],B=m[T];if(x===void 0)continue;x.updateMatrix&&x.updateMatrix();const v=s._createAnimationTracks(x,C,k,D,B);if(v)for(let $=0;$<v.length;$++)y.push(v[$])}return new h.AnimationClip(i,void 0,y)})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(i){const o=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let r=0,c=n.weights.length;r<c;r++)a.morphTargetInfluences[r]=n.weights[r]}),o})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],i=s._loadNodeShallow(e),o=[],a=n.children||[];for(let c=0,d=a.length;c<d;c++)o.push(s.getDependency("node",a[c]));const r=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(o),r]).then(function(c){const d=c[0],u=c[1],p=c[2];p!==null&&d.traverse(function(f){f.isSkinnedMesh&&f.bind(p,Ye)});for(let f=0,g=u.length;f<g;f++)d.add(u[f]);return d})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?n.createUniqueName(i.name):"",a=[],r=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return r&&a.push(r),i.camera!==void 0&&a.push(n.getDependency("camera",i.camera).then(function(c){return n._getNodeRef(n.cameraCache,i.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let d;if(i.isBone===!0?d=new h.Bone:c.length>1?d=new h.Group:c.length===1?d=c[0]:d=new h.Object3D,d!==c[0])for(let u=0,p=c.length;u<p;u++)d.add(c[u]);if(i.name&&(d.userData.name=i.name,d.name=o),R(d,i),i.extensions&&F(s,d,i),i.matrix!==void 0){const u=new h.Matrix4;u.fromArray(i.matrix),d.applyMatrix4(u)}else i.translation!==void 0&&d.position.fromArray(i.translation),i.rotation!==void 0&&d.quaternion.fromArray(i.rotation),i.scale!==void 0&&d.scale.fromArray(i.scale);if(!n.associations.has(d))n.associations.set(d,{});else if(i.mesh!==void 0&&n.meshCache.refs[i.mesh]>1){const u=n.associations.get(d);n.associations.set(d,{...u})}return n.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,i=new h.Group;s.name&&(i.name=n.createUniqueName(s.name)),R(i,s),s.extensions&&F(t,i,s);const o=s.nodes||[],a=[];for(let r=0,c=o.length;r<c;r++)a.push(n.getDependency("node",o[r]));return Promise.all(a).then(function(r){for(let d=0,u=r.length;d<u;d++)i.add(r[d]);const c=d=>{const u=new Map;for(const[p,f]of n.associations)(p instanceof h.Material||p instanceof h.Texture)&&u.set(p,f);return d.traverse(p=>{const f=n.associations.get(p);f!=null&&u.set(p,f)}),u};return n.associations=c(i),i})}_createAnimationTracks(e,t,s,n,i){const o=[],a=e.name?e.name:e.uuid,r=[];I[i.path]===I.weights?e.traverse(function(p){p.morphTargetInfluences&&r.push(p.name?p.name:p.uuid)}):r.push(a);let c;switch(I[i.path]){case I.weights:c=h.NumberKeyframeTrack;break;case I.rotation:c=h.QuaternionKeyframeTrack;break;case I.translation:case I.scale:c=h.VectorKeyframeTrack;break;default:switch(s.itemSize){case 1:c=h.NumberKeyframeTrack;break;case 2:case 3:default:c=h.VectorKeyframeTrack;break}break}const d=n.interpolation!==void 0?Ve[n.interpolation]:h.InterpolateLinear,u=this._getArrayFromAccessor(s);for(let p=0,f=r.length;p<f;p++){const g=new c(r[p]+"."+I[i.path],t.array,u,d);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),o.push(g)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=q(t.constructor),n=new Float32Array(t.length);for(let i=0,o=t.length;i<o;i++)n[i]=t[i]*s;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const n=this instanceof h.QuaternionKeyframeTrack?Be:ie;return new n(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Ze(l,e,t){const s=e.attributes,n=new h.Box3;if(s.POSITION!==void 0){const a=t.json.accessors[s.POSITION],r=a.min,c=a.max;if(r!==void 0&&c!==void 0){if(n.set(new h.Vector3(r[0],r[1],r[2]),new h.Vector3(c[0],c[1],c[2])),a.normalized){const d=q(U[a.componentType]);n.min.multiplyScalar(d),n.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const a=new h.Vector3,r=new h.Vector3;for(let c=0,d=i.length;c<d;c++){const u=i[c];if(u.POSITION!==void 0){const p=t.json.accessors[u.POSITION],f=p.min,g=p.max;if(f!==void 0&&g!==void 0){if(r.setX(Math.max(Math.abs(f[0]),Math.abs(g[0]))),r.setY(Math.max(Math.abs(f[1]),Math.abs(g[1]))),r.setZ(Math.max(Math.abs(f[2]),Math.abs(g[2]))),p.normalized){const _=q(U[p.componentType]);r.multiplyScalar(_)}a.max(r)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}l.boundingBox=n;const o=new h.Sphere;n.getCenter(o.center),o.radius=n.min.distanceTo(n.max)/2,l.boundingSphere=o}function ae(l,e,t){const s=e.attributes,n=[];function i(o,a){return t.getDependency("accessor",o).then(function(r){l.setAttribute(a,r)})}for(const o in s){const a=X[o]||o.toLowerCase();a in l.attributes||n.push(i(s[o],a))}if(e.indices!==void 0&&!l.index){const o=t.getDependency("accessor",e.indices).then(function(a){l.setIndex(a)});n.push(o)}return h.ColorManagement.workingColorSpace!==h.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${h.ColorManagement.workingColorSpace}" not supported.`),R(l,e),Ze(l,e,t),Promise.all(n).then(function(){return e.targets!==void 0?Ke(l,e.targets,t):l})}const ce={type:"change"},Z={type:"start"},le={type:"end"},E=new h.Ray,he=new h.Plane,Qe=Math.cos(70*h.MathUtils.DEG2RAD),L=new h.Vector3,P=2*Math.PI,S={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Q=1e-6;class $e extends h.Controls{constructor(e,t=null){super(e,t),this.state=S.NONE,this.target=new h.Vector3,this.cursor=new h.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:h.MOUSE.ROTATE,MIDDLE:h.MOUSE.DOLLY,RIGHT:h.MOUSE.PAN},this.touches={ONE:h.TOUCH.ROTATE,TWO:h.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new h.Vector3,this._lastQuaternion=new h.Quaternion,this._lastTargetPosition=new h.Vector3,this._quat=new h.Quaternion().setFromUnitVectors(e.up,new h.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new h.Spherical,this._sphericalDelta=new h.Spherical,this._scale=1,this._panOffset=new h.Vector3,this._rotateStart=new h.Vector2,this._rotateEnd=new h.Vector2,this._rotateDelta=new h.Vector2,this._panStart=new h.Vector2,this._panEnd=new h.Vector2,this._panDelta=new h.Vector2,this._dollyStart=new h.Vector2,this._dollyEnd=new h.Vector2,this._dollyDelta=new h.Vector2,this._dollyDirection=new h.Vector3,this._mouse=new h.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=He.bind(this),this._onPointerDown=Je.bind(this),this._onPointerUp=et.bind(this),this._onContextMenu=at.bind(this),this._onMouseWheel=nt.bind(this),this._onKeyDown=it.bind(this),this._onTouchStart=ot.bind(this),this._onTouchMove=rt.bind(this),this._onMouseDown=tt.bind(this),this._onMouseMove=st.bind(this),this._interceptControlDown=ct.bind(this),this._interceptControlUp=lt.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(ce),this.update(),this.state=S.NONE}update(e=null){const t=this.object.position;L.copy(t).sub(this.target),L.applyQuaternion(this._quat),this._spherical.setFromVector3(L),this.autoRotate&&this.state===S.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let s=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(s)&&isFinite(n)&&(s<-Math.PI?s+=P:s>Math.PI&&(s-=P),n<-Math.PI?n+=P:n>Math.PI&&(n-=P),s<=n?this._spherical.theta=Math.max(s,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+n)/2?Math.max(s,this._spherical.theta):Math.min(n,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=o!=this._spherical.radius}if(L.setFromSpherical(this._spherical),L.applyQuaternion(this._quatInverse),t.copy(this.target).add(L),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=L.length();o=this._clampDistance(a*this._scale);const r=a-o;this.object.position.addScaledVector(this._dollyDirection,r),this.object.updateMatrixWorld(),i=!!r}else if(this.object.isOrthographicCamera){const a=new h.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=r!==this.object.zoom;const c=new h.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=L.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(E.origin.copy(this.object.position),E.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(E.direction))<Qe?this.object.lookAt(this.target):(he.setFromNormalAndCoplanarPoint(this.object.up,this.target),E.intersectPlane(he,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),i=!0)}return this._scale=1,this._performCursorZoom=!1,i||this._lastPosition.distanceToSquared(this.object.position)>Q||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Q||this._lastTargetPosition.distanceToSquared(this.target)>Q?(this.dispatchEvent(ce),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?P/60*this.autoRotateSpeed*e:P/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){L.setFromMatrixColumn(t,0),L.multiplyScalar(-e),this._panOffset.add(L)}_panUp(e,t){this.screenSpacePanning===!0?L.setFromMatrixColumn(t,1):(L.setFromMatrixColumn(t,0),L.crossVectors(this.object.up,L)),L.multiplyScalar(e),this._panOffset.add(L)}_pan(e,t){const s=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;L.copy(n).sub(this.target);let i=L.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/s.clientHeight,this.object.matrix),this._panUp(2*t*i/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/s.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const s=this.domElement.getBoundingClientRect(),n=e-s.left,i=t-s.top,o=s.width,a=s.height;this._mouse.x=n/o*2-1,this._mouse.y=-(i/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(P*this._rotateDelta.x/t.clientHeight),this._rotateUp(P*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(P*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-P*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(P*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-P*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(s,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(s,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,i=Math.sqrt(s*s+n*n);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const s=this._getSecondPointerPosition(e),n=.5*(e.pageX+s.x),i=.5*(e.pageY+s.y);this._rotateEnd.set(n,i)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(P*this._rotateDelta.x/t.clientHeight),this._rotateUp(P*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(s,n)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,i=Math.sqrt(s*s+n*n);this._dollyEnd.set(0,i),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new h.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,s={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}}function Je(l){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(l.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(l)&&(this._addPointer(l),l.pointerType==="touch"?this._onTouchStart(l):this._onMouseDown(l)))}function He(l){this.enabled!==!1&&(l.pointerType==="touch"?this._onTouchMove(l):this._onMouseMove(l))}function et(l){switch(this._removePointer(l),this._pointers.length){case 0:this.domElement.releasePointerCapture(l.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(le),this.state=S.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function tt(l){let e;switch(l.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case h.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(l),this.state=S.DOLLY;break;case h.MOUSE.ROTATE:if(l.ctrlKey||l.metaKey||l.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(l),this.state=S.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(l),this.state=S.ROTATE}break;case h.MOUSE.PAN:if(l.ctrlKey||l.metaKey||l.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(l),this.state=S.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(l),this.state=S.PAN}break;default:this.state=S.NONE}this.state!==S.NONE&&this.dispatchEvent(Z)}function st(l){switch(this.state){case S.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(l);break;case S.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(l);break;case S.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(l);break}}function nt(l){this.enabled===!1||this.enableZoom===!1||this.state!==S.NONE||(l.preventDefault(),this.dispatchEvent(Z),this._handleMouseWheel(this._customWheelEvent(l)),this.dispatchEvent(le))}function it(l){this.enabled!==!1&&this._handleKeyDown(l)}function ot(l){switch(this._trackPointer(l),this._pointers.length){case 1:switch(this.touches.ONE){case h.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(l),this.state=S.TOUCH_ROTATE;break;case h.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(l),this.state=S.TOUCH_PAN;break;default:this.state=S.NONE}break;case 2:switch(this.touches.TWO){case h.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(l),this.state=S.TOUCH_DOLLY_PAN;break;case h.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(l),this.state=S.TOUCH_DOLLY_ROTATE;break;default:this.state=S.NONE}break;default:this.state=S.NONE}this.state!==S.NONE&&this.dispatchEvent(Z)}function rt(l){switch(this._trackPointer(l),this.state){case S.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(l),this.update();break;case S.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(l),this.update();break;case S.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(l),this.update();break;case S.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(l),this.update();break;default:this.state=S.NONE}}function at(l){this.enabled!==!1&&l.preventDefault()}function ct(l){l.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function lt(l){l.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const ht=((l,e)=>{const t=l.__vccOpts||l;for(const[s,n]of e)t[s]=n;return t})({__name:"ThreeFrame",props:{animation:{type:Boolean,default:!1},clearAlpha:{type:[String,Number],default:1},clearColor:{type:String,default:"#7fbfff"},useOrbitControls:{type:Boolean,default:!1},useGridHelper:{type:Boolean,default:!1},useAxesHelper:{type:Boolean,default:!1},useDefaultLight:{type:Boolean,default:!1}},emits:["initialized","animate"],setup(l,{emit:e}){const t=e,s=l,n="dom"+M.getCurrentInstance().uid,i=M.useTemplateRef(n);let o=null,a=null,r=null,c=null,d=null;const u=()=>{const _={GLTFLoader:K,THREE:O,VRMExpressionPresetName:j.VRMExpressionPresetName,VRMHumanBoneName:j.VRMHumanBoneName,camera:r,controls:d,renderer:c,scene:a};t("animate",_),o!=null&&(cancelAnimationFrame(o),o=null),s.animation&&(o=requestAnimationFrame(u)),c.render(a,r)},p=()=>{o!=null&&(cancelAnimationFrame(o),o=null),o=requestAnimationFrame(u)},f=()=>{o!=null&&(cancelAnimationFrame(o),o=null)};M.watch(()=>s.animation,_=>{_==!0?p():f()}),M.watch(()=>s.clearAlpha,_=>{c&&c.setClearAlpha(parseFloat(_))}),M.watch(()=>s.clearColor,_=>{if(c){const m=new O.Color(_),y=c.getClearAlpha();c.setClearColor(m,y)}});const g=()=>{const _=i.value,m=_.clientWidth,y=_.clientHeight,T={antialias:!0,alpha:!1};if(O.ColorManagement.enabled=!1,c=new O.WebGLRenderer(T),c.setPixelRatio(window.devicePixelRatio),c.setSize(m,y),c.setClearColor(s.clearColor,s.clearAlpha),c.outputColorSpace=O.SRGBColorSpace,_.appendChild(c.domElement),a=new O.Scene,r=new O.PerspectiveCamera(45,m/y,.1,1e3),r.position.set(0,1.25,1),s.useOrbitControls&&(d=new $e(r,_),d.screenSpacePanning=!0,d.target.set(0,1.25,0),d.update()),s.useGridHelper){const x=new O.GridHelper(10,10);a.add(x),x.visible=!0}if(s.useAxesHelper){const x=new O.AxesHelper(5);a.add(x)}if(s.useDefaultLight){const x=new O.DirectionalLight(16777215);x.intensity=3,x.position.set(1,1,1).normalize(),a.add(x);const C=new O.AmbientLight(4210752);a.add(C)}const w={GLTFLoader:K,THREE:O,VRMExpressionPresetName:j.VRMExpressionPresetName,VRMHumanBoneName:j.VRMHumanBoneName,camera:r,controls:d,renderer:c,scene:a};t("initialized",w)};return M.onMounted(async()=>{if(!ee.isWebGL2Available()){const m=ee.getWebGLErrorMessage();console.error(m);return}const _=()=>{const m=i.value,y=m.clientWidth,T=m.clientHeight;c.setPixelRatio(window.devicePixelRatio),c.setSize(y,T),r.aspect=y/T,r.updateProjectionMatrix()};window.addEventListener("resize",_),g()}),(_,m)=>(M.openBlock(),M.createElementBlock("div",{ref:n,class:"box"}))}},[["__scopeId","data-v-81e1dabc"]]),ue={__name:"VroidExpression",props:{command:{type:String},name:{type:String},url:{type:String},data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,s=l,n=async o=>{if(!o)return;t("loading",s.name,s.command);const r=await new V().fetchExpression(o);let c=!1;r&&(c=!0),t("loaded",s.name,s.command,c,r)},i=o=>{t("loading",s.name,s.command);let a=!1;o&&(a=!0),t("loaded",s.name,s.command,a,o)};return M.onMounted(async()=>{s.data!=null?i(s.data):n(s.url)}),M.watch(()=>s.data,()=>{s.data!=null&&i(s.data)}),M.watch(()=>s.url,()=>{s.url&&n(s.url)}),(o,a)=>null}},de={__name:"VroidPose",props:{command:{type:String},name:{type:String},url:{type:String},data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,s=l,n=async o=>{if(!o)return;t("loading",s.name,s.command);const r=await new V().fetchPose(o);let c=!1;r&&(c=!0),t("loaded",s.name,s.command,c,r)},i=o=>{t("loading",s.name,s.command);const r=new V().normalizePose(o);let c=!1;r&&(c=!0),t("loaded",s.name,s.command,c,r)};return M.onMounted(async()=>{s.data!=null?i(s.data):n(s.url)}),M.watch(()=>s.data,()=>{s.data!=null&&i(s.data)}),M.watch(()=>s.url,()=>{s.url&&n(s.url)}),(o,a)=>null}},pe={__name:"VroidVrm",props:{url:{type:String},data:{type:[Object,null],default:null},name:{type:String},command:{type:String}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,s=l,n=async a=>{const r=new K;return r.register(c=>new j.VRMLoaderPlugin(c)),await r.loadAsync(a).then(c=>{const d=c.userData.vrm;return j.VRMUtils.rotateVRM0(d),d})},i=async a=>{if(!a)return;t("loading",s.name,s.command);const r=await n(a);let c=!1;r&&(c=!0),t("loaded",s.name,s.command,c,r)},o=a=>{t("loading",s.name,s.command);let r=!1;a&&(r=!0),t("loaded",s.name,s.command,r,a)};return M.onMounted(async()=>{s.data!=null?o(s.data):i(s.url)}),M.watch(()=>s.data,()=>{s.data!=null&&o(s.data)}),M.watch(()=>s.url,()=>{s.url&&i(s.url)}),(a,r)=>null}},fe={__name:"VroidModel",props:{name:{type:String},expression_name:{type:String},expression_url:{type:String},expression_data:{type:[Object,null],default:null},pose_name:{type:String},pose_url:{type:String},pose_data:{type:[Object,null],default:null},vrm_name:{type:String},vrm_url:{type:String},vrm_data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,s=l,n={},i={},o=M.ref(null),a=M.ref(null),r=M.ref(null),c=(u,p)=>{const f=Object.keys(n).length;n[u]=p;const g=Object.keys(n).length;f==0&&g&&t("loading",s.name)},d=(u,p,f,g)=>{const _=Object.keys(n).length;f&&(p=="load_expression"&&(o.value=g),p=="load_pose"&&(a.value=g),p=="load_vrm"&&(r.value=g),i[u]=p),delete n[u];const m=Object.keys(n).length;if(_&&m==0){const y={};for(const w in i){const x=i[w];x=="load_expression"&&(y.expression=o.value),x=="load_pose"&&(y.pose=a.value),x=="load_vrm"&&(y.vrm=r.value)}t("loaded",s.name,y);const T=Object.keys(i);for(const w of T)delete i[w]}};return(u,p)=>(M.openBlock(),M.createElementBlock(M.Fragment,null,[M.createVNode(ue,{command:"load_expression",name:s.expression_name,url:s.expression_url,data:s.expression_data,onLoading:c,onLoaded:d},null,8,["name","url","data"]),M.createVNode(de,{command:"load_pose",name:s.pose_name,url:s.pose_url,data:s.pose_data,onLoading:c,onLoaded:d},null,8,["name","url","data"]),M.createVNode(pe,{command:"load_vrm",name:s.vrm_name,url:s.vrm_url,data:s.vrm_data,onLoading:c,onLoaded:d},null,8,["name","url","data"])],64))}},ut={__name:"VroidControl",props:{model_name:{type:String,required:!0},expression_name:{type:String,default:"expression"},expression_url:{type:String,default:""},expression_data:{type:[Object,null],default:null},pose_name:{type:String,default:"pose"},pose_url:{type:String,default:""},pose_data:{type:[Object,null],default:null},vrm_name:{type:String,default:"vrm"},vrm_url:{type:String,default:""},vrm_data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,s=M.ref(null);s.value=new H;const n=o=>{t("loading",o)},i=(o,a)=>{"vrm"in a&&s.value.setModel(a.vrm),"pose"in a&&(s.value.resetPose(),s.value.setPose(a.pose),s.value.updatePose()),"expression"in a&&(s.value.resetExpression(),s.value.importExpression(a.expression),s.value.updateExpression()),t("loaded",o,s.value)};return(o,a)=>(M.openBlock(),M.createBlock(fe,{name:l.model_name,expression_name:l.expression_name,expression_url:l.expression_url,expression_data:l.expression_data,pose_name:l.pose_name,pose_url:l.pose_url,pose_data:l.pose_data,vrm_name:l.vrm_name,vrm_url:l.vrm_url,vrm_data:l.vrm_data,onLoading:n,onLoaded:i},null,8,["name","expression_name","expression_url","expression_data","pose_name","pose_url","pose_data","vrm_name","vrm_url","vrm_data"]))}};A.ResourceLoader=V,A.ThreeFrame=ht,A.VrmModel=H,A.VroidControl=ut,A.VroidExpression=ue,A.VroidModel=fe,A.VroidPose=de,A.VroidVrm=pe,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|