@thatopen/components 2.0.9 → 2.0.10
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.
- package/dist/core/Clipper/index.d.ts +34 -6
- package/dist/core/Clipper/src/simple-plane.d.ts +40 -4
- package/dist/core/Components/index.d.ts +42 -18
- package/dist/core/Cullers/index.d.ts +23 -27
- package/dist/core/Cullers/src/culler-renderer.d.ts +26 -2
- package/dist/core/Cullers/src/mesh-culler-renderer.d.ts +32 -4
- package/dist/core/Disposer/index.d.ts +6 -4
- package/dist/core/Grids/index.d.ts +35 -1
- package/dist/core/Grids/src/simple-grid.d.ts +3 -0
- package/dist/core/MiniMap/index.d.ts +31 -0
- package/dist/core/MiniMap/src/index.d.ts +55 -0
- package/dist/core/OrthoPerspectiveCamera/index.d.ts +19 -6
- package/dist/core/OrthoPerspectiveCamera/src/first-person-mode.d.ts +1 -2
- package/dist/core/OrthoPerspectiveCamera/src/orbit-mode.d.ts +1 -2
- package/dist/core/OrthoPerspectiveCamera/src/plan-mode.d.ts +1 -2
- package/dist/core/OrthoPerspectiveCamera/src/projections.d.ts +10 -2
- package/dist/core/OrthoPerspectiveCamera/src/types.d.ts +1 -2
- package/dist/core/Raycasters/index.d.ts +29 -0
- package/dist/core/Raycasters/src/simple-raycaster.d.ts +18 -0
- package/dist/core/Types/src/async-event.d.ts +1 -7
- package/dist/core/Types/src/base-camera.d.ts +18 -1
- package/dist/core/Types/src/base-renderer.d.ts +34 -9
- package/dist/core/Types/src/base-scene.d.ts +7 -0
- package/dist/core/Types/src/base-world-item.d.ts +8 -2
- package/dist/core/Types/src/base.d.ts +1 -1
- package/dist/core/Types/src/component.d.ts +1 -6
- package/dist/core/Types/src/event.d.ts +1 -7
- package/dist/core/Types/src/interfaces.d.ts +9 -24
- package/dist/core/Types/src/world.d.ts +21 -0
- package/dist/core/Worlds/index.d.ts +31 -15
- package/dist/core/Worlds/src/simple-camera.d.ts +22 -6
- package/dist/core/Worlds/src/simple-renderer.d.ts +25 -3
- package/dist/core/Worlds/src/simple-scene.d.ts +13 -4
- package/dist/core/Worlds/src/simple-world.d.ts +57 -6
- package/dist/fragments/BoundingBoxer/index.d.ts +1 -2
- package/dist/fragments/FragmentsManager/index.d.ts +22 -2
- package/dist/ifc/IfcRelationsIndexer/index.d.ts +1 -2
- package/dist/index.cjs +5 -5
- package/dist/index.mjs +862 -383
- package/dist/namespace.d.ts +1501 -1000
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var Wn = Object.defineProperty;
|
|
2
2
|
var Xn = (l, s, t) => s in l ? Wn(l, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[s] = t;
|
|
3
3
|
var I = (l, s, t) => (Xn(l, typeof s != "symbol" ? s + "" : s, t), t);
|
|
4
|
-
import * as
|
|
5
|
-
import { BufferAttribute as Ln, Vector3 as w, Vector2 as pe, Plane as Fi, Line3 as Lt, Triangle as Ie, Sphere as Zn, Matrix4 as yt, Box3 as
|
|
4
|
+
import * as O from "three";
|
|
5
|
+
import { BufferAttribute as Ln, Vector3 as w, Vector2 as pe, Plane as Fi, Line3 as Lt, Triangle as Ie, Sphere as Zn, Matrix4 as yt, Box3 as gt, BackSide as Qn, DoubleSide as yn, FrontSide as Di, Mesh as v, Ray as jn, Raycaster as qn, Quaternion as Pt, Object3D as ri, Euler as $n, MeshBasicMaterial as wn, LineBasicMaterial as Kn, CylinderGeometry as ct, BoxGeometry as rt, BufferGeometry as Ui, Float32BufferAttribute as xi, OctahedronGeometry as Qe, Line as Dt, SphereGeometry as Jn, TorusGeometry as Re, PlaneGeometry as to } from "three";
|
|
6
6
|
import * as Vt from "@thatopen/fragments";
|
|
7
7
|
import { Serializer as eo } from "@thatopen/fragments";
|
|
8
8
|
import * as U from "web-ifc";
|
|
@@ -95,8 +95,8 @@ function Gs(l, s, t, e, i = null) {
|
|
|
95
95
|
let o = 1 / 0, n = 1 / 0, r = 1 / 0, a = -1 / 0, c = -1 / 0, h = -1 / 0, d = 1 / 0, E = 1 / 0, u = 1 / 0, p = -1 / 0, A = -1 / 0, m = -1 / 0;
|
|
96
96
|
const C = i !== null;
|
|
97
97
|
for (let R = s * 6, F = (s + t) * 6; R < F; R += 6) {
|
|
98
|
-
const f = l[R + 0], T = l[R + 1],
|
|
99
|
-
|
|
98
|
+
const f = l[R + 0], T = l[R + 1], g = f - T, S = f + T;
|
|
99
|
+
g < o && (o = g), S > a && (a = S), C && f < d && (d = f), C && f > p && (p = f);
|
|
100
100
|
const _ = l[R + 2], N = l[R + 3], L = _ - N, M = _ + N;
|
|
101
101
|
L < n && (n = L), M > c && (c = M), C && _ < E && (E = _), C && _ > A && (A = _);
|
|
102
102
|
const y = l[R + 4], x = l[R + 5], b = y - x, B = y + x;
|
|
@@ -131,10 +131,10 @@ function Eo(l, s) {
|
|
|
131
131
|
n ? (R = t[h[C]](p), F = t[h[C]](A), f = t[h[C]](m)) : (R = r[p + C], F = r[A + C], f = r[m + C]);
|
|
132
132
|
let T = R;
|
|
133
133
|
F < T && (T = F), f < T && (T = f);
|
|
134
|
-
let
|
|
135
|
-
F >
|
|
136
|
-
const S = (
|
|
137
|
-
o[u + _ + 0] = T + S, o[u + _ + 1] = S + (Math.abs(T) + S) * no, T < s[C] && (s[C] = T),
|
|
134
|
+
let g = R;
|
|
135
|
+
F > g && (g = F), f > g && (g = f);
|
|
136
|
+
const S = (g - T) / 2, _ = C * 2;
|
|
137
|
+
o[u + _ + 0] = T + S, o[u + _ + 1] = S + (Math.abs(T) + S) * no, T < s[C] && (s[C] = T), g > s[C + 3] && (s[C + 3] = g);
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
return o;
|
|
@@ -166,13 +166,13 @@ function Io(l, s, t, e, i, o) {
|
|
|
166
166
|
const T = C[R];
|
|
167
167
|
T.candidate = t[f + 2 * E], T.count = 0;
|
|
168
168
|
const {
|
|
169
|
-
bounds:
|
|
169
|
+
bounds: g,
|
|
170
170
|
leftCacheBounds: S,
|
|
171
171
|
rightCacheBounds: _
|
|
172
172
|
} = T;
|
|
173
173
|
for (let N = 0; N < 3; N++)
|
|
174
|
-
_[N] = 1 / 0, _[N + 3] = -1 / 0, S[N] = 1 / 0, S[N + 3] = -1 / 0,
|
|
175
|
-
je(f, t,
|
|
174
|
+
_[N] = 1 / 0, _[N + 3] = -1 / 0, S[N] = 1 / 0, S[N + 3] = -1 / 0, g[N] = 1 / 0, g[N + 3] = -1 / 0;
|
|
175
|
+
je(f, t, g);
|
|
176
176
|
}
|
|
177
177
|
C.sort(uo);
|
|
178
178
|
let F = i;
|
|
@@ -183,18 +183,18 @@ function Io(l, s, t, e, i, o) {
|
|
|
183
183
|
}
|
|
184
184
|
for (let f = h; f < d; f += 6) {
|
|
185
185
|
const T = t[f + 2 * E];
|
|
186
|
-
for (let
|
|
187
|
-
const S = C[
|
|
186
|
+
for (let g = 0; g < F; g++) {
|
|
187
|
+
const S = C[g];
|
|
188
188
|
T >= S.candidate ? je(f, t, S.rightCacheBounds) : (je(f, t, S.leftCacheBounds), S.count++);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
for (let f = 0; f < F; f++) {
|
|
192
|
-
const T = C[f],
|
|
192
|
+
const T = C[f], g = T.count, S = i - T.count, _ = T.leftCacheBounds, N = T.rightCacheBounds;
|
|
193
193
|
let L = 0;
|
|
194
|
-
|
|
194
|
+
g !== 0 && (L = Ae(_) / a);
|
|
195
195
|
let M = 0;
|
|
196
196
|
S !== 0 && (M = Ae(N) / a);
|
|
197
|
-
const y = vi + Ys * (L *
|
|
197
|
+
const y = vi + Ys * (L * g + M * S);
|
|
198
198
|
y < c && (n = E, c = y, r = T.candidate);
|
|
199
199
|
}
|
|
200
200
|
} else {
|
|
@@ -202,13 +202,13 @@ function Io(l, s, t, e, i, o) {
|
|
|
202
202
|
const f = Ut[F];
|
|
203
203
|
f.count = 0, f.candidate = u + m + F * m;
|
|
204
204
|
const T = f.bounds;
|
|
205
|
-
for (let
|
|
206
|
-
T[
|
|
205
|
+
for (let g = 0; g < 3; g++)
|
|
206
|
+
T[g] = 1 / 0, T[g + 3] = -1 / 0;
|
|
207
207
|
}
|
|
208
208
|
for (let F = h; F < d; F += 6) {
|
|
209
|
-
let
|
|
210
|
-
|
|
211
|
-
const S = Ut[
|
|
209
|
+
let g = ~~((t[F + 2 * E] - u) / m);
|
|
210
|
+
g >= wt && (g = wt - 1);
|
|
211
|
+
const S = Ut[g];
|
|
212
212
|
S.count++, je(F, t, S.bounds);
|
|
213
213
|
}
|
|
214
214
|
const C = Ut[wt - 1];
|
|
@@ -219,8 +219,8 @@ function Io(l, s, t, e, i, o) {
|
|
|
219
219
|
}
|
|
220
220
|
let R = 0;
|
|
221
221
|
for (let F = 0; F < wt - 1; F++) {
|
|
222
|
-
const f = Ut[F], T = f.count,
|
|
223
|
-
T !== 0 && (R === 0 ? Yi(
|
|
222
|
+
const f = Ut[F], T = f.count, g = f.bounds, _ = Ut[F + 1].rightCacheBounds;
|
|
223
|
+
T !== 0 && (R === 0 ? Yi(g, qe) : Vi(g, qe, qe)), R += T;
|
|
224
224
|
let N = 0, L = 0;
|
|
225
225
|
R !== 0 && (N = Ae(qe) / a);
|
|
226
226
|
const M = i - R;
|
|
@@ -308,20 +308,20 @@ function mo(l, s) {
|
|
|
308
308
|
function R(f) {
|
|
309
309
|
a && a(f / c);
|
|
310
310
|
}
|
|
311
|
-
function F(f, T,
|
|
312
|
-
if (!d && _ >= i && (d = !0, o && (console.warn(`MeshBVH: Max depth of ${i} reached when generating BVH. Consider increasing maxDepth.`), console.warn(t))),
|
|
313
|
-
return R(T +
|
|
314
|
-
const N = Io(f.boundingData, S, p, T,
|
|
311
|
+
function F(f, T, g, S = null, _ = 0) {
|
|
312
|
+
if (!d && _ >= i && (d = !0, o && (console.warn(`MeshBVH: Max depth of ${i} reached when generating BVH. Consider increasing maxDepth.`), console.warn(t))), g <= n || _ >= i)
|
|
313
|
+
return R(T + g), f.offset = T, f.count = g, f;
|
|
314
|
+
const N = Io(f.boundingData, S, p, T, g, r);
|
|
315
315
|
if (N.axis === -1)
|
|
316
|
-
return R(T +
|
|
317
|
-
const L = A(h, e, p, T,
|
|
318
|
-
if (L === T || L === T +
|
|
319
|
-
R(T +
|
|
316
|
+
return R(T + g), f.offset = T, f.count = g, f;
|
|
317
|
+
const L = A(h, e, p, T, g, N);
|
|
318
|
+
if (L === T || L === T + g)
|
|
319
|
+
R(T + g), f.offset = T, f.count = g;
|
|
320
320
|
else {
|
|
321
321
|
f.splitAxis = N.axis;
|
|
322
322
|
const M = new $e(), y = T, x = L - T;
|
|
323
323
|
f.left = M, M.boundingData = new Float32Array(6), Gs(p, y, x, M.boundingData, u), F(M, y, x, u, _ + 1);
|
|
324
|
-
const b = new $e(), B = L, H =
|
|
324
|
+
const b = new $e(), B = L, H = g - x;
|
|
325
325
|
f.right = b, b.boundingData = new Float32Array(6), Gs(p, B, H, b.boundingData, u), F(b, B, H, u, _ + 1);
|
|
326
326
|
}
|
|
327
327
|
return f;
|
|
@@ -410,7 +410,7 @@ const Ao = function() {
|
|
|
410
410
|
let C, R;
|
|
411
411
|
m !== 0 ? C = (d * E - p * u) / m : C = 0, R = (d + C * E) / u, n.x = C, n.y = R;
|
|
412
412
|
};
|
|
413
|
-
}(),
|
|
413
|
+
}(), gi = function() {
|
|
414
414
|
const l = new pe(), s = new w(), t = new w();
|
|
415
415
|
return function(i, o, n, r) {
|
|
416
416
|
Ao(i, o, l);
|
|
@@ -453,9 +453,9 @@ const Ao = function() {
|
|
|
453
453
|
}
|
|
454
454
|
return !1;
|
|
455
455
|
};
|
|
456
|
-
}(),
|
|
456
|
+
}(), go = 1e-15;
|
|
457
457
|
function zs(l) {
|
|
458
|
-
return Math.abs(l) <
|
|
458
|
+
return Math.abs(l) < go;
|
|
459
459
|
}
|
|
460
460
|
class Ft extends Ie {
|
|
461
461
|
constructor(...s) {
|
|
@@ -482,7 +482,7 @@ Ft.prototype.closestPointToSegment = function() {
|
|
|
482
482
|
let h, d = 1 / 0;
|
|
483
483
|
for (let E = 0; E < 3; E++) {
|
|
484
484
|
const u = (E + 1) % 3;
|
|
485
|
-
t.start.copy(c[E]), t.end.copy(c[u]),
|
|
485
|
+
t.start.copy(c[E]), t.end.copy(c[u]), gi(t, i, l, s), h = l.distanceToSquared(s), h < d && (d = h, o && o.copy(l), n && n.copy(s));
|
|
486
486
|
}
|
|
487
487
|
return this.closestPointToPoint(r, l), h = r.distanceToSquared(l), h < d && (d = h, o && o.copy(l), n && n.copy(r)), this.closestPointToPoint(a, l), h = a.distanceToSquared(l), h < d && (d = h, o && o.copy(l), n && n.copy(a)), Math.sqrt(d);
|
|
488
488
|
};
|
|
@@ -493,15 +493,15 @@ Ft.prototype.intersectsTriangle = function() {
|
|
|
493
493
|
const R = A.points;
|
|
494
494
|
let F = 0, f = -1;
|
|
495
495
|
for (let T = 0; T < 3; T++) {
|
|
496
|
-
const { start:
|
|
497
|
-
|
|
498
|
-
const _ = zs(m.distanceToPoint(
|
|
496
|
+
const { start: g, end: S } = h;
|
|
497
|
+
g.copy(R[T]), S.copy(R[(T + 1) % 3]), h.delta(n);
|
|
498
|
+
const _ = zs(m.distanceToPoint(g));
|
|
499
499
|
if (zs(m.normal.dot(n)) && _) {
|
|
500
500
|
C.copy(h), F = 2;
|
|
501
501
|
break;
|
|
502
502
|
}
|
|
503
503
|
const N = m.intersectLine(h, u);
|
|
504
|
-
if (!N && _ && u.copy(
|
|
504
|
+
if (!N && _ && u.copy(g), (N || _) && !zs(u.distanceTo(S))) {
|
|
505
505
|
if (F <= 1)
|
|
506
506
|
(F === 1 ? C.start : C.end).copy(u), _ && (f = F);
|
|
507
507
|
else if (F >= 2) {
|
|
@@ -518,10 +518,10 @@ Ft.prototype.intersectsTriangle = function() {
|
|
|
518
518
|
this.needsUpdate && this.update(), m.isExtendedTriangle ? m.needsUpdate && m.update() : (l.copy(m), l.update(), m = l);
|
|
519
519
|
const F = this.plane, f = m.plane;
|
|
520
520
|
if (Math.abs(F.normal.dot(f.normal)) > 1 - 1e-10) {
|
|
521
|
-
const T = this.satBounds,
|
|
521
|
+
const T = this.satBounds, g = this.satAxes;
|
|
522
522
|
t[0] = m.a, t[1] = m.b, t[2] = m.c;
|
|
523
523
|
for (let N = 0; N < 4; N++) {
|
|
524
|
-
const L = T[N], M =
|
|
524
|
+
const L = T[N], M = g[N];
|
|
525
525
|
if (e.setFromPoints(M, t), L.isSeparated(e))
|
|
526
526
|
return !1;
|
|
527
527
|
}
|
|
@@ -533,7 +533,7 @@ Ft.prototype.intersectsTriangle = function() {
|
|
|
533
533
|
return !1;
|
|
534
534
|
}
|
|
535
535
|
for (let N = 0; N < 4; N++) {
|
|
536
|
-
const L =
|
|
536
|
+
const L = g[N];
|
|
537
537
|
for (let M = 0; M < 4; M++) {
|
|
538
538
|
const y = _[M];
|
|
539
539
|
if (o.crossVectors(L, y), e.setFromPoints(o, s), i.setFromPoints(o, t), e.isSeparated(i))
|
|
@@ -547,10 +547,10 @@ Ft.prototype.intersectsTriangle = function() {
|
|
|
547
547
|
return C && (C.start.copy(d.end), C.end.copy(d.end)), !0;
|
|
548
548
|
if (T !== 2)
|
|
549
549
|
return !1;
|
|
550
|
-
const
|
|
551
|
-
if (
|
|
550
|
+
const g = p(m, F, E);
|
|
551
|
+
if (g === 1 && this.containsPoint(E.end))
|
|
552
552
|
return C && (C.start.copy(E.end), C.end.copy(E.end)), !0;
|
|
553
|
-
if (
|
|
553
|
+
if (g !== 2)
|
|
554
554
|
return !1;
|
|
555
555
|
if (d.delta(r), E.delta(a), r.dot(a) < 0) {
|
|
556
556
|
let x = E.start;
|
|
@@ -586,7 +586,7 @@ Ft.prototype.distanceToTriangle = function() {
|
|
|
586
586
|
e.set(this[E], this[u]);
|
|
587
587
|
for (let p = 0; p < 3; p++) {
|
|
588
588
|
const A = t[p], m = t[(p + 1) % 3];
|
|
589
|
-
i.set(n[A], n[m]),
|
|
589
|
+
i.set(n[A], n[m]), gi(e, i, l, s);
|
|
590
590
|
const C = l.distanceToSquared(s);
|
|
591
591
|
C < h && (h = C, r && r.copy(l), a && a.copy(s));
|
|
592
592
|
}
|
|
@@ -695,7 +695,7 @@ at.prototype.distanceToBox = function() {
|
|
|
695
695
|
for (let m = 0; m < 3; m++)
|
|
696
696
|
for (let C = 0; C <= 1; C++)
|
|
697
697
|
for (let R = 0; R <= 1; R++) {
|
|
698
|
-
const F = (m + 1) % 3, f = (m + 2) % 3, T = C << F | R << f,
|
|
698
|
+
const F = (m + 1) % 3, f = (m + 2) % 3, T = C << F | R << f, g = 1 << m | C << F | R << f, S = u[T], _ = u[g];
|
|
699
699
|
s[A].set(S, _);
|
|
700
700
|
const L = l[m], M = l[F], y = l[f], x = t[A], b = x.start, B = x.end;
|
|
701
701
|
b[L] = d[L], b[M] = C ? d[M] : E[M], b[y] = R ? d[y] : E[M], B[L] = E[L], B[M] = C ? d[M] : E[M], B[y] = R ? d[y] : E[M], A++;
|
|
@@ -712,7 +712,7 @@ at.prototype.distanceToBox = function() {
|
|
|
712
712
|
const C = s[m];
|
|
713
713
|
for (let R = 0; R < 12; R++) {
|
|
714
714
|
const F = t[R];
|
|
715
|
-
|
|
715
|
+
gi(C, F, e, i);
|
|
716
716
|
const f = e.distanceToSquared(i);
|
|
717
717
|
if (f < p && (p = f, a && a.copy(e), c && c.copy(i), f < h))
|
|
718
718
|
return Math.sqrt(f);
|
|
@@ -721,7 +721,7 @@ at.prototype.distanceToBox = function() {
|
|
|
721
721
|
return Math.sqrt(p);
|
|
722
722
|
};
|
|
723
723
|
}();
|
|
724
|
-
class
|
|
724
|
+
class Oi {
|
|
725
725
|
constructor(s) {
|
|
726
726
|
this._getNewPrimitive = s, this._primitives = [];
|
|
727
727
|
}
|
|
@@ -733,12 +733,12 @@ class gi {
|
|
|
733
733
|
this._primitives.push(s);
|
|
734
734
|
}
|
|
735
735
|
}
|
|
736
|
-
class
|
|
736
|
+
class Oo extends Oi {
|
|
737
737
|
constructor() {
|
|
738
738
|
super(() => new Ft());
|
|
739
739
|
}
|
|
740
740
|
}
|
|
741
|
-
const It = /* @__PURE__ */ new
|
|
741
|
+
const It = /* @__PURE__ */ new Oo();
|
|
742
742
|
function ht(l, s) {
|
|
743
743
|
return s[l + 15] === 65535;
|
|
744
744
|
}
|
|
@@ -771,7 +771,7 @@ class So {
|
|
|
771
771
|
}
|
|
772
772
|
const Z = new So();
|
|
773
773
|
let Yt, fe;
|
|
774
|
-
const te = [], Ke = /* @__PURE__ */ new
|
|
774
|
+
const te = [], Ke = /* @__PURE__ */ new Oi(() => new gt());
|
|
775
775
|
function _o(l, s, t, e, i, o) {
|
|
776
776
|
Yt = Ke.getPrimitive(), fe = Ke.getPrimitive(), te.push(Yt, fe), Z.setBuffer(l._roots[s]);
|
|
777
777
|
const n = ai(0, l.geometry, t, e, i, o);
|
|
@@ -808,12 +808,12 @@ function ai(l, s, t, e, i = null, o = 0, n = 0) {
|
|
|
808
808
|
}
|
|
809
809
|
R || (R = Yt, $(p, r, R));
|
|
810
810
|
const f = ht(p * 2, a), T = t(R, f, m, n + 1, o + p);
|
|
811
|
-
let
|
|
811
|
+
let g;
|
|
812
812
|
if (T === bi) {
|
|
813
813
|
const y = L(p), b = M(p) - y;
|
|
814
|
-
|
|
814
|
+
g = e(y, b, !0, n + 1, o + p, R);
|
|
815
815
|
} else
|
|
816
|
-
|
|
816
|
+
g = T && ai(
|
|
817
817
|
p,
|
|
818
818
|
s,
|
|
819
819
|
t,
|
|
@@ -822,7 +822,7 @@ function ai(l, s, t, e, i = null, o = 0, n = 0) {
|
|
|
822
822
|
o,
|
|
823
823
|
n + 1
|
|
824
824
|
);
|
|
825
|
-
if (
|
|
825
|
+
if (g)
|
|
826
826
|
return !0;
|
|
827
827
|
F = fe, $(A, r, F);
|
|
828
828
|
const S = ht(A * 2, a), _ = t(F, S, C, n + 1, o + A);
|
|
@@ -933,18 +933,18 @@ function Do(l, s = null) {
|
|
|
933
933
|
const A = E * 2;
|
|
934
934
|
if (r[A + 15] === Us) {
|
|
935
935
|
const C = n[E + 6], R = r[A + 14];
|
|
936
|
-
let F = 1 / 0, f = 1 / 0, T = 1 / 0,
|
|
936
|
+
let F = 1 / 0, f = 1 / 0, T = 1 / 0, g = -1 / 0, S = -1 / 0, _ = -1 / 0;
|
|
937
937
|
for (let N = 3 * C, L = 3 * (C + R); N < L; N++) {
|
|
938
938
|
let M = e[N];
|
|
939
939
|
const y = i.getX(M), x = i.getY(M), b = i.getZ(M);
|
|
940
|
-
y < F && (F = y), y >
|
|
940
|
+
y < F && (F = y), y > g && (g = y), x < f && (f = x), x > S && (S = x), b < T && (T = b), b > _ && (_ = b);
|
|
941
941
|
}
|
|
942
|
-
return a[E + 0] !== F || a[E + 1] !== f || a[E + 2] !== T || a[E + 3] !==
|
|
942
|
+
return a[E + 0] !== F || a[E + 1] !== f || a[E + 2] !== T || a[E + 3] !== g || a[E + 4] !== S || a[E + 5] !== _ ? (a[E + 0] = F, a[E + 1] = f, a[E + 2] = T, a[E + 3] = g, a[E + 4] = S, a[E + 5] = _, !0) : !1;
|
|
943
943
|
} else {
|
|
944
944
|
const C = E + 8, R = n[E + 6], F = C + u, f = R + u;
|
|
945
|
-
let T = p,
|
|
946
|
-
s ? T || (
|
|
947
|
-
const _ = T ||
|
|
945
|
+
let T = p, g = !1, S = !1;
|
|
946
|
+
s ? T || (g = s.has(F), S = s.has(f), T = !g && !S) : (g = !0, S = !0);
|
|
947
|
+
const _ = T || g, N = T || S;
|
|
948
948
|
let L = !1;
|
|
949
949
|
_ && (L = d(C, u, T));
|
|
950
950
|
let M = !1;
|
|
@@ -959,7 +959,7 @@ function Do(l, s = null) {
|
|
|
959
959
|
}
|
|
960
960
|
}
|
|
961
961
|
}
|
|
962
|
-
const ki = /* @__PURE__ */ new
|
|
962
|
+
const ki = /* @__PURE__ */ new gt();
|
|
963
963
|
function Gt(l, s, t, e) {
|
|
964
964
|
return $(l, s, ki), t.intersectBox(ki, e);
|
|
965
965
|
}
|
|
@@ -1033,7 +1033,7 @@ function li(l, s, t, e) {
|
|
|
1033
1033
|
return m && R ? m.distance <= R.distance ? m : R : m || R || null;
|
|
1034
1034
|
}
|
|
1035
1035
|
}
|
|
1036
|
-
const is = /* @__PURE__ */ new
|
|
1036
|
+
const is = /* @__PURE__ */ new gt(), ne = /* @__PURE__ */ new Ft(), oe = /* @__PURE__ */ new Ft(), ge = /* @__PURE__ */ new yt(), Zi = /* @__PURE__ */ new at(), ns = /* @__PURE__ */ new at();
|
|
1037
1037
|
function Vo(l, s, t, e) {
|
|
1038
1038
|
Z.setBuffer(l._roots[s]);
|
|
1039
1039
|
const i = hi(0, l, t, e);
|
|
@@ -1044,8 +1044,8 @@ function hi(l, s, t, e, i = null) {
|
|
|
1044
1044
|
let a = l * 2;
|
|
1045
1045
|
if (i === null && (t.boundingBox || t.computeBoundingBox(), Zi.set(t.boundingBox.min, t.boundingBox.max, e), i = Zi), ht(a, n)) {
|
|
1046
1046
|
const h = s.geometry, d = h.index, E = h.attributes.position, u = t.index, p = t.attributes.position, A = Et(l, r), m = ft(a, n);
|
|
1047
|
-
if (
|
|
1048
|
-
return $(l, o, ns), ns.matrix.copy(
|
|
1047
|
+
if (ge.copy(e).invert(), t.boundsTree)
|
|
1048
|
+
return $(l, o, ns), ns.matrix.copy(ge), ns.needsUpdate = !0, t.boundsTree.shapecast({
|
|
1049
1049
|
intersectsBounds: (R) => ns.intersectsBox(R),
|
|
1050
1050
|
intersectsTriangle: (R) => {
|
|
1051
1051
|
R.a.applyMatrix4(e), R.b.applyMatrix4(e), R.c.applyMatrix4(e), R.needsUpdate = !0;
|
|
@@ -1056,7 +1056,7 @@ function hi(l, s, t, e, i = null) {
|
|
|
1056
1056
|
}
|
|
1057
1057
|
});
|
|
1058
1058
|
for (let C = A * 3, R = (m + A) * 3; C < R; C += 3) {
|
|
1059
|
-
et(ne, C, d, E), ne.a.applyMatrix4(
|
|
1059
|
+
et(ne, C, d, E), ne.a.applyMatrix4(ge), ne.b.applyMatrix4(ge), ne.c.applyMatrix4(ge), ne.needsUpdate = !0;
|
|
1060
1060
|
for (let F = 0, f = u.count; F < f; F += 3)
|
|
1061
1061
|
if (et(oe, F, u, p), oe.needsUpdate = !0, ne.intersectsTriangle(oe))
|
|
1062
1062
|
return !0;
|
|
@@ -1066,26 +1066,26 @@ function hi(l, s, t, e, i = null) {
|
|
|
1066
1066
|
return $(h, o, is), !!(i.intersectsBox(is) && hi(h, s, t, e, i) || ($(d, o, is), i.intersectsBox(is) && hi(d, s, t, e, i)));
|
|
1067
1067
|
}
|
|
1068
1068
|
}
|
|
1069
|
-
const os = /* @__PURE__ */ new yt(), ks = /* @__PURE__ */ new at(),
|
|
1069
|
+
const os = /* @__PURE__ */ new yt(), ks = /* @__PURE__ */ new at(), Oe = /* @__PURE__ */ new at(), Go = /* @__PURE__ */ new w(), zo = /* @__PURE__ */ new w(), Ho = /* @__PURE__ */ new w(), ko = /* @__PURE__ */ new w();
|
|
1070
1070
|
function Wo(l, s, t, e = {}, i = {}, o = 0, n = 1 / 0) {
|
|
1071
1071
|
s.boundingBox || s.computeBoundingBox(), ks.set(s.boundingBox.min, s.boundingBox.max, t), ks.needsUpdate = !0;
|
|
1072
1072
|
const r = l.geometry, a = r.attributes.position, c = r.index, h = s.attributes.position, d = s.index, E = It.getPrimitive(), u = It.getPrimitive();
|
|
1073
1073
|
let p = Go, A = zo, m = null, C = null;
|
|
1074
1074
|
i && (m = Ho, C = ko);
|
|
1075
1075
|
let R = 1 / 0, F = null, f = null;
|
|
1076
|
-
return os.copy(t).invert(),
|
|
1076
|
+
return os.copy(t).invert(), Oe.matrix.copy(os), l.shapecast(
|
|
1077
1077
|
{
|
|
1078
1078
|
boundsTraverseOrder: (T) => ks.distanceToBox(T),
|
|
1079
|
-
intersectsBounds: (T,
|
|
1080
|
-
intersectsRange: (T,
|
|
1079
|
+
intersectsBounds: (T, g, S) => S < R && S < n ? (g && (Oe.min.copy(T.min), Oe.max.copy(T.max), Oe.needsUpdate = !0), !0) : !1,
|
|
1080
|
+
intersectsRange: (T, g) => {
|
|
1081
1081
|
if (s.boundsTree)
|
|
1082
1082
|
return s.boundsTree.shapecast({
|
|
1083
|
-
boundsTraverseOrder: (_) =>
|
|
1083
|
+
boundsTraverseOrder: (_) => Oe.distanceToBox(_),
|
|
1084
1084
|
intersectsBounds: (_, N, L) => L < R && L < n,
|
|
1085
1085
|
intersectsRange: (_, N) => {
|
|
1086
1086
|
for (let L = _, M = _ + N; L < M; L++) {
|
|
1087
1087
|
et(u, 3 * L, d, h), u.a.applyMatrix4(t), u.b.applyMatrix4(t), u.c.applyMatrix4(t), u.needsUpdate = !0;
|
|
1088
|
-
for (let y = T, x = T +
|
|
1088
|
+
for (let y = T, x = T + g; y < x; y++) {
|
|
1089
1089
|
et(E, 3 * y, c, a), E.needsUpdate = !0;
|
|
1090
1090
|
const b = E.distanceToTriangle(u, p, m);
|
|
1091
1091
|
if (b < R && (A.copy(p), C && C.copy(m), R = b, F = y, f = L), b < o)
|
|
@@ -1098,7 +1098,7 @@ function Wo(l, s, t, e = {}, i = {}, o = 0, n = 1 / 0) {
|
|
|
1098
1098
|
const S = Ce(s);
|
|
1099
1099
|
for (let _ = 0, N = S; _ < N; _++) {
|
|
1100
1100
|
et(u, 3 * _, d, h), u.a.applyMatrix4(t), u.b.applyMatrix4(t), u.c.applyMatrix4(t), u.needsUpdate = !0;
|
|
1101
|
-
for (let L = T, M = T +
|
|
1101
|
+
for (let L = T, M = T + g; L < M; L++) {
|
|
1102
1102
|
et(E, 3 * L, c, a), E.needsUpdate = !0;
|
|
1103
1103
|
const y = E.distanceToTriangle(u, p, m);
|
|
1104
1104
|
if (y < R && (A.copy(p), C && C.copy(m), R = y, F = L, f = _), y < o)
|
|
@@ -1121,22 +1121,22 @@ function Xo(l, s = null) {
|
|
|
1121
1121
|
const A = E * 2;
|
|
1122
1122
|
if (r[A + 15] === Us) {
|
|
1123
1123
|
const C = n[E + 6], R = r[A + 14];
|
|
1124
|
-
let F = 1 / 0, f = 1 / 0, T = 1 / 0,
|
|
1124
|
+
let F = 1 / 0, f = 1 / 0, T = 1 / 0, g = -1 / 0, S = -1 / 0, _ = -1 / 0;
|
|
1125
1125
|
for (let N = C, L = C + R; N < L; N++) {
|
|
1126
1126
|
const M = 3 * l.resolveTriangleIndex(N);
|
|
1127
1127
|
for (let y = 0; y < 3; y++) {
|
|
1128
1128
|
let x = M + y;
|
|
1129
1129
|
x = e ? e[x] : x;
|
|
1130
1130
|
const b = i.getX(x), B = i.getY(x), H = i.getZ(x);
|
|
1131
|
-
b < F && (F = b), b >
|
|
1131
|
+
b < F && (F = b), b > g && (g = b), B < f && (f = B), B > S && (S = B), H < T && (T = H), H > _ && (_ = H);
|
|
1132
1132
|
}
|
|
1133
1133
|
}
|
|
1134
|
-
return a[E + 0] !== F || a[E + 1] !== f || a[E + 2] !== T || a[E + 3] !==
|
|
1134
|
+
return a[E + 0] !== F || a[E + 1] !== f || a[E + 2] !== T || a[E + 3] !== g || a[E + 4] !== S || a[E + 5] !== _ ? (a[E + 0] = F, a[E + 1] = f, a[E + 2] = T, a[E + 3] = g, a[E + 4] = S, a[E + 5] = _, !0) : !1;
|
|
1135
1135
|
} else {
|
|
1136
1136
|
const C = E + 8, R = n[E + 6], F = C + u, f = R + u;
|
|
1137
|
-
let T = p,
|
|
1138
|
-
s ? T || (
|
|
1139
|
-
const _ = T ||
|
|
1137
|
+
let T = p, g = !1, S = !1;
|
|
1138
|
+
s ? T || (g = s.has(F), S = s.has(f), T = !g && !S) : (g = !0, S = !0);
|
|
1139
|
+
const _ = T || g, N = T || S;
|
|
1140
1140
|
let L = !1;
|
|
1141
1141
|
_ && (L = d(C, u, T));
|
|
1142
1142
|
let M = !1;
|
|
@@ -1196,7 +1196,7 @@ function di(l, s, t, e) {
|
|
|
1196
1196
|
return m && R ? m.distance <= R.distance ? m : R : m || R || null;
|
|
1197
1197
|
}
|
|
1198
1198
|
}
|
|
1199
|
-
const rs = /* @__PURE__ */ new
|
|
1199
|
+
const rs = /* @__PURE__ */ new gt(), re = /* @__PURE__ */ new Ft(), ae = /* @__PURE__ */ new Ft(), Se = /* @__PURE__ */ new yt(), qi = /* @__PURE__ */ new at(), as = /* @__PURE__ */ new at();
|
|
1200
1200
|
function qo(l, s, t, e) {
|
|
1201
1201
|
Z.setBuffer(l._roots[s]);
|
|
1202
1202
|
const i = ui(0, l, t, e);
|
|
@@ -1240,8 +1240,8 @@ function er(l, s, t, e = {}, i = {}, o = 0, n = 1 / 0) {
|
|
|
1240
1240
|
return cs.copy(t).invert(), _e.matrix.copy(cs), l.shapecast(
|
|
1241
1241
|
{
|
|
1242
1242
|
boundsTraverseOrder: (T) => Ws.distanceToBox(T),
|
|
1243
|
-
intersectsBounds: (T,
|
|
1244
|
-
intersectsRange: (T,
|
|
1243
|
+
intersectsBounds: (T, g, S) => S < R && S < n ? (g && (_e.min.copy(T.min), _e.max.copy(T.max), _e.needsUpdate = !0), !0) : !1,
|
|
1244
|
+
intersectsRange: (T, g) => {
|
|
1245
1245
|
if (s.boundsTree) {
|
|
1246
1246
|
const S = s.boundsTree;
|
|
1247
1247
|
return S.shapecast({
|
|
@@ -1251,7 +1251,7 @@ function er(l, s, t, e = {}, i = {}, o = 0, n = 1 / 0) {
|
|
|
1251
1251
|
for (let L = _, M = _ + N; L < M; L++) {
|
|
1252
1252
|
const y = S.resolveTriangleIndex(L);
|
|
1253
1253
|
et(u, 3 * y, d, h), u.a.applyMatrix4(t), u.b.applyMatrix4(t), u.c.applyMatrix4(t), u.needsUpdate = !0;
|
|
1254
|
-
for (let x = T, b = T +
|
|
1254
|
+
for (let x = T, b = T + g; x < b; x++) {
|
|
1255
1255
|
const B = l.resolveTriangleIndex(x);
|
|
1256
1256
|
et(E, 3 * B, c, a), E.needsUpdate = !0;
|
|
1257
1257
|
const H = E.distanceToTriangle(u, p, m);
|
|
@@ -1265,7 +1265,7 @@ function er(l, s, t, e = {}, i = {}, o = 0, n = 1 / 0) {
|
|
|
1265
1265
|
const S = Ce(s);
|
|
1266
1266
|
for (let _ = 0, N = S; _ < N; _++) {
|
|
1267
1267
|
et(u, 3 * _, d, h), u.a.applyMatrix4(t), u.b.applyMatrix4(t), u.c.applyMatrix4(t), u.needsUpdate = !0;
|
|
1268
|
-
for (let L = T, M = T +
|
|
1268
|
+
for (let L = T, M = T + g; L < M; L++) {
|
|
1269
1269
|
const y = l.resolveTriangleIndex(L);
|
|
1270
1270
|
et(E, 3 * y, c, a), E.needsUpdate = !0;
|
|
1271
1271
|
const x = E.distanceToTriangle(u, p, m);
|
|
@@ -1281,7 +1281,7 @@ function er(l, s, t, e = {}, i = {}, o = 0, n = 1 / 0) {
|
|
|
1281
1281
|
function sr() {
|
|
1282
1282
|
return typeof SharedArrayBuffer < "u";
|
|
1283
1283
|
}
|
|
1284
|
-
const be = new Z.constructor(), As = new Z.constructor(), vt = new
|
|
1284
|
+
const be = new Z.constructor(), As = new Z.constructor(), vt = new Oi(() => new gt()), ce = new gt(), le = new gt(), Xs = new gt(), Zs = new gt();
|
|
1285
1285
|
let Qs = !1;
|
|
1286
1286
|
function ir(l, s, t, e) {
|
|
1287
1287
|
if (Qs)
|
|
@@ -1315,9 +1315,9 @@ function ir(l, s, t, e) {
|
|
|
1315
1315
|
function Tt(l, s, t, e, i, o = 0, n = 0, r = 0, a = 0, c = null, h = !1) {
|
|
1316
1316
|
let d, E;
|
|
1317
1317
|
h ? (d = As, E = be) : (d = be, E = As);
|
|
1318
|
-
const u = d.float32Array, p = d.uint32Array, A = d.uint16Array, m = E.float32Array, C = E.uint32Array, R = E.uint16Array, F = l * 2, f = s * 2, T = ht(F, A),
|
|
1318
|
+
const u = d.float32Array, p = d.uint32Array, A = d.uint16Array, m = E.float32Array, C = E.uint32Array, R = E.uint16Array, F = l * 2, f = s * 2, T = ht(F, A), g = ht(f, R);
|
|
1319
1319
|
let S = !1;
|
|
1320
|
-
if (
|
|
1320
|
+
if (g && T)
|
|
1321
1321
|
h ? S = i(
|
|
1322
1322
|
Et(s, C),
|
|
1323
1323
|
ft(s * 2, R),
|
|
@@ -1337,7 +1337,7 @@ function Tt(l, s, t, e, i, o = 0, n = 0, r = 0, a = 0, c = null, h = !1) {
|
|
|
1337
1337
|
a,
|
|
1338
1338
|
n + s
|
|
1339
1339
|
);
|
|
1340
|
-
else if (
|
|
1340
|
+
else if (g) {
|
|
1341
1341
|
const _ = vt.getPrimitive();
|
|
1342
1342
|
$(s, m, _), _.applyMatrix4(t);
|
|
1343
1343
|
const N = pt(l), L = Ct(l, p);
|
|
@@ -1495,7 +1495,7 @@ function Tt(l, s, t, e, i, o = 0, n = 0, r = 0, a = 0, c = null, h = !1) {
|
|
|
1495
1495
|
}
|
|
1496
1496
|
return S;
|
|
1497
1497
|
}
|
|
1498
|
-
const ls = /* @__PURE__ */ new at(), $i = /* @__PURE__ */ new
|
|
1498
|
+
const ls = /* @__PURE__ */ new at(), $i = /* @__PURE__ */ new gt();
|
|
1499
1499
|
class Si {
|
|
1500
1500
|
static serialize(s, t = {}) {
|
|
1501
1501
|
t = {
|
|
@@ -1554,7 +1554,7 @@ class Si {
|
|
|
1554
1554
|
[Vs]: !1
|
|
1555
1555
|
}, t), t.useSharedArrayBuffer && !sr())
|
|
1556
1556
|
throw new Error("MeshBVH: SharedArrayBuffer is not available.");
|
|
1557
|
-
this.geometry = s, this._roots = null, this._indirectBuffer = null, t[Vs] || (Ro(this, t), !s.boundingBox && t.setBoundingBox && (s.boundingBox = this.getBoundingBox(new
|
|
1557
|
+
this.geometry = s, this._roots = null, this._indirectBuffer = null, t[Vs] || (Ro(this, t), !s.boundingBox && t.setBoundingBox && (s.boundingBox = this.getBoundingBox(new gt())));
|
|
1558
1558
|
const { _indirectBuffer: e } = this;
|
|
1559
1559
|
this.resolveTriangleIndex = t.indirect ? (i) => e[i] : (i) => i;
|
|
1560
1560
|
}
|
|
@@ -1645,19 +1645,19 @@ class Si {
|
|
|
1645
1645
|
et(h, p * 3, d, E);
|
|
1646
1646
|
};
|
|
1647
1647
|
if (o) {
|
|
1648
|
-
const p = (A, m, C, R, F, f, T,
|
|
1648
|
+
const p = (A, m, C, R, F, f, T, g) => {
|
|
1649
1649
|
for (let S = C, _ = C + R; S < _; S++) {
|
|
1650
1650
|
u(S), h.a.applyMatrix4(t), h.b.applyMatrix4(t), h.c.applyMatrix4(t), h.needsUpdate = !0;
|
|
1651
1651
|
for (let N = A, L = A + m; N < L; N++)
|
|
1652
|
-
if (c(N), n.needsUpdate = !0, o(n, h, N, S, F, f, T,
|
|
1652
|
+
if (c(N), n.needsUpdate = !0, o(n, h, N, S, F, f, T, g))
|
|
1653
1653
|
return !0;
|
|
1654
1654
|
}
|
|
1655
1655
|
return !1;
|
|
1656
1656
|
};
|
|
1657
1657
|
if (i) {
|
|
1658
1658
|
const A = i;
|
|
1659
|
-
i = function(m, C, R, F, f, T,
|
|
1660
|
-
return A(m, C, R, F, f, T,
|
|
1659
|
+
i = function(m, C, R, F, f, T, g, S) {
|
|
1660
|
+
return A(m, C, R, F, f, T, g, S) ? !0 : p(m, C, R, F, f, T, g, S);
|
|
1661
1661
|
};
|
|
1662
1662
|
} else
|
|
1663
1663
|
i = p;
|
|
@@ -1815,7 +1815,14 @@ class Ni extends _i {
|
|
|
1815
1815
|
constructor(t) {
|
|
1816
1816
|
super(t);
|
|
1817
1817
|
I(this, "worlds", /* @__PURE__ */ new Map());
|
|
1818
|
+
/**
|
|
1819
|
+
* Event that is triggered when a world is added or removed from the `worlds` map.
|
|
1820
|
+
* The event payload contains the world instance and the action ("added" or "removed").
|
|
1821
|
+
*/
|
|
1818
1822
|
I(this, "onWorldChanged", new D());
|
|
1823
|
+
/**
|
|
1824
|
+
* The current world this item is associated with. It can be null if no world is currently active.
|
|
1825
|
+
*/
|
|
1819
1826
|
I(this, "currentWorld", null);
|
|
1820
1827
|
this.onWorldChanged.add(({ world: e, action: i }) => {
|
|
1821
1828
|
i === "removed" && this.worlds.delete(e.uuid);
|
|
@@ -1825,7 +1832,11 @@ class Ni extends _i {
|
|
|
1825
1832
|
class cr extends Ni {
|
|
1826
1833
|
constructor() {
|
|
1827
1834
|
super(...arguments);
|
|
1828
|
-
/**
|
|
1835
|
+
/**
|
|
1836
|
+
* Checks whether the instance is {@link CameraControllable}.
|
|
1837
|
+
*
|
|
1838
|
+
* @returns True if the instance is controllable, false otherwise.
|
|
1839
|
+
*/
|
|
1829
1840
|
I(this, "hasCameraControls", () => "controls" in this);
|
|
1830
1841
|
}
|
|
1831
1842
|
}
|
|
@@ -1838,6 +1849,7 @@ class lr extends Ni {
|
|
|
1838
1849
|
I(this, "onBeforeUpdate", new D());
|
|
1839
1850
|
/** {@link Disposable.onDisposed} */
|
|
1840
1851
|
I(this, "onDisposed", new D());
|
|
1852
|
+
/** {@link Resizeable.onResize} */
|
|
1841
1853
|
I(this, "onResize", new D());
|
|
1842
1854
|
/**
|
|
1843
1855
|
* Event that fires when there has been a change to the list of clipping
|
|
@@ -1845,23 +1857,34 @@ class lr extends Ni {
|
|
|
1845
1857
|
*/
|
|
1846
1858
|
I(this, "onClippingPlanesUpdated", new D());
|
|
1847
1859
|
/**
|
|
1848
|
-
* The list of [clipping planes](https://threejs.org/docs/#api/en/renderers/WebGLRenderer.clippingPlanes) used by this
|
|
1849
|
-
* instance of the renderer.
|
|
1860
|
+
* The list of [clipping planes](https://threejs.org/docs/#api/en/renderers/WebGLRenderer.clippingPlanes) used by this instance of the renderer.
|
|
1850
1861
|
*/
|
|
1851
1862
|
I(this, "clippingPlanes", []);
|
|
1852
1863
|
}
|
|
1853
1864
|
/**
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1865
|
+
* Updates the clipping planes and triggers the `onClippingPlanesUpdated` event.
|
|
1866
|
+
*
|
|
1867
|
+
* @remarks
|
|
1868
|
+
* This method is typically called when there is a change to the list of clipping planes
|
|
1869
|
+
* used by the active renderer.
|
|
1870
|
+
*/
|
|
1857
1871
|
updateClippingPlanes() {
|
|
1858
1872
|
this.onClippingPlanesUpdated.trigger();
|
|
1859
1873
|
}
|
|
1860
1874
|
/**
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1875
|
+
* Sets or removes a clipping plane from the renderer.
|
|
1876
|
+
*
|
|
1877
|
+
* @param active - A boolean indicating whether the clipping plane should be active or not.
|
|
1878
|
+
* @param plane - The clipping plane to be added or removed.
|
|
1879
|
+
* @param isLocal - An optional boolean indicating whether the clipping plane is local to the object. If not provided, it defaults to `false`.
|
|
1880
|
+
*
|
|
1881
|
+
* @remarks
|
|
1882
|
+
* This method adds or removes a clipping plane from the `clippingPlanes` array.
|
|
1883
|
+
* If `active` is `true` and the plane is not already in the array, it is added.
|
|
1884
|
+
* If `active` is `false` and the plane is in the array, it is removed.
|
|
1885
|
+
* The `three.clippingPlanes` property is then updated to reflect the current state of the `clippingPlanes` array,
|
|
1886
|
+
* excluding any planes marked as local.
|
|
1887
|
+
*/
|
|
1865
1888
|
setPlane(t, e, i) {
|
|
1866
1889
|
e.isLocal = i;
|
|
1867
1890
|
const o = this.clippingPlanes.indexOf(e);
|
|
@@ -1879,8 +1902,7 @@ const ve = class ve extends J {
|
|
|
1879
1902
|
t.add(ve.uuid, this);
|
|
1880
1903
|
}
|
|
1881
1904
|
/**
|
|
1882
|
-
*
|
|
1883
|
-
* @return the list of UUIDs of deleted components.
|
|
1905
|
+
* Return the UUIDs of all disposed components.
|
|
1884
1906
|
*/
|
|
1885
1907
|
get() {
|
|
1886
1908
|
return this._disposedComponents;
|
|
@@ -1910,8 +1932,7 @@ const ve = class ve extends J {
|
|
|
1910
1932
|
* to remove.
|
|
1911
1933
|
*/
|
|
1912
1934
|
disposeGeometry(t) {
|
|
1913
|
-
|
|
1914
|
-
e.boundsTree && e.disposeBoundsTree(), t.dispose();
|
|
1935
|
+
t.boundsTree && t.disposeBoundsTree && t.disposeBoundsTree(), t.dispose();
|
|
1915
1936
|
}
|
|
1916
1937
|
disposeGeometryAndMaterials(t, e) {
|
|
1917
1938
|
const i = t;
|
|
@@ -1930,6 +1951,10 @@ const ve = class ve extends J {
|
|
|
1930
1951
|
t.material.dispose();
|
|
1931
1952
|
}
|
|
1932
1953
|
};
|
|
1954
|
+
/**
|
|
1955
|
+
* A unique identifier for the component.
|
|
1956
|
+
* This UUID is used to register the component within the Components system.
|
|
1957
|
+
*/
|
|
1933
1958
|
I(ve, "uuid", "76e9cd8e-ad8f-4753-9ef6-cbc60f7247fe");
|
|
1934
1959
|
let zt = ve;
|
|
1935
1960
|
class hr extends Ni {
|
|
@@ -2338,7 +2363,7 @@ function Tr(l, s) {
|
|
|
2338
2363
|
let t = 0, e = 0;
|
|
2339
2364
|
const i = 10;
|
|
2340
2365
|
s.unitary.identity(), s.diagonal.copy(l);
|
|
2341
|
-
const o = s.unitary, n = s.diagonal, r = new
|
|
2366
|
+
const o = s.unitary, n = s.diagonal, r = new O.Matrix3(), a = new O.Matrix3(), c = Number.EPSILON * fr(n);
|
|
2342
2367
|
for (; e < i && pr(n) > c; )
|
|
2343
2368
|
Cr(n, r), a.copy(r).transpose(), n.multiply(r), n.premultiply(a), o.multiply(r), ++t > 2 && (e++, t = 0);
|
|
2344
2369
|
return s;
|
|
@@ -2347,13 +2372,13 @@ function mr(l) {
|
|
|
2347
2372
|
const s = [];
|
|
2348
2373
|
for (let it = 0; it < l.length - 2; it += 3) {
|
|
2349
2374
|
const Xt = l[it], tt = l[it + 1], Jt = l[it + 2];
|
|
2350
|
-
s.push(new
|
|
2375
|
+
s.push(new O.Vector3(Xt, tt, Jt));
|
|
2351
2376
|
}
|
|
2352
2377
|
const t = new ur();
|
|
2353
2378
|
t.setFromPoints(s);
|
|
2354
2379
|
const e = {
|
|
2355
|
-
unitary: new
|
|
2356
|
-
diagonal: new
|
|
2380
|
+
unitary: new O.Matrix3(),
|
|
2381
|
+
diagonal: new O.Matrix3()
|
|
2357
2382
|
}, i = t.faces, o = [], n = [];
|
|
2358
2383
|
for (let it = 0, Xt = i.length; it < Xt; it++) {
|
|
2359
2384
|
const tt = i[it];
|
|
@@ -2368,7 +2393,7 @@ function mr(l) {
|
|
|
2368
2393
|
n.push(bs.point.x, bs.point.y, bs.point.z), n.push(vs.point.x, vs.point.y, vs.point.z), n.push(Bs.point.x, Bs.point.y, Bs.point.z);
|
|
2369
2394
|
}
|
|
2370
2395
|
}
|
|
2371
|
-
const r = new
|
|
2396
|
+
const r = new O.Vector3(), a = new O.Vector3(), c = new O.Vector3(), h = new O.Vector3(), d = new O.Vector3(), E = new O.Vector3(), u = new O.Vector3(), p = new O.Vector3();
|
|
2372
2397
|
let A = 0, m = 0, C = 0, R = 0, F = 0, f = 0, T = 0;
|
|
2373
2398
|
for (let it = 0, Xt = n.length; it < Xt; it += 9) {
|
|
2374
2399
|
r.fromArray(n, it), a.fromArray(n, it + 3), c.fromArray(n, it + 6), u.set(0, 0, 0), u.add(r).add(a).add(c).divideScalar(3), h.subVectors(a, r), d.subVectors(c, r);
|
|
@@ -2376,9 +2401,9 @@ function mr(l) {
|
|
|
2376
2401
|
p.add(E.copy(u).multiplyScalar(tt)), A += tt, m += (9 * u.x * u.x + r.x * r.x + a.x * a.x + c.x * c.x) * (tt / 12), C += (9 * u.x * u.y + r.x * r.y + a.x * a.y + c.x * c.y) * (tt / 12), R += (9 * u.x * u.z + r.x * r.z + a.x * a.z + c.x * c.z) * (tt / 12), F += (9 * u.y * u.y + r.y * r.y + a.y * a.y + c.y * c.y) * (tt / 12), f += (9 * u.y * u.z + r.y * r.z + a.y * a.z + c.y * c.z) * (tt / 12), T += (9 * u.z * u.z + r.z * r.z + a.z * a.z + c.z * c.z) * (tt / 12);
|
|
2377
2402
|
}
|
|
2378
2403
|
p.divideScalar(A), m /= A, C /= A, R /= A, F /= A, f /= A, T /= A, m -= p.x * p.x, C -= p.x * p.y, R -= p.x * p.z, F -= p.y * p.y, f -= p.y * p.z, T -= p.z * p.z;
|
|
2379
|
-
const
|
|
2380
|
-
|
|
2381
|
-
const S = e.unitary, _ = new
|
|
2404
|
+
const g = new O.Matrix3();
|
|
2405
|
+
g.elements[0] = m, g.elements[1] = C, g.elements[2] = R, g.elements[3] = C, g.elements[4] = F, g.elements[5] = f, g.elements[6] = R, g.elements[7] = f, g.elements[8] = T, Tr(g, e);
|
|
2406
|
+
const S = e.unitary, _ = new O.Vector3(), N = new O.Vector3(), L = new O.Vector3();
|
|
2382
2407
|
S.extractBasis(_, N, L);
|
|
2383
2408
|
let M = -1 / 0, y = -1 / 0, x = -1 / 0, b = 1 / 0, B = 1 / 0, H = 1 / 0;
|
|
2384
2409
|
for (let it = 0, Xt = s.length; it < Xt; it++) {
|
|
@@ -2386,17 +2411,17 @@ function mr(l) {
|
|
|
2386
2411
|
M = Math.max(_.dot(tt), M), y = Math.max(N.dot(tt), y), x = Math.max(L.dot(tt), x), b = Math.min(_.dot(tt), b), B = Math.min(N.dot(tt), B), H = Math.min(L.dot(tt), H);
|
|
2387
2412
|
}
|
|
2388
2413
|
_.multiplyScalar(0.5 * (b + M)), N.multiplyScalar(0.5 * (B + y)), L.multiplyScalar(0.5 * (H + x));
|
|
2389
|
-
const q = new
|
|
2414
|
+
const q = new O.Vector3(), st = new O.Vector3(), Q = new O.Matrix3();
|
|
2390
2415
|
q.add(_).add(N).add(L), st.x = M - b, st.y = y - B, st.z = x - H, st.multiplyScalar(0.5), Q.copy(S);
|
|
2391
|
-
const { x: Ht, y: kt, z: Wt } = st, Xe = new
|
|
2416
|
+
const { x: Ht, y: kt, z: Wt } = st, Xe = new O.Matrix4();
|
|
2392
2417
|
Xe.makeScale(Ht * 2, kt * 2, Wt * 2);
|
|
2393
|
-
const Te = new
|
|
2418
|
+
const Te = new O.Matrix4();
|
|
2394
2419
|
Te.makeTranslation(-Ht, -kt, -Wt);
|
|
2395
|
-
const wi = new
|
|
2420
|
+
const wi = new O.Matrix4();
|
|
2396
2421
|
wi.makeTranslation(q.x, q.y, q.z);
|
|
2397
|
-
const Mi = new
|
|
2422
|
+
const Mi = new O.Matrix4();
|
|
2398
2423
|
Mi.setFromMatrix3(Q);
|
|
2399
|
-
const me = new
|
|
2424
|
+
const me = new O.Matrix4();
|
|
2400
2425
|
return me.multiply(wi), me.multiply(Mi), me.multiply(Te), me.multiply(Xe), { center: q, halfSizes: st, rotation: Q, transformation: me };
|
|
2401
2426
|
}
|
|
2402
2427
|
function Rr(l, s, t) {
|
|
@@ -2737,7 +2762,7 @@ class sa extends J {
|
|
|
2737
2762
|
return n ? (this.workingPlane ? Math.abs(this.workingPlane.distanceToPoint(n)) < 1e-3 : !0) ? ((this._pickedPoint === null || !this._pickedPoint.equals(n)) && (this._pickedPoint = n.clone(), this.onVertexFound.trigger(this._pickedPoint)), this._pickedPoint) : (this._pickedPoint = null, this._pickedPoint) : (this._pickedPoint !== null && (this.onVertexLost.trigger(), this._pickedPoint = null), this._pickedPoint);
|
|
2738
2763
|
}
|
|
2739
2764
|
getClosestVertex(t) {
|
|
2740
|
-
let e = new
|
|
2765
|
+
let e = new O.Vector3(), i = !1, o = Number.MAX_SAFE_INTEGER;
|
|
2741
2766
|
const n = this.getVertices(t);
|
|
2742
2767
|
if (n === null)
|
|
2743
2768
|
return null;
|
|
@@ -2753,7 +2778,7 @@ class sa extends J {
|
|
|
2753
2778
|
const e = t.object;
|
|
2754
2779
|
if (!t.face || !e)
|
|
2755
2780
|
return null;
|
|
2756
|
-
const i = e.geometry, o = new
|
|
2781
|
+
const i = e.geometry, o = new O.Matrix4(), { instanceId: n } = t, r = n !== void 0, a = e instanceof O.InstancedMesh;
|
|
2757
2782
|
return a && r && e.getMatrixAt(n, o), [
|
|
2758
2783
|
this.getVertex(t.face.a, i),
|
|
2759
2784
|
this.getVertex(t.face.b, i),
|
|
@@ -2764,7 +2789,7 @@ class sa extends J {
|
|
|
2764
2789
|
if (t === void 0)
|
|
2765
2790
|
return null;
|
|
2766
2791
|
const i = e.attributes.position;
|
|
2767
|
-
return new
|
|
2792
|
+
return new O.Vector3(
|
|
2768
2793
|
i.getX(t),
|
|
2769
2794
|
i.getY(t),
|
|
2770
2795
|
i.getZ(t)
|
|
@@ -2775,9 +2800,15 @@ const Fs = class Fs {
|
|
|
2775
2800
|
constructor() {
|
|
2776
2801
|
/** {@link Disposable.onDisposed} */
|
|
2777
2802
|
I(this, "onDisposed", new D());
|
|
2778
|
-
/**
|
|
2803
|
+
/**
|
|
2804
|
+
* The list of components created in this app.
|
|
2805
|
+
* The keys are UUIDs and the values are instances of the components.
|
|
2806
|
+
*/
|
|
2779
2807
|
I(this, "list", /* @__PURE__ */ new Map());
|
|
2780
|
-
/**
|
|
2808
|
+
/**
|
|
2809
|
+
* If disabled, the animation loop will be stopped.
|
|
2810
|
+
* Default value is false.
|
|
2811
|
+
*/
|
|
2781
2812
|
I(this, "enabled", !1);
|
|
2782
2813
|
I(this, "_clock");
|
|
2783
2814
|
I(this, "update", () => {
|
|
@@ -2788,21 +2819,39 @@ const Fs = class Fs {
|
|
|
2788
2819
|
e.enabled && e.isUpdateable() && e.update(s);
|
|
2789
2820
|
requestAnimationFrame(this.update);
|
|
2790
2821
|
});
|
|
2791
|
-
this._clock = new
|
|
2822
|
+
this._clock = new O.Clock(), Fs.setupBVH();
|
|
2792
2823
|
}
|
|
2824
|
+
/**
|
|
2825
|
+
* Adds a component to the list of components.
|
|
2826
|
+
* Throws an error if a component with the same UUID already exists.
|
|
2827
|
+
*
|
|
2828
|
+
* @param uuid - The unique identifier of the component.
|
|
2829
|
+
* @param instance - The instance of the component to be added.
|
|
2830
|
+
*
|
|
2831
|
+
* @throws Will throw an error if a component with the same UUID already exists.
|
|
2832
|
+
*
|
|
2833
|
+
* @internal
|
|
2834
|
+
*/
|
|
2793
2835
|
add(s, t) {
|
|
2794
2836
|
if (this.list.has(s))
|
|
2795
2837
|
throw new Error(
|
|
2796
|
-
"You're trying to add a component that already exists in the components
|
|
2838
|
+
"You're trying to add a component that already exists in the components instance. Use Components.get() instead."
|
|
2797
2839
|
);
|
|
2798
2840
|
ze.validate(s), this.list.set(s, t);
|
|
2799
2841
|
}
|
|
2800
2842
|
/**
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2843
|
+
* Retrieves a component instance by its constructor function.
|
|
2844
|
+
* If the component does not exist in the list, it will be created and added.
|
|
2845
|
+
*
|
|
2846
|
+
* @template U - The type of the component to retrieve.
|
|
2847
|
+
* @param Component - The constructor function of the component to retrieve.
|
|
2848
|
+
*
|
|
2849
|
+
* @returns The instance of the requested component.
|
|
2850
|
+
*
|
|
2851
|
+
* @throws Will throw an error if a component with the same UUID already exists.
|
|
2852
|
+
*
|
|
2853
|
+
* @internal
|
|
2854
|
+
*/
|
|
2806
2855
|
get(s) {
|
|
2807
2856
|
const t = s.uuid;
|
|
2808
2857
|
if (!this.list.has(t)) {
|
|
@@ -2812,10 +2861,11 @@ const Fs = class Fs {
|
|
|
2812
2861
|
return this.list.get(t);
|
|
2813
2862
|
}
|
|
2814
2863
|
/**
|
|
2815
|
-
* Initializes the
|
|
2816
|
-
*
|
|
2817
|
-
*
|
|
2818
|
-
*
|
|
2864
|
+
* Initializes the Components instance.
|
|
2865
|
+
* This method starts the animation loop, sets the enabled flag to true,
|
|
2866
|
+
* and calls the update method.
|
|
2867
|
+
*
|
|
2868
|
+
* @returns {void}
|
|
2819
2869
|
*/
|
|
2820
2870
|
init() {
|
|
2821
2871
|
this.enabled = !0, this._clock.start(), this.update();
|
|
@@ -2828,7 +2878,7 @@ const Fs = class Fs {
|
|
|
2828
2878
|
* called. This is especially relevant in Single Page Applications (React,
|
|
2829
2879
|
* Angular, Vue, etc).
|
|
2830
2880
|
*
|
|
2831
|
-
* - Any of the objects of this instance (meshes, geometries, etc) is
|
|
2881
|
+
* - Any of the objects of this instance (meshes, geometries,materials, etc) is
|
|
2832
2882
|
* referenced by a reference type (object or array).
|
|
2833
2883
|
*
|
|
2834
2884
|
* You can learn more about how Three.js handles memory leaks
|
|
@@ -2842,15 +2892,18 @@ const Fs = class Fs {
|
|
|
2842
2892
|
this._clock.stop(), this.onDisposed.trigger(), this.onDisposed.reset();
|
|
2843
2893
|
}
|
|
2844
2894
|
static setupBVH() {
|
|
2845
|
-
|
|
2895
|
+
O.BufferGeometry.prototype.computeBoundsTree = rr, O.BufferGeometry.prototype.disposeBoundsTree = ar, O.Mesh.prototype.raycast = or;
|
|
2846
2896
|
}
|
|
2847
2897
|
};
|
|
2848
|
-
|
|
2898
|
+
/**
|
|
2899
|
+
* The version of the @thatopen/components library.
|
|
2900
|
+
*/
|
|
2901
|
+
I(Fs, "release", "2.0.8");
|
|
2849
2902
|
let pi = Fs;
|
|
2850
2903
|
class Ar {
|
|
2851
2904
|
constructor(s) {
|
|
2852
2905
|
I(this, "_event");
|
|
2853
|
-
I(this, "_position", new
|
|
2906
|
+
I(this, "_position", new O.Vector2());
|
|
2854
2907
|
/** {@link Disposable.onDisposed} */
|
|
2855
2908
|
I(this, "onDisposed", new D());
|
|
2856
2909
|
I(this, "updateMouseInfo", (s) => {
|
|
@@ -2886,12 +2939,21 @@ class Fr {
|
|
|
2886
2939
|
constructor(s, t) {
|
|
2887
2940
|
/** {@link Component.enabled} */
|
|
2888
2941
|
I(this, "enabled", !0);
|
|
2942
|
+
/** The components instance to which this Raycaster belongs. */
|
|
2889
2943
|
I(this, "components");
|
|
2890
2944
|
/** {@link Disposable.onDisposed} */
|
|
2891
2945
|
I(this, "onDisposed", new D());
|
|
2892
2946
|
/** The position of the mouse in the screen. */
|
|
2893
2947
|
I(this, "mouse");
|
|
2894
|
-
|
|
2948
|
+
/**
|
|
2949
|
+
* A reference to the Three.js Raycaster instance.
|
|
2950
|
+
* This is used for raycasting operations.
|
|
2951
|
+
*/
|
|
2952
|
+
I(this, "three", new O.Raycaster());
|
|
2953
|
+
/**
|
|
2954
|
+
* A reference to the world instance to which this Raycaster belongs.
|
|
2955
|
+
* This is used to access the camera and meshes.
|
|
2956
|
+
*/
|
|
2895
2957
|
I(this, "world");
|
|
2896
2958
|
const e = t.renderer;
|
|
2897
2959
|
if (!e)
|
|
@@ -2917,6 +2979,15 @@ class Fr {
|
|
|
2917
2979
|
const t = this.world.camera.three;
|
|
2918
2980
|
return this.three.setFromCamera(this.mouse.position, t), this.intersect(s);
|
|
2919
2981
|
}
|
|
2982
|
+
/**
|
|
2983
|
+
* Casts a ray from a given origin in a given direction and returns the first item found.
|
|
2984
|
+
* This method also takes into account the clipping planes used by the renderer.
|
|
2985
|
+
*
|
|
2986
|
+
* @param origin - The origin of the ray.
|
|
2987
|
+
* @param direction - The direction of the ray.
|
|
2988
|
+
* @param items - The meshes to query. If not provided, it will query all the meshes stored in {@link World.meshes}.
|
|
2989
|
+
* @returns The first intersection found or `null` if no intersection was found.
|
|
2990
|
+
*/
|
|
2920
2991
|
castRayFromVector(s, t, e = Array.from(this.world.meshes)) {
|
|
2921
2992
|
return this.three.set(s, t), this.intersect(e);
|
|
2922
2993
|
}
|
|
@@ -2936,14 +3007,28 @@ class Fr {
|
|
|
2936
3007
|
);
|
|
2937
3008
|
}
|
|
2938
3009
|
}
|
|
2939
|
-
const
|
|
3010
|
+
const gs = class gs extends J {
|
|
2940
3011
|
constructor(t) {
|
|
2941
3012
|
super(t);
|
|
3013
|
+
/** {@link Component.enabled} */
|
|
2942
3014
|
I(this, "enabled", !0);
|
|
3015
|
+
/**
|
|
3016
|
+
* A Map that stores raycasters for each world.
|
|
3017
|
+
* The key is the world's UUID, and the value is the corresponding SimpleRaycaster instance.
|
|
3018
|
+
*/
|
|
2943
3019
|
I(this, "list", /* @__PURE__ */ new Map());
|
|
3020
|
+
/** {@link Disposable.onDisposed} */
|
|
2944
3021
|
I(this, "onDisposed", new D());
|
|
2945
|
-
t.add(
|
|
3022
|
+
t.add(gs.uuid, this);
|
|
2946
3023
|
}
|
|
3024
|
+
/**
|
|
3025
|
+
* Retrieves a SimpleRaycaster instance for the given world.
|
|
3026
|
+
* If a SimpleRaycaster instance already exists for the world, it will be returned.
|
|
3027
|
+
* Otherwise, a new SimpleRaycaster instance will be created and added to the list.
|
|
3028
|
+
*
|
|
3029
|
+
* @param world - The world for which to retrieve or create a SimpleRaycaster instance.
|
|
3030
|
+
* @returns The SimpleRaycaster instance for the given world.
|
|
3031
|
+
*/
|
|
2947
3032
|
get(t) {
|
|
2948
3033
|
if (this.list.has(t.uuid))
|
|
2949
3034
|
return this.list.get(t.uuid);
|
|
@@ -2952,61 +3037,119 @@ const Os = class Os extends J {
|
|
|
2952
3037
|
this.delete(t);
|
|
2953
3038
|
}), e;
|
|
2954
3039
|
}
|
|
3040
|
+
/**
|
|
3041
|
+
* Deletes the SimpleRaycaster instance associated with the given world.
|
|
3042
|
+
* If a SimpleRaycaster instance exists for the given world, it will be disposed and removed from the list.
|
|
3043
|
+
*
|
|
3044
|
+
* @param world - The world for which to delete the SimpleRaycaster instance.
|
|
3045
|
+
* @returns {void}
|
|
3046
|
+
*/
|
|
2955
3047
|
delete(t) {
|
|
2956
3048
|
const e = this.list.get(t.uuid);
|
|
2957
3049
|
e && e.dispose(), this.list.delete(t.uuid);
|
|
2958
3050
|
}
|
|
3051
|
+
/** {@link Disposable.dispose} */
|
|
2959
3052
|
dispose() {
|
|
2960
3053
|
for (const [t, e] of this.list)
|
|
2961
3054
|
e.dispose();
|
|
2962
3055
|
this.list.clear(), this.onDisposed.trigger();
|
|
2963
3056
|
}
|
|
2964
3057
|
};
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
3058
|
+
/**
|
|
3059
|
+
* A unique identifier for the component.
|
|
3060
|
+
* This UUID is used to register the component within the Components system.
|
|
3061
|
+
*/
|
|
3062
|
+
I(gs, "uuid", "d5d8bdf0-db25-4952-b951-b643af207ace");
|
|
3063
|
+
let He = gs;
|
|
3064
|
+
class gr extends _i {
|
|
3065
|
+
constructor() {
|
|
3066
|
+
super(...arguments);
|
|
2970
3067
|
/**
|
|
2971
|
-
* All the loaded [meshes](https://threejs.org/docs/#api/en/objects/Mesh).
|
|
3068
|
+
* All the loaded [meshes](https://threejs.org/docs/#api/en/objects/Mesh). These meshes will be taken into account in operations like raycasting.
|
|
2972
3069
|
*/
|
|
2973
3070
|
I(this, "meshes", /* @__PURE__ */ new Set());
|
|
3071
|
+
/** {@link Updateable.onAfterUpdate} */
|
|
2974
3072
|
I(this, "onAfterUpdate", new D());
|
|
3073
|
+
/** {@link Updateable.onBeforeUpdate} */
|
|
2975
3074
|
I(this, "onBeforeUpdate", new D());
|
|
3075
|
+
/** {@link Disposable.onDisposed} */
|
|
3076
|
+
I(this, "onDisposed", new D());
|
|
3077
|
+
/**
|
|
3078
|
+
* Indicates whether the world is currently being disposed. This is useful to prevent trying to access world's elements when it's being disposed, which could cause errors when you dispose a world.
|
|
3079
|
+
*/
|
|
2976
3080
|
I(this, "isDisposing", !1);
|
|
3081
|
+
/**
|
|
3082
|
+
* Indicates whether the world is currently enabled.
|
|
3083
|
+
* When disabled, the world will not be updated.
|
|
3084
|
+
*/
|
|
2977
3085
|
I(this, "enabled", !0);
|
|
3086
|
+
/**
|
|
3087
|
+
* A unique identifier for the world.
|
|
3088
|
+
*/
|
|
2978
3089
|
I(this, "uuid", ze.create());
|
|
3090
|
+
/**
|
|
3091
|
+
* An optional name for the world.
|
|
3092
|
+
*/
|
|
2979
3093
|
I(this, "name");
|
|
2980
|
-
I(this, "onDisposed", new D());
|
|
2981
3094
|
I(this, "_scene");
|
|
2982
3095
|
I(this, "_camera");
|
|
2983
3096
|
I(this, "_renderer", null);
|
|
2984
3097
|
}
|
|
3098
|
+
/**
|
|
3099
|
+
* Getter for the scene. If no scene is initialized, it throws an error.
|
|
3100
|
+
* @returns The current scene.
|
|
3101
|
+
*/
|
|
2985
3102
|
get scene() {
|
|
2986
3103
|
if (!this._scene)
|
|
2987
3104
|
throw new Error("No scene initialized!");
|
|
2988
3105
|
return this._scene;
|
|
2989
3106
|
}
|
|
3107
|
+
/**
|
|
3108
|
+
* Setter for the scene. It sets the current scene, adds the world to the scene's worlds set,
|
|
3109
|
+
* sets the current world in the scene, and triggers the scene's onWorldChanged event with the added action.
|
|
3110
|
+
* @param scene - The new scene to be set.
|
|
3111
|
+
*/
|
|
2990
3112
|
set scene(t) {
|
|
2991
3113
|
this._scene = t, t.worlds.set(this.uuid, this), t.currentWorld = this, t.onWorldChanged.trigger({ world: this, action: "added" });
|
|
2992
3114
|
}
|
|
3115
|
+
/**
|
|
3116
|
+
* Getter for the camera. If no camera is initialized, it throws an error.
|
|
3117
|
+
* @returns The current camera.
|
|
3118
|
+
*/
|
|
2993
3119
|
get camera() {
|
|
2994
3120
|
if (!this._camera)
|
|
2995
3121
|
throw new Error("No camera initialized!");
|
|
2996
3122
|
return this._camera;
|
|
2997
3123
|
}
|
|
3124
|
+
/**
|
|
3125
|
+
* Setter for the camera. It sets the current camera, adds the world to the camera's worlds set,
|
|
3126
|
+
* sets the current world in the camera, and triggers the camera's onWorldChanged event with the added action.
|
|
3127
|
+
* @param camera - The new camera to be set.
|
|
3128
|
+
*/
|
|
2998
3129
|
set camera(t) {
|
|
2999
3130
|
this._camera = t, t.worlds.set(this.uuid, this), t.currentWorld = this, t.onWorldChanged.trigger({ world: this, action: "added" });
|
|
3000
3131
|
}
|
|
3132
|
+
/**
|
|
3133
|
+
* Getter for the renderer.
|
|
3134
|
+
* @returns The current renderer or null if no renderer is set. Some worlds don't need a renderer to work (when your mail goal is not to display a 3D viewport to the user).
|
|
3135
|
+
*/
|
|
3001
3136
|
get renderer() {
|
|
3002
3137
|
return this._renderer;
|
|
3003
3138
|
}
|
|
3139
|
+
/**
|
|
3140
|
+
* Setter for the renderer. It sets the current renderer, adds the world to the renderer's worlds set,
|
|
3141
|
+
* sets the current world in the renderer, and triggers the renderer's onWorldChanged event with the added action.
|
|
3142
|
+
* If a new renderer is set, it also triggers the onWorldChanged event with the removed action for the old renderer.
|
|
3143
|
+
* @param renderer - The new renderer to be set or null to remove the current renderer.
|
|
3144
|
+
*/
|
|
3004
3145
|
set renderer(t) {
|
|
3005
3146
|
this._renderer = t, t && (t.worlds.set(this.uuid, this), t.currentWorld = this, t.onWorldChanged.trigger({ world: this, action: "added" }));
|
|
3006
3147
|
}
|
|
3148
|
+
/** {@link Updateable.update} */
|
|
3007
3149
|
update(t) {
|
|
3008
3150
|
this.enabled && (!this._scene || !this._camera || (this.scene.currentWorld = this, this.camera.currentWorld = this, this.renderer && (this.renderer.currentWorld = this), this.onBeforeUpdate.trigger(), this.scene.isUpdateable() && this.scene.update(t), this.camera.isUpdateable() && this.camera.update(t), this.renderer && this.renderer.update(t), this.onAfterUpdate.trigger()));
|
|
3009
3151
|
}
|
|
3152
|
+
/** {@link Disposable.dispose} */
|
|
3010
3153
|
dispose(t = !0) {
|
|
3011
3154
|
if (this.enabled = !1, this.isDisposing = !0, this.scene.onWorldChanged.trigger({ world: this, action: "removed" }), this.camera.onWorldChanged.trigger({ world: this, action: "removed" }), this.renderer && this.renderer.onWorldChanged.trigger({ world: this, action: "removed" }), t) {
|
|
3012
3155
|
const e = this.components.get(zt);
|
|
@@ -3023,31 +3166,39 @@ class ia extends hr {
|
|
|
3023
3166
|
super(t);
|
|
3024
3167
|
/** {@link Configurable.isSetup} */
|
|
3025
3168
|
I(this, "isSetup", !1);
|
|
3169
|
+
/**
|
|
3170
|
+
* The underlying Three.js scene object.
|
|
3171
|
+
* It is used to define the 3D space containing objects, lights, and cameras.
|
|
3172
|
+
*/
|
|
3026
3173
|
I(this, "three");
|
|
3027
3174
|
/** {@link Configurable.onSetup} */
|
|
3028
3175
|
I(this, "onSetup", new D());
|
|
3176
|
+
/**
|
|
3177
|
+
* Configuration interface for the {@link SimpleScene}.
|
|
3178
|
+
* Defines properties for directional and ambient lights.
|
|
3179
|
+
*/
|
|
3029
3180
|
I(this, "config", {
|
|
3030
3181
|
directionalLight: {
|
|
3031
|
-
color: new
|
|
3182
|
+
color: new O.Color("white"),
|
|
3032
3183
|
intensity: 1.5,
|
|
3033
|
-
position: new
|
|
3184
|
+
position: new O.Vector3(5, 10, 3)
|
|
3034
3185
|
},
|
|
3035
3186
|
ambientLight: {
|
|
3036
|
-
color: new
|
|
3187
|
+
color: new O.Color("white"),
|
|
3037
3188
|
intensity: 1
|
|
3038
3189
|
}
|
|
3039
3190
|
});
|
|
3040
|
-
this.three = new
|
|
3191
|
+
this.three = new O.Scene(), this.three.background = new O.Color(2107698);
|
|
3041
3192
|
}
|
|
3042
|
-
/**
|
|
3193
|
+
/** {@link Configurable.setup} */
|
|
3043
3194
|
setup(t) {
|
|
3044
3195
|
this.config = { ...this.config, ...t };
|
|
3045
|
-
const e = new
|
|
3196
|
+
const e = new O.DirectionalLight(
|
|
3046
3197
|
this.config.directionalLight.color,
|
|
3047
3198
|
this.config.directionalLight.intensity
|
|
3048
3199
|
);
|
|
3049
3200
|
e.position.copy(this.config.directionalLight.position);
|
|
3050
|
-
const i = new
|
|
3201
|
+
const i = new O.AmbientLight(
|
|
3051
3202
|
this.config.ambientLight.color,
|
|
3052
3203
|
this.config.ambientLight.intensity
|
|
3053
3204
|
);
|
|
@@ -3055,11 +3206,27 @@ class ia extends hr {
|
|
|
3055
3206
|
}
|
|
3056
3207
|
}
|
|
3057
3208
|
class na extends lr {
|
|
3209
|
+
/**
|
|
3210
|
+
* Constructor for the SimpleRenderer class.
|
|
3211
|
+
*
|
|
3212
|
+
* @param components - The components instance.
|
|
3213
|
+
* @param container - The HTML container where the THREE.js canvas will be rendered.
|
|
3214
|
+
* @param parameters - Optional parameters for the THREE.js WebGLRenderer.
|
|
3215
|
+
*/
|
|
3058
3216
|
constructor(t, e, i) {
|
|
3059
3217
|
super(t);
|
|
3218
|
+
/**
|
|
3219
|
+
* Indicates whether the renderer is enabled. If it's not, it won't be updated.
|
|
3220
|
+
* Default is `true`.
|
|
3221
|
+
*/
|
|
3060
3222
|
I(this, "enabled", !0);
|
|
3061
|
-
/**
|
|
3223
|
+
/**
|
|
3224
|
+
* The HTML container of the THREE.js canvas where the scene is rendered.
|
|
3225
|
+
*/
|
|
3062
3226
|
I(this, "container");
|
|
3227
|
+
/**
|
|
3228
|
+
* The THREE.js WebGLRenderer instance.
|
|
3229
|
+
*/
|
|
3063
3230
|
I(this, "three");
|
|
3064
3231
|
I(this, "_canvas");
|
|
3065
3232
|
I(this, "_parameters");
|
|
@@ -3072,7 +3239,7 @@ class na extends lr {
|
|
|
3072
3239
|
return;
|
|
3073
3240
|
this._resizing = !0, this.onContainerUpdated.trigger();
|
|
3074
3241
|
const e = t ? t.x : this.container.clientWidth, i = t ? t.y : this.container.clientHeight;
|
|
3075
|
-
this.three.setSize(e, i), this.onResize.trigger(new
|
|
3242
|
+
this.three.setSize(e, i), this.onResize.trigger(new O.Vector2(e, i)), this._resizing = !1;
|
|
3076
3243
|
});
|
|
3077
3244
|
I(this, "resizeEvent", () => {
|
|
3078
3245
|
this.resize();
|
|
@@ -3081,14 +3248,14 @@ class na extends lr {
|
|
|
3081
3248
|
t.preventDefault(), this.enabled = !1;
|
|
3082
3249
|
});
|
|
3083
3250
|
I(this, "onContextBack", () => {
|
|
3084
|
-
this.three.setRenderTarget(null), this.three.dispose(), this.three = new
|
|
3251
|
+
this.three.setRenderTarget(null), this.three.dispose(), this.three = new O.WebGLRenderer({
|
|
3085
3252
|
canvas: this._canvas,
|
|
3086
3253
|
antialias: !0,
|
|
3087
3254
|
alpha: !0,
|
|
3088
3255
|
...this._parameters
|
|
3089
3256
|
}), this.enabled = !0;
|
|
3090
3257
|
});
|
|
3091
|
-
this.container = e, this._parameters = i, this.three = new
|
|
3258
|
+
this.container = e, this._parameters = i, this.three = new O.WebGLRenderer({
|
|
3092
3259
|
antialias: !0,
|
|
3093
3260
|
alpha: !0,
|
|
3094
3261
|
...i
|
|
@@ -3110,11 +3277,18 @@ class na extends lr {
|
|
|
3110
3277
|
}
|
|
3111
3278
|
/** {@link Resizeable.getSize}. */
|
|
3112
3279
|
getSize() {
|
|
3113
|
-
return new
|
|
3280
|
+
return new O.Vector2(
|
|
3114
3281
|
this.three.domElement.clientWidth,
|
|
3115
3282
|
this.three.domElement.clientHeight
|
|
3116
3283
|
);
|
|
3117
3284
|
}
|
|
3285
|
+
/**
|
|
3286
|
+
* Sets up and manages the event listeners for the renderer.
|
|
3287
|
+
*
|
|
3288
|
+
* @param active - A boolean indicating whether to activate or deactivate the event listeners.
|
|
3289
|
+
*
|
|
3290
|
+
* @throws Will throw an error if the renderer does not have an HTML container.
|
|
3291
|
+
*/
|
|
3118
3292
|
setupEvents(t) {
|
|
3119
3293
|
const e = this.three.domElement.parentElement;
|
|
3120
3294
|
if (!e)
|
|
@@ -3204,8 +3378,8 @@ function an(l, s, t, e, i = 1 / 0, o, n) {
|
|
|
3204
3378
|
u = u / B * F, p = p / B * F, A = A / B * F;
|
|
3205
3379
|
}
|
|
3206
3380
|
h = l.x - u, d = l.y - p, E = l.z - A;
|
|
3207
|
-
const
|
|
3208
|
-
t.x = (t.x - r *
|
|
3381
|
+
const g = (t.x + r * u) * o, S = (t.y + r * p) * o, _ = (t.z + r * A) * o;
|
|
3382
|
+
t.x = (t.x - r * g) * c, t.y = (t.y - r * S) * c, t.z = (t.z - r * _) * c, n.x = h + (u + g) * c, n.y = d + (p + S) * c, n.z = E + (A + _) * c;
|
|
3209
3383
|
const N = m - l.x, L = C - l.y, M = R - l.z, y = n.x - m, x = n.y - C, b = n.z - R;
|
|
3210
3384
|
return N * y + L * x + M * b > 0 && (n.x = m, n.y = C, n.z = R, t.x = (n.x - m) / o, t.y = (n.y - C) / o, t.z = (n.z - R) / o), n;
|
|
3211
3385
|
}
|
|
@@ -3217,7 +3391,7 @@ function Ks(l, s) {
|
|
|
3217
3391
|
function Js(l, s) {
|
|
3218
3392
|
return bt(l) ? (console.warn(`${s} is not supported in OrthographicCamera`), !0) : !1;
|
|
3219
3393
|
}
|
|
3220
|
-
class
|
|
3394
|
+
class Or {
|
|
3221
3395
|
constructor() {
|
|
3222
3396
|
this._listeners = {};
|
|
3223
3397
|
}
|
|
@@ -3282,8 +3456,8 @@ class gr {
|
|
|
3282
3456
|
}
|
|
3283
3457
|
}
|
|
3284
3458
|
const Sr = "2.7.3", ds = 1 / 8, vn = typeof window < "u", _r = vn && /Mac/.test(navigator.platform), Nr = !(vn && "PointerEvent" in window);
|
|
3285
|
-
let Y, cn, us, ti, lt, G, z, de, ye,
|
|
3286
|
-
class ot extends
|
|
3459
|
+
let Y, cn, us, ti, lt, G, z, de, ye, Ot, St, Qt, ln, hn, dt, we, ue, En, ei, dn, si, ii, Is;
|
|
3460
|
+
class ot extends Or {
|
|
3287
3461
|
/**
|
|
3288
3462
|
* Injects THREE as the dependency. You can then proceed to use CameraControls.
|
|
3289
3463
|
*
|
|
@@ -3325,7 +3499,7 @@ class ot extends gr {
|
|
|
3325
3499
|
* @category Statics
|
|
3326
3500
|
*/
|
|
3327
3501
|
static install(s) {
|
|
3328
|
-
Y = s.THREE, cn = Object.freeze(new Y.Vector3(0, 0, 0)), us = Object.freeze(new Y.Vector3(0, 1, 0)), ti = Object.freeze(new Y.Vector3(0, 0, 1)), lt = new Y.Vector2(), G = new Y.Vector3(), z = new Y.Vector3(), de = new Y.Vector3(), ye = new Y.Vector3(),
|
|
3502
|
+
Y = s.THREE, cn = Object.freeze(new Y.Vector3(0, 0, 0)), us = Object.freeze(new Y.Vector3(0, 1, 0)), ti = Object.freeze(new Y.Vector3(0, 0, 1)), lt = new Y.Vector2(), G = new Y.Vector3(), z = new Y.Vector3(), de = new Y.Vector3(), ye = new Y.Vector3(), Ot = new Y.Vector3(), St = new Y.Vector3(), Qt = new Y.Vector3(), ln = new Y.Vector3(), hn = new Y.Vector3(), dt = new Y.Spherical(), we = new Y.Spherical(), ue = new Y.Box3(), En = new Y.Box3(), ei = new Y.Sphere(), dn = new Y.Quaternion(), si = new Y.Quaternion(), ii = new Y.Matrix4(), Is = new Y.Raycaster();
|
|
3329
3503
|
}
|
|
3330
3504
|
/**
|
|
3331
3505
|
* list all ACTIONs
|
|
@@ -3353,7 +3527,7 @@ class ot extends gr {
|
|
|
3353
3527
|
*/
|
|
3354
3528
|
constructor(s, t) {
|
|
3355
3529
|
super(), this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -1 / 0, this.maxAzimuthAngle = 1 / 0, this.minDistance = Number.EPSILON, this.maxDistance = 1 / 0, this.infinityDolly = !1, this.minZoom = 0.01, this.maxZoom = 1 / 0, this.smoothTime = 0.25, this.draggingSmoothTime = 0.125, this.maxSpeed = 1 / 0, this.azimuthRotateSpeed = 1, this.polarRotateSpeed = 1, this.dollySpeed = 1, this.dollyDragInverted = !1, this.truckSpeed = 2, this.dollyToCursor = !1, this.dragToOffset = !1, this.verticalDragToForward = !1, this.boundaryFriction = 0, this.restThreshold = 0.01, this.colliderMeshes = [], this.cancel = () => {
|
|
3356
|
-
}, this._enabled = !0, this._state = P.NONE, this._viewport = null, this._changedDolly = 0, this._changedZoom = 0, this._hasRested = !0, this._boundaryEnclosesCamera = !1, this._needsUpdate = !0, this._updatedLastTime = !1, this._elementRect = new DOMRect(), this._isDragging = !1, this._dragNeedsUpdate = !0, this._activePointers = [], this._lockedPointer = null, this._interactiveArea = new DOMRect(0, 0, 1, 1), this._isUserControllingRotate = !1, this._isUserControllingDolly = !1, this._isUserControllingTruck = !1, this._isUserControllingOffset = !1, this._isUserControllingZoom = !1, this._lastDollyDirection = he.NONE, this._thetaVelocity = { value: 0 }, this._phiVelocity = { value: 0 }, this._radiusVelocity = { value: 0 }, this._targetVelocity = new Y.Vector3(), this._focalOffsetVelocity = new Y.Vector3(), this._zoomVelocity = { value: 0 }, this._truckInternal = (f, T,
|
|
3530
|
+
}, this._enabled = !0, this._state = P.NONE, this._viewport = null, this._changedDolly = 0, this._changedZoom = 0, this._hasRested = !0, this._boundaryEnclosesCamera = !1, this._needsUpdate = !0, this._updatedLastTime = !1, this._elementRect = new DOMRect(), this._isDragging = !1, this._dragNeedsUpdate = !0, this._activePointers = [], this._lockedPointer = null, this._interactiveArea = new DOMRect(0, 0, 1, 1), this._isUserControllingRotate = !1, this._isUserControllingDolly = !1, this._isUserControllingTruck = !1, this._isUserControllingOffset = !1, this._isUserControllingZoom = !1, this._lastDollyDirection = he.NONE, this._thetaVelocity = { value: 0 }, this._phiVelocity = { value: 0 }, this._radiusVelocity = { value: 0 }, this._targetVelocity = new Y.Vector3(), this._focalOffsetVelocity = new Y.Vector3(), this._zoomVelocity = { value: 0 }, this._truckInternal = (f, T, g) => {
|
|
3357
3531
|
let S, _;
|
|
3358
3532
|
if (Zt(this._camera)) {
|
|
3359
3533
|
const N = G.copy(this._camera.position).sub(this._target), L = this._camera.getEffectiveFOV() * Ne, M = N.length() * Math.tan(L * 0.5);
|
|
@@ -3363,16 +3537,16 @@ class ot extends gr {
|
|
|
3363
3537
|
S = f * (N.right - N.left) / N.zoom / this._elementRect.width, _ = T * (N.top - N.bottom) / N.zoom / this._elementRect.height;
|
|
3364
3538
|
} else
|
|
3365
3539
|
return;
|
|
3366
|
-
this.verticalDragToForward ? (
|
|
3540
|
+
this.verticalDragToForward ? (g ? this.setFocalOffset(this._focalOffsetEnd.x + S, this._focalOffsetEnd.y, this._focalOffsetEnd.z, !0) : this.truck(S, 0, !0), this.forward(-_, !0)) : g ? this.setFocalOffset(this._focalOffsetEnd.x + S, this._focalOffsetEnd.y + _, this._focalOffsetEnd.z, !0) : this.truck(S, _, !0);
|
|
3367
3541
|
}, this._rotateInternal = (f, T) => {
|
|
3368
|
-
const
|
|
3369
|
-
this.rotate(
|
|
3370
|
-
}, this._dollyInternal = (f, T,
|
|
3542
|
+
const g = Ee * this.azimuthRotateSpeed * f / this._elementRect.height, S = Ee * this.polarRotateSpeed * T / this._elementRect.height;
|
|
3543
|
+
this.rotate(g, S, !0);
|
|
3544
|
+
}, this._dollyInternal = (f, T, g) => {
|
|
3371
3545
|
const S = Math.pow(0.95, -f * this.dollySpeed), _ = this._sphericalEnd.radius, N = this._sphericalEnd.radius * S, L = mt(N, this.minDistance, this.maxDistance), M = L - N;
|
|
3372
|
-
this.infinityDolly && this.dollyToCursor ? this._dollyToNoClamp(N, !0) : this.infinityDolly && !this.dollyToCursor ? (this.dollyInFixed(M, !0), this._dollyToNoClamp(L, !0)) : this._dollyToNoClamp(L, !0), this.dollyToCursor && (this._changedDolly += (this.infinityDolly ? N : L) - _, this._dollyControlCoord.set(T,
|
|
3373
|
-
}, this._zoomInternal = (f, T,
|
|
3546
|
+
this.infinityDolly && this.dollyToCursor ? this._dollyToNoClamp(N, !0) : this.infinityDolly && !this.dollyToCursor ? (this.dollyInFixed(M, !0), this._dollyToNoClamp(L, !0)) : this._dollyToNoClamp(L, !0), this.dollyToCursor && (this._changedDolly += (this.infinityDolly ? N : L) - _, this._dollyControlCoord.set(T, g)), this._lastDollyDirection = Math.sign(-f);
|
|
3547
|
+
}, this._zoomInternal = (f, T, g) => {
|
|
3374
3548
|
const S = Math.pow(0.95, f * this.dollySpeed), _ = this._zoom, N = this._zoom * S;
|
|
3375
|
-
this.zoomTo(N, !0), this.dollyToCursor && (this._changedZoom += N - _, this._dollyControlCoord.set(T,
|
|
3549
|
+
this.zoomTo(N, !0), this.dollyToCursor && (this._changedZoom += N - _, this._dollyControlCoord.set(T, g));
|
|
3376
3550
|
}, typeof Y > "u" && console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."), this._camera = s, this._yAxisUpSpace = new Y.Quaternion().setFromUnitVectors(this._camera.up, us), this._yAxisUpSpaceInverse = this._yAxisUpSpace.clone().invert(), this._state = P.NONE, this._target = new Y.Vector3(), this._targetEnd = this._target.clone(), this._focalOffset = new Y.Vector3(), this._focalOffsetEnd = this._focalOffset.clone(), this._spherical = new Y.Spherical().setFromVector3(G.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)), this._sphericalEnd = this._spherical.clone(), this._lastDistance = this._spherical.radius, this._zoom = this._camera.zoom, this._zoomEnd = this._zoom, this._lastZoom = this._zoom, this._nearPlaneCorners = [
|
|
3377
3551
|
new Y.Vector3(),
|
|
3378
3552
|
new Y.Vector3(),
|
|
@@ -3403,7 +3577,7 @@ class ot extends gr {
|
|
|
3403
3577
|
}
|
|
3404
3578
|
if ((f.buttons & V.LEFT) === V.LEFT && this._lockedPointer)
|
|
3405
3579
|
return;
|
|
3406
|
-
const
|
|
3580
|
+
const g = {
|
|
3407
3581
|
pointerId: f.pointerId,
|
|
3408
3582
|
clientX: f.clientX,
|
|
3409
3583
|
clientY: f.clientY,
|
|
@@ -3411,7 +3585,7 @@ class ot extends gr {
|
|
|
3411
3585
|
deltaY: 0,
|
|
3412
3586
|
mouseButton: T
|
|
3413
3587
|
};
|
|
3414
|
-
this._activePointers.push(
|
|
3588
|
+
this._activePointers.push(g), this._domElement.ownerDocument.removeEventListener("pointermove", a, { passive: !1 }), this._domElement.ownerDocument.removeEventListener("pointerup", h), this._domElement.ownerDocument.addEventListener("pointermove", a, { passive: !1 }), this._domElement.ownerDocument.addEventListener("pointerup", h), this._isDragging = !0, A(f);
|
|
3415
3589
|
}, r = (f) => {
|
|
3416
3590
|
if (!this._enabled || !this._domElement || this._lockedPointer)
|
|
3417
3591
|
return;
|
|
@@ -3425,7 +3599,7 @@ class ot extends gr {
|
|
|
3425
3599
|
const S = this._findPointerByMouseButton(T);
|
|
3426
3600
|
S && this._disposePointer(S);
|
|
3427
3601
|
}
|
|
3428
|
-
const
|
|
3602
|
+
const g = {
|
|
3429
3603
|
pointerId: 1,
|
|
3430
3604
|
clientX: f.clientX,
|
|
3431
3605
|
clientY: f.clientY,
|
|
@@ -3433,12 +3607,12 @@ class ot extends gr {
|
|
|
3433
3607
|
deltaY: 0,
|
|
3434
3608
|
mouseButton: (f.buttons & V.LEFT) === V.LEFT ? V.LEFT : (f.buttons & V.MIDDLE) === V.LEFT ? V.MIDDLE : (f.buttons & V.RIGHT) === V.LEFT ? V.RIGHT : null
|
|
3435
3609
|
};
|
|
3436
|
-
this._activePointers.push(
|
|
3610
|
+
this._activePointers.push(g), this._domElement.ownerDocument.removeEventListener("mousemove", c), this._domElement.ownerDocument.removeEventListener("mouseup", d), this._domElement.ownerDocument.addEventListener("mousemove", c), this._domElement.ownerDocument.addEventListener("mouseup", d), this._isDragging = !0, A(f);
|
|
3437
3611
|
}, a = (f) => {
|
|
3438
3612
|
f.cancelable && f.preventDefault();
|
|
3439
|
-
const T = f.pointerId,
|
|
3440
|
-
if (
|
|
3441
|
-
if (
|
|
3613
|
+
const T = f.pointerId, g = this._lockedPointer || this._findPointerById(T);
|
|
3614
|
+
if (g) {
|
|
3615
|
+
if (g.clientX = f.clientX, g.clientY = f.clientY, g.deltaX = f.movementX, g.deltaY = f.movementY, this._state = 0, f.pointerType === "touch")
|
|
3442
3616
|
switch (this._activePointers.length) {
|
|
3443
3617
|
case 1:
|
|
3444
3618
|
this._state = this.touches.one;
|
|
@@ -3496,7 +3670,7 @@ class ot extends gr {
|
|
|
3496
3670
|
const N = performance.now();
|
|
3497
3671
|
E - N < 1e3 && this._getClientRect(this._elementRect), E = N;
|
|
3498
3672
|
}
|
|
3499
|
-
const T = _r ? -1 : -3,
|
|
3673
|
+
const T = _r ? -1 : -3, g = f.deltaMode === 1 ? f.deltaY / T : f.deltaY / (T * 10), S = this.dollyToCursor ? (f.clientX - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0, _ = this.dollyToCursor ? (f.clientY - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0;
|
|
3500
3674
|
switch (this.mouseButtons.wheel) {
|
|
3501
3675
|
case P.ROTATE: {
|
|
3502
3676
|
this._rotateInternal(f.deltaX, f.deltaY), this._isUserControllingRotate = !0;
|
|
@@ -3511,11 +3685,11 @@ class ot extends gr {
|
|
|
3511
3685
|
break;
|
|
3512
3686
|
}
|
|
3513
3687
|
case P.DOLLY: {
|
|
3514
|
-
this._dollyInternal(-
|
|
3688
|
+
this._dollyInternal(-g, S, _), this._isUserControllingDolly = !0;
|
|
3515
3689
|
break;
|
|
3516
3690
|
}
|
|
3517
3691
|
case P.ZOOM: {
|
|
3518
|
-
this._zoomInternal(-
|
|
3692
|
+
this._zoomInternal(-g, S, _), this._isUserControllingZoom = !0;
|
|
3519
3693
|
break;
|
|
3520
3694
|
}
|
|
3521
3695
|
}
|
|
@@ -3523,8 +3697,8 @@ class ot extends gr {
|
|
|
3523
3697
|
}, p = (f) => {
|
|
3524
3698
|
if (!(!this._domElement || !this._enabled)) {
|
|
3525
3699
|
if (this.mouseButtons.right === ot.ACTION.NONE) {
|
|
3526
|
-
const T = f instanceof PointerEvent ? f.pointerId : (f instanceof MouseEvent, 0),
|
|
3527
|
-
|
|
3700
|
+
const T = f instanceof PointerEvent ? f.pointerId : (f instanceof MouseEvent, 0), g = this._findPointerById(T);
|
|
3701
|
+
g && this._disposePointer(g), this._domElement.ownerDocument.removeEventListener("pointermove", a, { passive: !1 }), this._domElement.ownerDocument.removeEventListener("pointerup", h), this._domElement.ownerDocument.removeEventListener("mousemove", c), this._domElement.ownerDocument.removeEventListener("mouseup", d);
|
|
3528
3702
|
return;
|
|
3529
3703
|
}
|
|
3530
3704
|
f.preventDefault();
|
|
@@ -3533,7 +3707,7 @@ class ot extends gr {
|
|
|
3533
3707
|
if (!this._enabled)
|
|
3534
3708
|
return;
|
|
3535
3709
|
if (Ks(this._activePointers, lt), this._getClientRect(this._elementRect), e.copy(lt), i.copy(lt), this._activePointers.length >= 2) {
|
|
3536
|
-
const
|
|
3710
|
+
const g = lt.x - this._activePointers[1].clientX, S = lt.y - this._activePointers[1].clientY, _ = Math.sqrt(g * g + S * S);
|
|
3537
3711
|
o.set(0, _);
|
|
3538
3712
|
const N = (this._activePointers[0].clientX + this._activePointers[1].clientX) * 0.5, L = (this._activePointers[0].clientY + this._activePointers[1].clientY) * 0.5;
|
|
3539
3713
|
i.set(N, L);
|
|
@@ -3559,8 +3733,8 @@ class ot extends gr {
|
|
|
3559
3733
|
if (!this._enabled || !this._dragNeedsUpdate)
|
|
3560
3734
|
return;
|
|
3561
3735
|
this._dragNeedsUpdate = !1, Ks(this._activePointers, lt);
|
|
3562
|
-
const T = this._domElement && document.pointerLockElement === this._domElement ? this._lockedPointer || this._activePointers[0] : null,
|
|
3563
|
-
if (i.copy(lt), ((this._state & P.ROTATE) === P.ROTATE || (this._state & P.TOUCH_ROTATE) === P.TOUCH_ROTATE || (this._state & P.TOUCH_DOLLY_ROTATE) === P.TOUCH_DOLLY_ROTATE || (this._state & P.TOUCH_ZOOM_ROTATE) === P.TOUCH_ZOOM_ROTATE) && (this._rotateInternal(
|
|
3736
|
+
const T = this._domElement && document.pointerLockElement === this._domElement ? this._lockedPointer || this._activePointers[0] : null, g = T ? -T.deltaX : i.x - lt.x, S = T ? -T.deltaY : i.y - lt.y;
|
|
3737
|
+
if (i.copy(lt), ((this._state & P.ROTATE) === P.ROTATE || (this._state & P.TOUCH_ROTATE) === P.TOUCH_ROTATE || (this._state & P.TOUCH_DOLLY_ROTATE) === P.TOUCH_DOLLY_ROTATE || (this._state & P.TOUCH_ZOOM_ROTATE) === P.TOUCH_ZOOM_ROTATE) && (this._rotateInternal(g, S), this._isUserControllingRotate = !0), (this._state & P.DOLLY) === P.DOLLY || (this._state & P.ZOOM) === P.ZOOM) {
|
|
3564
3738
|
const _ = this.dollyToCursor ? (e.x - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0, N = this.dollyToCursor ? (e.y - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0, L = this.dollyDragInverted ? -1 : 1;
|
|
3565
3739
|
(this._state & P.DOLLY) === P.DOLLY ? (this._dollyInternal(L * S * ds, _, N), this._isUserControllingDolly = !0) : (this._zoomInternal(L * S * ds, _, N), this._isUserControllingZoom = !0);
|
|
3566
3740
|
}
|
|
@@ -3570,7 +3744,7 @@ class ot extends gr {
|
|
|
3570
3744
|
const y = this.dollyToCursor ? (i.x - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0, x = this.dollyToCursor ? (i.y - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0;
|
|
3571
3745
|
(this._state & P.TOUCH_DOLLY) === P.TOUCH_DOLLY || (this._state & P.TOUCH_DOLLY_ROTATE) === P.TOUCH_DOLLY_ROTATE || (this._state & P.TOUCH_DOLLY_TRUCK) === P.TOUCH_DOLLY_TRUCK || (this._state & P.TOUCH_DOLLY_OFFSET) === P.TOUCH_DOLLY_OFFSET ? (this._dollyInternal(M * ds, y, x), this._isUserControllingDolly = !0) : (this._zoomInternal(M * ds, y, x), this._isUserControllingZoom = !0);
|
|
3572
3746
|
}
|
|
3573
|
-
((this._state & P.TRUCK) === P.TRUCK || (this._state & P.TOUCH_TRUCK) === P.TOUCH_TRUCK || (this._state & P.TOUCH_DOLLY_TRUCK) === P.TOUCH_DOLLY_TRUCK || (this._state & P.TOUCH_ZOOM_TRUCK) === P.TOUCH_ZOOM_TRUCK) && (this._truckInternal(
|
|
3747
|
+
((this._state & P.TRUCK) === P.TRUCK || (this._state & P.TOUCH_TRUCK) === P.TOUCH_TRUCK || (this._state & P.TOUCH_DOLLY_TRUCK) === P.TOUCH_DOLLY_TRUCK || (this._state & P.TOUCH_ZOOM_TRUCK) === P.TOUCH_ZOOM_TRUCK) && (this._truckInternal(g, S, !1), this._isUserControllingTruck = !0), ((this._state & P.OFFSET) === P.OFFSET || (this._state & P.TOUCH_OFFSET) === P.TOUCH_OFFSET || (this._state & P.TOUCH_DOLLY_OFFSET) === P.TOUCH_DOLLY_OFFSET || (this._state & P.TOUCH_ZOOM_OFFSET) === P.TOUCH_ZOOM_OFFSET) && (this._truckInternal(g, S, !0), this._isUserControllingOffset = !0), this.dispatchEvent({ type: "control" });
|
|
3574
3748
|
}, C = () => {
|
|
3575
3749
|
Ks(this._activePointers, lt), i.copy(lt), this._dragNeedsUpdate = !1, (this._activePointers.length === 0 || this._activePointers.length === 1 && this._activePointers[0] === this._lockedPointer) && (this._isDragging = !1), this._activePointers.length === 0 && this._domElement && (this._domElement.ownerDocument.removeEventListener("pointermove", a, { passive: !1 }), this._domElement.ownerDocument.removeEventListener("mousemove", c), this._domElement.ownerDocument.removeEventListener("pointerup", h), this._domElement.ownerDocument.removeEventListener("mouseup", d), this.dispatchEvent({ type: "controlend" }));
|
|
3576
3750
|
};
|
|
@@ -3893,8 +4067,8 @@ class ot extends gr {
|
|
|
3893
4067
|
* @category Methods
|
|
3894
4068
|
*/
|
|
3895
4069
|
truck(s, t, e = !1) {
|
|
3896
|
-
this._camera.updateMatrix(),
|
|
3897
|
-
const i = G.copy(
|
|
4070
|
+
this._camera.updateMatrix(), Ot.setFromMatrixColumn(this._camera.matrix, 0), St.setFromMatrixColumn(this._camera.matrix, 1), Ot.multiplyScalar(s), St.multiplyScalar(-t);
|
|
4071
|
+
const i = G.copy(Ot).add(St), o = z.copy(this._targetEnd).add(i);
|
|
3898
4072
|
return this.moveTo(o.x, o.y, o.z, e);
|
|
3899
4073
|
}
|
|
3900
4074
|
/**
|
|
@@ -4038,8 +4212,8 @@ class ot extends gr {
|
|
|
4038
4212
|
we.setFromVector3(R.sub(C).applyQuaternion(this._yAxisUpSpace)), this._targetEnd.copy(A.lerp(C, u));
|
|
4039
4213
|
const F = we.theta - dt.theta, f = we.phi - dt.phi, T = we.radius - dt.radius;
|
|
4040
4214
|
this._sphericalEnd.set(dt.radius + T * u, dt.phi + f * u, dt.theta + F * u), this.normalizeRotations(), this._needsUpdate = !0, p || (this._target.copy(this._targetEnd), this._spherical.copy(this._sphericalEnd));
|
|
4041
|
-
const
|
|
4042
|
-
return this._createOnRestPromise(
|
|
4215
|
+
const g = !p || k(this._target.x, this._targetEnd.x, this.restThreshold) && k(this._target.y, this._targetEnd.y, this.restThreshold) && k(this._target.z, this._targetEnd.z, this.restThreshold) && k(this._spherical.theta, this._sphericalEnd.theta, this.restThreshold) && k(this._spherical.phi, this._sphericalEnd.phi, this.restThreshold) && k(this._spherical.radius, this._sphericalEnd.radius, this.restThreshold);
|
|
4216
|
+
return this._createOnRestPromise(g);
|
|
4043
4217
|
}
|
|
4044
4218
|
/**
|
|
4045
4219
|
* Set angle and distance by given position.
|
|
@@ -4088,9 +4262,9 @@ class ot extends gr {
|
|
|
4088
4262
|
* @category Methods
|
|
4089
4263
|
*/
|
|
4090
4264
|
setOrbitPoint(s, t, e) {
|
|
4091
|
-
this._camera.updateMatrixWorld(),
|
|
4265
|
+
this._camera.updateMatrixWorld(), Ot.setFromMatrixColumn(this._camera.matrixWorldInverse, 0), St.setFromMatrixColumn(this._camera.matrixWorldInverse, 1), Qt.setFromMatrixColumn(this._camera.matrixWorldInverse, 2);
|
|
4092
4266
|
const i = G.set(s, t, e), o = i.distanceTo(this._camera.position), n = i.sub(this._camera.position);
|
|
4093
|
-
|
|
4267
|
+
Ot.multiplyScalar(n.x), St.multiplyScalar(n.y), Qt.multiplyScalar(n.z), G.copy(Ot).add(St).add(Qt), G.z = G.z + o, this.dollyTo(o, !1), this.setFocalOffset(-G.x, G.y, -G.z, !1), this.moveTo(s, t, e, !1);
|
|
4094
4268
|
}
|
|
4095
4269
|
/**
|
|
4096
4270
|
* Set the boundary box that encloses the target of the camera. box3 is in THREE.Box3
|
|
@@ -4282,8 +4456,8 @@ class ot extends gr {
|
|
|
4282
4456
|
if (Zt(this._camera) && this._changedDolly !== 0) {
|
|
4283
4457
|
const d = this._spherical.radius - this._lastDistance, E = this._camera, u = this._getCameraDirection(ye), p = G.copy(u).cross(E.up).normalize();
|
|
4284
4458
|
p.lengthSq() === 0 && (p.x = 1);
|
|
4285
|
-
const A = z.crossVectors(p, u), m = this._sphericalEnd.radius * Math.tan(E.getEffectiveFOV() * Ne * 0.5), R = (this._sphericalEnd.radius - d - this._sphericalEnd.radius) / this._sphericalEnd.radius, F = de.copy(this._targetEnd).add(p.multiplyScalar(this._dollyControlCoord.x * m * E.aspect)).add(A.multiplyScalar(this._dollyControlCoord.y * m)), f = G.copy(this._targetEnd).lerp(F, R), T = this._lastDollyDirection === he.IN && this._spherical.radius <= this.minDistance,
|
|
4286
|
-
if (this.infinityDolly && (T ||
|
|
4459
|
+
const A = z.crossVectors(p, u), m = this._sphericalEnd.radius * Math.tan(E.getEffectiveFOV() * Ne * 0.5), R = (this._sphericalEnd.radius - d - this._sphericalEnd.radius) / this._sphericalEnd.radius, F = de.copy(this._targetEnd).add(p.multiplyScalar(this._dollyControlCoord.x * m * E.aspect)).add(A.multiplyScalar(this._dollyControlCoord.y * m)), f = G.copy(this._targetEnd).lerp(F, R), T = this._lastDollyDirection === he.IN && this._spherical.radius <= this.minDistance, g = this._lastDollyDirection === he.OUT && this.maxDistance <= this._spherical.radius;
|
|
4460
|
+
if (this.infinityDolly && (T || g)) {
|
|
4287
4461
|
this._sphericalEnd.radius -= d, this._spherical.radius -= d;
|
|
4288
4462
|
const _ = z.copy(u).multiplyScalar(-d);
|
|
4289
4463
|
f.add(_);
|
|
@@ -4292,15 +4466,15 @@ class ot extends gr {
|
|
|
4292
4466
|
const S = z.subVectors(f, this._targetEnd);
|
|
4293
4467
|
this._targetEnd.copy(f), this._target.add(S), this._changedDolly -= d, X(this._changedDolly) && (this._changedDolly = 0);
|
|
4294
4468
|
} else if (bt(this._camera) && this._changedZoom !== 0) {
|
|
4295
|
-
const d = this._zoom - this._lastZoom, E = this._camera, u = G.set(this._dollyControlCoord.x, this._dollyControlCoord.y, (E.near + E.far) / (E.near - E.far)).unproject(E), p = z.set(0, 0, -1).applyQuaternion(E.quaternion), A = de.copy(u).add(p.multiplyScalar(-u.dot(E.up))), C = -(this._zoom - d - this._zoom) / this._zoom, R = this._getCameraDirection(ye), F = this._targetEnd.dot(R), f = G.copy(this._targetEnd).lerp(A, C), T = f.dot(R),
|
|
4296
|
-
f.sub(
|
|
4469
|
+
const d = this._zoom - this._lastZoom, E = this._camera, u = G.set(this._dollyControlCoord.x, this._dollyControlCoord.y, (E.near + E.far) / (E.near - E.far)).unproject(E), p = z.set(0, 0, -1).applyQuaternion(E.quaternion), A = de.copy(u).add(p.multiplyScalar(-u.dot(E.up))), C = -(this._zoom - d - this._zoom) / this._zoom, R = this._getCameraDirection(ye), F = this._targetEnd.dot(R), f = G.copy(this._targetEnd).lerp(A, C), T = f.dot(R), g = R.multiplyScalar(T - F);
|
|
4470
|
+
f.sub(g), this._boundary.clampPoint(f, f);
|
|
4297
4471
|
const S = z.subVectors(f, this._targetEnd);
|
|
4298
4472
|
this._targetEnd.copy(f), this._target.add(S), this._changedZoom -= d, X(this._changedZoom) && (this._changedZoom = 0);
|
|
4299
4473
|
}
|
|
4300
4474
|
}
|
|
4301
4475
|
this._camera.zoom !== this._zoom && (this._camera.zoom = this._zoom, this._camera.updateProjectionMatrix(), this._updateNearPlaneCorners(), this._needsUpdate = !0), this._dragNeedsUpdate = !0;
|
|
4302
4476
|
const a = this._collisionTest();
|
|
4303
|
-
this._spherical.radius = Math.min(this._spherical.radius, a), this._spherical.makeSafe(), this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target), this._camera.lookAt(this._target), (!X(this._focalOffset.x) || !X(this._focalOffset.y) || !X(this._focalOffset.z)) && (this._camera.updateMatrixWorld(),
|
|
4477
|
+
this._spherical.radius = Math.min(this._spherical.radius, a), this._spherical.makeSafe(), this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target), this._camera.lookAt(this._target), (!X(this._focalOffset.x) || !X(this._focalOffset.y) || !X(this._focalOffset.z)) && (this._camera.updateMatrixWorld(), Ot.setFromMatrixColumn(this._camera.matrix, 0), St.setFromMatrixColumn(this._camera.matrix, 1), Qt.setFromMatrixColumn(this._camera.matrix, 2), Ot.multiplyScalar(this._focalOffset.x), St.multiplyScalar(-this._focalOffset.y), Qt.multiplyScalar(this._focalOffset.z), G.copy(Ot).add(St).add(Qt), this._camera.position.add(G)), this._boundaryEnclosesCamera && this._encloseToBoundary(this._camera.position.copy(this._target), G.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse), 1);
|
|
4304
4478
|
const h = this._needsUpdate;
|
|
4305
4479
|
return h && !this._updatedLastTime ? (this._hasRested = !1, this.dispatchEvent({ type: "wake" }), this.dispatchEvent({ type: "update" })) : h ? (this.dispatchEvent({ type: "update" }), X(t, this.restThreshold) && X(e, this.restThreshold) && X(i, this.restThreshold) && X(o.x, this.restThreshold) && X(o.y, this.restThreshold) && X(o.z, this.restThreshold) && X(n.x, this.restThreshold) && X(n.y, this.restThreshold) && X(n.z, this.restThreshold) && X(r, this.restThreshold) && !this._hasRested && (this._hasRested = !0, this.dispatchEvent({ type: "rest" }))) : !h && this._updatedLastTime && this.dispatchEvent({ type: "sleep" }), this._lastDistance = this._spherical.radius, this._lastZoom = this._zoom, this._updatedLastTime = h, this._needsUpdate = !1, h;
|
|
4306
4480
|
}
|
|
@@ -4506,9 +4680,17 @@ class ke extends cr {
|
|
|
4506
4680
|
I(this, "onBeforeUpdate", new D());
|
|
4507
4681
|
/** {@link Updateable.onAfterUpdate} */
|
|
4508
4682
|
I(this, "onAfterUpdate", new D());
|
|
4683
|
+
/**
|
|
4684
|
+
* Event that is triggered when the aspect of the camera has been updated.
|
|
4685
|
+
* This event is useful when you need to perform actions after the aspect of the camera has been changed.
|
|
4686
|
+
*/
|
|
4509
4687
|
I(this, "onAspectUpdated", new D());
|
|
4510
4688
|
/** {@link Disposable.onDisposed} */
|
|
4511
4689
|
I(this, "onDisposed", new D());
|
|
4690
|
+
/**
|
|
4691
|
+
* A three.js PerspectiveCamera or OrthographicCamera instance.
|
|
4692
|
+
* This camera is used for rendering the scene.
|
|
4693
|
+
*/
|
|
4512
4694
|
I(this, "three");
|
|
4513
4695
|
I(this, "_allControls", /* @__PURE__ */ new Map());
|
|
4514
4696
|
/**
|
|
@@ -4518,7 +4700,7 @@ class ke extends cr {
|
|
|
4518
4700
|
I(this, "updateAspect", () => {
|
|
4519
4701
|
var t;
|
|
4520
4702
|
if (!(!this.currentWorld || !this.currentWorld.renderer)) {
|
|
4521
|
-
if (this.three instanceof
|
|
4703
|
+
if (this.three instanceof O.OrthographicCamera) {
|
|
4522
4704
|
this.onAspectUpdated.trigger();
|
|
4523
4705
|
return;
|
|
4524
4706
|
}
|
|
@@ -4553,13 +4735,24 @@ class ke extends cr {
|
|
|
4553
4735
|
throw new Error("Controls not found!");
|
|
4554
4736
|
return t;
|
|
4555
4737
|
}
|
|
4556
|
-
/**
|
|
4738
|
+
/**
|
|
4739
|
+
* Getter for the enabled state of the camera controls.
|
|
4740
|
+
* If the current world is null, it returns false.
|
|
4741
|
+
* Otherwise, it returns the enabled state of the camera controls.
|
|
4742
|
+
*
|
|
4743
|
+
* @returns {boolean} The enabled state of the camera controls.
|
|
4744
|
+
*/
|
|
4557
4745
|
get enabled() {
|
|
4558
4746
|
return this.currentWorld === null ? !1 : this.controls.enabled;
|
|
4559
4747
|
}
|
|
4560
|
-
/**
|
|
4748
|
+
/**
|
|
4749
|
+
* Setter for the enabled state of the camera controls.
|
|
4750
|
+
* If the current world is not null, it sets the enabled state of the camera controls to the provided value.
|
|
4751
|
+
*
|
|
4752
|
+
* @param {boolean} enabled - The new enabled state of the camera controls.
|
|
4753
|
+
*/
|
|
4561
4754
|
set enabled(t) {
|
|
4562
|
-
this.controls.enabled = t;
|
|
4755
|
+
this.currentWorld !== null && (this.controls.enabled = t);
|
|
4563
4756
|
}
|
|
4564
4757
|
/** {@link Disposable.dispose} */
|
|
4565
4758
|
dispose() {
|
|
@@ -4572,8 +4765,8 @@ class ke extends cr {
|
|
|
4572
4765
|
this.enabled && (this.onBeforeUpdate.trigger(this), this.controls.update(t), this.onAfterUpdate.trigger(this));
|
|
4573
4766
|
}
|
|
4574
4767
|
setupCamera() {
|
|
4575
|
-
const t = window.innerWidth / window.innerHeight, e = new
|
|
4576
|
-
return e.position.set(50, 50, 50), e.lookAt(new
|
|
4768
|
+
const t = window.innerWidth / window.innerHeight, e = new O.PerspectiveCamera(60, t, 1, 1e3);
|
|
4769
|
+
return e.position.set(50, 50, 50), e.lookAt(new O.Vector3(0, 0, 0)), e;
|
|
4577
4770
|
}
|
|
4578
4771
|
newCameraControls() {
|
|
4579
4772
|
if (!this.currentWorld)
|
|
@@ -4589,51 +4782,47 @@ class ke extends cr {
|
|
|
4589
4782
|
}
|
|
4590
4783
|
static getSubsetOfThree() {
|
|
4591
4784
|
return {
|
|
4592
|
-
MOUSE:
|
|
4593
|
-
Vector2:
|
|
4594
|
-
Vector3:
|
|
4595
|
-
Vector4:
|
|
4596
|
-
Quaternion:
|
|
4597
|
-
Matrix4:
|
|
4598
|
-
Spherical:
|
|
4599
|
-
Box3:
|
|
4600
|
-
Sphere:
|
|
4601
|
-
Raycaster:
|
|
4602
|
-
MathUtils:
|
|
4785
|
+
MOUSE: O.MOUSE,
|
|
4786
|
+
Vector2: O.Vector2,
|
|
4787
|
+
Vector3: O.Vector3,
|
|
4788
|
+
Vector4: O.Vector4,
|
|
4789
|
+
Quaternion: O.Quaternion,
|
|
4790
|
+
Matrix4: O.Matrix4,
|
|
4791
|
+
Spherical: O.Spherical,
|
|
4792
|
+
Box3: O.Box3,
|
|
4793
|
+
Sphere: O.Sphere,
|
|
4794
|
+
Raycaster: O.Raycaster,
|
|
4795
|
+
MathUtils: O.MathUtils
|
|
4603
4796
|
};
|
|
4604
4797
|
}
|
|
4605
4798
|
}
|
|
4606
|
-
const
|
|
4799
|
+
const Os = class Os extends J {
|
|
4607
4800
|
constructor(t) {
|
|
4608
4801
|
super(t);
|
|
4609
|
-
/**
|
|
4610
|
-
* Event triggered after the update process of all worlds.
|
|
4611
|
-
* Subscribers can listen to this event to perform actions post-update.
|
|
4612
|
-
*/
|
|
4802
|
+
/** {@link Updateable.onAfterUpdate} */
|
|
4613
4803
|
I(this, "onAfterUpdate", new D());
|
|
4614
|
-
/**
|
|
4615
|
-
* Event triggered before the update process of all worlds.
|
|
4616
|
-
* Subscribers can listen to this event to perform actions pre-update.
|
|
4617
|
-
*/
|
|
4804
|
+
/** {@link Updateable.onBeforeUpdate} */
|
|
4618
4805
|
I(this, "onBeforeUpdate", new D());
|
|
4806
|
+
/** {@link Disposable.onDisposed} */
|
|
4807
|
+
I(this, "onDisposed", new D());
|
|
4619
4808
|
/**
|
|
4620
|
-
*
|
|
4621
|
-
*
|
|
4809
|
+
* An event that is triggered when a new world is created.
|
|
4810
|
+
* The event passes the newly created world as a parameter.
|
|
4622
4811
|
*/
|
|
4623
|
-
I(this, "onDisposed", new D());
|
|
4624
4812
|
I(this, "onWorldCreated", new D());
|
|
4813
|
+
/**
|
|
4814
|
+
* An event that is triggered when a world is deleted.
|
|
4815
|
+
* The event passes the UUID of the deleted world as a parameter.
|
|
4816
|
+
*/
|
|
4625
4817
|
I(this, "onWorldDeleted", new D());
|
|
4626
4818
|
/**
|
|
4627
4819
|
* A collection of worlds managed by this component.
|
|
4628
4820
|
* The key is the unique identifier (UUID) of the world, and the value is the World instance.
|
|
4629
4821
|
*/
|
|
4630
4822
|
I(this, "list", /* @__PURE__ */ new Map());
|
|
4631
|
-
/**
|
|
4632
|
-
* A flag indicating whether the Worlds component is enabled.
|
|
4633
|
-
* If false, the update process will be skipped.
|
|
4634
|
-
*/
|
|
4823
|
+
/** {@link Component.enabled} */
|
|
4635
4824
|
I(this, "enabled", !0);
|
|
4636
|
-
t.add(
|
|
4825
|
+
t.add(Os.uuid, this);
|
|
4637
4826
|
}
|
|
4638
4827
|
/**
|
|
4639
4828
|
* Creates a new instance of a SimpleWorld and adds it to the list of worlds.
|
|
@@ -4645,21 +4834,40 @@ const gs = class gs extends J {
|
|
|
4645
4834
|
* @throws {Error} - Throws an error if a world with the same UUID already exists in the list.
|
|
4646
4835
|
*/
|
|
4647
4836
|
create() {
|
|
4648
|
-
const t = new
|
|
4837
|
+
const t = new gr(this.components), e = t.uuid;
|
|
4649
4838
|
if (this.list.has(e))
|
|
4650
4839
|
throw new Error("There is already a world with this name!");
|
|
4651
4840
|
return this.list.set(e, t), this.onWorldCreated.trigger(t), t;
|
|
4652
4841
|
}
|
|
4842
|
+
/**
|
|
4843
|
+
* Deletes a world from the list of worlds.
|
|
4844
|
+
*
|
|
4845
|
+
* @param {World} world - The world to be deleted.
|
|
4846
|
+
*
|
|
4847
|
+
* @throws {Error} - Throws an error if the provided world is not found in the list.
|
|
4848
|
+
*
|
|
4849
|
+
* @returns {void}
|
|
4850
|
+
*/
|
|
4653
4851
|
delete(t) {
|
|
4852
|
+
if (!this.list.has(t.uuid))
|
|
4853
|
+
throw new Error("The provided world is not found in the list!");
|
|
4654
4854
|
const e = t.uuid;
|
|
4655
4855
|
this.list.delete(t.uuid), t.dispose(), this.onWorldDeleted.trigger(e);
|
|
4656
4856
|
}
|
|
4857
|
+
/**
|
|
4858
|
+
* Disposes of the Worlds component and all its managed worlds.
|
|
4859
|
+
* This method sets the enabled flag to false, disposes of all worlds, clears the list,
|
|
4860
|
+
* and triggers the onDisposed event.
|
|
4861
|
+
*
|
|
4862
|
+
* @returns {void}
|
|
4863
|
+
*/
|
|
4657
4864
|
dispose() {
|
|
4658
4865
|
this.enabled = !1;
|
|
4659
4866
|
for (const [t, e] of this.list)
|
|
4660
4867
|
e.dispose();
|
|
4661
4868
|
this.list.clear(), this.onDisposed.trigger();
|
|
4662
4869
|
}
|
|
4870
|
+
/** {@link Updateable.update} */
|
|
4663
4871
|
update(t) {
|
|
4664
4872
|
if (this.enabled)
|
|
4665
4873
|
for (const [e, i] of this.list)
|
|
@@ -4670,14 +4878,17 @@ const gs = class gs extends J {
|
|
|
4670
4878
|
* A unique identifier for the component.
|
|
4671
4879
|
* This UUID is used to register the component within the Components system.
|
|
4672
4880
|
*/
|
|
4673
|
-
I(
|
|
4674
|
-
let Ci =
|
|
4881
|
+
I(Os, "uuid", "fdb61dc4-2ec1-4966-b83d-54ea795fad4a");
|
|
4882
|
+
let Ci = Os;
|
|
4675
4883
|
class Pr {
|
|
4676
4884
|
constructor(s, t, e) {
|
|
4677
4885
|
/** {@link Disposable.onDisposed} */
|
|
4678
4886
|
I(this, "onDisposed", new D());
|
|
4887
|
+
/** The world instance to which this Raycaster belongs. */
|
|
4679
4888
|
I(this, "world");
|
|
4889
|
+
/** The components instance to which this grid belongs. */
|
|
4680
4890
|
I(this, "components");
|
|
4891
|
+
/** The Three.js mesh that contains the infinite grid. */
|
|
4681
4892
|
I(this, "three");
|
|
4682
4893
|
I(this, "_fade", 3);
|
|
4683
4894
|
I(this, "updateZoom", () => {
|
|
@@ -4686,8 +4897,8 @@ class Pr {
|
|
|
4686
4897
|
this.world = t;
|
|
4687
4898
|
const { color: i, size1: o, size2: n, distance: r } = e;
|
|
4688
4899
|
this.components = s;
|
|
4689
|
-
const a = new
|
|
4690
|
-
side:
|
|
4900
|
+
const a = new O.PlaneGeometry(2, 2, 1, 1), c = new O.ShaderMaterial({
|
|
4901
|
+
side: O.DoubleSide,
|
|
4691
4902
|
uniforms: {
|
|
4692
4903
|
uSize1: {
|
|
4693
4904
|
value: o
|
|
@@ -4776,7 +4987,7 @@ class Pr {
|
|
|
4776
4987
|
derivatives: !0
|
|
4777
4988
|
}
|
|
4778
4989
|
});
|
|
4779
|
-
this.three = new
|
|
4990
|
+
this.three = new O.Mesh(a, c), this.three.frustumCulled = !1, t.scene.three.add(this.three), this.setupEvents(!0);
|
|
4780
4991
|
}
|
|
4781
4992
|
/** {@link Hideable.visible} */
|
|
4782
4993
|
get visible() {
|
|
@@ -4818,18 +5029,34 @@ class Pr {
|
|
|
4818
5029
|
const Ss = class Ss extends J {
|
|
4819
5030
|
constructor(t) {
|
|
4820
5031
|
super(t);
|
|
5032
|
+
/**
|
|
5033
|
+
* A map of world UUIDs to their corresponding grid instances.
|
|
5034
|
+
*/
|
|
4821
5035
|
I(this, "list", /* @__PURE__ */ new Map());
|
|
4822
|
-
|
|
5036
|
+
/**
|
|
5037
|
+
* The default configuration for grid creation.
|
|
5038
|
+
*/
|
|
4823
5039
|
I(this, "config", {
|
|
4824
|
-
color: new
|
|
5040
|
+
color: new O.Color(12303291),
|
|
4825
5041
|
size1: 1,
|
|
4826
5042
|
size2: 10,
|
|
4827
5043
|
distance: 500
|
|
4828
5044
|
});
|
|
5045
|
+
/** {@link Disposable.onDisposed} */
|
|
5046
|
+
I(this, "onDisposed", new D());
|
|
4829
5047
|
/** {@link Component.enabled} */
|
|
4830
5048
|
I(this, "enabled", !0);
|
|
4831
5049
|
t.add(Ss.uuid, this);
|
|
4832
5050
|
}
|
|
5051
|
+
/**
|
|
5052
|
+
* Creates a new grid for the given world.
|
|
5053
|
+
* Throws an error if a grid already exists for the world.
|
|
5054
|
+
*
|
|
5055
|
+
* @param world - The world to create the grid for.
|
|
5056
|
+
* @returns The newly created grid.
|
|
5057
|
+
*
|
|
5058
|
+
* @throws Will throw an error if a grid already exists for the given world.
|
|
5059
|
+
*/
|
|
4833
5060
|
create(t) {
|
|
4834
5061
|
if (this.list.has(t.uuid))
|
|
4835
5062
|
throw new Error("This world already has a grid!");
|
|
@@ -4838,16 +5065,31 @@ const Ss = class Ss extends J {
|
|
|
4838
5065
|
this.delete(t);
|
|
4839
5066
|
}), e;
|
|
4840
5067
|
}
|
|
5068
|
+
/**
|
|
5069
|
+
* Deletes the grid associated with the given world.
|
|
5070
|
+
* If a grid does not exist for the given world, this method does nothing.
|
|
5071
|
+
*
|
|
5072
|
+
* @param world - The world for which to delete the grid.
|
|
5073
|
+
*
|
|
5074
|
+
* @remarks
|
|
5075
|
+
* This method will dispose of the grid and remove it from the internal list.
|
|
5076
|
+
* If the world is disposed before calling this method, the grid will be automatically deleted.
|
|
5077
|
+
*/
|
|
4841
5078
|
delete(t) {
|
|
4842
5079
|
const e = this.list.get(t.uuid);
|
|
4843
5080
|
e && e.dispose(), this.list.delete(t.uuid);
|
|
4844
5081
|
}
|
|
5082
|
+
/** {@link Disposable.dispose} */
|
|
4845
5083
|
dispose() {
|
|
4846
5084
|
for (const [t, e] of this.list)
|
|
4847
5085
|
e.dispose();
|
|
4848
5086
|
this.list.clear(), this.onDisposed.trigger(), this.onDisposed.reset();
|
|
4849
5087
|
}
|
|
4850
5088
|
};
|
|
5089
|
+
/**
|
|
5090
|
+
* A unique identifier for the component.
|
|
5091
|
+
* This UUID is used to register the component within the Components system.
|
|
5092
|
+
*/
|
|
4851
5093
|
I(Ss, "uuid", "d1e814d5-b81c-4452-87a2-f039375e0489");
|
|
4852
5094
|
let un = Ss;
|
|
4853
5095
|
const jt = new qn(), nt = new w(), xt = new w(), j = new Pt(), In = {
|
|
@@ -5090,7 +5332,7 @@ class xr extends ri {
|
|
|
5090
5332
|
XZ: [
|
|
5091
5333
|
[new v(new rt(0.15, 0.15, 0.01), c.clone()), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]]
|
|
5092
5334
|
]
|
|
5093
|
-
},
|
|
5335
|
+
}, g = {
|
|
5094
5336
|
X: [
|
|
5095
5337
|
[new v(new ct(0.2, 0, 0.6, 4), e), [0.3, 0, 0], [0, 0, -Math.PI / 2]],
|
|
5096
5338
|
[new v(new ct(0.2, 0, 0.6, 4), e), [-0.3, 0, 0], [0, 0, Math.PI / 2]]
|
|
@@ -5245,7 +5487,7 @@ class xr extends ri {
|
|
|
5245
5487
|
}
|
|
5246
5488
|
return H;
|
|
5247
5489
|
}
|
|
5248
|
-
this.gizmo = {}, this.picker = {}, this.helper = {}, this.add(this.gizmo.translate = b(T)), this.add(this.gizmo.rotate = b(_)), this.add(this.gizmo.scale = b(M)), this.add(this.picker.translate = b(
|
|
5490
|
+
this.gizmo = {}, this.picker = {}, this.helper = {}, this.add(this.gizmo.translate = b(T)), this.add(this.gizmo.rotate = b(_)), this.add(this.gizmo.scale = b(M)), this.add(this.picker.translate = b(g)), this.add(this.picker.rotate = b(L)), this.add(this.picker.scale = b(y)), this.add(this.helper.translate = b(S)), this.add(this.helper.rotate = b(N)), this.add(this.helper.scale = b(x)), this.picker.translate.visible = !1, this.picker.rotate.visible = !1, this.picker.scale.visible = !1;
|
|
5249
5491
|
}
|
|
5250
5492
|
// updateMatrixWorld will update transformations and appearance of individual handles
|
|
5251
5493
|
updateMatrixWorld(s) {
|
|
@@ -5320,19 +5562,30 @@ class Pi {
|
|
|
5320
5562
|
I(this, "onDraggingEnded", new D());
|
|
5321
5563
|
/** {@link Disposable.onDisposed} */
|
|
5322
5564
|
I(this, "onDisposed", new D());
|
|
5565
|
+
/**
|
|
5566
|
+
* The normal vector of the clipping plane.
|
|
5567
|
+
*/
|
|
5323
5568
|
I(this, "normal");
|
|
5569
|
+
/**
|
|
5570
|
+
* The origin point of the clipping plane.
|
|
5571
|
+
*/
|
|
5324
5572
|
I(this, "origin");
|
|
5325
|
-
|
|
5573
|
+
/**
|
|
5574
|
+
* The THREE.js Plane object representing the clipping plane.
|
|
5575
|
+
*/
|
|
5576
|
+
I(this, "three", new O.Plane());
|
|
5577
|
+
/** The components instance to which this plane belongs. */
|
|
5578
|
+
I(this, "components");
|
|
5579
|
+
/** The world instance to which this plane belongs. */
|
|
5580
|
+
I(this, "world");
|
|
5326
5581
|
I(this, "_helper");
|
|
5327
5582
|
I(this, "_visible", !0);
|
|
5328
5583
|
I(this, "_enabled", !0);
|
|
5329
|
-
I(this, "components");
|
|
5330
|
-
I(this, "world");
|
|
5331
5584
|
I(this, "_controlsActive", !1);
|
|
5332
|
-
I(this, "_arrowBoundBox", new
|
|
5585
|
+
I(this, "_arrowBoundBox", new O.Mesh());
|
|
5333
5586
|
I(this, "_planeMesh");
|
|
5334
5587
|
I(this, "_controls");
|
|
5335
|
-
I(this, "_hiddenMaterial", new
|
|
5588
|
+
I(this, "_hiddenMaterial", new O.MeshBasicMaterial({
|
|
5336
5589
|
visible: !1
|
|
5337
5590
|
}));
|
|
5338
5591
|
/** {@link Updateable.update} */
|
|
@@ -5349,10 +5602,18 @@ class Pi {
|
|
|
5349
5602
|
throw new Error("The given world must have a renderer!");
|
|
5350
5603
|
this.normal = i, this.origin = e, t.renderer.setPlane(!0, this.three), this._planeMesh = Pi.newPlaneMesh(n, o), this._helper = this.newHelper(), this._controls = this.newTransformControls(), this.three.setFromNormalAndCoplanarPoint(i, e), r && this.toggleControls(!0);
|
|
5351
5604
|
}
|
|
5605
|
+
/**
|
|
5606
|
+
* Getter for the enabled state of the clipping plane.
|
|
5607
|
+
* @returns {boolean} The current enabled state.
|
|
5608
|
+
*/
|
|
5352
5609
|
get enabled() {
|
|
5353
5610
|
return this._enabled;
|
|
5354
5611
|
}
|
|
5355
|
-
/**
|
|
5612
|
+
/**
|
|
5613
|
+
* Setter for the enabled state of the clipping plane.
|
|
5614
|
+
* Updates the clipping plane state in the renderer and throws an error if no renderer is found.
|
|
5615
|
+
* @param {boolean} state - The new enabled state.
|
|
5616
|
+
*/
|
|
5356
5617
|
set enabled(s) {
|
|
5357
5618
|
if (!this.world.renderer)
|
|
5358
5619
|
throw new Error("No renderer found for clipping plane!");
|
|
@@ -5386,9 +5647,26 @@ class Pi {
|
|
|
5386
5647
|
set size(s) {
|
|
5387
5648
|
this._planeMesh.scale.set(s, s, s);
|
|
5388
5649
|
}
|
|
5650
|
+
/**
|
|
5651
|
+
* Getter for the helper object of the clipping plane.
|
|
5652
|
+
* The helper object is a THREE.Object3D that contains the clipping plane mesh and other related objects.
|
|
5653
|
+
* It is used for positioning, rotating, and scaling the clipping plane in the 3D scene.
|
|
5654
|
+
*
|
|
5655
|
+
* @returns {THREE.Object3D} The helper object of the clipping plane.
|
|
5656
|
+
*/
|
|
5389
5657
|
get helper() {
|
|
5390
5658
|
return this._helper;
|
|
5391
5659
|
}
|
|
5660
|
+
/**
|
|
5661
|
+
* Sets the clipping plane's normal and origin from the given normal and point.
|
|
5662
|
+
* This method resets the clipping plane's state, updates the normal and origin,
|
|
5663
|
+
* and positions the helper object accordingly.
|
|
5664
|
+
*
|
|
5665
|
+
* @param normal - The new normal vector for the clipping plane.
|
|
5666
|
+
* @param point - The new origin point for the clipping plane.
|
|
5667
|
+
*
|
|
5668
|
+
* @returns {void}
|
|
5669
|
+
*/
|
|
5392
5670
|
setFromNormalAndCoplanarPoint(s, t) {
|
|
5393
5671
|
this.reset(), this.normal.equals(s) || (this.normal.copy(s), this._helper.lookAt(s)), this.origin.copy(t), this._helper.position.copy(t), this._helper.updateMatrix(), this.update();
|
|
5394
5672
|
}
|
|
@@ -5397,7 +5675,7 @@ class Pi {
|
|
|
5397
5675
|
this._enabled = !1, this.onDraggingStarted.reset(), this.onDraggingEnded.reset(), this._helper.removeFromParent(), this.world.renderer && this.world.renderer.setPlane(!1, this.three), this._arrowBoundBox.removeFromParent(), this._arrowBoundBox.geometry.dispose(), this._planeMesh.geometry.dispose(), this._controls.removeFromParent(), this._controls.dispose(), this.onDisposed.trigger(), this.onDisposed.reset();
|
|
5398
5676
|
}
|
|
5399
5677
|
reset() {
|
|
5400
|
-
const s = new
|
|
5678
|
+
const s = new O.Vector3(1, 0, 0), t = new O.Vector3();
|
|
5401
5679
|
this.normal.equals(s) || (this.normal.copy(s), this._helper.lookAt(s)), this.origin.copy(t), this._helper.position.copy(t), this._helper.updateMatrix();
|
|
5402
5680
|
}
|
|
5403
5681
|
toggleControls(s) {
|
|
@@ -5419,7 +5697,7 @@ class Pi {
|
|
|
5419
5697
|
s.attach(this._helper), s.showX = !1, s.showY = !1, s.setSpace("local"), this.createArrowBoundingBox(), s.children[0].children[0].add(this._arrowBoundBox);
|
|
5420
5698
|
}
|
|
5421
5699
|
createArrowBoundingBox() {
|
|
5422
|
-
this._arrowBoundBox.geometry = new
|
|
5700
|
+
this._arrowBoundBox.geometry = new O.CylinderGeometry(0.18, 0.18, 1.2), this._arrowBoundBox.material = this._hiddenMaterial, this._arrowBoundBox.rotateX(Math.PI / 2), this._arrowBoundBox.updateMatrix(), this._arrowBoundBox.geometry.applyMatrix4(this._arrowBoundBox.matrix);
|
|
5423
5701
|
}
|
|
5424
5702
|
notifyDraggingChanged(s) {
|
|
5425
5703
|
s.value ? this.onDraggingStarted.trigger() : this.onDraggingEnded.trigger();
|
|
@@ -5428,29 +5706,47 @@ class Pi {
|
|
|
5428
5706
|
this.world.camera.enabled = this._visible;
|
|
5429
5707
|
}
|
|
5430
5708
|
newHelper() {
|
|
5431
|
-
const s = new
|
|
5709
|
+
const s = new O.Object3D();
|
|
5432
5710
|
return s.lookAt(this.normal), s.position.copy(this.origin), this._planeMesh.position.z += 0.01, s.add(this._planeMesh), this.world.scene.three.add(s), s;
|
|
5433
5711
|
}
|
|
5434
5712
|
static newPlaneMesh(s, t) {
|
|
5435
|
-
const e = new
|
|
5713
|
+
const e = new O.PlaneGeometry(1), i = new O.Mesh(e, t);
|
|
5436
5714
|
return i.scale.set(s, s, s), i;
|
|
5437
5715
|
}
|
|
5438
5716
|
}
|
|
5439
5717
|
const Be = class Be extends J {
|
|
5440
5718
|
constructor(t) {
|
|
5441
5719
|
super(t);
|
|
5442
|
-
/** {@link Createable.onAfterCreate} */
|
|
5443
|
-
I(this, "onAfterCreate", new D());
|
|
5444
|
-
/** {@link Createable.onAfterDelete} */
|
|
5445
|
-
I(this, "onAfterDelete", new D());
|
|
5446
5720
|
/** Event that fires when the user starts dragging a clipping plane. */
|
|
5447
5721
|
I(this, "onBeforeDrag", new D());
|
|
5448
5722
|
/** Event that fires when the user stops dragging a clipping plane. */
|
|
5449
5723
|
I(this, "onAfterDrag", new D());
|
|
5724
|
+
/**
|
|
5725
|
+
* Event that fires when the user starts creating a clipping plane.
|
|
5726
|
+
*/
|
|
5450
5727
|
I(this, "onBeforeCreate", new D());
|
|
5728
|
+
/**
|
|
5729
|
+
* Event that fires when the user cancels the creation of a clipping plane.
|
|
5730
|
+
*/
|
|
5451
5731
|
I(this, "onBeforeCancel", new D());
|
|
5732
|
+
/**
|
|
5733
|
+
* Event that fires after the user cancels the creation of a clipping plane.
|
|
5734
|
+
*/
|
|
5452
5735
|
I(this, "onAfterCancel", new D());
|
|
5736
|
+
/**
|
|
5737
|
+
* Event that fires when the user starts deleting a clipping plane.
|
|
5738
|
+
*/
|
|
5453
5739
|
I(this, "onBeforeDelete", new D());
|
|
5740
|
+
/**
|
|
5741
|
+
* Event that fires after a clipping plane has been created.
|
|
5742
|
+
* @param plane - The newly created clipping plane.
|
|
5743
|
+
*/
|
|
5744
|
+
I(this, "onAfterCreate", new D());
|
|
5745
|
+
/**
|
|
5746
|
+
* Event that fires after a clipping plane has been deleted.
|
|
5747
|
+
* @param plane - The deleted clipping plane.
|
|
5748
|
+
*/
|
|
5749
|
+
I(this, "onAfterDelete", new D());
|
|
5454
5750
|
/** {@link Disposable.onDisposed} */
|
|
5455
5751
|
I(this, "onDisposed", new D());
|
|
5456
5752
|
/**
|
|
@@ -5466,12 +5762,19 @@ const Be = class Be extends J {
|
|
|
5466
5762
|
* has to be `true` for this to apply.
|
|
5467
5763
|
*/
|
|
5468
5764
|
I(this, "toleranceOrthogonalY", 0.7);
|
|
5765
|
+
/**
|
|
5766
|
+
* The type of clipping plane to be created.
|
|
5767
|
+
* Default is {@link SimplePlane}.
|
|
5768
|
+
*/
|
|
5469
5769
|
I(this, "Type", Pi);
|
|
5770
|
+
/**
|
|
5771
|
+
* A list of all the clipping planes created by this component.
|
|
5772
|
+
*/
|
|
5470
5773
|
I(this, "list", []);
|
|
5471
5774
|
/** The material used in all the clipping planes. */
|
|
5472
|
-
I(this, "_material", new
|
|
5775
|
+
I(this, "_material", new O.MeshBasicMaterial({
|
|
5473
5776
|
color: 12255487,
|
|
5474
|
-
side:
|
|
5777
|
+
side: O.DoubleSide,
|
|
5475
5778
|
transparent: !0,
|
|
5476
5779
|
opacity: 0.2
|
|
5477
5780
|
}));
|
|
@@ -5596,7 +5899,7 @@ const Be = class Be extends J {
|
|
|
5596
5899
|
var a;
|
|
5597
5900
|
if (!t.renderer)
|
|
5598
5901
|
throw new Error("The given world must have a renderer!");
|
|
5599
|
-
const i = e.point.distanceTo(new
|
|
5902
|
+
const i = e.point.distanceTo(new O.Vector3(0, 0, 0)), o = (a = e.face) == null ? void 0 : a.normal;
|
|
5600
5903
|
if (!i || !o)
|
|
5601
5904
|
return;
|
|
5602
5905
|
const n = this.getWorldNormal(e, o), r = this.newPlane(t, e.point, n.negate());
|
|
@@ -5605,11 +5908,11 @@ const Be = class Be extends J {
|
|
|
5605
5908
|
getWorldNormal(t, e) {
|
|
5606
5909
|
const i = t.object;
|
|
5607
5910
|
let o = t.object.matrixWorld.clone();
|
|
5608
|
-
if (i instanceof
|
|
5609
|
-
const c = new
|
|
5911
|
+
if (i instanceof O.InstancedMesh && t.instanceId !== void 0) {
|
|
5912
|
+
const c = new O.Matrix4();
|
|
5610
5913
|
i.getMatrixAt(t.instanceId, c), o = c.multiply(o);
|
|
5611
5914
|
}
|
|
5612
|
-
const r = new
|
|
5915
|
+
const r = new O.Matrix3().getNormalMatrix(o), a = e.clone().applyMatrix3(r).normalize();
|
|
5613
5916
|
return this.normalizePlaneDirectionY(a), a;
|
|
5614
5917
|
}
|
|
5615
5918
|
normalizePlaneDirectionY(t) {
|
|
@@ -5641,6 +5944,10 @@ const Be = class Be extends J {
|
|
|
5641
5944
|
}
|
|
5642
5945
|
}
|
|
5643
5946
|
};
|
|
5947
|
+
/**
|
|
5948
|
+
* A unique identifier for the component.
|
|
5949
|
+
* This UUID is used to register the component within the Components system.
|
|
5950
|
+
*/
|
|
5644
5951
|
I(Be, "uuid", "66290bc5-18c4-4cd1-9379-2e17a0617611");
|
|
5645
5952
|
let An = Be;
|
|
5646
5953
|
function vr(l, s, t, e) {
|
|
@@ -5678,7 +5985,9 @@ class Vr {
|
|
|
5678
5985
|
* just before but not anymore.
|
|
5679
5986
|
*/
|
|
5680
5987
|
I(this, "onViewUpdated", new $t());
|
|
5681
|
-
/**
|
|
5988
|
+
/**
|
|
5989
|
+
* Whether this renderer is active or not. If not, it won't render anything.
|
|
5990
|
+
*/
|
|
5682
5991
|
I(this, "enabled", !0);
|
|
5683
5992
|
/**
|
|
5684
5993
|
* Needs to check whether there are objects that need to be hidden or shown.
|
|
@@ -5690,13 +5999,16 @@ class Vr {
|
|
|
5690
5999
|
* for debugging purposes.
|
|
5691
6000
|
*/
|
|
5692
6001
|
I(this, "renderDebugFrame", !1);
|
|
6002
|
+
/** The components instance to which this renderer belongs. */
|
|
5693
6003
|
I(this, "components");
|
|
6004
|
+
/** The world instance to which this renderer belongs. */
|
|
5694
6005
|
I(this, "world");
|
|
6006
|
+
/** The THREE.js renderer used to make the visibility test. */
|
|
5695
6007
|
I(this, "renderer");
|
|
5696
6008
|
I(this, "autoUpdate", !0);
|
|
5697
6009
|
I(this, "updateInterval", 1e3);
|
|
5698
6010
|
I(this, "worker");
|
|
5699
|
-
I(this, "scene", new
|
|
6011
|
+
I(this, "scene", new O.Scene());
|
|
5700
6012
|
I(this, "_width", 512);
|
|
5701
6013
|
I(this, "_height", 512);
|
|
5702
6014
|
I(this, "_availableColor", 1);
|
|
@@ -5733,7 +6045,7 @@ class Vr {
|
|
|
5733
6045
|
});
|
|
5734
6046
|
if (!t.renderer)
|
|
5735
6047
|
throw new Error("The given world must have a renderer!");
|
|
5736
|
-
this.components = s, this.applySettings(e), this.world = t, this.renderer = new
|
|
6048
|
+
this.components = s, this.applySettings(e), this.world = t, this.renderer = new O.WebGLRenderer(), this.renderTarget = new O.WebGLRenderTarget(this._width, this._height), this.bufferSize = this._width * this._height * 4, this._buffer = new Uint8Array(this.bufferSize), this.renderer.clippingPlanes = t.renderer.clippingPlanes;
|
|
5737
6049
|
const i = `
|
|
5738
6050
|
addEventListener("message", (event) => {
|
|
5739
6051
|
const { buffer } = event.data;
|
|
@@ -5793,17 +6105,32 @@ class Vr {
|
|
|
5793
6105
|
class Gr extends Vr {
|
|
5794
6106
|
constructor(t, e, i) {
|
|
5795
6107
|
super(t, e, i);
|
|
5796
|
-
|
|
5797
|
-
|
|
6108
|
+
/**
|
|
6109
|
+
* Event triggered when the visibility of meshes is updated.
|
|
6110
|
+
* Contains two sets: seen and unseen.
|
|
6111
|
+
*/
|
|
5798
6112
|
I(this, "onViewUpdated", new D());
|
|
6113
|
+
/**
|
|
6114
|
+
* Pixels in screen a geometry must occupy to be considered "seen".
|
|
6115
|
+
* Default value is 100.
|
|
6116
|
+
*/
|
|
6117
|
+
I(this, "threshold", 100);
|
|
6118
|
+
/**
|
|
6119
|
+
* Map of color code to THREE.InstancedMesh.
|
|
6120
|
+
* Used to keep track of color-coded meshes.
|
|
6121
|
+
*/
|
|
5799
6122
|
I(this, "colorMeshes", /* @__PURE__ */ new Map());
|
|
6123
|
+
/**
|
|
6124
|
+
* Flag to indicate if the renderer is currently processing.
|
|
6125
|
+
* Used to prevent concurrent processing.
|
|
6126
|
+
*/
|
|
5800
6127
|
I(this, "isProcessing", !1);
|
|
5801
6128
|
I(this, "_colorCodeMeshMap", /* @__PURE__ */ new Map());
|
|
5802
6129
|
I(this, "_meshIDColorCodeMap", /* @__PURE__ */ new Map());
|
|
5803
6130
|
I(this, "_currentVisibleMeshes", /* @__PURE__ */ new Set());
|
|
5804
6131
|
I(this, "_recentlyHiddenMeshes", /* @__PURE__ */ new Set());
|
|
5805
6132
|
I(this, "_intervalID", null);
|
|
5806
|
-
I(this, "_transparentMat", new
|
|
6133
|
+
I(this, "_transparentMat", new O.MeshBasicMaterial({
|
|
5807
6134
|
transparent: !0,
|
|
5808
6135
|
opacity: 0
|
|
5809
6136
|
}));
|
|
@@ -5832,6 +6159,7 @@ class Gr extends Vr {
|
|
|
5832
6159
|
r.visible = !1;
|
|
5833
6160
|
});
|
|
5834
6161
|
}
|
|
6162
|
+
/** {@link Disposable.dispose} */
|
|
5835
6163
|
dispose() {
|
|
5836
6164
|
super.dispose(), this._intervalID !== null && (window.clearInterval(this._intervalID), this._intervalID = null), this._currentVisibleMeshes.clear(), this._recentlyHiddenMeshes.clear(), this._meshIDColorCodeMap.clear(), this._transparentMat.dispose(), this._colorCodeMeshMap.clear();
|
|
5837
6165
|
const t = this.components.get(zt);
|
|
@@ -5841,6 +6169,11 @@ class Gr extends Vr {
|
|
|
5841
6169
|
}
|
|
5842
6170
|
this.colorMeshes.clear();
|
|
5843
6171
|
}
|
|
6172
|
+
/**
|
|
6173
|
+
* Adds a mesh to the culler. When the mesh is not visibile anymore, it will be removed from the scene. When it's visible again, it will be added to the scene.
|
|
6174
|
+
* @param mesh - The mesh to add. It can be a regular THREE.Mesh or an instance of THREE.InstancedMesh.
|
|
6175
|
+
* @returns {void}
|
|
6176
|
+
*/
|
|
5844
6177
|
add(t) {
|
|
5845
6178
|
if (!this.enabled)
|
|
5846
6179
|
return;
|
|
@@ -5849,7 +6182,7 @@ class Gr extends Vr {
|
|
|
5849
6182
|
return;
|
|
5850
6183
|
}
|
|
5851
6184
|
this.isProcessing = !0;
|
|
5852
|
-
const e = t instanceof
|
|
6185
|
+
const e = t instanceof O.InstancedMesh, { geometry: i, material: o } = t, { colorMaterial: n, code: r } = this.getAvailableMaterial();
|
|
5853
6186
|
let a;
|
|
5854
6187
|
if (Array.isArray(o)) {
|
|
5855
6188
|
let d = !0;
|
|
@@ -5867,9 +6200,15 @@ class Gr extends Vr {
|
|
|
5867
6200
|
} else
|
|
5868
6201
|
a = n;
|
|
5869
6202
|
this._colorCodeMeshMap.set(r, t), this._meshIDColorCodeMap.set(t.uuid, r);
|
|
5870
|
-
const c = e ? t.count : 1, h = new
|
|
5871
|
-
e ? h.instanceMatrix = t.instanceMatrix : h.setMatrixAt(0, new
|
|
6203
|
+
const c = e ? t.count : 1, h = new O.InstancedMesh(i, a, c);
|
|
6204
|
+
e ? h.instanceMatrix = t.instanceMatrix : h.setMatrixAt(0, new O.Matrix4()), t.visible = !1, h.applyMatrix4(t.matrix), h.updateMatrix(), this.scene.add(h), this.colorMeshes.set(t.uuid, h), this.increaseColor(), this.isProcessing = !1;
|
|
5872
6205
|
}
|
|
6206
|
+
/**
|
|
6207
|
+
* Removes a mesh from the culler, so its visibility is not controlled by the culler anymore.
|
|
6208
|
+
* When the mesh is removed, it will be hidden from the scene and its color-coded mesh will be destroyed.
|
|
6209
|
+
* @param mesh - The mesh to remove. It can be a regular THREE.Mesh or an instance of THREE.InstancedMesh.
|
|
6210
|
+
* @returns {void}
|
|
6211
|
+
*/
|
|
5873
6212
|
remove(t) {
|
|
5874
6213
|
if (this.isProcessing) {
|
|
5875
6214
|
console.log("Culler processing not finished yet.");
|
|
@@ -5886,70 +6225,66 @@ class Gr extends Vr {
|
|
|
5886
6225
|
this._colorCodeMeshMap.delete(o), this._meshIDColorCodeMap.delete(t.uuid), this.colorMeshes.delete(t.uuid), i.geometry = void 0, i.material = [], e.destroy(i, !0), this._recentlyHiddenMeshes.delete(t), this._currentVisibleMeshes.delete(t), this.isProcessing = !1;
|
|
5887
6226
|
}
|
|
5888
6227
|
getAvailableMaterial() {
|
|
5889
|
-
const { r: t, g: e, b: i, code: o } = this.getAvailableColor(), n =
|
|
5890
|
-
|
|
5891
|
-
const r = new
|
|
6228
|
+
const { r: t, g: e, b: i, code: o } = this.getAvailableColor(), n = O.ColorManagement.enabled;
|
|
6229
|
+
O.ColorManagement.enabled = !1;
|
|
6230
|
+
const r = new O.Color(`rgb(${t}, ${e}, ${i})`);
|
|
5892
6231
|
if (!this.world.renderer)
|
|
5893
6232
|
throw new Error("Renderer not found in the world!");
|
|
5894
|
-
const a = this.world.renderer.clippingPlanes, c = new
|
|
6233
|
+
const a = this.world.renderer.clippingPlanes, c = new O.MeshBasicMaterial({
|
|
5895
6234
|
color: r,
|
|
5896
6235
|
clippingPlanes: a,
|
|
5897
|
-
side:
|
|
6236
|
+
side: O.DoubleSide
|
|
5898
6237
|
});
|
|
5899
|
-
return
|
|
6238
|
+
return O.ColorManagement.enabled = n, { colorMaterial: c, code: o };
|
|
5900
6239
|
}
|
|
5901
6240
|
}
|
|
5902
6241
|
const Ye = class Ye extends J {
|
|
5903
6242
|
constructor(t) {
|
|
5904
6243
|
super(t);
|
|
5905
6244
|
/**
|
|
5906
|
-
|
|
5907
|
-
|
|
6245
|
+
* An event that is triggered when the Cullers component is disposed.
|
|
6246
|
+
*/
|
|
6247
|
+
I(this, "onDisposed", new D());
|
|
5908
6248
|
I(this, "_enabled", !0);
|
|
5909
6249
|
/**
|
|
5910
6250
|
* A map of MeshCullerRenderer instances, keyed by their world UUIDs.
|
|
5911
6251
|
*/
|
|
5912
6252
|
I(this, "list", /* @__PURE__ */ new Map());
|
|
5913
|
-
/**
|
|
5914
|
-
* An event that is triggered when the Cullers component is disposed.
|
|
5915
|
-
*/
|
|
5916
|
-
I(this, "onDisposed", new D());
|
|
5917
6253
|
t.add(Ye.uuid, this);
|
|
5918
6254
|
}
|
|
5919
|
-
/**
|
|
5920
|
-
* Gets the enabled state of the Cullers component.
|
|
5921
|
-
*
|
|
5922
|
-
* @returns The current enabled state.
|
|
5923
|
-
*/
|
|
6255
|
+
/** {@link Component.enabled} */
|
|
5924
6256
|
get enabled() {
|
|
5925
6257
|
return this._enabled;
|
|
5926
6258
|
}
|
|
5927
|
-
/**
|
|
5928
|
-
* Sets the enabled state of the Cullers component.
|
|
5929
|
-
* Also sets the enabled state of all MeshCullerRenderer instances.
|
|
5930
|
-
*
|
|
5931
|
-
* @param value - The new enabled state.
|
|
5932
|
-
*/
|
|
6259
|
+
/** {@link Component.enabled} */
|
|
5933
6260
|
set enabled(t) {
|
|
5934
6261
|
this._enabled = t;
|
|
5935
6262
|
for (const [e, i] of this.list)
|
|
5936
6263
|
i.enabled = t;
|
|
5937
6264
|
}
|
|
5938
6265
|
/**
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
6266
|
+
* Creates a new MeshCullerRenderer for the given world.
|
|
6267
|
+
* If a MeshCullerRenderer already exists for the world, it will return the existing one.
|
|
6268
|
+
*
|
|
6269
|
+
* @param world - The world for which to create the MeshCullerRenderer.
|
|
6270
|
+
* @param config - Optional configuration settings for the MeshCullerRenderer.
|
|
6271
|
+
*
|
|
6272
|
+
* @returns The newly created or existing MeshCullerRenderer for the given world.
|
|
6273
|
+
*/
|
|
5947
6274
|
create(t, e) {
|
|
5948
6275
|
if (this.list.has(t.uuid))
|
|
5949
6276
|
return this.list.get(t.uuid);
|
|
5950
6277
|
const i = new Gr(this.components, t, e);
|
|
5951
6278
|
return this.list.set(t.uuid, i), i;
|
|
5952
6279
|
}
|
|
6280
|
+
/**
|
|
6281
|
+
* Deletes the MeshCullerRenderer associated with the given world.
|
|
6282
|
+
* If a MeshCullerRenderer exists for the given world, it will be disposed and removed from the list.
|
|
6283
|
+
*
|
|
6284
|
+
* @param world - The world for which to delete the MeshCullerRenderer.
|
|
6285
|
+
*
|
|
6286
|
+
* @returns {void}
|
|
6287
|
+
*/
|
|
5953
6288
|
delete(t) {
|
|
5954
6289
|
const e = this.list.get(t.uuid);
|
|
5955
6290
|
e && e.dispose(), this.list.delete(t.uuid);
|
|
@@ -5963,7 +6298,8 @@ const Ye = class Ye extends J {
|
|
|
5963
6298
|
}
|
|
5964
6299
|
};
|
|
5965
6300
|
/**
|
|
5966
|
-
* A unique identifier for the
|
|
6301
|
+
* A unique identifier for the component.
|
|
6302
|
+
* This UUID is used to register the component within the Components system.
|
|
5967
6303
|
*/
|
|
5968
6304
|
I(Ye, "uuid", "69f2a50d-c266-44fc-b1bd-fa4d34be89e6");
|
|
5969
6305
|
let Ti = Ye;
|
|
@@ -5971,24 +6307,51 @@ class zr {
|
|
|
5971
6307
|
constructor(s) {
|
|
5972
6308
|
/** {@link Disposable.onDisposed} */
|
|
5973
6309
|
I(this, "onDisposed", new D());
|
|
6310
|
+
/** {@link Updateable.onAfterUpdate} */
|
|
5974
6311
|
I(this, "onAfterUpdate", new D());
|
|
6312
|
+
/** {@link Updateable.onBeforeUpdate} */
|
|
5975
6313
|
I(this, "onBeforeUpdate", new D());
|
|
6314
|
+
/** {@link Resizeable.onResize} */
|
|
5976
6315
|
I(this, "onResize", new D());
|
|
5977
|
-
|
|
6316
|
+
/**
|
|
6317
|
+
* The front offset of the minimap.
|
|
6318
|
+
* It determines how much the minimap's view is offset from the camera's view.
|
|
6319
|
+
* By pushing the map to the front, what the user sees on screen corresponds with what they see on the map
|
|
6320
|
+
*/
|
|
5978
6321
|
I(this, "frontOffset", 0);
|
|
5979
|
-
|
|
5980
|
-
|
|
6322
|
+
/**
|
|
6323
|
+
* The override material for the minimap.
|
|
6324
|
+
* It is used to render the depth information of the world onto the minimap.
|
|
6325
|
+
*/
|
|
6326
|
+
I(this, "overrideMaterial", new O.MeshDepthMaterial());
|
|
6327
|
+
/**
|
|
6328
|
+
* The background color of the minimap.
|
|
6329
|
+
* It is used to set the background color of the minimap's renderer.
|
|
6330
|
+
*/
|
|
6331
|
+
I(this, "backgroundColor", new O.Color(395274));
|
|
6332
|
+
/**
|
|
6333
|
+
* The WebGL renderer for the minimap.
|
|
6334
|
+
* It is used to render the minimap onto the screen.
|
|
6335
|
+
*/
|
|
5981
6336
|
I(this, "renderer");
|
|
6337
|
+
/**
|
|
6338
|
+
* A flag indicating whether the minimap is enabled.
|
|
6339
|
+
* If disabled, the minimap will not update or render.
|
|
6340
|
+
*/
|
|
5982
6341
|
I(this, "enabled", !0);
|
|
6342
|
+
/**
|
|
6343
|
+
* The world in which the minimap is displayed.
|
|
6344
|
+
* It provides access to the 3D scene, camera, and other relevant world elements.
|
|
6345
|
+
*/
|
|
5983
6346
|
I(this, "world");
|
|
5984
6347
|
I(this, "_lockRotation", !0);
|
|
5985
6348
|
I(this, "_camera");
|
|
5986
6349
|
I(this, "_plane");
|
|
5987
|
-
I(this, "_size", new
|
|
5988
|
-
I(this, "_tempVector1", new
|
|
5989
|
-
I(this, "_tempVector2", new
|
|
5990
|
-
I(this, "_tempTarget", new
|
|
5991
|
-
I(this, "down", new
|
|
6350
|
+
I(this, "_size", new O.Vector2(320, 160));
|
|
6351
|
+
I(this, "_tempVector1", new O.Vector3());
|
|
6352
|
+
I(this, "_tempVector2", new O.Vector3());
|
|
6353
|
+
I(this, "_tempTarget", new O.Vector3());
|
|
6354
|
+
I(this, "down", new O.Vector3(0, -1, 0));
|
|
5992
6355
|
I(this, "updatePlanes", () => {
|
|
5993
6356
|
if (!this.world.renderer)
|
|
5994
6357
|
throw new Error("The given world must have a renderer!");
|
|
@@ -5999,33 +6362,55 @@ class zr {
|
|
|
5999
6362
|
});
|
|
6000
6363
|
if (this.world = s, !this.world.renderer)
|
|
6001
6364
|
throw new Error("The given world must have a renderer!");
|
|
6002
|
-
this.renderer = new
|
|
6365
|
+
this.renderer = new O.WebGLRenderer(), this.renderer.setSize(this._size.x, this._size.y);
|
|
6003
6366
|
const t = 1, e = this._size.x / this._size.y;
|
|
6004
|
-
this._camera = new
|
|
6367
|
+
this._camera = new O.OrthographicCamera(
|
|
6005
6368
|
t * e / -2,
|
|
6006
6369
|
t * e / 2,
|
|
6007
6370
|
t / 2,
|
|
6008
6371
|
t / -2
|
|
6009
|
-
), this.world.renderer.onClippingPlanesUpdated.add(this.updatePlanes), this._camera.position.set(0, 200, 0), this._camera.zoom = 0.1, this._camera.rotation.x = -Math.PI / 2, this._plane = new
|
|
6372
|
+
), this.world.renderer.onClippingPlanesUpdated.add(this.updatePlanes), this._camera.position.set(0, 200, 0), this._camera.zoom = 0.1, this._camera.rotation.x = -Math.PI / 2, this._plane = new O.Plane(this.down, 200), this.updatePlanes();
|
|
6010
6373
|
}
|
|
6374
|
+
/**
|
|
6375
|
+
* Gets or sets whether the minimap rotation is locked.
|
|
6376
|
+
* When rotation is locked, the minimap will always face the same direction as the camera.
|
|
6377
|
+
*/
|
|
6011
6378
|
get lockRotation() {
|
|
6012
6379
|
return this._lockRotation;
|
|
6013
6380
|
}
|
|
6381
|
+
/**
|
|
6382
|
+
* Sets whether the minimap rotation is locked.
|
|
6383
|
+
* When rotation is locked, the minimap will always face the same direction as the camera.
|
|
6384
|
+
* @param active - If `true`, rotation is locked. If `false`, rotation is not locked.
|
|
6385
|
+
*/
|
|
6014
6386
|
set lockRotation(s) {
|
|
6015
6387
|
this._lockRotation = s, s && (this._camera.rotation.z = 0);
|
|
6016
6388
|
}
|
|
6389
|
+
/**
|
|
6390
|
+
* Gets the current zoom level of the minimap.
|
|
6391
|
+
* The zoom level determines how much of the world is visible on the minimap.
|
|
6392
|
+
* @returns The current zoom level of the minimap.
|
|
6393
|
+
*/
|
|
6017
6394
|
get zoom() {
|
|
6018
6395
|
return this._camera.zoom;
|
|
6019
6396
|
}
|
|
6397
|
+
/**
|
|
6398
|
+
* Sets the zoom level of the minimap.
|
|
6399
|
+
* The zoom level determines how much of the world is visible on the minimap.
|
|
6400
|
+
* @param value - The new zoom level of the minimap.
|
|
6401
|
+
*/
|
|
6020
6402
|
set zoom(s) {
|
|
6021
6403
|
this._camera.zoom = s, this._camera.updateProjectionMatrix();
|
|
6022
6404
|
}
|
|
6405
|
+
/** {@link Disposable.dispose} */
|
|
6023
6406
|
dispose() {
|
|
6024
6407
|
this.enabled = !1, this.onBeforeUpdate.reset(), this.onAfterUpdate.reset(), this.onResize.reset(), this.overrideMaterial.dispose(), this.renderer.dispose(), this.onDisposed.trigger(), this.onDisposed.reset();
|
|
6025
6408
|
}
|
|
6409
|
+
/** Returns the camera used by the MiniMap */
|
|
6026
6410
|
get() {
|
|
6027
6411
|
return this._camera;
|
|
6028
6412
|
}
|
|
6413
|
+
/** {@link Updateable.update} */
|
|
6029
6414
|
update() {
|
|
6030
6415
|
if (!this.enabled)
|
|
6031
6416
|
return;
|
|
@@ -6033,7 +6418,7 @@ class zr {
|
|
|
6033
6418
|
const s = this.world.scene.three, t = this.world.camera;
|
|
6034
6419
|
if (!t.hasCameraControls())
|
|
6035
6420
|
throw new Error("The given world must use camera controls!");
|
|
6036
|
-
if (!(s instanceof
|
|
6421
|
+
if (!(s instanceof O.Scene))
|
|
6037
6422
|
throw new Error("The given world must have a THREE.Scene as a root!");
|
|
6038
6423
|
const e = t.controls;
|
|
6039
6424
|
if (e.getPosition(this._tempVector1), this._camera.position.x = this._tempVector1.x, this._camera.position.z = this._tempVector1.z, this.frontOffset !== 0 && (e.getTarget(this._tempVector2), this._tempVector2.sub(this._tempVector1), this._tempVector2.normalize().multiplyScalar(this.frontOffset), this._camera.position.x += this._tempVector2.x, this._camera.position.z += this._tempVector2.z), !this._lockRotation) {
|
|
@@ -6048,9 +6433,11 @@ class zr {
|
|
|
6048
6433
|
const i = s.background;
|
|
6049
6434
|
s.background = this.backgroundColor, this.renderer.render(s, this._camera), s.background = i, this.onAfterUpdate.trigger();
|
|
6050
6435
|
}
|
|
6436
|
+
/** {@link Resizeable.getSize} */
|
|
6051
6437
|
getSize() {
|
|
6052
6438
|
return this._size;
|
|
6053
6439
|
}
|
|
6440
|
+
/** {@link Resizeable.resize} */
|
|
6054
6441
|
resize(s = this._size) {
|
|
6055
6442
|
this._size.copy(s), this.renderer.setSize(s.x, s.y);
|
|
6056
6443
|
const t = s.x / s.y, e = 1;
|
|
@@ -6060,33 +6447,61 @@ class zr {
|
|
|
6060
6447
|
const _s = class _s extends J {
|
|
6061
6448
|
constructor(t) {
|
|
6062
6449
|
super(t);
|
|
6450
|
+
/** {@link Updateable.onAfterUpdate} */
|
|
6063
6451
|
I(this, "onAfterUpdate", new D());
|
|
6452
|
+
/** {@link Updateable.onBeforeUpdate} */
|
|
6064
6453
|
I(this, "onBeforeUpdate", new D());
|
|
6454
|
+
/** {@link Disposable.onDisposed} */
|
|
6065
6455
|
I(this, "onDisposed", new D());
|
|
6456
|
+
/** {@link Component.enabled} */
|
|
6066
6457
|
I(this, "enabled", !0);
|
|
6458
|
+
/**
|
|
6459
|
+
* A collection of {@link MiniMap} instances, each associated with a unique world ID.
|
|
6460
|
+
*/
|
|
6067
6461
|
I(this, "list", /* @__PURE__ */ new Map());
|
|
6068
6462
|
this.components.add(_s.uuid, this);
|
|
6069
6463
|
}
|
|
6464
|
+
/**
|
|
6465
|
+
* Creates a new {@link MiniMap} instance associated with the given world.
|
|
6466
|
+
* If a {@link MiniMap} instance already exists for the given world, an error will be thrown.
|
|
6467
|
+
*
|
|
6468
|
+
* @param world - The {@link World} for which to create a {@link MiniMap} instance.
|
|
6469
|
+
* @returns The newly created {@link MiniMap} instance.
|
|
6470
|
+
* @throws Will throw an error if a {@link MiniMap} instance already exists for the given world.
|
|
6471
|
+
*/
|
|
6070
6472
|
create(t) {
|
|
6071
6473
|
if (this.list.has(t.uuid))
|
|
6072
6474
|
throw new Error("This world already has a minimap!");
|
|
6073
6475
|
const e = new zr(t);
|
|
6074
6476
|
return this.list.set(t.uuid, e), e;
|
|
6075
6477
|
}
|
|
6478
|
+
/**
|
|
6479
|
+
* Deletes a {@link MiniMap} instance associated with the given world ID.
|
|
6480
|
+
* If a {@link MiniMap} instance does not exist for the given ID, nothing happens.
|
|
6481
|
+
*
|
|
6482
|
+
* @param id - The unique identifier of the world for which to delete the {@link MiniMap} instance.
|
|
6483
|
+
* @returns {void}
|
|
6484
|
+
*/
|
|
6076
6485
|
delete(t) {
|
|
6077
6486
|
const e = this.list.get(t);
|
|
6078
6487
|
e && e.dispose(), this.list.delete(t);
|
|
6079
6488
|
}
|
|
6489
|
+
/** {@link Disposable.dispose} */
|
|
6080
6490
|
dispose() {
|
|
6081
6491
|
for (const [t, e] of this.list)
|
|
6082
6492
|
e.dispose();
|
|
6083
6493
|
this.list.clear(), this.onDisposed.trigger();
|
|
6084
6494
|
}
|
|
6495
|
+
/** {@link Updateable.update} */
|
|
6085
6496
|
update() {
|
|
6086
6497
|
for (const [t, e] of this.list)
|
|
6087
6498
|
e.update();
|
|
6088
6499
|
}
|
|
6089
6500
|
};
|
|
6501
|
+
/**
|
|
6502
|
+
* A unique identifier for the component.
|
|
6503
|
+
* This UUID is used to register the component within the Components system.
|
|
6504
|
+
*/
|
|
6090
6505
|
I(_s, "uuid", "39ad6aad-84c8-4adf-a1e0-7f25313a9e7f");
|
|
6091
6506
|
let Fn = _s;
|
|
6092
6507
|
class Hr {
|
|
@@ -6108,7 +6523,7 @@ class Hr {
|
|
|
6108
6523
|
}
|
|
6109
6524
|
}
|
|
6110
6525
|
setupFirstPersonCamera() {
|
|
6111
|
-
const s = this.camera.controls, t = new
|
|
6526
|
+
const s = this.camera.controls, t = new O.Vector3();
|
|
6112
6527
|
s.distance--, s.getPosition(t), s.minDistance = 1, s.maxDistance = 1, s.distance = 1, s.moveTo(
|
|
6113
6528
|
t.x,
|
|
6114
6529
|
t.y,
|
|
@@ -6131,11 +6546,11 @@ class kr {
|
|
|
6131
6546
|
activateOrbitControls() {
|
|
6132
6547
|
const s = this.camera.controls;
|
|
6133
6548
|
s.minDistance = 1, s.maxDistance = 300;
|
|
6134
|
-
const t = new
|
|
6549
|
+
const t = new O.Vector3();
|
|
6135
6550
|
s.getPosition(t);
|
|
6136
6551
|
const e = t.length();
|
|
6137
6552
|
s.distance = e, s.truckSpeed = 2;
|
|
6138
|
-
const { rotation: i } = this.camera.three, o = new
|
|
6553
|
+
const { rotation: i } = this.camera.three, o = new O.Vector3(0, 0, -1).applyEuler(i), n = t.addScaledVector(o, e);
|
|
6139
6554
|
s.moveTo(n.x, n.y, n.z);
|
|
6140
6555
|
}
|
|
6141
6556
|
}
|
|
@@ -6165,12 +6580,20 @@ class Xr {
|
|
|
6165
6580
|
* Event that fires when the {@link CameraProjection} changes.
|
|
6166
6581
|
*/
|
|
6167
6582
|
I(this, "onChanged", new D());
|
|
6583
|
+
/**
|
|
6584
|
+
* Current projection mode of the camera.
|
|
6585
|
+
* Default is "Perspective".
|
|
6586
|
+
*/
|
|
6168
6587
|
I(this, "current", "Perspective");
|
|
6588
|
+
/**
|
|
6589
|
+
* The camera controlled by this ProjectionManager.
|
|
6590
|
+
* It can be either a PerspectiveCamera or an OrthographicCamera.
|
|
6591
|
+
*/
|
|
6169
6592
|
I(this, "camera");
|
|
6170
|
-
I(this, "_component");
|
|
6171
|
-
I(this, "_previousDistance", -1);
|
|
6172
6593
|
/** Match Ortho zoom with Perspective distance when changing projection mode */
|
|
6173
6594
|
I(this, "matchOrthoDistanceEnabled", !1);
|
|
6595
|
+
I(this, "_component");
|
|
6596
|
+
I(this, "_previousDistance", -1);
|
|
6174
6597
|
this._component = s, this.camera = s.three;
|
|
6175
6598
|
}
|
|
6176
6599
|
/**
|
|
@@ -6204,9 +6627,9 @@ class Xr {
|
|
|
6204
6627
|
const s = this._component.currentWorld;
|
|
6205
6628
|
if (!s || !s.renderer)
|
|
6206
6629
|
return null;
|
|
6207
|
-
const t = new
|
|
6630
|
+
const t = new O.Vector3();
|
|
6208
6631
|
this._component.threePersp.getWorldDirection(t);
|
|
6209
|
-
const e = new
|
|
6632
|
+
const e = new O.Vector3();
|
|
6210
6633
|
this._component.controls.getTarget(e);
|
|
6211
6634
|
const o = e.clone().sub(this._component.threePersp.position).dot(t), n = s.renderer.getSize(), r = n.x / n.y, a = this._component.threePersp, c = o * 2 * Math.atan(a.fov * (Math.PI / 180) / 2);
|
|
6212
6635
|
return { width: c * r, height: c };
|
|
@@ -6230,15 +6653,23 @@ class oa extends ke {
|
|
|
6230
6653
|
constructor(t) {
|
|
6231
6654
|
super(t);
|
|
6232
6655
|
/**
|
|
6233
|
-
*
|
|
6656
|
+
* A ProjectionManager instance that manages the projection modes of the camera.
|
|
6234
6657
|
*/
|
|
6235
|
-
I(this, "_mode", null);
|
|
6236
6658
|
I(this, "projection");
|
|
6659
|
+
/**
|
|
6660
|
+
* A THREE.OrthographicCamera instance that represents the orthographic camera.
|
|
6661
|
+
* This camera is used when the projection mode is set to orthographic.
|
|
6662
|
+
*/
|
|
6237
6663
|
I(this, "threeOrtho");
|
|
6664
|
+
/**
|
|
6665
|
+
* A THREE.PerspectiveCamera instance that represents the perspective camera.
|
|
6666
|
+
* This camera is used when the projection mode is set to perspective.
|
|
6667
|
+
*/
|
|
6238
6668
|
I(this, "threePersp");
|
|
6239
6669
|
I(this, "_userInputButtons", {});
|
|
6240
6670
|
I(this, "_frustumSize", 50);
|
|
6241
6671
|
I(this, "_navigationModes", /* @__PURE__ */ new Map());
|
|
6672
|
+
I(this, "_mode", null);
|
|
6242
6673
|
I(this, "previousSize", null);
|
|
6243
6674
|
this.threePersp = this.three, this.threeOrtho = this.newOrthoCamera(), this.projection = new Xr(this), this.onAspectUpdated.add(() => {
|
|
6244
6675
|
this.setOrthoPerspCameraAspect();
|
|
@@ -6250,6 +6681,14 @@ class oa extends ke {
|
|
|
6250
6681
|
e === "added" && (this._navigationModes.clear(), this._navigationModes.set("Orbit", new kr(this)), this._navigationModes.set("FirstPerson", new Hr(this)), this._navigationModes.set("Plan", new Wr(this)), this._mode = this._navigationModes.get("Orbit"), this.mode.set(!0, { preventTargetAdjustment: !0 }), this.currentWorld && this.currentWorld.renderer && (this.previousSize = this.currentWorld.renderer.getSize().clone()));
|
|
6251
6682
|
});
|
|
6252
6683
|
}
|
|
6684
|
+
/**
|
|
6685
|
+
* Getter for the current navigation mode.
|
|
6686
|
+
* Throws an error if the mode is not found or the camera is not initialized.
|
|
6687
|
+
*
|
|
6688
|
+
* @returns {NavigationMode} The current navigation mode.
|
|
6689
|
+
*
|
|
6690
|
+
* @throws {Error} Throws an error if the mode is not found or the camera is not initialized.
|
|
6691
|
+
*/
|
|
6253
6692
|
get mode() {
|
|
6254
6693
|
if (!this._mode)
|
|
6255
6694
|
throw new Error("Mode not found, camera not initialized");
|
|
@@ -6281,16 +6720,16 @@ class oa extends ke {
|
|
|
6281
6720
|
async fit(t, e = 1.5) {
|
|
6282
6721
|
if (!this.enabled)
|
|
6283
6722
|
return;
|
|
6284
|
-
const i = Number.MAX_VALUE, o = Number.MIN_VALUE, n = new
|
|
6723
|
+
const i = Number.MAX_VALUE, o = Number.MIN_VALUE, n = new O.Vector3(i, i, i), r = new O.Vector3(o, o, o);
|
|
6285
6724
|
for (const u of t) {
|
|
6286
|
-
const p = new
|
|
6725
|
+
const p = new O.Box3().setFromObject(u);
|
|
6287
6726
|
p.min.x < n.x && (n.x = p.min.x), p.min.y < n.y && (n.y = p.min.y), p.min.z < n.z && (n.z = p.min.z), p.max.x > r.x && (r.x = p.max.x), p.max.y > r.y && (r.y = p.max.y), p.max.z > r.z && (r.z = p.max.z);
|
|
6288
6727
|
}
|
|
6289
|
-
const a = new
|
|
6728
|
+
const a = new O.Box3(n, r), c = new O.Vector3();
|
|
6290
6729
|
a.getSize(c);
|
|
6291
|
-
const h = new
|
|
6730
|
+
const h = new O.Vector3();
|
|
6292
6731
|
a.getCenter(h);
|
|
6293
|
-
const d = Math.max(c.x, c.y, c.z) * e, E = new
|
|
6732
|
+
const d = Math.max(c.x, c.y, c.z) * e, E = new O.Sphere(h, d);
|
|
6294
6733
|
await this.controls.fitToSphere(E, !0);
|
|
6295
6734
|
}
|
|
6296
6735
|
/**
|
|
@@ -6309,7 +6748,7 @@ class oa extends ke {
|
|
|
6309
6748
|
}
|
|
6310
6749
|
newOrthoCamera() {
|
|
6311
6750
|
const t = window.innerWidth / window.innerHeight;
|
|
6312
|
-
return new
|
|
6751
|
+
return new O.OrthographicCamera(
|
|
6313
6752
|
this._frustumSize * t / -2,
|
|
6314
6753
|
this._frustumSize * t / 2,
|
|
6315
6754
|
this._frustumSize / 2,
|
|
@@ -6338,12 +6777,12 @@ const At = class At extends J {
|
|
|
6338
6777
|
this.components.add(At.uuid, this), this._absoluteMin = At.newBound(!0), this._absoluteMax = At.newBound(!1);
|
|
6339
6778
|
}
|
|
6340
6779
|
static getDimensions(t) {
|
|
6341
|
-
const { min: e, max: i } = t, o = Math.abs(i.x - e.x), n = Math.abs(i.y - e.y), r = Math.abs(i.z - e.z), a = new
|
|
6780
|
+
const { min: e, max: i } = t, o = Math.abs(i.x - e.x), n = Math.abs(i.y - e.y), r = Math.abs(i.z - e.z), a = new O.Vector3();
|
|
6342
6781
|
return a.subVectors(i, e).divideScalar(2).add(e), { width: o, height: n, depth: r, center: a };
|
|
6343
6782
|
}
|
|
6344
6783
|
static newBound(t) {
|
|
6345
6784
|
const e = t ? 1 : -1;
|
|
6346
|
-
return new
|
|
6785
|
+
return new O.Vector3(
|
|
6347
6786
|
e * Number.MAX_VALUE,
|
|
6348
6787
|
e * Number.MAX_VALUE,
|
|
6349
6788
|
e * Number.MAX_VALUE
|
|
@@ -6353,7 +6792,7 @@ const At = class At extends J {
|
|
|
6353
6792
|
const o = i || this.newBound(!1), n = e || this.newBound(!0);
|
|
6354
6793
|
for (const r of t)
|
|
6355
6794
|
r.x < n.x && (n.x = r.x), r.y < n.y && (n.y = r.y), r.z < n.z && (n.z = r.z), r.x > o.x && (o.x = r.x), r.y > o.y && (o.y = r.y), r.z > o.z && (o.z = r.z);
|
|
6356
|
-
return new
|
|
6795
|
+
return new O.Box3(e, i);
|
|
6357
6796
|
}
|
|
6358
6797
|
/** {@link Disposable.dispose} */
|
|
6359
6798
|
dispose() {
|
|
@@ -6364,14 +6803,14 @@ const At = class At extends J {
|
|
|
6364
6803
|
}
|
|
6365
6804
|
get() {
|
|
6366
6805
|
const t = this._absoluteMin.clone(), e = this._absoluteMax.clone();
|
|
6367
|
-
return new
|
|
6806
|
+
return new O.Box3(t, e);
|
|
6368
6807
|
}
|
|
6369
6808
|
getSphere() {
|
|
6370
|
-
const t = this._absoluteMin.clone(), e = this._absoluteMax.clone(), i = Math.abs((e.x - t.x) / 2), o = Math.abs((e.y - t.y) / 2), n = Math.abs((e.z - t.z) / 2), r = new
|
|
6371
|
-
return new
|
|
6809
|
+
const t = this._absoluteMin.clone(), e = this._absoluteMax.clone(), i = Math.abs((e.x - t.x) / 2), o = Math.abs((e.y - t.y) / 2), n = Math.abs((e.z - t.z) / 2), r = new O.Vector3(t.x + i, t.y + o, t.z + n), a = r.distanceTo(t);
|
|
6810
|
+
return new O.Sphere(r, a);
|
|
6372
6811
|
}
|
|
6373
6812
|
getMesh() {
|
|
6374
|
-
const t = new
|
|
6813
|
+
const t = new O.Box3(this._absoluteMin, this._absoluteMax), e = At.getDimensions(t), { width: i, height: o, depth: n, center: r } = e, a = new O.BoxGeometry(i, o, n), c = new O.Mesh(a);
|
|
6375
6814
|
return this._meshes.push(c), c.position.copy(r), c;
|
|
6376
6815
|
}
|
|
6377
6816
|
reset() {
|
|
@@ -6386,7 +6825,7 @@ const At = class At extends J {
|
|
|
6386
6825
|
return;
|
|
6387
6826
|
const i = At.getFragmentBounds(t);
|
|
6388
6827
|
t.updateMatrixWorld();
|
|
6389
|
-
const o = t.matrixWorld, n = new
|
|
6828
|
+
const o = t.matrixWorld, n = new O.Matrix4(), r = t instanceof O.InstancedMesh, a = /* @__PURE__ */ new Set();
|
|
6390
6829
|
if (e && t instanceof Vt.FragmentMesh)
|
|
6391
6830
|
for (const c of e) {
|
|
6392
6831
|
const h = t.fragment.getInstancesIDs(c);
|
|
@@ -6402,7 +6841,7 @@ const At = class At extends J {
|
|
|
6402
6841
|
}
|
|
6403
6842
|
}
|
|
6404
6843
|
static getFragmentBounds(t) {
|
|
6405
|
-
const e = t.geometry.attributes.position, i = Number.MAX_VALUE, o = -i, n = new
|
|
6844
|
+
const e = t.geometry.attributes.position, i = Number.MAX_VALUE, o = -i, n = new O.Vector3(i, i, i), r = new O.Vector3(o, o, o);
|
|
6406
6845
|
if (!t.geometry.index)
|
|
6407
6846
|
throw new Error("Geometry must be indexed!");
|
|
6408
6847
|
const a = Array.from(t.geometry.index.array);
|
|
@@ -6414,11 +6853,11 @@ const At = class At extends J {
|
|
|
6414
6853
|
const h = a[c], d = e.getX(h), E = e.getY(h), u = e.getZ(h);
|
|
6415
6854
|
d < n.x && (n.x = d), E < n.y && (n.y = E), u < n.z && (n.z = u), d > r.x && (r.x = d), E > r.y && (r.y = E), u > r.z && (r.z = u);
|
|
6416
6855
|
}
|
|
6417
|
-
return new
|
|
6856
|
+
return new O.Box3(n, r);
|
|
6418
6857
|
}
|
|
6419
6858
|
};
|
|
6420
6859
|
I(At, "uuid", "d1444724-dba6-4cdd-a0c7-68ee1450d166");
|
|
6421
|
-
let
|
|
6860
|
+
let gn = At;
|
|
6422
6861
|
const Li = /* @__PURE__ */ new Set([
|
|
6423
6862
|
1123145078,
|
|
6424
6863
|
574549367,
|
|
@@ -6653,6 +7092,46 @@ const Ps = class Ps extends J {
|
|
|
6653
7092
|
export(t) {
|
|
6654
7093
|
return this._loader.export(t);
|
|
6655
7094
|
}
|
|
7095
|
+
/**
|
|
7096
|
+
* Gets a map of model IDs to sets of express IDs for the given fragment ID map.
|
|
7097
|
+
* @param fragmentIdMap - A map of fragment IDs to their corresponding express IDs.
|
|
7098
|
+
* @returns A map of model IDs to sets of express IDs.
|
|
7099
|
+
*/
|
|
7100
|
+
getModelIdMap(t) {
|
|
7101
|
+
const e = {};
|
|
7102
|
+
for (const i in t) {
|
|
7103
|
+
const o = this.list.get(i);
|
|
7104
|
+
if (!(o && o.group))
|
|
7105
|
+
continue;
|
|
7106
|
+
const n = o.group;
|
|
7107
|
+
n.uuid in e || (e[n.uuid] = /* @__PURE__ */ new Set());
|
|
7108
|
+
const r = t[i];
|
|
7109
|
+
for (const a of r)
|
|
7110
|
+
e[n.uuid].add(a);
|
|
7111
|
+
}
|
|
7112
|
+
return e;
|
|
7113
|
+
}
|
|
7114
|
+
/**
|
|
7115
|
+
* Converts a map of model IDs to sets of express IDs to a fragment ID map.
|
|
7116
|
+
* @param modelIdMap - A map of model IDs to their corresponding express IDs.
|
|
7117
|
+
* @returns A fragment ID map.
|
|
7118
|
+
* @remarks
|
|
7119
|
+
* This method iterates through the provided model ID map, retrieves the corresponding model from the `groups` map,
|
|
7120
|
+
* and then calls the `getFragmentMap` method of the model to obtain a fragment ID map for the given express IDs.
|
|
7121
|
+
* The fragment ID maps are then merged into a single map and returned.
|
|
7122
|
+
* If a model with a given ID is not found in the `groups` map, the method skips that model and continues with the next one.
|
|
7123
|
+
*/
|
|
7124
|
+
modelIdToFragmentIdMap(t) {
|
|
7125
|
+
let e = {};
|
|
7126
|
+
for (const i in t) {
|
|
7127
|
+
const o = this.groups.get(i);
|
|
7128
|
+
if (!o)
|
|
7129
|
+
continue;
|
|
7130
|
+
const n = t[i], r = o.getFragmentMap(n);
|
|
7131
|
+
e = { ...e, ...r };
|
|
7132
|
+
}
|
|
7133
|
+
return e;
|
|
7134
|
+
}
|
|
6656
7135
|
coordinate(t = Array.from(this.groups.values())) {
|
|
6657
7136
|
if (this.baseCoordinationModel.length === 0) {
|
|
6658
7137
|
const o = t.pop();
|
|
@@ -8448,7 +8927,7 @@ class jr {
|
|
|
8448
8927
|
}
|
|
8449
8928
|
getScaleMatrix() {
|
|
8450
8929
|
const s = this.factor;
|
|
8451
|
-
return new
|
|
8930
|
+
return new O.Matrix4().fromArray([
|
|
8452
8931
|
s,
|
|
8453
8932
|
0,
|
|
8454
8933
|
0,
|
|
@@ -8570,7 +9049,7 @@ class yi {
|
|
|
8570
9049
|
}
|
|
8571
9050
|
class Vn {
|
|
8572
9051
|
constructor() {
|
|
8573
|
-
I(this, "defLineMat", new
|
|
9052
|
+
I(this, "defLineMat", new O.LineBasicMaterial({ color: 16777215 }));
|
|
8574
9053
|
}
|
|
8575
9054
|
read(s) {
|
|
8576
9055
|
const t = s.GetAllAlignments(0), e = s.GetAllCrossSections2D(0), i = s.GetAllCrossSections3D(0), o = {
|
|
@@ -8587,7 +9066,7 @@ class Vn {
|
|
|
8587
9066
|
const i = new Vt.Alignment();
|
|
8588
9067
|
i.absolute = this.getCurves(e.curve3D, i), i.horizontal = this.getCurves(e.horizontal, i), i.vertical = this.getCurves(e.vertical, i), t.set(t.size, i);
|
|
8589
9068
|
}
|
|
8590
|
-
return { alignments: t, coordinationMatrix: new
|
|
9069
|
+
return { alignments: t, coordinationMatrix: new O.Matrix4() };
|
|
8591
9070
|
}
|
|
8592
9071
|
}
|
|
8593
9072
|
getCurves(s, t) {
|
|
@@ -8605,7 +9084,7 @@ class Vn {
|
|
|
8605
9084
|
const { x: u, y: p, z: A } = r[E];
|
|
8606
9085
|
a[E * 3] = u, a[E * 3 + 1] = p, a[E * 3 + 2] = A || 0;
|
|
8607
9086
|
}
|
|
8608
|
-
const c = new
|
|
9087
|
+
const c = new O.BufferAttribute(a, 3), h = new O.EdgesGeometry();
|
|
8609
9088
|
h.setAttribute("position", c);
|
|
8610
9089
|
const d = new Vt.CurveMesh(
|
|
8611
9090
|
i,
|
|
@@ -8664,13 +9143,13 @@ const Ge = class Ge extends J {
|
|
|
8664
9143
|
I(this, "settings", new yi());
|
|
8665
9144
|
I(this, "enabled", !0);
|
|
8666
9145
|
I(this, "webIfc", new U.IfcAPI());
|
|
8667
|
-
I(this, "_material", new
|
|
9146
|
+
I(this, "_material", new O.MeshLambertMaterial());
|
|
8668
9147
|
I(this, "_spatialTree", new Yn());
|
|
8669
9148
|
I(this, "_metaData", new Gn());
|
|
8670
9149
|
I(this, "_fragmentInstances", /* @__PURE__ */ new Map());
|
|
8671
9150
|
I(this, "_civil", new Vn());
|
|
8672
9151
|
I(this, "_visitedFragments", /* @__PURE__ */ new Map());
|
|
8673
|
-
I(this, "_materialT", new
|
|
9152
|
+
I(this, "_materialT", new O.MeshLambertMaterial({
|
|
8674
9153
|
transparent: !0,
|
|
8675
9154
|
opacity: 0.5
|
|
8676
9155
|
}));
|
|
@@ -8747,12 +9226,12 @@ const Ge = class Ge extends J {
|
|
|
8747
9226
|
for (let n = 0; n < i; n++) {
|
|
8748
9227
|
const r = t.geometries.get(n), { x: a, y: c, z: h, w: d } = r.color, E = d !== 1, { geometryExpressID: u } = r, p = `${u}-${E}`;
|
|
8749
9228
|
if (!this._visitedFragments.has(p)) {
|
|
8750
|
-
const T = this.getGeometry(this.webIfc, u),
|
|
9229
|
+
const T = this.getGeometry(this.webIfc, u), g = E ? this._materialT : this._material, S = new Vt.Fragment(T, g, 1);
|
|
8751
9230
|
e.add(S.mesh), e.items.push(S);
|
|
8752
9231
|
const _ = this._visitedFragments.size;
|
|
8753
9232
|
this._visitedFragments.set(p, { index: _, fragment: S });
|
|
8754
9233
|
}
|
|
8755
|
-
const A = new
|
|
9234
|
+
const A = new O.Color().setRGB(a, c, h, "srgb"), m = new O.Matrix4();
|
|
8756
9235
|
m.fromArray(r.flatTransformation);
|
|
8757
9236
|
const C = this._visitedFragments.get(p);
|
|
8758
9237
|
if (C === void 0)
|
|
@@ -8785,7 +9264,7 @@ const Ge = class Ge extends J {
|
|
|
8785
9264
|
), r = new Float32Array(n.length / 2), a = new Float32Array(n.length / 2);
|
|
8786
9265
|
for (let E = 0; E < n.length; E += 6)
|
|
8787
9266
|
r[E / 2] = n[E], r[E / 2 + 1] = n[E + 1], r[E / 2 + 2] = n[E + 2], a[E / 2] = n[E + 3], a[E / 2 + 1] = n[E + 4], a[E / 2 + 2] = n[E + 5];
|
|
8788
|
-
const c = new
|
|
9267
|
+
const c = new O.BufferGeometry(), h = new O.BufferAttribute(r, 3), d = new O.BufferAttribute(a, 3);
|
|
8789
9268
|
return c.setAttribute("position", h), c.setAttribute("normal", d), c.setIndex(Array.from(o)), i.delete(), c;
|
|
8790
9269
|
}
|
|
8791
9270
|
async autoSetWasm() {
|
|
@@ -8997,7 +9476,7 @@ const Bt = class Bt extends J {
|
|
|
8997
9476
|
}
|
|
8998
9477
|
};
|
|
8999
9478
|
I(Bt, "uuid", "58c2d9f0-183c-48d6-a402-dfcf5b9a34df");
|
|
9000
|
-
let
|
|
9479
|
+
let On = Bt;
|
|
9001
9480
|
const Ls = class Ls extends J {
|
|
9002
9481
|
constructor(t) {
|
|
9003
9482
|
super(t);
|
|
@@ -9218,7 +9697,7 @@ const ys = class ys extends J {
|
|
|
9218
9697
|
return;
|
|
9219
9698
|
const e = this.components.get(Ai), i = this.components.get(ut), o = t ? 1 : -1;
|
|
9220
9699
|
let n = 0;
|
|
9221
|
-
const r = e.list[this.groupName], a = new
|
|
9700
|
+
const r = e.list[this.groupName], a = new O.Matrix4();
|
|
9222
9701
|
for (const c in r) {
|
|
9223
9702
|
a.elements[13] = n * o * this.height;
|
|
9224
9703
|
for (const h in r[c]) {
|
|
@@ -9496,8 +9975,8 @@ const Ms = class Ms extends J {
|
|
|
9496
9975
|
const c = e.geometries.get(a), h = c.geometryExpressID, d = c.color.w === 1 ? 1 : -1, E = h * d;
|
|
9497
9976
|
if (!this._visitedGeometries.has(E)) {
|
|
9498
9977
|
this._visitedGeometries.has(h) || this.getGeometry(t, h);
|
|
9499
|
-
const T = this._visitedGeometries.size,
|
|
9500
|
-
this._visitedGeometries.set(E, { uuid:
|
|
9978
|
+
const T = this._visitedGeometries.size, g = O.MathUtils.generateUUID();
|
|
9979
|
+
this._visitedGeometries.set(E, { uuid: g, index: T });
|
|
9501
9980
|
}
|
|
9502
9981
|
const u = this._visitedGeometries.get(E);
|
|
9503
9982
|
if (u === void 0)
|
|
@@ -9663,14 +10142,14 @@ const Ds = class Ds extends J {
|
|
|
9663
10142
|
const p = /* @__PURE__ */ new Map();
|
|
9664
10143
|
for (const { id: T } of u)
|
|
9665
10144
|
if (h.has(T)) {
|
|
9666
|
-
const
|
|
9667
|
-
p.set(T,
|
|
10145
|
+
const g = h.get(T);
|
|
10146
|
+
p.set(T, g);
|
|
9668
10147
|
}
|
|
9669
10148
|
const A = u.map((T) => T.id);
|
|
9670
10149
|
if (!p.size) {
|
|
9671
10150
|
const T = c++;
|
|
9672
|
-
for (const { id:
|
|
9673
|
-
h.set(
|
|
10151
|
+
for (const { id: g } of u)
|
|
10152
|
+
h.set(g, T);
|
|
9674
10153
|
d.set(T, {
|
|
9675
10154
|
edges: new Set(A),
|
|
9676
10155
|
indices: /* @__PURE__ */ new Set([E])
|
|
@@ -9679,9 +10158,9 @@ const Ds = class Ds extends J {
|
|
|
9679
10158
|
}
|
|
9680
10159
|
let m = null;
|
|
9681
10160
|
const C = /* @__PURE__ */ new Set(), R = new Set(A);
|
|
9682
|
-
for (const [T,
|
|
9683
|
-
m === null ? m =
|
|
9684
|
-
const { edges: S } = d.get(
|
|
10161
|
+
for (const [T, g] of p) {
|
|
10162
|
+
m === null ? m = g : g !== m && C.add(g), h.delete(T);
|
|
10163
|
+
const { edges: S } = d.get(g);
|
|
9685
10164
|
S.delete(T), R.delete(T);
|
|
9686
10165
|
}
|
|
9687
10166
|
if (m === null)
|
|
@@ -9690,11 +10169,11 @@ const Ds = class Ds extends J {
|
|
|
9690
10169
|
f.add(E);
|
|
9691
10170
|
for (const T of R) {
|
|
9692
10171
|
h.set(T, m);
|
|
9693
|
-
const { edges:
|
|
9694
|
-
|
|
10172
|
+
const { edges: g } = F;
|
|
10173
|
+
g.add(T);
|
|
9695
10174
|
}
|
|
9696
10175
|
for (const T of C) {
|
|
9697
|
-
const
|
|
10176
|
+
const g = d.get(T), { edges: S, indices: _ } = g, N = d.get(m), { edges: L, indices: M } = N;
|
|
9698
10177
|
for (const y of S)
|
|
9699
10178
|
L.add(y), h.set(y, m);
|
|
9700
10179
|
for (const y of _)
|
|
@@ -9714,7 +10193,7 @@ const Ds = class Ds extends J {
|
|
|
9714
10193
|
return null;
|
|
9715
10194
|
}
|
|
9716
10195
|
static distanceFromPointToLine(t, e, i, o = !1) {
|
|
9717
|
-
const n = new
|
|
10196
|
+
const n = new O.Line3(), r = new O.Vector3();
|
|
9718
10197
|
return n.set(e, i), n.closestPointToPoint(t, o, r), r.distanceTo(t);
|
|
9719
10198
|
}
|
|
9720
10199
|
getFaceData(t, e, i) {
|
|
@@ -9746,18 +10225,18 @@ const Ds = class Ds extends J {
|
|
|
9746
10225
|
distance: E.distanceTo(m),
|
|
9747
10226
|
points: [E, m]
|
|
9748
10227
|
}
|
|
9749
|
-
], R = new
|
|
10228
|
+
], R = new O.Plane();
|
|
9750
10229
|
return R.setFromNormalAndCoplanarPoint(c, n), R.constant = Math.round(R.constant * 10) / 10, { plane: R, edges: C };
|
|
9751
10230
|
}
|
|
9752
10231
|
getVerticesAndNormal(t, e, i) {
|
|
9753
10232
|
if (!t.geometry.index)
|
|
9754
10233
|
throw new Error("Geometry must be indexed!");
|
|
9755
|
-
const o = t.geometry.index.array, n = t.geometry.attributes.position.array, r = t.geometry.attributes.normal.array, a = o[e * 3] * 3, c = o[e * 3 + 1] * 3, h = o[e * 3 + 2] * 3, d = new
|
|
9756
|
-
if (i !== void 0 && t instanceof
|
|
9757
|
-
const T = new
|
|
10234
|
+
const o = t.geometry.index.array, n = t.geometry.attributes.position.array, r = t.geometry.attributes.normal.array, a = o[e * 3] * 3, c = o[e * 3 + 1] * 3, h = o[e * 3 + 2] * 3, d = new O.Vector3(n[a], n[a + 1], n[a + 2]), E = new O.Vector3(n[c], n[c + 1], n[c + 2]), u = new O.Vector3(n[h], n[h + 1], n[h + 2]), p = new O.Vector3(r[a], r[a + 1], r[a + 2]), A = new O.Vector3(r[c], r[c + 1], r[c + 2]), m = new O.Vector3(r[h], r[h + 1], r[h + 2]), C = (p.x + A.x + m.x) / 3, R = (p.y + A.y + m.y) / 3, F = (p.z + A.z + m.z) / 3, f = new O.Vector3(C, R, F);
|
|
10235
|
+
if (i !== void 0 && t instanceof O.InstancedMesh) {
|
|
10236
|
+
const T = new O.Matrix4();
|
|
9758
10237
|
t.getMatrixAt(i, T);
|
|
9759
|
-
const
|
|
9760
|
-
|
|
10238
|
+
const g = new O.Matrix4();
|
|
10239
|
+
g.extractRotation(T), f.applyMatrix4(g), d.applyMatrix4(T), E.applyMatrix4(T), u.applyMatrix4(T);
|
|
9761
10240
|
}
|
|
9762
10241
|
return { p1: d, p2: E, p3: u, faceNormal: f };
|
|
9763
10242
|
}
|
|
@@ -9774,7 +10253,7 @@ export {
|
|
|
9774
10253
|
lr as BaseRenderer,
|
|
9775
10254
|
hr as BaseScene,
|
|
9776
10255
|
Ni as BaseWorldItem,
|
|
9777
|
-
|
|
10256
|
+
gn as BoundingBoxer,
|
|
9778
10257
|
Ai as Classifier,
|
|
9779
10258
|
An as Clipper,
|
|
9780
10259
|
J as Component,
|
|
@@ -9795,7 +10274,7 @@ export {
|
|
|
9795
10274
|
Nn as IfcGeometryTiler,
|
|
9796
10275
|
mi as IfcJsonExporter,
|
|
9797
10276
|
Ri as IfcLoader,
|
|
9798
|
-
|
|
10277
|
+
On as IfcPropertiesManager,
|
|
9799
10278
|
Kr as IfcPropertiesTiler,
|
|
9800
10279
|
Kt as IfcPropertiesUtils,
|
|
9801
10280
|
We as IfcRelationsIndexer,
|
|
@@ -9814,7 +10293,7 @@ export {
|
|
|
9814
10293
|
Pi as SimplePlane,
|
|
9815
10294
|
na as SimpleRenderer,
|
|
9816
10295
|
ia as SimpleScene,
|
|
9817
|
-
|
|
10296
|
+
gr as SimpleWorld,
|
|
9818
10297
|
ze as UUID,
|
|
9819
10298
|
sa as VertexPicker,
|
|
9820
10299
|
Ci as Worlds,
|