@roomle/web-sdk 5.1.0-alpha.2 → 5.1.0-alpha.3

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 (112) hide show
  1. package/lib/{BufferGeometry-Cd2ewNVQ.mjs → BufferGeometry-Bl5whHAB.mjs} +1 -1
  2. package/lib/{BufferGeometry-Cd2ewNVQ.mjs.map → BufferGeometry-Bl5whHAB.mjs.map} +1 -1
  3. package/lib/ConfiguratorKernel.js +2 -2
  4. package/lib/ConfiguratorKernel.wasm +0 -0
  5. package/lib/{GLTFExporter-n80QLoDf.mjs → GLTFExporter-yQ7mMauu.mjs} +1 -1
  6. package/lib/{GLTFExporter-n80QLoDf.mjs.map → GLTFExporter-yQ7mMauu.mjs.map} +1 -1
  7. package/lib/{GaussianBlurNode-Cwy3kx8H.mjs → GaussianBlurNode-DNBEf5-n.mjs} +14 -14
  8. package/lib/{GaussianBlurNode-Cwy3kx8H.mjs.map → GaussianBlurNode-DNBEf5-n.mjs.map} +1 -1
  9. package/lib/{PointLightHelper-DlPLsDNy.mjs → PointLightHelper-CuPSBuDU.mjs} +2 -2
  10. package/lib/{PointLightHelper-DlPLsDNy.mjs.map → PointLightHelper-CuPSBuDU.mjs.map} +1 -1
  11. package/lib/RoomleCore.wasm +0 -0
  12. package/lib/RoomleToolsCore.wasm +0 -0
  13. package/lib/{SpotLightHelper-YWHbVXAF.mjs → SpotLightHelper-m-Rh8vGU.mjs} +2 -2
  14. package/lib/{SpotLightHelper-YWHbVXAF.mjs.map → SpotLightHelper-m-Rh8vGU.mjs.map} +1 -1
  15. package/lib/{USDZExporter-Bm-c5e_n.mjs → USDZExporter-MdkuT226.mjs} +1 -1
  16. package/lib/{USDZExporter-Bm-c5e_n.mjs.map → USDZExporter-MdkuT226.mjs.map} +1 -1
  17. package/lib/{api-B5wIZIHt.mjs → api-KWh-ESd5.mjs} +2 -2
  18. package/lib/{api-B5wIZIHt.mjs.map → api-KWh-ESd5.mjs.map} +1 -1
  19. package/lib/{asset-loader.worker-CE4O0JU-.mjs → asset-loader.worker-CzI1oyTY.mjs} +1 -1
  20. package/lib/asset-loader.worker-CzI1oyTY.mjs.map +1 -0
  21. package/lib/{banana-for-scale-D0bw51dn.mjs → banana-for-scale-DpKXNBt_.mjs} +2 -2
  22. package/lib/{banana-for-scale-D0bw51dn.mjs.map → banana-for-scale-DpKXNBt_.mjs.map} +1 -1
  23. package/lib/{budgeteer.sw-yR2xApHT.mjs → budgeteer.sw-D80jTmYa.mjs} +1 -1
  24. package/lib/budgeteer.sw-D80jTmYa.mjs.map +1 -0
  25. package/lib/{component-dimensioning-VIUcXV7r.mjs → component-dimensioning-luQ3LgrU.mjs} +4 -4
  26. package/lib/{component-dimensioning-VIUcXV7r.mjs.map → component-dimensioning-luQ3LgrU.mjs.map} +1 -1
  27. package/lib/{component-raycast-helper-CEAdBcdx.mjs → component-raycast-helper-hj6sm7jw.mjs} +3 -3
  28. package/lib/{component-raycast-helper-CEAdBcdx.mjs.map → component-raycast-helper-hj6sm7jw.mjs.map} +1 -1
  29. package/lib/{configurator-CxlLvBCx.mjs → configurator-CQ7KsW0O.mjs} +4 -4
  30. package/lib/{configurator-CxlLvBCx.mjs.map → configurator-CQ7KsW0O.mjs.map} +1 -1
  31. package/lib/configurator-ymHt9qjg.mjs +2 -0
  32. package/lib/{continuous-drawing-helper-Dr1r-5N2.mjs → continuous-drawing-helper-DqHIR_qF.mjs} +1 -1
  33. package/lib/{continuous-drawing-helper-Dr1r-5N2.mjs.map → continuous-drawing-helper-DqHIR_qF.mjs.map} +1 -1
  34. package/lib/{dimensioning-helper-ChQDwSjn.mjs → dimensioning-helper-CGPjS2hW.mjs} +2 -2
  35. package/lib/{dimensioning-helper-ChQDwSjn.mjs.map → dimensioning-helper-CGPjS2hW.mjs.map} +1 -1
  36. package/lib/dimensioning-helper-VndKlIXS.mjs +2 -0
  37. package/lib/{glb-viewer-27e6wfY4.mjs → glb-viewer-BWMMzvuG.mjs} +4 -4
  38. package/lib/{glb-viewer-27e6wfY4.mjs.map → glb-viewer-BWMMzvuG.mjs.map} +1 -1
  39. package/lib/glb-viewer-D5QHd6Da.mjs +2 -0
  40. package/lib/{highlight-coordinator-C05kDjj5.mjs → highlight-coordinator-DYjBxYpy.mjs} +2 -2
  41. package/lib/{highlight-coordinator-C05kDjj5.mjs.map → highlight-coordinator-DYjBxYpy.mjs.map} +1 -1
  42. package/lib/{homag-intelligence-BRQ1WoQo.mjs → homag-intelligence-lbse0Y0v.mjs} +3 -3
  43. package/lib/{homag-intelligence-BRQ1WoQo.mjs.map → homag-intelligence-lbse0Y0v.mjs.map} +1 -1
  44. package/lib/hosek-wilkie-sky-iMar2iw-.mjs +3755 -0
  45. package/lib/hosek-wilkie-sky-iMar2iw-.mjs.map +1 -0
  46. package/lib/{imos-ix-poc-export-helper-DhxAAMc9.mjs → imos-ix-poc-export-helper-CyGqK7nu.mjs} +1 -1
  47. package/lib/{imos-ix-poc-export-helper-DhxAAMc9.mjs.map → imos-ix-poc-export-helper-CyGqK7nu.mjs.map} +1 -1
  48. package/lib/{layer-DaGoZ5YI.mjs → layer-DRMDGxT7.mjs} +2 -2
  49. package/lib/layer-DRMDGxT7.mjs.map +1 -0
  50. package/lib/{material-viewer-Byi5t7-x.mjs → material-viewer-BKTxh5Ui.mjs} +4 -4
  51. package/lib/{material-viewer-Byi5t7-x.mjs.map → material-viewer-BKTxh5Ui.mjs.map} +1 -1
  52. package/lib/{packages-3jOdcfbr.mjs → packages-B4K6xrdJ.mjs} +5 -5
  53. package/lib/{packages-3jOdcfbr.mjs.map → packages-B4K6xrdJ.mjs.map} +1 -1
  54. package/lib/planner-BM825oIz.mjs +2 -0
  55. package/lib/{planner-BeINcWRR.mjs → planner-HMMHSMAp.mjs} +3 -3
  56. package/lib/{planner-BeINcWRR.mjs.map → planner-HMMHSMAp.mjs.map} +1 -1
  57. package/lib/{plugin-system-DR5maiUo.mjs → plugin-system-CRaC04G5.mjs} +2 -2
  58. package/lib/{plugin-system-DR5maiUo.mjs.map → plugin-system-CRaC04G5.mjs.map} +1 -1
  59. package/lib/roomle-headless.d.ts +162 -4
  60. package/lib/roomle-headless.js +11 -11
  61. package/lib/roomle-renderer-Ato6RMrd.mjs.map +1 -1
  62. package/lib/{roomle-sdk-CsSQAqQG.mjs → roomle-sdk-5aB4wxLW.mjs} +3045 -2876
  63. package/lib/roomle-sdk-5aB4wxLW.mjs.map +1 -0
  64. package/lib/roomle-sdk.d.ts +162 -4
  65. package/lib/roomle-sdk.js +8 -8
  66. package/lib/{roomle-webgpu-renderer-BBE14A8V.mjs → roomle-webgpu-renderer-BfZKcXSz.mjs} +349 -344
  67. package/lib/{roomle-webgpu-renderer-BBE14A8V.mjs.map → roomle-webgpu-renderer-BfZKcXSz.mjs.map} +1 -1
  68. package/lib/{scene-renderer-B8SBMSQ7.mjs → scene-renderer-DXvavD4L.mjs} +3 -3
  69. package/lib/{scene-renderer-B8SBMSQ7.mjs.map → scene-renderer-DXvavD4L.mjs.map} +1 -1
  70. package/lib/{script-loader-Dx3gOiB3.mjs → script-loader-axxcKvph.mjs} +2 -2
  71. package/lib/{script-loader-Dx3gOiB3.mjs.map → script-loader-axxcKvph.mjs.map} +1 -1
  72. package/lib/src-Bbq3Hqzn.mjs +2 -0
  73. package/lib/src-HhklrVDg.mjs +1950 -0
  74. package/lib/src-HhklrVDg.mjs.map +1 -0
  75. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/package.json +1 -1
  76. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/configuratorCoreInterface.d.ts +16 -0
  77. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/configuratorCoreInterface.js +5 -1
  78. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/configuratorCoreInterface.js.map +1 -1
  79. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/plannerCoreInterface.d.ts +2 -8
  80. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/plannerCoreInterface.js +1 -5
  81. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/src/embind/plannerCoreInterface.js.map +1 -1
  82. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/ConfiguratorKernel.js +2 -2
  83. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/ConfiguratorKernel.wasm +0 -0
  84. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleCore.wasm +0 -0
  85. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleToolsCore.wasm +0 -0
  86. package/lib/{stats-helper-W654V5ay.mjs → stats-helper-BSmoG68E.mjs} +2 -2
  87. package/lib/{stats-helper-W654V5ay.mjs.map → stats-helper-BSmoG68E.mjs.map} +1 -1
  88. package/lib/three.tsl-BTc4fg8T.mjs +2 -0
  89. package/lib/{three.tsl-B7hcNZE8.mjs → three.tsl-Cf0-sCqB.mjs} +70 -66
  90. package/lib/{three.tsl-B7hcNZE8.mjs.map → three.tsl-Cf0-sCqB.mjs.map} +1 -1
  91. package/lib/{threejs-utils-WK7Uu2TS.mjs → threejs-utils-CLdyrCet.mjs} +14 -14
  92. package/lib/threejs-utils-CLdyrCet.mjs.map +1 -0
  93. package/lib/{tools-core-CWrR_N9g.mjs → tools-core-DusxT3AY.mjs} +3 -3
  94. package/lib/{tools-core-CWrR_N9g.mjs.map → tools-core-DusxT3AY.mjs.map} +1 -1
  95. package/lib/webgpu-BHAP6BLI.mjs +3140 -0
  96. package/lib/webgpu-BHAP6BLI.mjs.map +1 -0
  97. package/lib/workers-B_wmKVL0.mjs +6 -0
  98. package/lib/{workers-B-AqdQMe.mjs.map → workers-B_wmKVL0.mjs.map} +1 -1
  99. package/package.json +2 -2
  100. package/lib/asset-loader.worker-CE4O0JU-.mjs.map +0 -1
  101. package/lib/budgeteer.sw-yR2xApHT.mjs.map +0 -1
  102. package/lib/configurator-h8QoUnMz.mjs +0 -2
  103. package/lib/dimensioning-helper-BEGkpZFA.mjs +0 -2
  104. package/lib/glb-viewer-Dc2Tl8Ef.mjs +0 -2
  105. package/lib/layer-DaGoZ5YI.mjs.map +0 -1
  106. package/lib/planner-Ler1UMAp.mjs +0 -2
  107. package/lib/roomle-sdk-CsSQAqQG.mjs.map +0 -1
  108. package/lib/three.tsl-BBUCm-uB.mjs +0 -2
  109. package/lib/threejs-utils-WK7Uu2TS.mjs.map +0 -1
  110. package/lib/webgpu-DSecxaB8.mjs +0 -5084
  111. package/lib/webgpu-DSecxaB8.mjs.map +0 -1
  112. package/lib/workers-B-AqdQMe.mjs +0 -6
@@ -0,0 +1,1950 @@
1
+ import { Bt as e, Ci as t, Er as n, Qr as r, Si as i, cn as a, f as o, h as s, kn as c, m as l, sn as u, ui as d } from "./three.core-0KaTx8dm.mjs";
2
+ var f = 1.25, p = 65535;
3
+ p << 16;
4
+ var m = 2 ** -24, h = Symbol("SKIP_GENERATION"), g = {
5
+ strategy: 0,
6
+ maxDepth: 40,
7
+ targetLeafSize: 10,
8
+ useSharedArrayBuffer: !1,
9
+ setBoundingBox: !0,
10
+ onProgress: null,
11
+ indirect: !1,
12
+ verbose: !0,
13
+ range: null,
14
+ [h]: !1
15
+ };
16
+ //#endregion
17
+ //#region ../../node_modules/three-mesh-bvh/src/utils/ArrayBoxUtilities.js
18
+ function _(e, t, n) {
19
+ return n.min.x = t[e], n.min.y = t[e + 1], n.min.z = t[e + 2], n.max.x = t[e + 3], n.max.y = t[e + 4], n.max.z = t[e + 5], n;
20
+ }
21
+ function v(e) {
22
+ let t = -1, n = -Infinity;
23
+ for (let r = 0; r < 3; r++) {
24
+ let i = e[r + 3] - e[r];
25
+ i > n && (n = i, t = r);
26
+ }
27
+ return t;
28
+ }
29
+ function y(e, t) {
30
+ t.set(e);
31
+ }
32
+ function b(e, t, n) {
33
+ let r, i;
34
+ for (let a = 0; a < 3; a++) {
35
+ let o = a + 3;
36
+ r = e[a], i = t[a], n[a] = r < i ? r : i, r = e[o], i = t[o], n[o] = r > i ? r : i;
37
+ }
38
+ }
39
+ function x(e, t, n) {
40
+ for (let r = 0; r < 3; r++) {
41
+ let i = t[e + 2 * r], a = t[e + 2 * r + 1], o = i - a, s = i + a;
42
+ o < n[r] && (n[r] = o), s > n[r + 3] && (n[r + 3] = s);
43
+ }
44
+ }
45
+ function S(e) {
46
+ let t = e[3] - e[0], n = e[4] - e[1], r = e[5] - e[2];
47
+ return 2 * (t * n + n * r + r * t);
48
+ }
49
+ //#endregion
50
+ //#region ../../node_modules/three-mesh-bvh/src/core/utils/nodeBufferUtils.js
51
+ function C(e, t) {
52
+ return t[e + 15] === p;
53
+ }
54
+ function w(e, t) {
55
+ return t[e + 6];
56
+ }
57
+ function T(e, t) {
58
+ return t[e + 14];
59
+ }
60
+ function E(e) {
61
+ return e + 8;
62
+ }
63
+ function D(e, t) {
64
+ return e + t[e + 6] * 8;
65
+ }
66
+ function O(e, t) {
67
+ return t[e + 7];
68
+ }
69
+ function k(e) {
70
+ return e;
71
+ }
72
+ //#endregion
73
+ //#region ../../node_modules/three-mesh-bvh/src/core/build/computeBoundsUtils.js
74
+ function A(e, t, n, r, i) {
75
+ let a = Infinity, o = Infinity, s = Infinity, c = -Infinity, l = -Infinity, u = -Infinity, d = Infinity, f = Infinity, p = Infinity, m = -Infinity, h = -Infinity, g = -Infinity, _ = e.offset || 0;
76
+ for (let r = (t - _) * 6, i = (t + n - _) * 6; r < i; r += 6) {
77
+ let t = e[r + 0], n = e[r + 1], i = t - n, _ = t + n;
78
+ i < a && (a = i), _ > c && (c = _), t < d && (d = t), t > m && (m = t);
79
+ let v = e[r + 2], y = e[r + 3], b = v - y, x = v + y;
80
+ b < o && (o = b), x > l && (l = x), v < f && (f = v), v > h && (h = v);
81
+ let S = e[r + 4], C = e[r + 5], w = S - C, T = S + C;
82
+ w < s && (s = w), T > u && (u = T), S < p && (p = S), S > g && (g = S);
83
+ }
84
+ r[0] = a, r[1] = o, r[2] = s, r[3] = c, r[4] = l, r[5] = u, i[0] = d, i[1] = f, i[2] = p, i[3] = m, i[4] = h, i[5] = g;
85
+ }
86
+ //#endregion
87
+ //#region ../../node_modules/three-mesh-bvh/src/core/build/splitUtils.js
88
+ var j = 32, ee = (e, t) => e.candidate - t.candidate, M = /* @__PURE__ */ Array(j).fill().map(() => ({
89
+ count: 0,
90
+ bounds: new Float32Array(6),
91
+ rightCacheBounds: new Float32Array(6),
92
+ leftCacheBounds: new Float32Array(6),
93
+ candidate: 0
94
+ })), te = /* @__PURE__ */ new Float32Array(6);
95
+ function ne(e, t, n, r, i, a) {
96
+ let o = -1, s = 0;
97
+ if (a === 0) o = v(t), o !== -1 && (s = (t[o] + t[o + 3]) / 2);
98
+ else if (a === 1) o = v(e), o !== -1 && (s = re(n, r, i, o));
99
+ else if (a === 2) {
100
+ let a = S(e), c = f * i, l = n.offset || 0, u = (r - l) * 6, d = (r + i - l) * 6;
101
+ for (let e = 0; e < 3; e++) {
102
+ let r = t[e], l = (t[e + 3] - r) / j;
103
+ if (i < j / 4) {
104
+ let t = [...M];
105
+ t.length = i;
106
+ let r = 0;
107
+ for (let i = u; i < d; i += 6, r++) {
108
+ let a = t[r];
109
+ a.candidate = n[i + 2 * e], a.count = 0;
110
+ let { bounds: o, leftCacheBounds: s, rightCacheBounds: c } = a;
111
+ for (let e = 0; e < 3; e++) c[e] = Infinity, c[e + 3] = -Infinity, s[e] = Infinity, s[e + 3] = -Infinity, o[e] = Infinity, o[e + 3] = -Infinity;
112
+ x(i, n, o);
113
+ }
114
+ t.sort(ee);
115
+ let l = i;
116
+ for (let e = 0; e < l; e++) {
117
+ let n = t[e];
118
+ for (; e + 1 < l && t[e + 1].candidate === n.candidate;) t.splice(e + 1, 1), l--;
119
+ }
120
+ for (let r = u; r < d; r += 6) {
121
+ let i = n[r + 2 * e];
122
+ for (let e = 0; e < l; e++) {
123
+ let a = t[e];
124
+ i >= a.candidate ? x(r, n, a.rightCacheBounds) : (x(r, n, a.leftCacheBounds), a.count++);
125
+ }
126
+ }
127
+ for (let n = 0; n < l; n++) {
128
+ let r = t[n], l = r.count, u = i - r.count, d = r.leftCacheBounds, p = r.rightCacheBounds, m = 0;
129
+ l !== 0 && (m = S(d) / a);
130
+ let h = 0;
131
+ u !== 0 && (h = S(p) / a);
132
+ let g = 1 + f * (m * l + h * u);
133
+ g < c && (o = e, c = g, s = r.candidate);
134
+ }
135
+ } else {
136
+ for (let e = 0; e < j; e++) {
137
+ let t = M[e];
138
+ t.count = 0, t.candidate = r + l + e * l;
139
+ let n = t.bounds;
140
+ for (let e = 0; e < 3; e++) n[e] = Infinity, n[e + 3] = -Infinity;
141
+ }
142
+ for (let t = u; t < d; t += 6) {
143
+ let i = ~~((n[t + 2 * e] - r) / l);
144
+ i >= j && (i = j - 1);
145
+ let a = M[i];
146
+ a.count++, x(t, n, a.bounds);
147
+ }
148
+ let t = M[j - 1];
149
+ y(t.bounds, t.rightCacheBounds);
150
+ for (let e = j - 2; e >= 0; e--) {
151
+ let t = M[e], n = M[e + 1];
152
+ b(t.bounds, n.rightCacheBounds, t.rightCacheBounds);
153
+ }
154
+ let p = 0;
155
+ for (let t = 0; t < j - 1; t++) {
156
+ let n = M[t], r = n.count, l = n.bounds, u = M[t + 1].rightCacheBounds;
157
+ r !== 0 && (p === 0 ? y(l, te) : b(l, te, te)), p += r;
158
+ let d = 0, m = 0;
159
+ p !== 0 && (d = S(te) / a);
160
+ let h = i - p;
161
+ h !== 0 && (m = S(u) / a);
162
+ let g = 1 + f * (d * p + m * h);
163
+ g < c && (o = e, c = g, s = n.candidate);
164
+ }
165
+ }
166
+ }
167
+ } else console.warn(`BVH: Invalid build strategy value ${a} used.`);
168
+ return {
169
+ axis: o,
170
+ pos: s
171
+ };
172
+ }
173
+ function re(e, t, n, r) {
174
+ let i = 0, a = e.offset;
175
+ for (let o = t, s = t + n; o < s; o++) i += e[(o - a) * 6 + r * 2];
176
+ return i / n;
177
+ }
178
+ //#endregion
179
+ //#region ../../node_modules/three-mesh-bvh/src/core/BVHNode.js
180
+ var ie = class {
181
+ constructor() {
182
+ this.boundingData = new Float32Array(6);
183
+ }
184
+ };
185
+ //#endregion
186
+ //#region ../../node_modules/three-mesh-bvh/src/core/build/sortUtils.js
187
+ function ae(e, t, n, r, i, a) {
188
+ let o = r, s = r + i - 1, c = a.pos, l = a.axis * 2, u = n.offset || 0;
189
+ for (;;) {
190
+ for (; o <= s && n[(o - u) * 6 + l] < c;) o++;
191
+ for (; o <= s && n[(s - u) * 6 + l] >= c;) s--;
192
+ if (o < s) {
193
+ for (let n = 0; n < t; n++) {
194
+ let r = e[o * t + n];
195
+ e[o * t + n] = e[s * t + n], e[s * t + n] = r;
196
+ }
197
+ for (let e = 0; e < 6; e++) {
198
+ let t = o - u, r = s - u, i = n[t * 6 + e];
199
+ n[t * 6 + e] = n[r * 6 + e], n[r * 6 + e] = i;
200
+ }
201
+ o++, s--;
202
+ } else return o;
203
+ }
204
+ }
205
+ //#endregion
206
+ //#region ../../node_modules/three-mesh-bvh/src/core/build/buildUtils.js
207
+ var oe, se, ce, le, ue = 2 ** 32;
208
+ function de(e) {
209
+ return "count" in e ? 1 : 1 + de(e.left) + de(e.right);
210
+ }
211
+ function fe(e, t, n) {
212
+ return oe = new Float32Array(n), se = new Uint32Array(n), ce = new Uint16Array(n), le = new Uint8Array(n), pe(e, t);
213
+ }
214
+ function pe(e, t) {
215
+ let n = e / 4, r = e / 2, i = "count" in t, a = t.boundingData;
216
+ for (let e = 0; e < 6; e++) oe[n + e] = a[e];
217
+ if (i) return t.buffer ? (le.set(new Uint8Array(t.buffer), e), e + t.buffer.byteLength) : (se[n + 6] = t.offset, ce[r + 14] = t.count, ce[r + 15] = p, e + 32);
218
+ {
219
+ let { left: r, right: i, splitAxis: a } = t, o = pe(e + 32, r), s = e / 32, c = o / 32 - s;
220
+ if (c > ue) throw Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");
221
+ return se[n + 6] = c, se[n + 7] = a, pe(o, i);
222
+ }
223
+ }
224
+ //#endregion
225
+ //#region ../../node_modules/three-mesh-bvh/src/core/build/buildTree.js
226
+ function me(e, t, n, r, i, a) {
227
+ let { maxDepth: o, verbose: s, targetLeafSize: c, _strictLeafSize: l = Infinity, strategy: u, onProgress: d } = i, f = e.primitiveBuffer, p = e.primitiveBufferStride, m = new Float32Array(6), h = !1, g = new ie();
228
+ return A(t, n, r, g.boundingData, m), y(g, n, r, m), g;
229
+ function _(e) {
230
+ d && d((e - a.offset) / a.count);
231
+ }
232
+ function y(e, n, r, i = null, a = 0) {
233
+ !h && a >= o && (h = !0, s && console.warn(`BVH: Max depth of ${o} reached when generating BVH. Consider increasing maxDepth.`));
234
+ let d = r > l;
235
+ if (r <= c && !d || a >= o) return _(n + r), e.offset = n, e.count = r, e;
236
+ let g = ne(e.boundingData, i, t, n, r, u), b = g.axis === -1 ? -1 : ae(f, p, t, n, r, g);
237
+ if (g.axis === -1 || b === n || b === n + r) {
238
+ if (!d) return _(n + r), e.offset = n, e.count = r, e;
239
+ g.axis = Math.max(0, v(e.boundingData)), b = n + Math.max(1, Math.floor(r / 2));
240
+ }
241
+ e.splitAxis = g.axis;
242
+ let x = new ie(), S = n, C = b - n;
243
+ e.left = x, A(t, S, C, x.boundingData, m), y(x, S, C, m, a + 1);
244
+ let w = new ie(), T = b, E = r - C;
245
+ return e.right = w, A(t, T, E, w.boundingData, m), y(w, T, E, m, a + 1), e;
246
+ }
247
+ }
248
+ function he(e, t) {
249
+ let n = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer, r = e.getRootRanges(t.range), i = r[0], a = r[r.length - 1], o = {
250
+ offset: i.offset,
251
+ count: a.offset + a.count - i.offset
252
+ }, s = new Float32Array(6 * o.count);
253
+ s.offset = o.offset, e.computePrimitiveBounds(o.offset, o.count, s), e._roots = r.map((r) => {
254
+ let i = me(e, s, r.offset, r.count, t, o), a = new n(32 * de(i));
255
+ return fe(0, i, a), a;
256
+ });
257
+ }
258
+ //#endregion
259
+ //#region ../../node_modules/three-mesh-bvh/src/utils/PrimitivePool.js
260
+ var ge = class {
261
+ constructor(e) {
262
+ this._getNewPrimitive = e, this._primitives = [];
263
+ }
264
+ getPrimitive() {
265
+ let e = this._primitives;
266
+ return e.length === 0 ? this._getNewPrimitive() : e.pop();
267
+ }
268
+ releasePrimitive(e) {
269
+ this._primitives.push(e);
270
+ }
271
+ }, N = /* @__PURE__ */ new class {
272
+ constructor() {
273
+ this.float32Array = null, this.uint16Array = null, this.uint32Array = null;
274
+ let e = [], t = null;
275
+ this.setBuffer = (n) => {
276
+ t && e.push(t), t = n, this.float32Array = new Float32Array(n), this.uint16Array = new Uint16Array(n), this.uint32Array = new Uint32Array(n);
277
+ }, this.clearBuffer = () => {
278
+ t = null, this.float32Array = null, this.uint16Array = null, this.uint32Array = null, e.length !== 0 && this.setBuffer(e.pop());
279
+ };
280
+ }
281
+ }(), P, _e, ve = [], ye = /* @__PURE__ */ new ge(() => new o());
282
+ function be(e, t, n, r, i, a) {
283
+ P = ye.getPrimitive(), _e = ye.getPrimitive(), ve.push(P, _e), N.setBuffer(e._roots[t]);
284
+ let o = xe(0, e.geometry, n, r, i, a);
285
+ N.clearBuffer(), ye.releasePrimitive(P), ye.releasePrimitive(_e), ve.pop(), ve.pop();
286
+ let s = ve.length;
287
+ return s > 0 && (_e = ve[s - 1], P = ve[s - 2]), o;
288
+ }
289
+ function xe(e, t, n, r, i = null, a = 0, o = 0) {
290
+ let { float32Array: s, uint16Array: c, uint32Array: l } = N, u = e * 2;
291
+ if (C(u, c)) {
292
+ let t = w(e, l), n = T(u, c);
293
+ return _(k(e), s, P), r(t, n, !1, o, a + e / 8, P);
294
+ } else {
295
+ let u = E(e), d = D(e, l), f = u, p = d, m, h, g, v;
296
+ if (i && (g = P, v = _e, _(k(f), s, g), _(k(p), s, v), m = i(g), h = i(v), h < m)) {
297
+ f = d, p = u;
298
+ let e = m;
299
+ m = h, h = e, g = v;
300
+ }
301
+ g || (g = P, _(k(f), s, g));
302
+ let y = C(f * 2, c), b = n(g, y, m, o + 1, a + f / 8), x;
303
+ if (b === 2) {
304
+ let e = j(f);
305
+ x = r(e, ee(f) - e, !0, o + 1, a + f / 8, g);
306
+ } else x = b && xe(f, t, n, r, i, a, o + 1);
307
+ if (x) return !0;
308
+ v = _e, _(k(p), s, v);
309
+ let S = C(p * 2, c), O = n(v, S, h, o + 1, a + p / 8), A;
310
+ if (O === 2) {
311
+ let e = j(p);
312
+ A = r(e, ee(p) - e, !0, o + 1, a + p / 8, v);
313
+ } else A = O && xe(p, t, n, r, i, a, o + 1);
314
+ if (A) return !0;
315
+ return !1;
316
+ function j(e) {
317
+ let { uint16Array: t, uint32Array: n } = N, r = e * 2;
318
+ for (; !C(r, t);) e = E(e), r = e * 2;
319
+ return w(e, n);
320
+ }
321
+ function ee(e) {
322
+ let { uint16Array: t, uint32Array: n } = N, r = e * 2;
323
+ for (; !C(r, t);) e = D(e, n), r = e * 2;
324
+ return w(e, n) + T(r, t);
325
+ }
326
+ }
327
+ }
328
+ //#endregion
329
+ //#region ../../node_modules/three-mesh-bvh/src/core/cast/bvhcast.js
330
+ var Se = /* @__PURE__ */ new N.constructor(), Ce = /* @__PURE__ */ new N.constructor(), F = /* @__PURE__ */ new ge(() => new o()), we = /* @__PURE__ */ new o(), Te = /* @__PURE__ */ new o(), Ee = /* @__PURE__ */ new o(), De = /* @__PURE__ */ new o(), Oe = !1;
331
+ function ke(e, t, n, r) {
332
+ if (Oe) throw Error("MeshBVH: Recursive calls to bvhcast not supported.");
333
+ Oe = !0;
334
+ let i = e._roots, a = t._roots, o, s = 0, c = 0, l = new u().copy(n).invert();
335
+ for (let e = 0, t = i.length; e < t; e++) {
336
+ Se.setBuffer(i[e]), c = 0;
337
+ let t = F.getPrimitive();
338
+ _(k(0), Se.float32Array, t), t.applyMatrix4(l);
339
+ for (let e = 0, i = a.length; e < i && (Ce.setBuffer(a[e]), o = I(0, 0, n, l, r, s, c, 0, 0, t), Ce.clearBuffer(), c += a[e].byteLength / 32, !o); e++);
340
+ if (F.releasePrimitive(t), Se.clearBuffer(), s += i[e].byteLength / 32, o) break;
341
+ }
342
+ return Oe = !1, o;
343
+ }
344
+ function I(e, t, n, r, i, a = 0, o = 0, s = 0, c = 0, l = null, u = !1) {
345
+ let d, f;
346
+ u ? (d = Ce, f = Se) : (d = Se, f = Ce);
347
+ let p = d.float32Array, m = d.uint32Array, h = d.uint16Array, g = f.float32Array, v = f.uint32Array, y = f.uint16Array, b = e * 2, x = t * 2, S = C(b, h), O = C(x, y), A = !1;
348
+ if (O && S) A = u ? i(w(t, v), T(t * 2, y), w(e, m), T(e * 2, h), c, o + t / 8, s, a + e / 8) : i(w(e, m), T(e * 2, h), w(t, v), T(t * 2, y), s, a + e / 8, c, o + t / 8);
349
+ else if (O) {
350
+ let l = F.getPrimitive();
351
+ _(k(t), g, l), l.applyMatrix4(n);
352
+ let d = E(e), f = D(e, m);
353
+ _(k(d), p, we), _(k(f), p, Te);
354
+ let h = l.intersectsBox(we), v = l.intersectsBox(Te);
355
+ A = h && I(t, d, r, n, i, o, a, c, s + 1, l, !u) || v && I(t, f, r, n, i, o, a, c, s + 1, l, !u), F.releasePrimitive(l);
356
+ } else {
357
+ let d = E(t), f = D(t, v);
358
+ _(k(d), g, Ee), _(k(f), g, De);
359
+ let h = l.intersectsBox(Ee), y = l.intersectsBox(De);
360
+ if (h && y) A = I(e, d, n, r, i, a, o, s, c + 1, l, u) || I(e, f, n, r, i, a, o, s, c + 1, l, u);
361
+ else if (h) if (S) A = I(e, d, n, r, i, a, o, s, c + 1, l, u);
362
+ else {
363
+ let t = F.getPrimitive();
364
+ t.copy(Ee).applyMatrix4(n);
365
+ let l = E(e), f = D(e, m);
366
+ _(k(l), p, we), _(k(f), p, Te);
367
+ let h = t.intersectsBox(we), g = t.intersectsBox(Te);
368
+ A = h && I(d, l, r, n, i, o, a, c, s + 1, t, !u) || g && I(d, f, r, n, i, o, a, c, s + 1, t, !u), F.releasePrimitive(t);
369
+ }
370
+ else if (y) if (S) A = I(e, f, n, r, i, a, o, s, c + 1, l, u);
371
+ else {
372
+ let t = F.getPrimitive();
373
+ t.copy(De).applyMatrix4(n);
374
+ let l = E(e), d = D(e, m);
375
+ _(k(l), p, we), _(k(d), p, Te);
376
+ let h = t.intersectsBox(we), g = t.intersectsBox(Te);
377
+ A = h && I(f, l, r, n, i, o, a, c, s + 1, t, !u) || g && I(f, d, r, n, i, o, a, c, s + 1, t, !u), F.releasePrimitive(t);
378
+ }
379
+ }
380
+ return A;
381
+ }
382
+ //#endregion
383
+ //#region ../../node_modules/three-mesh-bvh/src/core/BVHTraversalHelper.js
384
+ var Ae = new class {
385
+ constructor() {
386
+ let e = null, t = null, n = null, r = !1;
387
+ this.root = null, this.buffer = null, this.uint32Array = null, this.uint16Array = null, this.setBVH = (i, a) => {
388
+ if (r) throw Error("BVHTraversalHelper: cannot call setBVH during an active traversal.");
389
+ this.root = a, this.buffer = e = i._roots[a], this.uint16Array = n = new Uint16Array(e), this.uint32Array = t = new Uint32Array(e);
390
+ }, this.reset = () => {
391
+ this.root = null, this.buffer = e = null, this.uint16Array = n = null, this.uint32Array = t = null;
392
+ }, this.getRangeStart = (e) => {
393
+ let r = e * 2;
394
+ for (; !C(r, n);) e = E(e), r = e * 2;
395
+ return w(e, t);
396
+ }, this.getRangeEnd = (e) => {
397
+ let r = e * 2;
398
+ for (; !C(r, n);) e = D(e, t), r = e * 2;
399
+ return w(e, t) + T(r, n);
400
+ };
401
+ let i = (e, r, a) => {
402
+ let o = C(r * 2, n);
403
+ if (!e(a, o, r) && !o) {
404
+ let n = E(r), o = D(r, t);
405
+ i(e, n, a + 1), i(e, o, a + 1);
406
+ }
407
+ };
408
+ this.traverseBuffer = (e) => {
409
+ if (r) throw Error("BVHTraversalHelper: cannot start a traversal during an active traversal.");
410
+ r = !0;
411
+ try {
412
+ i(e, 0, 0);
413
+ } finally {
414
+ r = !1;
415
+ }
416
+ }, this.traverse = (r) => {
417
+ this.traverseBuffer((i, a, o) => {
418
+ if (a) {
419
+ let s = o * 2, c = t[o + 6], l = n[s + 14];
420
+ return r(i, a, new Float32Array(e, o * 4, 6), c, l);
421
+ } else {
422
+ let n = O(o, t);
423
+ return r(i, a, new Float32Array(e, o * 4, 6), n);
424
+ }
425
+ });
426
+ };
427
+ }
428
+ }(), je = /* @__PURE__ */ new o(), Me = /* @__PURE__ */ new Float32Array(6), Ne = class {
429
+ constructor() {
430
+ this._roots = null, this.primitiveBuffer = null, this.primitiveBufferStride = null;
431
+ }
432
+ init(e) {
433
+ e = {
434
+ ...g,
435
+ ...e
436
+ }, "maxLeafSize" in e && (console.warn("BVH: \"maxLeafSize\" option has been deprecated. Use \"targetLeafSize\", instead."), e = {
437
+ ...e,
438
+ targetLeafSize: e.maxLeafSize
439
+ }), he(this, e);
440
+ }
441
+ getRootRanges() {
442
+ throw Error("BVH: getRootRanges() not implemented");
443
+ }
444
+ writePrimitiveBounds() {
445
+ throw Error("BVH: writePrimitiveBounds() not implemented");
446
+ }
447
+ writePrimitiveRangeBounds(e, t, n, r) {
448
+ let i = Infinity, a = Infinity, o = Infinity, s = -Infinity, c = -Infinity, l = -Infinity;
449
+ for (let n = e, r = e + t; n < r; n++) {
450
+ this.writePrimitiveBounds(n, Me, 0);
451
+ let [e, t, r, u, d, f] = Me;
452
+ e < i && (i = e), u > s && (s = u), t < a && (a = t), d > c && (c = d), r < o && (o = r), f > l && (l = f);
453
+ }
454
+ return n[r + 0] = i, n[r + 1] = a, n[r + 2] = o, n[r + 3] = s, n[r + 4] = c, n[r + 5] = l, n;
455
+ }
456
+ computePrimitiveBounds(e, t, n) {
457
+ let r = n.offset || 0;
458
+ for (let i = e, a = e + t; i < a; i++) {
459
+ this.writePrimitiveBounds(i, Me, 0);
460
+ let [e, t, a, o, s, c] = Me, l = (e + o) / 2, u = (t + s) / 2, d = (a + c) / 2, f = (o - e) / 2, p = (s - t) / 2, h = (c - a) / 2, g = (i - r) * 6;
461
+ n[g + 0] = l, n[g + 1] = f + (Math.abs(l) + f) * m, n[g + 2] = u, n[g + 3] = p + (Math.abs(u) + p) * m, n[g + 4] = d, n[g + 5] = h + (Math.abs(d) + h) * m;
462
+ }
463
+ return n;
464
+ }
465
+ shiftPrimitiveOffsets(e) {
466
+ let t = this._indirectBuffer;
467
+ if (t) for (let n = 0, r = t.length; n < r; n++) t[n] += e;
468
+ else {
469
+ let t = this._roots;
470
+ for (let n = 0; n < t.length; n++) {
471
+ let r = t[n], i = new Uint32Array(r), a = new Uint16Array(r), o = r.byteLength / 32;
472
+ for (let t = 0; t < o; t++) {
473
+ let n = 8 * t;
474
+ C(2 * n, a) && (i[n + 6] += e);
475
+ }
476
+ }
477
+ }
478
+ }
479
+ traverse(e, t = 0) {
480
+ Ae.setBVH(this, t), Ae.traverse(e), Ae.reset();
481
+ }
482
+ refit() {
483
+ let e = this._roots;
484
+ for (let t = 0, n = e.length; t < n; t++) {
485
+ let n = e[t], r = new Uint32Array(n), i = new Uint16Array(n), a = new Float32Array(n), o = n.byteLength / 32;
486
+ for (let e = o - 1; e >= 0; e--) {
487
+ let t = e * 8, n = t * 2;
488
+ if (C(n, i)) {
489
+ let e = w(t, r), o = T(n, i);
490
+ this.writePrimitiveRangeBounds(e, o, Me, 0), a.set(Me, t);
491
+ } else {
492
+ let e = E(t), n = D(t, r);
493
+ for (let r = 0; r < 3; r++) {
494
+ let i = a[e + r], o = a[e + r + 3], s = a[n + r], c = a[n + r + 3];
495
+ a[t + r] = i < s ? i : s, a[t + r + 3] = o > c ? o : c;
496
+ }
497
+ }
498
+ }
499
+ }
500
+ }
501
+ getBoundingBox(e) {
502
+ return e.makeEmpty(), this._roots.forEach((t) => {
503
+ _(0, new Float32Array(t), je), e.union(je);
504
+ }), e;
505
+ }
506
+ shapecast(e) {
507
+ let { boundsTraverseOrder: t, intersectsBounds: n, intersectsRange: r, intersectsPrimitive: i, scratchPrimitive: a, iterate: o } = e;
508
+ if (r && i) {
509
+ let e = r;
510
+ r = (t, n, r, s, c) => e(t, n, r, s, c) ? !0 : o(t, n, this, i, r, s, a);
511
+ } else r ||= i ? (e, t, n, r) => o(e, t, this, i, n, r, a) : (e, t, n) => n;
512
+ let s = !1, c = 0, l = this._roots;
513
+ for (let e = 0, i = l.length; e < i; e++) {
514
+ let i = l[e];
515
+ if (s = be(this, e, n, r, t, c), s) break;
516
+ c += i.byteLength / 32;
517
+ }
518
+ return s;
519
+ }
520
+ bvhcast(e, t, n) {
521
+ let { intersectsRanges: r } = n;
522
+ return ke(this, e, t, r);
523
+ }
524
+ };
525
+ //#endregion
526
+ //#region ../../node_modules/three-mesh-bvh/src/utils/BufferUtils.js
527
+ function Pe() {
528
+ return typeof SharedArrayBuffer < "u";
529
+ }
530
+ //#endregion
531
+ //#region ../../node_modules/three-mesh-bvh/src/core/build/geometryUtils.js
532
+ function Fe(e) {
533
+ return e.index ? e.index.count : e.attributes.position.count;
534
+ }
535
+ function Ie(e) {
536
+ return Fe(e) / 3;
537
+ }
538
+ function Le(e, t = ArrayBuffer) {
539
+ return e > 65535 ? new Uint32Array(new t(4 * e)) : new Uint16Array(new t(2 * e));
540
+ }
541
+ function Re(e, t) {
542
+ if (!e.index) {
543
+ let n = e.attributes.position.count, r = Le(n, t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer);
544
+ e.setIndex(new l(r, 1));
545
+ for (let e = 0; e < n; e++) r[e] = e;
546
+ }
547
+ }
548
+ function ze(e, t, n) {
549
+ let r = Fe(e) / n, i = t || e.drawRange, a = i.start / n, o = (i.start + i.count) / n, s = Math.max(0, a), c = Math.min(r, o) - s;
550
+ return {
551
+ offset: Math.floor(s),
552
+ count: Math.floor(c)
553
+ };
554
+ }
555
+ function Be(e, t) {
556
+ return e.groups.map((e) => ({
557
+ offset: e.start / t,
558
+ count: e.count / t
559
+ }));
560
+ }
561
+ function Ve(e, t, n) {
562
+ let r = ze(e, t, n), i = Be(e, n);
563
+ if (!i.length) return [r];
564
+ let a = [], o = r.offset, s = r.offset + r.count, c = Fe(e) / n, l = [];
565
+ for (let e of i) {
566
+ let { offset: t, count: n } = e, r = t, i = t + (isFinite(n) ? n : c - t);
567
+ r < s && i > o && (l.push({
568
+ pos: Math.max(o, r),
569
+ isStart: !0
570
+ }), l.push({
571
+ pos: Math.min(s, i),
572
+ isStart: !1
573
+ }));
574
+ }
575
+ l.sort((e, t) => e.pos === t.pos ? e.type === "end" ? -1 : 1 : e.pos - t.pos);
576
+ let u = 0, d = null;
577
+ for (let e of l) {
578
+ let t = e.pos;
579
+ u !== 0 && t !== d && a.push({
580
+ offset: d,
581
+ count: t - d
582
+ }), u += e.isStart ? 1 : -1, d = t;
583
+ }
584
+ return a;
585
+ }
586
+ //#endregion
587
+ //#region ../../node_modules/three-mesh-bvh/src/core/GeometryBVH.js
588
+ function He(e, t) {
589
+ let n = e[e.length - 1], r = n.offset + n.count > 2 ** 16, i = e.reduce((e, t) => e + t.count, 0), a = r ? 4 : 2, o = t ? new SharedArrayBuffer(i * a) : new ArrayBuffer(i * a), s = r ? new Uint32Array(o) : new Uint16Array(o), c = 0;
590
+ for (let t = 0; t < e.length; t++) {
591
+ let { offset: n, count: r } = e[t];
592
+ for (let e = 0; e < r; e++) s[c + e] = n + e;
593
+ c += r;
594
+ }
595
+ return s;
596
+ }
597
+ var Ue = class extends Ne {
598
+ get indirect() {
599
+ return !!this._indirectBuffer;
600
+ }
601
+ get primitiveStride() {
602
+ return null;
603
+ }
604
+ get primitiveBufferStride() {
605
+ return this.indirect ? 1 : this.primitiveStride;
606
+ }
607
+ set primitiveBufferStride(e) {}
608
+ get primitiveBuffer() {
609
+ return this.indirect ? this._indirectBuffer : this.geometry.index.array;
610
+ }
611
+ set primitiveBuffer(e) {}
612
+ constructor(e, t = {}) {
613
+ if (!e.isBufferGeometry) throw Error("BVH: Only BufferGeometries are supported.");
614
+ if (e.index && e.index.isInterleavedBufferAttribute) throw Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.");
615
+ if (t.useSharedArrayBuffer && !Pe()) throw Error("BVH: SharedArrayBuffer is not available.");
616
+ super(), this.geometry = e, this.resolvePrimitiveIndex = t.indirect ? (e) => this._indirectBuffer[e] : (e) => e, this.primitiveBuffer = null, this.primitiveBufferStride = null, this._indirectBuffer = null, t = {
617
+ ...g,
618
+ ...t
619
+ }, t[h] || this.init(t);
620
+ }
621
+ init(e) {
622
+ let { geometry: t, primitiveStride: n } = this;
623
+ e.indirect ? this._indirectBuffer = He(Ve(t, e.range, n), e.useSharedArrayBuffer) : Re(t, e), super.init(e), !t.boundingBox && e.setBoundingBox && (t.boundingBox = this.getBoundingBox(new o()));
624
+ }
625
+ getRootRanges(e) {
626
+ return this.indirect ? [{
627
+ offset: 0,
628
+ count: this._indirectBuffer.length
629
+ }] : Ve(this.geometry, e, this.primitiveStride);
630
+ }
631
+ raycastObject3D() {
632
+ throw Error("BVH: raycastObject3D() not implemented");
633
+ }
634
+ }, L = class {
635
+ constructor() {
636
+ this.min = Infinity, this.max = -Infinity;
637
+ }
638
+ setFromPointsField(e, t) {
639
+ let n = Infinity, r = -Infinity;
640
+ for (let i = 0, a = e.length; i < a; i++) {
641
+ let a = e[i][t];
642
+ n = a < n ? a : n, r = a > r ? a : r;
643
+ }
644
+ this.min = n, this.max = r;
645
+ }
646
+ setFromPoints(e, t) {
647
+ let n = Infinity, r = -Infinity;
648
+ for (let i = 0, a = t.length; i < a; i++) {
649
+ let a = t[i], o = e.dot(a);
650
+ n = o < n ? o : n, r = o > r ? o : r;
651
+ }
652
+ this.min = n, this.max = r;
653
+ }
654
+ isSeparated(e) {
655
+ return this.min > e.max || e.min > this.max;
656
+ }
657
+ };
658
+ L.prototype.setFromBox = (function() {
659
+ let e = /* @__PURE__ */ new t();
660
+ return function(t, n) {
661
+ let r = n.min, i = n.max, a = Infinity, o = -Infinity;
662
+ for (let n = 0; n <= 1; n++) for (let s = 0; s <= 1; s++) for (let c = 0; c <= 1; c++) {
663
+ e.x = r.x * n + i.x * (1 - n), e.y = r.y * s + i.y * (1 - s), e.z = r.z * c + i.z * (1 - c);
664
+ let l = t.dot(e);
665
+ a = Math.min(l, a), o = Math.max(l, o);
666
+ }
667
+ this.min = a, this.max = o;
668
+ };
669
+ })(), (function() {
670
+ let e = /* @__PURE__ */ new L();
671
+ return function(t, n) {
672
+ let r = t.points, i = t.satAxes, a = t.satBounds, o = n.points, s = n.satAxes, c = n.satBounds;
673
+ for (let t = 0; t < 3; t++) {
674
+ let n = a[t], r = i[t];
675
+ if (e.setFromPoints(r, o), n.isSeparated(e)) return !1;
676
+ }
677
+ for (let t = 0; t < 3; t++) {
678
+ let n = c[t], i = s[t];
679
+ if (e.setFromPoints(i, r), n.isSeparated(e)) return !1;
680
+ }
681
+ };
682
+ })();
683
+ //#endregion
684
+ //#region ../../node_modules/three-mesh-bvh/src/math/MathUtilities.js
685
+ var We = (function() {
686
+ let e = /* @__PURE__ */ new t(), n = /* @__PURE__ */ new t(), r = /* @__PURE__ */ new t();
687
+ return function(t, i, a) {
688
+ let o = t.start, s = e, c = i.start, l = n;
689
+ r.subVectors(o, c), e.subVectors(t.end, t.start), n.subVectors(i.end, i.start);
690
+ let u = r.dot(l), d = l.dot(s), f = l.dot(l), p = r.dot(s), m = s.dot(s) * f - d * d, h, g;
691
+ h = m === 0 ? 0 : (u * d - p * f) / m, g = (u + h * d) / f, a.x = h, a.y = g;
692
+ };
693
+ })(), Ge = (function() {
694
+ let e = /* @__PURE__ */ new i(), n = /* @__PURE__ */ new t(), r = /* @__PURE__ */ new t();
695
+ return function(t, i, a, o) {
696
+ We(t, i, e);
697
+ let s = e.x, c = e.y;
698
+ if (s >= 0 && s <= 1 && c >= 0 && c <= 1) {
699
+ t.at(s, a), i.at(c, o);
700
+ return;
701
+ } else if (s >= 0 && s <= 1) {
702
+ c < 0 ? i.at(0, o) : i.at(1, o), t.closestPointToPoint(o, !0, a);
703
+ return;
704
+ } else if (c >= 0 && c <= 1) {
705
+ s < 0 ? t.at(0, a) : t.at(1, a), i.closestPointToPoint(a, !0, o);
706
+ return;
707
+ } else {
708
+ let e;
709
+ e = s < 0 ? t.start : t.end;
710
+ let l;
711
+ l = c < 0 ? i.start : i.end;
712
+ let u = n, d = r;
713
+ if (t.closestPointToPoint(l, !0, n), i.closestPointToPoint(e, !0, r), u.distanceToSquared(l) <= d.distanceToSquared(e)) {
714
+ a.copy(u), o.copy(l);
715
+ return;
716
+ } else {
717
+ a.copy(e), o.copy(d);
718
+ return;
719
+ }
720
+ }
721
+ };
722
+ })(), Ke = (function() {
723
+ let n = /* @__PURE__ */ new t(), r = /* @__PURE__ */ new t(), i = /* @__PURE__ */ new c(), a = /* @__PURE__ */ new e();
724
+ return function(e, t) {
725
+ let { radius: o, center: s } = e, { a: c, b: l, c: u } = t;
726
+ if (a.start = c, a.end = l, a.closestPointToPoint(s, !0, n).distanceTo(s) <= o || (a.start = c, a.end = u, a.closestPointToPoint(s, !0, n).distanceTo(s) <= o) || (a.start = l, a.end = u, a.closestPointToPoint(s, !0, n).distanceTo(s) <= o)) return !0;
727
+ let d = t.getPlane(i);
728
+ if (Math.abs(d.distanceToPoint(s)) <= o) {
729
+ let e = d.projectPoint(s, r);
730
+ if (t.containsPoint(e)) return !0;
731
+ }
732
+ return !1;
733
+ };
734
+ })(), qe = [
735
+ "x",
736
+ "y",
737
+ "z"
738
+ ], R = 1e-15, Je = R * R;
739
+ function z(e) {
740
+ return Math.abs(e) < R;
741
+ }
742
+ var B = class extends d {
743
+ constructor(...n) {
744
+ super(...n), this.isExtendedTriangle = !0, this.satAxes = [
745
+ ,
746
+ ,
747
+ ,
748
+ ,
749
+ ].fill().map(() => new t()), this.satBounds = [
750
+ ,
751
+ ,
752
+ ,
753
+ ,
754
+ ].fill().map(() => new L()), this.points = [
755
+ this.a,
756
+ this.b,
757
+ this.c
758
+ ], this.plane = new c(), this.isDegenerateIntoSegment = !1, this.isDegenerateIntoPoint = !1, this.degenerateSegment = new e(), this.needsUpdate = !0;
759
+ }
760
+ intersectsSphere(e) {
761
+ return Ke(e, this);
762
+ }
763
+ update() {
764
+ let e = this.a, t = this.b, n = this.c, r = this.points, i = this.satAxes, a = this.satBounds, o = i[0], s = a[0];
765
+ this.getNormal(o), s.setFromPoints(o, r);
766
+ let c = i[1], l = a[1];
767
+ c.subVectors(e, t), l.setFromPoints(c, r);
768
+ let u = i[2], d = a[2];
769
+ u.subVectors(t, n), d.setFromPoints(u, r);
770
+ let f = i[3], p = a[3];
771
+ f.subVectors(n, e), p.setFromPoints(f, r);
772
+ let m = c.length(), h = u.length(), g = f.length();
773
+ this.isDegenerateIntoPoint = !1, this.isDegenerateIntoSegment = !1, m < R ? h < R || g < R ? this.isDegenerateIntoPoint = !0 : (this.isDegenerateIntoSegment = !0, this.degenerateSegment.start.copy(e), this.degenerateSegment.end.copy(n)) : h < R ? g < R ? this.isDegenerateIntoPoint = !0 : (this.isDegenerateIntoSegment = !0, this.degenerateSegment.start.copy(t), this.degenerateSegment.end.copy(e)) : g < R && (this.isDegenerateIntoSegment = !0, this.degenerateSegment.start.copy(n), this.degenerateSegment.end.copy(t)), this.plane.setFromNormalAndCoplanarPoint(o, e), this.needsUpdate = !1;
774
+ }
775
+ };
776
+ B.prototype.closestPointToSegment = (function() {
777
+ let n = /* @__PURE__ */ new t(), r = /* @__PURE__ */ new t(), i = /* @__PURE__ */ new e();
778
+ return function(e, t = null, a = null) {
779
+ let { start: o, end: s } = e, c = this.points, l, u = Infinity;
780
+ for (let o = 0; o < 3; o++) {
781
+ let s = (o + 1) % 3;
782
+ i.start.copy(c[o]), i.end.copy(c[s]), Ge(i, e, n, r), l = n.distanceToSquared(r), l < u && (u = l, t && t.copy(n), a && a.copy(r));
783
+ }
784
+ return this.closestPointToPoint(o, n), l = o.distanceToSquared(n), l < u && (u = l, t && t.copy(n), a && a.copy(o)), this.closestPointToPoint(s, n), l = s.distanceToSquared(n), l < u && (u = l, t && t.copy(n), a && a.copy(s)), Math.sqrt(u);
785
+ };
786
+ })(), B.prototype.intersectsTriangle = (function() {
787
+ let n = /* @__PURE__ */ new B(), r = /* @__PURE__ */ new L(), a = /* @__PURE__ */ new L(), o = /* @__PURE__ */ new t(), s = /* @__PURE__ */ new t(), c = /* @__PURE__ */ new t(), l = /* @__PURE__ */ new t(), u = /* @__PURE__ */ new e(), d = /* @__PURE__ */ new e(), f = /* @__PURE__ */ new t(), p = /* @__PURE__ */ new i(), m = /* @__PURE__ */ new i();
788
+ function h(e, t, n, i) {
789
+ let s = o;
790
+ !e.isDegenerateIntoPoint && !e.isDegenerateIntoSegment ? s.copy(e.plane.normal) : s.copy(t.plane.normal);
791
+ let c = e.satBounds, u = e.satAxes;
792
+ for (let n = 1; n < 4; n++) {
793
+ let i = c[n], o = u[n];
794
+ if (r.setFromPoints(o, t.points), i.isSeparated(r) || (l.copy(s).cross(o), r.setFromPoints(l, e.points), a.setFromPoints(l, t.points), r.isSeparated(a))) return !1;
795
+ }
796
+ let d = t.satBounds, f = t.satAxes;
797
+ for (let n = 1; n < 4; n++) {
798
+ let i = d[n], o = f[n];
799
+ if (r.setFromPoints(o, e.points), i.isSeparated(r) || (l.crossVectors(s, o), r.setFromPoints(l, e.points), a.setFromPoints(l, t.points), r.isSeparated(a))) return !1;
800
+ }
801
+ return n && (i || console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."), n.start.set(0, 0, 0), n.end.set(0, 0, 0)), !0;
802
+ }
803
+ function g(e, t, n, r, i, a, o, s, c, l, u) {
804
+ let d = o / (o - s);
805
+ l.x = r + (i - r) * d, u.start.subVectors(t, e).multiplyScalar(d).add(e), d = o / (o - c), l.y = r + (a - r) * d, u.end.subVectors(n, e).multiplyScalar(d).add(e);
806
+ }
807
+ function _(e, t, n, r, i, a, o, s, c, l, u) {
808
+ if (i > 0) g(e.c, e.a, e.b, r, t, n, c, o, s, l, u);
809
+ else if (a > 0) g(e.b, e.a, e.c, n, t, r, s, o, c, l, u);
810
+ else if (s * c > 0 || o != 0) g(e.a, e.b, e.c, t, n, r, o, s, c, l, u);
811
+ else if (s != 0) g(e.b, e.a, e.c, n, t, r, s, o, c, l, u);
812
+ else if (c != 0) g(e.c, e.a, e.b, r, t, n, c, o, s, l, u);
813
+ else return !0;
814
+ return !1;
815
+ }
816
+ function v(e, t, n, r) {
817
+ let i = t.degenerateSegment, a = e.plane.distanceToPoint(i.start), s = e.plane.distanceToPoint(i.end);
818
+ return z(a) ? z(s) ? h(e, t, n, r) : (n && (n.start.copy(i.start), n.end.copy(i.start)), e.containsPoint(i.start)) : z(s) ? (n && (n.start.copy(i.end), n.end.copy(i.end)), e.containsPoint(i.end)) : e.plane.intersectLine(i, o) == null ? !1 : (n && (n.start.copy(o), n.end.copy(o)), e.containsPoint(o));
819
+ }
820
+ function y(e, t, n) {
821
+ let r = t.a;
822
+ return z(e.plane.distanceToPoint(r)) && e.containsPoint(r) ? (n && (n.start.copy(r), n.end.copy(r)), !0) : !1;
823
+ }
824
+ function b(e, t, n) {
825
+ let r = e.degenerateSegment, i = t.a;
826
+ return r.closestPointToPoint(i, !0, o), i.distanceToSquared(o) < Je ? (n && (n.start.copy(i), n.end.copy(i)), !0) : !1;
827
+ }
828
+ function x(e, t, n, r) {
829
+ if (e.isDegenerateIntoSegment) if (t.isDegenerateIntoSegment) {
830
+ let r = e.degenerateSegment, i = t.degenerateSegment, a = s, l = c;
831
+ r.delta(a), i.delta(l);
832
+ let u = o.subVectors(i.start, r.start), d = a.x * l.y - a.y * l.x;
833
+ if (z(d)) return !1;
834
+ let f = (u.x * l.y - u.y * l.x) / d, p = -(a.x * u.y - a.y * u.x) / d;
835
+ return f < 0 || f > 1 || p < 0 || p > 1 ? !1 : z(r.start.z + a.z * f - (i.start.z + l.z * p)) ? (n && (n.start.copy(r.start).addScaledVector(a, f), n.end.copy(r.start).addScaledVector(a, f)), !0) : !1;
836
+ } else if (t.isDegenerateIntoPoint) return b(e, t, n);
837
+ else return v(t, e, n, r);
838
+ else if (e.isDegenerateIntoPoint) return t.isDegenerateIntoPoint ? t.a.distanceToSquared(e.a) < Je ? (n && (n.start.copy(e.a), n.end.copy(e.a)), !0) : !1 : t.isDegenerateIntoSegment ? b(t, e, n) : y(t, e, n);
839
+ else if (t.isDegenerateIntoPoint) return y(e, t, n);
840
+ else if (t.isDegenerateIntoSegment) return v(e, t, n, r);
841
+ }
842
+ return function(e, t = null, r = !1) {
843
+ this.needsUpdate && this.update(), e.isExtendedTriangle ? e.needsUpdate && e.update() : (n.copy(e), n.update(), e = n);
844
+ let i = x(this, e, t, r);
845
+ if (i !== void 0) return i;
846
+ let a = this.plane, o = e.plane, l = o.distanceToPoint(this.a), g = o.distanceToPoint(this.b), v = o.distanceToPoint(this.c);
847
+ z(l) && (l = 0), z(g) && (g = 0), z(v) && (v = 0);
848
+ let y = l * g, b = l * v;
849
+ if (y > 0 && b > 0) return !1;
850
+ let S = a.distanceToPoint(e.a), C = a.distanceToPoint(e.b), w = a.distanceToPoint(e.c);
851
+ z(S) && (S = 0), z(C) && (C = 0), z(w) && (w = 0);
852
+ let T = S * C, E = S * w;
853
+ if (T > 0 && E > 0) return !1;
854
+ s.copy(a.normal), c.copy(o.normal);
855
+ let D = s.cross(c), O = 0, k = Math.abs(D.x), A = Math.abs(D.y);
856
+ A > k && (k = A, O = 1), Math.abs(D.z) > k && (O = 2);
857
+ let j = qe[O], ee = this.a[j], M = this.b[j], te = this.c[j], ne = e.a[j], re = e.b[j], ie = e.c[j];
858
+ if (_(this, ee, M, te, y, b, l, g, v, p, u) || _(e, ne, re, ie, T, E, S, C, w, m, d)) return h(this, e, t, r);
859
+ if (p.y < p.x) {
860
+ let e = p.y;
861
+ p.y = p.x, p.x = e, f.copy(u.start), u.start.copy(u.end), u.end.copy(f);
862
+ }
863
+ if (m.y < m.x) {
864
+ let e = m.y;
865
+ m.y = m.x, m.x = e, f.copy(d.start), d.start.copy(d.end), d.end.copy(f);
866
+ }
867
+ return p.y < m.x || m.y < p.x ? !1 : (t && (m.x > p.x ? t.start.copy(d.start) : t.start.copy(u.start), m.y < p.y ? t.end.copy(d.end) : t.end.copy(u.end)), !0);
868
+ };
869
+ })(), B.prototype.distanceToPoint = (function() {
870
+ let e = /* @__PURE__ */ new t();
871
+ return function(t) {
872
+ return this.closestPointToPoint(t, e), t.distanceTo(e);
873
+ };
874
+ })(), B.prototype.distanceToTriangle = (function() {
875
+ let n = /* @__PURE__ */ new t(), r = /* @__PURE__ */ new t(), i = [
876
+ "a",
877
+ "b",
878
+ "c"
879
+ ], a = /* @__PURE__ */ new e(), o = /* @__PURE__ */ new e();
880
+ return function(e, t = null, s = null) {
881
+ let c = t || s ? a : null;
882
+ if (this.intersectsTriangle(e, c, !0)) return (t || s) && (t && c.getCenter(t), s && c.getCenter(s)), 0;
883
+ let l = Infinity;
884
+ for (let r = 0; r < 3; r++) {
885
+ let a, o = i[r], c = e[o];
886
+ this.closestPointToPoint(c, n), a = c.distanceToSquared(n), a < l && (l = a, t && t.copy(n), s && s.copy(c));
887
+ let u = this[o];
888
+ e.closestPointToPoint(u, n), a = u.distanceToSquared(n), a < l && (l = a, t && t.copy(u), s && s.copy(n));
889
+ }
890
+ for (let c = 0; c < 3; c++) {
891
+ let u = i[c], d = i[(c + 1) % 3];
892
+ a.set(this[u], this[d]);
893
+ for (let c = 0; c < 3; c++) {
894
+ let u = i[c], d = i[(c + 1) % 3];
895
+ o.set(e[u], e[d]), Ge(a, o, n, r);
896
+ let f = n.distanceToSquared(r);
897
+ f < l && (l = f, t && t.copy(n), s && s.copy(r));
898
+ }
899
+ }
900
+ return Math.sqrt(l);
901
+ };
902
+ })();
903
+ //#endregion
904
+ //#region ../../node_modules/three-mesh-bvh/src/math/OrientedBox.js
905
+ var V = class {
906
+ constructor(e, n, r) {
907
+ this.isOrientedBox = !0, this.min = new t(), this.max = new t(), this.matrix = new u(), this.invMatrix = new u(), this.points = Array(8).fill().map(() => new t()), this.satAxes = [
908
+ ,
909
+ ,
910
+ ,
911
+ ].fill().map(() => new t()), this.satBounds = [
912
+ ,
913
+ ,
914
+ ,
915
+ ].fill().map(() => new L()), this.alignedSatBounds = [
916
+ ,
917
+ ,
918
+ ,
919
+ ].fill().map(() => new L()), this.needsUpdate = !1, e && this.min.copy(e), n && this.max.copy(n), r && this.matrix.copy(r);
920
+ }
921
+ set(e, t, n) {
922
+ this.min.copy(e), this.max.copy(t), this.matrix.copy(n), this.needsUpdate = !0;
923
+ }
924
+ copy(e) {
925
+ this.min.copy(e.min), this.max.copy(e.max), this.matrix.copy(e.matrix), this.needsUpdate = !0;
926
+ }
927
+ };
928
+ V.prototype.update = (function() {
929
+ return function() {
930
+ let e = this.matrix, t = this.min, n = this.max, r = this.points;
931
+ for (let i = 0; i <= 1; i++) for (let a = 0; a <= 1; a++) for (let o = 0; o <= 1; o++) {
932
+ let s = r[1 * i | 2 * a | 4 * o];
933
+ s.x = i ? n.x : t.x, s.y = a ? n.y : t.y, s.z = o ? n.z : t.z, s.applyMatrix4(e);
934
+ }
935
+ let i = this.satBounds, a = this.satAxes, o = r[0];
936
+ for (let e = 0; e < 3; e++) {
937
+ let t = a[e], n = i[e], s = r[1 << e];
938
+ t.subVectors(o, s), n.setFromPoints(t, r);
939
+ }
940
+ let s = this.alignedSatBounds;
941
+ s[0].setFromPointsField(r, "x"), s[1].setFromPointsField(r, "y"), s[2].setFromPointsField(r, "z"), this.invMatrix.copy(this.matrix).invert(), this.needsUpdate = !1;
942
+ };
943
+ })(), V.prototype.intersectsBox = (function() {
944
+ let e = /* @__PURE__ */ new L();
945
+ return function(t) {
946
+ this.needsUpdate && this.update();
947
+ let n = t.min, r = t.max, i = this.satBounds, a = this.satAxes, o = this.alignedSatBounds;
948
+ if (e.min = n.x, e.max = r.x, o[0].isSeparated(e) || (e.min = n.y, e.max = r.y, o[1].isSeparated(e)) || (e.min = n.z, e.max = r.z, o[2].isSeparated(e))) return !1;
949
+ for (let n = 0; n < 3; n++) {
950
+ let r = a[n], o = i[n];
951
+ if (e.setFromBox(r, t), o.isSeparated(e)) return !1;
952
+ }
953
+ return !0;
954
+ };
955
+ })(), V.prototype.intersectsTriangle = (function() {
956
+ let e = /* @__PURE__ */ new B(), n = [
957
+ ,
958
+ ,
959
+ ,
960
+ ], r = /* @__PURE__ */ new L(), i = /* @__PURE__ */ new L(), a = /* @__PURE__ */ new t();
961
+ return function(t) {
962
+ this.needsUpdate && this.update(), t.isExtendedTriangle ? t.needsUpdate && t.update() : (e.copy(t), e.update(), t = e);
963
+ let o = this.satBounds, s = this.satAxes;
964
+ n[0] = t.a, n[1] = t.b, n[2] = t.c;
965
+ for (let e = 0; e < 3; e++) {
966
+ let t = o[e], i = s[e];
967
+ if (r.setFromPoints(i, n), t.isSeparated(r)) return !1;
968
+ }
969
+ let c = t.satBounds, l = t.satAxes, u = this.points;
970
+ for (let e = 0; e < 3; e++) {
971
+ let t = c[e], n = l[e];
972
+ if (r.setFromPoints(n, u), t.isSeparated(r)) return !1;
973
+ }
974
+ for (let e = 0; e < 3; e++) {
975
+ let t = s[e];
976
+ for (let e = 0; e < 4; e++) {
977
+ let o = l[e];
978
+ if (a.crossVectors(t, o), r.setFromPoints(a, n), i.setFromPoints(a, u), r.isSeparated(i)) return !1;
979
+ }
980
+ }
981
+ return !0;
982
+ };
983
+ })(), V.prototype.closestPointToPoint = (function() {
984
+ return function(e, t) {
985
+ return this.needsUpdate && this.update(), t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min, this.max).applyMatrix4(this.matrix), t;
986
+ };
987
+ })(), V.prototype.distanceToPoint = (function() {
988
+ let e = new t();
989
+ return function(t) {
990
+ return this.closestPointToPoint(t, e), t.distanceTo(e);
991
+ };
992
+ })(), V.prototype.distanceToBox = (function() {
993
+ let n = [
994
+ "x",
995
+ "y",
996
+ "z"
997
+ ], r = /* @__PURE__ */ Array(12).fill().map(() => new e()), i = /* @__PURE__ */ Array(12).fill().map(() => new e()), a = /* @__PURE__ */ new t(), o = /* @__PURE__ */ new t();
998
+ return function(e, t = 0, s = null, c = null) {
999
+ if (this.needsUpdate && this.update(), this.intersectsBox(e)) return (s || c) && (e.getCenter(o), this.closestPointToPoint(o, a), e.closestPointToPoint(a, o), s && s.copy(a), c && c.copy(o)), 0;
1000
+ let l = t * t, u = e.min, d = e.max, f = this.points, p = Infinity;
1001
+ for (let e = 0; e < 8; e++) {
1002
+ let t = f[e];
1003
+ o.copy(t).clamp(u, d);
1004
+ let n = t.distanceToSquared(o);
1005
+ if (n < p && (p = n, s && s.copy(t), c && c.copy(o), n < l)) return Math.sqrt(n);
1006
+ }
1007
+ let m = 0;
1008
+ for (let e = 0; e < 3; e++) for (let t = 0; t <= 1; t++) for (let a = 0; a <= 1; a++) {
1009
+ let o = (e + 1) % 3, s = (e + 2) % 3, c = t << o | a << s, l = 1 << e | t << o | a << s, p = f[c], h = f[l];
1010
+ r[m].set(p, h);
1011
+ let g = n[e], _ = n[o], v = n[s], y = i[m], b = y.start, x = y.end;
1012
+ b[g] = u[g], b[_] = t ? u[_] : d[_], b[v] = a ? u[v] : d[_], x[g] = d[g], x[_] = t ? u[_] : d[_], x[v] = a ? u[v] : d[_], m++;
1013
+ }
1014
+ for (let e = 0; e <= 1; e++) for (let t = 0; t <= 1; t++) for (let n = 0; n <= 1; n++) {
1015
+ o.x = e ? d.x : u.x, o.y = t ? d.y : u.y, o.z = n ? d.z : u.z, this.closestPointToPoint(o, a);
1016
+ let r = o.distanceToSquared(a);
1017
+ if (r < p && (p = r, s && s.copy(a), c && c.copy(o), r < l)) return Math.sqrt(r);
1018
+ }
1019
+ for (let e = 0; e < 12; e++) {
1020
+ let t = r[e];
1021
+ for (let e = 0; e < 12; e++) {
1022
+ let n = i[e];
1023
+ Ge(t, n, a, o);
1024
+ let r = a.distanceToSquared(o);
1025
+ if (r < p && (p = r, s && s.copy(a), c && c.copy(o), r < l)) return Math.sqrt(r);
1026
+ }
1027
+ }
1028
+ return Math.sqrt(p);
1029
+ };
1030
+ })();
1031
+ var H = /* @__PURE__ */ new class extends ge {
1032
+ constructor() {
1033
+ super(() => new B());
1034
+ }
1035
+ }(), Ye = /* @__PURE__ */ new t(), Xe = /* @__PURE__ */ new t();
1036
+ function Ze(e, t, n = {}, r = 0, i = Infinity) {
1037
+ let a = r * r, o = i * i, s = Infinity, c = null;
1038
+ if (e.shapecast({
1039
+ boundsTraverseOrder: (e) => (Ye.copy(t).clamp(e.min, e.max), Ye.distanceToSquared(t)),
1040
+ intersectsBounds: (e, t, n) => n < s && n < o,
1041
+ intersectsTriangle: (e, n) => {
1042
+ e.closestPointToPoint(t, Ye);
1043
+ let r = t.distanceToSquared(Ye);
1044
+ return r < s && (Xe.copy(Ye), s = r, c = n), r < a;
1045
+ }
1046
+ }), s === Infinity) return null;
1047
+ let l = Math.sqrt(s);
1048
+ return n.point ? n.point.copy(Xe) : n.point = Xe.clone(), n.distance = l, n.faceIndex = c, n;
1049
+ }
1050
+ //#endregion
1051
+ //#region ../../node_modules/three-mesh-bvh/src/utils/ThreeRayIntersectUtilities.js
1052
+ var Qe = !0, $e = !1, U = /* @__PURE__ */ new t(), W = /* @__PURE__ */ new t(), G = /* @__PURE__ */ new t(), et = /* @__PURE__ */ new i(), tt = /* @__PURE__ */ new i(), nt = /* @__PURE__ */ new i(), rt = /* @__PURE__ */ new t(), it = /* @__PURE__ */ new t(), at = /* @__PURE__ */ new t(), ot = /* @__PURE__ */ new t();
1053
+ function st(e, t, n, r, i, a, o, s) {
1054
+ let c;
1055
+ if (c = a === 1 ? e.intersectTriangle(r, n, t, !0, i) : e.intersectTriangle(t, n, r, a !== 2, i), c === null) return null;
1056
+ let l = e.origin.distanceTo(i);
1057
+ return l < o || l > s ? null : {
1058
+ distance: l,
1059
+ point: i.clone()
1060
+ };
1061
+ }
1062
+ function ct(e, n, r, a, o, s, c, l, u, f, p) {
1063
+ U.fromBufferAttribute(n, s), W.fromBufferAttribute(n, c), G.fromBufferAttribute(n, l);
1064
+ let m = st(e, U, W, G, ot, u, f, p);
1065
+ if (m) {
1066
+ if (a) {
1067
+ et.fromBufferAttribute(a, s), tt.fromBufferAttribute(a, c), nt.fromBufferAttribute(a, l), m.uv = new i();
1068
+ let e = d.getInterpolation(ot, U, W, G, et, tt, nt, m.uv);
1069
+ Qe || (m.uv = e);
1070
+ }
1071
+ if (o) {
1072
+ et.fromBufferAttribute(o, s), tt.fromBufferAttribute(o, c), nt.fromBufferAttribute(o, l), m.uv1 = new i();
1073
+ let e = d.getInterpolation(ot, U, W, G, et, tt, nt, m.uv1);
1074
+ Qe || (m.uv1 = e), $e && (m.uv2 = m.uv1);
1075
+ }
1076
+ if (r) {
1077
+ rt.fromBufferAttribute(r, s), it.fromBufferAttribute(r, c), at.fromBufferAttribute(r, l), m.normal = new t();
1078
+ let n = d.getInterpolation(ot, U, W, G, rt, it, at, m.normal);
1079
+ m.normal.dot(e.direction) > 0 && m.normal.multiplyScalar(-1), Qe || (m.normal = n);
1080
+ }
1081
+ let n = {
1082
+ a: s,
1083
+ b: c,
1084
+ c: l,
1085
+ normal: new t(),
1086
+ materialIndex: 0
1087
+ };
1088
+ if (d.getNormal(U, W, G, n.normal), m.face = n, m.faceIndex = s, Qe) {
1089
+ let e = new t();
1090
+ d.getBarycoord(ot, U, W, G, e), m.barycoord = e;
1091
+ }
1092
+ }
1093
+ return m;
1094
+ }
1095
+ function lt(e) {
1096
+ return e && e.isMaterial ? e.side : e;
1097
+ }
1098
+ function ut(e, t, n, r, i, a, o) {
1099
+ let s = r * 3, c = s + 0, l = s + 1, u = s + 2, { index: d, groups: f } = e;
1100
+ e.index && (c = d.getX(c), l = d.getX(l), u = d.getX(u));
1101
+ let { position: p, normal: m, uv: h, uv1: g } = e.attributes;
1102
+ if (Array.isArray(t)) {
1103
+ let e = r * 3;
1104
+ for (let s = 0, d = f.length; s < d; s++) {
1105
+ let { start: d, count: _, materialIndex: v } = f[s];
1106
+ if (e >= d && e < d + _) {
1107
+ let e = lt(t[v]), s = ct(n, p, m, h, g, c, l, u, e, a, o);
1108
+ if (s) if (s.faceIndex = r, s.face.materialIndex = v, i) i.push(s);
1109
+ else return s;
1110
+ }
1111
+ }
1112
+ } else {
1113
+ let e = lt(t), s = ct(n, p, m, h, g, c, l, u, e, a, o);
1114
+ if (s) if (s.faceIndex = r, s.face.materialIndex = 0, i) i.push(s);
1115
+ else return s;
1116
+ }
1117
+ return null;
1118
+ }
1119
+ //#endregion
1120
+ //#region ../../node_modules/three-mesh-bvh/src/utils/TriangleUtilities.js
1121
+ function K(e, t, n, r) {
1122
+ let i = e.a, a = e.b, o = e.c, s = t, c = t + 1, l = t + 2;
1123
+ n && (s = n.getX(s), c = n.getX(c), l = n.getX(l)), i.x = r.getX(s), i.y = r.getY(s), i.z = r.getZ(s), a.x = r.getX(c), a.y = r.getY(c), a.z = r.getZ(c), o.x = r.getX(l), o.y = r.getY(l), o.z = r.getZ(l);
1124
+ }
1125
+ //#endregion
1126
+ //#region ../../node_modules/three-mesh-bvh/src/core/utils/iterationUtils.generated.js
1127
+ function dt(e, t, n, r, i, a, o, s) {
1128
+ let { geometry: c, _indirectBuffer: l } = e;
1129
+ for (let e = r, l = r + i; e < l; e++) ut(c, t, n, e, a, o, s);
1130
+ }
1131
+ function ft(e, t, n, r, i, a, o) {
1132
+ let { geometry: s, _indirectBuffer: c } = e, l = Infinity, u = null;
1133
+ for (let e = r, c = r + i; e < c; e++) {
1134
+ let r;
1135
+ r = ut(s, t, n, e, null, a, o), r && r.distance < l && (u = r, l = r.distance);
1136
+ }
1137
+ return u;
1138
+ }
1139
+ function pt(e, t, n, r, i, a, o) {
1140
+ let { geometry: s } = n, { index: c } = s, l = s.attributes.position;
1141
+ for (let n = e, s = t + e; n < s; n++) {
1142
+ let e;
1143
+ if (e = n, K(o, e * 3, c, l), o.needsUpdate = !0, r(o, e, i, a)) return !0;
1144
+ }
1145
+ return !1;
1146
+ }
1147
+ //#endregion
1148
+ //#region ../../node_modules/three-mesh-bvh/src/core/cast/refit.generated.js
1149
+ function mt(e, t = null) {
1150
+ t && Array.isArray(t) && (t = new Set(t));
1151
+ let n = e.geometry, r = n.index ? n.index.array : null, i = n.attributes.position, a, o, s, c, l = 0, u = e._roots;
1152
+ for (let e = 0, t = u.length; e < t; e++) a = u[e], o = new Uint32Array(a), s = new Uint16Array(a), c = new Float32Array(a), d(0, l), l += a.byteLength;
1153
+ function d(e, n, a = !1) {
1154
+ let l = e * 2;
1155
+ if (C(l, s)) {
1156
+ let t = w(e, o), n = T(l, s), a = Infinity, u = Infinity, d = Infinity, f = -Infinity, p = -Infinity, m = -Infinity;
1157
+ for (let e = 3 * t, o = 3 * (t + n); e < o; e++) {
1158
+ let t = r[e], n = i.getX(t), o = i.getY(t), s = i.getZ(t);
1159
+ n < a && (a = n), n > f && (f = n), o < u && (u = o), o > p && (p = o), s < d && (d = s), s > m && (m = s);
1160
+ }
1161
+ return c[e + 0] !== a || c[e + 1] !== u || c[e + 2] !== d || c[e + 3] !== f || c[e + 4] !== p || c[e + 5] !== m ? (c[e + 0] = a, c[e + 1] = u, c[e + 2] = d, c[e + 3] = f, c[e + 4] = p, c[e + 5] = m, !0) : !1;
1162
+ } else {
1163
+ let r = E(e), i = D(e, o), s = a, l = !1, u = !1;
1164
+ if (t) {
1165
+ if (!s) {
1166
+ let e = r / 8 + n / 32, a = i / 8 + n / 32;
1167
+ l = t.has(e), u = t.has(a), s = !l && !u;
1168
+ }
1169
+ } else l = !0, u = !0;
1170
+ let f = s || l, p = s || u, m = !1;
1171
+ f && (m = d(r, n, s));
1172
+ let h = !1;
1173
+ p && (h = d(i, n, s));
1174
+ let g = m || h;
1175
+ if (g) for (let t = 0; t < 3; t++) {
1176
+ let n = r + t, a = i + t, o = c[n], s = c[n + 3], l = c[a], u = c[a + 3];
1177
+ c[e + t] = o < l ? o : l, c[e + t + 3] = s > u ? s : u;
1178
+ }
1179
+ return g;
1180
+ }
1181
+ }
1182
+ }
1183
+ //#endregion
1184
+ //#region ../../node_modules/three-mesh-bvh/src/core/utils/intersectUtils.js
1185
+ function q(e, t, n, r, i) {
1186
+ let a, o, s, c, l, u, d = 1 / n.direction.x, f = 1 / n.direction.y, p = 1 / n.direction.z, m = n.origin.x, h = n.origin.y, g = n.origin.z, _ = t[e], v = t[e + 3], y = t[e + 1], b = t[e + 3 + 1], x = t[e + 2], S = t[e + 3 + 2];
1187
+ return d >= 0 ? (a = (_ - m) * d, o = (v - m) * d) : (a = (v - m) * d, o = (_ - m) * d), f >= 0 ? (s = (y - h) * f, c = (b - h) * f) : (s = (b - h) * f, c = (y - h) * f), a > c || s > o || ((s > a || isNaN(a)) && (a = s), (c < o || isNaN(o)) && (o = c), p >= 0 ? (l = (x - g) * p, u = (S - g) * p) : (l = (S - g) * p, u = (x - g) * p), a > u || l > o) ? !1 : ((l > a || a !== a) && (a = l), (u < o || o !== o) && (o = u), a <= i && o >= r);
1188
+ }
1189
+ //#endregion
1190
+ //#region ../../node_modules/three-mesh-bvh/src/core/utils/iterationUtils_indirect.generated.js
1191
+ function ht(e, t, n, r, i, a, o, s) {
1192
+ let { geometry: c, _indirectBuffer: l } = e;
1193
+ for (let e = r, u = r + i; e < u; e++) ut(c, t, n, l ? l[e] : e, a, o, s);
1194
+ }
1195
+ function gt(e, t, n, r, i, a, o) {
1196
+ let { geometry: s, _indirectBuffer: c } = e, l = Infinity, u = null;
1197
+ for (let e = r, d = r + i; e < d; e++) {
1198
+ let r;
1199
+ r = ut(s, t, n, c ? c[e] : e, null, a, o), r && r.distance < l && (u = r, l = r.distance);
1200
+ }
1201
+ return u;
1202
+ }
1203
+ function _t(e, t, n, r, i, a, o) {
1204
+ let { geometry: s } = n, { index: c } = s, l = s.attributes.position;
1205
+ for (let s = e, u = t + e; s < u; s++) {
1206
+ let e;
1207
+ if (e = n.resolveTriangleIndex(s), K(o, e * 3, c, l), o.needsUpdate = !0, r(o, e, i, a)) return !0;
1208
+ }
1209
+ return !1;
1210
+ }
1211
+ //#endregion
1212
+ //#region ../../node_modules/three-mesh-bvh/src/core/cast/raycast.generated.js
1213
+ function vt(e, t, n, r, i, a, o) {
1214
+ N.setBuffer(e._roots[t]), yt(0, e, n, r, i, a, o), N.clearBuffer();
1215
+ }
1216
+ function yt(e, t, n, r, i, a, o) {
1217
+ let { float32Array: s, uint16Array: c, uint32Array: l } = N, u = e * 2;
1218
+ if (C(u, c)) dt(t, n, r, w(e, l), T(u, c), i, a, o);
1219
+ else {
1220
+ let c = E(e);
1221
+ q(c, s, r, a, o) && yt(c, t, n, r, i, a, o);
1222
+ let u = D(e, l);
1223
+ q(u, s, r, a, o) && yt(u, t, n, r, i, a, o);
1224
+ }
1225
+ }
1226
+ //#endregion
1227
+ //#region ../../node_modules/three-mesh-bvh/src/core/cast/raycastFirst.generated.js
1228
+ var bt = [
1229
+ "x",
1230
+ "y",
1231
+ "z"
1232
+ ];
1233
+ function xt(e, t, n, r, i, a) {
1234
+ N.setBuffer(e._roots[t]);
1235
+ let o = St(0, e, n, r, i, a);
1236
+ return N.clearBuffer(), o;
1237
+ }
1238
+ function St(e, t, n, r, i, a) {
1239
+ let { float32Array: o, uint16Array: s, uint32Array: c } = N, l = e * 2;
1240
+ if (C(l, s)) return ft(t, n, r, w(e, c), T(l, s), i, a);
1241
+ {
1242
+ let s = O(e, c), l = bt[s], u = r.direction[l] >= 0, d, f;
1243
+ u ? (d = E(e), f = D(e, c)) : (d = D(e, c), f = E(e));
1244
+ let p = q(d, o, r, i, a) ? St(d, t, n, r, i, a) : null;
1245
+ if (p) {
1246
+ let e = p.point[l];
1247
+ if (u ? e <= o[f + s] : e >= o[f + s + 3]) return p;
1248
+ }
1249
+ let m = q(f, o, r, i, a) ? St(f, t, n, r, i, a) : null;
1250
+ return p && m ? p.distance <= m.distance ? p : m : p || m || null;
1251
+ }
1252
+ }
1253
+ //#endregion
1254
+ //#region ../../node_modules/three-mesh-bvh/src/core/cast/intersectsGeometry.generated.js
1255
+ var Ct = /* @__PURE__ */ new o(), wt = /* @__PURE__ */ new B(), Tt = /* @__PURE__ */ new B(), Et = /* @__PURE__ */ new u(), Dt = /* @__PURE__ */ new V(), Ot = /* @__PURE__ */ new V();
1256
+ function kt(e, t, n, r) {
1257
+ N.setBuffer(e._roots[t]);
1258
+ let i = At(0, e, n, r);
1259
+ return N.clearBuffer(), i;
1260
+ }
1261
+ function At(e, t, n, r, i = null) {
1262
+ let { float32Array: a, uint16Array: o, uint32Array: s } = N, c = e * 2;
1263
+ if (i === null && (n.boundingBox || n.computeBoundingBox(), Dt.set(n.boundingBox.min, n.boundingBox.max, r), i = Dt), C(c, o)) {
1264
+ let i = t.geometry, l = i.index, u = i.attributes.position, d = n.index, f = n.attributes.position, p = w(e, s), m = T(c, o);
1265
+ if (Et.copy(r).invert(), n.boundsTree) return _(k(e), a, Ot), Ot.matrix.copy(Et), Ot.needsUpdate = !0, n.boundsTree.shapecast({
1266
+ intersectsBounds: (e) => Ot.intersectsBox(e),
1267
+ intersectsTriangle: (e) => {
1268
+ e.a.applyMatrix4(r), e.b.applyMatrix4(r), e.c.applyMatrix4(r), e.needsUpdate = !0;
1269
+ for (let t = p * 3, n = (m + p) * 3; t < n; t += 3) if (K(Tt, t, l, u), Tt.needsUpdate = !0, e.intersectsTriangle(Tt)) return !0;
1270
+ return !1;
1271
+ }
1272
+ });
1273
+ {
1274
+ let e = Ie(n);
1275
+ for (let t = p * 3, n = (m + p) * 3; t < n; t += 3) {
1276
+ K(wt, t, l, u), wt.a.applyMatrix4(Et), wt.b.applyMatrix4(Et), wt.c.applyMatrix4(Et), wt.needsUpdate = !0;
1277
+ for (let t = 0, n = e * 3; t < n; t += 3) if (K(Tt, t, d, f), Tt.needsUpdate = !0, wt.intersectsTriangle(Tt)) return !0;
1278
+ }
1279
+ }
1280
+ } else {
1281
+ let o = E(e), c = D(e, s);
1282
+ return _(k(o), a, Ct), !!(i.intersectsBox(Ct) && At(o, t, n, r, i) || (_(k(c), a, Ct), i.intersectsBox(Ct) && At(c, t, n, r, i)));
1283
+ }
1284
+ }
1285
+ //#endregion
1286
+ //#region ../../node_modules/three-mesh-bvh/src/core/cast/closestPointToGeometry.generated.js
1287
+ var jt = /* @__PURE__ */ new u(), Mt = /* @__PURE__ */ new V(), Nt = /* @__PURE__ */ new V(), Pt = /* @__PURE__ */ new t(), Ft = /* @__PURE__ */ new t(), It = /* @__PURE__ */ new t(), Lt = /* @__PURE__ */ new t();
1288
+ function Rt(e, t, n, r = {}, i = {}, a = 0, o = Infinity) {
1289
+ t.boundingBox || t.computeBoundingBox(), Mt.set(t.boundingBox.min, t.boundingBox.max, n), Mt.needsUpdate = !0;
1290
+ let s = e.geometry, c = s.attributes.position, l = s.index, u = t.attributes.position, d = t.index, f = H.getPrimitive(), p = H.getPrimitive(), m = Pt, h = Ft, g = null, _ = null;
1291
+ i && (g = It, _ = Lt);
1292
+ let v = Infinity, y = null, b = null;
1293
+ return jt.copy(n).invert(), Nt.matrix.copy(jt), e.shapecast({
1294
+ boundsTraverseOrder: (e) => Mt.distanceToBox(e),
1295
+ intersectsBounds: (e, t, n) => n < v && n < o ? (t && (Nt.min.copy(e.min), Nt.max.copy(e.max), Nt.needsUpdate = !0), !0) : !1,
1296
+ intersectsRange: (e, r) => {
1297
+ if (t.boundsTree) return t.boundsTree.shapecast({
1298
+ boundsTraverseOrder: (e) => Nt.distanceToBox(e),
1299
+ intersectsBounds: (e, t, n) => n < v && n < o,
1300
+ intersectsRange: (t, i) => {
1301
+ for (let o = t, s = t + i; o < s; o++) {
1302
+ K(p, 3 * o, d, u), p.a.applyMatrix4(n), p.b.applyMatrix4(n), p.c.applyMatrix4(n), p.needsUpdate = !0;
1303
+ for (let t = e, n = e + r; t < n; t++) {
1304
+ K(f, 3 * t, l, c), f.needsUpdate = !0;
1305
+ let e = f.distanceToTriangle(p, m, g);
1306
+ if (e < v && (h.copy(m), _ && _.copy(g), v = e, y = t, b = o), e < a) return !0;
1307
+ }
1308
+ }
1309
+ }
1310
+ });
1311
+ {
1312
+ let i = Ie(t);
1313
+ for (let t = 0, o = i; t < o; t++) {
1314
+ K(p, 3 * t, d, u), p.a.applyMatrix4(n), p.b.applyMatrix4(n), p.c.applyMatrix4(n), p.needsUpdate = !0;
1315
+ for (let n = e, i = e + r; n < i; n++) {
1316
+ K(f, 3 * n, l, c), f.needsUpdate = !0;
1317
+ let e = f.distanceToTriangle(p, m, g);
1318
+ if (e < v && (h.copy(m), _ && _.copy(g), v = e, y = n, b = t), e < a) return !0;
1319
+ }
1320
+ }
1321
+ }
1322
+ }
1323
+ }), H.releasePrimitive(f), H.releasePrimitive(p), v === Infinity ? null : (r.point ? r.point.copy(h) : r.point = h.clone(), r.distance = v, r.faceIndex = y, i && (i.point ? i.point.copy(_) : i.point = _.clone(), i.point.applyMatrix4(jt), h.applyMatrix4(jt), i.distance = h.sub(i.point).length(), i.faceIndex = b), r);
1324
+ }
1325
+ //#endregion
1326
+ //#region ../../node_modules/three-mesh-bvh/src/core/cast/refit_indirect.generated.js
1327
+ function zt(e, t = null) {
1328
+ t && Array.isArray(t) && (t = new Set(t));
1329
+ let n = e.geometry, r = n.index ? n.index.array : null, i = n.attributes.position, a, o, s, c, l = 0, u = e._roots;
1330
+ for (let e = 0, t = u.length; e < t; e++) a = u[e], o = new Uint32Array(a), s = new Uint16Array(a), c = new Float32Array(a), d(0, l), l += a.byteLength;
1331
+ function d(n, a, l = !1) {
1332
+ let u = n * 2;
1333
+ if (C(u, s)) {
1334
+ let t = w(n, o), a = T(u, s), l = Infinity, d = Infinity, f = Infinity, p = -Infinity, m = -Infinity, h = -Infinity;
1335
+ for (let n = t, o = t + a; n < o; n++) {
1336
+ let t = 3 * e.resolveTriangleIndex(n);
1337
+ for (let e = 0; e < 3; e++) {
1338
+ let n = t + e;
1339
+ n = r ? r[n] : n;
1340
+ let a = i.getX(n), o = i.getY(n), s = i.getZ(n);
1341
+ a < l && (l = a), a > p && (p = a), o < d && (d = o), o > m && (m = o), s < f && (f = s), s > h && (h = s);
1342
+ }
1343
+ }
1344
+ return c[n + 0] !== l || c[n + 1] !== d || c[n + 2] !== f || c[n + 3] !== p || c[n + 4] !== m || c[n + 5] !== h ? (c[n + 0] = l, c[n + 1] = d, c[n + 2] = f, c[n + 3] = p, c[n + 4] = m, c[n + 5] = h, !0) : !1;
1345
+ } else {
1346
+ let e = E(n), r = D(n, o), i = l, s = !1, u = !1;
1347
+ if (t) {
1348
+ if (!i) {
1349
+ let n = e / 8 + a / 32, o = r / 8 + a / 32;
1350
+ s = t.has(n), u = t.has(o), i = !s && !u;
1351
+ }
1352
+ } else s = !0, u = !0;
1353
+ let f = i || s, p = i || u, m = !1;
1354
+ f && (m = d(e, a, i));
1355
+ let h = !1;
1356
+ p && (h = d(r, a, i));
1357
+ let g = m || h;
1358
+ if (g) for (let t = 0; t < 3; t++) {
1359
+ let i = e + t, a = r + t, o = c[i], s = c[i + 3], l = c[a], u = c[a + 3];
1360
+ c[n + t] = o < l ? o : l, c[n + t + 3] = s > u ? s : u;
1361
+ }
1362
+ return g;
1363
+ }
1364
+ }
1365
+ }
1366
+ //#endregion
1367
+ //#region ../../node_modules/three-mesh-bvh/src/core/cast/raycast_indirect.generated.js
1368
+ function Bt(e, t, n, r, i, a, o) {
1369
+ N.setBuffer(e._roots[t]), Vt(0, e, n, r, i, a, o), N.clearBuffer();
1370
+ }
1371
+ function Vt(e, t, n, r, i, a, o) {
1372
+ let { float32Array: s, uint16Array: c, uint32Array: l } = N, u = e * 2;
1373
+ if (C(u, c)) ht(t, n, r, w(e, l), T(u, c), i, a, o);
1374
+ else {
1375
+ let c = E(e);
1376
+ q(c, s, r, a, o) && Vt(c, t, n, r, i, a, o);
1377
+ let u = D(e, l);
1378
+ q(u, s, r, a, o) && Vt(u, t, n, r, i, a, o);
1379
+ }
1380
+ }
1381
+ //#endregion
1382
+ //#region ../../node_modules/three-mesh-bvh/src/core/cast/raycastFirst_indirect.generated.js
1383
+ var Ht = [
1384
+ "x",
1385
+ "y",
1386
+ "z"
1387
+ ];
1388
+ function Ut(e, t, n, r, i, a) {
1389
+ N.setBuffer(e._roots[t]);
1390
+ let o = Wt(0, e, n, r, i, a);
1391
+ return N.clearBuffer(), o;
1392
+ }
1393
+ function Wt(e, t, n, r, i, a) {
1394
+ let { float32Array: o, uint16Array: s, uint32Array: c } = N, l = e * 2;
1395
+ if (C(l, s)) return gt(t, n, r, w(e, c), T(l, s), i, a);
1396
+ {
1397
+ let s = O(e, c), l = Ht[s], u = r.direction[l] >= 0, d, f;
1398
+ u ? (d = E(e), f = D(e, c)) : (d = D(e, c), f = E(e));
1399
+ let p = q(d, o, r, i, a) ? Wt(d, t, n, r, i, a) : null;
1400
+ if (p) {
1401
+ let e = p.point[l];
1402
+ if (u ? e <= o[f + s] : e >= o[f + s + 3]) return p;
1403
+ }
1404
+ let m = q(f, o, r, i, a) ? Wt(f, t, n, r, i, a) : null;
1405
+ return p && m ? p.distance <= m.distance ? p : m : p || m || null;
1406
+ }
1407
+ }
1408
+ //#endregion
1409
+ //#region ../../node_modules/three-mesh-bvh/src/core/cast/intersectsGeometry_indirect.generated.js
1410
+ var Gt = /* @__PURE__ */ new o(), Kt = /* @__PURE__ */ new B(), qt = /* @__PURE__ */ new B(), Jt = /* @__PURE__ */ new u(), Yt = /* @__PURE__ */ new V(), Xt = /* @__PURE__ */ new V();
1411
+ function Zt(e, t, n, r) {
1412
+ N.setBuffer(e._roots[t]);
1413
+ let i = Qt(0, e, n, r);
1414
+ return N.clearBuffer(), i;
1415
+ }
1416
+ function Qt(e, t, n, r, i = null) {
1417
+ let { float32Array: a, uint16Array: o, uint32Array: s } = N, c = e * 2;
1418
+ if (i === null && (n.boundingBox || n.computeBoundingBox(), Yt.set(n.boundingBox.min, n.boundingBox.max, r), i = Yt), C(c, o)) {
1419
+ let i = t.geometry, l = i.index, u = i.attributes.position, d = n.index, f = n.attributes.position, p = w(e, s), m = T(c, o);
1420
+ if (Jt.copy(r).invert(), n.boundsTree) return _(k(e), a, Xt), Xt.matrix.copy(Jt), Xt.needsUpdate = !0, n.boundsTree.shapecast({
1421
+ intersectsBounds: (e) => Xt.intersectsBox(e),
1422
+ intersectsTriangle: (e) => {
1423
+ e.a.applyMatrix4(r), e.b.applyMatrix4(r), e.c.applyMatrix4(r), e.needsUpdate = !0;
1424
+ for (let n = p, r = m + p; n < r; n++) if (K(qt, 3 * t.resolveTriangleIndex(n), l, u), qt.needsUpdate = !0, e.intersectsTriangle(qt)) return !0;
1425
+ return !1;
1426
+ }
1427
+ });
1428
+ {
1429
+ let e = Ie(n);
1430
+ for (let n = p, r = m + p; n < r; n++) {
1431
+ K(Kt, 3 * t.resolveTriangleIndex(n), l, u), Kt.a.applyMatrix4(Jt), Kt.b.applyMatrix4(Jt), Kt.c.applyMatrix4(Jt), Kt.needsUpdate = !0;
1432
+ for (let t = 0, n = e * 3; t < n; t += 3) if (K(qt, t, d, f), qt.needsUpdate = !0, Kt.intersectsTriangle(qt)) return !0;
1433
+ }
1434
+ }
1435
+ } else {
1436
+ let o = E(e), c = D(e, s);
1437
+ return _(k(o), a, Gt), !!(i.intersectsBox(Gt) && Qt(o, t, n, r, i) || (_(k(c), a, Gt), i.intersectsBox(Gt) && Qt(c, t, n, r, i)));
1438
+ }
1439
+ }
1440
+ //#endregion
1441
+ //#region ../../node_modules/three-mesh-bvh/src/core/cast/closestPointToGeometry_indirect.generated.js
1442
+ var $t = /* @__PURE__ */ new u(), en = /* @__PURE__ */ new V(), tn = /* @__PURE__ */ new V(), nn = /* @__PURE__ */ new t(), rn = /* @__PURE__ */ new t(), an = /* @__PURE__ */ new t(), on = /* @__PURE__ */ new t();
1443
+ function sn(e, t, n, r = {}, i = {}, a = 0, o = Infinity) {
1444
+ t.boundingBox || t.computeBoundingBox(), en.set(t.boundingBox.min, t.boundingBox.max, n), en.needsUpdate = !0;
1445
+ let s = e.geometry, c = s.attributes.position, l = s.index, u = t.attributes.position, d = t.index, f = H.getPrimitive(), p = H.getPrimitive(), m = nn, h = rn, g = null, _ = null;
1446
+ i && (g = an, _ = on);
1447
+ let v = Infinity, y = null, b = null;
1448
+ return $t.copy(n).invert(), tn.matrix.copy($t), e.shapecast({
1449
+ boundsTraverseOrder: (e) => en.distanceToBox(e),
1450
+ intersectsBounds: (e, t, n) => n < v && n < o ? (t && (tn.min.copy(e.min), tn.max.copy(e.max), tn.needsUpdate = !0), !0) : !1,
1451
+ intersectsRange: (r, i) => {
1452
+ if (t.boundsTree) {
1453
+ let s = t.boundsTree;
1454
+ return s.shapecast({
1455
+ boundsTraverseOrder: (e) => tn.distanceToBox(e),
1456
+ intersectsBounds: (e, t, n) => n < v && n < o,
1457
+ intersectsRange: (t, o) => {
1458
+ for (let x = t, S = t + o; x < S; x++) {
1459
+ K(p, 3 * s.resolveTriangleIndex(x), d, u), p.a.applyMatrix4(n), p.b.applyMatrix4(n), p.c.applyMatrix4(n), p.needsUpdate = !0;
1460
+ for (let t = r, n = r + i; t < n; t++) {
1461
+ K(f, 3 * e.resolveTriangleIndex(t), l, c), f.needsUpdate = !0;
1462
+ let n = f.distanceToTriangle(p, m, g);
1463
+ if (n < v && (h.copy(m), _ && _.copy(g), v = n, y = t, b = x), n < a) return !0;
1464
+ }
1465
+ }
1466
+ }
1467
+ });
1468
+ } else {
1469
+ let o = Ie(t);
1470
+ for (let t = 0, s = o; t < s; t++) {
1471
+ K(p, 3 * t, d, u), p.a.applyMatrix4(n), p.b.applyMatrix4(n), p.c.applyMatrix4(n), p.needsUpdate = !0;
1472
+ for (let n = r, o = r + i; n < o; n++) {
1473
+ K(f, 3 * e.resolveTriangleIndex(n), l, c), f.needsUpdate = !0;
1474
+ let r = f.distanceToTriangle(p, m, g);
1475
+ if (r < v && (h.copy(m), _ && _.copy(g), v = r, y = n, b = t), r < a) return !0;
1476
+ }
1477
+ }
1478
+ }
1479
+ }
1480
+ }), H.releasePrimitive(f), H.releasePrimitive(p), v === Infinity ? null : (r.point ? r.point.copy(h) : r.point = h.clone(), r.distance = v, r.faceIndex = y, i && (i.point ? i.point.copy(_) : i.point = _.clone(), i.point.applyMatrix4($t), h.applyMatrix4($t), i.distance = h.sub(i.point).length(), i.faceIndex = b), r);
1481
+ }
1482
+ //#endregion
1483
+ //#region ../../node_modules/three-mesh-bvh/src/utils/GeometryRayIntersectUtilities.js
1484
+ function cn(e, t, n) {
1485
+ return e === null ? null : (e.point.applyMatrix4(t.matrixWorld), e.distance = e.point.distanceTo(n.ray.origin), e.object = t, e);
1486
+ }
1487
+ //#endregion
1488
+ //#region ../../node_modules/three-mesh-bvh/src/core/MeshBVH.js
1489
+ var ln = /* @__PURE__ */ new V(), un = /* @__PURE__ */ new n(), dn = /* @__PURE__ */ new t(), fn = /* @__PURE__ */ new u(), pn = /* @__PURE__ */ new t(), mn = [
1490
+ "getX",
1491
+ "getY",
1492
+ "getZ"
1493
+ ], hn = class e extends Ue {
1494
+ static serialize(e, t = {}) {
1495
+ t = {
1496
+ cloneBuffers: !0,
1497
+ ...t
1498
+ };
1499
+ let n = e.geometry, r = e._roots, i = e._indirectBuffer, a = n.getIndex(), o = {
1500
+ version: 1,
1501
+ roots: null,
1502
+ index: null,
1503
+ indirectBuffer: null
1504
+ };
1505
+ return t.cloneBuffers ? (o.roots = r.map((e) => e.slice()), o.index = a ? a.array.slice() : null, o.indirectBuffer = i ? i.slice() : null) : (o.roots = r, o.index = a ? a.array : null, o.indirectBuffer = i), o;
1506
+ }
1507
+ static deserialize(t, n, r = {}) {
1508
+ r = {
1509
+ setIndex: !0,
1510
+ indirect: !!t.indirectBuffer,
1511
+ ...r
1512
+ };
1513
+ let { index: i, roots: a, indirectBuffer: o } = t;
1514
+ t.version || (console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."), c(a));
1515
+ let s = new e(n, {
1516
+ ...r,
1517
+ [h]: !0
1518
+ });
1519
+ if (s._roots = a, s._indirectBuffer = o || null, r.setIndex) {
1520
+ let e = n.getIndex();
1521
+ if (e === null) {
1522
+ let e = new l(t.index, 1, !1);
1523
+ n.setIndex(e);
1524
+ } else e.array !== i && (e.array.set(i), e.needsUpdate = !0);
1525
+ }
1526
+ return s;
1527
+ function c(e) {
1528
+ for (let t = 0; t < e.length; t++) {
1529
+ let n = e[t], r = new Uint32Array(n), i = new Uint16Array(n);
1530
+ for (let e = 0, t = n.byteLength / 32; e < t; e++) {
1531
+ let t = 8 * e;
1532
+ C(2 * t, i) || (r[t + 6] = r[t + 6] / 8 - e);
1533
+ }
1534
+ }
1535
+ }
1536
+ }
1537
+ get primitiveStride() {
1538
+ return 3;
1539
+ }
1540
+ get resolveTriangleIndex() {
1541
+ return this.resolvePrimitiveIndex;
1542
+ }
1543
+ constructor(e, t = {}) {
1544
+ t.maxLeafTris && (console.warn("MeshBVH: \"maxLeafTris\" option has been deprecated. Use \"targetLeafSize\", instead."), t = {
1545
+ ...t,
1546
+ targetLeafSize: t.maxLeafTris
1547
+ }), super(e, t);
1548
+ }
1549
+ shiftTriangleOffsets(e) {
1550
+ return super.shiftPrimitiveOffsets(e);
1551
+ }
1552
+ writePrimitiveBounds(e, t, n) {
1553
+ let r = this.geometry, i = this._indirectBuffer, a = r.attributes.position, o = r.index ? r.index.array : null, s = (i ? i[e] : e) * 3, c = s + 0, l = s + 1, u = s + 2;
1554
+ o && (c = o[c], l = o[l], u = o[u]);
1555
+ for (let e = 0; e < 3; e++) {
1556
+ let r = a[mn[e]](c), i = a[mn[e]](l), o = a[mn[e]](u), s = r;
1557
+ i < s && (s = i), o < s && (s = o);
1558
+ let d = r;
1559
+ i > d && (d = i), o > d && (d = o), t[n + e] = s, t[n + e + 3] = d;
1560
+ }
1561
+ return t;
1562
+ }
1563
+ computePrimitiveBounds(e, t, n) {
1564
+ let r = this.geometry, i = this._indirectBuffer, a = r.attributes.position, o = r.index ? r.index.array : null, s = a.normalized;
1565
+ if (e < 0 || t + e - n.offset > n.length / 6) throw Error("MeshBVH: compute triangle bounds range is invalid.");
1566
+ let c = a.array, l = a.offset || 0, u = 3;
1567
+ a.isInterleavedBufferAttribute && (u = a.data.stride);
1568
+ let d = [
1569
+ "getX",
1570
+ "getY",
1571
+ "getZ"
1572
+ ], f = n.offset;
1573
+ for (let r = e, p = e + t; r < p; r++) {
1574
+ let e = (i ? i[r] : r) * 3, t = (r - f) * 6, p = e + 0, h = e + 1, g = e + 2;
1575
+ o && (p = o[p], h = o[h], g = o[g]), s || (p = p * u + l, h = h * u + l, g = g * u + l);
1576
+ for (let e = 0; e < 3; e++) {
1577
+ let r, i, o;
1578
+ s ? (r = a[d[e]](p), i = a[d[e]](h), o = a[d[e]](g)) : (r = c[p + e], i = c[h + e], o = c[g + e]);
1579
+ let l = r;
1580
+ i < l && (l = i), o < l && (l = o);
1581
+ let u = r;
1582
+ i > u && (u = i), o > u && (u = o);
1583
+ let f = (u - l) / 2, _ = e * 2;
1584
+ n[t + _ + 0] = l + f, n[t + _ + 1] = f + (Math.abs(l) + f) * m;
1585
+ }
1586
+ }
1587
+ return n;
1588
+ }
1589
+ raycastObject3D(e, t, n = []) {
1590
+ let { material: r } = e;
1591
+ if (r === void 0) return;
1592
+ fn.copy(e.matrixWorld).invert(), un.copy(t.ray).applyMatrix4(fn), pn.setFromMatrixScale(e.matrixWorld), dn.copy(un.direction).multiply(pn);
1593
+ let i = dn.length(), a = t.near / i, o = t.far / i;
1594
+ if (t.firstHitOnly === !0) {
1595
+ let i = this.raycastFirst(un, r, a, o);
1596
+ i = cn(i, e, t), i && n.push(i);
1597
+ } else {
1598
+ let i = this.raycast(un, r, a, o);
1599
+ for (let r = 0, a = i.length; r < a; r++) {
1600
+ let a = cn(i[r], e, t);
1601
+ a && n.push(a);
1602
+ }
1603
+ }
1604
+ return n;
1605
+ }
1606
+ refit(e = null) {
1607
+ return (this.indirect ? zt : mt)(this, e);
1608
+ }
1609
+ raycast(e, t = 0, n = 0, r = Infinity) {
1610
+ let i = this._roots, a = [], o = this.indirect ? Bt : vt;
1611
+ for (let s = 0, c = i.length; s < c; s++) o(this, s, t, e, a, n, r);
1612
+ return a;
1613
+ }
1614
+ raycastFirst(e, t = 0, n = 0, r = Infinity) {
1615
+ let i = this._roots, a = null, o = this.indirect ? Ut : xt;
1616
+ for (let s = 0, c = i.length; s < c; s++) {
1617
+ let i = o(this, s, t, e, n, r);
1618
+ i != null && (a == null || i.distance < a.distance) && (a = i);
1619
+ }
1620
+ return a;
1621
+ }
1622
+ intersectsGeometry(e, t) {
1623
+ let n = !1, r = this._roots, i = this.indirect ? Zt : kt;
1624
+ for (let a = 0, o = r.length; a < o && (n = i(this, a, e, t), !n); a++);
1625
+ return n;
1626
+ }
1627
+ shapecast(e) {
1628
+ let t = H.getPrimitive(), n = super.shapecast({
1629
+ ...e,
1630
+ intersectsPrimitive: e.intersectsTriangle,
1631
+ scratchPrimitive: t,
1632
+ iterate: this.indirect ? _t : pt
1633
+ });
1634
+ return H.releasePrimitive(t), n;
1635
+ }
1636
+ bvhcast(t, n, r) {
1637
+ let { intersectsRanges: i, intersectsTriangles: a } = r, o = H.getPrimitive(), s = this.geometry.index, c = this.geometry.attributes.position, l = this.indirect ? (e) => {
1638
+ K(o, this.resolveTriangleIndex(e) * 3, s, c);
1639
+ } : (e) => {
1640
+ K(o, e * 3, s, c);
1641
+ }, u = H.getPrimitive(), d = t.geometry.index, f = t.geometry.attributes.position, p = t.indirect ? (e) => {
1642
+ K(u, t.resolveTriangleIndex(e) * 3, d, f);
1643
+ } : (e) => {
1644
+ K(u, e * 3, d, f);
1645
+ };
1646
+ if (a) {
1647
+ if (!(t instanceof e)) throw Error("MeshBVH: \"intersectsTriangles\" callback can only be used with another MeshBVH.");
1648
+ let r = (e, t, r, i, s, c, d, f) => {
1649
+ for (let m = r, h = r + i; m < h; m++) {
1650
+ p(m), u.a.applyMatrix4(n), u.b.applyMatrix4(n), u.c.applyMatrix4(n), u.needsUpdate = !0;
1651
+ for (let n = e, r = e + t; n < r; n++) if (l(n), o.needsUpdate = !0, a(o, u, n, m, s, c, d, f)) return !0;
1652
+ }
1653
+ return !1;
1654
+ };
1655
+ if (i) {
1656
+ let e = i;
1657
+ i = function(t, n, i, a, o, s, c, l) {
1658
+ return e(t, n, i, a, o, s, c, l) ? !0 : r(t, n, i, a, o, s, c, l);
1659
+ };
1660
+ } else i = r;
1661
+ }
1662
+ return super.bvhcast(t, n, { intersectsRanges: i });
1663
+ }
1664
+ intersectsBox(e, t) {
1665
+ return ln.set(e.min, e.max, t), ln.needsUpdate = !0, this.shapecast({
1666
+ intersectsBounds: (e) => ln.intersectsBox(e),
1667
+ intersectsTriangle: (e) => ln.intersectsTriangle(e)
1668
+ });
1669
+ }
1670
+ intersectsSphere(e) {
1671
+ return this.shapecast({
1672
+ intersectsBounds: (t) => e.intersectsBox(t),
1673
+ intersectsTriangle: (t) => t.intersectsSphere(e)
1674
+ });
1675
+ }
1676
+ closestPointToGeometry(e, t, n = {}, r = {}, i = 0, a = Infinity) {
1677
+ return (this.indirect ? sn : Rt)(this, e, t, n, r, i, a);
1678
+ }
1679
+ closestPointToPoint(e, t = {}, n = 0, r = Infinity) {
1680
+ return Ze(this, e, t, n, r);
1681
+ }
1682
+ }, J = /* @__PURE__ */ new s(), Y = /* @__PURE__ */ new u(), gn = /* @__PURE__ */ new u(), _n = /* @__PURE__ */ new o(), vn = /* @__PURE__ */ new r(), X = /* @__PURE__ */ new t(), yn = /* @__PURE__ */ new n(), Z = /* @__PURE__ */ new a(), bn = {}, xn = class extends Ne {
1683
+ constructor(e, t = {}) {
1684
+ t = {
1685
+ precise: !1,
1686
+ includeInstances: !0,
1687
+ matrixWorld: Array.isArray(e) ? new u() : e.matrixWorld,
1688
+ targetLeafSize: 1,
1689
+ ...t
1690
+ }, super();
1691
+ let n = /* @__PURE__ */ new Set();
1692
+ wn(e, n);
1693
+ let r = Array.from(n), i = Math.ceil(Math.log2(r.length)), a = (1 << i) - 1;
1694
+ this.objects = r, this.idBits = i, this.idMask = a, this.primitiveBuffer = null, this.primitiveBufferStride = 1, this.precise = t.precise, this.includeInstances = t.includeInstances, this.matrixWorld = t.matrixWorld, this.init(t);
1695
+ }
1696
+ getObjectFromId(e) {
1697
+ let { idMask: t, objects: n } = this;
1698
+ return n[Sn(e, t)];
1699
+ }
1700
+ getInstanceFromId(e) {
1701
+ let { idMask: t, idBits: n } = this;
1702
+ return Cn(e, n, t);
1703
+ }
1704
+ init(e) {
1705
+ let { objects: t, idBits: n, matrixWorld: r } = this;
1706
+ gn.copy(r).invert(), this.primitiveBuffer = new Uint32Array(this._countPrimitives(t)), this._fillPrimitiveBuffer(t, n, this.primitiveBuffer), super.init(e);
1707
+ }
1708
+ refit(...e) {
1709
+ gn.copy(this.matrixWorld).invert(), super.refit(...e);
1710
+ }
1711
+ writePrimitiveBounds(e, t, n) {
1712
+ let { primitiveBuffer: r } = this;
1713
+ this._getPrimitiveBoundingBox(r[e], gn, _n);
1714
+ let { min: i, max: a } = _n;
1715
+ t[n + 0] = i.x, t[n + 1] = i.y, t[n + 2] = i.z, t[n + 3] = a.x, t[n + 4] = a.y, t[n + 5] = a.z;
1716
+ }
1717
+ getRootRanges() {
1718
+ return [{
1719
+ offset: 0,
1720
+ count: this.primitiveBuffer.length
1721
+ }];
1722
+ }
1723
+ shapecast(e) {
1724
+ return super.shapecast({
1725
+ ...e,
1726
+ intersectsPrimitive: e.intersectsObject,
1727
+ scratchPrimitive: null,
1728
+ iterate: En
1729
+ });
1730
+ }
1731
+ raycast(e, t = []) {
1732
+ let { matrixWorld: n, includeInstances: r } = this, { firstHitOnly: i } = e, a = [];
1733
+ gn.copy(n).invert(), yn.copy(e.ray).applyMatrix4(gn);
1734
+ let o = Infinity, s = null;
1735
+ return this.shapecast({
1736
+ boundsTraverseOrder: (e) => e.distanceToPoint(yn.origin),
1737
+ intersectsBounds: (t) => {
1738
+ if (i) {
1739
+ if (!yn.intersectBox(t, X)) return 0;
1740
+ let r;
1741
+ return t.containsPoint(yn.origin) ? r = 0 : (X.applyMatrix4(n), r = e.ray.origin.distanceTo(X)), r < o ? 1 : 0;
1742
+ } else return yn.intersectsBox(t) ? 1 : 0;
1743
+ },
1744
+ intersectsObject(n, c) {
1745
+ if (n.visible) {
1746
+ if (a.length = 0, n.isInstancedMesh && r) Z.geometry = n.geometry, Z.material = n.material, n.getMatrixAt(c, Z.matrixWorld), Z.matrixWorld.premultiply(n.matrixWorld), Z.raycast(e, a), a.forEach((e) => {
1747
+ e.object = n, e.instanceId = c;
1748
+ }), Z.material = null;
1749
+ else if (n.isBatchedMesh && r) {
1750
+ if (!n.getVisibleAt(c)) return;
1751
+ let t = n.getGeometryIdAt(c), r = n.getGeometryRangeAt(t, bn);
1752
+ J.index = n.geometry.index, J.attributes = n.geometry.attributes, J.setDrawRange(r.start, r.count), Z.geometry = J, Z.material = n.material, n.getMatrixAt(c, Z.matrixWorld), Z.matrixWorld.premultiply(n.matrixWorld), Z.raycast(e, a), a.forEach((e) => {
1753
+ e.object = n, e.batchId = c;
1754
+ }), Z.material = null, J.index = null, J.attributes = null, J.setDrawRange(0, Infinity);
1755
+ } else n.raycast(e, a);
1756
+ i ? a.forEach((e) => {
1757
+ e.distance < o && (o = e.distance, s = e);
1758
+ }) : t.push(...a);
1759
+ }
1760
+ }
1761
+ }), i && s && t.push(s), t;
1762
+ }
1763
+ _getPrimitiveBoundingBox(e, t, n) {
1764
+ let { objects: r, idMask: i, idBits: a, precise: o, includeInstances: s } = this, c = Sn(e, i), l = Cn(e, a, i), u = r[c];
1765
+ if (!s && (u.isInstancedMesh || u.isBatchedMesh)) u.boundingBox || u.computeBoundingBox(), u.boundingSphere || u.computeBoundingSphere(), Y.copy(u.matrixWorld).premultiply(t), vn.copy(u.boundingSphere).applyMatrix4(Y), n.copy(u.boundingBox).applyMatrix4(Y), Dn(n, vn);
1766
+ else if (o) if (u.isInstancedMesh) u.getMatrixAt(l, Y), Y.premultiply(u.matrixWorld).premultiply(t), Tn(u.geometry, Y, n);
1767
+ else if (u.isBatchedMesh) {
1768
+ let e = u.getGeometryIdAt(l), r = u.getGeometryRangeAt(e, bn);
1769
+ J.index = u.geometry.index, J.attributes = u.geometry.attributes, J.setDrawRange(r.start, r.count), u.getMatrixAt(l, Y), Y.premultiply(u.matrixWorld).premultiply(t), Tn(J, Y, n), J.attributes = null;
1770
+ } else Y.copy(u.matrixWorld).premultiply(t), n.setFromObject(u, !0).applyMatrix4(t);
1771
+ else if (u.isInstancedMesh) u.geometry.boundingBox || u.geometry.computeBoundingBox(), u.geometry.boundingSphere || u.geometry.computeBoundingSphere(), u.getMatrixAt(l, Y), Y.premultiply(u.matrixWorld).premultiply(t), vn.copy(u.geometry.boundingSphere).applyMatrix4(Y), n.copy(u.geometry.boundingBox).applyMatrix4(Y), Dn(n, vn);
1772
+ else if (u.isBatchedMesh) {
1773
+ let e = u.getGeometryIdAt(l);
1774
+ u.getMatrixAt(l, Y), Y.premultiply(u.matrixWorld).premultiply(t), u.getBoundingSphereAt(e, vn).applyMatrix4(Y), u.getBoundingBoxAt(e, n).applyMatrix4(Y), Dn(n, vn);
1775
+ } else n.setFromObject(u, !1).applyMatrix4(t);
1776
+ }
1777
+ _countPrimitives(e) {
1778
+ let { includeInstances: t } = this, n = 0;
1779
+ return e.forEach((e) => {
1780
+ if (e.isInstancedMesh && t) n += e.count;
1781
+ else if (e.isBatchedMesh && t) {
1782
+ if (!("instanceCount" in e)) throw Error("ObjectBVH: Three.js revision >= r169 is required to use BatchedMesh.");
1783
+ n += e.instanceCount;
1784
+ } else n++;
1785
+ }), n;
1786
+ }
1787
+ _fillPrimitiveBuffer(e, t, n) {
1788
+ let { includeInstances: r } = this, i = 0;
1789
+ e.forEach((e, a) => {
1790
+ if (e.isInstancedMesh && r) {
1791
+ let r = e.count;
1792
+ for (let e = 0; e < r; e++) n[i] = e << t | a, i++;
1793
+ } else if (e.isBatchedMesh && r) {
1794
+ let { instanceCount: r, maxInstanceCount: o } = e, s = 0, c = 0;
1795
+ for (; s < r && c < o;) {
1796
+ try {
1797
+ e.getVisibleAt(c), n[i] = c << t | a, s++, i++;
1798
+ } catch {}
1799
+ c++;
1800
+ }
1801
+ } else n[i] = a, i++;
1802
+ });
1803
+ }
1804
+ };
1805
+ function Sn(e, t) {
1806
+ return e & t;
1807
+ }
1808
+ function Cn(e, t, n) {
1809
+ return (e & ~n) >>> t;
1810
+ }
1811
+ function wn(e, t = /* @__PURE__ */ new Set()) {
1812
+ Array.isArray(e) ? e.forEach((e) => wn(e, t)) : e.traverse((e) => {
1813
+ (e.isMesh || e.isLine || e.isPoints) && t.add(e);
1814
+ });
1815
+ }
1816
+ function Tn(e, t, n) {
1817
+ n.makeEmpty();
1818
+ let r = e.drawRange, i = e.index, a = e.attributes.position, o = r.start, s = i ? i.count : a.count, c = Math.min(s - o, r.count);
1819
+ for (let e = o, r = o + c; e < r; e++) {
1820
+ let r = e;
1821
+ i && (r = i.getX(r)), X.fromBufferAttribute(a, r).applyMatrix4(t), n.expandByPoint(X);
1822
+ }
1823
+ return n;
1824
+ }
1825
+ function En(e, t, n, r, i, a) {
1826
+ let { primitiveBuffer: o, objects: s, idMask: c, idBits: l } = n;
1827
+ for (let n = e, u = t + e; n < u; n++) {
1828
+ let e = o[n], t = Sn(e, c), u = Cn(e, l, c), d = s[t];
1829
+ if (r(d, u, i, a)) return !0;
1830
+ }
1831
+ return !1;
1832
+ }
1833
+ function Dn(e, t) {
1834
+ X.copy(t.center).addScalar(-t.radius), e.min.max(X), X.copy(t.center).addScalar(t.radius), e.max.min(X);
1835
+ }
1836
+ //#endregion
1837
+ //#region ../../node_modules/three-mesh-bvh/src/core/SkinnedMeshBVH.js
1838
+ var On = /* @__PURE__ */ new t(), kn = /* @__PURE__ */ new t(), An = /* @__PURE__ */ new t(), Q = /* @__PURE__ */ new n(), jn = /* @__PURE__ */ new u(), $ = /* @__PURE__ */ new t(), Mn = /* @__PURE__ */ new t(), Nn = [
1839
+ "x",
1840
+ "y",
1841
+ "z"
1842
+ ], Pn = !0, Fn = !1, In = /* @__PURE__ */ new i(), Ln = /* @__PURE__ */ new i(), Rn = /* @__PURE__ */ new i(), zn = /* @__PURE__ */ new t(), Bn = /* @__PURE__ */ new t(), Vn = /* @__PURE__ */ new t(), Hn = class extends Ue {
1843
+ get primitiveStride() {
1844
+ return 3;
1845
+ }
1846
+ constructor(e, t = {}) {
1847
+ if (!e.isMesh) throw Error("SkinnedMeshBVH: First argument must be a Mesh.");
1848
+ super(e.geometry, {
1849
+ ...t,
1850
+ [h]: !0
1851
+ }), this.mesh = e, t[h] || this.init(t);
1852
+ }
1853
+ writePrimitiveBounds(e, t, n) {
1854
+ let { mesh: r, geometry: i } = this, a = this._indirectBuffer, o = i.index ? i.index.array : null, s = (a ? a[e] : e) * 3, c = s + 0, l = s + 1, u = s + 2;
1855
+ o && (c = o[c], l = o[l], u = o[u]), r.getVertexPosition(c, On), r.getVertexPosition(l, kn), r.getVertexPosition(u, An);
1856
+ for (let e = 0; e < 3; e++) {
1857
+ let r = Nn[e], i = On[r], a = kn[r], o = An[r], s = i;
1858
+ a < s && (s = a), o < s && (s = o);
1859
+ let c = i;
1860
+ a > c && (c = a), o > c && (c = o), t[n + e] = s, t[n + e + 3] = c;
1861
+ }
1862
+ return t;
1863
+ }
1864
+ shapecast(e) {
1865
+ let t = new B();
1866
+ return super.shapecast({
1867
+ ...e,
1868
+ intersectsPrimitive: e.intersectsTriangle,
1869
+ scratchPrimitive: t,
1870
+ iterate: Un
1871
+ });
1872
+ }
1873
+ raycastObject3D(e, n, r = []) {
1874
+ let { material: a } = e;
1875
+ if (a === void 0) return;
1876
+ let { matrixWorld: o } = e, { firstHitOnly: s } = n;
1877
+ jn.copy(o).invert(), Q.copy(n.ray).applyMatrix4(jn);
1878
+ let c = null, l = Infinity;
1879
+ return this.shapecast({
1880
+ boundsTraverseOrder: (e) => e.distanceToPoint(Q.origin),
1881
+ intersectsBounds: (e) => {
1882
+ if (s) {
1883
+ if (!Q.intersectBox(e, Mn)) return 0;
1884
+ let t;
1885
+ return e.containsPoint(Q.origin) ? t = 0 : (Mn.applyMatrix4(o), t = n.ray.origin.distanceTo(Mn)), t < l ? 1 : 0;
1886
+ } else return Q.intersectsBox(e) ? 1 : 0;
1887
+ },
1888
+ intersectsTriangle: (u, f) => {
1889
+ let p = null;
1890
+ if (p = a.side === 0 ? Q.intersectTriangle(u.a, u.b, u.c, !0, $) : a.side === 1 ? Q.intersectTriangle(u.c, u.b, u.a, !0, $) : Q.intersectTriangle(u.a, u.b, u.c, !1, $), !p) return;
1891
+ p = p.clone().applyMatrix4(o);
1892
+ let m = n.ray.origin.distanceTo(p);
1893
+ if (m >= n.near && m <= n.far) {
1894
+ if (s && m >= l) return;
1895
+ let { geometry: n } = this, { index: a } = n, o = this.resolvePrimitiveIndex(f), h = o * 3, g = h + 0, _ = h + 1, v = h + 2;
1896
+ a && (g = a.array[g], _ = a.array[_], v = a.array[v]);
1897
+ let y = {
1898
+ distance: m,
1899
+ point: p.clone(),
1900
+ object: e,
1901
+ uv: null,
1902
+ uv1: null,
1903
+ normal: null,
1904
+ face: {
1905
+ a: g,
1906
+ b: _,
1907
+ c: v,
1908
+ normal: d.getNormal(u.a, u.b, u.c, new t()),
1909
+ materialIndex: 0
1910
+ },
1911
+ faceIndex: o
1912
+ };
1913
+ if (Pn) {
1914
+ let e = new t();
1915
+ d.getBarycoord($, u.a, u.b, u.c, e), y.barycoord = e;
1916
+ }
1917
+ let b = n.attributes.uv, x = n.attributes.uv1, S = n.attributes.normal;
1918
+ if (b) {
1919
+ In.fromBufferAttribute(b, g), Ln.fromBufferAttribute(b, _), Rn.fromBufferAttribute(b, v), y.uv = new i();
1920
+ let e = d.getInterpolation($, u.a, u.b, u.c, In, Ln, Rn, y.uv);
1921
+ Pn || (y.uv = e);
1922
+ }
1923
+ if (x) {
1924
+ In.fromBufferAttribute(x, g), Ln.fromBufferAttribute(x, _), Rn.fromBufferAttribute(x, v), y.uv1 = new i();
1925
+ let e = d.getInterpolation($, u.a, u.b, u.c, In, Ln, Rn, y.uv1);
1926
+ Pn || (y.uv1 = e), Fn && (y.uv2 = y.uv1);
1927
+ }
1928
+ if (S) {
1929
+ zn.fromBufferAttribute(S, g), Bn.fromBufferAttribute(S, _), Vn.fromBufferAttribute(S, v), y.normal = new t();
1930
+ let e = d.getInterpolation($, u.a, u.b, u.c, zn, Bn, Vn, y.normal);
1931
+ y.normal.dot(Q.direction) > 0 && y.normal.multiplyScalar(-1), Pn || (y.normal = e);
1932
+ }
1933
+ l = y.distance, c = y, s || r.push(y);
1934
+ }
1935
+ }
1936
+ }), s && c && r.push(c), r;
1937
+ }
1938
+ };
1939
+ function Un(e, t, n, r, i, a, o) {
1940
+ let { mesh: s, geometry: c } = n, l = c.index ? c.index.array : null;
1941
+ for (let c = e, u = t + e; c < u; c++) {
1942
+ let e = n.resolvePrimitiveIndex(c), t = 3 * e + 0, u = 3 * e + 1, d = 3 * e + 2;
1943
+ if (l && (t = l[t], u = l[u], d = l[d]), s.getVertexPosition(t, o.a), s.getVertexPosition(u, o.b), s.getVertexPosition(d, o.c), o.needsUpdate = !0, r(o, c, i, a)) return !0;
1944
+ }
1945
+ return !1;
1946
+ }
1947
+ //#endregion
1948
+ export { B as a, Ne as c, V as i, p as l, xn as n, Ue as o, hn as r, He as s, Hn as t, h as u };
1949
+
1950
+ //# sourceMappingURL=src-HhklrVDg.mjs.map