@j-kyoda/vue-three-vrm 0.6.2 → 0.6.4

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