@j-kyoda/vue-three-vrm 0.6.3 → 0.7.0

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