@ridp/threejs 1.1.7 → 1.2.1

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.
Files changed (77) hide show
  1. package/dist/common-C1rNPPkt.cjs +15 -0
  2. package/dist/common-D1_IztgM.js +54 -0
  3. package/dist/hooks.cjs +1 -1
  4. package/dist/hooks.js +4 -4
  5. package/dist/modelSerialize-5oJb1ka7.js +965 -0
  6. package/dist/modelSerialize-Ds_2KBaA.cjs +5 -0
  7. package/dist/threejs.cjs +1 -1
  8. package/dist/threejs.js +184 -24
  9. package/dist/useGLTFLoader-Ca78rpg1.js +5507 -0
  10. package/dist/useGLTFLoader-SChWH4Nf.cjs +4 -0
  11. package/dist/utils.cjs +1 -1
  12. package/dist/utils.js +18 -16
  13. package/esdoc/ast/source/.external-ecmascript.js.json +2801 -2801
  14. package/esdoc/ast/source/hooks/index.js.json +738 -738
  15. package/esdoc/ast/source/hooks/useGLTFLoader.js.json +9110 -9110
  16. package/esdoc/ast/source/hooks/useObb.js.json +16462 -16462
  17. package/esdoc/ast/source/hooks/useRaycaster.js.json +15555 -15555
  18. package/esdoc/ast/source/hooks/useThreeJs.js.json +52886 -52886
  19. package/esdoc/ast/source/index.js.json +569 -569
  20. package/esdoc/ast/source/instance/IDBCache.js.json +40977 -40977
  21. package/esdoc/ast/source/instance/index.js.json +231 -231
  22. package/esdoc/ast/source/utils/ImageLoader.js.json +7036 -7036
  23. package/esdoc/ast/source/utils/common.js.json +5133 -5133
  24. package/esdoc/ast/source/utils/css3dHelper.js.json +9100 -9100
  25. package/esdoc/ast/source/utils/disposeObject.js.json +5977 -5977
  26. package/esdoc/ast/source/utils/helper.js.json +10521 -10521
  27. package/esdoc/ast/source/utils/index.js.json +907 -907
  28. package/esdoc/badge.svg +17 -17
  29. package/esdoc/class/src/instance/IDBCache.js~IDBCache.html +1299 -1299
  30. package/esdoc/coverage.json +85 -85
  31. package/esdoc/css/github.css +83 -83
  32. package/esdoc/css/identifiers.css +37 -37
  33. package/esdoc/css/manual.css +134 -134
  34. package/esdoc/css/prettify-tomorrow.css +132 -132
  35. package/esdoc/css/search.css +84 -84
  36. package/esdoc/css/source.css +55 -55
  37. package/esdoc/css/style.css +608 -608
  38. package/esdoc/css/test.css +58 -58
  39. package/esdoc/file/src/hooks/index.js.html +75 -75
  40. package/esdoc/file/src/hooks/useGLTFLoader.js.html +75 -75
  41. package/esdoc/file/src/hooks/useObb.js.html +75 -75
  42. package/esdoc/file/src/hooks/useRaycaster.js.html +75 -75
  43. package/esdoc/file/src/hooks/useThreeJs.js.html +75 -75
  44. package/esdoc/file/src/index.js.html +75 -75
  45. package/esdoc/file/src/instance/IDBCache.js.html +75 -75
  46. package/esdoc/file/src/instance/index.js.html +75 -75
  47. package/esdoc/file/src/utils/ImageLoader.js.html +75 -75
  48. package/esdoc/file/src/utils/common.js.html +75 -75
  49. package/esdoc/file/src/utils/css3dHelper.js.html +75 -75
  50. package/esdoc/file/src/utils/disposeObject.js.html +75 -75
  51. package/esdoc/file/src/utils/helper.js.html +75 -75
  52. package/esdoc/file/src/utils/index.js.html +75 -75
  53. package/esdoc/function/index.html +2019 -2019
  54. package/esdoc/identifiers.html +738 -738
  55. package/esdoc/image/badge.svg +17 -17
  56. package/esdoc/image/manual-badge.svg +17 -17
  57. package/esdoc/index.html +153 -153
  58. package/esdoc/index.json +2050 -2050
  59. package/esdoc/script/inherited-summary.js +28 -28
  60. package/esdoc/script/inner-link.js +32 -32
  61. package/esdoc/script/manual.js +12 -12
  62. package/esdoc/script/patch-for-local.js +8 -8
  63. package/esdoc/script/prettify/Apache-License-2.0.txt +202 -202
  64. package/esdoc/script/prettify/prettify.js +46 -46
  65. package/esdoc/script/pretty-print.js +25 -25
  66. package/esdoc/script/search.js +117 -117
  67. package/esdoc/script/search_index.js +571 -571
  68. package/esdoc/script/test-summary.js +54 -54
  69. package/esdoc/source.html +213 -213
  70. package/esdoc/variable/index.html +225 -225
  71. package/package.json +3 -5
  72. package/dist/ImageLoader-B_rHfhtt.cjs +0 -1
  73. package/dist/ImageLoader-D9uANgrl.js +0 -1475
  74. package/dist/common-DTEEkXFr.cjs +0 -1
  75. package/dist/common-DhuVL1VV.js +0 -73
  76. package/dist/useGLTFLoader-BDER-upw.cjs +0 -1
  77. package/dist/useGLTFLoader-UD3WYZET.js +0 -7016
@@ -0,0 +1,965 @@
1
+ import * as F from "three";
2
+ import { Matrix4 as dt, Vector3 as x, Quaternion as et, Object3D as yt, Controls as gt, MOUSE as z, TOUCH as G, Spherical as nt, Vector2 as L, Ray as Et, Plane as bt, MathUtils as wt, CameraHelper as Dt, GridHelper as St, BoxHelper as Pt, Raycaster as Tt, AxesHelper as Mt, ArrowHelper as Rt, DataTextureLoader as xt, HalfFloatType as X, FloatType as $, DataUtils as V, LinearSRGBColorSpace as At, LinearFilter as at, EquirectangularReflectionMapping as Ot } from "three";
3
+ var K = function() {
4
+ var e = 0, t = document.createElement("div");
5
+ t.style.cssText = "position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000", t.addEventListener("click", function(m) {
6
+ m.preventDefault(), o(++e % t.children.length);
7
+ }, !1);
8
+ function i(m) {
9
+ return t.appendChild(m.dom), m;
10
+ }
11
+ function o(m) {
12
+ for (var h = 0; h < t.children.length; h++)
13
+ t.children[h].style.display = h === m ? "block" : "none";
14
+ e = m;
15
+ }
16
+ var r = (performance || Date).now(), c = r, a = 0, f = i(new K.Panel("FPS", "#0ff", "#002")), P = i(new K.Panel("MS", "#0f0", "#020"));
17
+ if (self.performance && self.performance.memory)
18
+ var b = i(new K.Panel("MB", "#f08", "#201"));
19
+ return o(0), {
20
+ REVISION: 16,
21
+ dom: t,
22
+ addPanel: i,
23
+ showPanel: o,
24
+ begin: function() {
25
+ r = (performance || Date).now();
26
+ },
27
+ end: function() {
28
+ a++;
29
+ var m = (performance || Date).now();
30
+ if (P.update(m - r, 200), m >= c + 1e3 && (f.update(a * 1e3 / (m - c), 100), c = m, a = 0, b)) {
31
+ var h = performance.memory;
32
+ b.update(h.usedJSHeapSize / 1048576, h.jsHeapSizeLimit / 1048576);
33
+ }
34
+ return m;
35
+ },
36
+ update: function() {
37
+ r = this.end();
38
+ },
39
+ // Backwards Compatibility
40
+ domElement: t,
41
+ setMode: o
42
+ };
43
+ };
44
+ K.Panel = function(e, t, i) {
45
+ var o = 1 / 0, r = 0, c = Math.round, a = c(window.devicePixelRatio || 1), f = 80 * a, P = 48 * a, b = 3 * a, m = 2 * a, h = 3 * a, O = 15 * a, v = 74 * a, C = 30 * a, k = document.createElement("canvas");
46
+ k.width = f, k.height = P, k.style.cssText = "width:80px;height:48px";
47
+ var n = k.getContext("2d");
48
+ return n.font = "bold " + 9 * a + "px Helvetica,Arial,sans-serif", n.textBaseline = "top", n.fillStyle = i, n.fillRect(0, 0, f, P), n.fillStyle = t, n.fillText(e, b, m), n.fillRect(h, O, v, C), n.fillStyle = i, n.globalAlpha = 0.9, n.fillRect(h, O, v, C), {
49
+ dom: k,
50
+ update: function(s, T) {
51
+ o = Math.min(o, s), r = Math.max(r, s), n.fillStyle = i, n.globalAlpha = 1, n.fillRect(0, 0, f, O), n.fillStyle = t, n.fillText(c(s) + " " + e + " (" + c(o) + "-" + c(r) + ")", b, m), n.drawImage(k, h + a, O, v - a, C, h, O, v - a, C), n.fillRect(h + v - a, O, a, C), n.fillStyle = i, n.globalAlpha = 0.9, n.fillRect(h + v - a, O, a, c((1 - s / T) * C));
52
+ }
53
+ };
54
+ };
55
+ const rt = new x(), Lt = new et(), ht = new x();
56
+ class vt extends yt {
57
+ /**
58
+ * Constructs a new CSS3D object.
59
+ *
60
+ * @param {DOMElement} [element] - The DOM element.
61
+ */
62
+ constructor(t = document.createElement("div")) {
63
+ super(), this.isCSS3DObject = !0, this.element = t, this.element.style.position = "absolute", this.element.style.pointerEvents = "auto", this.element.style.userSelect = "none", this.element.setAttribute("draggable", !1), this.addEventListener("removed", function() {
64
+ this.traverse(function(i) {
65
+ i.element instanceof i.element.ownerDocument.defaultView.Element && i.element.parentNode !== null && i.element.remove();
66
+ });
67
+ });
68
+ }
69
+ copy(t, i) {
70
+ return super.copy(t, i), this.element = t.element.cloneNode(!0), this;
71
+ }
72
+ }
73
+ class se extends vt {
74
+ /**
75
+ * Constructs a new CSS3D sprite object.
76
+ *
77
+ * @param {DOMElement} [element] - The DOM element.
78
+ */
79
+ constructor(t) {
80
+ super(t), this.isCSS3DSprite = !0, this.rotation2D = 0;
81
+ }
82
+ copy(t, i) {
83
+ return super.copy(t, i), this.rotation2D = t.rotation2D, this;
84
+ }
85
+ }
86
+ const H = new dt(), Ct = new dt();
87
+ class oe {
88
+ /**
89
+ * Constructs a new CSS3D renderer.
90
+ *
91
+ * @param {CSS3DRenderer~Parameters} [parameters] - The parameters.
92
+ */
93
+ constructor(t = {}) {
94
+ const i = this;
95
+ let o, r, c, a;
96
+ const f = {
97
+ camera: { style: "" },
98
+ objects: /* @__PURE__ */ new WeakMap()
99
+ }, P = t.element !== void 0 ? t.element : document.createElement("div");
100
+ P.style.overflow = "hidden", this.domElement = P;
101
+ const b = document.createElement("div");
102
+ b.style.transformOrigin = "0 0", b.style.pointerEvents = "none", P.appendChild(b);
103
+ const m = document.createElement("div");
104
+ m.style.transformStyle = "preserve-3d", b.appendChild(m), this.getSize = function() {
105
+ return {
106
+ width: o,
107
+ height: r
108
+ };
109
+ }, this.render = function(n, s) {
110
+ const T = s.projectionMatrix.elements[5] * a;
111
+ s.view && s.view.enabled ? (b.style.transform = `translate( ${-s.view.offsetX * (o / s.view.width)}px, ${-s.view.offsetY * (r / s.view.height)}px )`, b.style.transform += `scale( ${s.view.fullWidth / s.view.width}, ${s.view.fullHeight / s.view.height} )`) : b.style.transform = "", n.matrixWorldAutoUpdate === !0 && n.updateMatrixWorld(), s.parent === null && s.matrixWorldAutoUpdate === !0 && s.updateMatrixWorld();
112
+ let B, M;
113
+ s.isOrthographicCamera && (B = -(s.right + s.left) / 2, M = (s.top + s.bottom) / 2);
114
+ const A = s.view && s.view.enabled ? s.view.height / s.view.fullHeight : 1, I = s.isOrthographicCamera ? `scale( ${A} )scale(` + T + ")translate(" + h(B) + "px," + h(M) + "px)" + O(s.matrixWorldInverse) : `scale( ${A} )translateZ(` + T + "px)" + O(s.matrixWorldInverse), l = (s.isPerspectiveCamera ? "perspective(" + T + "px) " : "") + I + "translate(" + c + "px," + a + "px)";
115
+ f.camera.style !== l && (m.style.transform = l, f.camera.style = l), k(n, n, s);
116
+ }, this.setSize = function(n, s) {
117
+ o = n, r = s, c = o / 2, a = r / 2, P.style.width = n + "px", P.style.height = s + "px", b.style.width = n + "px", b.style.height = s + "px", m.style.width = n + "px", m.style.height = s + "px";
118
+ };
119
+ function h(n) {
120
+ return Math.abs(n) < 1e-10 ? 0 : n;
121
+ }
122
+ function O(n) {
123
+ const s = n.elements;
124
+ return "matrix3d(" + h(s[0]) + "," + h(-s[1]) + "," + h(s[2]) + "," + h(s[3]) + "," + h(s[4]) + "," + h(-s[5]) + "," + h(s[6]) + "," + h(s[7]) + "," + h(s[8]) + "," + h(-s[9]) + "," + h(s[10]) + "," + h(s[11]) + "," + h(s[12]) + "," + h(-s[13]) + "," + h(s[14]) + "," + h(s[15]) + ")";
125
+ }
126
+ function v(n) {
127
+ const s = n.elements;
128
+ return "translate(-50%,-50%)" + ("matrix3d(" + h(s[0]) + "," + h(s[1]) + "," + h(s[2]) + "," + h(s[3]) + "," + h(-s[4]) + "," + h(-s[5]) + "," + h(-s[6]) + "," + h(-s[7]) + "," + h(s[8]) + "," + h(s[9]) + "," + h(s[10]) + "," + h(s[11]) + "," + h(s[12]) + "," + h(s[13]) + "," + h(s[14]) + "," + h(s[15]) + ")");
129
+ }
130
+ function C(n) {
131
+ n.isCSS3DObject && (n.element.style.display = "none");
132
+ for (let s = 0, T = n.children.length; s < T; s++)
133
+ C(n.children[s]);
134
+ }
135
+ function k(n, s, T, B) {
136
+ if (n.visible === !1) {
137
+ C(n);
138
+ return;
139
+ }
140
+ if (n.isCSS3DObject) {
141
+ const M = n.layers.test(T.layers) === !0, A = n.element;
142
+ if (A.style.display = M === !0 ? "" : "none", M === !0) {
143
+ n.onBeforeRender(i, s, T);
144
+ let I;
145
+ n.isCSS3DSprite ? (H.copy(T.matrixWorldInverse), H.transpose(), n.rotation2D !== 0 && H.multiply(Ct.makeRotationZ(n.rotation2D)), n.matrixWorld.decompose(rt, Lt, ht), H.setPosition(rt), H.scale(ht), H.elements[3] = 0, H.elements[7] = 0, H.elements[11] = 0, H.elements[15] = 1, I = v(H)) : I = v(n.matrixWorld);
146
+ const N = f.objects.get(n);
147
+ if (N === void 0 || N.style !== I) {
148
+ A.style.transform = I;
149
+ const l = { style: I };
150
+ f.objects.set(n, l);
151
+ }
152
+ A.parentNode !== m && m.appendChild(A), n.onAfterRender(i, s, T);
153
+ }
154
+ }
155
+ for (let M = 0, A = n.children.length; M < A; M++)
156
+ k(n.children[M], s, T);
157
+ }
158
+ }
159
+ }
160
+ const lt = { type: "change" }, it = { type: "start" }, ut = { type: "end" }, q = new Et(), ct = new bt(), kt = Math.cos(70 * wt.DEG2RAD), S = new x(), R = 2 * Math.PI, d = {
161
+ NONE: -1,
162
+ ROTATE: 0,
163
+ DOLLY: 1,
164
+ PAN: 2,
165
+ TOUCH_ROTATE: 3,
166
+ TOUCH_PAN: 4,
167
+ TOUCH_DOLLY_PAN: 5,
168
+ TOUCH_DOLLY_ROTATE: 6
169
+ }, Q = 1e-6;
170
+ class mt extends gt {
171
+ /**
172
+ * Constructs a new controls instance.
173
+ *
174
+ * @param {Object3D} object - The object that is managed by the controls.
175
+ * @param {?HTMLDOMElement} domElement - The HTML element used for event listeners.
176
+ */
177
+ constructor(t, i = null) {
178
+ super(t, i), this.state = d.NONE, this.target = new x(), this.cursor = new x(), 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: z.ROTATE, MIDDLE: z.DOLLY, RIGHT: z.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 x(), this._lastQuaternion = new et(), this._lastTargetPosition = new x(), this._quat = new et().setFromUnitVectors(t.up, new x(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new nt(), this._sphericalDelta = new nt(), this._scale = 1, this._panOffset = new x(), this._rotateStart = new L(), this._rotateEnd = new L(), this._rotateDelta = new L(), this._panStart = new L(), this._panEnd = new L(), this._panDelta = new L(), this._dollyStart = new L(), this._dollyEnd = new L(), this._dollyDelta = new L(), this._dollyDirection = new x(), this._mouse = new L(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = Nt.bind(this), this._onPointerDown = It.bind(this), this._onPointerUp = Ht.bind(this), this._onContextMenu = Bt.bind(this), this._onMouseWheel = Yt.bind(this), this._onKeyDown = zt.bind(this), this._onTouchStart = Gt.bind(this), this._onTouchMove = Ft.bind(this), this._onMouseDown = jt.bind(this), this._onMouseMove = Ut.bind(this), this._interceptControlDown = Zt.bind(this), this._interceptControlUp = Wt.bind(this), this.domElement !== null && this.connect(this.domElement), this.update();
179
+ }
180
+ connect(t) {
181
+ super.connect(t), 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";
182
+ }
183
+ disconnect() {
184
+ 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";
185
+ }
186
+ dispose() {
187
+ this.disconnect();
188
+ }
189
+ /**
190
+ * Get the current vertical rotation, in radians.
191
+ *
192
+ * @return {number} The current vertical rotation, in radians.
193
+ */
194
+ getPolarAngle() {
195
+ return this._spherical.phi;
196
+ }
197
+ /**
198
+ * Get the current horizontal rotation, in radians.
199
+ *
200
+ * @return {number} The current horizontal rotation, in radians.
201
+ */
202
+ getAzimuthalAngle() {
203
+ return this._spherical.theta;
204
+ }
205
+ /**
206
+ * Returns the distance from the camera to the target.
207
+ *
208
+ * @return {number} The distance from the camera to the target.
209
+ */
210
+ getDistance() {
211
+ return this.object.position.distanceTo(this.target);
212
+ }
213
+ /**
214
+ * Adds key event listeners to the given DOM element.
215
+ * `window` is a recommended argument for using this method.
216
+ *
217
+ * @param {HTMLDOMElement} domElement - The DOM element
218
+ */
219
+ listenToKeyEvents(t) {
220
+ t.addEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = t;
221
+ }
222
+ /**
223
+ * Removes the key event listener previously defined with `listenToKeyEvents()`.
224
+ */
225
+ stopListenToKeyEvents() {
226
+ this._domElementKeyEvents !== null && (this._domElementKeyEvents.removeEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = null);
227
+ }
228
+ /**
229
+ * Save the current state of the controls. This can later be recovered with `reset()`.
230
+ */
231
+ saveState() {
232
+ this.target0.copy(this.target), this.position0.copy(this.object.position), this.zoom0 = this.object.zoom;
233
+ }
234
+ /**
235
+ * Reset the controls to their state from either the last time the `saveState()`
236
+ * was called, or the initial state.
237
+ */
238
+ reset() {
239
+ this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(lt), this.update(), this.state = d.NONE;
240
+ }
241
+ update(t = null) {
242
+ const i = this.object.position;
243
+ S.copy(i).sub(this.target), S.applyQuaternion(this._quat), this._spherical.setFromVector3(S), this.autoRotate && this.state === d.NONE && this._rotateLeft(this._getAutoRotationAngle(t)), 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);
244
+ let o = this.minAzimuthAngle, r = this.maxAzimuthAngle;
245
+ isFinite(o) && isFinite(r) && (o < -Math.PI ? o += R : o > Math.PI && (o -= R), r < -Math.PI ? r += R : r > Math.PI && (r -= R), o <= r ? this._spherical.theta = Math.max(o, Math.min(r, this._spherical.theta)) : this._spherical.theta = this._spherical.theta > (o + r) / 2 ? Math.max(o, this._spherical.theta) : Math.min(r, 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);
246
+ let c = !1;
247
+ if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera)
248
+ this._spherical.radius = this._clampDistance(this._spherical.radius);
249
+ else {
250
+ const a = this._spherical.radius;
251
+ this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale), c = a != this._spherical.radius;
252
+ }
253
+ if (S.setFromSpherical(this._spherical), S.applyQuaternion(this._quatInverse), i.copy(this.target).add(S), 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) {
254
+ let a = null;
255
+ if (this.object.isPerspectiveCamera) {
256
+ const f = S.length();
257
+ a = this._clampDistance(f * this._scale);
258
+ const P = f - a;
259
+ this.object.position.addScaledVector(this._dollyDirection, P), this.object.updateMatrixWorld(), c = !!P;
260
+ } else if (this.object.isOrthographicCamera) {
261
+ const f = new x(this._mouse.x, this._mouse.y, 0);
262
+ f.unproject(this.object);
263
+ const P = this.object.zoom;
264
+ this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(), c = P !== this.object.zoom;
265
+ const b = new x(this._mouse.x, this._mouse.y, 0);
266
+ b.unproject(this.object), this.object.position.sub(b).add(f), this.object.updateMatrixWorld(), a = S.length();
267
+ } else
268
+ console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), this.zoomToCursor = !1;
269
+ a !== null && (this.screenSpacePanning ? this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position) : (q.origin.copy(this.object.position), q.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot(q.direction)) < kt ? this.object.lookAt(this.target) : (ct.setFromNormalAndCoplanarPoint(this.object.up, this.target), q.intersectPlane(ct, this.target))));
270
+ } else if (this.object.isOrthographicCamera) {
271
+ const a = this.object.zoom;
272
+ this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), a !== this.object.zoom && (this.object.updateProjectionMatrix(), c = !0);
273
+ }
274
+ return this._scale = 1, this._performCursorZoom = !1, c || this._lastPosition.distanceToSquared(this.object.position) > Q || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > Q || this._lastTargetPosition.distanceToSquared(this.target) > Q ? (this.dispatchEvent(lt), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1;
275
+ }
276
+ _getAutoRotationAngle(t) {
277
+ return t !== null ? R / 60 * this.autoRotateSpeed * t : R / 60 / 60 * this.autoRotateSpeed;
278
+ }
279
+ _getZoomScale(t) {
280
+ const i = Math.abs(t * 0.01);
281
+ return Math.pow(0.95, this.zoomSpeed * i);
282
+ }
283
+ _rotateLeft(t) {
284
+ this._sphericalDelta.theta -= t;
285
+ }
286
+ _rotateUp(t) {
287
+ this._sphericalDelta.phi -= t;
288
+ }
289
+ _panLeft(t, i) {
290
+ S.setFromMatrixColumn(i, 0), S.multiplyScalar(-t), this._panOffset.add(S);
291
+ }
292
+ _panUp(t, i) {
293
+ this.screenSpacePanning === !0 ? S.setFromMatrixColumn(i, 1) : (S.setFromMatrixColumn(i, 0), S.crossVectors(this.object.up, S)), S.multiplyScalar(t), this._panOffset.add(S);
294
+ }
295
+ // deltaX and deltaY are in pixels; right and down are positive
296
+ _pan(t, i) {
297
+ const o = this.domElement;
298
+ if (this.object.isPerspectiveCamera) {
299
+ const r = this.object.position;
300
+ S.copy(r).sub(this.target);
301
+ let c = S.length();
302
+ c *= Math.tan(this.object.fov / 2 * Math.PI / 180), this._panLeft(2 * t * c / o.clientHeight, this.object.matrix), this._panUp(2 * i * c / o.clientHeight, this.object.matrix);
303
+ } else this.object.isOrthographicCamera ? (this._panLeft(t * (this.object.right - this.object.left) / this.object.zoom / o.clientWidth, this.object.matrix), this._panUp(i * (this.object.top - this.object.bottom) / this.object.zoom / o.clientHeight, this.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), this.enablePan = !1);
304
+ }
305
+ _dollyOut(t) {
306
+ this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale /= t : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1);
307
+ }
308
+ _dollyIn(t) {
309
+ this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale *= t : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1);
310
+ }
311
+ _updateZoomParameters(t, i) {
312
+ if (!this.zoomToCursor)
313
+ return;
314
+ this._performCursorZoom = !0;
315
+ const o = this.domElement.getBoundingClientRect(), r = t - o.left, c = i - o.top, a = o.width, f = o.height;
316
+ this._mouse.x = r / a * 2 - 1, this._mouse.y = -(c / f) * 2 + 1, this._dollyDirection.set(this._mouse.x, this._mouse.y, 1).unproject(this.object).sub(this.object.position).normalize();
317
+ }
318
+ _clampDistance(t) {
319
+ return Math.max(this.minDistance, Math.min(this.maxDistance, t));
320
+ }
321
+ //
322
+ // event callbacks - update the object state
323
+ //
324
+ _handleMouseDownRotate(t) {
325
+ this._rotateStart.set(t.clientX, t.clientY);
326
+ }
327
+ _handleMouseDownDolly(t) {
328
+ this._updateZoomParameters(t.clientX, t.clientX), this._dollyStart.set(t.clientX, t.clientY);
329
+ }
330
+ _handleMouseDownPan(t) {
331
+ this._panStart.set(t.clientX, t.clientY);
332
+ }
333
+ _handleMouseMoveRotate(t) {
334
+ this._rotateEnd.set(t.clientX, t.clientY), this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
335
+ const i = this.domElement;
336
+ this._rotateLeft(R * this._rotateDelta.x / i.clientHeight), this._rotateUp(R * this._rotateDelta.y / i.clientHeight), this._rotateStart.copy(this._rotateEnd), this.update();
337
+ }
338
+ _handleMouseMoveDolly(t) {
339
+ this._dollyEnd.set(t.clientX, t.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();
340
+ }
341
+ _handleMouseMovePan(t) {
342
+ this._panEnd.set(t.clientX, t.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();
343
+ }
344
+ _handleMouseWheel(t) {
345
+ this._updateZoomParameters(t.clientX, t.clientY), t.deltaY < 0 ? this._dollyIn(this._getZoomScale(t.deltaY)) : t.deltaY > 0 && this._dollyOut(this._getZoomScale(t.deltaY)), this.update();
346
+ }
347
+ _handleKeyDown(t) {
348
+ let i = !1;
349
+ switch (t.code) {
350
+ case this.keys.UP:
351
+ t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateUp(R * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, this.keyPanSpeed), i = !0;
352
+ break;
353
+ case this.keys.BOTTOM:
354
+ t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateUp(-R * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, -this.keyPanSpeed), i = !0;
355
+ break;
356
+ case this.keys.LEFT:
357
+ t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateLeft(R * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(this.keyPanSpeed, 0), i = !0;
358
+ break;
359
+ case this.keys.RIGHT:
360
+ t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateLeft(-R * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(-this.keyPanSpeed, 0), i = !0;
361
+ break;
362
+ }
363
+ i && (t.preventDefault(), this.update());
364
+ }
365
+ _handleTouchStartRotate(t) {
366
+ if (this._pointers.length === 1)
367
+ this._rotateStart.set(t.pageX, t.pageY);
368
+ else {
369
+ const i = this._getSecondPointerPosition(t), o = 0.5 * (t.pageX + i.x), r = 0.5 * (t.pageY + i.y);
370
+ this._rotateStart.set(o, r);
371
+ }
372
+ }
373
+ _handleTouchStartPan(t) {
374
+ if (this._pointers.length === 1)
375
+ this._panStart.set(t.pageX, t.pageY);
376
+ else {
377
+ const i = this._getSecondPointerPosition(t), o = 0.5 * (t.pageX + i.x), r = 0.5 * (t.pageY + i.y);
378
+ this._panStart.set(o, r);
379
+ }
380
+ }
381
+ _handleTouchStartDolly(t) {
382
+ const i = this._getSecondPointerPosition(t), o = t.pageX - i.x, r = t.pageY - i.y, c = Math.sqrt(o * o + r * r);
383
+ this._dollyStart.set(0, c);
384
+ }
385
+ _handleTouchStartDollyPan(t) {
386
+ this.enableZoom && this._handleTouchStartDolly(t), this.enablePan && this._handleTouchStartPan(t);
387
+ }
388
+ _handleTouchStartDollyRotate(t) {
389
+ this.enableZoom && this._handleTouchStartDolly(t), this.enableRotate && this._handleTouchStartRotate(t);
390
+ }
391
+ _handleTouchMoveRotate(t) {
392
+ if (this._pointers.length == 1)
393
+ this._rotateEnd.set(t.pageX, t.pageY);
394
+ else {
395
+ const o = this._getSecondPointerPosition(t), r = 0.5 * (t.pageX + o.x), c = 0.5 * (t.pageY + o.y);
396
+ this._rotateEnd.set(r, c);
397
+ }
398
+ this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
399
+ const i = this.domElement;
400
+ this._rotateLeft(R * this._rotateDelta.x / i.clientHeight), this._rotateUp(R * this._rotateDelta.y / i.clientHeight), this._rotateStart.copy(this._rotateEnd);
401
+ }
402
+ _handleTouchMovePan(t) {
403
+ if (this._pointers.length === 1)
404
+ this._panEnd.set(t.pageX, t.pageY);
405
+ else {
406
+ const i = this._getSecondPointerPosition(t), o = 0.5 * (t.pageX + i.x), r = 0.5 * (t.pageY + i.y);
407
+ this._panEnd.set(o, r);
408
+ }
409
+ this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd);
410
+ }
411
+ _handleTouchMoveDolly(t) {
412
+ const i = this._getSecondPointerPosition(t), o = t.pageX - i.x, r = t.pageY - i.y, c = Math.sqrt(o * o + r * r);
413
+ this._dollyEnd.set(0, c), this._dollyDelta.set(0, Math.pow(this._dollyEnd.y / this._dollyStart.y, this.zoomSpeed)), this._dollyOut(this._dollyDelta.y), this._dollyStart.copy(this._dollyEnd);
414
+ const a = (t.pageX + i.x) * 0.5, f = (t.pageY + i.y) * 0.5;
415
+ this._updateZoomParameters(a, f);
416
+ }
417
+ _handleTouchMoveDollyPan(t) {
418
+ this.enableZoom && this._handleTouchMoveDolly(t), this.enablePan && this._handleTouchMovePan(t);
419
+ }
420
+ _handleTouchMoveDollyRotate(t) {
421
+ this.enableZoom && this._handleTouchMoveDolly(t), this.enableRotate && this._handleTouchMoveRotate(t);
422
+ }
423
+ // pointers
424
+ _addPointer(t) {
425
+ this._pointers.push(t.pointerId);
426
+ }
427
+ _removePointer(t) {
428
+ delete this._pointerPositions[t.pointerId];
429
+ for (let i = 0; i < this._pointers.length; i++)
430
+ if (this._pointers[i] == t.pointerId) {
431
+ this._pointers.splice(i, 1);
432
+ return;
433
+ }
434
+ }
435
+ _isTrackingPointer(t) {
436
+ for (let i = 0; i < this._pointers.length; i++)
437
+ if (this._pointers[i] == t.pointerId) return !0;
438
+ return !1;
439
+ }
440
+ _trackPointer(t) {
441
+ let i = this._pointerPositions[t.pointerId];
442
+ i === void 0 && (i = new L(), this._pointerPositions[t.pointerId] = i), i.set(t.pageX, t.pageY);
443
+ }
444
+ _getSecondPointerPosition(t) {
445
+ const i = t.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0];
446
+ return this._pointerPositions[i];
447
+ }
448
+ //
449
+ _customWheelEvent(t) {
450
+ const i = t.deltaMode, o = {
451
+ clientX: t.clientX,
452
+ clientY: t.clientY,
453
+ deltaY: t.deltaY
454
+ };
455
+ switch (i) {
456
+ case 1:
457
+ o.deltaY *= 16;
458
+ break;
459
+ case 2:
460
+ o.deltaY *= 100;
461
+ break;
462
+ }
463
+ return t.ctrlKey && !this._controlActive && (o.deltaY *= 10), o;
464
+ }
465
+ }
466
+ function It(e) {
467
+ this.enabled !== !1 && (this._pointers.length === 0 && (this.domElement.setPointerCapture(e.pointerId), this.domElement.addEventListener("pointermove", this._onPointerMove), this.domElement.addEventListener("pointerup", this._onPointerUp)), !this._isTrackingPointer(e) && (this._addPointer(e), e.pointerType === "touch" ? this._onTouchStart(e) : this._onMouseDown(e)));
468
+ }
469
+ function Nt(e) {
470
+ this.enabled !== !1 && (e.pointerType === "touch" ? this._onTouchMove(e) : this._onMouseMove(e));
471
+ }
472
+ function Ht(e) {
473
+ switch (this._removePointer(e), this._pointers.length) {
474
+ case 0:
475
+ this.domElement.releasePointerCapture(e.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(ut), this.state = d.NONE;
476
+ break;
477
+ case 1:
478
+ const t = this._pointers[0], i = this._pointerPositions[t];
479
+ this._onTouchStart({ pointerId: t, pageX: i.x, pageY: i.y });
480
+ break;
481
+ }
482
+ }
483
+ function jt(e) {
484
+ let t;
485
+ switch (e.button) {
486
+ case 0:
487
+ t = this.mouseButtons.LEFT;
488
+ break;
489
+ case 1:
490
+ t = this.mouseButtons.MIDDLE;
491
+ break;
492
+ case 2:
493
+ t = this.mouseButtons.RIGHT;
494
+ break;
495
+ default:
496
+ t = -1;
497
+ }
498
+ switch (t) {
499
+ case z.DOLLY:
500
+ if (this.enableZoom === !1) return;
501
+ this._handleMouseDownDolly(e), this.state = d.DOLLY;
502
+ break;
503
+ case z.ROTATE:
504
+ if (e.ctrlKey || e.metaKey || e.shiftKey) {
505
+ if (this.enablePan === !1) return;
506
+ this._handleMouseDownPan(e), this.state = d.PAN;
507
+ } else {
508
+ if (this.enableRotate === !1) return;
509
+ this._handleMouseDownRotate(e), this.state = d.ROTATE;
510
+ }
511
+ break;
512
+ case z.PAN:
513
+ if (e.ctrlKey || e.metaKey || e.shiftKey) {
514
+ if (this.enableRotate === !1) return;
515
+ this._handleMouseDownRotate(e), this.state = d.ROTATE;
516
+ } else {
517
+ if (this.enablePan === !1) return;
518
+ this._handleMouseDownPan(e), this.state = d.PAN;
519
+ }
520
+ break;
521
+ default:
522
+ this.state = d.NONE;
523
+ }
524
+ this.state !== d.NONE && this.dispatchEvent(it);
525
+ }
526
+ function Ut(e) {
527
+ switch (this.state) {
528
+ case d.ROTATE:
529
+ if (this.enableRotate === !1) return;
530
+ this._handleMouseMoveRotate(e);
531
+ break;
532
+ case d.DOLLY:
533
+ if (this.enableZoom === !1) return;
534
+ this._handleMouseMoveDolly(e);
535
+ break;
536
+ case d.PAN:
537
+ if (this.enablePan === !1) return;
538
+ this._handleMouseMovePan(e);
539
+ break;
540
+ }
541
+ }
542
+ function Yt(e) {
543
+ this.enabled === !1 || this.enableZoom === !1 || this.state !== d.NONE || (e.preventDefault(), this.dispatchEvent(it), this._handleMouseWheel(this._customWheelEvent(e)), this.dispatchEvent(ut));
544
+ }
545
+ function zt(e) {
546
+ this.enabled !== !1 && this._handleKeyDown(e);
547
+ }
548
+ function Gt(e) {
549
+ switch (this._trackPointer(e), this._pointers.length) {
550
+ case 1:
551
+ switch (this.touches.ONE) {
552
+ case G.ROTATE:
553
+ if (this.enableRotate === !1) return;
554
+ this._handleTouchStartRotate(e), this.state = d.TOUCH_ROTATE;
555
+ break;
556
+ case G.PAN:
557
+ if (this.enablePan === !1) return;
558
+ this._handleTouchStartPan(e), this.state = d.TOUCH_PAN;
559
+ break;
560
+ default:
561
+ this.state = d.NONE;
562
+ }
563
+ break;
564
+ case 2:
565
+ switch (this.touches.TWO) {
566
+ case G.DOLLY_PAN:
567
+ if (this.enableZoom === !1 && this.enablePan === !1) return;
568
+ this._handleTouchStartDollyPan(e), this.state = d.TOUCH_DOLLY_PAN;
569
+ break;
570
+ case G.DOLLY_ROTATE:
571
+ if (this.enableZoom === !1 && this.enableRotate === !1) return;
572
+ this._handleTouchStartDollyRotate(e), this.state = d.TOUCH_DOLLY_ROTATE;
573
+ break;
574
+ default:
575
+ this.state = d.NONE;
576
+ }
577
+ break;
578
+ default:
579
+ this.state = d.NONE;
580
+ }
581
+ this.state !== d.NONE && this.dispatchEvent(it);
582
+ }
583
+ function Ft(e) {
584
+ switch (this._trackPointer(e), this.state) {
585
+ case d.TOUCH_ROTATE:
586
+ if (this.enableRotate === !1) return;
587
+ this._handleTouchMoveRotate(e), this.update();
588
+ break;
589
+ case d.TOUCH_PAN:
590
+ if (this.enablePan === !1) return;
591
+ this._handleTouchMovePan(e), this.update();
592
+ break;
593
+ case d.TOUCH_DOLLY_PAN:
594
+ if (this.enableZoom === !1 && this.enablePan === !1) return;
595
+ this._handleTouchMoveDollyPan(e), this.update();
596
+ break;
597
+ case d.TOUCH_DOLLY_ROTATE:
598
+ if (this.enableZoom === !1 && this.enableRotate === !1) return;
599
+ this._handleTouchMoveDollyRotate(e), this.update();
600
+ break;
601
+ default:
602
+ this.state = d.NONE;
603
+ }
604
+ }
605
+ function Bt(e) {
606
+ this.enabled !== !1 && e.preventDefault();
607
+ }
608
+ function Zt(e) {
609
+ e.key === "Control" && (this._controlActive = !0, this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
610
+ }
611
+ function Wt(e) {
612
+ e.key === "Control" && (this._controlActive = !1, this.domElement.getRootNode().removeEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
613
+ }
614
+ class Kt extends mt {
615
+ constructor(t, i) {
616
+ super(t, i), this.screenSpacePanning = !1, this.mouseButtons = { LEFT: z.PAN, MIDDLE: z.DOLLY, RIGHT: z.ROTATE }, this.touches = { ONE: G.PAN, TWO: G.DOLLY_ROTATE };
617
+ }
618
+ }
619
+ function ne(e) {
620
+ return new Dt(e);
621
+ }
622
+ function ae(e = 150, ...t) {
623
+ return new St(e, e / 10, ...t);
624
+ }
625
+ function re(e) {
626
+ return new Pt(e, 16776960);
627
+ }
628
+ function he(e, t) {
629
+ return new mt(e, t);
630
+ }
631
+ function le(e, t) {
632
+ return new Kt(e, t);
633
+ }
634
+ function ce() {
635
+ const e = new Tt(), t = new L(0, 0);
636
+ return {
637
+ raycaster: e,
638
+ pointer: t
639
+ };
640
+ }
641
+ function pe(e = 10) {
642
+ return new Mt(e);
643
+ }
644
+ function de(e = new x(1, 1, 1), t = new x(10, 10, 10), i = 5, o = 16776960) {
645
+ return e.normalize(), new Rt(e, t, i, o);
646
+ }
647
+ function ue() {
648
+ const e = new K();
649
+ return e.dom.style.cssText = "position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000", e;
650
+ }
651
+ class Xt extends xt {
652
+ /**
653
+ * Constructs a new RGBE loader.
654
+ *
655
+ * @param {LoadingManager} [manager] - The loading manager.
656
+ */
657
+ constructor(t) {
658
+ super(t), this.type = X;
659
+ }
660
+ /**
661
+ * Parses the given RGBE texture data.
662
+ *
663
+ * @param {ArrayBuffer} buffer - The raw texture data.
664
+ * @return {DataTextureLoader~TexData} An object representing the parsed texture data.
665
+ */
666
+ parse(t) {
667
+ const a = function(l, u) {
668
+ switch (l) {
669
+ case 1:
670
+ throw new Error("THREE.RGBELoader: Read Error: " + (u || ""));
671
+ case 2:
672
+ throw new Error("THREE.RGBELoader: Write Error: " + (u || ""));
673
+ case 3:
674
+ throw new Error("THREE.RGBELoader: Bad File Format: " + (u || ""));
675
+ default:
676
+ case 4:
677
+ throw new Error("THREE.RGBELoader: Memory Error: " + (u || ""));
678
+ }
679
+ }, m = `
680
+ `, h = function(l, u, y) {
681
+ u = u || 1024;
682
+ let w = l.pos, E = -1, p = 0, D = "", _ = String.fromCharCode.apply(null, new Uint16Array(l.subarray(w, w + 128)));
683
+ for (; 0 > (E = _.indexOf(m)) && p < u && w < l.byteLength; )
684
+ D += _, p += _.length, w += 128, _ += String.fromCharCode.apply(null, new Uint16Array(l.subarray(w, w + 128)));
685
+ return -1 < E ? (l.pos += p + E + 1, D + _.slice(0, E)) : !1;
686
+ }, O = function(l) {
687
+ const u = /^#\?(\S+)/, y = /^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/, g = /^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/, w = /^\s*FORMAT=(\S+)\s*$/, E = /^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/, p = {
688
+ valid: 0,
689
+ /* indicate which fields are valid */
690
+ string: "",
691
+ /* the actual header string */
692
+ comments: "",
693
+ /* comments found in header */
694
+ programtype: "RGBE",
695
+ /* listed at beginning of file to identify it after "#?". defaults to "RGBE" */
696
+ format: "",
697
+ /* RGBE format, default 32-bit_rle_rgbe */
698
+ gamma: 1,
699
+ /* image has already been gamma corrected with given gamma. defaults to 1.0 (no correction) */
700
+ exposure: 1,
701
+ /* a value of 1.0 in an image corresponds to <exposure> watts/steradian/m^2. defaults to 1.0 */
702
+ width: 0,
703
+ height: 0
704
+ /* image dimensions, width/height */
705
+ };
706
+ let D, _;
707
+ for ((l.pos >= l.byteLength || !(D = h(l))) && a(1, "no header found"), (_ = D.match(u)) || a(3, "bad initial token"), p.valid |= 1, p.programtype = _[1], p.string += D + `
708
+ `; D = h(l), D !== !1; ) {
709
+ if (p.string += D + `
710
+ `, D.charAt(0) === "#") {
711
+ p.comments += D + `
712
+ `;
713
+ continue;
714
+ }
715
+ if ((_ = D.match(y)) && (p.gamma = parseFloat(_[1])), (_ = D.match(g)) && (p.exposure = parseFloat(_[1])), (_ = D.match(w)) && (p.valid |= 2, p.format = _[1]), (_ = D.match(E)) && (p.valid |= 4, p.height = parseInt(_[1], 10), p.width = parseInt(_[2], 10)), p.valid & 2 && p.valid & 4) break;
716
+ }
717
+ return p.valid & 2 || a(3, "missing format specifier"), p.valid & 4 || a(3, "missing image size specifier"), p;
718
+ }, v = function(l, u, y) {
719
+ const g = u;
720
+ if (
721
+ // run length encoding is not allowed so read flat
722
+ g < 8 || g > 32767 || // this file is not run length encoded
723
+ l[0] !== 2 || l[1] !== 2 || l[2] & 128
724
+ )
725
+ return new Uint8Array(l);
726
+ g !== (l[2] << 8 | l[3]) && a(3, "wrong scanline width");
727
+ const w = new Uint8Array(4 * u * y);
728
+ w.length || a(4, "unable to allocate buffer space");
729
+ let E = 0, p = 0;
730
+ const D = 4 * g, _ = new Uint8Array(4), Z = new Uint8Array(D);
731
+ let st = y;
732
+ for (; st > 0 && p < l.byteLength; ) {
733
+ p + 4 > l.byteLength && a(1), _[0] = l[p++], _[1] = l[p++], _[2] = l[p++], _[3] = l[p++], (_[0] != 2 || _[1] != 2 || (_[2] << 8 | _[3]) != g) && a(3, "bad rgbe scanline format");
734
+ let W = 0, j;
735
+ for (; W < D && p < l.byteLength; ) {
736
+ j = l[p++];
737
+ const U = j > 128;
738
+ if (U && (j -= 128), (j === 0 || W + j > D) && a(3, "bad scanline data"), U) {
739
+ const Y = l[p++];
740
+ for (let ot = 0; ot < j; ot++)
741
+ Z[W++] = Y;
742
+ } else
743
+ Z.set(l.subarray(p, p + j), W), W += j, p += j;
744
+ }
745
+ const ft = g;
746
+ for (let U = 0; U < ft; U++) {
747
+ let Y = 0;
748
+ w[E] = Z[U + Y], Y += g, w[E + 1] = Z[U + Y], Y += g, w[E + 2] = Z[U + Y], Y += g, w[E + 3] = Z[U + Y], E += 4;
749
+ }
750
+ st--;
751
+ }
752
+ return w;
753
+ }, C = function(l, u, y, g) {
754
+ const w = l[u + 3], E = Math.pow(2, w - 128) / 255;
755
+ y[g + 0] = l[u + 0] * E, y[g + 1] = l[u + 1] * E, y[g + 2] = l[u + 2] * E, y[g + 3] = 1;
756
+ }, k = function(l, u, y, g) {
757
+ const w = l[u + 3], E = Math.pow(2, w - 128) / 255;
758
+ y[g + 0] = V.toHalfFloat(Math.min(l[u + 0] * E, 65504)), y[g + 1] = V.toHalfFloat(Math.min(l[u + 1] * E, 65504)), y[g + 2] = V.toHalfFloat(Math.min(l[u + 2] * E, 65504)), y[g + 3] = V.toHalfFloat(1);
759
+ }, n = new Uint8Array(t);
760
+ n.pos = 0;
761
+ const s = O(n), T = s.width, B = s.height, M = v(n.subarray(n.pos), T, B);
762
+ let A, I, N;
763
+ switch (this.type) {
764
+ case $:
765
+ N = M.length / 4;
766
+ const l = new Float32Array(N * 4);
767
+ for (let y = 0; y < N; y++)
768
+ C(M, y * 4, l, y * 4);
769
+ A = l, I = $;
770
+ break;
771
+ case X:
772
+ N = M.length / 4;
773
+ const u = new Uint16Array(N * 4);
774
+ for (let y = 0; y < N; y++)
775
+ k(M, y * 4, u, y * 4);
776
+ A = u, I = X;
777
+ break;
778
+ default:
779
+ throw new Error("THREE.RGBELoader: Unsupported type: " + this.type);
780
+ }
781
+ return {
782
+ width: T,
783
+ height: B,
784
+ data: A,
785
+ header: s.string,
786
+ gamma: s.gamma,
787
+ exposure: s.exposure,
788
+ type: I
789
+ };
790
+ }
791
+ /**
792
+ * Sets the texture type.
793
+ *
794
+ * @param {(HalfFloatType|FloatType)} value - The texture type to set.
795
+ * @return {RGBELoader} A reference to this loader.
796
+ */
797
+ setDataType(t) {
798
+ return this.type = t, this;
799
+ }
800
+ load(t, i, o, r) {
801
+ function c(a, f) {
802
+ switch (a.type) {
803
+ case $:
804
+ case X:
805
+ a.colorSpace = At, a.minFilter = at, a.magFilter = at, a.generateMipmaps = !1, a.flipY = !0;
806
+ break;
807
+ }
808
+ i && i(a, f);
809
+ }
810
+ return super.load(t, c, o, r);
811
+ }
812
+ }
813
+ const Vt = (e) => {
814
+ e.geometry && e.geometry.dispose(), e.material && (Array.isArray(e.material) ? e.material.forEach((t) => {
815
+ pt(t);
816
+ }) : pt(e.material)), e.children && e.children.forEach((t) => Vt(t));
817
+ };
818
+ function pt(e) {
819
+ for (const t in e)
820
+ e[t] && e[t].isTexture && e[t].dispose();
821
+ e.dispose();
822
+ }
823
+ const J = {}, _t = new Xt();
824
+ async function me(e, t) {
825
+ if (t) {
826
+ if (J[t]) {
827
+ const i = J[t];
828
+ e.environment = i;
829
+ return;
830
+ }
831
+ return new Promise((i, o) => {
832
+ _t.load(t, i, void 0, o);
833
+ }).then((i) => {
834
+ i.mapping = Ot, e.environment = i, J[t] = i;
835
+ }).catch((i) => {
836
+ console.log(" =====> e:", i);
837
+ });
838
+ }
839
+ }
840
+ async function _e(e) {
841
+ return new Promise((t, i) => {
842
+ _t.load(e, t, void 0, i);
843
+ });
844
+ }
845
+ const tt = {};
846
+ function qt(e) {
847
+ const t = {
848
+ type: e.type,
849
+ name: e.name,
850
+ position: e.position.toArray(),
851
+ rotation: e.rotation.toArray(),
852
+ scale: e.scale.toArray(),
853
+ visible: e.visible,
854
+ children: [],
855
+ geometry: null,
856
+ material: null,
857
+ userData: e.userData
858
+ };
859
+ e.isMesh && (t.geometry = Qt(e.geometry), t.material = te(e.material));
860
+ for (const i of e.children)
861
+ t.children.push(qt(i));
862
+ return t;
863
+ }
864
+ function $t(e) {
865
+ let t;
866
+ switch (e.type) {
867
+ case "Mesh":
868
+ const i = Jt(e.geometry), o = ee(e.material);
869
+ t = new F.Mesh(i, o);
870
+ break;
871
+ case "Group":
872
+ t = new F.Group();
873
+ break;
874
+ case "Object3D":
875
+ t = new F.Object3D();
876
+ break;
877
+ default:
878
+ return console.warn(`Unsupported object type: ${e.type}`), null;
879
+ }
880
+ t.name = e.name, t.position.fromArray(e.position), t.rotation.fromArray(e.rotation), t.scale.fromArray(e.scale), t.visible = e.visible, t.userData = e.userData;
881
+ for (const i of e.children) {
882
+ const o = $t(i);
883
+ o && t.add(o);
884
+ }
885
+ return t;
886
+ }
887
+ function Qt(e) {
888
+ const t = [], { attributes: i, index: o, type: r } = e;
889
+ i.position && (t.position = {
890
+ type: "Float32Array",
891
+ array: Array.from(i.position.array),
892
+ itemSize: 3
893
+ }), i.normal && (t.normal = {
894
+ type: "Float32Array",
895
+ array: Array.from(i.normal.array),
896
+ itemSize: 3
897
+ }), i.uv && (t.uv = {
898
+ type: "Float32Array",
899
+ array: Array.from(i.uv.array),
900
+ itemSize: 2
901
+ });
902
+ const c = {
903
+ type: r,
904
+ attributes: t
905
+ };
906
+ return o && o.array && (c.index = {
907
+ type: "Uint32Array",
908
+ array: Array.from(o.array),
909
+ itemSize: 1
910
+ }), c;
911
+ }
912
+ function Jt(e) {
913
+ const { type: t, attributes: i, index: o } = e, r = new F.BufferGeometry();
914
+ return Object.keys(i).forEach((c) => {
915
+ const { type: a, array: f, itemSize: P } = i[c];
916
+ r.setAttribute(
917
+ c,
918
+ new F.BufferAttribute(new Float32Array(f), P)
919
+ );
920
+ }), o && r.setIndex(o.array), r;
921
+ }
922
+ function te(e) {
923
+ return {
924
+ type: e.type,
925
+ color: e.color.getHex(),
926
+ map: e.map ? e.map.image.src : null,
927
+ opacity: e.opacity,
928
+ name: e.name,
929
+ depthTest: e.depthTest,
930
+ depthWrite: e.depthWrite,
931
+ transparent: e.transparent,
932
+ side: e.side,
933
+ roughness: e.roughness,
934
+ metalness: e.metalness,
935
+ emissive: e.emissive.getHex()
936
+ };
937
+ }
938
+ function ee(e) {
939
+ if (tt[e.name]) return tt[e.name];
940
+ const { type: t, ...i } = e, o = t || "MeshStandardMaterial", r = new F[o]({ ...i });
941
+ if (e.map) {
942
+ const c = new F.TextureLoader().load(e.map);
943
+ r.map = c;
944
+ }
945
+ return r.needsUpdate = !0, tt[e.name] = r, r;
946
+ }
947
+ export {
948
+ oe as C,
949
+ _e as I,
950
+ K as S,
951
+ ae as a,
952
+ re as b,
953
+ ne as c,
954
+ he as d,
955
+ le as e,
956
+ ce as f,
957
+ pe as g,
958
+ de as h,
959
+ ue as i,
960
+ Vt as j,
961
+ me as k,
962
+ $t as l,
963
+ se as m,
964
+ qt as o
965
+ };