@ridp/threejs 0.2.0 → 1.1.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.
Files changed (82) hide show
  1. package/dist/ImageLoader-CB_URfeZ.js +860 -0
  2. package/dist/ImageLoader-DwvBWW6h.cjs +5 -0
  3. package/dist/common-BHi3qsZW.cjs +15 -0
  4. package/dist/{common-DESmndxO.js → common-fbJUHqlj.js} +1 -1
  5. package/dist/hooks.cjs +1 -1
  6. package/dist/hooks.js +7 -9
  7. package/dist/threejs.cjs +1 -1
  8. package/dist/threejs.js +17 -15
  9. package/dist/useGLTFLoader-DHxBLucO.js +5629 -0
  10. package/dist/useGLTFLoader-DM3-7jdq.cjs +4 -0
  11. package/dist/utils.cjs +1 -1
  12. package/dist/utils.js +15 -12
  13. package/esdoc/ast/source/.external-ecmascript.js.json +2802 -0
  14. package/esdoc/ast/source/hooks/index.js.json +739 -0
  15. package/esdoc/ast/source/hooks/useGLTFLoader.js.json +9111 -0
  16. package/esdoc/ast/source/hooks/useObb.js.json +16463 -0
  17. package/esdoc/ast/source/hooks/useRaycaster.js.json +15556 -0
  18. package/esdoc/ast/source/hooks/useThreeJs.js.json +52887 -0
  19. package/esdoc/ast/source/index.js.json +570 -0
  20. package/esdoc/ast/source/instance/IDBCache.js.json +40978 -0
  21. package/esdoc/ast/source/instance/index.js.json +232 -0
  22. package/esdoc/ast/source/utils/ImageLoader.js.json +7037 -0
  23. package/esdoc/ast/source/utils/common.js.json +5134 -0
  24. package/esdoc/ast/source/utils/css3dHelper.js.json +9101 -0
  25. package/esdoc/ast/source/utils/disposeObject.js.json +5978 -0
  26. package/esdoc/ast/source/utils/helper.js.json +10522 -0
  27. package/esdoc/ast/source/utils/index.js.json +908 -0
  28. package/esdoc/badge.svg +17 -0
  29. package/esdoc/class/src/instance/IDBCache.js~IDBCache.html +1299 -0
  30. package/esdoc/coverage.json +86 -0
  31. package/esdoc/css/github.css +83 -0
  32. package/esdoc/css/identifiers.css +37 -0
  33. package/esdoc/css/manual.css +134 -0
  34. package/esdoc/css/prettify-tomorrow.css +132 -0
  35. package/esdoc/css/search.css +84 -0
  36. package/esdoc/css/source.css +55 -0
  37. package/esdoc/css/style.css +608 -0
  38. package/esdoc/css/test.css +58 -0
  39. package/esdoc/file/src/hooks/index.js.html +79 -0
  40. package/esdoc/file/src/hooks/useGLTFLoader.js.html +146 -0
  41. package/esdoc/file/src/hooks/useObb.js.html +149 -0
  42. package/esdoc/file/src/hooks/useRaycaster.js.html +153 -0
  43. package/esdoc/file/src/hooks/useThreeJs.js.html +362 -0
  44. package/esdoc/file/src/index.js.html +78 -0
  45. package/esdoc/file/src/instance/IDBCache.js.html +312 -0
  46. package/esdoc/file/src/instance/index.js.html +76 -0
  47. package/esdoc/file/src/utils/ImageLoader.js.html +118 -0
  48. package/esdoc/file/src/utils/common.js.html +102 -0
  49. package/esdoc/file/src/utils/css3dHelper.js.html +131 -0
  50. package/esdoc/file/src/utils/disposeObject.js.html +114 -0
  51. package/esdoc/file/src/utils/helper.js.html +138 -0
  52. package/esdoc/file/src/utils/index.js.html +80 -0
  53. package/esdoc/function/index.html +2019 -0
  54. package/esdoc/identifiers.html +738 -0
  55. package/esdoc/image/badge.svg +17 -0
  56. package/esdoc/image/esdoc-logo-mini-black.png +0 -0
  57. package/esdoc/image/esdoc-logo-mini.png +0 -0
  58. package/esdoc/image/manual-badge.svg +17 -0
  59. package/esdoc/image/search.png +0 -0
  60. package/esdoc/index.html +153 -0
  61. package/esdoc/index.json +2051 -0
  62. package/esdoc/inject/css/0-cus-style.css +1 -0
  63. package/esdoc/lint.json +1 -0
  64. package/esdoc/script/inherited-summary.js +28 -0
  65. package/esdoc/script/inner-link.js +32 -0
  66. package/esdoc/script/manual.js +12 -0
  67. package/esdoc/script/patch-for-local.js +8 -0
  68. package/esdoc/script/prettify/Apache-License-2.0.txt +202 -0
  69. package/esdoc/script/prettify/prettify.js +46 -0
  70. package/esdoc/script/pretty-print.js +25 -0
  71. package/esdoc/script/search.js +117 -0
  72. package/esdoc/script/search_index.js +572 -0
  73. package/esdoc/script/test-summary.js +54 -0
  74. package/esdoc/source.html +213 -0
  75. package/esdoc/variable/index.html +225 -0
  76. package/package.json +13 -3
  77. package/readme.md +93 -0
  78. package/dist/common-nMt4tIRA.cjs +0 -15
  79. package/dist/disposeObject-BuI3II7v.cjs +0 -1
  80. package/dist/disposeObject-CmFSSgi7.js +0 -616
  81. package/dist/useGLTFLoader-BAoIZjEX.js +0 -2645
  82. package/dist/useGLTFLoader-CGOxhEOO.cjs +0 -6
@@ -1,616 +0,0 @@
1
- import { Object3D as F, Matrix4 as K, Vector3 as _, Quaternion as A, Controls as V, MOUSE as D, TOUCH as w, Spherical as I, Vector2 as y, Ray as B, Plane as q, MathUtils as G, CameraHelper as Q, GridHelper as $, BoxHelper as J, Raycaster as tt, AxesHelper as et, ArrowHelper as it } from "three";
2
- const Y = new _(), st = new A(), H = new _();
3
- class ot extends F {
4
- /**
5
- * Constructs a new CSS3D object.
6
- *
7
- * @param {DOMElement} [element] - The DOM element.
8
- */
9
- constructor(t = document.createElement("div")) {
10
- 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() {
11
- this.traverse(function(i) {
12
- i.element instanceof i.element.ownerDocument.defaultView.Element && i.element.parentNode !== null && i.element.remove();
13
- });
14
- });
15
- }
16
- copy(t, i) {
17
- return super.copy(t, i), this.element = t.element.cloneNode(!0), this;
18
- }
19
- }
20
- class Dt extends ot {
21
- /**
22
- * Constructs a new CSS3D sprite object.
23
- *
24
- * @param {DOMElement} [element] - The DOM element.
25
- */
26
- constructor(t) {
27
- super(t), this.isCSS3DSprite = !0, this.rotation2D = 0;
28
- }
29
- copy(t, i) {
30
- return super.copy(t, i), this.rotation2D = t.rotation2D, this;
31
- }
32
- }
33
- const g = new K(), nt = new K();
34
- class wt {
35
- /**
36
- * Constructs a new CSS3D renderer.
37
- *
38
- * @param {CSS3DRenderer~Parameters} [parameters] - The parameters.
39
- */
40
- constructor(t = {}) {
41
- const i = this;
42
- let o, h, l, p;
43
- const d = {
44
- camera: { style: "" },
45
- objects: /* @__PURE__ */ new WeakMap()
46
- }, b = t.element !== void 0 ? t.element : document.createElement("div");
47
- b.style.overflow = "hidden", this.domElement = b;
48
- const m = document.createElement("div");
49
- m.style.transformOrigin = "0 0", m.style.pointerEvents = "none", b.appendChild(m);
50
- const S = document.createElement("div");
51
- S.style.transformStyle = "preserve-3d", m.appendChild(S), this.getSize = function() {
52
- return {
53
- width: o,
54
- height: h
55
- };
56
- }, this.render = function(n, s) {
57
- const f = s.projectionMatrix.elements[5] * p;
58
- s.view && s.view.enabled ? (m.style.transform = `translate( ${-s.view.offsetX * (o / s.view.width)}px, ${-s.view.offsetY * (h / s.view.height)}px )`, m.style.transform += `scale( ${s.view.fullWidth / s.view.width}, ${s.view.fullHeight / s.view.height} )`) : m.style.transform = "", n.matrixWorldAutoUpdate === !0 && n.updateMatrixWorld(), s.parent === null && s.matrixWorldAutoUpdate === !0 && s.updateMatrixWorld();
59
- let O, E;
60
- s.isOrthographicCamera && (O = -(s.right + s.left) / 2, E = (s.top + s.bottom) / 2);
61
- const P = s.view && s.view.enabled ? s.view.height / s.view.fullHeight : 1, T = s.isOrthographicCamera ? `scale( ${P} )scale(` + f + ")translate(" + a(O) + "px," + a(E) + "px)" + k(s.matrixWorldInverse) : `scale( ${P} )translateZ(` + f + "px)" + k(s.matrixWorldInverse), M = (s.isPerspectiveCamera ? "perspective(" + f + "px) " : "") + T + "translate(" + l + "px," + p + "px)";
62
- d.camera.style !== M && (S.style.transform = M, d.camera.style = M), v(n, n, s);
63
- }, this.setSize = function(n, s) {
64
- o = n, h = s, l = o / 2, p = h / 2, b.style.width = n + "px", b.style.height = s + "px", m.style.width = n + "px", m.style.height = s + "px", S.style.width = n + "px", S.style.height = s + "px";
65
- };
66
- function a(n) {
67
- return Math.abs(n) < 1e-10 ? 0 : n;
68
- }
69
- function k(n) {
70
- const s = n.elements;
71
- return "matrix3d(" + a(s[0]) + "," + a(-s[1]) + "," + a(s[2]) + "," + a(s[3]) + "," + a(s[4]) + "," + a(-s[5]) + "," + a(s[6]) + "," + a(s[7]) + "," + a(s[8]) + "," + a(-s[9]) + "," + a(s[10]) + "," + a(s[11]) + "," + a(s[12]) + "," + a(-s[13]) + "," + a(s[14]) + "," + a(s[15]) + ")";
72
- }
73
- function N(n) {
74
- const s = n.elements;
75
- return "translate(-50%,-50%)" + ("matrix3d(" + a(s[0]) + "," + a(s[1]) + "," + a(s[2]) + "," + a(s[3]) + "," + a(-s[4]) + "," + a(-s[5]) + "," + a(-s[6]) + "," + a(-s[7]) + "," + a(s[8]) + "," + a(s[9]) + "," + a(s[10]) + "," + a(s[11]) + "," + a(s[12]) + "," + a(s[13]) + "," + a(s[14]) + "," + a(s[15]) + ")");
76
- }
77
- function j(n) {
78
- n.isCSS3DObject && (n.element.style.display = "none");
79
- for (let s = 0, f = n.children.length; s < f; s++)
80
- j(n.children[s]);
81
- }
82
- function v(n, s, f, O) {
83
- if (n.visible === !1) {
84
- j(n);
85
- return;
86
- }
87
- if (n.isCSS3DObject) {
88
- const E = n.layers.test(f.layers) === !0, P = n.element;
89
- if (P.style.display = E === !0 ? "" : "none", E === !0) {
90
- n.onBeforeRender(i, s, f);
91
- let T;
92
- n.isCSS3DSprite ? (g.copy(f.matrixWorldInverse), g.transpose(), n.rotation2D !== 0 && g.multiply(nt.makeRotationZ(n.rotation2D)), n.matrixWorld.decompose(Y, st, H), g.setPosition(Y), g.scale(H), g.elements[3] = 0, g.elements[7] = 0, g.elements[11] = 0, g.elements[15] = 1, T = N(g)) : T = N(n.matrixWorld);
93
- const R = d.objects.get(n);
94
- if (R === void 0 || R.style !== T) {
95
- P.style.transform = T;
96
- const M = { style: T };
97
- d.objects.set(n, M);
98
- }
99
- P.parentNode !== S && S.appendChild(P), n.onAfterRender(i, s, f);
100
- }
101
- }
102
- for (let E = 0, P = n.children.length; E < P; E++)
103
- v(n.children[E], s, f);
104
- }
105
- }
106
- }
107
- const U = { type: "change" }, L = { type: "start" }, W = { type: "end" }, x = new B(), Z = new q(), at = Math.cos(70 * G.DEG2RAD), c = new _(), u = 2 * Math.PI, r = {
108
- NONE: -1,
109
- ROTATE: 0,
110
- DOLLY: 1,
111
- PAN: 2,
112
- TOUCH_ROTATE: 3,
113
- TOUCH_PAN: 4,
114
- TOUCH_DOLLY_PAN: 5,
115
- TOUCH_DOLLY_ROTATE: 6
116
- }, C = 1e-6;
117
- class X extends V {
118
- /**
119
- * Constructs a new controls instance.
120
- *
121
- * @param {Object3D} object - The object that is managed by the controls.
122
- * @param {?HTMLDOMElement} domElement - The HTML element used for event listeners.
123
- */
124
- constructor(t, i = null) {
125
- super(t, i), this.state = r.NONE, this.target = new _(), this.cursor = new _(), 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: D.ROTATE, MIDDLE: D.DOLLY, RIGHT: D.PAN }, this.touches = { ONE: w.ROTATE, TWO: w.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this._lastPosition = new _(), this._lastQuaternion = new A(), this._lastTargetPosition = new _(), this._quat = new A().setFromUnitVectors(t.up, new _(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new I(), this._sphericalDelta = new I(), this._scale = 1, this._panOffset = new _(), this._rotateStart = new y(), this._rotateEnd = new y(), this._rotateDelta = new y(), this._panStart = new y(), this._panEnd = new y(), this._panDelta = new y(), this._dollyStart = new y(), this._dollyEnd = new y(), this._dollyDelta = new y(), this._dollyDirection = new _(), this._mouse = new y(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = rt.bind(this), this._onPointerDown = ht.bind(this), this._onPointerUp = lt.bind(this), this._onContextMenu = ft.bind(this), this._onMouseWheel = dt.bind(this), this._onKeyDown = ut.bind(this), this._onTouchStart = _t.bind(this), this._onTouchMove = mt.bind(this), this._onMouseDown = ct.bind(this), this._onMouseMove = pt.bind(this), this._interceptControlDown = yt.bind(this), this._interceptControlUp = bt.bind(this), this.domElement !== null && this.connect(this.domElement), this.update();
126
- }
127
- connect(t) {
128
- 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";
129
- }
130
- disconnect() {
131
- 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";
132
- }
133
- dispose() {
134
- this.disconnect();
135
- }
136
- /**
137
- * Get the current vertical rotation, in radians.
138
- *
139
- * @return {number} The current vertical rotation, in radians.
140
- */
141
- getPolarAngle() {
142
- return this._spherical.phi;
143
- }
144
- /**
145
- * Get the current horizontal rotation, in radians.
146
- *
147
- * @return {number} The current horizontal rotation, in radians.
148
- */
149
- getAzimuthalAngle() {
150
- return this._spherical.theta;
151
- }
152
- /**
153
- * Returns the distance from the camera to the target.
154
- *
155
- * @return {number} The distance from the camera to the target.
156
- */
157
- getDistance() {
158
- return this.object.position.distanceTo(this.target);
159
- }
160
- /**
161
- * Adds key event listeners to the given DOM element.
162
- * `window` is a recommended argument for using this method.
163
- *
164
- * @param {HTMLDOMElement} domElement - The DOM element
165
- */
166
- listenToKeyEvents(t) {
167
- t.addEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = t;
168
- }
169
- /**
170
- * Removes the key event listener previously defined with `listenToKeyEvents()`.
171
- */
172
- stopListenToKeyEvents() {
173
- this._domElementKeyEvents !== null && (this._domElementKeyEvents.removeEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = null);
174
- }
175
- /**
176
- * Save the current state of the controls. This can later be recovered with `reset()`.
177
- */
178
- saveState() {
179
- this.target0.copy(this.target), this.position0.copy(this.object.position), this.zoom0 = this.object.zoom;
180
- }
181
- /**
182
- * Reset the controls to their state from either the last time the `saveState()`
183
- * was called, or the initial state.
184
- */
185
- reset() {
186
- this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(U), this.update(), this.state = r.NONE;
187
- }
188
- update(t = null) {
189
- const i = this.object.position;
190
- c.copy(i).sub(this.target), c.applyQuaternion(this._quat), this._spherical.setFromVector3(c), this.autoRotate && this.state === r.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);
191
- let o = this.minAzimuthAngle, h = this.maxAzimuthAngle;
192
- isFinite(o) && isFinite(h) && (o < -Math.PI ? o += u : o > Math.PI && (o -= u), h < -Math.PI ? h += u : h > Math.PI && (h -= u), o <= h ? this._spherical.theta = Math.max(o, Math.min(h, this._spherical.theta)) : this._spherical.theta = this._spherical.theta > (o + h) / 2 ? Math.max(o, this._spherical.theta) : Math.min(h, 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);
193
- let l = !1;
194
- if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera)
195
- this._spherical.radius = this._clampDistance(this._spherical.radius);
196
- else {
197
- const p = this._spherical.radius;
198
- this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale), l = p != this._spherical.radius;
199
- }
200
- if (c.setFromSpherical(this._spherical), c.applyQuaternion(this._quatInverse), i.copy(this.target).add(c), 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) {
201
- let p = null;
202
- if (this.object.isPerspectiveCamera) {
203
- const d = c.length();
204
- p = this._clampDistance(d * this._scale);
205
- const b = d - p;
206
- this.object.position.addScaledVector(this._dollyDirection, b), this.object.updateMatrixWorld(), l = !!b;
207
- } else if (this.object.isOrthographicCamera) {
208
- const d = new _(this._mouse.x, this._mouse.y, 0);
209
- d.unproject(this.object);
210
- const b = this.object.zoom;
211
- this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(), l = b !== this.object.zoom;
212
- const m = new _(this._mouse.x, this._mouse.y, 0);
213
- m.unproject(this.object), this.object.position.sub(m).add(d), this.object.updateMatrixWorld(), p = c.length();
214
- } else
215
- console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), this.zoomToCursor = !1;
216
- p !== null && (this.screenSpacePanning ? this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(p).add(this.object.position) : (x.origin.copy(this.object.position), x.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot(x.direction)) < at ? this.object.lookAt(this.target) : (Z.setFromNormalAndCoplanarPoint(this.object.up, this.target), x.intersectPlane(Z, this.target))));
217
- } else if (this.object.isOrthographicCamera) {
218
- const p = this.object.zoom;
219
- this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), p !== this.object.zoom && (this.object.updateProjectionMatrix(), l = !0);
220
- }
221
- return this._scale = 1, this._performCursorZoom = !1, l || this._lastPosition.distanceToSquared(this.object.position) > C || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > C || this._lastTargetPosition.distanceToSquared(this.target) > C ? (this.dispatchEvent(U), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1;
222
- }
223
- _getAutoRotationAngle(t) {
224
- return t !== null ? u / 60 * this.autoRotateSpeed * t : u / 60 / 60 * this.autoRotateSpeed;
225
- }
226
- _getZoomScale(t) {
227
- const i = Math.abs(t * 0.01);
228
- return Math.pow(0.95, this.zoomSpeed * i);
229
- }
230
- _rotateLeft(t) {
231
- this._sphericalDelta.theta -= t;
232
- }
233
- _rotateUp(t) {
234
- this._sphericalDelta.phi -= t;
235
- }
236
- _panLeft(t, i) {
237
- c.setFromMatrixColumn(i, 0), c.multiplyScalar(-t), this._panOffset.add(c);
238
- }
239
- _panUp(t, i) {
240
- this.screenSpacePanning === !0 ? c.setFromMatrixColumn(i, 1) : (c.setFromMatrixColumn(i, 0), c.crossVectors(this.object.up, c)), c.multiplyScalar(t), this._panOffset.add(c);
241
- }
242
- // deltaX and deltaY are in pixels; right and down are positive
243
- _pan(t, i) {
244
- const o = this.domElement;
245
- if (this.object.isPerspectiveCamera) {
246
- const h = this.object.position;
247
- c.copy(h).sub(this.target);
248
- let l = c.length();
249
- l *= Math.tan(this.object.fov / 2 * Math.PI / 180), this._panLeft(2 * t * l / o.clientHeight, this.object.matrix), this._panUp(2 * i * l / o.clientHeight, this.object.matrix);
250
- } 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);
251
- }
252
- _dollyOut(t) {
253
- 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);
254
- }
255
- _dollyIn(t) {
256
- 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);
257
- }
258
- _updateZoomParameters(t, i) {
259
- if (!this.zoomToCursor)
260
- return;
261
- this._performCursorZoom = !0;
262
- const o = this.domElement.getBoundingClientRect(), h = t - o.left, l = i - o.top, p = o.width, d = o.height;
263
- this._mouse.x = h / p * 2 - 1, this._mouse.y = -(l / d) * 2 + 1, this._dollyDirection.set(this._mouse.x, this._mouse.y, 1).unproject(this.object).sub(this.object.position).normalize();
264
- }
265
- _clampDistance(t) {
266
- return Math.max(this.minDistance, Math.min(this.maxDistance, t));
267
- }
268
- //
269
- // event callbacks - update the object state
270
- //
271
- _handleMouseDownRotate(t) {
272
- this._rotateStart.set(t.clientX, t.clientY);
273
- }
274
- _handleMouseDownDolly(t) {
275
- this._updateZoomParameters(t.clientX, t.clientX), this._dollyStart.set(t.clientX, t.clientY);
276
- }
277
- _handleMouseDownPan(t) {
278
- this._panStart.set(t.clientX, t.clientY);
279
- }
280
- _handleMouseMoveRotate(t) {
281
- this._rotateEnd.set(t.clientX, t.clientY), this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
282
- const i = this.domElement;
283
- this._rotateLeft(u * this._rotateDelta.x / i.clientHeight), this._rotateUp(u * this._rotateDelta.y / i.clientHeight), this._rotateStart.copy(this._rotateEnd), this.update();
284
- }
285
- _handleMouseMoveDolly(t) {
286
- 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();
287
- }
288
- _handleMouseMovePan(t) {
289
- 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();
290
- }
291
- _handleMouseWheel(t) {
292
- 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();
293
- }
294
- _handleKeyDown(t) {
295
- let i = !1;
296
- switch (t.code) {
297
- case this.keys.UP:
298
- t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateUp(u * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, this.keyPanSpeed), i = !0;
299
- break;
300
- case this.keys.BOTTOM:
301
- t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateUp(-u * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, -this.keyPanSpeed), i = !0;
302
- break;
303
- case this.keys.LEFT:
304
- t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateLeft(u * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(this.keyPanSpeed, 0), i = !0;
305
- break;
306
- case this.keys.RIGHT:
307
- t.ctrlKey || t.metaKey || t.shiftKey ? this.enableRotate && this._rotateLeft(-u * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(-this.keyPanSpeed, 0), i = !0;
308
- break;
309
- }
310
- i && (t.preventDefault(), this.update());
311
- }
312
- _handleTouchStartRotate(t) {
313
- if (this._pointers.length === 1)
314
- this._rotateStart.set(t.pageX, t.pageY);
315
- else {
316
- const i = this._getSecondPointerPosition(t), o = 0.5 * (t.pageX + i.x), h = 0.5 * (t.pageY + i.y);
317
- this._rotateStart.set(o, h);
318
- }
319
- }
320
- _handleTouchStartPan(t) {
321
- if (this._pointers.length === 1)
322
- this._panStart.set(t.pageX, t.pageY);
323
- else {
324
- const i = this._getSecondPointerPosition(t), o = 0.5 * (t.pageX + i.x), h = 0.5 * (t.pageY + i.y);
325
- this._panStart.set(o, h);
326
- }
327
- }
328
- _handleTouchStartDolly(t) {
329
- const i = this._getSecondPointerPosition(t), o = t.pageX - i.x, h = t.pageY - i.y, l = Math.sqrt(o * o + h * h);
330
- this._dollyStart.set(0, l);
331
- }
332
- _handleTouchStartDollyPan(t) {
333
- this.enableZoom && this._handleTouchStartDolly(t), this.enablePan && this._handleTouchStartPan(t);
334
- }
335
- _handleTouchStartDollyRotate(t) {
336
- this.enableZoom && this._handleTouchStartDolly(t), this.enableRotate && this._handleTouchStartRotate(t);
337
- }
338
- _handleTouchMoveRotate(t) {
339
- if (this._pointers.length == 1)
340
- this._rotateEnd.set(t.pageX, t.pageY);
341
- else {
342
- const o = this._getSecondPointerPosition(t), h = 0.5 * (t.pageX + o.x), l = 0.5 * (t.pageY + o.y);
343
- this._rotateEnd.set(h, l);
344
- }
345
- this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed);
346
- const i = this.domElement;
347
- this._rotateLeft(u * this._rotateDelta.x / i.clientHeight), this._rotateUp(u * this._rotateDelta.y / i.clientHeight), this._rotateStart.copy(this._rotateEnd);
348
- }
349
- _handleTouchMovePan(t) {
350
- if (this._pointers.length === 1)
351
- this._panEnd.set(t.pageX, t.pageY);
352
- else {
353
- const i = this._getSecondPointerPosition(t), o = 0.5 * (t.pageX + i.x), h = 0.5 * (t.pageY + i.y);
354
- this._panEnd.set(o, h);
355
- }
356
- this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd);
357
- }
358
- _handleTouchMoveDolly(t) {
359
- const i = this._getSecondPointerPosition(t), o = t.pageX - i.x, h = t.pageY - i.y, l = Math.sqrt(o * o + h * h);
360
- this._dollyEnd.set(0, l), this._dollyDelta.set(0, Math.pow(this._dollyEnd.y / this._dollyStart.y, this.zoomSpeed)), this._dollyOut(this._dollyDelta.y), this._dollyStart.copy(this._dollyEnd);
361
- const p = (t.pageX + i.x) * 0.5, d = (t.pageY + i.y) * 0.5;
362
- this._updateZoomParameters(p, d);
363
- }
364
- _handleTouchMoveDollyPan(t) {
365
- this.enableZoom && this._handleTouchMoveDolly(t), this.enablePan && this._handleTouchMovePan(t);
366
- }
367
- _handleTouchMoveDollyRotate(t) {
368
- this.enableZoom && this._handleTouchMoveDolly(t), this.enableRotate && this._handleTouchMoveRotate(t);
369
- }
370
- // pointers
371
- _addPointer(t) {
372
- this._pointers.push(t.pointerId);
373
- }
374
- _removePointer(t) {
375
- delete this._pointerPositions[t.pointerId];
376
- for (let i = 0; i < this._pointers.length; i++)
377
- if (this._pointers[i] == t.pointerId) {
378
- this._pointers.splice(i, 1);
379
- return;
380
- }
381
- }
382
- _isTrackingPointer(t) {
383
- for (let i = 0; i < this._pointers.length; i++)
384
- if (this._pointers[i] == t.pointerId) return !0;
385
- return !1;
386
- }
387
- _trackPointer(t) {
388
- let i = this._pointerPositions[t.pointerId];
389
- i === void 0 && (i = new y(), this._pointerPositions[t.pointerId] = i), i.set(t.pageX, t.pageY);
390
- }
391
- _getSecondPointerPosition(t) {
392
- const i = t.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0];
393
- return this._pointerPositions[i];
394
- }
395
- //
396
- _customWheelEvent(t) {
397
- const i = t.deltaMode, o = {
398
- clientX: t.clientX,
399
- clientY: t.clientY,
400
- deltaY: t.deltaY
401
- };
402
- switch (i) {
403
- case 1:
404
- o.deltaY *= 16;
405
- break;
406
- case 2:
407
- o.deltaY *= 100;
408
- break;
409
- }
410
- return t.ctrlKey && !this._controlActive && (o.deltaY *= 10), o;
411
- }
412
- }
413
- function ht(e) {
414
- 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)));
415
- }
416
- function rt(e) {
417
- this.enabled !== !1 && (e.pointerType === "touch" ? this._onTouchMove(e) : this._onMouseMove(e));
418
- }
419
- function lt(e) {
420
- switch (this._removePointer(e), this._pointers.length) {
421
- case 0:
422
- this.domElement.releasePointerCapture(e.pointerId), this.domElement.removeEventListener("pointermove", this._onPointerMove), this.domElement.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(W), this.state = r.NONE;
423
- break;
424
- case 1:
425
- const t = this._pointers[0], i = this._pointerPositions[t];
426
- this._onTouchStart({ pointerId: t, pageX: i.x, pageY: i.y });
427
- break;
428
- }
429
- }
430
- function ct(e) {
431
- let t;
432
- switch (e.button) {
433
- case 0:
434
- t = this.mouseButtons.LEFT;
435
- break;
436
- case 1:
437
- t = this.mouseButtons.MIDDLE;
438
- break;
439
- case 2:
440
- t = this.mouseButtons.RIGHT;
441
- break;
442
- default:
443
- t = -1;
444
- }
445
- switch (t) {
446
- case D.DOLLY:
447
- if (this.enableZoom === !1) return;
448
- this._handleMouseDownDolly(e), this.state = r.DOLLY;
449
- break;
450
- case D.ROTATE:
451
- if (e.ctrlKey || e.metaKey || e.shiftKey) {
452
- if (this.enablePan === !1) return;
453
- this._handleMouseDownPan(e), this.state = r.PAN;
454
- } else {
455
- if (this.enableRotate === !1) return;
456
- this._handleMouseDownRotate(e), this.state = r.ROTATE;
457
- }
458
- break;
459
- case D.PAN:
460
- if (e.ctrlKey || e.metaKey || e.shiftKey) {
461
- if (this.enableRotate === !1) return;
462
- this._handleMouseDownRotate(e), this.state = r.ROTATE;
463
- } else {
464
- if (this.enablePan === !1) return;
465
- this._handleMouseDownPan(e), this.state = r.PAN;
466
- }
467
- break;
468
- default:
469
- this.state = r.NONE;
470
- }
471
- this.state !== r.NONE && this.dispatchEvent(L);
472
- }
473
- function pt(e) {
474
- switch (this.state) {
475
- case r.ROTATE:
476
- if (this.enableRotate === !1) return;
477
- this._handleMouseMoveRotate(e);
478
- break;
479
- case r.DOLLY:
480
- if (this.enableZoom === !1) return;
481
- this._handleMouseMoveDolly(e);
482
- break;
483
- case r.PAN:
484
- if (this.enablePan === !1) return;
485
- this._handleMouseMovePan(e);
486
- break;
487
- }
488
- }
489
- function dt(e) {
490
- this.enabled === !1 || this.enableZoom === !1 || this.state !== r.NONE || (e.preventDefault(), this.dispatchEvent(L), this._handleMouseWheel(this._customWheelEvent(e)), this.dispatchEvent(W));
491
- }
492
- function ut(e) {
493
- this.enabled !== !1 && this._handleKeyDown(e);
494
- }
495
- function _t(e) {
496
- switch (this._trackPointer(e), this._pointers.length) {
497
- case 1:
498
- switch (this.touches.ONE) {
499
- case w.ROTATE:
500
- if (this.enableRotate === !1) return;
501
- this._handleTouchStartRotate(e), this.state = r.TOUCH_ROTATE;
502
- break;
503
- case w.PAN:
504
- if (this.enablePan === !1) return;
505
- this._handleTouchStartPan(e), this.state = r.TOUCH_PAN;
506
- break;
507
- default:
508
- this.state = r.NONE;
509
- }
510
- break;
511
- case 2:
512
- switch (this.touches.TWO) {
513
- case w.DOLLY_PAN:
514
- if (this.enableZoom === !1 && this.enablePan === !1) return;
515
- this._handleTouchStartDollyPan(e), this.state = r.TOUCH_DOLLY_PAN;
516
- break;
517
- case w.DOLLY_ROTATE:
518
- if (this.enableZoom === !1 && this.enableRotate === !1) return;
519
- this._handleTouchStartDollyRotate(e), this.state = r.TOUCH_DOLLY_ROTATE;
520
- break;
521
- default:
522
- this.state = r.NONE;
523
- }
524
- break;
525
- default:
526
- this.state = r.NONE;
527
- }
528
- this.state !== r.NONE && this.dispatchEvent(L);
529
- }
530
- function mt(e) {
531
- switch (this._trackPointer(e), this.state) {
532
- case r.TOUCH_ROTATE:
533
- if (this.enableRotate === !1) return;
534
- this._handleTouchMoveRotate(e), this.update();
535
- break;
536
- case r.TOUCH_PAN:
537
- if (this.enablePan === !1) return;
538
- this._handleTouchMovePan(e), this.update();
539
- break;
540
- case r.TOUCH_DOLLY_PAN:
541
- if (this.enableZoom === !1 && this.enablePan === !1) return;
542
- this._handleTouchMoveDollyPan(e), this.update();
543
- break;
544
- case r.TOUCH_DOLLY_ROTATE:
545
- if (this.enableZoom === !1 && this.enableRotate === !1) return;
546
- this._handleTouchMoveDollyRotate(e), this.update();
547
- break;
548
- default:
549
- this.state = r.NONE;
550
- }
551
- }
552
- function ft(e) {
553
- this.enabled !== !1 && e.preventDefault();
554
- }
555
- function yt(e) {
556
- e.key === "Control" && (this._controlActive = !0, this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
557
- }
558
- function bt(e) {
559
- e.key === "Control" && (this._controlActive = !1, this.domElement.getRootNode().removeEventListener("keyup", this._interceptControlUp, { passive: !0, capture: !0 }));
560
- }
561
- class gt extends X {
562
- constructor(t, i) {
563
- super(t, i), this.screenSpacePanning = !1, this.mouseButtons = { LEFT: D.PAN, MIDDLE: D.DOLLY, RIGHT: D.ROTATE }, this.touches = { ONE: w.PAN, TWO: w.DOLLY_ROTATE };
564
- }
565
- }
566
- function St(e) {
567
- return new Q(e);
568
- }
569
- function Tt(e = 150, ...t) {
570
- return new $(e, e / 10, ...t);
571
- }
572
- function Mt(e) {
573
- return new J(e, 16776960);
574
- }
575
- function xt(e, t) {
576
- return new X(e, t);
577
- }
578
- function Ot(e, t) {
579
- return new gt(e, t);
580
- }
581
- function Rt() {
582
- const e = new tt(), t = new y(0, 0);
583
- return {
584
- raycaster: e,
585
- pointer: t
586
- };
587
- }
588
- function Ct(e = 10) {
589
- return new et(e);
590
- }
591
- function At(e = new _(1, 1, 1), t = new _(10, 10, 10), i = 5, o = 16776960) {
592
- return e.normalize(), new it(e, t, i, o);
593
- }
594
- const Et = (e) => {
595
- e.geometry && e.geometry.dispose(), e.material && (Array.isArray(e.material) ? e.material.forEach((t) => {
596
- z(t);
597
- }) : z(e.material)), e.children && e.children.forEach((t) => Et(t));
598
- };
599
- function z(e) {
600
- for (const t in e)
601
- e[t] && e[t].isTexture && e[t].dispose();
602
- e.dispose();
603
- }
604
- export {
605
- Dt as C,
606
- Tt as a,
607
- Mt as b,
608
- St as c,
609
- xt as d,
610
- Ot as e,
611
- Rt as f,
612
- Ct as g,
613
- At as h,
614
- Et as i,
615
- wt as j
616
- };