@j-kyoda/vue-three-vrm 0.5.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.
@@ -0,0 +1,2730 @@
1
+ import { getCurrentInstance as Ke, useTemplateRef as Be, watch as Ve, onMounted as Q, createElementBlock as Le, openBlock as de, inject as Pe, ref as W, Fragment as ze, createVNode as J, createBlock as Xe } from "vue";
2
+ import * as O from "three";
3
+ import { Controls as Ye, Vector3 as M, MOUSE as U, TOUCH as H, Quaternion as Z, Spherical as fe, Vector2 as S, Ray as We, Plane as Ze, MathUtils as Ne, TrianglesDrawMode as qe, TriangleFanDrawMode as ae, TriangleStripDrawMode as Oe, Loader as Qe, LoaderUtils as z, FileLoader as De, MeshPhysicalMaterial as N, Color as F, LinearSRGBColorSpace as C, SRGBColorSpace as X, SpotLight as $e, PointLight as Je, DirectionalLight as et, Matrix4 as q, InstancedMesh as tt, InstancedBufferAttribute as st, Object3D as Ce, TextureLoader as nt, ImageBitmapLoader as it, BufferAttribute as ee, InterleavedBuffer as ot, InterleavedBufferAttribute as rt, LinearMipmapLinearFilter as Ie, NearestMipmapLinearFilter as at, LinearMipmapNearestFilter as ct, NearestMipmapNearestFilter as lt, LinearFilter as ce, NearestFilter as ve, RepeatWrapping as le, MirroredRepeatWrapping as ht, ClampToEdgeWrapping as ut, PointsMaterial as dt, Material as te, LineBasicMaterial as pt, MeshStandardMaterial as ke, DoubleSide as ft, MeshBasicMaterial as V, PropertyBinding as mt, BufferGeometry as _t, SkinnedMesh as gt, Mesh as Tt, LineSegments as yt, Line as xt, LineLoop as Et, Points as bt, Group as se, PerspectiveCamera as Rt, OrthographicCamera as Mt, Skeleton as wt, AnimationClip as St, Bone as At, InterpolateDiscrete as Lt, InterpolateLinear as je, Texture as me, VectorKeyframeTrack as _e, NumberKeyframeTrack as ge, QuaternionKeyframeTrack as Te, ColorManagement as ye, FrontSide as Pt, Interpolant as Nt, Box3 as Ot, Sphere as Dt } from "three";
4
+ import { VRMLoaderPlugin as Ct, VRMUtils as It } from "@pixiv/three-vrm";
5
+ class Fe {
6
+ constructor() {
7
+ this.status = 0, this.url = null, this.data = null;
8
+ }
9
+ is_loaded() {
10
+ return this.status == 2;
11
+ }
12
+ is_failed() {
13
+ return this.status == 3;
14
+ }
15
+ async loadUrl(e, t) {
16
+ this.url = t, this.data = null, this.status = 1;
17
+ const n = await e.get(t);
18
+ return n.status != 200 ? (this.status = 3, null) : n.data ? (this.data = n.data, this.status = 2, this.data) : (this.status = 3, null);
19
+ }
20
+ async loadPose(e, t) {
21
+ const n = await this.loadUrl(e, t);
22
+ return n == null ? null : "pose" in n ? (this.data = n.pose, this.data) : this.data;
23
+ }
24
+ async loadExpression(e, t) {
25
+ const n = await this.loadUrl(e, t);
26
+ return n == null ? null : "expressions" in n ? (this.data = n.expressions, this.data) : this.data;
27
+ }
28
+ }
29
+ class vt {
30
+ constructor() {
31
+ this.vrm = null;
32
+ }
33
+ // getter
34
+ get scene() {
35
+ return this.vrm ? this.vrm.scene : null;
36
+ }
37
+ // methods
38
+ setModel(e) {
39
+ this.vrm = e;
40
+ }
41
+ setPosition(e) {
42
+ this.vrm.scene.position.x = e.x, this.vrm.scene.position.y = e.y, this.vrm.scene.position.z = e.z;
43
+ }
44
+ getPosition() {
45
+ return {
46
+ x: this.vrm.scene.position.x,
47
+ y: this.vrm.scene.position.y,
48
+ z: this.vrm.scene.position.z
49
+ };
50
+ }
51
+ setPose(e) {
52
+ this.vrm && this.vrm.humanoid.setNormalizedPose(e);
53
+ }
54
+ getPose() {
55
+ return this.vrm ? this.vrm.humanoid.getNormalizedPose() : null;
56
+ }
57
+ updatePose() {
58
+ this.vrm && this.vrm.humanoid.update();
59
+ }
60
+ resetPose() {
61
+ this.vrm && this.vrm.humanoid.resetNormalizedPose();
62
+ }
63
+ getBoneNode(e) {
64
+ return this.vrm ? this.vrm.humanoid.getNormalizedBoneNode(e) : null;
65
+ }
66
+ isValid() {
67
+ return !!this.vrm;
68
+ }
69
+ getBoneRotate(e) {
70
+ const t = this.getBoneNode(e);
71
+ return t ? {
72
+ x: t.rotation.x,
73
+ y: t.rotation.y,
74
+ z: t.rotation.z
75
+ } : null;
76
+ }
77
+ setBoneRotate(e, t, n, s) {
78
+ const i = this.getBoneNode(e);
79
+ i && (i.rotation.x = t, i.rotation.y = n, i.rotation.z = s);
80
+ }
81
+ getBonePosition(e) {
82
+ const t = this.getBoneNode(e);
83
+ return t ? {
84
+ x: t.position.x,
85
+ y: t.position.y,
86
+ z: t.position.z
87
+ } : null;
88
+ }
89
+ setBonePosition(e, t, n, s) {
90
+ const i = this.getBoneNode(e);
91
+ i && (i.position.x = t, i.position.y = n, i.position.z = s);
92
+ }
93
+ getMetaVersion() {
94
+ return this.vrm ? this.vrm.meta.metaVersion : null;
95
+ }
96
+ setExpression(e, t) {
97
+ this.vrm && this.vrm.expressionManager.setValue(e, t);
98
+ }
99
+ getExpression(e) {
100
+ return this.vrm ? this.vrm.expressionManager.getValue(e) : null;
101
+ }
102
+ updateExpression() {
103
+ return this.vrm ? this.vrm.expressionManager.update() : null;
104
+ }
105
+ getExpressionNames() {
106
+ if (this.vrm) {
107
+ let e = [];
108
+ for (const t in this.vrm.expressionManager.expressionMap)
109
+ e.push(t);
110
+ return e;
111
+ }
112
+ return null;
113
+ }
114
+ importExpression(e) {
115
+ if (this.vrm)
116
+ for (const t in e)
117
+ this.vrm.expressionManager.setValue(t, e[t]);
118
+ }
119
+ exportExpression() {
120
+ if (this.vrm) {
121
+ let e = {};
122
+ const t = this.getExpressionNames();
123
+ for (const n in t)
124
+ e[n] = this.getExpression(n);
125
+ return e;
126
+ }
127
+ return null;
128
+ }
129
+ }
130
+ class xe {
131
+ /**
132
+ * Returns `true` if WebGL 2 is available.
133
+ *
134
+ * @return {boolean} Whether WebGL 2 is available or not.
135
+ */
136
+ static isWebGL2Available() {
137
+ try {
138
+ const e = document.createElement("canvas");
139
+ return !!(window.WebGL2RenderingContext && e.getContext("webgl2"));
140
+ } catch {
141
+ return !1;
142
+ }
143
+ }
144
+ /**
145
+ * Returns `true` if the given color space is available. This method can only be used
146
+ * if WebGL 2 is supported.
147
+ *
148
+ * @param {string} colorSpace - The color space to test.
149
+ * @return {boolean} Whether the given color space is available or not.
150
+ */
151
+ static isColorSpaceAvailable(e) {
152
+ try {
153
+ const t = document.createElement("canvas"), n = window.WebGL2RenderingContext && t.getContext("webgl2");
154
+ return n.drawingBufferColorSpace = e, n.drawingBufferColorSpace === e;
155
+ } catch {
156
+ return !1;
157
+ }
158
+ }
159
+ /**
160
+ * Returns a `div` element representing a formatted error message that can be appended in
161
+ * web sites if WebGL 2 isn't supported.
162
+ *
163
+ * @return {HTMLDivElement} A `div` element representing a formatted error message that WebGL 2 isn't supported.
164
+ */
165
+ static getWebGL2ErrorMessage() {
166
+ return this._getErrorMessage(2);
167
+ }
168
+ // private
169
+ static _getErrorMessage(e) {
170
+ const t = {
171
+ 1: "WebGL",
172
+ 2: "WebGL 2"
173
+ }, n = {
174
+ 1: window.WebGLRenderingContext,
175
+ 2: window.WebGL2RenderingContext
176
+ };
177
+ let s = 'Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';
178
+ const i = document.createElement("div");
179
+ 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", n[e] ? s = s.replace("$0", "graphics card") : s = s.replace("$0", "browser"), s = s.replace("$1", t[e]), i.innerHTML = s, i;
180
+ }
181
+ // @deprecated, r168
182
+ static isWebGLAvailable() {
183
+ console.warn("isWebGLAvailable() has been deprecated and will be removed in r178. Use isWebGL2Available() instead.");
184
+ try {
185
+ const e = document.createElement("canvas");
186
+ return !!(window.WebGLRenderingContext && (e.getContext("webgl") || e.getContext("experimental-webgl")));
187
+ } catch {
188
+ return !1;
189
+ }
190
+ }
191
+ static getWebGLErrorMessage() {
192
+ return console.warn("getWebGLErrorMessage() has been deprecated and will be removed in r178. Use getWebGL2ErrorMessage() instead."), this._getErrorMessage(1);
193
+ }
194
+ }
195
+ const Ee = { type: "change" }, pe = { type: "start" }, He = { type: "end" }, Y = new We(), be = new Ze(), kt = Math.cos(70 * Ne.DEG2RAD), R = new M(), w = 2 * Math.PI, E = {
196
+ NONE: -1,
197
+ ROTATE: 0,
198
+ DOLLY: 1,
199
+ PAN: 2,
200
+ TOUCH_ROTATE: 3,
201
+ TOUCH_PAN: 4,
202
+ TOUCH_DOLLY_PAN: 5,
203
+ TOUCH_DOLLY_ROTATE: 6
204
+ }, ne = 1e-6;
205
+ class jt extends Ye {
206
+ /**
207
+ * Constructs a new controls instance.
208
+ *
209
+ * @param {Object3D} object - The object that is managed by the controls.
210
+ * @param {?HTMLDOMElement} domElement - The HTML element used for event listeners.
211
+ */
212
+ constructor(e, t = null) {
213
+ super(e, t), this.state = E.NONE, this.target = new M(), this.cursor = new M(), 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 = 0.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: U.ROTATE, MIDDLE: U.DOLLY, RIGHT: U.PAN }, this.touches = { ONE: H.ROTATE, TWO: H.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this._lastPosition = new M(), this._lastQuaternion = new Z(), this._lastTargetPosition = new M(), this._quat = new Z().setFromUnitVectors(e.up, new M(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new fe(), this._sphericalDelta = new fe(), this._scale = 1, this._panOffset = new M(), this._rotateStart = new S(), this._rotateEnd = new S(), this._rotateDelta = new S(), this._panStart = new S(), this._panEnd = new S(), this._panDelta = new S(), this._dollyStart = new S(), this._dollyEnd = new S(), this._dollyDelta = new S(), this._dollyDirection = new M(), this._mouse = new S(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = Ht.bind(this), this._onPointerDown = Ft.bind(this), this._onPointerUp = Ut.bind(this), this._onContextMenu = Yt.bind(this), this._onMouseWheel = Bt.bind(this), this._onKeyDown = Vt.bind(this), this._onTouchStart = zt.bind(this), this._onTouchMove = Xt.bind(this), this._onMouseDown = Gt.bind(this), this._onMouseMove = Kt.bind(this), this._interceptControlDown = Wt.bind(this), this._interceptControlUp = Zt.bind(this), this.domElement !== null && this.connect(this.domElement), this.update();
214
+ }
215
+ connect(e) {
216
+ 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";
217
+ }
218
+ disconnect() {
219
+ 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";
220
+ }
221
+ dispose() {
222
+ this.disconnect();
223
+ }
224
+ /**
225
+ * Get the current vertical rotation, in radians.
226
+ *
227
+ * @return {number} The current vertical rotation, in radians.
228
+ */
229
+ getPolarAngle() {
230
+ return this._spherical.phi;
231
+ }
232
+ /**
233
+ * Get the current horizontal rotation, in radians.
234
+ *
235
+ * @return {number} The current horizontal rotation, in radians.
236
+ */
237
+ getAzimuthalAngle() {
238
+ return this._spherical.theta;
239
+ }
240
+ /**
241
+ * Returns the distance from the camera to the target.
242
+ *
243
+ * @return {number} The distance from the camera to the target.
244
+ */
245
+ getDistance() {
246
+ return this.object.position.distanceTo(this.target);
247
+ }
248
+ /**
249
+ * Adds key event listeners to the given DOM element.
250
+ * `window` is a recommended argument for using this method.
251
+ *
252
+ * @param {HTMLDOMElement} domElement - The DOM element
253
+ */
254
+ listenToKeyEvents(e) {
255
+ e.addEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = e;
256
+ }
257
+ /**
258
+ * Removes the key event listener previously defined with `listenToKeyEvents()`.
259
+ */
260
+ stopListenToKeyEvents() {
261
+ this._domElementKeyEvents !== null && (this._domElementKeyEvents.removeEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = null);
262
+ }
263
+ /**
264
+ * Save the current state of the controls. This can later be recovered with `reset()`.
265
+ */
266
+ saveState() {
267
+ this.target0.copy(this.target), this.position0.copy(this.object.position), this.zoom0 = this.object.zoom;
268
+ }
269
+ /**
270
+ * Reset the controls to their state from either the last time the `saveState()`
271
+ * was called, or the initial state.
272
+ */
273
+ reset() {
274
+ this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(Ee), this.update(), this.state = E.NONE;
275
+ }
276
+ update(e = null) {
277
+ const t = this.object.position;
278
+ R.copy(t).sub(this.target), R.applyQuaternion(this._quat), this._spherical.setFromVector3(R), this.autoRotate && this.state === E.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);
279
+ let n = this.minAzimuthAngle, s = this.maxAzimuthAngle;
280
+ isFinite(n) && isFinite(s) && (n < -Math.PI ? n += w : n > Math.PI && (n -= w), s < -Math.PI ? s += w : s > Math.PI && (s -= w), n <= s ? this._spherical.theta = Math.max(n, Math.min(s, this._spherical.theta)) : this._spherical.theta = this._spherical.theta > (n + s) / 2 ? Math.max(n, this._spherical.theta) : Math.min(s, 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);
281
+ let i = !1;
282
+ if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera)
283
+ this._spherical.radius = this._clampDistance(this._spherical.radius);
284
+ else {
285
+ const o = this._spherical.radius;
286
+ this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale), i = o != this._spherical.radius;
287
+ }
288
+ if (R.setFromSpherical(this._spherical), R.applyQuaternion(this._quatInverse), t.copy(this.target).add(R), 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) {
289
+ let o = null;
290
+ if (this.object.isPerspectiveCamera) {
291
+ const r = R.length();
292
+ o = this._clampDistance(r * this._scale);
293
+ const a = r - o;
294
+ this.object.position.addScaledVector(this._dollyDirection, a), this.object.updateMatrixWorld(), i = !!a;
295
+ } else if (this.object.isOrthographicCamera) {
296
+ const r = new M(this._mouse.x, this._mouse.y, 0);
297
+ r.unproject(this.object);
298
+ const a = this.object.zoom;
299
+ this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(), i = a !== this.object.zoom;
300
+ const c = new M(this._mouse.x, this._mouse.y, 0);
301
+ c.unproject(this.object), this.object.position.sub(c).add(r), this.object.updateMatrixWorld(), o = R.length();
302
+ } else
303
+ console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), this.zoomToCursor = !1;
304
+ o !== null && (this.screenSpacePanning ? this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position) : (Y.origin.copy(this.object.position), Y.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot(Y.direction)) < kt ? this.object.lookAt(this.target) : (be.setFromNormalAndCoplanarPoint(this.object.up, this.target), Y.intersectPlane(be, this.target))));
305
+ } else if (this.object.isOrthographicCamera) {
306
+ const o = this.object.zoom;
307
+ 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);
308
+ }
309
+ return this._scale = 1, this._performCursorZoom = !1, i || this._lastPosition.distanceToSquared(this.object.position) > ne || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > ne || this._lastTargetPosition.distanceToSquared(this.target) > ne ? (this.dispatchEvent(Ee), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1;
310
+ }
311
+ _getAutoRotationAngle(e) {
312
+ return e !== null ? w / 60 * this.autoRotateSpeed * e : w / 60 / 60 * this.autoRotateSpeed;
313
+ }
314
+ _getZoomScale(e) {
315
+ const t = Math.abs(e * 0.01);
316
+ return Math.pow(0.95, this.zoomSpeed * t);
317
+ }
318
+ _rotateLeft(e) {
319
+ this._sphericalDelta.theta -= e;
320
+ }
321
+ _rotateUp(e) {
322
+ this._sphericalDelta.phi -= e;
323
+ }
324
+ _panLeft(e, t) {
325
+ R.setFromMatrixColumn(t, 0), R.multiplyScalar(-e), this._panOffset.add(R);
326
+ }
327
+ _panUp(e, t) {
328
+ this.screenSpacePanning === !0 ? R.setFromMatrixColumn(t, 1) : (R.setFromMatrixColumn(t, 0), R.crossVectors(this.object.up, R)), R.multiplyScalar(e), this._panOffset.add(R);
329
+ }
330
+ // deltaX and deltaY are in pixels; right and down are positive
331
+ _pan(e, t) {
332
+ const n = this.domElement;
333
+ if (this.object.isPerspectiveCamera) {
334
+ const s = this.object.position;
335
+ R.copy(s).sub(this.target);
336
+ let i = R.length();
337
+ i *= Math.tan(this.object.fov / 2 * Math.PI / 180), this._panLeft(2 * e * i / n.clientHeight, this.object.matrix), this._panUp(2 * t * i / n.clientHeight, this.object.matrix);
338
+ } else this.object.isOrthographicCamera ? (this._panLeft(e * (this.object.right - this.object.left) / this.object.zoom / n.clientWidth, this.object.matrix), this._panUp(t * (this.object.top - this.object.bottom) / this.object.zoom / n.clientHeight, this.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), this.enablePan = !1);
339
+ }
340
+ _dollyOut(e) {
341
+ 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);
342
+ }
343
+ _dollyIn(e) {
344
+ 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);
345
+ }
346
+ _updateZoomParameters(e, t) {
347
+ if (!this.zoomToCursor)
348
+ return;
349
+ this._performCursorZoom = !0;
350
+ const n = this.domElement.getBoundingClientRect(), s = e - n.left, i = t - n.top, o = n.width, r = n.height;
351
+ this._mouse.x = s / o * 2 - 1, this._mouse.y = -(i / r) * 2 + 1, this._dollyDirection.set(this._mouse.x, this._mouse.y, 1).unproject(this.object).sub(this.object.position).normalize();
352
+ }
353
+ _clampDistance(e) {
354
+ return Math.max(this.minDistance, Math.min(this.maxDistance, e));
355
+ }
356
+ //
357
+ // event callbacks - update the object state
358
+ //
359
+ _handleMouseDownRotate(e) {
360
+ this._rotateStart.set(e.clientX, e.clientY);
361
+ }
362
+ _handleMouseDownDolly(e) {
363
+ this._updateZoomParameters(e.clientX, e.clientX), this._dollyStart.set(e.clientX, e.clientY);
364
+ }
365
+ _handleMouseDownPan(e) {
366
+ this._panStart.set(e.clientX, e.clientY);
367
+ }
368
+ _handleMouseMoveRotate(e) {
369
+ this._rotateEnd.set(e.clientX, e.clientY), this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
370
+ const t = this.domElement;
371
+ this._rotateLeft(w * this._rotateDelta.x / t.clientHeight), this._rotateUp(w * this._rotateDelta.y / t.clientHeight), this._rotateStart.copy(this._rotateEnd), this.update();
372
+ }
373
+ _handleMouseMoveDolly(e) {
374
+ 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();
375
+ }
376
+ _handleMouseMovePan(e) {
377
+ 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();
378
+ }
379
+ _handleMouseWheel(e) {
380
+ 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();
381
+ }
382
+ _handleKeyDown(e) {
383
+ let t = !1;
384
+ switch (e.code) {
385
+ case this.keys.UP:
386
+ e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateUp(w * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, this.keyPanSpeed), t = !0;
387
+ break;
388
+ case this.keys.BOTTOM:
389
+ e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateUp(-w * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, -this.keyPanSpeed), t = !0;
390
+ break;
391
+ case this.keys.LEFT:
392
+ e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateLeft(w * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(this.keyPanSpeed, 0), t = !0;
393
+ break;
394
+ case this.keys.RIGHT:
395
+ e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateLeft(-w * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(-this.keyPanSpeed, 0), t = !0;
396
+ break;
397
+ }
398
+ t && (e.preventDefault(), this.update());
399
+ }
400
+ _handleTouchStartRotate(e) {
401
+ if (this._pointers.length === 1)
402
+ this._rotateStart.set(e.pageX, e.pageY);
403
+ else {
404
+ const t = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + t.x), s = 0.5 * (e.pageY + t.y);
405
+ this._rotateStart.set(n, s);
406
+ }
407
+ }
408
+ _handleTouchStartPan(e) {
409
+ if (this._pointers.length === 1)
410
+ this._panStart.set(e.pageX, e.pageY);
411
+ else {
412
+ const t = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + t.x), s = 0.5 * (e.pageY + t.y);
413
+ this._panStart.set(n, s);
414
+ }
415
+ }
416
+ _handleTouchStartDolly(e) {
417
+ const t = this._getSecondPointerPosition(e), n = e.pageX - t.x, s = e.pageY - t.y, i = Math.sqrt(n * n + s * s);
418
+ this._dollyStart.set(0, i);
419
+ }
420
+ _handleTouchStartDollyPan(e) {
421
+ this.enableZoom && this._handleTouchStartDolly(e), this.enablePan && this._handleTouchStartPan(e);
422
+ }
423
+ _handleTouchStartDollyRotate(e) {
424
+ this.enableZoom && this._handleTouchStartDolly(e), this.enableRotate && this._handleTouchStartRotate(e);
425
+ }
426
+ _handleTouchMoveRotate(e) {
427
+ if (this._pointers.length == 1)
428
+ this._rotateEnd.set(e.pageX, e.pageY);
429
+ else {
430
+ const n = this._getSecondPointerPosition(e), s = 0.5 * (e.pageX + n.x), i = 0.5 * (e.pageY + n.y);
431
+ this._rotateEnd.set(s, i);
432
+ }
433
+ this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
434
+ const t = this.domElement;
435
+ this._rotateLeft(w * this._rotateDelta.x / t.clientHeight), this._rotateUp(w * this._rotateDelta.y / t.clientHeight), this._rotateStart.copy(this._rotateEnd);
436
+ }
437
+ _handleTouchMovePan(e) {
438
+ if (this._pointers.length === 1)
439
+ this._panEnd.set(e.pageX, e.pageY);
440
+ else {
441
+ const t = this._getSecondPointerPosition(e), n = 0.5 * (e.pageX + t.x), s = 0.5 * (e.pageY + t.y);
442
+ this._panEnd.set(n, s);
443
+ }
444
+ this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd);
445
+ }
446
+ _handleTouchMoveDolly(e) {
447
+ const t = this._getSecondPointerPosition(e), n = e.pageX - t.x, s = e.pageY - t.y, i = Math.sqrt(n * n + s * s);
448
+ 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);
449
+ const o = (e.pageX + t.x) * 0.5, r = (e.pageY + t.y) * 0.5;
450
+ this._updateZoomParameters(o, r);
451
+ }
452
+ _handleTouchMoveDollyPan(e) {
453
+ this.enableZoom && this._handleTouchMoveDolly(e), this.enablePan && this._handleTouchMovePan(e);
454
+ }
455
+ _handleTouchMoveDollyRotate(e) {
456
+ this.enableZoom && this._handleTouchMoveDolly(e), this.enableRotate && this._handleTouchMoveRotate(e);
457
+ }
458
+ // pointers
459
+ _addPointer(e) {
460
+ this._pointers.push(e.pointerId);
461
+ }
462
+ _removePointer(e) {
463
+ delete this._pointerPositions[e.pointerId];
464
+ for (let t = 0; t < this._pointers.length; t++)
465
+ if (this._pointers[t] == e.pointerId) {
466
+ this._pointers.splice(t, 1);
467
+ return;
468
+ }
469
+ }
470
+ _isTrackingPointer(e) {
471
+ for (let t = 0; t < this._pointers.length; t++)
472
+ if (this._pointers[t] == e.pointerId) return !0;
473
+ return !1;
474
+ }
475
+ _trackPointer(e) {
476
+ let t = this._pointerPositions[e.pointerId];
477
+ t === void 0 && (t = new S(), this._pointerPositions[e.pointerId] = t), t.set(e.pageX, e.pageY);
478
+ }
479
+ _getSecondPointerPosition(e) {
480
+ const t = e.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0];
481
+ return this._pointerPositions[t];
482
+ }
483
+ //
484
+ _customWheelEvent(e) {
485
+ const t = e.deltaMode, n = {
486
+ clientX: e.clientX,
487
+ clientY: e.clientY,
488
+ deltaY: e.deltaY
489
+ };
490
+ switch (t) {
491
+ case 1:
492
+ n.deltaY *= 16;
493
+ break;
494
+ case 2:
495
+ n.deltaY *= 100;
496
+ break;
497
+ }
498
+ return e.ctrlKey && !this._controlActive && (n.deltaY *= 10), n;
499
+ }
500
+ }
501
+ function Ft(l) {
502
+ 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)));
503
+ }
504
+ function Ht(l) {
505
+ this.enabled !== !1 && (l.pointerType === "touch" ? this._onTouchMove(l) : this._onMouseMove(l));
506
+ }
507
+ function Ut(l) {
508
+ switch (this._removePointer(l), this._pointers.length) {
509
+ case 0:
510
+ this.domElement.releasePointerCapture(l.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(He), this.state = E.NONE;
511
+ break;
512
+ case 1:
513
+ const e = this._pointers[0], t = this._pointerPositions[e];
514
+ this._onTouchStart({ pointerId: e, pageX: t.x, pageY: t.y });
515
+ break;
516
+ }
517
+ }
518
+ function Gt(l) {
519
+ let e;
520
+ switch (l.button) {
521
+ case 0:
522
+ e = this.mouseButtons.LEFT;
523
+ break;
524
+ case 1:
525
+ e = this.mouseButtons.MIDDLE;
526
+ break;
527
+ case 2:
528
+ e = this.mouseButtons.RIGHT;
529
+ break;
530
+ default:
531
+ e = -1;
532
+ }
533
+ switch (e) {
534
+ case U.DOLLY:
535
+ if (this.enableZoom === !1) return;
536
+ this._handleMouseDownDolly(l), this.state = E.DOLLY;
537
+ break;
538
+ case U.ROTATE:
539
+ if (l.ctrlKey || l.metaKey || l.shiftKey) {
540
+ if (this.enablePan === !1) return;
541
+ this._handleMouseDownPan(l), this.state = E.PAN;
542
+ } else {
543
+ if (this.enableRotate === !1) return;
544
+ this._handleMouseDownRotate(l), this.state = E.ROTATE;
545
+ }
546
+ break;
547
+ case U.PAN:
548
+ if (l.ctrlKey || l.metaKey || l.shiftKey) {
549
+ if (this.enableRotate === !1) return;
550
+ this._handleMouseDownRotate(l), this.state = E.ROTATE;
551
+ } else {
552
+ if (this.enablePan === !1) return;
553
+ this._handleMouseDownPan(l), this.state = E.PAN;
554
+ }
555
+ break;
556
+ default:
557
+ this.state = E.NONE;
558
+ }
559
+ this.state !== E.NONE && this.dispatchEvent(pe);
560
+ }
561
+ function Kt(l) {
562
+ switch (this.state) {
563
+ case E.ROTATE:
564
+ if (this.enableRotate === !1) return;
565
+ this._handleMouseMoveRotate(l);
566
+ break;
567
+ case E.DOLLY:
568
+ if (this.enableZoom === !1) return;
569
+ this._handleMouseMoveDolly(l);
570
+ break;
571
+ case E.PAN:
572
+ if (this.enablePan === !1) return;
573
+ this._handleMouseMovePan(l);
574
+ break;
575
+ }
576
+ }
577
+ function Bt(l) {
578
+ this.enabled === !1 || this.enableZoom === !1 || this.state !== E.NONE || (l.preventDefault(), this.dispatchEvent(pe), this._handleMouseWheel(this._customWheelEvent(l)), this.dispatchEvent(He));
579
+ }
580
+ function Vt(l) {
581
+ this.enabled !== !1 && this._handleKeyDown(l);
582
+ }
583
+ function zt(l) {
584
+ switch (this._trackPointer(l), this._pointers.length) {
585
+ case 1:
586
+ switch (this.touches.ONE) {
587
+ case H.ROTATE:
588
+ if (this.enableRotate === !1) return;
589
+ this._handleTouchStartRotate(l), this.state = E.TOUCH_ROTATE;
590
+ break;
591
+ case H.PAN:
592
+ if (this.enablePan === !1) return;
593
+ this._handleTouchStartPan(l), this.state = E.TOUCH_PAN;
594
+ break;
595
+ default:
596
+ this.state = E.NONE;
597
+ }
598
+ break;
599
+ case 2:
600
+ switch (this.touches.TWO) {
601
+ case H.DOLLY_PAN:
602
+ if (this.enableZoom === !1 && this.enablePan === !1) return;
603
+ this._handleTouchStartDollyPan(l), this.state = E.TOUCH_DOLLY_PAN;
604
+ break;
605
+ case H.DOLLY_ROTATE:
606
+ if (this.enableZoom === !1 && this.enableRotate === !1) return;
607
+ this._handleTouchStartDollyRotate(l), this.state = E.TOUCH_DOLLY_ROTATE;
608
+ break;
609
+ default:
610
+ this.state = E.NONE;
611
+ }
612
+ break;
613
+ default:
614
+ this.state = E.NONE;
615
+ }
616
+ this.state !== E.NONE && this.dispatchEvent(pe);
617
+ }
618
+ function Xt(l) {
619
+ switch (this._trackPointer(l), this.state) {
620
+ case E.TOUCH_ROTATE:
621
+ if (this.enableRotate === !1) return;
622
+ this._handleTouchMoveRotate(l), this.update();
623
+ break;
624
+ case E.TOUCH_PAN:
625
+ if (this.enablePan === !1) return;
626
+ this._handleTouchMovePan(l), this.update();
627
+ break;
628
+ case E.TOUCH_DOLLY_PAN:
629
+ if (this.enableZoom === !1 && this.enablePan === !1) return;
630
+ this._handleTouchMoveDollyPan(l), this.update();
631
+ break;
632
+ case E.TOUCH_DOLLY_ROTATE:
633
+ if (this.enableZoom === !1 && this.enableRotate === !1) return;
634
+ this._handleTouchMoveDollyRotate(l), this.update();
635
+ break;
636
+ default:
637
+ this.state = E.NONE;
638
+ }
639
+ }
640
+ function Yt(l) {
641
+ this.enabled !== !1 && l.preventDefault();
642
+ }
643
+ function Wt(l) {
644
+ l.key === "Control" && (this._controlActive = !0, this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
645
+ }
646
+ function Zt(l) {
647
+ l.key === "Control" && (this._controlActive = !1, this.domElement.getRootNode().removeEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
648
+ }
649
+ const qt = (l, e) => {
650
+ const t = l.__vccOpts || l;
651
+ for (const [n, s] of e)
652
+ t[n] = s;
653
+ return t;
654
+ }, Qt = {
655
+ __name: "ThreeFrame",
656
+ props: {
657
+ animation: {
658
+ type: Boolean,
659
+ default: !1
660
+ },
661
+ useOrbitControls: {
662
+ type: Boolean,
663
+ default: !1
664
+ },
665
+ useGridHelper: {
666
+ type: Boolean,
667
+ default: !1
668
+ },
669
+ useAxesHelper: {
670
+ type: Boolean,
671
+ default: !1
672
+ },
673
+ useDefaultLight: {
674
+ type: Boolean,
675
+ default: !1
676
+ }
677
+ },
678
+ emits: ["init", "animate"],
679
+ setup(l, { emit: e }) {
680
+ const t = e, n = l, s = "dom" + Ke().uid, i = Be(s);
681
+ let o = null, r = null, a = null, c = null, h = null;
682
+ const u = () => {
683
+ t("animate", {
684
+ scene: r,
685
+ camera: a,
686
+ renderer: c,
687
+ controls: h
688
+ }), o != null && (cancelAnimationFrame(o), o = null), n.animation && (o = requestAnimationFrame(u)), c.render(r, a);
689
+ }, d = () => {
690
+ o != null && (cancelAnimationFrame(o), o = null), o = requestAnimationFrame(u);
691
+ }, p = () => {
692
+ o != null && (cancelAnimationFrame(o), o = null);
693
+ };
694
+ Ve(() => n.animation, (g) => {
695
+ g == !0 ? d() : p();
696
+ });
697
+ const m = () => {
698
+ const g = i.value, f = g.clientWidth, _ = g.clientHeight, x = {
699
+ antialias: !0,
700
+ alpha: !1
701
+ };
702
+ if (O.ColorManagement.enabled = !1, c = new O.WebGLRenderer(x), c.setPixelRatio(window.devicePixelRatio), c.setSize(f, _), c.setClearColor(8372223, 1), c.outputColorSpace = O.SRGBColorSpace, g.appendChild(c.domElement), r = new O.Scene(), a = new O.PerspectiveCamera(
703
+ 45,
704
+ f / _,
705
+ 0.1,
706
+ 1e3
707
+ ), a.position.set(0, 1.25, 1), n.useOrbitControls && (h = new jt(a, g), h.screenSpacePanning = !0, h.target.set(0, 1.25, 0), h.update()), n.useGridHelper) {
708
+ const T = new O.GridHelper(10, 10);
709
+ r.add(T), T.visible = !0;
710
+ }
711
+ if (n.useAxesHelper) {
712
+ const T = new O.AxesHelper(5);
713
+ r.add(T);
714
+ }
715
+ if (n.useDefaultLight) {
716
+ const T = new O.DirectionalLight(16777215);
717
+ T.intensity = 3, T.position.set(1, 1, 1).normalize(), r.add(T);
718
+ const A = new O.AmbientLight(4210752);
719
+ r.add(A);
720
+ }
721
+ t("init", {
722
+ scene: r,
723
+ camera: a,
724
+ renderer: c,
725
+ controls: h
726
+ });
727
+ };
728
+ return Q(async () => {
729
+ if (!xe.isWebGL2Available()) {
730
+ const f = xe.getWebGLErrorMessage();
731
+ console.error(f);
732
+ return;
733
+ }
734
+ const g = () => {
735
+ const f = i.value, _ = f.clientWidth, x = f.clientHeight;
736
+ c.setPixelRatio(window.devicePixelRatio), c.setSize(_, x), a.aspect = _ / x, a.updateProjectionMatrix();
737
+ };
738
+ window.addEventListener("resize", g), m();
739
+ }), (g, f) => (de(), Le("div", {
740
+ ref: s,
741
+ class: "box"
742
+ }));
743
+ }
744
+ }, Us = /* @__PURE__ */ qt(Qt, [["__scopeId", "data-v-1ac174e9"]]), $t = {
745
+ __name: "VroidExpression",
746
+ props: {
747
+ command: {
748
+ type: String
749
+ },
750
+ name: {
751
+ type: String
752
+ },
753
+ url: {
754
+ type: String
755
+ },
756
+ data: {
757
+ type: [Object, null],
758
+ default: null
759
+ }
760
+ },
761
+ emits: ["loading", "loaded"],
762
+ setup(l, { emit: e }) {
763
+ const t = Pe("axios"), n = e, s = l, i = async (r) => {
764
+ if (!r)
765
+ return;
766
+ n("loading", s.name, s.command);
767
+ const c = await new Fe().loadExpression(t, r);
768
+ let h = !1;
769
+ c && (h = !0), n("loaded", s.name, s.command, h, c);
770
+ }, o = (r) => {
771
+ n("loading", s.name, s.command);
772
+ let a = !1;
773
+ r && (a = !0), n("loaded", s.name, s.command, a, r);
774
+ };
775
+ return Q(async () => {
776
+ s.data != null ? o(s.data) : i(s.url);
777
+ }), (r, a) => null;
778
+ }
779
+ }, Jt = {
780
+ __name: "VroidPose",
781
+ props: {
782
+ command: {
783
+ type: String
784
+ },
785
+ name: {
786
+ type: String
787
+ },
788
+ url: {
789
+ type: String
790
+ },
791
+ data: {
792
+ type: [Object, null],
793
+ default: null
794
+ }
795
+ },
796
+ emits: ["loading", "loaded"],
797
+ setup(l, { emit: e }) {
798
+ const t = Pe("axios"), n = e, s = l, i = async (r) => {
799
+ if (!r)
800
+ return;
801
+ n("loading", s.name, s.command);
802
+ const c = await new Fe().loadPose(t, r);
803
+ let h = !1;
804
+ c && (h = !0), n("loaded", s.name, s.command, h, c);
805
+ }, o = (r) => {
806
+ n("loading", s.name, s.command);
807
+ let a = !1;
808
+ r && (a = !0), n("loaded", s.name, s.command, a, r);
809
+ };
810
+ return Q(async () => {
811
+ s.data != null ? o(s.data) : i(s.url);
812
+ }), (r, a) => null;
813
+ }
814
+ };
815
+ function Re(l, e) {
816
+ if (e === qe)
817
+ return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), l;
818
+ if (e === ae || e === Oe) {
819
+ let t = l.getIndex();
820
+ if (t === null) {
821
+ const o = [], r = l.getAttribute("position");
822
+ if (r !== void 0) {
823
+ for (let a = 0; a < r.count; a++)
824
+ o.push(a);
825
+ l.setIndex(o), t = l.getIndex();
826
+ } else
827
+ return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), l;
828
+ }
829
+ const n = t.count - 2, s = [];
830
+ if (e === ae)
831
+ for (let o = 1; o <= n; o++)
832
+ s.push(t.getX(0)), s.push(t.getX(o)), s.push(t.getX(o + 1));
833
+ else
834
+ for (let o = 0; o < n; o++)
835
+ o % 2 === 0 ? (s.push(t.getX(o)), s.push(t.getX(o + 1)), s.push(t.getX(o + 2))) : (s.push(t.getX(o + 2)), s.push(t.getX(o + 1)), s.push(t.getX(o)));
836
+ s.length / 3 !== n && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
837
+ const i = l.clone();
838
+ return i.setIndex(s), i.clearGroups(), i;
839
+ } else
840
+ return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", e), l;
841
+ }
842
+ class es extends Qe {
843
+ /**
844
+ * Constructs a new glTF loader.
845
+ *
846
+ * @param {LoadingManager} [manager] - The loading manager.
847
+ */
848
+ constructor(e) {
849
+ super(e), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(t) {
850
+ return new os(t);
851
+ }), this.register(function(t) {
852
+ return new rs(t);
853
+ }), this.register(function(t) {
854
+ return new ms(t);
855
+ }), this.register(function(t) {
856
+ return new _s(t);
857
+ }), this.register(function(t) {
858
+ return new gs(t);
859
+ }), this.register(function(t) {
860
+ return new cs(t);
861
+ }), this.register(function(t) {
862
+ return new ls(t);
863
+ }), this.register(function(t) {
864
+ return new hs(t);
865
+ }), this.register(function(t) {
866
+ return new us(t);
867
+ }), this.register(function(t) {
868
+ return new is(t);
869
+ }), this.register(function(t) {
870
+ return new ds(t);
871
+ }), this.register(function(t) {
872
+ return new as(t);
873
+ }), this.register(function(t) {
874
+ return new fs(t);
875
+ }), this.register(function(t) {
876
+ return new ps(t);
877
+ }), this.register(function(t) {
878
+ return new ss(t);
879
+ }), this.register(function(t) {
880
+ return new Ts(t);
881
+ }), this.register(function(t) {
882
+ return new ys(t);
883
+ });
884
+ }
885
+ /**
886
+ * Starts loading from the given URL and passes the loaded glTF asset
887
+ * to the `onLoad()` callback.
888
+ *
889
+ * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
890
+ * @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
891
+ * @param {onProgressCallback} onProgress - Executed while the loading is in progress.
892
+ * @param {onErrorCallback} onError - Executed when errors occur.
893
+ */
894
+ load(e, t, n, s) {
895
+ const i = this;
896
+ let o;
897
+ if (this.resourcePath !== "")
898
+ o = this.resourcePath;
899
+ else if (this.path !== "") {
900
+ const c = z.extractUrlBase(e);
901
+ o = z.resolveURL(c, this.path);
902
+ } else
903
+ o = z.extractUrlBase(e);
904
+ this.manager.itemStart(e);
905
+ const r = function(c) {
906
+ s ? s(c) : console.error(c), i.manager.itemError(e), i.manager.itemEnd(e);
907
+ }, a = new De(this.manager);
908
+ a.setPath(this.path), a.setResponseType("arraybuffer"), a.setRequestHeader(this.requestHeader), a.setWithCredentials(this.withCredentials), a.load(e, function(c) {
909
+ try {
910
+ i.parse(c, o, function(h) {
911
+ t(h), i.manager.itemEnd(e);
912
+ }, r);
913
+ } catch (h) {
914
+ r(h);
915
+ }
916
+ }, n, r);
917
+ }
918
+ /**
919
+ * Sets the given Draco loader to this loader. Required for decoding assets
920
+ * compressed with the `KHR_draco_mesh_compression` extension.
921
+ *
922
+ * @param {DRACOLoader} dracoLoader - The Draco loader to set.
923
+ * @return {GLTFLoader} A reference to this loader.
924
+ */
925
+ setDRACOLoader(e) {
926
+ return this.dracoLoader = e, this;
927
+ }
928
+ /**
929
+ * Sets the given KTX2 loader to this loader. Required for loading KTX2
930
+ * compressed textures.
931
+ *
932
+ * @param {KTX2Loader} ktx2Loader - The KTX2 loader to set.
933
+ * @return {GLTFLoader} A reference to this loader.
934
+ */
935
+ setKTX2Loader(e) {
936
+ return this.ktx2Loader = e, this;
937
+ }
938
+ /**
939
+ * Sets the given meshopt decoder. Required for decoding assets
940
+ * compressed with the `EXT_meshopt_compression` extension.
941
+ *
942
+ * @param {Object} meshoptDecoder - The meshopt decoder to set.
943
+ * @return {GLTFLoader} A reference to this loader.
944
+ */
945
+ setMeshoptDecoder(e) {
946
+ return this.meshoptDecoder = e, this;
947
+ }
948
+ /**
949
+ * Registers a plugin callback. This API is internally used to implement the various
950
+ * glTF extensions but can also used by third-party code to add additional logic
951
+ * to the loader.
952
+ *
953
+ * @param {function(parser:GLTFParser)} callback - The callback function to register.
954
+ * @return {GLTFLoader} A reference to this loader.
955
+ */
956
+ register(e) {
957
+ return this.pluginCallbacks.indexOf(e) === -1 && this.pluginCallbacks.push(e), this;
958
+ }
959
+ /**
960
+ * Unregisters a plugin callback.
961
+ *
962
+ * @param {Function} callback - The callback function to unregister.
963
+ * @return {GLTFLoader} A reference to this loader.
964
+ */
965
+ unregister(e) {
966
+ return this.pluginCallbacks.indexOf(e) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e), 1), this;
967
+ }
968
+ /**
969
+ * Parses the given FBX data and returns the resulting group.
970
+ *
971
+ * @param {string|ArrayBuffer} data - The raw glTF data.
972
+ * @param {string} path - The URL base path.
973
+ * @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
974
+ * @param {onErrorCallback} onError - Executed when errors occur.
975
+ */
976
+ parse(e, t, n, s) {
977
+ let i;
978
+ const o = {}, r = {}, a = new TextDecoder();
979
+ if (typeof e == "string")
980
+ i = JSON.parse(e);
981
+ else if (e instanceof ArrayBuffer)
982
+ if (a.decode(new Uint8Array(e, 0, 4)) === Ue) {
983
+ try {
984
+ o[y.KHR_BINARY_GLTF] = new xs(e);
985
+ } catch (u) {
986
+ s && s(u);
987
+ return;
988
+ }
989
+ i = JSON.parse(o[y.KHR_BINARY_GLTF].content);
990
+ } else
991
+ i = JSON.parse(a.decode(e));
992
+ else
993
+ i = e;
994
+ if (i.asset === void 0 || i.asset.version[0] < 2) {
995
+ s && s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
996
+ return;
997
+ }
998
+ const c = new Cs(i, {
999
+ path: t || this.resourcePath || "",
1000
+ crossOrigin: this.crossOrigin,
1001
+ requestHeader: this.requestHeader,
1002
+ manager: this.manager,
1003
+ ktx2Loader: this.ktx2Loader,
1004
+ meshoptDecoder: this.meshoptDecoder
1005
+ });
1006
+ c.fileLoader.setRequestHeader(this.requestHeader);
1007
+ for (let h = 0; h < this.pluginCallbacks.length; h++) {
1008
+ const u = this.pluginCallbacks[h](c);
1009
+ u.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), r[u.name] = u, o[u.name] = !0;
1010
+ }
1011
+ if (i.extensionsUsed)
1012
+ for (let h = 0; h < i.extensionsUsed.length; ++h) {
1013
+ const u = i.extensionsUsed[h], d = i.extensionsRequired || [];
1014
+ switch (u) {
1015
+ case y.KHR_MATERIALS_UNLIT:
1016
+ o[u] = new ns();
1017
+ break;
1018
+ case y.KHR_DRACO_MESH_COMPRESSION:
1019
+ o[u] = new Es(i, this.dracoLoader);
1020
+ break;
1021
+ case y.KHR_TEXTURE_TRANSFORM:
1022
+ o[u] = new bs();
1023
+ break;
1024
+ case y.KHR_MESH_QUANTIZATION:
1025
+ o[u] = new Rs();
1026
+ break;
1027
+ default:
1028
+ d.indexOf(u) >= 0 && r[u] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + u + '".');
1029
+ }
1030
+ }
1031
+ c.setExtensions(o), c.setPlugins(r), c.parse(n, s);
1032
+ }
1033
+ /**
1034
+ * Async version of {@link GLTFLoader#parse}.
1035
+ *
1036
+ * @async
1037
+ * @param {string|ArrayBuffer} data - The raw glTF data.
1038
+ * @param {string} path - The URL base path.
1039
+ * @return {Promise<GLTFLoader~LoadObject>} A Promise that resolves with the loaded glTF when the parsing has been finished.
1040
+ */
1041
+ parseAsync(e, t) {
1042
+ const n = this;
1043
+ return new Promise(function(s, i) {
1044
+ n.parse(e, t, s, i);
1045
+ });
1046
+ }
1047
+ }
1048
+ function ts() {
1049
+ let l = {};
1050
+ return {
1051
+ get: function(e) {
1052
+ return l[e];
1053
+ },
1054
+ add: function(e, t) {
1055
+ l[e] = t;
1056
+ },
1057
+ remove: function(e) {
1058
+ delete l[e];
1059
+ },
1060
+ removeAll: function() {
1061
+ l = {};
1062
+ }
1063
+ };
1064
+ }
1065
+ const y = {
1066
+ KHR_BINARY_GLTF: "KHR_binary_glTF",
1067
+ KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
1068
+ KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
1069
+ KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
1070
+ KHR_MATERIALS_DISPERSION: "KHR_materials_dispersion",
1071
+ KHR_MATERIALS_IOR: "KHR_materials_ior",
1072
+ KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
1073
+ KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
1074
+ KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
1075
+ KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
1076
+ KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy",
1077
+ KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
1078
+ KHR_MATERIALS_VOLUME: "KHR_materials_volume",
1079
+ KHR_TEXTURE_BASISU: "KHR_texture_basisu",
1080
+ KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
1081
+ KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
1082
+ KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
1083
+ EXT_MATERIALS_BUMP: "EXT_materials_bump",
1084
+ EXT_TEXTURE_WEBP: "EXT_texture_webp",
1085
+ EXT_TEXTURE_AVIF: "EXT_texture_avif",
1086
+ EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
1087
+ EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
1088
+ };
1089
+ class ss {
1090
+ constructor(e) {
1091
+ this.parser = e, this.name = y.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} };
1092
+ }
1093
+ _markDefs() {
1094
+ const e = this.parser, t = this.parser.json.nodes || [];
1095
+ for (let n = 0, s = t.length; n < s; n++) {
1096
+ const i = t[n];
1097
+ i.extensions && i.extensions[this.name] && i.extensions[this.name].light !== void 0 && e._addNodeRef(this.cache, i.extensions[this.name].light);
1098
+ }
1099
+ }
1100
+ _loadLight(e) {
1101
+ const t = this.parser, n = "light:" + e;
1102
+ let s = t.cache.get(n);
1103
+ if (s) return s;
1104
+ const i = t.json, a = ((i.extensions && i.extensions[this.name] || {}).lights || [])[e];
1105
+ let c;
1106
+ const h = new F(16777215);
1107
+ a.color !== void 0 && h.setRGB(a.color[0], a.color[1], a.color[2], C);
1108
+ const u = a.range !== void 0 ? a.range : 0;
1109
+ switch (a.type) {
1110
+ case "directional":
1111
+ c = new et(h), c.target.position.set(0, 0, -1), c.add(c.target);
1112
+ break;
1113
+ case "point":
1114
+ c = new Je(h), c.distance = u;
1115
+ break;
1116
+ case "spot":
1117
+ c = new $e(h), c.distance = u, a.spot = a.spot || {}, a.spot.innerConeAngle = a.spot.innerConeAngle !== void 0 ? a.spot.innerConeAngle : 0, a.spot.outerConeAngle = a.spot.outerConeAngle !== void 0 ? a.spot.outerConeAngle : Math.PI / 4, c.angle = a.spot.outerConeAngle, c.penumbra = 1 - a.spot.innerConeAngle / a.spot.outerConeAngle, c.target.position.set(0, 0, -1), c.add(c.target);
1118
+ break;
1119
+ default:
1120
+ throw new Error("THREE.GLTFLoader: Unexpected light type: " + a.type);
1121
+ }
1122
+ return c.position.set(0, 0, 0), D(c, a), a.intensity !== void 0 && (c.intensity = a.intensity), c.name = t.createUniqueName(a.name || "light_" + e), s = Promise.resolve(c), t.cache.add(n, s), s;
1123
+ }
1124
+ getDependency(e, t) {
1125
+ if (e === "light")
1126
+ return this._loadLight(t);
1127
+ }
1128
+ createNodeAttachment(e) {
1129
+ const t = this, n = this.parser, i = n.json.nodes[e], r = (i.extensions && i.extensions[this.name] || {}).light;
1130
+ return r === void 0 ? null : this._loadLight(r).then(function(a) {
1131
+ return n._getNodeRef(t.cache, r, a);
1132
+ });
1133
+ }
1134
+ }
1135
+ class ns {
1136
+ constructor() {
1137
+ this.name = y.KHR_MATERIALS_UNLIT;
1138
+ }
1139
+ getMaterialType() {
1140
+ return V;
1141
+ }
1142
+ extendParams(e, t, n) {
1143
+ const s = [];
1144
+ e.color = new F(1, 1, 1), e.opacity = 1;
1145
+ const i = t.pbrMetallicRoughness;
1146
+ if (i) {
1147
+ if (Array.isArray(i.baseColorFactor)) {
1148
+ const o = i.baseColorFactor;
1149
+ e.color.setRGB(o[0], o[1], o[2], C), e.opacity = o[3];
1150
+ }
1151
+ i.baseColorTexture !== void 0 && s.push(n.assignTexture(e, "map", i.baseColorTexture, X));
1152
+ }
1153
+ return Promise.all(s);
1154
+ }
1155
+ }
1156
+ class is {
1157
+ constructor(e) {
1158
+ this.parser = e, this.name = y.KHR_MATERIALS_EMISSIVE_STRENGTH;
1159
+ }
1160
+ extendMaterialParams(e, t) {
1161
+ const s = this.parser.json.materials[e];
1162
+ if (!s.extensions || !s.extensions[this.name])
1163
+ return Promise.resolve();
1164
+ const i = s.extensions[this.name].emissiveStrength;
1165
+ return i !== void 0 && (t.emissiveIntensity = i), Promise.resolve();
1166
+ }
1167
+ }
1168
+ class os {
1169
+ constructor(e) {
1170
+ this.parser = e, this.name = y.KHR_MATERIALS_CLEARCOAT;
1171
+ }
1172
+ getMaterialType(e) {
1173
+ const n = this.parser.json.materials[e];
1174
+ return !n.extensions || !n.extensions[this.name] ? null : N;
1175
+ }
1176
+ extendMaterialParams(e, t) {
1177
+ const n = this.parser, s = n.json.materials[e];
1178
+ if (!s.extensions || !s.extensions[this.name])
1179
+ return Promise.resolve();
1180
+ const i = [], o = s.extensions[this.name];
1181
+ if (o.clearcoatFactor !== void 0 && (t.clearcoat = o.clearcoatFactor), o.clearcoatTexture !== void 0 && i.push(n.assignTexture(t, "clearcoatMap", o.clearcoatTexture)), o.clearcoatRoughnessFactor !== void 0 && (t.clearcoatRoughness = o.clearcoatRoughnessFactor), o.clearcoatRoughnessTexture !== void 0 && i.push(n.assignTexture(t, "clearcoatRoughnessMap", o.clearcoatRoughnessTexture)), o.clearcoatNormalTexture !== void 0 && (i.push(n.assignTexture(t, "clearcoatNormalMap", o.clearcoatNormalTexture)), o.clearcoatNormalTexture.scale !== void 0)) {
1182
+ const r = o.clearcoatNormalTexture.scale;
1183
+ t.clearcoatNormalScale = new S(r, r);
1184
+ }
1185
+ return Promise.all(i);
1186
+ }
1187
+ }
1188
+ class rs {
1189
+ constructor(e) {
1190
+ this.parser = e, this.name = y.KHR_MATERIALS_DISPERSION;
1191
+ }
1192
+ getMaterialType(e) {
1193
+ const n = this.parser.json.materials[e];
1194
+ return !n.extensions || !n.extensions[this.name] ? null : N;
1195
+ }
1196
+ extendMaterialParams(e, t) {
1197
+ const s = this.parser.json.materials[e];
1198
+ if (!s.extensions || !s.extensions[this.name])
1199
+ return Promise.resolve();
1200
+ const i = s.extensions[this.name];
1201
+ return t.dispersion = i.dispersion !== void 0 ? i.dispersion : 0, Promise.resolve();
1202
+ }
1203
+ }
1204
+ class as {
1205
+ constructor(e) {
1206
+ this.parser = e, this.name = y.KHR_MATERIALS_IRIDESCENCE;
1207
+ }
1208
+ getMaterialType(e) {
1209
+ const n = this.parser.json.materials[e];
1210
+ return !n.extensions || !n.extensions[this.name] ? null : N;
1211
+ }
1212
+ extendMaterialParams(e, t) {
1213
+ const n = this.parser, s = n.json.materials[e];
1214
+ if (!s.extensions || !s.extensions[this.name])
1215
+ return Promise.resolve();
1216
+ const i = [], o = s.extensions[this.name];
1217
+ return o.iridescenceFactor !== void 0 && (t.iridescence = o.iridescenceFactor), o.iridescenceTexture !== void 0 && i.push(n.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(n.assignTexture(t, "iridescenceThicknessMap", o.iridescenceThicknessTexture)), Promise.all(i);
1218
+ }
1219
+ }
1220
+ class cs {
1221
+ constructor(e) {
1222
+ this.parser = e, this.name = y.KHR_MATERIALS_SHEEN;
1223
+ }
1224
+ getMaterialType(e) {
1225
+ const n = this.parser.json.materials[e];
1226
+ return !n.extensions || !n.extensions[this.name] ? null : N;
1227
+ }
1228
+ extendMaterialParams(e, t) {
1229
+ const n = this.parser, s = n.json.materials[e];
1230
+ if (!s.extensions || !s.extensions[this.name])
1231
+ return Promise.resolve();
1232
+ const i = [];
1233
+ t.sheenColor = new F(0, 0, 0), t.sheenRoughness = 0, t.sheen = 1;
1234
+ const o = s.extensions[this.name];
1235
+ if (o.sheenColorFactor !== void 0) {
1236
+ const r = o.sheenColorFactor;
1237
+ t.sheenColor.setRGB(r[0], r[1], r[2], C);
1238
+ }
1239
+ return o.sheenRoughnessFactor !== void 0 && (t.sheenRoughness = o.sheenRoughnessFactor), o.sheenColorTexture !== void 0 && i.push(n.assignTexture(t, "sheenColorMap", o.sheenColorTexture, X)), o.sheenRoughnessTexture !== void 0 && i.push(n.assignTexture(t, "sheenRoughnessMap", o.sheenRoughnessTexture)), Promise.all(i);
1240
+ }
1241
+ }
1242
+ class ls {
1243
+ constructor(e) {
1244
+ this.parser = e, this.name = y.KHR_MATERIALS_TRANSMISSION;
1245
+ }
1246
+ getMaterialType(e) {
1247
+ const n = this.parser.json.materials[e];
1248
+ return !n.extensions || !n.extensions[this.name] ? null : N;
1249
+ }
1250
+ extendMaterialParams(e, t) {
1251
+ const n = this.parser, s = n.json.materials[e];
1252
+ if (!s.extensions || !s.extensions[this.name])
1253
+ return Promise.resolve();
1254
+ const i = [], o = s.extensions[this.name];
1255
+ return o.transmissionFactor !== void 0 && (t.transmission = o.transmissionFactor), o.transmissionTexture !== void 0 && i.push(n.assignTexture(t, "transmissionMap", o.transmissionTexture)), Promise.all(i);
1256
+ }
1257
+ }
1258
+ class hs {
1259
+ constructor(e) {
1260
+ this.parser = e, this.name = y.KHR_MATERIALS_VOLUME;
1261
+ }
1262
+ getMaterialType(e) {
1263
+ const n = this.parser.json.materials[e];
1264
+ return !n.extensions || !n.extensions[this.name] ? null : N;
1265
+ }
1266
+ extendMaterialParams(e, t) {
1267
+ const n = this.parser, s = n.json.materials[e];
1268
+ if (!s.extensions || !s.extensions[this.name])
1269
+ return Promise.resolve();
1270
+ const i = [], o = s.extensions[this.name];
1271
+ t.thickness = o.thicknessFactor !== void 0 ? o.thicknessFactor : 0, o.thicknessTexture !== void 0 && i.push(n.assignTexture(t, "thicknessMap", o.thicknessTexture)), t.attenuationDistance = o.attenuationDistance || 1 / 0;
1272
+ const r = o.attenuationColor || [1, 1, 1];
1273
+ return t.attenuationColor = new F().setRGB(r[0], r[1], r[2], C), Promise.all(i);
1274
+ }
1275
+ }
1276
+ class us {
1277
+ constructor(e) {
1278
+ this.parser = e, this.name = y.KHR_MATERIALS_IOR;
1279
+ }
1280
+ getMaterialType(e) {
1281
+ const n = this.parser.json.materials[e];
1282
+ return !n.extensions || !n.extensions[this.name] ? null : N;
1283
+ }
1284
+ extendMaterialParams(e, t) {
1285
+ const s = this.parser.json.materials[e];
1286
+ if (!s.extensions || !s.extensions[this.name])
1287
+ return Promise.resolve();
1288
+ const i = s.extensions[this.name];
1289
+ return t.ior = i.ior !== void 0 ? i.ior : 1.5, Promise.resolve();
1290
+ }
1291
+ }
1292
+ class ds {
1293
+ constructor(e) {
1294
+ this.parser = e, this.name = y.KHR_MATERIALS_SPECULAR;
1295
+ }
1296
+ getMaterialType(e) {
1297
+ const n = this.parser.json.materials[e];
1298
+ return !n.extensions || !n.extensions[this.name] ? null : N;
1299
+ }
1300
+ extendMaterialParams(e, t) {
1301
+ const n = this.parser, s = n.json.materials[e];
1302
+ if (!s.extensions || !s.extensions[this.name])
1303
+ return Promise.resolve();
1304
+ const i = [], o = s.extensions[this.name];
1305
+ t.specularIntensity = o.specularFactor !== void 0 ? o.specularFactor : 1, o.specularTexture !== void 0 && i.push(n.assignTexture(t, "specularIntensityMap", o.specularTexture));
1306
+ const r = o.specularColorFactor || [1, 1, 1];
1307
+ return t.specularColor = new F().setRGB(r[0], r[1], r[2], C), o.specularColorTexture !== void 0 && i.push(n.assignTexture(t, "specularColorMap", o.specularColorTexture, X)), Promise.all(i);
1308
+ }
1309
+ }
1310
+ class ps {
1311
+ constructor(e) {
1312
+ this.parser = e, this.name = y.EXT_MATERIALS_BUMP;
1313
+ }
1314
+ getMaterialType(e) {
1315
+ const n = this.parser.json.materials[e];
1316
+ return !n.extensions || !n.extensions[this.name] ? null : N;
1317
+ }
1318
+ extendMaterialParams(e, t) {
1319
+ const n = this.parser, s = n.json.materials[e];
1320
+ if (!s.extensions || !s.extensions[this.name])
1321
+ return Promise.resolve();
1322
+ const i = [], o = s.extensions[this.name];
1323
+ return t.bumpScale = o.bumpFactor !== void 0 ? o.bumpFactor : 1, o.bumpTexture !== void 0 && i.push(n.assignTexture(t, "bumpMap", o.bumpTexture)), Promise.all(i);
1324
+ }
1325
+ }
1326
+ class fs {
1327
+ constructor(e) {
1328
+ this.parser = e, this.name = y.KHR_MATERIALS_ANISOTROPY;
1329
+ }
1330
+ getMaterialType(e) {
1331
+ const n = this.parser.json.materials[e];
1332
+ return !n.extensions || !n.extensions[this.name] ? null : N;
1333
+ }
1334
+ extendMaterialParams(e, t) {
1335
+ const n = this.parser, s = n.json.materials[e];
1336
+ if (!s.extensions || !s.extensions[this.name])
1337
+ return Promise.resolve();
1338
+ const i = [], o = s.extensions[this.name];
1339
+ return o.anisotropyStrength !== void 0 && (t.anisotropy = o.anisotropyStrength), o.anisotropyRotation !== void 0 && (t.anisotropyRotation = o.anisotropyRotation), o.anisotropyTexture !== void 0 && i.push(n.assignTexture(t, "anisotropyMap", o.anisotropyTexture)), Promise.all(i);
1340
+ }
1341
+ }
1342
+ class ms {
1343
+ constructor(e) {
1344
+ this.parser = e, this.name = y.KHR_TEXTURE_BASISU;
1345
+ }
1346
+ loadTexture(e) {
1347
+ const t = this.parser, n = t.json, s = n.textures[e];
1348
+ if (!s.extensions || !s.extensions[this.name])
1349
+ return null;
1350
+ const i = s.extensions[this.name], o = t.options.ktx2Loader;
1351
+ if (!o) {
1352
+ if (n.extensionsRequired && n.extensionsRequired.indexOf(this.name) >= 0)
1353
+ throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
1354
+ return null;
1355
+ }
1356
+ return t.loadTextureImage(e, i.source, o);
1357
+ }
1358
+ }
1359
+ class _s {
1360
+ constructor(e) {
1361
+ this.parser = e, this.name = y.EXT_TEXTURE_WEBP;
1362
+ }
1363
+ loadTexture(e) {
1364
+ const t = this.name, n = this.parser, s = n.json, i = s.textures[e];
1365
+ if (!i.extensions || !i.extensions[t])
1366
+ return null;
1367
+ const o = i.extensions[t], r = s.images[o.source];
1368
+ let a = n.textureLoader;
1369
+ if (r.uri) {
1370
+ const c = n.options.manager.getHandler(r.uri);
1371
+ c !== null && (a = c);
1372
+ }
1373
+ return n.loadTextureImage(e, o.source, a);
1374
+ }
1375
+ }
1376
+ class gs {
1377
+ constructor(e) {
1378
+ this.parser = e, this.name = y.EXT_TEXTURE_AVIF;
1379
+ }
1380
+ loadTexture(e) {
1381
+ const t = this.name, n = this.parser, s = n.json, i = s.textures[e];
1382
+ if (!i.extensions || !i.extensions[t])
1383
+ return null;
1384
+ const o = i.extensions[t], r = s.images[o.source];
1385
+ let a = n.textureLoader;
1386
+ if (r.uri) {
1387
+ const c = n.options.manager.getHandler(r.uri);
1388
+ c !== null && (a = c);
1389
+ }
1390
+ return n.loadTextureImage(e, o.source, a);
1391
+ }
1392
+ }
1393
+ class Ts {
1394
+ constructor(e) {
1395
+ this.name = y.EXT_MESHOPT_COMPRESSION, this.parser = e;
1396
+ }
1397
+ loadBufferView(e) {
1398
+ const t = this.parser.json, n = t.bufferViews[e];
1399
+ if (n.extensions && n.extensions[this.name]) {
1400
+ const s = n.extensions[this.name], i = this.parser.getDependency("buffer", s.buffer), o = this.parser.options.meshoptDecoder;
1401
+ if (!o || !o.supported) {
1402
+ if (t.extensionsRequired && t.extensionsRequired.indexOf(this.name) >= 0)
1403
+ throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
1404
+ return null;
1405
+ }
1406
+ return i.then(function(r) {
1407
+ const a = s.byteOffset || 0, c = s.byteLength || 0, h = s.count, u = s.byteStride, d = new Uint8Array(r, a, c);
1408
+ return o.decodeGltfBufferAsync ? o.decodeGltfBufferAsync(h, u, d, s.mode, s.filter).then(function(p) {
1409
+ return p.buffer;
1410
+ }) : o.ready.then(function() {
1411
+ const p = new ArrayBuffer(h * u);
1412
+ return o.decodeGltfBuffer(new Uint8Array(p), h, u, d, s.mode, s.filter), p;
1413
+ });
1414
+ });
1415
+ } else
1416
+ return null;
1417
+ }
1418
+ }
1419
+ class ys {
1420
+ constructor(e) {
1421
+ this.name = y.EXT_MESH_GPU_INSTANCING, this.parser = e;
1422
+ }
1423
+ createNodeMesh(e) {
1424
+ const t = this.parser.json, n = t.nodes[e];
1425
+ if (!n.extensions || !n.extensions[this.name] || n.mesh === void 0)
1426
+ return null;
1427
+ const s = t.meshes[n.mesh];
1428
+ for (const c of s.primitives)
1429
+ if (c.mode !== L.TRIANGLES && c.mode !== L.TRIANGLE_STRIP && c.mode !== L.TRIANGLE_FAN && c.mode !== void 0)
1430
+ return null;
1431
+ const o = n.extensions[this.name].attributes, r = [], a = {};
1432
+ for (const c in o)
1433
+ r.push(this.parser.getDependency("accessor", o[c]).then((h) => (a[c] = h, a[c])));
1434
+ return r.length < 1 ? null : (r.push(this.parser.createNodeMesh(e)), Promise.all(r).then((c) => {
1435
+ const h = c.pop(), u = h.isGroup ? h.children : [h], d = c[0].count, p = [];
1436
+ for (const m of u) {
1437
+ const g = new q(), f = new M(), _ = new Z(), x = new M(1, 1, 1), b = new tt(m.geometry, m.material, d);
1438
+ for (let T = 0; T < d; T++)
1439
+ a.TRANSLATION && f.fromBufferAttribute(a.TRANSLATION, T), a.ROTATION && _.fromBufferAttribute(a.ROTATION, T), a.SCALE && x.fromBufferAttribute(a.SCALE, T), b.setMatrixAt(T, g.compose(f, _, x));
1440
+ for (const T in a)
1441
+ if (T === "_COLOR_0") {
1442
+ const A = a[T];
1443
+ b.instanceColor = new st(A.array, A.itemSize, A.normalized);
1444
+ } else T !== "TRANSLATION" && T !== "ROTATION" && T !== "SCALE" && m.geometry.setAttribute(T, a[T]);
1445
+ Ce.prototype.copy.call(b, m), this.parser.assignFinalMaterial(b), p.push(b);
1446
+ }
1447
+ return h.isGroup ? (h.clear(), h.add(...p), h) : p[0];
1448
+ }));
1449
+ }
1450
+ }
1451
+ const Ue = "glTF", B = 12, Me = { JSON: 1313821514, BIN: 5130562 };
1452
+ class xs {
1453
+ constructor(e) {
1454
+ this.name = y.KHR_BINARY_GLTF, this.content = null, this.body = null;
1455
+ const t = new DataView(e, 0, B), n = new TextDecoder();
1456
+ if (this.header = {
1457
+ magic: n.decode(new Uint8Array(e.slice(0, 4))),
1458
+ version: t.getUint32(4, !0),
1459
+ length: t.getUint32(8, !0)
1460
+ }, this.header.magic !== Ue)
1461
+ throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
1462
+ if (this.header.version < 2)
1463
+ throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
1464
+ const s = this.header.length - B, i = new DataView(e, B);
1465
+ let o = 0;
1466
+ for (; o < s; ) {
1467
+ const r = i.getUint32(o, !0);
1468
+ o += 4;
1469
+ const a = i.getUint32(o, !0);
1470
+ if (o += 4, a === Me.JSON) {
1471
+ const c = new Uint8Array(e, B + o, r);
1472
+ this.content = n.decode(c);
1473
+ } else if (a === Me.BIN) {
1474
+ const c = B + o;
1475
+ this.body = e.slice(c, c + r);
1476
+ }
1477
+ o += r;
1478
+ }
1479
+ if (this.content === null)
1480
+ throw new Error("THREE.GLTFLoader: JSON content not found.");
1481
+ }
1482
+ }
1483
+ class Es {
1484
+ constructor(e, t) {
1485
+ if (!t)
1486
+ throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
1487
+ this.name = y.KHR_DRACO_MESH_COMPRESSION, this.json = e, this.dracoLoader = t, this.dracoLoader.preload();
1488
+ }
1489
+ decodePrimitive(e, t) {
1490
+ const n = this.json, s = this.dracoLoader, i = e.extensions[this.name].bufferView, o = e.extensions[this.name].attributes, r = {}, a = {}, c = {};
1491
+ for (const h in o) {
1492
+ const u = he[h] || h.toLowerCase();
1493
+ r[u] = o[h];
1494
+ }
1495
+ for (const h in e.attributes) {
1496
+ const u = he[h] || h.toLowerCase();
1497
+ if (o[h] !== void 0) {
1498
+ const d = n.accessors[e.attributes[h]], p = G[d.componentType];
1499
+ c[u] = p.name, a[u] = d.normalized === !0;
1500
+ }
1501
+ }
1502
+ return t.getDependency("bufferView", i).then(function(h) {
1503
+ return new Promise(function(u, d) {
1504
+ s.decodeDracoFile(h, function(p) {
1505
+ for (const m in p.attributes) {
1506
+ const g = p.attributes[m], f = a[m];
1507
+ f !== void 0 && (g.normalized = f);
1508
+ }
1509
+ u(p);
1510
+ }, r, c, C, d);
1511
+ });
1512
+ });
1513
+ }
1514
+ }
1515
+ class bs {
1516
+ constructor() {
1517
+ this.name = y.KHR_TEXTURE_TRANSFORM;
1518
+ }
1519
+ extendTexture(e, t) {
1520
+ 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;
1521
+ }
1522
+ }
1523
+ class Rs {
1524
+ constructor() {
1525
+ this.name = y.KHR_MESH_QUANTIZATION;
1526
+ }
1527
+ }
1528
+ class Ge extends Nt {
1529
+ constructor(e, t, n, s) {
1530
+ super(e, t, n, s);
1531
+ }
1532
+ copySampleValue_(e) {
1533
+ const t = this.resultBuffer, n = this.sampleValues, s = this.valueSize, i = e * s * 3 + s;
1534
+ for (let o = 0; o !== s; o++)
1535
+ t[o] = n[i + o];
1536
+ return t;
1537
+ }
1538
+ interpolate_(e, t, n, s) {
1539
+ const i = this.resultBuffer, o = this.sampleValues, r = this.valueSize, a = r * 2, c = r * 3, h = s - t, u = (n - t) / h, d = u * u, p = d * u, m = e * c, g = m - c, f = -2 * p + 3 * d, _ = p - d, x = 1 - f, b = _ - d + u;
1540
+ for (let T = 0; T !== r; T++) {
1541
+ const A = o[g + T + r], I = o[g + T + a] * h, P = o[m + T + r], K = o[m + T] * h;
1542
+ i[T] = x * A + b * I + f * P + _ * K;
1543
+ }
1544
+ return i;
1545
+ }
1546
+ }
1547
+ const Ms = new Z();
1548
+ class ws extends Ge {
1549
+ interpolate_(e, t, n, s) {
1550
+ const i = super.interpolate_(e, t, n, s);
1551
+ return Ms.fromArray(i).normalize().toArray(i), i;
1552
+ }
1553
+ }
1554
+ const L = {
1555
+ POINTS: 0,
1556
+ LINES: 1,
1557
+ LINE_LOOP: 2,
1558
+ LINE_STRIP: 3,
1559
+ TRIANGLES: 4,
1560
+ TRIANGLE_STRIP: 5,
1561
+ TRIANGLE_FAN: 6
1562
+ }, G = {
1563
+ 5120: Int8Array,
1564
+ 5121: Uint8Array,
1565
+ 5122: Int16Array,
1566
+ 5123: Uint16Array,
1567
+ 5125: Uint32Array,
1568
+ 5126: Float32Array
1569
+ }, we = {
1570
+ 9728: ve,
1571
+ 9729: ce,
1572
+ 9984: lt,
1573
+ 9985: ct,
1574
+ 9986: at,
1575
+ 9987: Ie
1576
+ }, Se = {
1577
+ 33071: ut,
1578
+ 33648: ht,
1579
+ 10497: le
1580
+ }, ie = {
1581
+ SCALAR: 1,
1582
+ VEC2: 2,
1583
+ VEC3: 3,
1584
+ VEC4: 4,
1585
+ MAT2: 4,
1586
+ MAT3: 9,
1587
+ MAT4: 16
1588
+ }, he = {
1589
+ POSITION: "position",
1590
+ NORMAL: "normal",
1591
+ TANGENT: "tangent",
1592
+ TEXCOORD_0: "uv",
1593
+ TEXCOORD_1: "uv1",
1594
+ TEXCOORD_2: "uv2",
1595
+ TEXCOORD_3: "uv3",
1596
+ COLOR_0: "color",
1597
+ WEIGHTS_0: "skinWeight",
1598
+ JOINTS_0: "skinIndex"
1599
+ }, k = {
1600
+ scale: "scale",
1601
+ translation: "position",
1602
+ rotation: "quaternion",
1603
+ weights: "morphTargetInfluences"
1604
+ }, Ss = {
1605
+ CUBICSPLINE: void 0,
1606
+ // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
1607
+ // keyframe track will be initialized with a default interpolation type, then modified.
1608
+ LINEAR: je,
1609
+ STEP: Lt
1610
+ }, oe = {
1611
+ OPAQUE: "OPAQUE",
1612
+ MASK: "MASK",
1613
+ BLEND: "BLEND"
1614
+ };
1615
+ function As(l) {
1616
+ return l.DefaultMaterial === void 0 && (l.DefaultMaterial = new ke({
1617
+ color: 16777215,
1618
+ emissive: 0,
1619
+ metalness: 1,
1620
+ roughness: 1,
1621
+ transparent: !1,
1622
+ depthTest: !0,
1623
+ side: Pt
1624
+ })), l.DefaultMaterial;
1625
+ }
1626
+ function j(l, e, t) {
1627
+ for (const n in t.extensions)
1628
+ l[n] === void 0 && (e.userData.gltfExtensions = e.userData.gltfExtensions || {}, e.userData.gltfExtensions[n] = t.extensions[n]);
1629
+ }
1630
+ function D(l, e) {
1631
+ e.extras !== void 0 && (typeof e.extras == "object" ? Object.assign(l.userData, e.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + e.extras));
1632
+ }
1633
+ function Ls(l, e, t) {
1634
+ let n = !1, s = !1, i = !1;
1635
+ for (let c = 0, h = e.length; c < h; c++) {
1636
+ const u = e[c];
1637
+ if (u.POSITION !== void 0 && (n = !0), u.NORMAL !== void 0 && (s = !0), u.COLOR_0 !== void 0 && (i = !0), n && s && i) break;
1638
+ }
1639
+ if (!n && !s && !i) return Promise.resolve(l);
1640
+ const o = [], r = [], a = [];
1641
+ for (let c = 0, h = e.length; c < h; c++) {
1642
+ const u = e[c];
1643
+ if (n) {
1644
+ const d = u.POSITION !== void 0 ? t.getDependency("accessor", u.POSITION) : l.attributes.position;
1645
+ o.push(d);
1646
+ }
1647
+ if (s) {
1648
+ const d = u.NORMAL !== void 0 ? t.getDependency("accessor", u.NORMAL) : l.attributes.normal;
1649
+ r.push(d);
1650
+ }
1651
+ if (i) {
1652
+ const d = u.COLOR_0 !== void 0 ? t.getDependency("accessor", u.COLOR_0) : l.attributes.color;
1653
+ a.push(d);
1654
+ }
1655
+ }
1656
+ return Promise.all([
1657
+ Promise.all(o),
1658
+ Promise.all(r),
1659
+ Promise.all(a)
1660
+ ]).then(function(c) {
1661
+ const h = c[0], u = c[1], d = c[2];
1662
+ return n && (l.morphAttributes.position = h), s && (l.morphAttributes.normal = u), i && (l.morphAttributes.color = d), l.morphTargetsRelative = !0, l;
1663
+ });
1664
+ }
1665
+ function Ps(l, e) {
1666
+ if (l.updateMorphTargets(), e.weights !== void 0)
1667
+ for (let t = 0, n = e.weights.length; t < n; t++)
1668
+ l.morphTargetInfluences[t] = e.weights[t];
1669
+ if (e.extras && Array.isArray(e.extras.targetNames)) {
1670
+ const t = e.extras.targetNames;
1671
+ if (l.morphTargetInfluences.length === t.length) {
1672
+ l.morphTargetDictionary = {};
1673
+ for (let n = 0, s = t.length; n < s; n++)
1674
+ l.morphTargetDictionary[t[n]] = n;
1675
+ } else
1676
+ console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
1677
+ }
1678
+ }
1679
+ function Ns(l) {
1680
+ let e;
1681
+ const t = l.extensions && l.extensions[y.KHR_DRACO_MESH_COMPRESSION];
1682
+ if (t ? e = "draco:" + t.bufferView + ":" + t.indices + ":" + re(t.attributes) : e = l.indices + ":" + re(l.attributes) + ":" + l.mode, l.targets !== void 0)
1683
+ for (let n = 0, s = l.targets.length; n < s; n++)
1684
+ e += ":" + re(l.targets[n]);
1685
+ return e;
1686
+ }
1687
+ function re(l) {
1688
+ let e = "";
1689
+ const t = Object.keys(l).sort();
1690
+ for (let n = 0, s = t.length; n < s; n++)
1691
+ e += t[n] + ":" + l[t[n]] + ";";
1692
+ return e;
1693
+ }
1694
+ function ue(l) {
1695
+ switch (l) {
1696
+ case Int8Array:
1697
+ return 1 / 127;
1698
+ case Uint8Array:
1699
+ return 1 / 255;
1700
+ case Int16Array:
1701
+ return 1 / 32767;
1702
+ case Uint16Array:
1703
+ return 1 / 65535;
1704
+ default:
1705
+ throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
1706
+ }
1707
+ }
1708
+ function Os(l) {
1709
+ 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";
1710
+ }
1711
+ const Ds = new q();
1712
+ class Cs {
1713
+ constructor(e = {}, t = {}) {
1714
+ this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new ts(), 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 = {};
1715
+ let n = !1, s = -1, i = !1, o = -1;
1716
+ if (typeof navigator < "u") {
1717
+ const r = navigator.userAgent;
1718
+ n = /^((?!chrome|android).)*safari/i.test(r) === !0;
1719
+ const a = r.match(/Version\/(\d+)/);
1720
+ s = n && a ? parseInt(a[1], 10) : -1, i = r.indexOf("Firefox") > -1, o = i ? r.match(/Firefox\/([0-9]+)\./)[1] : -1;
1721
+ }
1722
+ typeof createImageBitmap > "u" || n && s < 17 || i && o < 98 ? this.textureLoader = new nt(this.options.manager) : this.textureLoader = new it(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new De(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0);
1723
+ }
1724
+ setExtensions(e) {
1725
+ this.extensions = e;
1726
+ }
1727
+ setPlugins(e) {
1728
+ this.plugins = e;
1729
+ }
1730
+ parse(e, t) {
1731
+ const n = this, s = this.json, i = this.extensions;
1732
+ this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(o) {
1733
+ return o._markDefs && o._markDefs();
1734
+ }), Promise.all(this._invokeAll(function(o) {
1735
+ return o.beforeRoot && o.beforeRoot();
1736
+ })).then(function() {
1737
+ return Promise.all([
1738
+ n.getDependencies("scene"),
1739
+ n.getDependencies("animation"),
1740
+ n.getDependencies("camera")
1741
+ ]);
1742
+ }).then(function(o) {
1743
+ const r = {
1744
+ scene: o[0][s.scene || 0],
1745
+ scenes: o[0],
1746
+ animations: o[1],
1747
+ cameras: o[2],
1748
+ asset: s.asset,
1749
+ parser: n,
1750
+ userData: {}
1751
+ };
1752
+ return j(i, r, s), D(r, s), Promise.all(n._invokeAll(function(a) {
1753
+ return a.afterRoot && a.afterRoot(r);
1754
+ })).then(function() {
1755
+ for (const a of r.scenes)
1756
+ a.updateMatrixWorld();
1757
+ e(r);
1758
+ });
1759
+ }).catch(t);
1760
+ }
1761
+ /**
1762
+ * Marks the special nodes/meshes in json for efficient parse.
1763
+ *
1764
+ * @private
1765
+ */
1766
+ _markDefs() {
1767
+ const e = this.json.nodes || [], t = this.json.skins || [], n = this.json.meshes || [];
1768
+ for (let s = 0, i = t.length; s < i; s++) {
1769
+ const o = t[s].joints;
1770
+ for (let r = 0, a = o.length; r < a; r++)
1771
+ e[o[r]].isBone = !0;
1772
+ }
1773
+ for (let s = 0, i = e.length; s < i; s++) {
1774
+ const o = e[s];
1775
+ o.mesh !== void 0 && (this._addNodeRef(this.meshCache, o.mesh), o.skin !== void 0 && (n[o.mesh].isSkinnedMesh = !0)), o.camera !== void 0 && this._addNodeRef(this.cameraCache, o.camera);
1776
+ }
1777
+ }
1778
+ /**
1779
+ * Counts references to shared node / Object3D resources. These resources
1780
+ * can be reused, or "instantiated", at multiple nodes in the scene
1781
+ * hierarchy. Mesh, Camera, and Light instances are instantiated and must
1782
+ * be marked. Non-scenegraph resources (like Materials, Geometries, and
1783
+ * Textures) can be reused directly and are not marked here.
1784
+ *
1785
+ * Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
1786
+ *
1787
+ * @private
1788
+ * @param {Object} cache
1789
+ * @param {Object3D} index
1790
+ */
1791
+ _addNodeRef(e, t) {
1792
+ t !== void 0 && (e.refs[t] === void 0 && (e.refs[t] = e.uses[t] = 0), e.refs[t]++);
1793
+ }
1794
+ /**
1795
+ * Returns a reference to a shared resource, cloning it if necessary.
1796
+ *
1797
+ * @private
1798
+ * @param {Object} cache
1799
+ * @param {number} index
1800
+ * @param {Object} object
1801
+ * @return {Object}
1802
+ */
1803
+ _getNodeRef(e, t, n) {
1804
+ if (e.refs[t] <= 1) return n;
1805
+ const s = n.clone(), i = (o, r) => {
1806
+ const a = this.associations.get(o);
1807
+ a != null && this.associations.set(r, a);
1808
+ for (const [c, h] of o.children.entries())
1809
+ i(h, r.children[c]);
1810
+ };
1811
+ return i(n, s), s.name += "_instance_" + e.uses[t]++, s;
1812
+ }
1813
+ _invokeOne(e) {
1814
+ const t = Object.values(this.plugins);
1815
+ t.push(this);
1816
+ for (let n = 0; n < t.length; n++) {
1817
+ const s = e(t[n]);
1818
+ if (s) return s;
1819
+ }
1820
+ return null;
1821
+ }
1822
+ _invokeAll(e) {
1823
+ const t = Object.values(this.plugins);
1824
+ t.unshift(this);
1825
+ const n = [];
1826
+ for (let s = 0; s < t.length; s++) {
1827
+ const i = e(t[s]);
1828
+ i && n.push(i);
1829
+ }
1830
+ return n;
1831
+ }
1832
+ /**
1833
+ * Requests the specified dependency asynchronously, with caching.
1834
+ *
1835
+ * @private
1836
+ * @param {string} type
1837
+ * @param {number} index
1838
+ * @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
1839
+ */
1840
+ getDependency(e, t) {
1841
+ const n = e + ":" + t;
1842
+ let s = this.cache.get(n);
1843
+ if (!s) {
1844
+ switch (e) {
1845
+ case "scene":
1846
+ s = this.loadScene(t);
1847
+ break;
1848
+ case "node":
1849
+ s = this._invokeOne(function(i) {
1850
+ return i.loadNode && i.loadNode(t);
1851
+ });
1852
+ break;
1853
+ case "mesh":
1854
+ s = this._invokeOne(function(i) {
1855
+ return i.loadMesh && i.loadMesh(t);
1856
+ });
1857
+ break;
1858
+ case "accessor":
1859
+ s = this.loadAccessor(t);
1860
+ break;
1861
+ case "bufferView":
1862
+ s = this._invokeOne(function(i) {
1863
+ return i.loadBufferView && i.loadBufferView(t);
1864
+ });
1865
+ break;
1866
+ case "buffer":
1867
+ s = this.loadBuffer(t);
1868
+ break;
1869
+ case "material":
1870
+ s = this._invokeOne(function(i) {
1871
+ return i.loadMaterial && i.loadMaterial(t);
1872
+ });
1873
+ break;
1874
+ case "texture":
1875
+ s = this._invokeOne(function(i) {
1876
+ return i.loadTexture && i.loadTexture(t);
1877
+ });
1878
+ break;
1879
+ case "skin":
1880
+ s = this.loadSkin(t);
1881
+ break;
1882
+ case "animation":
1883
+ s = this._invokeOne(function(i) {
1884
+ return i.loadAnimation && i.loadAnimation(t);
1885
+ });
1886
+ break;
1887
+ case "camera":
1888
+ s = this.loadCamera(t);
1889
+ break;
1890
+ default:
1891
+ if (s = this._invokeOne(function(i) {
1892
+ return i != this && i.getDependency && i.getDependency(e, t);
1893
+ }), !s)
1894
+ throw new Error("Unknown type: " + e);
1895
+ break;
1896
+ }
1897
+ this.cache.add(n, s);
1898
+ }
1899
+ return s;
1900
+ }
1901
+ /**
1902
+ * Requests all dependencies of the specified type asynchronously, with caching.
1903
+ *
1904
+ * @private
1905
+ * @param {string} type
1906
+ * @return {Promise<Array<Object>>}
1907
+ */
1908
+ getDependencies(e) {
1909
+ let t = this.cache.get(e);
1910
+ if (!t) {
1911
+ const n = this, s = this.json[e + (e === "mesh" ? "es" : "s")] || [];
1912
+ t = Promise.all(s.map(function(i, o) {
1913
+ return n.getDependency(e, o);
1914
+ })), this.cache.add(e, t);
1915
+ }
1916
+ return t;
1917
+ }
1918
+ /**
1919
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
1920
+ *
1921
+ * @private
1922
+ * @param {number} bufferIndex
1923
+ * @return {Promise<ArrayBuffer>}
1924
+ */
1925
+ loadBuffer(e) {
1926
+ const t = this.json.buffers[e], n = this.fileLoader;
1927
+ if (t.type && t.type !== "arraybuffer")
1928
+ throw new Error("THREE.GLTFLoader: " + t.type + " buffer type is not supported.");
1929
+ if (t.uri === void 0 && e === 0)
1930
+ return Promise.resolve(this.extensions[y.KHR_BINARY_GLTF].body);
1931
+ const s = this.options;
1932
+ return new Promise(function(i, o) {
1933
+ n.load(z.resolveURL(t.uri, s.path), i, void 0, function() {
1934
+ o(new Error('THREE.GLTFLoader: Failed to load buffer "' + t.uri + '".'));
1935
+ });
1936
+ });
1937
+ }
1938
+ /**
1939
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
1940
+ *
1941
+ * @private
1942
+ * @param {number} bufferViewIndex
1943
+ * @return {Promise<ArrayBuffer>}
1944
+ */
1945
+ loadBufferView(e) {
1946
+ const t = this.json.bufferViews[e];
1947
+ return this.getDependency("buffer", t.buffer).then(function(n) {
1948
+ const s = t.byteLength || 0, i = t.byteOffset || 0;
1949
+ return n.slice(i, i + s);
1950
+ });
1951
+ }
1952
+ /**
1953
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
1954
+ *
1955
+ * @private
1956
+ * @param {number} accessorIndex
1957
+ * @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
1958
+ */
1959
+ loadAccessor(e) {
1960
+ const t = this, n = this.json, s = this.json.accessors[e];
1961
+ if (s.bufferView === void 0 && s.sparse === void 0) {
1962
+ const o = ie[s.type], r = G[s.componentType], a = s.normalized === !0, c = new r(s.count * o);
1963
+ return Promise.resolve(new ee(c, o, a));
1964
+ }
1965
+ const i = [];
1966
+ return s.bufferView !== void 0 ? i.push(this.getDependency("bufferView", s.bufferView)) : i.push(null), s.sparse !== void 0 && (i.push(this.getDependency("bufferView", s.sparse.indices.bufferView)), i.push(this.getDependency("bufferView", s.sparse.values.bufferView))), Promise.all(i).then(function(o) {
1967
+ const r = o[0], a = ie[s.type], c = G[s.componentType], h = c.BYTES_PER_ELEMENT, u = h * a, d = s.byteOffset || 0, p = s.bufferView !== void 0 ? n.bufferViews[s.bufferView].byteStride : void 0, m = s.normalized === !0;
1968
+ let g, f;
1969
+ if (p && p !== u) {
1970
+ const _ = Math.floor(d / p), x = "InterleavedBuffer:" + s.bufferView + ":" + s.componentType + ":" + _ + ":" + s.count;
1971
+ let b = t.cache.get(x);
1972
+ b || (g = new c(r, _ * p, s.count * p / h), b = new ot(g, p / h), t.cache.add(x, b)), f = new rt(b, a, d % p / h, m);
1973
+ } else
1974
+ r === null ? g = new c(s.count * a) : g = new c(r, d, s.count * a), f = new ee(g, a, m);
1975
+ if (s.sparse !== void 0) {
1976
+ const _ = ie.SCALAR, x = G[s.sparse.indices.componentType], b = s.sparse.indices.byteOffset || 0, T = s.sparse.values.byteOffset || 0, A = new x(o[1], b, s.sparse.count * _), I = new c(o[2], T, s.sparse.count * a);
1977
+ r !== null && (f = new ee(f.array.slice(), f.itemSize, f.normalized)), f.normalized = !1;
1978
+ for (let P = 0, K = A.length; P < K; P++) {
1979
+ const v = A[P];
1980
+ if (f.setX(v, I[P * a]), a >= 2 && f.setY(v, I[P * a + 1]), a >= 3 && f.setZ(v, I[P * a + 2]), a >= 4 && f.setW(v, I[P * a + 3]), a >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
1981
+ }
1982
+ f.normalized = m;
1983
+ }
1984
+ return f;
1985
+ });
1986
+ }
1987
+ /**
1988
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
1989
+ *
1990
+ * @private
1991
+ * @param {number} textureIndex
1992
+ * @return {Promise<THREE.Texture|null>}
1993
+ */
1994
+ loadTexture(e) {
1995
+ const t = this.json, n = this.options, i = t.textures[e].source, o = t.images[i];
1996
+ let r = this.textureLoader;
1997
+ if (o.uri) {
1998
+ const a = n.manager.getHandler(o.uri);
1999
+ a !== null && (r = a);
2000
+ }
2001
+ return this.loadTextureImage(e, i, r);
2002
+ }
2003
+ loadTextureImage(e, t, n) {
2004
+ const s = this, i = this.json, o = i.textures[e], r = i.images[t], a = (r.uri || r.bufferView) + ":" + o.sampler;
2005
+ if (this.textureCache[a])
2006
+ return this.textureCache[a];
2007
+ const c = this.loadImageSource(t, n).then(function(h) {
2008
+ h.flipY = !1, h.name = o.name || r.name || "", h.name === "" && typeof r.uri == "string" && r.uri.startsWith("data:image/") === !1 && (h.name = r.uri);
2009
+ const d = (i.samplers || {})[o.sampler] || {};
2010
+ return h.magFilter = we[d.magFilter] || ce, h.minFilter = we[d.minFilter] || Ie, h.wrapS = Se[d.wrapS] || le, h.wrapT = Se[d.wrapT] || le, h.generateMipmaps = !h.isCompressedTexture && h.minFilter !== ve && h.minFilter !== ce, s.associations.set(h, { textures: e }), h;
2011
+ }).catch(function() {
2012
+ return null;
2013
+ });
2014
+ return this.textureCache[a] = c, c;
2015
+ }
2016
+ loadImageSource(e, t) {
2017
+ const n = this, s = this.json, i = this.options;
2018
+ if (this.sourceCache[e] !== void 0)
2019
+ return this.sourceCache[e].then((u) => u.clone());
2020
+ const o = s.images[e], r = self.URL || self.webkitURL;
2021
+ let a = o.uri || "", c = !1;
2022
+ if (o.bufferView !== void 0)
2023
+ a = n.getDependency("bufferView", o.bufferView).then(function(u) {
2024
+ c = !0;
2025
+ const d = new Blob([u], { type: o.mimeType });
2026
+ return a = r.createObjectURL(d), a;
2027
+ });
2028
+ else if (o.uri === void 0)
2029
+ throw new Error("THREE.GLTFLoader: Image " + e + " is missing URI and bufferView");
2030
+ const h = Promise.resolve(a).then(function(u) {
2031
+ return new Promise(function(d, p) {
2032
+ let m = d;
2033
+ t.isImageBitmapLoader === !0 && (m = function(g) {
2034
+ const f = new me(g);
2035
+ f.needsUpdate = !0, d(f);
2036
+ }), t.load(z.resolveURL(u, i.path), m, void 0, p);
2037
+ });
2038
+ }).then(function(u) {
2039
+ return c === !0 && r.revokeObjectURL(a), D(u, o), u.userData.mimeType = o.mimeType || Os(o.uri), u;
2040
+ }).catch(function(u) {
2041
+ throw console.error("THREE.GLTFLoader: Couldn't load texture", a), u;
2042
+ });
2043
+ return this.sourceCache[e] = h, h;
2044
+ }
2045
+ /**
2046
+ * Asynchronously assigns a texture to the given material parameters.
2047
+ *
2048
+ * @private
2049
+ * @param {Object} materialParams
2050
+ * @param {string} mapName
2051
+ * @param {Object} mapDef
2052
+ * @param {string} [colorSpace]
2053
+ * @return {Promise<Texture>}
2054
+ */
2055
+ assignTexture(e, t, n, s) {
2056
+ const i = this;
2057
+ return this.getDependency("texture", n.index).then(function(o) {
2058
+ if (!o) return null;
2059
+ if (n.texCoord !== void 0 && n.texCoord > 0 && (o = o.clone(), o.channel = n.texCoord), i.extensions[y.KHR_TEXTURE_TRANSFORM]) {
2060
+ const r = n.extensions !== void 0 ? n.extensions[y.KHR_TEXTURE_TRANSFORM] : void 0;
2061
+ if (r) {
2062
+ const a = i.associations.get(o);
2063
+ o = i.extensions[y.KHR_TEXTURE_TRANSFORM].extendTexture(o, r), i.associations.set(o, a);
2064
+ }
2065
+ }
2066
+ return s !== void 0 && (o.colorSpace = s), e[t] = o, o;
2067
+ });
2068
+ }
2069
+ /**
2070
+ * Assigns final material to a Mesh, Line, or Points instance. The instance
2071
+ * already has a material (generated from the glTF material options alone)
2072
+ * but reuse of the same glTF material may require multiple threejs materials
2073
+ * to accommodate different primitive types, defines, etc. New materials will
2074
+ * be created if necessary, and reused from a cache.
2075
+ *
2076
+ * @private
2077
+ * @param {Object3D} mesh Mesh, Line, or Points instance.
2078
+ */
2079
+ assignFinalMaterial(e) {
2080
+ const t = e.geometry;
2081
+ let n = e.material;
2082
+ const s = t.attributes.tangent === void 0, i = t.attributes.color !== void 0, o = t.attributes.normal === void 0;
2083
+ if (e.isPoints) {
2084
+ const r = "PointsMaterial:" + n.uuid;
2085
+ let a = this.cache.get(r);
2086
+ a || (a = new dt(), te.prototype.copy.call(a, n), a.color.copy(n.color), a.map = n.map, a.sizeAttenuation = !1, this.cache.add(r, a)), n = a;
2087
+ } else if (e.isLine) {
2088
+ const r = "LineBasicMaterial:" + n.uuid;
2089
+ let a = this.cache.get(r);
2090
+ a || (a = new pt(), te.prototype.copy.call(a, n), a.color.copy(n.color), a.map = n.map, this.cache.add(r, a)), n = a;
2091
+ }
2092
+ if (s || i || o) {
2093
+ let r = "ClonedMaterial:" + n.uuid + ":";
2094
+ s && (r += "derivative-tangents:"), i && (r += "vertex-colors:"), o && (r += "flat-shading:");
2095
+ let a = this.cache.get(r);
2096
+ a || (a = n.clone(), i && (a.vertexColors = !0), o && (a.flatShading = !0), s && (a.normalScale && (a.normalScale.y *= -1), a.clearcoatNormalScale && (a.clearcoatNormalScale.y *= -1)), this.cache.add(r, a), this.associations.set(a, this.associations.get(n))), n = a;
2097
+ }
2098
+ e.material = n;
2099
+ }
2100
+ getMaterialType() {
2101
+ return ke;
2102
+ }
2103
+ /**
2104
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
2105
+ *
2106
+ * @private
2107
+ * @param {number} materialIndex
2108
+ * @return {Promise<Material>}
2109
+ */
2110
+ loadMaterial(e) {
2111
+ const t = this, n = this.json, s = this.extensions, i = n.materials[e];
2112
+ let o;
2113
+ const r = {}, a = i.extensions || {}, c = [];
2114
+ if (a[y.KHR_MATERIALS_UNLIT]) {
2115
+ const u = s[y.KHR_MATERIALS_UNLIT];
2116
+ o = u.getMaterialType(), c.push(u.extendParams(r, i, t));
2117
+ } else {
2118
+ const u = i.pbrMetallicRoughness || {};
2119
+ if (r.color = new F(1, 1, 1), r.opacity = 1, Array.isArray(u.baseColorFactor)) {
2120
+ const d = u.baseColorFactor;
2121
+ r.color.setRGB(d[0], d[1], d[2], C), r.opacity = d[3];
2122
+ }
2123
+ u.baseColorTexture !== void 0 && c.push(t.assignTexture(r, "map", u.baseColorTexture, X)), r.metalness = u.metallicFactor !== void 0 ? u.metallicFactor : 1, r.roughness = u.roughnessFactor !== void 0 ? u.roughnessFactor : 1, u.metallicRoughnessTexture !== void 0 && (c.push(t.assignTexture(r, "metalnessMap", u.metallicRoughnessTexture)), c.push(t.assignTexture(r, "roughnessMap", u.metallicRoughnessTexture))), o = this._invokeOne(function(d) {
2124
+ return d.getMaterialType && d.getMaterialType(e);
2125
+ }), c.push(Promise.all(this._invokeAll(function(d) {
2126
+ return d.extendMaterialParams && d.extendMaterialParams(e, r);
2127
+ })));
2128
+ }
2129
+ i.doubleSided === !0 && (r.side = ft);
2130
+ const h = i.alphaMode || oe.OPAQUE;
2131
+ if (h === oe.BLEND ? (r.transparent = !0, r.depthWrite = !1) : (r.transparent = !1, h === oe.MASK && (r.alphaTest = i.alphaCutoff !== void 0 ? i.alphaCutoff : 0.5)), i.normalTexture !== void 0 && o !== V && (c.push(t.assignTexture(r, "normalMap", i.normalTexture)), r.normalScale = new S(1, 1), i.normalTexture.scale !== void 0)) {
2132
+ const u = i.normalTexture.scale;
2133
+ r.normalScale.set(u, u);
2134
+ }
2135
+ if (i.occlusionTexture !== void 0 && o !== V && (c.push(t.assignTexture(r, "aoMap", i.occlusionTexture)), i.occlusionTexture.strength !== void 0 && (r.aoMapIntensity = i.occlusionTexture.strength)), i.emissiveFactor !== void 0 && o !== V) {
2136
+ const u = i.emissiveFactor;
2137
+ r.emissive = new F().setRGB(u[0], u[1], u[2], C);
2138
+ }
2139
+ return i.emissiveTexture !== void 0 && o !== V && c.push(t.assignTexture(r, "emissiveMap", i.emissiveTexture, X)), Promise.all(c).then(function() {
2140
+ const u = new o(r);
2141
+ return i.name && (u.name = i.name), D(u, i), t.associations.set(u, { materials: e }), i.extensions && j(s, u, i), u;
2142
+ });
2143
+ }
2144
+ /**
2145
+ * When Object3D instances are targeted by animation, they need unique names.
2146
+ *
2147
+ * @private
2148
+ * @param {string} originalName
2149
+ * @return {string}
2150
+ */
2151
+ createUniqueName(e) {
2152
+ const t = mt.sanitizeNodeName(e || "");
2153
+ return t in this.nodeNamesUsed ? t + "_" + ++this.nodeNamesUsed[t] : (this.nodeNamesUsed[t] = 0, t);
2154
+ }
2155
+ /**
2156
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
2157
+ *
2158
+ * Creates BufferGeometries from primitives.
2159
+ *
2160
+ * @private
2161
+ * @param {Array<GLTF.Primitive>} primitives
2162
+ * @return {Promise<Array<BufferGeometry>>}
2163
+ */
2164
+ loadGeometries(e) {
2165
+ const t = this, n = this.extensions, s = this.primitiveCache;
2166
+ function i(r) {
2167
+ return n[y.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(r, t).then(function(a) {
2168
+ return Ae(a, r, t);
2169
+ });
2170
+ }
2171
+ const o = [];
2172
+ for (let r = 0, a = e.length; r < a; r++) {
2173
+ const c = e[r], h = Ns(c), u = s[h];
2174
+ if (u)
2175
+ o.push(u.promise);
2176
+ else {
2177
+ let d;
2178
+ c.extensions && c.extensions[y.KHR_DRACO_MESH_COMPRESSION] ? d = i(c) : d = Ae(new _t(), c, t), s[h] = { primitive: c, promise: d }, o.push(d);
2179
+ }
2180
+ }
2181
+ return Promise.all(o);
2182
+ }
2183
+ /**
2184
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
2185
+ *
2186
+ * @private
2187
+ * @param {number} meshIndex
2188
+ * @return {Promise<Group|Mesh|SkinnedMesh|Line|Points>}
2189
+ */
2190
+ loadMesh(e) {
2191
+ const t = this, n = this.json, s = this.extensions, i = n.meshes[e], o = i.primitives, r = [];
2192
+ for (let a = 0, c = o.length; a < c; a++) {
2193
+ const h = o[a].material === void 0 ? As(this.cache) : this.getDependency("material", o[a].material);
2194
+ r.push(h);
2195
+ }
2196
+ return r.push(t.loadGeometries(o)), Promise.all(r).then(function(a) {
2197
+ const c = a.slice(0, a.length - 1), h = a[a.length - 1], u = [];
2198
+ for (let p = 0, m = h.length; p < m; p++) {
2199
+ const g = h[p], f = o[p];
2200
+ let _;
2201
+ const x = c[p];
2202
+ if (f.mode === L.TRIANGLES || f.mode === L.TRIANGLE_STRIP || f.mode === L.TRIANGLE_FAN || f.mode === void 0)
2203
+ _ = i.isSkinnedMesh === !0 ? new gt(g, x) : new Tt(g, x), _.isSkinnedMesh === !0 && _.normalizeSkinWeights(), f.mode === L.TRIANGLE_STRIP ? _.geometry = Re(_.geometry, Oe) : f.mode === L.TRIANGLE_FAN && (_.geometry = Re(_.geometry, ae));
2204
+ else if (f.mode === L.LINES)
2205
+ _ = new yt(g, x);
2206
+ else if (f.mode === L.LINE_STRIP)
2207
+ _ = new xt(g, x);
2208
+ else if (f.mode === L.LINE_LOOP)
2209
+ _ = new Et(g, x);
2210
+ else if (f.mode === L.POINTS)
2211
+ _ = new bt(g, x);
2212
+ else
2213
+ throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + f.mode);
2214
+ Object.keys(_.geometry.morphAttributes).length > 0 && Ps(_, i), _.name = t.createUniqueName(i.name || "mesh_" + e), D(_, i), f.extensions && j(s, _, f), t.assignFinalMaterial(_), u.push(_);
2215
+ }
2216
+ for (let p = 0, m = u.length; p < m; p++)
2217
+ t.associations.set(u[p], {
2218
+ meshes: e,
2219
+ primitives: p
2220
+ });
2221
+ if (u.length === 1)
2222
+ return i.extensions && j(s, u[0], i), u[0];
2223
+ const d = new se();
2224
+ i.extensions && j(s, d, i), t.associations.set(d, { meshes: e });
2225
+ for (let p = 0, m = u.length; p < m; p++)
2226
+ d.add(u[p]);
2227
+ return d;
2228
+ });
2229
+ }
2230
+ /**
2231
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
2232
+ *
2233
+ * @private
2234
+ * @param {number} cameraIndex
2235
+ * @return {Promise<THREE.Camera>}
2236
+ */
2237
+ loadCamera(e) {
2238
+ let t;
2239
+ const n = this.json.cameras[e], s = n[n.type];
2240
+ if (!s) {
2241
+ console.warn("THREE.GLTFLoader: Missing camera parameters.");
2242
+ return;
2243
+ }
2244
+ return n.type === "perspective" ? t = new Rt(Ne.radToDeg(s.yfov), s.aspectRatio || 1, s.znear || 1, s.zfar || 2e6) : n.type === "orthographic" && (t = new Mt(-s.xmag, s.xmag, s.ymag, -s.ymag, s.znear, s.zfar)), n.name && (t.name = this.createUniqueName(n.name)), D(t, n), Promise.resolve(t);
2245
+ }
2246
+ /**
2247
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
2248
+ *
2249
+ * @private
2250
+ * @param {number} skinIndex
2251
+ * @return {Promise<Skeleton>}
2252
+ */
2253
+ loadSkin(e) {
2254
+ const t = this.json.skins[e], n = [];
2255
+ for (let s = 0, i = t.joints.length; s < i; s++)
2256
+ n.push(this._loadNodeShallow(t.joints[s]));
2257
+ return t.inverseBindMatrices !== void 0 ? n.push(this.getDependency("accessor", t.inverseBindMatrices)) : n.push(null), Promise.all(n).then(function(s) {
2258
+ const i = s.pop(), o = s, r = [], a = [];
2259
+ for (let c = 0, h = o.length; c < h; c++) {
2260
+ const u = o[c];
2261
+ if (u) {
2262
+ r.push(u);
2263
+ const d = new q();
2264
+ i !== null && d.fromArray(i.array, c * 16), a.push(d);
2265
+ } else
2266
+ console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', t.joints[c]);
2267
+ }
2268
+ return new wt(r, a);
2269
+ });
2270
+ }
2271
+ /**
2272
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
2273
+ *
2274
+ * @private
2275
+ * @param {number} animationIndex
2276
+ * @return {Promise<AnimationClip>}
2277
+ */
2278
+ loadAnimation(e) {
2279
+ const t = this.json, n = this, s = t.animations[e], i = s.name ? s.name : "animation_" + e, o = [], r = [], a = [], c = [], h = [];
2280
+ for (let u = 0, d = s.channels.length; u < d; u++) {
2281
+ const p = s.channels[u], m = s.samplers[p.sampler], g = p.target, f = g.node, _ = s.parameters !== void 0 ? s.parameters[m.input] : m.input, x = s.parameters !== void 0 ? s.parameters[m.output] : m.output;
2282
+ g.node !== void 0 && (o.push(this.getDependency("node", f)), r.push(this.getDependency("accessor", _)), a.push(this.getDependency("accessor", x)), c.push(m), h.push(g));
2283
+ }
2284
+ return Promise.all([
2285
+ Promise.all(o),
2286
+ Promise.all(r),
2287
+ Promise.all(a),
2288
+ Promise.all(c),
2289
+ Promise.all(h)
2290
+ ]).then(function(u) {
2291
+ const d = u[0], p = u[1], m = u[2], g = u[3], f = u[4], _ = [];
2292
+ for (let x = 0, b = d.length; x < b; x++) {
2293
+ const T = d[x], A = p[x], I = m[x], P = g[x], K = f[x];
2294
+ if (T === void 0) continue;
2295
+ T.updateMatrix && T.updateMatrix();
2296
+ const v = n._createAnimationTracks(T, A, I, P, K);
2297
+ if (v)
2298
+ for (let $ = 0; $ < v.length; $++)
2299
+ _.push(v[$]);
2300
+ }
2301
+ return new St(i, void 0, _);
2302
+ });
2303
+ }
2304
+ createNodeMesh(e) {
2305
+ const t = this.json, n = this, s = t.nodes[e];
2306
+ return s.mesh === void 0 ? null : n.getDependency("mesh", s.mesh).then(function(i) {
2307
+ const o = n._getNodeRef(n.meshCache, s.mesh, i);
2308
+ return s.weights !== void 0 && o.traverse(function(r) {
2309
+ if (r.isMesh)
2310
+ for (let a = 0, c = s.weights.length; a < c; a++)
2311
+ r.morphTargetInfluences[a] = s.weights[a];
2312
+ }), o;
2313
+ });
2314
+ }
2315
+ /**
2316
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
2317
+ *
2318
+ * @private
2319
+ * @param {number} nodeIndex
2320
+ * @return {Promise<Object3D>}
2321
+ */
2322
+ loadNode(e) {
2323
+ const t = this.json, n = this, s = t.nodes[e], i = n._loadNodeShallow(e), o = [], r = s.children || [];
2324
+ for (let c = 0, h = r.length; c < h; c++)
2325
+ o.push(n.getDependency("node", r[c]));
2326
+ const a = s.skin === void 0 ? Promise.resolve(null) : n.getDependency("skin", s.skin);
2327
+ return Promise.all([
2328
+ i,
2329
+ Promise.all(o),
2330
+ a
2331
+ ]).then(function(c) {
2332
+ const h = c[0], u = c[1], d = c[2];
2333
+ d !== null && h.traverse(function(p) {
2334
+ p.isSkinnedMesh && p.bind(d, Ds);
2335
+ });
2336
+ for (let p = 0, m = u.length; p < m; p++)
2337
+ h.add(u[p]);
2338
+ return h;
2339
+ });
2340
+ }
2341
+ // ._loadNodeShallow() parses a single node.
2342
+ // skin and child nodes are created and added in .loadNode() (no '_' prefix).
2343
+ _loadNodeShallow(e) {
2344
+ const t = this.json, n = this.extensions, s = this;
2345
+ if (this.nodeCache[e] !== void 0)
2346
+ return this.nodeCache[e];
2347
+ const i = t.nodes[e], o = i.name ? s.createUniqueName(i.name) : "", r = [], a = s._invokeOne(function(c) {
2348
+ return c.createNodeMesh && c.createNodeMesh(e);
2349
+ });
2350
+ return a && r.push(a), i.camera !== void 0 && r.push(s.getDependency("camera", i.camera).then(function(c) {
2351
+ return s._getNodeRef(s.cameraCache, i.camera, c);
2352
+ })), s._invokeAll(function(c) {
2353
+ return c.createNodeAttachment && c.createNodeAttachment(e);
2354
+ }).forEach(function(c) {
2355
+ r.push(c);
2356
+ }), this.nodeCache[e] = Promise.all(r).then(function(c) {
2357
+ let h;
2358
+ if (i.isBone === !0 ? h = new At() : c.length > 1 ? h = new se() : c.length === 1 ? h = c[0] : h = new Ce(), h !== c[0])
2359
+ for (let u = 0, d = c.length; u < d; u++)
2360
+ h.add(c[u]);
2361
+ if (i.name && (h.userData.name = i.name, h.name = o), D(h, i), i.extensions && j(n, h, i), i.matrix !== void 0) {
2362
+ const u = new q();
2363
+ u.fromArray(i.matrix), h.applyMatrix4(u);
2364
+ } else
2365
+ i.translation !== void 0 && h.position.fromArray(i.translation), i.rotation !== void 0 && h.quaternion.fromArray(i.rotation), i.scale !== void 0 && h.scale.fromArray(i.scale);
2366
+ if (!s.associations.has(h))
2367
+ s.associations.set(h, {});
2368
+ else if (i.mesh !== void 0 && s.meshCache.refs[i.mesh] > 1) {
2369
+ const u = s.associations.get(h);
2370
+ s.associations.set(h, { ...u });
2371
+ }
2372
+ return s.associations.get(h).nodes = e, h;
2373
+ }), this.nodeCache[e];
2374
+ }
2375
+ /**
2376
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
2377
+ *
2378
+ * @private
2379
+ * @param {number} sceneIndex
2380
+ * @return {Promise<Group>}
2381
+ */
2382
+ loadScene(e) {
2383
+ const t = this.extensions, n = this.json.scenes[e], s = this, i = new se();
2384
+ n.name && (i.name = s.createUniqueName(n.name)), D(i, n), n.extensions && j(t, i, n);
2385
+ const o = n.nodes || [], r = [];
2386
+ for (let a = 0, c = o.length; a < c; a++)
2387
+ r.push(s.getDependency("node", o[a]));
2388
+ return Promise.all(r).then(function(a) {
2389
+ for (let h = 0, u = a.length; h < u; h++)
2390
+ i.add(a[h]);
2391
+ const c = (h) => {
2392
+ const u = /* @__PURE__ */ new Map();
2393
+ for (const [d, p] of s.associations)
2394
+ (d instanceof te || d instanceof me) && u.set(d, p);
2395
+ return h.traverse((d) => {
2396
+ const p = s.associations.get(d);
2397
+ p != null && u.set(d, p);
2398
+ }), u;
2399
+ };
2400
+ return s.associations = c(i), i;
2401
+ });
2402
+ }
2403
+ _createAnimationTracks(e, t, n, s, i) {
2404
+ const o = [], r = e.name ? e.name : e.uuid, a = [];
2405
+ k[i.path] === k.weights ? e.traverse(function(d) {
2406
+ d.morphTargetInfluences && a.push(d.name ? d.name : d.uuid);
2407
+ }) : a.push(r);
2408
+ let c;
2409
+ switch (k[i.path]) {
2410
+ case k.weights:
2411
+ c = ge;
2412
+ break;
2413
+ case k.rotation:
2414
+ c = Te;
2415
+ break;
2416
+ case k.translation:
2417
+ case k.scale:
2418
+ c = _e;
2419
+ break;
2420
+ default:
2421
+ switch (n.itemSize) {
2422
+ case 1:
2423
+ c = ge;
2424
+ break;
2425
+ case 2:
2426
+ case 3:
2427
+ default:
2428
+ c = _e;
2429
+ break;
2430
+ }
2431
+ break;
2432
+ }
2433
+ const h = s.interpolation !== void 0 ? Ss[s.interpolation] : je, u = this._getArrayFromAccessor(n);
2434
+ for (let d = 0, p = a.length; d < p; d++) {
2435
+ const m = new c(
2436
+ a[d] + "." + k[i.path],
2437
+ t.array,
2438
+ u,
2439
+ h
2440
+ );
2441
+ s.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(m), o.push(m);
2442
+ }
2443
+ return o;
2444
+ }
2445
+ _getArrayFromAccessor(e) {
2446
+ let t = e.array;
2447
+ if (e.normalized) {
2448
+ const n = ue(t.constructor), s = new Float32Array(t.length);
2449
+ for (let i = 0, o = t.length; i < o; i++)
2450
+ s[i] = t[i] * n;
2451
+ t = s;
2452
+ }
2453
+ return t;
2454
+ }
2455
+ _createCubicSplineTrackInterpolant(e) {
2456
+ e.createInterpolant = function(n) {
2457
+ const s = this instanceof Te ? ws : Ge;
2458
+ return new s(this.times, this.values, this.getValueSize() / 3, n);
2459
+ }, e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;
2460
+ }
2461
+ }
2462
+ function Is(l, e, t) {
2463
+ const n = e.attributes, s = new Ot();
2464
+ if (n.POSITION !== void 0) {
2465
+ const r = t.json.accessors[n.POSITION], a = r.min, c = r.max;
2466
+ if (a !== void 0 && c !== void 0) {
2467
+ if (s.set(
2468
+ new M(a[0], a[1], a[2]),
2469
+ new M(c[0], c[1], c[2])
2470
+ ), r.normalized) {
2471
+ const h = ue(G[r.componentType]);
2472
+ s.min.multiplyScalar(h), s.max.multiplyScalar(h);
2473
+ }
2474
+ } else {
2475
+ console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
2476
+ return;
2477
+ }
2478
+ } else
2479
+ return;
2480
+ const i = e.targets;
2481
+ if (i !== void 0) {
2482
+ const r = new M(), a = new M();
2483
+ for (let c = 0, h = i.length; c < h; c++) {
2484
+ const u = i[c];
2485
+ if (u.POSITION !== void 0) {
2486
+ const d = t.json.accessors[u.POSITION], p = d.min, m = d.max;
2487
+ if (p !== void 0 && m !== void 0) {
2488
+ if (a.setX(Math.max(Math.abs(p[0]), Math.abs(m[0]))), a.setY(Math.max(Math.abs(p[1]), Math.abs(m[1]))), a.setZ(Math.max(Math.abs(p[2]), Math.abs(m[2]))), d.normalized) {
2489
+ const g = ue(G[d.componentType]);
2490
+ a.multiplyScalar(g);
2491
+ }
2492
+ r.max(a);
2493
+ } else
2494
+ console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
2495
+ }
2496
+ }
2497
+ s.expandByVector(r);
2498
+ }
2499
+ l.boundingBox = s;
2500
+ const o = new Dt();
2501
+ s.getCenter(o.center), o.radius = s.min.distanceTo(s.max) / 2, l.boundingSphere = o;
2502
+ }
2503
+ function Ae(l, e, t) {
2504
+ const n = e.attributes, s = [];
2505
+ function i(o, r) {
2506
+ return t.getDependency("accessor", o).then(function(a) {
2507
+ l.setAttribute(r, a);
2508
+ });
2509
+ }
2510
+ for (const o in n) {
2511
+ const r = he[o] || o.toLowerCase();
2512
+ r in l.attributes || s.push(i(n[o], r));
2513
+ }
2514
+ if (e.indices !== void 0 && !l.index) {
2515
+ const o = t.getDependency("accessor", e.indices).then(function(r) {
2516
+ l.setIndex(r);
2517
+ });
2518
+ s.push(o);
2519
+ }
2520
+ return ye.workingColorSpace !== C && "COLOR_0" in n && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ye.workingColorSpace}" not supported.`), D(l, e), Is(l, e, t), Promise.all(s).then(function() {
2521
+ return e.targets !== void 0 ? Ls(l, e.targets, t) : l;
2522
+ });
2523
+ }
2524
+ const vs = {
2525
+ __name: "VroidVrm",
2526
+ props: {
2527
+ url: {
2528
+ type: String
2529
+ },
2530
+ data: {
2531
+ type: [Object, null],
2532
+ default: null
2533
+ },
2534
+ name: {
2535
+ type: String
2536
+ },
2537
+ command: {
2538
+ type: String
2539
+ }
2540
+ },
2541
+ emits: ["loading", "loaded"],
2542
+ setup(l, { emit: e }) {
2543
+ const t = e, n = l, s = async (r) => {
2544
+ const a = new es();
2545
+ return a.register((c) => new Ct(c)), await a.loadAsync(r).then((c) => {
2546
+ const h = c.userData.vrm;
2547
+ return It.rotateVRM0(h), h;
2548
+ });
2549
+ }, i = async (r) => {
2550
+ if (!r)
2551
+ return;
2552
+ t("loading", n.name, n.command);
2553
+ const a = await s(r);
2554
+ let c = !1;
2555
+ a && (c = !0), t("loaded", n.name, n.command, c, a);
2556
+ }, o = (r) => {
2557
+ t("loading", n.name, n.command);
2558
+ let a = !1;
2559
+ r && (a = !0), t("loaded", n.name, n.command, a, r);
2560
+ };
2561
+ return Q(async () => {
2562
+ n.data != null ? o(n.data) : i(n.url);
2563
+ }), (r, a) => null;
2564
+ }
2565
+ }, ks = {
2566
+ __name: "VroidModel",
2567
+ props: {
2568
+ name: {
2569
+ type: String
2570
+ },
2571
+ expression_name: {
2572
+ type: String
2573
+ },
2574
+ expression_url: {
2575
+ type: String
2576
+ },
2577
+ expression_data: {
2578
+ type: [Object, null],
2579
+ default: null
2580
+ },
2581
+ pose_name: {
2582
+ type: String
2583
+ },
2584
+ pose_url: {
2585
+ type: String
2586
+ },
2587
+ pose_data: {
2588
+ type: [Object, null],
2589
+ default: null
2590
+ },
2591
+ vrm_name: {
2592
+ type: String
2593
+ },
2594
+ vrm_url: {
2595
+ type: String
2596
+ },
2597
+ vrm_data: {
2598
+ type: [Object, null],
2599
+ default: null
2600
+ }
2601
+ },
2602
+ emits: ["loading", "loaded"],
2603
+ setup(l, { emit: e }) {
2604
+ const t = e, n = l, s = {}, i = {}, o = W(null), r = W(null), a = W(null), c = (u, d) => {
2605
+ const p = Object.keys(s).length;
2606
+ s[u] = d;
2607
+ const m = Object.keys(s).length;
2608
+ p == 0 && m && t("loading", n.name);
2609
+ }, h = (u, d, p, m) => {
2610
+ const g = Object.keys(s).length;
2611
+ p && (d == "load_expression" && (o.value = m), d == "load_pose" && (r.value = m), d == "load_vrm" && (a.value = m), i[u] = d), delete s[u];
2612
+ const f = Object.keys(s).length;
2613
+ if (g && f == 0) {
2614
+ const _ = {};
2615
+ for (const b in i) {
2616
+ const T = i[b];
2617
+ T == "load_expression" && (_.expression = o.value), T == "load_pose" && (_.pose = r.value), T == "load_vrm" && (_.vrm = a.value);
2618
+ }
2619
+ t("loaded", n.name, _);
2620
+ const x = Object.keys(i);
2621
+ for (const b of x)
2622
+ delete i[b];
2623
+ }
2624
+ };
2625
+ return (u, d) => (de(), Le(ze, null, [
2626
+ J($t, {
2627
+ command: "load_expression",
2628
+ name: n.expression_name,
2629
+ url: n.expression_url,
2630
+ data: n.expression_data,
2631
+ onLoading: c,
2632
+ onLoaded: h
2633
+ }, null, 8, ["name", "url", "data"]),
2634
+ J(Jt, {
2635
+ command: "load_pose",
2636
+ name: n.pose_name,
2637
+ url: n.pose_url,
2638
+ data: n.expression_data,
2639
+ onLoading: c,
2640
+ onLoaded: h
2641
+ }, null, 8, ["name", "url", "data"]),
2642
+ J(vs, {
2643
+ command: "load_vrm",
2644
+ name: n.vrm_name,
2645
+ url: n.vrm_url,
2646
+ data: n.vrm_data,
2647
+ onLoading: c,
2648
+ onLoaded: h
2649
+ }, null, 8, ["name", "url", "data"])
2650
+ ], 64));
2651
+ }
2652
+ }, Gs = {
2653
+ __name: "VroidControl",
2654
+ props: {
2655
+ model_name: {
2656
+ type: String,
2657
+ required: !0
2658
+ },
2659
+ expression_name: {
2660
+ type: String,
2661
+ default: "expression"
2662
+ },
2663
+ expression_url: {
2664
+ type: String,
2665
+ default: ""
2666
+ },
2667
+ expression_data: {
2668
+ type: [Object, null],
2669
+ default: null
2670
+ },
2671
+ pose_name: {
2672
+ type: String,
2673
+ default: "pose"
2674
+ },
2675
+ pose_url: {
2676
+ type: String,
2677
+ default: ""
2678
+ },
2679
+ pose_data: {
2680
+ type: [Object, null],
2681
+ default: null
2682
+ },
2683
+ vrm_name: {
2684
+ type: String,
2685
+ default: "vrm"
2686
+ },
2687
+ vrm_url: {
2688
+ type: String,
2689
+ default: ""
2690
+ },
2691
+ vrm_data: {
2692
+ type: [Object, null],
2693
+ default: null
2694
+ }
2695
+ },
2696
+ emits: ["loading", "loaded"],
2697
+ setup(l, { emit: e }) {
2698
+ const t = e, n = W(null);
2699
+ n.value = new vt();
2700
+ const s = (o) => {
2701
+ t("loading", o);
2702
+ }, i = (o, r) => {
2703
+ "vrm" in r && n.value.setModel(r.vrm), "pose" in r && (n.value.setPose(r.pose), n.value.updatePose()), "expression" in r && (n.value.importExpression(r.expression), n.value.updateExpression()), t("loaded", o, n.value);
2704
+ };
2705
+ return (o, r) => (de(), Xe(ks, {
2706
+ name: l.model_name,
2707
+ expression_name: l.expression_name,
2708
+ expression_url: l.expression_url,
2709
+ expression_data: l.expression_data,
2710
+ pose_name: l.pose_name,
2711
+ pose_url: l.pose_url,
2712
+ pose_data: l.pose_data,
2713
+ vrm_name: l.vrm_name,
2714
+ vrm_url: l.vrm_url,
2715
+ vrm_data: l.vrm_data,
2716
+ onLoading: s,
2717
+ onLoaded: i
2718
+ }, null, 8, ["name", "expression_name", "expression_url", "expression_data", "pose_name", "pose_url", "pose_data", "vrm_name", "vrm_url", "vrm_data"]));
2719
+ }
2720
+ };
2721
+ export {
2722
+ Fe as ResourceLoader,
2723
+ Us as ThreeFrame,
2724
+ vt as VrmModel,
2725
+ Gs as VroidControl,
2726
+ $t as VroidExpression,
2727
+ ks as VroidModel,
2728
+ Jt as VroidPose,
2729
+ vs as VroidVrm
2730
+ };