u-space 0.0.32 → 0.0.33
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/index.cjs +3 -3
- package/dist/index.js +1174 -938
- package/dist/modelDecodeProtocol-CC2tkS8h.js +405 -0
- package/dist/modelDecodeProtocol-pgjndTph.cjs +1 -0
- package/dist/src/loaders/ModelLoaderManager.d.ts +13 -1
- package/dist/src/loaders/modelPersistentCache.d.ts +35 -0
- package/dist/src/objects/Model.d.ts +4 -0
- package/dist/src/worker/decodeGltfModel.d.ts +7 -1
- package/dist/src/worker/modelDecodeProtocol.d.ts +2 -0
- package/dist/worker/model-decoder.cjs +1 -1
- package/dist/worker/model-decoder.js +231 -205
- package/docs/api-objects.md +11 -2
- package/docs/changelog.md +7 -0
- package/docs/examples-guide.md +2 -2
- package/docs/getting-started.md +1 -1
- package/package.json +1 -1
- package/dist/modelDecodeProtocol-D1Apm9iG.cjs +0 -1
- package/dist/modelDecodeProtocol-wDB7ksYw.js +0 -56
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
import { C as
|
|
3
|
-
import { EventDispatcher as
|
|
4
|
-
import { GLTFLoader as
|
|
5
|
-
import { FBXLoader as
|
|
6
|
-
import { OBJLoader as
|
|
7
|
-
import { STLLoader as
|
|
8
|
-
import { DRACOLoader as
|
|
9
|
-
import { KTX2Loader as
|
|
10
|
-
import { MeshoptDecoder as
|
|
11
|
-
import { M as
|
|
12
|
-
import { HDRLoader as
|
|
13
|
-
import { clone as
|
|
14
|
-
import { color as
|
|
15
|
-
import { outline as
|
|
16
|
-
import { Easing as
|
|
17
|
-
import { mergeGeometries as
|
|
18
|
-
import { CSS2DObject as
|
|
19
|
-
import { CSS3DObject as
|
|
20
|
-
class
|
|
1
|
+
import { g as Gt } from "./Viewer-Cs_y7IiH.js";
|
|
2
|
+
import { C as Pi, a as Di, I as Ui, b as ki, O as zi, R as ji, c as Wi, V as Fi, e as Gi } from "./Viewer-Cs_y7IiH.js";
|
|
3
|
+
import { EventDispatcher as fs, Vector2 as j, Box2 as ms, Matrix4 as D, Vector3 as N, Scene as gs, Color as P, AmbientLight as ys, DirectionalLight as He, PointLight as $e, SpotLight as Ke, HemisphereLight as qe, DirectionalLightHelper as bs, PointLightHelper as ws, SpotLightHelper as xs, HemisphereLightHelper as Ms, MeshStandardNodeMaterial as X, Loader as vs, LoaderUtils as de, FileLoader as Ht, TextureLoader as $t, Group as F, SRGBColorSpace as Ie, RepeatWrapping as Ce, BufferGeometry as q, BufferAttribute as Ue, Mesh as k, FrontSide as Ss, BackSide as Es, DoubleSide as Kt, InterleavedBufferAttribute as Ve, MeshStandardMaterial as Is, LinearSRGBColorSpace as Xe, InterleavedBuffer as Cs, Texture as qt, NearestFilter as Ae, LinearFilter as Ye, LinearMipmapLinearFilter as As, NearestMipmapLinearFilter as Os, LinearMipmapNearestFilter as Bs, NearestMipmapNearestFilter as _s, MirroredRepeatWrapping as Qe, ClampToEdgeWrapping as Je, NoColorSpace as me, REVISION as Ze, LoadingManager as Ls, CubeTextureLoader as Ts, EquirectangularReflectionMapping as Rs, Sprite as Ns, AnimationMixer as Ps, LoopRepeat as Ds, LoopOnce as Us, Box3 as V, SphereGeometry as ks, TubeGeometry as zs, LineCurve3 as js, CatmullRomCurve3 as Ws, SpriteNodeMaterial as Fs, CanvasTexture as Gs, ShapeGeometry as Hs, Shape as Vt, ExtrudeGeometry as $s, PlaneGeometry as Ks, CircleGeometry as qs, Quaternion as Vs, BoxGeometry as Xs, MeshBasicNodeMaterial as Ys, ClippingGroup as Qs, Plane as Js, PlaneHelper as Zs, LineBasicMaterial as we, Line as xe, Object3D as en, Sphere as re, Float32BufferAttribute as tn, SkinnedMesh as sn, DataTexture as nn, RGBAFormat as rn, FloatType as an, Frustum as on, InstancedBufferAttribute as et, DynamicDrawUsage as Re, InstancedMesh as cn, StorageInstancedBufferAttribute as ln } from "three/webgpu";
|
|
4
|
+
import { GLTFLoader as ke } from "three/addons/loaders/GLTFLoader.js";
|
|
5
|
+
import { FBXLoader as tt } from "three/addons/loaders/FBXLoader.js";
|
|
6
|
+
import { OBJLoader as hn } from "three/addons/loaders/OBJLoader.js";
|
|
7
|
+
import { STLLoader as dn } from "three/addons/loaders/STLLoader.js";
|
|
8
|
+
import { DRACOLoader as un } from "three/addons/loaders/DRACOLoader.js";
|
|
9
|
+
import { KTX2Loader as pn } from "three/addons/loaders/KTX2Loader.js";
|
|
10
|
+
import { MeshoptDecoder as Ne } from "three/addons/libs/meshopt_decoder.module.js";
|
|
11
|
+
import { M as st, v as fn, U as Xt, c as mn, d as ge, l as nt, m as gn } from "./modelDecodeProtocol-CC2tkS8h.js";
|
|
12
|
+
import { HDRLoader as yn } from "three/addons/loaders/HDRLoader.js";
|
|
13
|
+
import { clone as Ge } from "three/addons/utils/SkeletonUtils.js";
|
|
14
|
+
import { color as Q, uv as rt, time as Me, pow as ve, sin as ze, mix as Se, mx_noise_float as it, uniform as oe, add as bn, vec4 as wn, Fn as Yt, userData as G, materialColor as Oe, select as K, materialOpacity as je, vec3 as xn, attribute as Mn, int as at, textureSize as vn, textureLoad as ot, ivec2 as Sn, instancedBufferAttribute as ct, float as En } from "three/tsl";
|
|
15
|
+
import { outline as In } from "three/addons/tsl/display/OutlineNode.js";
|
|
16
|
+
import { Easing as L, Tween as Cn } from "three/addons/libs/tween.module.js";
|
|
17
|
+
import { mergeGeometries as An } from "three/addons/utils/BufferGeometryUtils.js";
|
|
18
|
+
import { CSS2DObject as $i } from "three/addons/renderers/CSS2DRenderer.js";
|
|
19
|
+
import { CSS3DObject as qi, CSS3DSprite as Vi } from "three/addons/renderers/CSS3DRenderer.js";
|
|
20
|
+
class mi extends fs {
|
|
21
21
|
scene;
|
|
22
22
|
camera;
|
|
23
23
|
domElement;
|
|
@@ -133,27 +133,27 @@ class si extends hs {
|
|
|
133
133
|
), r = new j(
|
|
134
134
|
this._endPoint.x / t * 2 - 1,
|
|
135
135
|
-(this._endPoint.y / s) * 2 + 1
|
|
136
|
-
), a = new
|
|
136
|
+
), a = new ms(
|
|
137
137
|
new j(Math.min(n.x, r.x), Math.min(n.y, r.y)),
|
|
138
138
|
new j(Math.max(n.x, r.x), Math.max(n.y, r.y))
|
|
139
|
-
), o = this.targetObjects || this.scene.children, c = [], l = new
|
|
139
|
+
), o = this.targetObjects || this.scene.children, c = [], l = new D();
|
|
140
140
|
l.multiplyMatrices(this.camera.projectionMatrix, this.camera.matrixWorldInverse);
|
|
141
|
-
const h = (
|
|
142
|
-
if (!
|
|
143
|
-
const
|
|
144
|
-
if (
|
|
145
|
-
for (const p of
|
|
141
|
+
const h = (u) => {
|
|
142
|
+
if (!u.visible) return;
|
|
143
|
+
const d = new N();
|
|
144
|
+
if (d.setFromMatrixPosition(u.matrixWorld), d.applyMatrix4(l), d.z > -1 && d.z < 1 && a.containsPoint(new j(d.x, d.y)) && c.push(u), this._deep)
|
|
145
|
+
for (const p of u.children)
|
|
146
146
|
h(p);
|
|
147
147
|
};
|
|
148
|
-
for (const
|
|
149
|
-
h(
|
|
148
|
+
for (const u of o)
|
|
149
|
+
h(u);
|
|
150
150
|
return c;
|
|
151
151
|
}
|
|
152
152
|
dispose() {
|
|
153
153
|
this.disableBoxSelection(), this._selected.clear();
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
class
|
|
156
|
+
class gi {
|
|
157
157
|
scenes = /* @__PURE__ */ new Map();
|
|
158
158
|
_activeSceneKey = null;
|
|
159
159
|
/**
|
|
@@ -166,7 +166,7 @@ class ni {
|
|
|
166
166
|
* Create and register a new scene.
|
|
167
167
|
*/
|
|
168
168
|
create(e, t = {}) {
|
|
169
|
-
const s = new
|
|
169
|
+
const s = new gs();
|
|
170
170
|
return t.background !== void 0 && (s.background = new P(t.background)), this.scenes.set(e, s), s;
|
|
171
171
|
}
|
|
172
172
|
/**
|
|
@@ -227,7 +227,7 @@ class ni {
|
|
|
227
227
|
return this.scenes.size;
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
|
-
class
|
|
230
|
+
class yi {
|
|
231
231
|
scene;
|
|
232
232
|
lights = /* @__PURE__ */ new Map();
|
|
233
233
|
helpers = /* @__PURE__ */ new Map();
|
|
@@ -235,15 +235,15 @@ class ri {
|
|
|
235
235
|
this.scene = e;
|
|
236
236
|
}
|
|
237
237
|
addAmbient(e, t = {}) {
|
|
238
|
-
const { color: s = 16777215, intensity: n = 0.5 } = t, r = new
|
|
238
|
+
const { color: s = 16777215, intensity: n = 0.5 } = t, r = new ys(s, n);
|
|
239
239
|
return r.name = e, this._register(e, r), r;
|
|
240
240
|
}
|
|
241
241
|
addDirectional(e, t = {}) {
|
|
242
|
-
const { color: s = 16777215, intensity: n = 1, position: r = { x: 5, y: 10, z: 5 }, castShadow: a = !1, shadowMapSize: o = 1024 } = t, c = new
|
|
242
|
+
const { color: s = 16777215, intensity: n = 1, position: r = { x: 5, y: 10, z: 5 }, castShadow: a = !1, shadowMapSize: o = 1024 } = t, c = new He(s, n);
|
|
243
243
|
return c.position.set(r.x, r.y, r.z), c.castShadow = a, a && c.shadow.mapSize.setScalar(o), c.name = e, this._register(e, c), c;
|
|
244
244
|
}
|
|
245
245
|
addPoint(e, t = {}) {
|
|
246
|
-
const { color: s = 16777215, intensity: n = 1, distance: r = 0, decay: a = 2, position: o = { x: 0, y: 5, z: 0 }, castShadow: c = !1 } = t, l = new
|
|
246
|
+
const { color: s = 16777215, intensity: n = 1, distance: r = 0, decay: a = 2, position: o = { x: 0, y: 5, z: 0 }, castShadow: c = !1 } = t, l = new $e(s, n, r, a);
|
|
247
247
|
return l.position.set(o.x, o.y, o.z), l.castShadow = c, l.name = e, this._register(e, l), l;
|
|
248
248
|
}
|
|
249
249
|
addSpot(e, t = {}) {
|
|
@@ -256,12 +256,12 @@ class ri {
|
|
|
256
256
|
decay: c = 2,
|
|
257
257
|
position: l = { x: 0, y: 10, z: 0 },
|
|
258
258
|
target: h,
|
|
259
|
-
castShadow:
|
|
260
|
-
} = t,
|
|
261
|
-
return
|
|
259
|
+
castShadow: u = !1
|
|
260
|
+
} = t, d = new Ke(s, n, r, a, o, c);
|
|
261
|
+
return d.position.set(l.x, l.y, l.z), h && d.target.position.set(h.x, h.y, h.z), d.castShadow = u, d.name = e, this._register(e, d), d;
|
|
262
262
|
}
|
|
263
263
|
addHemisphere(e, t = {}) {
|
|
264
|
-
const { skyColor: s = 8900331, groundColor: n = 3549447, intensity: r = 0.6 } = t, a = new
|
|
264
|
+
const { skyColor: s = 8900331, groundColor: n = 3549447, intensity: r = 0.6 } = t, a = new qe(s, n, r);
|
|
265
265
|
return a.name = e, this._register(e, a), a;
|
|
266
266
|
}
|
|
267
267
|
/**
|
|
@@ -312,7 +312,7 @@ class ri {
|
|
|
312
312
|
const t = this.lights.get(e);
|
|
313
313
|
if (!t) return;
|
|
314
314
|
let s = null;
|
|
315
|
-
t instanceof
|
|
315
|
+
t instanceof He ? s = new bs(t, 1) : t instanceof $e ? s = new ws(t, 0.5) : t instanceof Ke ? s = new xs(t) : t instanceof qe && (s = new Ms(t, 1)), s && (this.scene.add(s), this.helpers.set(e, s));
|
|
316
316
|
}
|
|
317
317
|
/**
|
|
318
318
|
* Hide (remove) the helper for a light.
|
|
@@ -343,22 +343,22 @@ class ri {
|
|
|
343
343
|
this.removeAll(), this.hideAllHelpers();
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
|
-
class
|
|
346
|
+
class lt extends ke {
|
|
347
347
|
constructor(e) {
|
|
348
348
|
super(e);
|
|
349
349
|
}
|
|
350
350
|
parse(e, t, s, n) {
|
|
351
|
-
if (
|
|
352
|
-
const a =
|
|
351
|
+
if (On(e.slice(0, 8)) === "SBMG----") {
|
|
352
|
+
const a = Bn(e.slice(8));
|
|
353
353
|
return super.parse(a, t, s, n);
|
|
354
354
|
} else
|
|
355
355
|
return super.parse(e, t, s, n);
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
|
-
function
|
|
358
|
+
function On(i) {
|
|
359
359
|
return new TextDecoder().decode(new Uint8Array(i));
|
|
360
360
|
}
|
|
361
|
-
function
|
|
361
|
+
function Bn(i) {
|
|
362
362
|
const e = new DataView(i);
|
|
363
363
|
for (let t = 0; t < e.byteLength; t++) {
|
|
364
364
|
const s = e.getUint8(t), n = (s >> 4 & 15) + (s << 4 & 240);
|
|
@@ -366,39 +366,39 @@ function Sn(i) {
|
|
|
366
366
|
}
|
|
367
367
|
return e.buffer;
|
|
368
368
|
}
|
|
369
|
-
const
|
|
370
|
-
function
|
|
371
|
-
let e =
|
|
369
|
+
const _n = 8, Ln = 130, ht = 66, Tn = "SBK-----", Rn = "SBM-----", Qt = new TextDecoder(), Nn = new TextEncoder();
|
|
370
|
+
function Pn(i) {
|
|
371
|
+
let e = _n;
|
|
372
372
|
const t = new Uint8Array(i, 0, e);
|
|
373
|
-
if (
|
|
373
|
+
if (Qt.decode(t) !== Tn)
|
|
374
374
|
return i;
|
|
375
|
-
e +=
|
|
375
|
+
e += Ln;
|
|
376
376
|
const n = new Uint8Array(i, 0, e);
|
|
377
377
|
if (n[40] === 1) {
|
|
378
|
-
const a =
|
|
379
|
-
let h =
|
|
380
|
-
const
|
|
381
|
-
for (let
|
|
382
|
-
p[
|
|
383
|
-
const
|
|
384
|
-
return
|
|
378
|
+
const a = Nn.encode(Rn), o = new Uint8Array([n[41]]), c = Dn(n), l = Un(c);
|
|
379
|
+
let h = ht % l.length;
|
|
380
|
+
const u = e + ht, d = new Uint8Array(i, u), p = new Uint8Array(d.length);
|
|
381
|
+
for (let S = 0; S < d.length; S++)
|
|
382
|
+
p[S] = d[S] ^ l[h], h = (h + 1) % l.length;
|
|
383
|
+
const b = new Uint8Array(a.length + o.length + p.length);
|
|
384
|
+
return b.set(a), b.set(o, a.length), b.set(p, a.length + o.length), b.buffer;
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
|
-
function
|
|
387
|
+
function Dn(i) {
|
|
388
388
|
const e = new Uint8Array(128);
|
|
389
389
|
return e.set(i.slice(42, 74), 0), e.set(i.slice(74, 138), 32), e.set(i.slice(8, 40), 96), e;
|
|
390
390
|
}
|
|
391
|
-
function
|
|
391
|
+
function Un(i) {
|
|
392
392
|
const e = new Uint8Array(64);
|
|
393
393
|
return e.set(i.slice(0, 8), 0), e.set(i.slice(24, 32), 8), e.set(i.slice(40, 56), 16), e.set(i.slice(64, 88), 32), e.set(i.slice(96, 104), 56), e;
|
|
394
394
|
}
|
|
395
|
-
const
|
|
395
|
+
const kn = (i, e, t) => {
|
|
396
396
|
const s = i.buffer.slice(t, t + e);
|
|
397
|
-
let n =
|
|
397
|
+
let n = Qt.decode(s);
|
|
398
398
|
return n = n.replace("\\", "/"), n.startsWith("Maps/") || (n = `Maps/${n}`), n;
|
|
399
|
-
},
|
|
399
|
+
}, zn = (i, e, t) => {
|
|
400
400
|
const [s, n, r, a, o] = e, c = t || a < 1;
|
|
401
|
-
return new
|
|
401
|
+
return new X({
|
|
402
402
|
name: i,
|
|
403
403
|
color: new P(s, n, r),
|
|
404
404
|
opacity: a,
|
|
@@ -406,19 +406,19 @@ const Ln = (i, e, t) => {
|
|
|
406
406
|
alphaTest: 0.01,
|
|
407
407
|
side: o
|
|
408
408
|
});
|
|
409
|
-
},
|
|
410
|
-
class
|
|
409
|
+
}, jn = (i) => i?.toLowerCase().endsWith(".png") ?? !1;
|
|
410
|
+
class Wn {
|
|
411
411
|
data;
|
|
412
412
|
options;
|
|
413
413
|
textureLoader;
|
|
414
414
|
littleEndian = !0;
|
|
415
415
|
materials = /* @__PURE__ */ new Map();
|
|
416
416
|
constructor(e, t) {
|
|
417
|
-
this.data = e, this.options = t, this.textureLoader = new
|
|
417
|
+
this.data = e, this.options = t, this.textureLoader = new $t(t.manager), this.textureLoader.setCrossOrigin(t.crossOrigin), this.textureLoader.setRequestHeader(t.requestHeader);
|
|
418
418
|
}
|
|
419
419
|
parse(e, t) {
|
|
420
420
|
let s = this.data;
|
|
421
|
-
const n =
|
|
421
|
+
const n = Pn(this.data);
|
|
422
422
|
n && (s = n);
|
|
423
423
|
const r = new DataView(s);
|
|
424
424
|
let a = 8;
|
|
@@ -426,7 +426,7 @@ class Pn {
|
|
|
426
426
|
a += 1, o === 1 ? this._parseV2(r, a, e) : o === 2 ? this._parseV2(r, a, e) : o === 3 ? this._parseV3(r, a, e) : t?.(new Error(`SBMLoader: Unsupported SBM version: ${o}`));
|
|
427
427
|
}
|
|
428
428
|
_parseV2(e, t, s) {
|
|
429
|
-
const n = new
|
|
429
|
+
const n = new F(), r = e.getUint16(t, this.littleEndian);
|
|
430
430
|
t += 2;
|
|
431
431
|
const a = e.getUint16(t, this.littleEndian);
|
|
432
432
|
t += 2;
|
|
@@ -437,19 +437,19 @@ class Pn {
|
|
|
437
437
|
t += 4;
|
|
438
438
|
const h = e.getFloat32(t, this.littleEndian);
|
|
439
439
|
t += 4;
|
|
440
|
-
const d = e.getFloat32(t, this.littleEndian);
|
|
441
|
-
t += 4;
|
|
442
440
|
const u = e.getFloat32(t, this.littleEndian);
|
|
441
|
+
t += 4;
|
|
442
|
+
const d = e.getFloat32(t, this.littleEndian);
|
|
443
443
|
t += 4, t += 4, t += 4, t += 4, t += 4;
|
|
444
444
|
let p = e.getUint8(t);
|
|
445
|
-
t += 1, p === 0 ? p =
|
|
446
|
-
const
|
|
445
|
+
t += 1, p === 0 ? p = Ss : p === 1 ? p = Es : p === 2 && (p = Kt);
|
|
446
|
+
const b = e.getUint16(t, this.littleEndian);
|
|
447
447
|
t += 2;
|
|
448
|
-
const
|
|
449
|
-
if (t +=
|
|
450
|
-
const
|
|
451
|
-
this.materials.set(c,
|
|
452
|
-
|
|
448
|
+
const S = b > 0 ? kn(e, b, t) : "";
|
|
449
|
+
if (t += b, !this.materials.has(c)) {
|
|
450
|
+
const I = zn(c, [l, h, u, d, p], jn(S));
|
|
451
|
+
this.materials.set(c, I), S && this.options.path && this.textureLoader.load(de.resolveURL(S, this.options.path), (x) => {
|
|
452
|
+
x.colorSpace = Ie, x.wrapS = Ce, x.wrapT = Ce, x.flipY = !1, x.anisotropy = 16, I.map = x;
|
|
453
453
|
});
|
|
454
454
|
}
|
|
455
455
|
}
|
|
@@ -458,69 +458,69 @@ class Pn {
|
|
|
458
458
|
t += 2;
|
|
459
459
|
const l = e.getUint16(t, this.littleEndian).toString();
|
|
460
460
|
t += 2;
|
|
461
|
-
const h = [],
|
|
462
|
-
if (t += 2,
|
|
463
|
-
for (let
|
|
464
|
-
const
|
|
465
|
-
|
|
461
|
+
const h = [], u = [], d = [], p = [], b = e.getUint16(t, this.littleEndian);
|
|
462
|
+
if (t += 2, b > 0)
|
|
463
|
+
for (let y = 0; y < b; y++) {
|
|
464
|
+
const v = new N();
|
|
465
|
+
v.setX(e.getFloat32(t, this.littleEndian)), t += 4, v.setY(e.getFloat32(t, this.littleEndian)), t += 4, v.setZ(e.getFloat32(t, this.littleEndian)), t += 4, h.push(v);
|
|
466
466
|
}
|
|
467
|
-
const
|
|
468
|
-
if (t += 2,
|
|
469
|
-
for (let
|
|
467
|
+
const S = e.getUint16(t, this.littleEndian);
|
|
468
|
+
if (t += 2, S > 0)
|
|
469
|
+
for (let y = 0; y < S; y++)
|
|
470
470
|
t += 4, t += 4, t += 4;
|
|
471
|
-
const
|
|
472
|
-
if (t += 2,
|
|
473
|
-
for (let
|
|
474
|
-
const
|
|
475
|
-
|
|
471
|
+
const O = e.getUint16(t, this.littleEndian);
|
|
472
|
+
if (t += 2, O > 0)
|
|
473
|
+
for (let y = 0; y < O; y++) {
|
|
474
|
+
const v = new j();
|
|
475
|
+
v.setX(e.getFloat32(t, this.littleEndian)), t += 4, v.setY(e.getFloat32(t, this.littleEndian)), t += 4, u.push(v);
|
|
476
476
|
}
|
|
477
|
-
const
|
|
478
|
-
if (t += 2,
|
|
479
|
-
for (let
|
|
480
|
-
const
|
|
477
|
+
const I = e.getUint16(t, this.littleEndian);
|
|
478
|
+
if (t += 2, I > 0)
|
|
479
|
+
for (let y = 0; y < I; y++) {
|
|
480
|
+
const v = e.getUint16(t, this.littleEndian);
|
|
481
481
|
t += 2;
|
|
482
|
-
const
|
|
482
|
+
const C = e.getUint16(t, this.littleEndian);
|
|
483
483
|
t += 2;
|
|
484
|
-
const
|
|
484
|
+
const E = e.getUint16(t, this.littleEndian);
|
|
485
485
|
t += 2;
|
|
486
|
-
const
|
|
487
|
-
|
|
486
|
+
const A = [v, C, E];
|
|
487
|
+
d.push(A), u.length > 0 && p.push([u[A[0]], u[A[1]], u[A[2]]]);
|
|
488
488
|
}
|
|
489
|
-
const
|
|
490
|
-
for (let
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
let
|
|
494
|
-
const
|
|
495
|
-
|
|
489
|
+
const x = [], g = [];
|
|
490
|
+
for (let y = 0; y < d.length; y++) {
|
|
491
|
+
const v = d[y], C = h[v[0]], E = h[v[1]], A = h[v[2]];
|
|
492
|
+
x.push(...C.toArray(), ...E.toArray(), ...A.toArray());
|
|
493
|
+
let U = new j(), R = new j(), m = new j();
|
|
494
|
+
const T = p[y];
|
|
495
|
+
T !== void 0 && (U = T[0], R = T[1], m = T[2]), g.push(...U.toArray(), ...R.toArray(), ...m.toArray());
|
|
496
496
|
}
|
|
497
|
-
const
|
|
498
|
-
if (
|
|
499
|
-
const
|
|
500
|
-
|
|
497
|
+
const w = new Float32Array(x), f = new Float32Array(g), M = new q();
|
|
498
|
+
if (w.length > 0 && M.setAttribute("position", new Ue(w, 3)), f.length > 0 && M.setAttribute("uv", new Ue(f, 2)), M.computeVertexNormals(), this.materials.has(l)) {
|
|
499
|
+
const y = new k(M, this.materials.get(l));
|
|
500
|
+
y.name = c, y.castShadow = !0, y.receiveShadow = !0, n.add(y);
|
|
501
501
|
}
|
|
502
502
|
}
|
|
503
503
|
s(n);
|
|
504
504
|
}
|
|
505
505
|
_parseV3(e, t, s) {
|
|
506
|
-
const n = new
|
|
506
|
+
const n = new F();
|
|
507
507
|
console.warn("SBMLoader: SBM version 3 is not supported yet."), s(n);
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
|
-
class
|
|
510
|
+
class dt extends vs {
|
|
511
511
|
load(e, t, s, n) {
|
|
512
512
|
let r;
|
|
513
513
|
if (this.resourcePath !== "")
|
|
514
514
|
r = this.resourcePath;
|
|
515
515
|
else if (this.path !== "") {
|
|
516
|
-
const c =
|
|
517
|
-
r =
|
|
516
|
+
const c = de.extractUrlBase(e);
|
|
517
|
+
r = de.resolveURL(c, this.path);
|
|
518
518
|
} else
|
|
519
|
-
r =
|
|
519
|
+
r = de.extractUrlBase(e);
|
|
520
520
|
this.manager.itemStart(e);
|
|
521
521
|
const a = (c) => {
|
|
522
522
|
n ? n(c) : console.error(c), this.manager.itemError(e), this.manager.itemEnd(e);
|
|
523
|
-
}, o = new
|
|
523
|
+
}, o = new Ht(this.manager);
|
|
524
524
|
o.setPath(this.path), o.setResponseType("arraybuffer"), o.setRequestHeader(this.requestHeader), o.setWithCredentials(this.withCredentials), o.load(
|
|
525
525
|
e,
|
|
526
526
|
(c) => {
|
|
@@ -547,7 +547,7 @@ class ct extends bs {
|
|
|
547
547
|
n?.(new Error(`SBMLoader: Invalid SBM format: ${r}`));
|
|
548
548
|
return;
|
|
549
549
|
}
|
|
550
|
-
new
|
|
550
|
+
new Wn(e, {
|
|
551
551
|
path: t,
|
|
552
552
|
crossOrigin: this.crossOrigin,
|
|
553
553
|
requestHeader: this.requestHeader,
|
|
@@ -569,14 +569,14 @@ class ct extends bs {
|
|
|
569
569
|
});
|
|
570
570
|
}
|
|
571
571
|
}
|
|
572
|
-
const
|
|
572
|
+
const Fn = {
|
|
573
573
|
5120: Int8Array,
|
|
574
574
|
5121: Uint8Array,
|
|
575
575
|
5122: Int16Array,
|
|
576
576
|
5123: Uint16Array,
|
|
577
577
|
5125: Uint32Array,
|
|
578
578
|
5126: Float32Array
|
|
579
|
-
},
|
|
579
|
+
}, Gn = {
|
|
580
580
|
SCALAR: 1,
|
|
581
581
|
VEC2: 2,
|
|
582
582
|
VEC3: 3,
|
|
@@ -584,7 +584,7 @@ const Rn = {
|
|
|
584
584
|
MAT2: 4,
|
|
585
585
|
MAT3: 9,
|
|
586
586
|
MAT4: 16
|
|
587
|
-
},
|
|
587
|
+
}, Hn = {
|
|
588
588
|
POSITION: "position",
|
|
589
589
|
NORMAL: "normal",
|
|
590
590
|
TANGENT: "tangent",
|
|
@@ -594,210 +594,210 @@ const Rn = {
|
|
|
594
594
|
TEXCOORD_3: "uv3",
|
|
595
595
|
COLOR_0: "color"
|
|
596
596
|
};
|
|
597
|
-
function
|
|
597
|
+
function ce(i, e) {
|
|
598
598
|
e && typeof e == "object" && !Array.isArray(e) && Object.assign(i.userData, e);
|
|
599
599
|
}
|
|
600
|
-
function
|
|
601
|
-
if (i.protocolVersion !==
|
|
600
|
+
function $n(i) {
|
|
601
|
+
if (i.protocolVersion !== st)
|
|
602
602
|
throw new Error(
|
|
603
|
-
`Unsupported model decode protocol ${i.protocolVersion}; expected ${
|
|
603
|
+
`Unsupported model decode protocol ${i.protocolVersion}; expected ${st}.`
|
|
604
604
|
);
|
|
605
605
|
const { document: e, buffers: t, images: s } = i;
|
|
606
|
-
|
|
607
|
-
const n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = (
|
|
608
|
-
const
|
|
609
|
-
if (
|
|
610
|
-
const
|
|
611
|
-
if (!
|
|
612
|
-
throw new Error(`Decoded glTF references missing accessor ${
|
|
613
|
-
const M = e.bufferViews?.[
|
|
614
|
-
if (!M) throw new Error(`Decoded glTF references missing bufferView ${
|
|
615
|
-
const
|
|
616
|
-
if (!
|
|
617
|
-
const
|
|
618
|
-
if (!
|
|
619
|
-
throw new Error(`Unsupported decoded glTF accessor type ${
|
|
620
|
-
const
|
|
621
|
-
let
|
|
622
|
-
const
|
|
623
|
-
if (M.byteStride && M.byteStride !==
|
|
624
|
-
if (M.byteStride %
|
|
625
|
-
throw new Error(`Decoded glTF accessor ${
|
|
626
|
-
const
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
606
|
+
fn(e);
|
|
607
|
+
const n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = (g) => {
|
|
608
|
+
const w = n.get(g);
|
|
609
|
+
if (w) return w;
|
|
610
|
+
const f = e.accessors?.[g];
|
|
611
|
+
if (!f || f.bufferView === void 0)
|
|
612
|
+
throw new Error(`Decoded glTF references missing accessor ${g}.`);
|
|
613
|
+
const M = e.bufferViews?.[f.bufferView];
|
|
614
|
+
if (!M) throw new Error(`Decoded glTF references missing bufferView ${f.bufferView}.`);
|
|
615
|
+
const y = t[M.buffer];
|
|
616
|
+
if (!y) throw new Error(`Decoded glTF references missing buffer ${M.buffer}.`);
|
|
617
|
+
const v = Fn[f.componentType], C = Gn[f.type];
|
|
618
|
+
if (!v || !C)
|
|
619
|
+
throw new Error(`Unsupported decoded glTF accessor type ${f.componentType}/${f.type}.`);
|
|
620
|
+
const E = v.BYTES_PER_ELEMENT, A = M.byteOffset ?? 0, U = f.byteOffset ?? 0;
|
|
621
|
+
let R;
|
|
622
|
+
const m = C * E;
|
|
623
|
+
if (M.byteStride && M.byteStride !== m) {
|
|
624
|
+
if (M.byteStride % E !== 0 || U % E !== 0)
|
|
625
|
+
throw new Error(`Decoded glTF accessor ${g} has an invalid interleaved alignment.`);
|
|
626
|
+
const T = Math.floor(U / M.byteStride), B = [
|
|
627
|
+
f.bufferView,
|
|
628
|
+
f.componentType,
|
|
629
|
+
T,
|
|
630
|
+
f.count
|
|
631
631
|
].join(":");
|
|
632
|
-
let
|
|
633
|
-
if (!
|
|
634
|
-
const
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
632
|
+
let _ = r.get(B);
|
|
633
|
+
if (!_) {
|
|
634
|
+
const z = new v(
|
|
635
|
+
y,
|
|
636
|
+
A + T * M.byteStride,
|
|
637
|
+
f.count * M.byteStride / E
|
|
638
638
|
);
|
|
639
|
-
|
|
639
|
+
_ = new Cs(z, M.byteStride / E), r.set(B, _);
|
|
640
640
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
641
|
+
R = new Ve(
|
|
642
|
+
_,
|
|
643
|
+
C,
|
|
644
|
+
U % M.byteStride / E,
|
|
645
|
+
f.normalized ?? !1
|
|
646
646
|
);
|
|
647
647
|
} else {
|
|
648
|
-
const
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
648
|
+
const T = new v(
|
|
649
|
+
y,
|
|
650
|
+
A + U,
|
|
651
|
+
f.count * C
|
|
652
652
|
);
|
|
653
|
-
|
|
653
|
+
R = new Ue(T, C, f.normalized ?? !1);
|
|
654
654
|
}
|
|
655
|
-
return
|
|
656
|
-
}, h = (
|
|
657
|
-
const M = `${
|
|
658
|
-
if (
|
|
659
|
-
const
|
|
660
|
-
if (!
|
|
661
|
-
throw new Error(`Decoded glTF references missing texture ${
|
|
662
|
-
const
|
|
663
|
-
if (!
|
|
664
|
-
const
|
|
665
|
-
return
|
|
666
|
-
switch (
|
|
655
|
+
return R.name = f.name ?? "", n.set(g, R), R;
|
|
656
|
+
}, h = (g, w, f) => {
|
|
657
|
+
const M = `${g}:${w}:${f}`, y = c.get(M);
|
|
658
|
+
if (y) return y;
|
|
659
|
+
const v = e.textures?.[g];
|
|
660
|
+
if (!v || v.source === void 0)
|
|
661
|
+
throw new Error(`Decoded glTF references missing texture ${g}.`);
|
|
662
|
+
const C = s[v.source];
|
|
663
|
+
if (!C) throw new Error(`Decoded glTF references missing image ${v.source}.`);
|
|
664
|
+
const E = v.sampler === void 0 ? void 0 : e.samplers?.[v.sampler], A = new qt(C);
|
|
665
|
+
return A.name = v.name ?? e.images?.[v.source]?.name ?? "", A.flipY = !1, A.colorSpace = w, A.channel = f, A.magFilter = E?.magFilter === 9728 ? Ae : Ye, A.minFilter = (() => {
|
|
666
|
+
switch (E?.minFilter) {
|
|
667
667
|
case 9728:
|
|
668
|
-
return
|
|
668
|
+
return Ae;
|
|
669
669
|
case 9729:
|
|
670
|
-
return
|
|
670
|
+
return Ye;
|
|
671
671
|
case 9984:
|
|
672
|
-
return
|
|
672
|
+
return _s;
|
|
673
673
|
case 9985:
|
|
674
|
-
return
|
|
674
|
+
return Bs;
|
|
675
675
|
case 9986:
|
|
676
|
-
return
|
|
676
|
+
return Os;
|
|
677
677
|
default:
|
|
678
|
-
return
|
|
678
|
+
return As;
|
|
679
679
|
}
|
|
680
|
-
})(),
|
|
681
|
-
switch (
|
|
680
|
+
})(), A.wrapS = (() => {
|
|
681
|
+
switch (E?.wrapS) {
|
|
682
682
|
case 33071:
|
|
683
|
-
return
|
|
683
|
+
return Je;
|
|
684
684
|
case 33648:
|
|
685
|
-
return
|
|
685
|
+
return Qe;
|
|
686
686
|
default:
|
|
687
|
-
return
|
|
687
|
+
return Ce;
|
|
688
688
|
}
|
|
689
|
-
})(),
|
|
690
|
-
switch (
|
|
689
|
+
})(), A.wrapT = (() => {
|
|
690
|
+
switch (E?.wrapT) {
|
|
691
691
|
case 33071:
|
|
692
|
-
return
|
|
692
|
+
return Je;
|
|
693
693
|
case 33648:
|
|
694
|
-
return
|
|
694
|
+
return Qe;
|
|
695
695
|
default:
|
|
696
|
-
return
|
|
696
|
+
return Ce;
|
|
697
697
|
}
|
|
698
|
-
})(),
|
|
699
|
-
},
|
|
700
|
-
|
|
701
|
-
},
|
|
702
|
-
const
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
698
|
+
})(), A.needsUpdate = !0, c.set(M, A), A;
|
|
699
|
+
}, u = (g, w, f, M) => {
|
|
700
|
+
f && (g[w] = h(f.index, M, f.texCoord ?? 0));
|
|
701
|
+
}, d = (g, w, f, M) => {
|
|
702
|
+
const y = [
|
|
703
|
+
g ?? "default",
|
|
704
|
+
w ? "derivative-tangents" : "",
|
|
705
|
+
f ? "vertex-colors" : "",
|
|
706
706
|
M ? "flat-shading" : ""
|
|
707
|
-
].join(":"),
|
|
708
|
-
if (
|
|
709
|
-
const
|
|
710
|
-
if (
|
|
711
|
-
throw new Error(`Decoded glTF references missing material ${
|
|
712
|
-
const
|
|
707
|
+
].join(":"), v = o.get(y);
|
|
708
|
+
if (v) return v;
|
|
709
|
+
const C = g === void 0 ? void 0 : e.materials?.[g];
|
|
710
|
+
if (g !== void 0 && !C)
|
|
711
|
+
throw new Error(`Decoded glTF references missing material ${g}.`);
|
|
712
|
+
const E = C ?? {}, A = E.pbrMetallicRoughness ?? {}, U = A.baseColorFactor ?? [1, 1, 1, 1], R = E.alphaMode ?? "OPAQUE", m = new Is({
|
|
713
713
|
color: new P().setRGB(
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
714
|
+
U[0] ?? 1,
|
|
715
|
+
U[1] ?? 1,
|
|
716
|
+
U[2] ?? 1,
|
|
717
|
+
Xe
|
|
718
718
|
),
|
|
719
|
-
opacity:
|
|
720
|
-
metalness:
|
|
721
|
-
roughness:
|
|
722
|
-
transparent:
|
|
723
|
-
depthWrite:
|
|
724
|
-
alphaTest:
|
|
719
|
+
opacity: U[3] ?? 1,
|
|
720
|
+
metalness: A.metallicFactor ?? 1,
|
|
721
|
+
roughness: A.roughnessFactor ?? 1,
|
|
722
|
+
transparent: R === "BLEND",
|
|
723
|
+
depthWrite: R !== "BLEND",
|
|
724
|
+
alphaTest: R === "MASK" ? E.alphaCutoff ?? 0.5 : 0
|
|
725
725
|
});
|
|
726
|
-
return
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
)),
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
),
|
|
735
|
-
}, p = (
|
|
736
|
-
const
|
|
726
|
+
return E.doubleSided && (m.side = Kt), m.vertexColors = f, m.flatShading = M, m.name = E.name ?? "", u(m, "map", A.baseColorTexture, Ie), u(m, "metalnessMap", A.metallicRoughnessTexture, me), u(m, "roughnessMap", A.metallicRoughnessTexture, me), u(m, "normalMap", E.normalTexture, me), u(m, "aoMap", E.occlusionTexture, me), u(m, "emissiveMap", E.emissiveTexture, Ie), E.normalTexture?.scale !== void 0 && (m.normalScale = new j(
|
|
727
|
+
E.normalTexture.scale,
|
|
728
|
+
E.normalTexture.scale
|
|
729
|
+
)), w && (m.normalScale.y *= -1), E.occlusionTexture?.strength !== void 0 && (m.aoMapIntensity = E.occlusionTexture.strength), E.emissiveFactor && m.emissive.setRGB(
|
|
730
|
+
E.emissiveFactor[0] ?? 0,
|
|
731
|
+
E.emissiveFactor[1] ?? 0,
|
|
732
|
+
E.emissiveFactor[2] ?? 0,
|
|
733
|
+
Xe
|
|
734
|
+
), ce(m, E.extras), o.set(y, m), m;
|
|
735
|
+
}, p = (g, w) => {
|
|
736
|
+
const f = `${g}:${w}`, M = a.get(f);
|
|
737
737
|
if (M) return M;
|
|
738
|
-
const
|
|
739
|
-
if (!
|
|
740
|
-
const
|
|
741
|
-
for (const [
|
|
742
|
-
const
|
|
743
|
-
|
|
738
|
+
const y = e.meshes?.[g]?.primitives[w];
|
|
739
|
+
if (!y) throw new Error(`Decoded glTF references missing primitive ${f}.`);
|
|
740
|
+
const v = new q();
|
|
741
|
+
for (const [C, E] of Object.entries(y.attributes)) {
|
|
742
|
+
const A = Hn[C] ?? C.toLowerCase();
|
|
743
|
+
v.setAttribute(A, l(E));
|
|
744
744
|
}
|
|
745
|
-
if (
|
|
746
|
-
const
|
|
747
|
-
if (
|
|
748
|
-
throw new Error(`Decoded glTF index accessor ${
|
|
749
|
-
|
|
745
|
+
if (y.indices !== void 0) {
|
|
746
|
+
const C = l(y.indices);
|
|
747
|
+
if (C instanceof Ve)
|
|
748
|
+
throw new Error(`Decoded glTF index accessor ${y.indices} cannot be interleaved.`);
|
|
749
|
+
v.setIndex(C);
|
|
750
750
|
}
|
|
751
|
-
return a.set(
|
|
752
|
-
},
|
|
753
|
-
const
|
|
754
|
-
if (!
|
|
755
|
-
const
|
|
756
|
-
const
|
|
757
|
-
p(
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
751
|
+
return a.set(f, v), v;
|
|
752
|
+
}, b = (g) => {
|
|
753
|
+
const w = e.meshes?.[g];
|
|
754
|
+
if (!w) throw new Error(`Decoded glTF references missing mesh ${g}.`);
|
|
755
|
+
const f = w.primitives.map((y, v) => {
|
|
756
|
+
const C = new k(
|
|
757
|
+
p(g, v),
|
|
758
|
+
d(
|
|
759
|
+
y.material,
|
|
760
|
+
y.attributes.TANGENT === void 0,
|
|
761
|
+
y.attributes.COLOR_0 !== void 0,
|
|
762
|
+
y.attributes.NORMAL === void 0
|
|
763
763
|
)
|
|
764
764
|
);
|
|
765
|
-
return
|
|
765
|
+
return C.name = w.name ?? "", C;
|
|
766
766
|
});
|
|
767
|
-
if (
|
|
768
|
-
return
|
|
769
|
-
const M = new
|
|
770
|
-
return M.name =
|
|
771
|
-
},
|
|
772
|
-
const
|
|
773
|
-
if (!
|
|
774
|
-
const
|
|
775
|
-
|
|
776
|
-
for (const M of
|
|
777
|
-
|
|
778
|
-
return
|
|
779
|
-
},
|
|
780
|
-
if (!
|
|
781
|
-
const
|
|
782
|
-
|
|
783
|
-
for (const
|
|
784
|
-
return
|
|
785
|
-
}
|
|
786
|
-
const
|
|
787
|
-
function
|
|
767
|
+
if (f.length === 1)
|
|
768
|
+
return ce(f[0], w.extras), f[0];
|
|
769
|
+
const M = new F();
|
|
770
|
+
return M.name = w.name ?? "", M.add(...f), ce(M, w.extras), M;
|
|
771
|
+
}, S = (g) => {
|
|
772
|
+
const w = e.nodes?.[g];
|
|
773
|
+
if (!w) throw new Error(`Decoded glTF references missing node ${g}.`);
|
|
774
|
+
const f = w.mesh === void 0 ? new F() : b(w.mesh);
|
|
775
|
+
f.name = w.name ?? f.name, w.matrix ? new D().fromArray(w.matrix).decompose(f.position, f.quaternion, f.scale) : (w.translation && f.position.fromArray(w.translation), w.rotation && f.quaternion.fromArray(w.rotation), w.scale && f.scale.fromArray(w.scale)), ce(f, w.extras);
|
|
776
|
+
for (const M of w.children ?? [])
|
|
777
|
+
f.add(S(M));
|
|
778
|
+
return f;
|
|
779
|
+
}, O = e.scene ?? 0, I = e.scenes?.[O];
|
|
780
|
+
if (!I) throw new Error(`Decoded glTF references missing scene ${O}.`);
|
|
781
|
+
const x = new F();
|
|
782
|
+
x.name = I.name ?? "", ce(x, I.extras);
|
|
783
|
+
for (const g of I.nodes ?? []) x.add(S(g));
|
|
784
|
+
return x.animations = [], x;
|
|
785
|
+
}
|
|
786
|
+
const Kn = 256;
|
|
787
|
+
function qn(i) {
|
|
788
788
|
return i instanceof Error ? { message: i.message, name: i.name, stack: i.stack } : { message: String(i) };
|
|
789
789
|
}
|
|
790
|
-
function
|
|
790
|
+
function Vn(i) {
|
|
791
791
|
const e = new Error(i.message);
|
|
792
792
|
return e.name = i.name ?? "Error", e.stack = i.stack, e;
|
|
793
793
|
}
|
|
794
|
-
class
|
|
794
|
+
class Ee extends Error {
|
|
795
795
|
name = "ModelDecodeWorkerUnavailableError";
|
|
796
796
|
constructor(e, t) {
|
|
797
797
|
super(e, t);
|
|
798
798
|
}
|
|
799
799
|
}
|
|
800
|
-
function
|
|
800
|
+
function Xn(i, e, t = Kn) {
|
|
801
801
|
if (i.images.length !== i.imageKeys.length)
|
|
802
802
|
throw new Error("Decoded model image identities do not match its image payload.");
|
|
803
803
|
const s = [];
|
|
@@ -814,7 +814,7 @@ function Hn(i, e, t = jn) {
|
|
|
814
814
|
}
|
|
815
815
|
return s;
|
|
816
816
|
}
|
|
817
|
-
class
|
|
817
|
+
class Yn {
|
|
818
818
|
worker;
|
|
819
819
|
#s;
|
|
820
820
|
#a = 1;
|
|
@@ -833,11 +833,11 @@ class $n {
|
|
|
833
833
|
}
|
|
834
834
|
async loadAsync(e, t = {}) {
|
|
835
835
|
if (this.#r)
|
|
836
|
-
throw new
|
|
836
|
+
throw new Ee("Model decode Worker is unavailable.");
|
|
837
837
|
const s = this.#a++, { signal: n, loadingManager: r, ...a } = t;
|
|
838
838
|
if (n?.aborted) throw n.reason ?? new DOMException("Aborted", "AbortError");
|
|
839
839
|
const o = await new Promise((l, h) => {
|
|
840
|
-
const
|
|
840
|
+
const u = {
|
|
841
841
|
resolve: l,
|
|
842
842
|
reject: h,
|
|
843
843
|
manager: r,
|
|
@@ -845,31 +845,31 @@ class $n {
|
|
|
845
845
|
resources: /* @__PURE__ */ new Map()
|
|
846
846
|
};
|
|
847
847
|
if (r?.itemStart(e), n) {
|
|
848
|
-
const
|
|
849
|
-
this.#t.delete(s), this.#h(
|
|
848
|
+
const d = () => {
|
|
849
|
+
this.#t.delete(s), this.#h(u, n.reason ?? new DOMException("Aborted", "AbortError")), h(n.reason ?? new DOMException("Aborted", "AbortError"));
|
|
850
850
|
try {
|
|
851
851
|
this.#n({ type: "cancel", id: s });
|
|
852
852
|
} catch {
|
|
853
853
|
}
|
|
854
854
|
};
|
|
855
|
-
|
|
855
|
+
u.cleanup = () => n.removeEventListener("abort", d), n.addEventListener("abort", d, { once: !0 });
|
|
856
856
|
}
|
|
857
|
-
this.#t.set(s,
|
|
857
|
+
this.#t.set(s, u);
|
|
858
858
|
try {
|
|
859
859
|
this.#n({ type: "decode", id: s, url: e, options: a });
|
|
860
|
-
} catch (
|
|
861
|
-
this.#t.delete(s),
|
|
862
|
-
const p =
|
|
863
|
-
this.#h(
|
|
860
|
+
} catch (d) {
|
|
861
|
+
this.#t.delete(s), u.cleanup?.();
|
|
862
|
+
const p = d instanceof Error ? d : new Error(String(d));
|
|
863
|
+
this.#h(u, p), h(p);
|
|
864
864
|
}
|
|
865
865
|
}), c = [];
|
|
866
866
|
try {
|
|
867
|
-
return c.push(...
|
|
867
|
+
return c.push(...Xn(o, this.#e)), $n(o);
|
|
868
868
|
} catch (l) {
|
|
869
869
|
const h = /* @__PURE__ */ new Set();
|
|
870
|
-
for (const
|
|
871
|
-
const
|
|
872
|
-
this.#e.get(
|
|
870
|
+
for (const u of c) {
|
|
871
|
+
const d = o.imageKeys.indexOf(u), p = this.#e.get(u) ?? o.images[d];
|
|
872
|
+
this.#e.get(u) === p && this.#e.delete(u), p && !h.has(p) && (p.close(), h.add(p));
|
|
873
873
|
}
|
|
874
874
|
throw l;
|
|
875
875
|
} finally {
|
|
@@ -886,7 +886,7 @@ class $n {
|
|
|
886
886
|
this.#n({ type: "dispose" });
|
|
887
887
|
} catch {
|
|
888
888
|
}
|
|
889
|
-
this.#i(), this.worker.terminate(), this.#p(new
|
|
889
|
+
this.#i(), this.worker.terminate(), this.#p(new Ee("Model decode Worker was disposed.")), this.#e.clear();
|
|
890
890
|
}
|
|
891
891
|
}
|
|
892
892
|
#n(e) {
|
|
@@ -918,9 +918,9 @@ class $n {
|
|
|
918
918
|
if (this.#t.delete(t.id), s.cleanup?.(), t.type === "decoded")
|
|
919
919
|
this.#h(s), s.resolve(t.packet);
|
|
920
920
|
else if (t.type === "unsupported")
|
|
921
|
-
this.#h(s, void 0, !1), s.reject(new
|
|
921
|
+
this.#h(s, void 0, !1), s.reject(new Xt(t.reason));
|
|
922
922
|
else {
|
|
923
|
-
const n =
|
|
923
|
+
const n = Vn(t.error);
|
|
924
924
|
this.#h(s, n), s.reject(n);
|
|
925
925
|
}
|
|
926
926
|
};
|
|
@@ -944,7 +944,7 @@ class $n {
|
|
|
944
944
|
} catch (a) {
|
|
945
945
|
r !== void 0 && n.resources.delete(t) && (n.manager?.itemError(r), n.manager?.itemEnd(r));
|
|
946
946
|
try {
|
|
947
|
-
this.#n({ type: "resource-resolved", id: e, resourceId: t, error:
|
|
947
|
+
this.#n({ type: "resource-resolved", id: e, resourceId: t, error: qn(a) });
|
|
948
948
|
} catch (o) {
|
|
949
949
|
this.#u(o instanceof Error ? o : new Error(String(o)));
|
|
950
950
|
}
|
|
@@ -959,7 +959,7 @@ class $n {
|
|
|
959
959
|
#u(e) {
|
|
960
960
|
if (this.#r) return;
|
|
961
961
|
this.#r = !0, this.#i(), this.worker.terminate();
|
|
962
|
-
const t = new
|
|
962
|
+
const t = new Ee(
|
|
963
963
|
`Model decode Worker failed: ${e.message}`,
|
|
964
964
|
{ cause: e }
|
|
965
965
|
);
|
|
@@ -979,7 +979,7 @@ class $n {
|
|
|
979
979
|
this.#t.clear();
|
|
980
980
|
}
|
|
981
981
|
}
|
|
982
|
-
const
|
|
982
|
+
const Qn = [
|
|
983
983
|
"map",
|
|
984
984
|
"alphaMap",
|
|
985
985
|
"aoMap",
|
|
@@ -1005,37 +1005,94 @@ const Gn = [
|
|
|
1005
1005
|
"specularMap",
|
|
1006
1006
|
"thicknessMap",
|
|
1007
1007
|
"transmissionMap"
|
|
1008
|
-
];
|
|
1009
|
-
function
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1008
|
+
], Jn = 1179937895, Zn = 1313821514, er = "SBMG----", Jt = new TextDecoder();
|
|
1009
|
+
function tr(i) {
|
|
1010
|
+
if (i.byteLength < 8 || Jt.decode(new Uint8Array(i, 0, 8)) !== er) return i;
|
|
1011
|
+
const e = new Uint8Array(i.byteLength - 8), t = new Uint8Array(i, 8);
|
|
1012
|
+
for (let s = 0; s < t.length; s++) {
|
|
1013
|
+
const n = t[s];
|
|
1014
|
+
e[s] = n >> 4 & 15 | n << 4 & 240;
|
|
1015
|
+
}
|
|
1016
|
+
return e.buffer;
|
|
1017
|
+
}
|
|
1018
|
+
function sr(i) {
|
|
1019
|
+
const e = tr(i), t = new DataView(e);
|
|
1020
|
+
let s = e;
|
|
1021
|
+
if (e.byteLength >= 12 && t.getUint32(0, !0) === Jn) {
|
|
1022
|
+
const n = Math.min(t.getUint32(8, !0), e.byteLength);
|
|
1023
|
+
let r = 12, a;
|
|
1024
|
+
for (; r + 8 <= n; ) {
|
|
1025
|
+
const o = t.getUint32(r, !0), c = t.getUint32(r + 4, !0);
|
|
1026
|
+
if (r += 8, r + o > n) break;
|
|
1027
|
+
if (c === Zn) {
|
|
1028
|
+
a = e.slice(r, r + o);
|
|
1029
|
+
break;
|
|
1030
|
+
}
|
|
1031
|
+
r += o;
|
|
1032
|
+
}
|
|
1033
|
+
if (!a) throw new Error("GLB does not contain a JSON chunk.");
|
|
1034
|
+
s = a;
|
|
1035
|
+
}
|
|
1036
|
+
return JSON.parse(
|
|
1037
|
+
Jt.decode(s).replace(/^\uFEFF/u, "").replace(/\u0000+$/u, "")
|
|
1038
|
+
);
|
|
1039
|
+
}
|
|
1040
|
+
function nr(i) {
|
|
1041
|
+
const e = sr(i), t = /* @__PURE__ */ new Map();
|
|
1042
|
+
for (const s of e.buffers ?? [])
|
|
1043
|
+
!s.uri || s.uri.startsWith("data:") || s.uri.startsWith("blob:") || t.set(s.uri, {
|
|
1044
|
+
uri: s.uri,
|
|
1045
|
+
expectedSize: s.byteLength
|
|
1046
|
+
});
|
|
1047
|
+
for (const s of e.images ?? []) {
|
|
1048
|
+
if (!s.uri || s.uri.startsWith("data:") || s.uri.startsWith("blob:")) continue;
|
|
1049
|
+
const n = t.get(s.uri);
|
|
1050
|
+
t.set(s.uri, {
|
|
1051
|
+
uri: s.uri,
|
|
1052
|
+
expectedSize: n?.expectedSize,
|
|
1053
|
+
mimeType: s.mimeType ?? n?.mimeType
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
return Array.from(t.values());
|
|
1057
|
+
}
|
|
1058
|
+
function J(i) {
|
|
1059
|
+
return typeof location > "u" ? new URL(i).href : new URL(i, location.href).href;
|
|
1060
|
+
}
|
|
1061
|
+
function rr(i) {
|
|
1062
|
+
let e = 0;
|
|
1063
|
+
return i.traverse((t) => {
|
|
1064
|
+
if (!t.isMesh) return;
|
|
1065
|
+
const s = t, n = Array.isArray(s.material) ? s.material : [s.material];
|
|
1066
|
+
for (const r of n) {
|
|
1067
|
+
if (!r) continue;
|
|
1068
|
+
let a = !1;
|
|
1069
|
+
for (const o of Qn) {
|
|
1070
|
+
const c = r[o];
|
|
1071
|
+
c?.isTexture && c.image == null && (c.dispose(), r[o] = null, a = !0, e++);
|
|
1019
1072
|
}
|
|
1020
|
-
|
|
1073
|
+
a && (r.needsUpdate = !0);
|
|
1021
1074
|
}
|
|
1022
|
-
}),
|
|
1075
|
+
}), e;
|
|
1076
|
+
}
|
|
1077
|
+
function le(i, e) {
|
|
1078
|
+
if (rr(i) > 0 && e)
|
|
1079
|
+
throw new Error("Cached model resource produced an undecoded texture.");
|
|
1080
|
+
return i;
|
|
1023
1081
|
}
|
|
1024
|
-
class
|
|
1025
|
-
static
|
|
1026
|
-
static
|
|
1027
|
-
|
|
1028
|
-
`https://cdn.jsdelivr.net/npm/three@0.${Qe}.0/examples/jsm/libs/draco/`
|
|
1082
|
+
class $ {
|
|
1083
|
+
static fileLoader = new Ht().setResponseType("arraybuffer");
|
|
1084
|
+
static dracoLoader = new un().setDecoderPath(
|
|
1085
|
+
`https://cdn.jsdelivr.net/npm/three@0.${Ze}.0/examples/jsm/libs/draco/`
|
|
1029
1086
|
);
|
|
1030
|
-
static ktx2Loader = new
|
|
1031
|
-
`https://cdn.jsdelivr.net/npm/three@0.${
|
|
1087
|
+
static ktx2Loader = new pn().setTranscoderPath(
|
|
1088
|
+
`https://cdn.jsdelivr.net/npm/three@0.${Ze}.0/examples/jsm/libs/basis/`
|
|
1032
1089
|
);
|
|
1033
|
-
static gltfLoader = new
|
|
1034
|
-
static sbmxLoader = new
|
|
1035
|
-
static sbmLoader = new
|
|
1036
|
-
static fbxLoader = new
|
|
1037
|
-
static objLoader = new
|
|
1038
|
-
static stlLoader = new
|
|
1090
|
+
static gltfLoader = new ke().setDRACOLoader($.dracoLoader).setKTX2Loader($.ktx2Loader).setMeshoptDecoder(Ne);
|
|
1091
|
+
static sbmxLoader = new lt().setDRACOLoader($.dracoLoader).setKTX2Loader($.ktx2Loader).setMeshoptDecoder(Ne);
|
|
1092
|
+
static sbmLoader = new dt();
|
|
1093
|
+
static fbxLoader = new tt();
|
|
1094
|
+
static objLoader = new hn();
|
|
1095
|
+
static stlLoader = new dn();
|
|
1039
1096
|
static decodeWorkerClient = null;
|
|
1040
1097
|
/**
|
|
1041
1098
|
* Routes supported static glTF/GLB/SBMX models through a dedicated decoder
|
|
@@ -1048,7 +1105,7 @@ class V {
|
|
|
1048
1105
|
if (this.decodeWorkerClient = null, t?.dispose(), !e) return () => {
|
|
1049
1106
|
};
|
|
1050
1107
|
let s;
|
|
1051
|
-
return s = new
|
|
1108
|
+
return s = new Yn(e, {
|
|
1052
1109
|
onFatal: () => {
|
|
1053
1110
|
this.decodeWorkerClient === s && (this.decodeWorkerClient = null);
|
|
1054
1111
|
}
|
|
@@ -1080,114 +1137,263 @@ class V {
|
|
|
1080
1137
|
static setKTX2Path(e) {
|
|
1081
1138
|
this.ktx2Loader.setTranscoderPath(e);
|
|
1082
1139
|
}
|
|
1140
|
+
static getMemoryCacheKey(e, t, s, n) {
|
|
1141
|
+
const r = this.fileLoader.manager.resolveURL(e), a = Object.entries(this.fileLoader.requestHeader).map(([o, c]) => [o.toLowerCase(), c]).sort(([o], [c]) => o.localeCompare(c));
|
|
1142
|
+
return JSON.stringify([
|
|
1143
|
+
r,
|
|
1144
|
+
t,
|
|
1145
|
+
s,
|
|
1146
|
+
n,
|
|
1147
|
+
this.fileLoader.withCredentials ? "include" : "same-origin",
|
|
1148
|
+
a
|
|
1149
|
+
]);
|
|
1150
|
+
}
|
|
1151
|
+
static clearPersistentCache() {
|
|
1152
|
+
return mn();
|
|
1153
|
+
}
|
|
1154
|
+
static deletePersistentCache(e, t = {}) {
|
|
1155
|
+
return ge(this.fileLoader.manager.resolveURL(e), {
|
|
1156
|
+
headers: { ...this.fileLoader.requestHeader },
|
|
1157
|
+
credentials: this.fileLoader.withCredentials ? "include" : "same-origin",
|
|
1158
|
+
cacheKey: t.cacheKey
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1083
1161
|
static async loadAsync(e, t = { persistent: !0 }) {
|
|
1084
|
-
const s = e.split(/[?#]/, 1)[0].split(".").pop()?.toLowerCase(), n = t.persistent ?? !0, r = t.signal;
|
|
1085
|
-
this.throwIfAborted(
|
|
1086
|
-
const
|
|
1087
|
-
if (
|
|
1088
|
-
const
|
|
1162
|
+
const s = e.split(/[?#]/, 1)[0].split(".").pop()?.toLowerCase(), n = t.persistent ?? !0, r = t.cacheMode, a = t.cacheKey, o = t.signal;
|
|
1163
|
+
this.throwIfAborted(o);
|
|
1164
|
+
const c = this.decodeWorkerClient;
|
|
1165
|
+
if (c?.supports(e)) {
|
|
1166
|
+
const l = this.fileLoader.manager.resolveURL(e), h = typeof location > "u" ? e : new URL(e, location.href).href, u = typeof location > "u" ? l : new URL(l, location.href).href;
|
|
1089
1167
|
try {
|
|
1090
|
-
return await
|
|
1168
|
+
return await c.loadAsync(u, {
|
|
1091
1169
|
persistent: n,
|
|
1170
|
+
cacheMode: r,
|
|
1171
|
+
cacheKey: a,
|
|
1092
1172
|
headers: this.fileLoader.requestHeader,
|
|
1093
1173
|
credentials: this.fileLoader.withCredentials ? "include" : "same-origin",
|
|
1094
|
-
resourceBaseUrl:
|
|
1095
|
-
signal:
|
|
1174
|
+
resourceBaseUrl: h,
|
|
1175
|
+
signal: o,
|
|
1096
1176
|
loadingManager: this.fileLoader.manager
|
|
1097
1177
|
});
|
|
1098
|
-
} catch (
|
|
1099
|
-
if (this.throwIfAborted(
|
|
1100
|
-
console.info(`[ModelLoaderManager] Decode Worker fallback for ${e}: ${
|
|
1178
|
+
} catch (d) {
|
|
1179
|
+
if (this.throwIfAborted(o), !(d instanceof Xt) && !(d instanceof Ee)) throw d;
|
|
1180
|
+
console.info(`[ModelLoaderManager] Decode Worker fallback for ${e}: ${d.message}`);
|
|
1101
1181
|
}
|
|
1102
1182
|
}
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1183
|
+
return this.loadRegularModel(e, s, n, o, !0, r, a);
|
|
1184
|
+
}
|
|
1185
|
+
static async loadRegularModel(e, t, s, n, r = !0, a, o) {
|
|
1186
|
+
const c = await this.loadSourceBuffer(e, s, n, a, o);
|
|
1187
|
+
this.throwIfAborted(n);
|
|
1188
|
+
let l;
|
|
1189
|
+
try {
|
|
1190
|
+
l = await this.prepareExternalGltfResources(
|
|
1191
|
+
e,
|
|
1192
|
+
t,
|
|
1193
|
+
c,
|
|
1194
|
+
s,
|
|
1195
|
+
n,
|
|
1196
|
+
a,
|
|
1197
|
+
o
|
|
1198
|
+
);
|
|
1199
|
+
} catch (d) {
|
|
1200
|
+
if (this.throwIfAborted(n), !r || !c.fromCache) throw d;
|
|
1201
|
+
const p = this.cacheUseFor(c.url, o);
|
|
1202
|
+
return await ge(p.url, p.options), this.loadRegularModel(e, t, s, n, !1, a, o);
|
|
1203
|
+
}
|
|
1204
|
+
const h = de.extractUrlBase(e), u = this.createParseLoadingManager(
|
|
1205
|
+
n,
|
|
1206
|
+
l.replacements,
|
|
1207
|
+
l.blobUrls
|
|
1208
|
+
);
|
|
1106
1209
|
try {
|
|
1107
|
-
switch (
|
|
1210
|
+
switch (t) {
|
|
1108
1211
|
case "gltf":
|
|
1109
1212
|
case "glb": {
|
|
1110
|
-
const
|
|
1111
|
-
return this.throwIfAborted(
|
|
1213
|
+
const p = await this.configureGltfLoader(new ke(u.manager)).parseAsync(c.buffer, h);
|
|
1214
|
+
return this.throwIfAborted(n), p.scene.animations = p.animations, le(
|
|
1215
|
+
p.scene,
|
|
1216
|
+
c.fromCache || l.cachedResources.length > 0
|
|
1217
|
+
);
|
|
1112
1218
|
}
|
|
1113
1219
|
case "sbmx": {
|
|
1114
|
-
const
|
|
1115
|
-
return this.throwIfAborted(
|
|
1220
|
+
const p = await this.configureGltfLoader(new lt(u.manager)).parseAsync(c.buffer, h);
|
|
1221
|
+
return this.throwIfAborted(n), p.scene.animations = p.animations, le(
|
|
1222
|
+
p.scene,
|
|
1223
|
+
c.fromCache || l.cachedResources.length > 0
|
|
1224
|
+
);
|
|
1116
1225
|
}
|
|
1117
1226
|
case "sbm": {
|
|
1118
|
-
const
|
|
1119
|
-
return this.throwIfAborted(
|
|
1227
|
+
const p = await new dt(u.manager).setCrossOrigin(this.sbmLoader.crossOrigin).setRequestHeader(this.sbmLoader.requestHeader).setWithCredentials(this.sbmLoader.withCredentials).parseAsync(c.buffer, h);
|
|
1228
|
+
return this.throwIfAborted(n), le(p, c.fromCache || l.cachedResources.length > 0);
|
|
1120
1229
|
}
|
|
1121
1230
|
case "fbx": {
|
|
1122
|
-
const
|
|
1123
|
-
return this.throwIfAborted(
|
|
1231
|
+
const p = new tt(u.manager).setCrossOrigin(this.fbxLoader.crossOrigin).setRequestHeader(this.fbxLoader.requestHeader).setWithCredentials(this.fbxLoader.withCredentials).parse(c.buffer, h);
|
|
1232
|
+
return this.throwIfAborted(n), le(p, c.fromCache || l.cachedResources.length > 0);
|
|
1124
1233
|
}
|
|
1125
1234
|
case "obj": {
|
|
1126
|
-
const
|
|
1127
|
-
return this.throwIfAborted(
|
|
1235
|
+
const d = new TextDecoder().decode(c.buffer), p = this.objLoader.parse(d);
|
|
1236
|
+
return this.throwIfAborted(n), le(p, c.fromCache || l.cachedResources.length > 0);
|
|
1128
1237
|
}
|
|
1129
1238
|
case "stl": {
|
|
1130
|
-
const
|
|
1131
|
-
return this.throwIfAborted(
|
|
1239
|
+
const d = this.stlLoader.parse(c.buffer);
|
|
1240
|
+
return this.throwIfAborted(n), new k(d, new X());
|
|
1132
1241
|
}
|
|
1133
1242
|
default:
|
|
1134
|
-
throw new Error(`Unsupported model format: ${
|
|
1243
|
+
throw new Error(`Unsupported model format: ${t}`);
|
|
1135
1244
|
}
|
|
1245
|
+
} catch (d) {
|
|
1246
|
+
this.throwIfAborted(n);
|
|
1247
|
+
const p = [
|
|
1248
|
+
...c.fromCache ? [this.cacheUseFor(c.url, o)] : [],
|
|
1249
|
+
...l.cachedResources
|
|
1250
|
+
];
|
|
1251
|
+
if (!r || p.length === 0) throw d;
|
|
1252
|
+
return await Promise.all(
|
|
1253
|
+
p.map((b) => ge(b.url, b.options))
|
|
1254
|
+
), this.loadRegularModel(e, t, s, n, !1, a, o);
|
|
1136
1255
|
} finally {
|
|
1137
|
-
l.cleanup();
|
|
1256
|
+
u.cleanup(), l.cleanup();
|
|
1138
1257
|
}
|
|
1139
1258
|
}
|
|
1140
1259
|
static configureGltfLoader(e) {
|
|
1141
|
-
return e.setDRACOLoader(this.dracoLoader).setKTX2Loader(this.ktx2Loader).setMeshoptDecoder(
|
|
1260
|
+
return e.setDRACOLoader(this.dracoLoader).setKTX2Loader(this.ktx2Loader).setMeshoptDecoder(Ne).setCrossOrigin(this.gltfLoader.crossOrigin).setRequestHeader(this.gltfLoader.requestHeader).setWithCredentials(this.gltfLoader.withCredentials), e;
|
|
1142
1261
|
}
|
|
1143
|
-
static createParseLoadingManager(e) {
|
|
1262
|
+
static createParseLoadingManager(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set()) {
|
|
1144
1263
|
this.throwIfAborted(e);
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
return e?.addEventListener("abort", n, { once: !0 }), {
|
|
1149
|
-
manager: s,
|
|
1150
|
-
cleanup: () => e?.removeEventListener("abort", n)
|
|
1151
|
-
};
|
|
1152
|
-
}
|
|
1153
|
-
static async loadSourceBuffer(e, t, s) {
|
|
1154
|
-
this.throwIfAborted(s);
|
|
1155
|
-
const n = this.fileLoader.manager, r = n.resolveURL(e);
|
|
1156
|
-
n.itemStart(r);
|
|
1157
|
-
try {
|
|
1158
|
-
let a;
|
|
1159
|
-
if (t && typeof caches < "u")
|
|
1264
|
+
const n = this.fileLoader.manager, r = new Ls();
|
|
1265
|
+
r.setURLModifier((o) => {
|
|
1266
|
+
const c = n.resolveURL(o), l = (() => {
|
|
1160
1267
|
try {
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
const u = await d.arrayBuffer();
|
|
1165
|
-
return this.throwIfAborted(s), u;
|
|
1166
|
-
}
|
|
1167
|
-
} catch (d) {
|
|
1168
|
-
this.throwIfAborted(s), console.warn(`[ModelLoaderManager] Failed to read Cache Storage for ${r}:`, d);
|
|
1268
|
+
return J(c);
|
|
1269
|
+
} catch {
|
|
1270
|
+
return c;
|
|
1169
1271
|
}
|
|
1170
|
-
|
|
1171
|
-
|
|
1272
|
+
})();
|
|
1273
|
+
return t.get(c) ?? t.get(l) ?? c;
|
|
1274
|
+
}), r.itemStart = (o) => {
|
|
1275
|
+
s.has(o) || n.itemStart(o);
|
|
1276
|
+
}, r.itemEnd = (o) => {
|
|
1277
|
+
s.has(o) || n.itemEnd(o);
|
|
1278
|
+
}, r.itemError = (o) => {
|
|
1279
|
+
s.has(o) || n.itemError(o);
|
|
1280
|
+
};
|
|
1281
|
+
const a = () => r.abort();
|
|
1282
|
+
return e?.addEventListener("abort", a, { once: !0 }), {
|
|
1283
|
+
manager: r,
|
|
1284
|
+
cleanup: () => e?.removeEventListener("abort", a)
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
static rootResourceOptions(e, t, s, n) {
|
|
1288
|
+
const r = this.fileLoader.manager.abortController.signal, a = t && typeof AbortSignal.any == "function" ? AbortSignal.any([t, r]) : t ?? r;
|
|
1289
|
+
return {
|
|
1290
|
+
persistent: e,
|
|
1291
|
+
cacheMode: s,
|
|
1292
|
+
cacheKey: n,
|
|
1293
|
+
signal: a,
|
|
1294
|
+
headers: { ...this.fileLoader.requestHeader },
|
|
1295
|
+
credentials: this.fileLoader.withCredentials ? "include" : "same-origin"
|
|
1296
|
+
};
|
|
1297
|
+
}
|
|
1298
|
+
static cacheUseFor(e, t) {
|
|
1299
|
+
return {
|
|
1300
|
+
url: e,
|
|
1301
|
+
options: {
|
|
1302
|
+
headers: { ...this.fileLoader.requestHeader },
|
|
1172
1303
|
credentials: this.fileLoader.withCredentials ? "include" : "same-origin",
|
|
1173
|
-
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1304
|
+
cacheKey: t
|
|
1305
|
+
}
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
static dependencyResourceOptions(e, t, s, n, r, a) {
|
|
1309
|
+
let o = !1;
|
|
1310
|
+
try {
|
|
1311
|
+
const c = new URL(J(e)), l = new URL(J(t));
|
|
1312
|
+
o = (c.protocol === "http:" || c.protocol === "https:") && c.origin === l.origin;
|
|
1313
|
+
} catch {
|
|
1314
|
+
o = !1;
|
|
1315
|
+
}
|
|
1316
|
+
return {
|
|
1317
|
+
persistent: s,
|
|
1318
|
+
cacheMode: r,
|
|
1319
|
+
cacheKey: a,
|
|
1320
|
+
signal: n,
|
|
1321
|
+
headers: o ? { ...this.fileLoader.requestHeader } : void 0,
|
|
1322
|
+
credentials: o ? this.fileLoader.withCredentials ? "include" : "same-origin" : "omit"
|
|
1323
|
+
};
|
|
1324
|
+
}
|
|
1325
|
+
static async loadManagedResource(e, t) {
|
|
1326
|
+
const s = this.fileLoader.manager;
|
|
1327
|
+
s.itemStart(e);
|
|
1328
|
+
try {
|
|
1329
|
+
return await nt(e, t);
|
|
1330
|
+
} catch (n) {
|
|
1331
|
+
throw s.itemError(e), n;
|
|
1332
|
+
} finally {
|
|
1333
|
+
s.itemEnd(e);
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
static async prepareExternalGltfResources(e, t, s, n, r, a, o) {
|
|
1337
|
+
const c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Set(), h = [], u = () => {
|
|
1338
|
+
for (const g of l) URL.revokeObjectURL(g);
|
|
1339
|
+
l.clear(), c.clear();
|
|
1340
|
+
}, d = { replacements: c, blobUrls: l, cachedResources: h, cleanup: u };
|
|
1341
|
+
if (!n || !gn() || !["gltf", "glb", "sbmx"].includes(t ?? "") || typeof URL.createObjectURL != "function") return d;
|
|
1342
|
+
const p = nr(s.buffer);
|
|
1343
|
+
if (p.length === 0) return d;
|
|
1344
|
+
const b = this.fileLoader.manager, S = J(e), O = J(b.resolveURL(e));
|
|
1345
|
+
let I = 0;
|
|
1346
|
+
const x = async () => {
|
|
1347
|
+
for (; I < p.length; ) {
|
|
1348
|
+
const g = p[I++], w = new URL(g.uri, S).href, f = J(b.resolveURL(w)), M = this.dependencyResourceOptions(
|
|
1349
|
+
f,
|
|
1350
|
+
O,
|
|
1351
|
+
n,
|
|
1352
|
+
r,
|
|
1353
|
+
a,
|
|
1354
|
+
o
|
|
1178
1355
|
);
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1356
|
+
let y = await this.loadManagedResource(f, M);
|
|
1357
|
+
if (g.expectedSize !== void 0 && y.buffer.byteLength < g.expectedSize && y.fromCache && (await ge(f, M), y = await this.loadManagedResource(f, M)), g.expectedSize !== void 0 && y.buffer.byteLength < g.expectedSize)
|
|
1358
|
+
throw new Error(
|
|
1359
|
+
`glTF resource is truncated: expected ${g.expectedSize}, received ${y.buffer.byteLength} from ${f}.`
|
|
1360
|
+
);
|
|
1361
|
+
y.fromCache && h.push({
|
|
1362
|
+
url: f,
|
|
1363
|
+
options: {
|
|
1364
|
+
headers: M.headers,
|
|
1365
|
+
credentials: M.credentials,
|
|
1366
|
+
cacheKey: M.cacheKey
|
|
1367
|
+
}
|
|
1368
|
+
});
|
|
1369
|
+
const v = new Blob([y.buffer], {
|
|
1370
|
+
type: y.headers.get("content-type") ?? g.mimeType ?? "application/octet-stream"
|
|
1371
|
+
}), C = URL.createObjectURL(v);
|
|
1372
|
+
l.add(C), c.set(w, C), c.set(f, C);
|
|
1373
|
+
}
|
|
1374
|
+
};
|
|
1375
|
+
try {
|
|
1376
|
+
return await Promise.all(
|
|
1377
|
+
Array.from({ length: Math.min(6, p.length) }, () => x())
|
|
1378
|
+
), d;
|
|
1379
|
+
} catch (g) {
|
|
1380
|
+
throw u(), g;
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
static async loadSourceBuffer(e, t, s, n, r) {
|
|
1384
|
+
this.throwIfAborted(s);
|
|
1385
|
+
const a = this.fileLoader.manager, o = a.resolveURL(e);
|
|
1386
|
+
a.itemStart(o);
|
|
1387
|
+
try {
|
|
1388
|
+
const c = await nt(
|
|
1389
|
+
o,
|
|
1390
|
+
this.rootResourceOptions(t, s, n, r)
|
|
1391
|
+
);
|
|
1392
|
+
return this.throwIfAborted(s), c;
|
|
1393
|
+
} catch (c) {
|
|
1394
|
+
throw a.itemError(o), c;
|
|
1189
1395
|
} finally {
|
|
1190
|
-
|
|
1396
|
+
a.itemEnd(o);
|
|
1191
1397
|
}
|
|
1192
1398
|
}
|
|
1193
1399
|
static throwIfAborted(e) {
|
|
@@ -1195,10 +1401,10 @@ class V {
|
|
|
1195
1401
|
throw e.reason ?? new DOMException("Aborted", "AbortError");
|
|
1196
1402
|
}
|
|
1197
1403
|
}
|
|
1198
|
-
class
|
|
1199
|
-
static textureLoader = new
|
|
1200
|
-
static hdrLoader = new
|
|
1201
|
-
static cubeTextureLoader = new
|
|
1404
|
+
class bi {
|
|
1405
|
+
static textureLoader = new $t();
|
|
1406
|
+
static hdrLoader = new yn();
|
|
1407
|
+
static cubeTextureLoader = new Ts();
|
|
1202
1408
|
static setLoadingManager(e) {
|
|
1203
1409
|
this.textureLoader.manager = e, this.hdrLoader.manager = e, this.cubeTextureLoader.manager = e;
|
|
1204
1410
|
}
|
|
@@ -1207,13 +1413,13 @@ class ii {
|
|
|
1207
1413
|
}
|
|
1208
1414
|
static async loadAsyncHDR(e) {
|
|
1209
1415
|
const t = await this.hdrLoader.loadAsync(e);
|
|
1210
|
-
return t.mapping =
|
|
1416
|
+
return t.mapping = Rs, t;
|
|
1211
1417
|
}
|
|
1212
1418
|
static async loadAsyncCubeTexture(e, t) {
|
|
1213
1419
|
return this.cubeTextureLoader.setPath(e), await this.cubeTextureLoader.loadAsync(t);
|
|
1214
1420
|
}
|
|
1215
1421
|
}
|
|
1216
|
-
class
|
|
1422
|
+
class Y extends k {
|
|
1217
1423
|
isBaseMesh = !0;
|
|
1218
1424
|
type = "BaseMesh";
|
|
1219
1425
|
castShadow = !0;
|
|
@@ -1226,7 +1432,7 @@ class X extends k {
|
|
|
1226
1432
|
return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
|
|
1227
1433
|
}
|
|
1228
1434
|
}
|
|
1229
|
-
class
|
|
1435
|
+
class fe extends F {
|
|
1230
1436
|
isBaseGroup = !0;
|
|
1231
1437
|
type = "BaseGroup";
|
|
1232
1438
|
ignoreInvisibleWhenRaycast = !0;
|
|
@@ -1237,7 +1443,7 @@ class pe extends W {
|
|
|
1237
1443
|
return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
|
|
1238
1444
|
}
|
|
1239
1445
|
}
|
|
1240
|
-
class
|
|
1446
|
+
class ir extends Ns {
|
|
1241
1447
|
isBaseSprite = !0;
|
|
1242
1448
|
type = "BaseSprite";
|
|
1243
1449
|
ignoreInvisibleWhenRaycast = !0;
|
|
@@ -1248,7 +1454,8 @@ class Kn extends _s {
|
|
|
1248
1454
|
return this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0 ? !1 : super.raycast(e, t);
|
|
1249
1455
|
}
|
|
1250
1456
|
}
|
|
1251
|
-
class
|
|
1457
|
+
class W extends fe {
|
|
1458
|
+
static MAX_MEMORY_CACHE_ENTRIES = 32;
|
|
1252
1459
|
isModel = !0;
|
|
1253
1460
|
type = "Model";
|
|
1254
1461
|
static memoryCache = /* @__PURE__ */ new Map();
|
|
@@ -1259,24 +1466,53 @@ class te extends pe {
|
|
|
1259
1466
|
super();
|
|
1260
1467
|
}
|
|
1261
1468
|
async loadAsync(e) {
|
|
1262
|
-
const {
|
|
1469
|
+
const {
|
|
1470
|
+
url: t,
|
|
1471
|
+
cache: s = !0,
|
|
1472
|
+
persistent: n = !0,
|
|
1473
|
+
cacheMode: r,
|
|
1474
|
+
cacheKey: a,
|
|
1475
|
+
signal: o
|
|
1476
|
+
} = e;
|
|
1263
1477
|
try {
|
|
1264
|
-
let
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1478
|
+
let c;
|
|
1479
|
+
const l = ["no-store", "reload", "revalidate"].includes(r ?? "");
|
|
1480
|
+
if (s && !o && !l) {
|
|
1481
|
+
const d = $.getMemoryCacheKey(
|
|
1482
|
+
t,
|
|
1483
|
+
n,
|
|
1484
|
+
r,
|
|
1485
|
+
a
|
|
1486
|
+
);
|
|
1487
|
+
if (W.memoryCache.has(d))
|
|
1488
|
+
c = W.memoryCache.get(d), W.memoryCache.delete(d), W.memoryCache.set(d, c);
|
|
1268
1489
|
else {
|
|
1269
|
-
const
|
|
1270
|
-
|
|
1490
|
+
const b = $.loadAsync(t, {
|
|
1491
|
+
persistent: n,
|
|
1492
|
+
cacheMode: r,
|
|
1493
|
+
cacheKey: a,
|
|
1494
|
+
signal: o
|
|
1495
|
+
}).catch((S) => {
|
|
1496
|
+
throw W.memoryCache.get(d) === b && W.memoryCache.delete(d), S;
|
|
1271
1497
|
});
|
|
1272
|
-
|
|
1498
|
+
for (W.memoryCache.set(d, b); W.memoryCache.size > W.MAX_MEMORY_CACHE_ENTRIES; ) {
|
|
1499
|
+
const S = W.memoryCache.keys().next().value;
|
|
1500
|
+
if (S === void 0) break;
|
|
1501
|
+
W.memoryCache.delete(S);
|
|
1502
|
+
}
|
|
1503
|
+
c = b;
|
|
1273
1504
|
}
|
|
1274
|
-
else
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1505
|
+
} else
|
|
1506
|
+
c = $.loadAsync(t, {
|
|
1507
|
+
persistent: n,
|
|
1508
|
+
cacheMode: r,
|
|
1509
|
+
cacheKey: a,
|
|
1510
|
+
signal: o
|
|
1511
|
+
});
|
|
1512
|
+
const h = await c, u = Ge(h);
|
|
1513
|
+
return this.add(u), u.animations && u.animations.length > 0 && (this.animations = u.animations, this.mixer = new Ps(u)), u;
|
|
1514
|
+
} catch (c) {
|
|
1515
|
+
return console.error(`[Model] Failed to load model from ${t}:`, c), null;
|
|
1280
1516
|
}
|
|
1281
1517
|
}
|
|
1282
1518
|
playAnimation(e, t = {}) {
|
|
@@ -1286,7 +1522,7 @@ class te extends pe {
|
|
|
1286
1522
|
if (e === void 0 ? o = this.animations[0] : typeof e == "number" ? o = this.animations[e] : o = this.animations.find((l) => l.name === e), !o)
|
|
1287
1523
|
return console.warn(`[Model] Animation not found: ${e}`), null;
|
|
1288
1524
|
let c = this.actions.get(o.name);
|
|
1289
|
-
return c || (c = this.mixer.clipAction(o), this.actions.set(o.name, c)), c.setLoop(s ?
|
|
1525
|
+
return c || (c = this.mixer.clipAction(o), this.actions.set(o.name, c)), c.setLoop(s ? Ds : Us, n), c.clampWhenFinished = a, c.timeScale = r, c.reset().play(), c;
|
|
1290
1526
|
}
|
|
1291
1527
|
playAllAnimations(e = {}) {
|
|
1292
1528
|
return this.animations.map((t, s) => this.playAnimation(s, e)).filter((t) => t !== null);
|
|
@@ -1307,13 +1543,13 @@ class te extends pe {
|
|
|
1307
1543
|
* Get the axis-aligned bounding box of this model.
|
|
1308
1544
|
*/
|
|
1309
1545
|
getBoundingBox() {
|
|
1310
|
-
return new
|
|
1546
|
+
return new V().setFromObject(this);
|
|
1311
1547
|
}
|
|
1312
1548
|
/**
|
|
1313
1549
|
* Get the center point of this model's bounding box.
|
|
1314
1550
|
*/
|
|
1315
1551
|
getCenter() {
|
|
1316
|
-
const e = new
|
|
1552
|
+
const e = new N();
|
|
1317
1553
|
return this.getBoundingBox().getCenter(e), e;
|
|
1318
1554
|
}
|
|
1319
1555
|
/**
|
|
@@ -1328,14 +1564,14 @@ class te extends pe {
|
|
|
1328
1564
|
this.memoryCache.clear();
|
|
1329
1565
|
}
|
|
1330
1566
|
static async clearPersistentCache() {
|
|
1331
|
-
|
|
1567
|
+
await $.clearPersistentCache();
|
|
1332
1568
|
}
|
|
1333
1569
|
}
|
|
1334
|
-
class
|
|
1570
|
+
class ar extends Y {
|
|
1335
1571
|
isSphereMesh = !0;
|
|
1336
1572
|
type = "SphereMesh";
|
|
1337
1573
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
1338
|
-
super(), this.geometry = new
|
|
1574
|
+
super(), this.geometry = new ks(
|
|
1339
1575
|
e?.radius,
|
|
1340
1576
|
e?.widthSegments,
|
|
1341
1577
|
e?.heightSegments,
|
|
@@ -1343,23 +1579,23 @@ class qn extends X {
|
|
|
1343
1579
|
e?.phiLength,
|
|
1344
1580
|
e?.thetaStart,
|
|
1345
1581
|
e?.thetaLength
|
|
1346
|
-
), this.material = new
|
|
1582
|
+
), this.material = new X(t);
|
|
1347
1583
|
}
|
|
1348
1584
|
}
|
|
1349
|
-
class
|
|
1585
|
+
class ut extends Y {
|
|
1350
1586
|
isTubeMesh = !0;
|
|
1351
1587
|
type = "TubeMesh";
|
|
1352
1588
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
1353
|
-
super(), this.geometry = new
|
|
1589
|
+
super(), this.geometry = new zs(
|
|
1354
1590
|
e?.path,
|
|
1355
1591
|
e?.tubularSegments,
|
|
1356
1592
|
e?.radius,
|
|
1357
1593
|
e?.radialSegments,
|
|
1358
1594
|
e?.closed
|
|
1359
|
-
), this.material = new
|
|
1595
|
+
), this.material = new X(t);
|
|
1360
1596
|
}
|
|
1361
1597
|
}
|
|
1362
|
-
class
|
|
1598
|
+
class wi extends fe {
|
|
1363
1599
|
isTopology = !0;
|
|
1364
1600
|
type = "Topology";
|
|
1365
1601
|
// Visuals
|
|
@@ -1433,19 +1669,19 @@ class ai extends pe {
|
|
|
1433
1669
|
s.set(c, 1 / 0), n.set(c, null), r.add(c);
|
|
1434
1670
|
for (s.set(e, 0); r.size > 0; ) {
|
|
1435
1671
|
let c = null, l = 1 / 0;
|
|
1436
|
-
for (const
|
|
1437
|
-
const
|
|
1438
|
-
|
|
1672
|
+
for (const u of r) {
|
|
1673
|
+
const d = s.get(u);
|
|
1674
|
+
d < l && (l = d, c = u);
|
|
1439
1675
|
}
|
|
1440
1676
|
if (c === null || c === t || l === 1 / 0)
|
|
1441
1677
|
break;
|
|
1442
1678
|
r.delete(c);
|
|
1443
1679
|
const h = this.adjacencyMap?.get(c);
|
|
1444
1680
|
if (h)
|
|
1445
|
-
for (const [
|
|
1446
|
-
if (!r.has(
|
|
1447
|
-
const p = s.get(c) +
|
|
1448
|
-
p < s.get(
|
|
1681
|
+
for (const [u, d] of h) {
|
|
1682
|
+
if (!r.has(u)) continue;
|
|
1683
|
+
const p = s.get(c) + d;
|
|
1684
|
+
p < s.get(u) && (s.set(u, p), n.set(u, c));
|
|
1449
1685
|
}
|
|
1450
1686
|
}
|
|
1451
1687
|
const a = [];
|
|
@@ -1462,8 +1698,8 @@ class ai extends pe {
|
|
|
1462
1698
|
* Renders the entire topology graph structure using TubeGeometry and Spheres.
|
|
1463
1699
|
*/
|
|
1464
1700
|
renderGraph() {
|
|
1465
|
-
this.clearGraph(), this.graphGroup = new
|
|
1466
|
-
const e = new
|
|
1701
|
+
this.clearGraph(), this.graphGroup = new F();
|
|
1702
|
+
const e = new ar({
|
|
1467
1703
|
geometryParameters: {
|
|
1468
1704
|
radius: this.parameters.nodeRadius,
|
|
1469
1705
|
widthSegments: 16,
|
|
@@ -1485,7 +1721,7 @@ class ai extends pe {
|
|
|
1485
1721
|
t.add(o);
|
|
1486
1722
|
const c = this.nodes.get(n), l = this.nodes.get(a);
|
|
1487
1723
|
if (c && l) {
|
|
1488
|
-
const h = new
|
|
1724
|
+
const h = new js(c, l), u = new ut({
|
|
1489
1725
|
geometryParameters: {
|
|
1490
1726
|
path: h,
|
|
1491
1727
|
tubularSegments: 1,
|
|
@@ -1497,7 +1733,7 @@ class ai extends pe {
|
|
|
1497
1733
|
color: this.parameters.edgeColor
|
|
1498
1734
|
}
|
|
1499
1735
|
});
|
|
1500
|
-
Object.assign(
|
|
1736
|
+
Object.assign(u.userData, { from: n, to: a, weight: r, type: "edge" }), this.graphGroup.add(u);
|
|
1501
1737
|
}
|
|
1502
1738
|
});
|
|
1503
1739
|
}), this.add(this.graphGroup);
|
|
@@ -1512,7 +1748,7 @@ class ai extends pe {
|
|
|
1512
1748
|
*/
|
|
1513
1749
|
renderPath(e, t = this.parameters.pathColor) {
|
|
1514
1750
|
if (e.length < 2) return;
|
|
1515
|
-
const s = new
|
|
1751
|
+
const s = new Ws(e, !1, "catmullrom", 0), n = new ut({
|
|
1516
1752
|
geometryParameters: {
|
|
1517
1753
|
path: s,
|
|
1518
1754
|
tubularSegments: e.length * 10,
|
|
@@ -1550,7 +1786,7 @@ class ai extends pe {
|
|
|
1550
1786
|
*/
|
|
1551
1787
|
importData(e) {
|
|
1552
1788
|
this.clearGraph(), this.clearPaths(), this.nodes.clear(), this.adjacencyMap.clear(), Object.entries(e.nodes).forEach(([t, s]) => {
|
|
1553
|
-
this.addNode(t, new
|
|
1789
|
+
this.addNode(t, new N(s.x, s.y, s.z));
|
|
1554
1790
|
}), e.edges.forEach(({ from: t, to: s, weight: n }) => {
|
|
1555
1791
|
this.addEdge(t, s, n);
|
|
1556
1792
|
}), this.renderGraph();
|
|
@@ -1562,7 +1798,7 @@ class ai extends pe {
|
|
|
1562
1798
|
return this.adjacencyMap.get(e);
|
|
1563
1799
|
}
|
|
1564
1800
|
}
|
|
1565
|
-
class
|
|
1801
|
+
class xi extends ir {
|
|
1566
1802
|
isPoi = !0;
|
|
1567
1803
|
type = "Poi";
|
|
1568
1804
|
parameters = {
|
|
@@ -1581,7 +1817,7 @@ class oi extends Kn {
|
|
|
1581
1817
|
_canvas = document.createElement("canvas");
|
|
1582
1818
|
_lastParametersJSON = "";
|
|
1583
1819
|
constructor(e = {}) {
|
|
1584
|
-
super(new
|
|
1820
|
+
super(new Fs()), Object.assign(this.parameters, e), this.updateAsync();
|
|
1585
1821
|
}
|
|
1586
1822
|
/**
|
|
1587
1823
|
* Update the POI with new parameters
|
|
@@ -1597,33 +1833,33 @@ class oi extends Kn {
|
|
|
1597
1833
|
n.font = `${this.parameters.fontSize}px ${this.parameters.fontFamily}`;
|
|
1598
1834
|
let r = null;
|
|
1599
1835
|
this.parameters.img && (r = await this._loadImage(this.parameters.img));
|
|
1600
|
-
const { text: a, fontSize: o, color: c, iconSize: l, padding: h, backgroundColor:
|
|
1601
|
-
let
|
|
1602
|
-
const
|
|
1603
|
-
if (
|
|
1836
|
+
const { text: a, fontSize: o, color: c, iconSize: l, padding: h, backgroundColor: u, borderRadius: d, textPosition: p, scaleFactor: b } = this.parameters, S = n.measureText(a), O = a ? S.width : 0, I = a ? o : 0;
|
|
1837
|
+
let x = 0, g = 0, w = 0, f = 0, M = 0, y = 0;
|
|
1838
|
+
const v = !!r, C = !!a;
|
|
1839
|
+
if (v && C)
|
|
1604
1840
|
switch (p) {
|
|
1605
1841
|
case "top":
|
|
1606
|
-
|
|
1842
|
+
x = Math.max(l, O), g = l + h + I, M = (x - O) / 2, y = I / 2, w = (x - l) / 2, f = I + h;
|
|
1607
1843
|
break;
|
|
1608
1844
|
case "bottom":
|
|
1609
|
-
|
|
1845
|
+
x = Math.max(l, O), g = l + h + I, w = (x - l) / 2, f = 0, M = (x - O) / 2, y = l + h + I / 2;
|
|
1610
1846
|
break;
|
|
1611
1847
|
case "left":
|
|
1612
|
-
|
|
1848
|
+
x = l + h + O, g = Math.max(l, I), M = 0, y = g / 2, w = O + h, f = (g - l) / 2;
|
|
1613
1849
|
break;
|
|
1614
1850
|
default:
|
|
1615
|
-
|
|
1851
|
+
x = l + h + O, g = Math.max(l, I), w = 0, f = (g - l) / 2, M = l + h, y = g / 2;
|
|
1616
1852
|
break;
|
|
1617
1853
|
}
|
|
1618
|
-
else
|
|
1619
|
-
const
|
|
1620
|
-
if (s.width =
|
|
1854
|
+
else v ? (x = l, g = l, w = 0, f = 0) : C && (x = O, g = I, M = 0, y = I / 2);
|
|
1855
|
+
const E = x + h * 2, A = g + h * 2;
|
|
1856
|
+
if (s.width = E, s.height = A, n.font = `${o}px ${this.parameters.fontFamily}`, u && (n.fillStyle = u, this._drawRoundedRect(n, 0, 0, E, A, d), n.fill()), v && n.drawImage(r, w + h, f + h, l, l), C) {
|
|
1621
1857
|
n.fillStyle = c;
|
|
1622
|
-
const
|
|
1623
|
-
n.textBaseline = "alphabetic", n.fillText(a, M + h,
|
|
1858
|
+
const m = n.measureText(a), T = m.actualBoundingBoxAscent + m.actualBoundingBoxDescent, B = m.actualBoundingBoxAscent - T / 2;
|
|
1859
|
+
n.textBaseline = "alphabetic", n.fillText(a, M + h, y + h + B);
|
|
1624
1860
|
}
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1861
|
+
const U = this.material.map, R = new Gs(s);
|
|
1862
|
+
R.colorSpace = Ie, this.material.map = R, U?.dispose(), this.scale.set(E * b, A * b, 1);
|
|
1627
1863
|
}
|
|
1628
1864
|
_loadImage(e) {
|
|
1629
1865
|
return new Promise((t, s) => {
|
|
@@ -1641,77 +1877,77 @@ class oi extends Kn {
|
|
|
1641
1877
|
this.material.map?.dispose(), this.material.dispose();
|
|
1642
1878
|
}
|
|
1643
1879
|
}
|
|
1644
|
-
class
|
|
1880
|
+
class Zt extends Y {
|
|
1645
1881
|
isShapeMesh = !0;
|
|
1646
1882
|
type = "ShapeMesh";
|
|
1647
1883
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
1648
|
-
super(), this.geometry = new
|
|
1884
|
+
super(), this.geometry = new Hs(e?.shape, e?.curveSegments), this.material = new X(t), this.geometry.rotateX(-Math.PI / 2);
|
|
1649
1885
|
}
|
|
1650
1886
|
static createFromPoints(e, t = {}) {
|
|
1651
|
-
return new
|
|
1887
|
+
return new Zt({
|
|
1652
1888
|
...t,
|
|
1653
1889
|
geometryParameters: {
|
|
1654
1890
|
...t.geometryParameters,
|
|
1655
|
-
shape: new
|
|
1891
|
+
shape: new Vt(e.map((s) => new j(s.x, -s.z)))
|
|
1656
1892
|
}
|
|
1657
1893
|
});
|
|
1658
1894
|
}
|
|
1659
1895
|
}
|
|
1660
|
-
class
|
|
1896
|
+
class es extends Y {
|
|
1661
1897
|
isExtrudeMesh = !0;
|
|
1662
1898
|
type = "ExtrudeMesh";
|
|
1663
1899
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
1664
|
-
super(), this.geometry = new
|
|
1900
|
+
super(), this.geometry = new $s(e?.shape, e?.options), this.material = new X(t), this.geometry.rotateX(-Math.PI / 2);
|
|
1665
1901
|
}
|
|
1666
1902
|
static createFromPoints(e, t = {}) {
|
|
1667
|
-
return e && e.length === 0 && (e = void 0), new
|
|
1903
|
+
return e && e.length === 0 && (e = void 0), new es({
|
|
1668
1904
|
...t,
|
|
1669
1905
|
geometryParameters: {
|
|
1670
1906
|
...t.geometryParameters,
|
|
1671
|
-
shape: new
|
|
1907
|
+
shape: new Vt(e?.map((s) => new j(s.x, -s.z)))
|
|
1672
1908
|
}
|
|
1673
1909
|
});
|
|
1674
1910
|
}
|
|
1675
1911
|
}
|
|
1676
|
-
class
|
|
1912
|
+
class Mi extends Y {
|
|
1677
1913
|
isPlaneMesh = !0;
|
|
1678
1914
|
type = "PlaneMesh";
|
|
1679
1915
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
1680
|
-
super(), this.geometry = new
|
|
1916
|
+
super(), this.geometry = new Ks(
|
|
1681
1917
|
e?.width,
|
|
1682
1918
|
e?.height,
|
|
1683
1919
|
e?.widthSegments,
|
|
1684
1920
|
e?.heightSegments
|
|
1685
|
-
), this.material = new
|
|
1921
|
+
), this.material = new X(t);
|
|
1686
1922
|
}
|
|
1687
1923
|
}
|
|
1688
|
-
class
|
|
1924
|
+
class vi extends Y {
|
|
1689
1925
|
isCircleMesh = !0;
|
|
1690
1926
|
type = "CircleMesh";
|
|
1691
1927
|
constructor({ geometryParameters: e, materialParameters: t } = {}) {
|
|
1692
1928
|
super(
|
|
1693
|
-
new
|
|
1929
|
+
new qs(
|
|
1694
1930
|
e?.radius,
|
|
1695
1931
|
e?.segments,
|
|
1696
1932
|
e?.thetaStart,
|
|
1697
1933
|
e?.thetaLength
|
|
1698
1934
|
),
|
|
1699
|
-
new
|
|
1935
|
+
new X(t)
|
|
1700
1936
|
), this.geometry.rotateX(-Math.PI / 2);
|
|
1701
1937
|
}
|
|
1702
1938
|
}
|
|
1703
|
-
class
|
|
1939
|
+
class Z {
|
|
1704
1940
|
static traverseMeshes(e, t) {
|
|
1705
1941
|
e.traverse((s) => {
|
|
1706
1942
|
s instanceof k && t(s);
|
|
1707
1943
|
});
|
|
1708
1944
|
}
|
|
1709
1945
|
}
|
|
1710
|
-
const
|
|
1711
|
-
function
|
|
1946
|
+
const or = 3, cr = 1, lr = 0, hr = 2, dr = 1e-3, pt = new N(), ee = new N(), ur = new Vs();
|
|
1947
|
+
function ft(i) {
|
|
1712
1948
|
return i.isInstanceObject === !0;
|
|
1713
1949
|
}
|
|
1714
|
-
function
|
|
1950
|
+
function mt(i) {
|
|
1715
1951
|
let e = !1;
|
|
1716
1952
|
return i.traverse((t) => {
|
|
1717
1953
|
if (e) return;
|
|
@@ -1719,7 +1955,7 @@ function ut(i) {
|
|
|
1719
1955
|
e = s.isMesh === !0 || s.isSprite === !0;
|
|
1720
1956
|
}), e;
|
|
1721
1957
|
}
|
|
1722
|
-
function
|
|
1958
|
+
function pr(i) {
|
|
1723
1959
|
let e = i;
|
|
1724
1960
|
for (; e; ) {
|
|
1725
1961
|
if (!e.visible) return !1;
|
|
@@ -1727,17 +1963,17 @@ function er(i) {
|
|
|
1727
1963
|
}
|
|
1728
1964
|
return !0;
|
|
1729
1965
|
}
|
|
1730
|
-
function
|
|
1731
|
-
return i === void 0 || !Number.isFinite(i) || i <= 0 ?
|
|
1966
|
+
function gt(i) {
|
|
1967
|
+
return i === void 0 || !Number.isFinite(i) || i <= 0 ? hr : i;
|
|
1732
1968
|
}
|
|
1733
|
-
class
|
|
1969
|
+
class Si {
|
|
1734
1970
|
static flow(e = {}) {
|
|
1735
|
-
const { baseColor: t = 16777215, flowColor: s = 65280, speed: n = 1, scale: r = 3, intensity: a = 4 } = e, o =
|
|
1736
|
-
return
|
|
1971
|
+
const { baseColor: t = 16777215, flowColor: s = 65280, speed: n = 1, scale: r = 3, intensity: a = 4 } = e, o = Q(new P(t)), c = Q(new P(s)), l = rt().x.mul(r).sub(Me.mul(n)), h = ve(ze(l).add(1).mul(0.5), a);
|
|
1972
|
+
return Se(o, c, h);
|
|
1737
1973
|
}
|
|
1738
1974
|
static breathe(e = {}) {
|
|
1739
|
-
const { baseColor: t = 16777215, breathColor: s = 65280, speed: n = 1, intensity: r = 2 } = e, a =
|
|
1740
|
-
return
|
|
1975
|
+
const { baseColor: t = 16777215, breathColor: s = 65280, speed: n = 1, intensity: r = 2 } = e, a = Q(new P(t)), o = Q(new P(s)), c = ze(Me.mul(n)).add(1).mul(0.5), l = ve(c, r);
|
|
1976
|
+
return Se(a, o, l);
|
|
1741
1977
|
}
|
|
1742
1978
|
static fluid(e = {}) {
|
|
1743
1979
|
const {
|
|
@@ -1747,143 +1983,143 @@ class hi {
|
|
|
1747
1983
|
scale: r = 1,
|
|
1748
1984
|
intensity: a = 1,
|
|
1749
1985
|
distortion: o = 0.5
|
|
1750
|
-
} = e, c =
|
|
1751
|
-
return
|
|
1986
|
+
} = e, c = Q(new P(t)), l = Q(new P(s)), h = rt().mul(r), u = Me.mul(n), d = it(h.add(u), 1, 0), p = h.add(d.mul(o)), b = it(p, 1, 0).add(1).mul(0.5), S = ve(b, a);
|
|
1987
|
+
return Se(c, l, S);
|
|
1752
1988
|
}
|
|
1753
1989
|
static outline(e = {}) {
|
|
1754
1990
|
let t = [...e.selectedObjects ?? []];
|
|
1755
|
-
const s = [], n = /* @__PURE__ */ new Map(), r = new
|
|
1756
|
-
let a = null, o = null, c = null, l = null, h = null,
|
|
1757
|
-
const
|
|
1758
|
-
const { source:
|
|
1759
|
-
if (!
|
|
1760
|
-
|
|
1991
|
+
const s = [], n = /* @__PURE__ */ new Map(), r = new V();
|
|
1992
|
+
let a = null, o = null, c = null, l = null, h = null, u = e.instanceBoundsProxy ?? !0, d = e.instanceBoundsPadding ?? 0, p = e.instanceBoundsMinSize ?? dr, b = gt(e.downSampleRatio);
|
|
1993
|
+
const S = oe(e.edgeStrength ?? or), O = oe(e.edgeThickness ?? cr), I = oe(e.edgeGlow ?? lr), x = oe(new P(e.visibleEdgeColor ?? 16777215)), g = oe(new P(e.hiddenEdgeColor ?? 5125686)), w = () => (l ??= new Xs(1, 1, 1), l), f = () => (h || (h = new Ys({ color: 16777215 }), h.colorWrite = !1, h.depthWrite = !1, h.name = "u-space.outline.instanceBoundsProxy"), h), M = (m) => {
|
|
1994
|
+
const { source: T, mesh: B } = m, _ = T.getInstanceBoundingBox?.(r, !0);
|
|
1995
|
+
if (!_ || _.isEmpty() || !pr(T)) {
|
|
1996
|
+
B.visible = !1;
|
|
1761
1997
|
return;
|
|
1762
1998
|
}
|
|
1763
|
-
|
|
1764
|
-
const
|
|
1765
|
-
|
|
1766
|
-
Math.max(
|
|
1767
|
-
Math.max(
|
|
1768
|
-
Math.max(
|
|
1769
|
-
),
|
|
1770
|
-
},
|
|
1771
|
-
|
|
1772
|
-
},
|
|
1773
|
-
let
|
|
1774
|
-
if (!
|
|
1775
|
-
const
|
|
1776
|
-
|
|
1777
|
-
},
|
|
1778
|
-
source:
|
|
1779
|
-
mesh:
|
|
1780
|
-
unsubscribe:
|
|
1781
|
-
}, n.set(
|
|
1999
|
+
_.getCenter(pt), _.getSize(ee);
|
|
2000
|
+
const z = Math.max(0, d), ae = Math.max(0, p);
|
|
2001
|
+
ee.set(
|
|
2002
|
+
Math.max(ee.x + z * 2, ae),
|
|
2003
|
+
Math.max(ee.y + z * 2, ae),
|
|
2004
|
+
Math.max(ee.z + z * 2, ae)
|
|
2005
|
+
), B.visible = !0, B.layers.mask = T.layers.mask, B.matrix.compose(pt, ur, ee), B.matrixWorldNeedsUpdate = !0;
|
|
2006
|
+
}, y = (m) => {
|
|
2007
|
+
m.unsubscribe?.(), m.mesh.removeFromParent();
|
|
2008
|
+
}, v = (m, T) => {
|
|
2009
|
+
let B = n.get(m);
|
|
2010
|
+
if (!B) {
|
|
2011
|
+
const _ = new k(w(), f());
|
|
2012
|
+
_.name = `u-space.outline.instanceBoundsProxy:${m.uuid}`, _.matrixAutoUpdate = !1, _.castShadow = !1, _.receiveShadow = !1, _.frustumCulled = !1, _.raycast = () => {
|
|
2013
|
+
}, _.userData.instanceObject = m, B = {
|
|
2014
|
+
source: m,
|
|
2015
|
+
mesh: _,
|
|
2016
|
+
unsubscribe: m.onInstanceRenderDirty?.(() => M(B)) ?? null
|
|
2017
|
+
}, n.set(m, B);
|
|
1782
2018
|
}
|
|
1783
|
-
return
|
|
1784
|
-
},
|
|
1785
|
-
const
|
|
1786
|
-
return
|
|
1787
|
-
},
|
|
1788
|
-
const
|
|
1789
|
-
for (const
|
|
1790
|
-
const
|
|
1791
|
-
|
|
2019
|
+
return B.mesh.parent !== T && (B.mesh.removeFromParent(), T.add(B.mesh)), M(B), B.mesh.visible ? B.mesh : null;
|
|
2020
|
+
}, C = (m, T) => {
|
|
2021
|
+
const B = m.getInstanceRenderObject?.();
|
|
2022
|
+
return B && mt(B) ? B : mt(m) ? m : u && m.getInstanceBoundingBox ? v(m, T) : null;
|
|
2023
|
+
}, E = (m) => {
|
|
2024
|
+
const T = /* @__PURE__ */ new Set(), B = /* @__PURE__ */ new Set();
|
|
2025
|
+
for (const _ of t) {
|
|
2026
|
+
const z = ft(_) ? C(_, m) : _;
|
|
2027
|
+
z && (T.add(z), ft(_) && n.get(_)?.mesh === z && B.add(_));
|
|
1792
2028
|
}
|
|
1793
|
-
n.forEach((
|
|
1794
|
-
|
|
1795
|
-
}), s.length = 0,
|
|
1796
|
-
},
|
|
2029
|
+
n.forEach((_, z) => {
|
|
2030
|
+
B.has(z) || (y(_), n.delete(z));
|
|
2031
|
+
}), s.length = 0, T.forEach((_) => s.push(_));
|
|
2032
|
+
}, A = () => {
|
|
1797
2033
|
a?.dispose(), a = null;
|
|
1798
|
-
},
|
|
1799
|
-
if (a && o ===
|
|
1800
|
-
return a.downSampleRatio =
|
|
1801
|
-
|
|
2034
|
+
}, U = (m, T) => {
|
|
2035
|
+
if (a && o === m && c === T)
|
|
2036
|
+
return a.downSampleRatio = b, a;
|
|
2037
|
+
A(), o = m, c = T, a = In(m, T, {
|
|
1802
2038
|
selectedObjects: s,
|
|
1803
|
-
edgeThickness:
|
|
1804
|
-
edgeGlow:
|
|
1805
|
-
downSampleRatio:
|
|
2039
|
+
edgeThickness: O,
|
|
2040
|
+
edgeGlow: I,
|
|
2041
|
+
downSampleRatio: b
|
|
1806
2042
|
});
|
|
1807
|
-
const
|
|
1808
|
-
return a.updateBefore = (
|
|
1809
|
-
},
|
|
1810
|
-
const
|
|
1811
|
-
|
|
1812
|
-
const
|
|
1813
|
-
return
|
|
2043
|
+
const B = a.updateBefore.bind(a);
|
|
2044
|
+
return a.updateBefore = (_) => (E(m), B(_)), a;
|
|
2045
|
+
}, R = ((m, T) => {
|
|
2046
|
+
const B = m.scene, _ = m.camera;
|
|
2047
|
+
E(B);
|
|
2048
|
+
const z = U(B, _), ae = z.visibleEdge.mul(x).add(z.hiddenEdge.mul(g)).mul(S);
|
|
2049
|
+
return bn(T, wn(ae, 0));
|
|
1814
2050
|
});
|
|
1815
|
-
return Object.defineProperties(
|
|
2051
|
+
return Object.defineProperties(R, {
|
|
1816
2052
|
outlineNode: {
|
|
1817
2053
|
get: () => a
|
|
1818
2054
|
},
|
|
1819
2055
|
selectedObjects: {
|
|
1820
2056
|
get: () => t
|
|
1821
2057
|
}
|
|
1822
|
-
}),
|
|
1823
|
-
|
|
1824
|
-
},
|
|
2058
|
+
}), R.setSelectedObjects = (m) => (t = [...m], o && E(o), R), R.update = (m) => (m.edgeStrength !== void 0 && (S.value = m.edgeStrength), m.edgeThickness !== void 0 && (O.value = m.edgeThickness), m.edgeGlow !== void 0 && (I.value = m.edgeGlow), m.visibleEdgeColor !== void 0 && x.value.set(m.visibleEdgeColor), m.hiddenEdgeColor !== void 0 && g.value.set(m.hiddenEdgeColor), m.instanceBoundsProxy !== void 0 && (u = m.instanceBoundsProxy), m.instanceBoundsPadding !== void 0 && (d = m.instanceBoundsPadding), m.instanceBoundsMinSize !== void 0 && (p = m.instanceBoundsMinSize), m.downSampleRatio !== void 0 && (b = gt(m.downSampleRatio), a && (a.downSampleRatio = b)), o && E(o), R), R.dispose = () => {
|
|
2059
|
+
A(), n.forEach(y), n.clear(), l?.dispose(), h?.dispose(), l = null, h = null, t = [], s.length = 0, o = null, c = null;
|
|
2060
|
+
}, R;
|
|
1825
2061
|
}
|
|
1826
2062
|
}
|
|
1827
|
-
function
|
|
2063
|
+
function Ei(i) {
|
|
1828
2064
|
}
|
|
1829
|
-
const
|
|
1830
|
-
const i =
|
|
1831
|
-
return
|
|
1832
|
-
})(),
|
|
1833
|
-
const i =
|
|
1834
|
-
return
|
|
2065
|
+
const ie = "uSpaceHighlight", pe = `${ie}/enabled`, ts = `${ie}/opacity`, ss = `${ie}/color`, ns = `${ie}/overwrite`, rs = `${ie}/multiplyOpacity`, Be = `${ie}/instancedOriginalOpacity`, Te = "uSpaceBreathe", _e = `${Te}/enabled`, is = `${Te}/color`, as = `${Te}/speed`, os = `${Te}/intensity`, Le = /* @__PURE__ */ new WeakMap(), fr = Yt(() => {
|
|
2066
|
+
const i = G(pe, "uint"), e = G(ss, "uint"), t = G(ns, "uint"), s = wt(e), n = Oe.mul(s), r = K(t.greaterThan(0), s, n), a = K(i.greaterThan(0), r, Oe), o = G(_e, "uint"), c = G(is, "uint"), l = G(as, "float"), h = G(os, "float"), u = wt(c), d = ze(Me.mul(l)).add(1).mul(0.5), p = ve(d, h), b = Se(a, u, p);
|
|
2067
|
+
return K(o.greaterThan(0), b, a);
|
|
2068
|
+
})(), mr = Yt(() => {
|
|
2069
|
+
const i = G(pe, "uint"), e = G(ts, "float"), t = G(rs, "uint"), s = K(t.greaterThan(0), je.mul(e), e);
|
|
2070
|
+
return K(i.greaterThan(0), s, je);
|
|
1835
2071
|
})();
|
|
1836
|
-
function
|
|
2072
|
+
function ue(i) {
|
|
1837
2073
|
return Array.isArray(i.material) ? i.material : [i.material];
|
|
1838
2074
|
}
|
|
1839
|
-
function
|
|
1840
|
-
|
|
2075
|
+
function yt(i) {
|
|
2076
|
+
ue(i).forEach((t) => {
|
|
1841
2077
|
if (!t) return;
|
|
1842
|
-
let s =
|
|
2078
|
+
let s = Le.get(t);
|
|
1843
2079
|
s || (s = {
|
|
1844
2080
|
colorNode: t.colorNode,
|
|
1845
2081
|
opacityNode: t.opacityNode,
|
|
1846
2082
|
transparent: t.transparent,
|
|
1847
2083
|
depthWrite: t.depthWrite,
|
|
1848
2084
|
activeMeshes: /* @__PURE__ */ new Set()
|
|
1849
|
-
},
|
|
2085
|
+
}, Le.set(t, s)), s.activeMeshes.add(i), t.transparent = !0, t.colorNode = fr, t.opacityNode = mr, t.needsUpdate = !0;
|
|
1850
2086
|
});
|
|
1851
2087
|
}
|
|
1852
|
-
function
|
|
1853
|
-
const e = i.userData[
|
|
2088
|
+
function bt(i) {
|
|
2089
|
+
const e = i.userData[pe], t = i.userData[_e];
|
|
1854
2090
|
if (e || t) return;
|
|
1855
|
-
|
|
2091
|
+
ue(i).forEach((n) => {
|
|
1856
2092
|
if (!n) return;
|
|
1857
|
-
const r =
|
|
1858
|
-
r && (r.activeMeshes.delete(i), !(r.activeMeshes.size > 0) && (n.colorNode = r.colorNode, n.opacityNode = r.opacityNode, n.transparent = r.transparent, n.depthWrite = r.depthWrite, n.needsUpdate = !0,
|
|
2093
|
+
const r = Le.get(n);
|
|
2094
|
+
r && (r.activeMeshes.delete(i), !(r.activeMeshes.size > 0) && (n.colorNode = r.colorNode, n.opacityNode = r.opacityNode, n.transparent = r.transparent, n.depthWrite = r.depthWrite, n.needsUpdate = !0, Le.delete(n)));
|
|
1859
2095
|
});
|
|
1860
2096
|
}
|
|
1861
|
-
function
|
|
2097
|
+
function gr(i, e, t, s) {
|
|
1862
2098
|
const n = i, r = n.setInstanceHighlight;
|
|
1863
2099
|
if (r)
|
|
1864
2100
|
return r.call(i, e, t, s), !0;
|
|
1865
2101
|
const a = n.setInstanceColor, o = n.setInstanceOpacity, c = n.getInstanceOpacity, l = n.getInstanceColor, h = n.hasInstanceColor;
|
|
1866
|
-
return !a || !o ? !1 : (i.userData[
|
|
2102
|
+
return !a || !o ? !1 : (i.userData[Be] === void 0 && (i.userData[Be] = {
|
|
1867
2103
|
hasColor: h?.call(i) ?? !1,
|
|
1868
2104
|
color: l?.call(i, new P()).getHex() ?? 16777215,
|
|
1869
2105
|
opacity: c?.call(i) ?? 1
|
|
1870
2106
|
}), a.call(i, e), o.call(i, t), !0);
|
|
1871
2107
|
}
|
|
1872
|
-
function
|
|
2108
|
+
function yr(i) {
|
|
1873
2109
|
const e = i, t = e.clearInstanceHighlight;
|
|
1874
2110
|
if (t)
|
|
1875
2111
|
return t.call(i), !0;
|
|
1876
2112
|
const s = e.resetInstanceColor, n = e.setInstanceColor, r = e.setInstanceOpacity;
|
|
1877
2113
|
if (!s || !r) return !1;
|
|
1878
|
-
const a = i.userData[
|
|
1879
|
-
return a && (a.hasColor && n ? n.call(i, a.color) : s.call(i), r.call(i, a.opacity), Reflect.deleteProperty(i.userData,
|
|
2114
|
+
const a = i.userData[Be];
|
|
2115
|
+
return a && (a.hasColor && n ? n.call(i, a.color) : s.call(i), r.call(i, a.opacity), Reflect.deleteProperty(i.userData, Be)), !0;
|
|
1880
2116
|
}
|
|
1881
|
-
class
|
|
2117
|
+
class ne {
|
|
1882
2118
|
static highlightColor(e, t = {}) {
|
|
1883
2119
|
const s = Array.isArray(e) ? e : [e], { opacity: n = 0.5, color: r = 16711680, overwrite: a = !1, depthWrite: o, multiplyOpacity: c = !1 } = t, l = new P(r).getHex();
|
|
1884
2120
|
for (const h of s)
|
|
1885
|
-
|
|
1886
|
-
|
|
2121
|
+
gr(h, r, n, a) || Z.traverseMeshes(h, (u) => {
|
|
2122
|
+
u.userData[pe] = 1, u.userData[ts] = n, u.userData[ss] = l, u.userData[ns] = a ? 1 : 0, u.userData[rs] = c ? 1 : 0, yt(u), o !== void 0 && ue(u).forEach((p) => {
|
|
1887
2123
|
p && (p.depthWrite = o);
|
|
1888
2124
|
});
|
|
1889
2125
|
});
|
|
@@ -1891,8 +2127,8 @@ class se {
|
|
|
1891
2127
|
static removeHighlightColor(e) {
|
|
1892
2128
|
const t = Array.isArray(e) ? e : [e];
|
|
1893
2129
|
for (const s of t)
|
|
1894
|
-
|
|
1895
|
-
n.userData[
|
|
2130
|
+
yr(s) || Z.traverseMeshes(s, (n) => {
|
|
2131
|
+
n.userData[pe] = 0, bt(n);
|
|
1896
2132
|
});
|
|
1897
2133
|
}
|
|
1898
2134
|
static breatheColor(e, t = {}) {
|
|
@@ -1906,15 +2142,15 @@ class se {
|
|
|
1906
2142
|
);
|
|
1907
2143
|
n.color = new P(n.color).getHex();
|
|
1908
2144
|
for (const r of s)
|
|
1909
|
-
|
|
1910
|
-
a.userData[
|
|
2145
|
+
Z.traverseMeshes(r, (a) => {
|
|
2146
|
+
a.userData[_e] = 1, a.userData[is] = n.color, a.userData[as] = n.speed, a.userData[os] = n.intensity, yt(a);
|
|
1911
2147
|
});
|
|
1912
2148
|
}
|
|
1913
2149
|
static removeBreatheColor(e) {
|
|
1914
2150
|
const t = Array.isArray(e) ? e : [e];
|
|
1915
2151
|
for (const s of t)
|
|
1916
|
-
|
|
1917
|
-
n.userData[
|
|
2152
|
+
Z.traverseMeshes(s, (n) => {
|
|
2153
|
+
n.userData[_e] = 0, bt(n);
|
|
1918
2154
|
});
|
|
1919
2155
|
}
|
|
1920
2156
|
/**
|
|
@@ -1923,8 +2159,8 @@ class se {
|
|
|
1923
2159
|
static wireframe(e, t = !0) {
|
|
1924
2160
|
const s = Array.isArray(e) ? e : [e];
|
|
1925
2161
|
for (const n of s)
|
|
1926
|
-
|
|
1927
|
-
|
|
2162
|
+
Z.traverseMeshes(n, (r) => {
|
|
2163
|
+
ue(r).forEach((a) => {
|
|
1928
2164
|
if (!a) return;
|
|
1929
2165
|
const o = a;
|
|
1930
2166
|
o.wireframe = t, o.needsUpdate = !0;
|
|
@@ -1935,7 +2171,7 @@ class se {
|
|
|
1935
2171
|
* Remove wireframe mode.
|
|
1936
2172
|
*/
|
|
1937
2173
|
static removeWireframe(e) {
|
|
1938
|
-
|
|
2174
|
+
ne.wireframe(e, !1);
|
|
1939
2175
|
}
|
|
1940
2176
|
/**
|
|
1941
2177
|
* Fade in object(s) from fully transparent to original opacity.
|
|
@@ -1943,7 +2179,7 @@ class se {
|
|
|
1943
2179
|
*/
|
|
1944
2180
|
static fadeIn(e, t = {}) {
|
|
1945
2181
|
const { duration: s = 500 } = t;
|
|
1946
|
-
return
|
|
2182
|
+
return ne._fade(e, 0, 1, s);
|
|
1947
2183
|
}
|
|
1948
2184
|
/**
|
|
1949
2185
|
* Fade out object(s) to fully transparent.
|
|
@@ -1951,20 +2187,20 @@ class se {
|
|
|
1951
2187
|
*/
|
|
1952
2188
|
static fadeOut(e, t = {}) {
|
|
1953
2189
|
const { duration: s = 500 } = t;
|
|
1954
|
-
return
|
|
2190
|
+
return ne._fade(e, 1, 0, s);
|
|
1955
2191
|
}
|
|
1956
2192
|
static _fade(e, t, s, n) {
|
|
1957
2193
|
const r = Array.isArray(e) ? e : [e], a = /* @__PURE__ */ new Map();
|
|
1958
2194
|
for (const o of r)
|
|
1959
|
-
|
|
1960
|
-
|
|
2195
|
+
Z.traverseMeshes(o, (c) => {
|
|
2196
|
+
ue(c).forEach((l) => {
|
|
1961
2197
|
if (!l || a.has(l)) return;
|
|
1962
|
-
const h = l.opacity,
|
|
2198
|
+
const h = l.opacity, u = l.transparent, d = s >= 1 ? h : s;
|
|
1963
2199
|
a.set(l, {
|
|
1964
2200
|
material: l,
|
|
1965
|
-
targetOpacity:
|
|
2201
|
+
targetOpacity: d,
|
|
1966
2202
|
originalOpacity: h,
|
|
1967
|
-
originalTransparent:
|
|
2203
|
+
originalTransparent: u
|
|
1968
2204
|
}), l.transparent = !0, l.opacity = t, l.needsUpdate = !0;
|
|
1969
2205
|
});
|
|
1970
2206
|
});
|
|
@@ -1972,19 +2208,19 @@ class se {
|
|
|
1972
2208
|
const c = performance.now();
|
|
1973
2209
|
let l = 0;
|
|
1974
2210
|
const h = () => {
|
|
1975
|
-
const
|
|
2211
|
+
const u = performance.now() - c, d = Math.min(u / n, 1);
|
|
1976
2212
|
if (!r[0].parent) {
|
|
1977
2213
|
cancelAnimationFrame(l), o();
|
|
1978
2214
|
return;
|
|
1979
2215
|
}
|
|
1980
|
-
for (const { material:
|
|
1981
|
-
|
|
1982
|
-
if (
|
|
2216
|
+
for (const { material: b, targetOpacity: S } of a.values())
|
|
2217
|
+
b.opacity = t + (S - t) * d, b.needsUpdate = !0;
|
|
2218
|
+
if (d < 1)
|
|
1983
2219
|
l = requestAnimationFrame(h);
|
|
1984
2220
|
else {
|
|
1985
2221
|
if (s >= 1)
|
|
1986
|
-
for (const { material:
|
|
1987
|
-
|
|
2222
|
+
for (const { material: b, originalOpacity: S, originalTransparent: O } of a.values())
|
|
2223
|
+
b.opacity = S, b.transparent = O, b.needsUpdate = !0;
|
|
1988
2224
|
o();
|
|
1989
2225
|
}
|
|
1990
2226
|
};
|
|
@@ -1992,11 +2228,11 @@ class se {
|
|
|
1992
2228
|
});
|
|
1993
2229
|
}
|
|
1994
2230
|
}
|
|
1995
|
-
const
|
|
2231
|
+
const wt = (i) => {
|
|
1996
2232
|
const e = i.shiftRight(16).bitAnd(255).toFloat().div(255), t = i.shiftRight(8).bitAnd(255).toFloat().div(255), s = i.bitAnd(255).toFloat().div(255);
|
|
1997
|
-
return
|
|
2233
|
+
return xn(e, t, s);
|
|
1998
2234
|
};
|
|
1999
|
-
class
|
|
2235
|
+
class br extends Cn {
|
|
2000
2236
|
viewer;
|
|
2001
2237
|
constructor(e, t) {
|
|
2002
2238
|
super(t), this.viewer = e;
|
|
@@ -2006,7 +2242,7 @@ class ir extends xn {
|
|
|
2006
2242
|
this.viewer.invalidate(), t || this.viewer.removeEventListener("afterControlsUpdate", this._update);
|
|
2007
2243
|
};
|
|
2008
2244
|
easingByMode(e) {
|
|
2009
|
-
const t =
|
|
2245
|
+
const t = wr[e];
|
|
2010
2246
|
return super.easing(t);
|
|
2011
2247
|
}
|
|
2012
2248
|
start(e, t) {
|
|
@@ -2016,10 +2252,10 @@ class ir extends xn {
|
|
|
2016
2252
|
return this.viewer.removeEventListener("afterControlsUpdate", this._update), super.stop();
|
|
2017
2253
|
}
|
|
2018
2254
|
}
|
|
2019
|
-
function
|
|
2255
|
+
function Ii(i, e, t, s = {}, n, r) {
|
|
2020
2256
|
return new Promise((a, o) => {
|
|
2021
|
-
const { duration: c = 1e3, delay: l = 0, repeat: h = !1, mode:
|
|
2022
|
-
n?.(
|
|
2257
|
+
const { duration: c = 1e3, delay: l = 0, repeat: h = !1, mode: u = "Linear.None", yoyo: d = !1 } = s, p = new br(i, e).to(t, c).easingByMode(u).delay(l).onUpdate((b) => {
|
|
2258
|
+
n?.(b, p);
|
|
2023
2259
|
}).onComplete(() => {
|
|
2024
2260
|
a();
|
|
2025
2261
|
}).onStop(() => {
|
|
@@ -2027,43 +2263,43 @@ function ui(i, e, t, s = {}, n, r) {
|
|
|
2027
2263
|
}).onStart(() => {
|
|
2028
2264
|
r?.(p);
|
|
2029
2265
|
});
|
|
2030
|
-
typeof h == "number" ? p.repeat(h) : typeof h == "boolean" && h && p.repeat(1 / 0),
|
|
2266
|
+
typeof h == "number" ? p.repeat(h) : typeof h == "boolean" && h && p.repeat(1 / 0), d && p.repeatDelay(20), p.yoyo(d), p.start();
|
|
2031
2267
|
});
|
|
2032
2268
|
}
|
|
2033
|
-
const
|
|
2034
|
-
"Linear.None":
|
|
2035
|
-
"Quadratic.In":
|
|
2036
|
-
"Quadratic.Out":
|
|
2037
|
-
"Quadratic.InOut":
|
|
2038
|
-
"Cubic.In":
|
|
2039
|
-
"Cubic.Out":
|
|
2040
|
-
"Cubic.InOut":
|
|
2041
|
-
"Quartic.In":
|
|
2042
|
-
"Quartic.Out":
|
|
2043
|
-
"Quartic.InOut":
|
|
2044
|
-
"Quintic.In":
|
|
2045
|
-
"Quintic.Out":
|
|
2046
|
-
"Quintic.InOut":
|
|
2047
|
-
"Sinusoidal.In":
|
|
2048
|
-
"Sinusoidal.Out":
|
|
2049
|
-
"Sinusoidal.InOut":
|
|
2050
|
-
"Exponential.In":
|
|
2051
|
-
"Exponential.Out":
|
|
2052
|
-
"Exponential.InOut":
|
|
2053
|
-
"Circular.In":
|
|
2054
|
-
"Circular.Out":
|
|
2055
|
-
"Circular.InOut":
|
|
2056
|
-
"Elastic.In":
|
|
2057
|
-
"Elastic.Out":
|
|
2058
|
-
"Elastic.InOut":
|
|
2059
|
-
"Back.In":
|
|
2060
|
-
"Back.Out":
|
|
2061
|
-
"Back.InOut":
|
|
2062
|
-
"Bounce.In":
|
|
2063
|
-
"Bounce.Out":
|
|
2064
|
-
"Bounce.InOut":
|
|
2269
|
+
const wr = {
|
|
2270
|
+
"Linear.None": L.Linear.None,
|
|
2271
|
+
"Quadratic.In": L.Quadratic.In,
|
|
2272
|
+
"Quadratic.Out": L.Quadratic.Out,
|
|
2273
|
+
"Quadratic.InOut": L.Quadratic.InOut,
|
|
2274
|
+
"Cubic.In": L.Cubic.In,
|
|
2275
|
+
"Cubic.Out": L.Cubic.Out,
|
|
2276
|
+
"Cubic.InOut": L.Cubic.InOut,
|
|
2277
|
+
"Quartic.In": L.Quartic.In,
|
|
2278
|
+
"Quartic.Out": L.Quartic.Out,
|
|
2279
|
+
"Quartic.InOut": L.Quartic.InOut,
|
|
2280
|
+
"Quintic.In": L.Quintic.In,
|
|
2281
|
+
"Quintic.Out": L.Quintic.Out,
|
|
2282
|
+
"Quintic.InOut": L.Quintic.InOut,
|
|
2283
|
+
"Sinusoidal.In": L.Sinusoidal.In,
|
|
2284
|
+
"Sinusoidal.Out": L.Sinusoidal.Out,
|
|
2285
|
+
"Sinusoidal.InOut": L.Sinusoidal.InOut,
|
|
2286
|
+
"Exponential.In": L.Exponential.In,
|
|
2287
|
+
"Exponential.Out": L.Exponential.Out,
|
|
2288
|
+
"Exponential.InOut": L.Exponential.InOut,
|
|
2289
|
+
"Circular.In": L.Circular.In,
|
|
2290
|
+
"Circular.Out": L.Circular.Out,
|
|
2291
|
+
"Circular.InOut": L.Circular.InOut,
|
|
2292
|
+
"Elastic.In": L.Elastic.In,
|
|
2293
|
+
"Elastic.Out": L.Elastic.Out,
|
|
2294
|
+
"Elastic.InOut": L.Elastic.InOut,
|
|
2295
|
+
"Back.In": L.Back.In,
|
|
2296
|
+
"Back.Out": L.Back.Out,
|
|
2297
|
+
"Back.InOut": L.Back.InOut,
|
|
2298
|
+
"Bounce.In": L.Bounce.In,
|
|
2299
|
+
"Bounce.Out": L.Bounce.Out,
|
|
2300
|
+
"Bounce.InOut": L.Bounce.InOut
|
|
2065
2301
|
};
|
|
2066
|
-
class
|
|
2302
|
+
class Ci {
|
|
2067
2303
|
scene;
|
|
2068
2304
|
planes = /* @__PURE__ */ new Map();
|
|
2069
2305
|
helpers = /* @__PURE__ */ new Map();
|
|
@@ -2072,7 +2308,7 @@ class pi {
|
|
|
2072
2308
|
*/
|
|
2073
2309
|
group;
|
|
2074
2310
|
constructor(e) {
|
|
2075
|
-
this.scene = e, this.group = new
|
|
2311
|
+
this.scene = e, this.group = new Qs(), this.group.name = "__clippingToolGroup", this.scene.add(this.group);
|
|
2076
2312
|
}
|
|
2077
2313
|
/**
|
|
2078
2314
|
* Move all current scene children (except the clipping group itself) into the ClippingGroup,
|
|
@@ -2113,7 +2349,7 @@ class pi {
|
|
|
2113
2349
|
showHelper: r = !1,
|
|
2114
2350
|
helperSize: a = 5,
|
|
2115
2351
|
helperColor: o = 16711680
|
|
2116
|
-
} = t, c = new
|
|
2352
|
+
} = t, c = new Js(new N(s.x, s.y, s.z), n);
|
|
2117
2353
|
return this.planes.set(e, c), this._syncPlanes(), r && this.showHelper(e, a, o), c;
|
|
2118
2354
|
}
|
|
2119
2355
|
/**
|
|
@@ -2130,8 +2366,8 @@ class pi {
|
|
|
2130
2366
|
{ suffix: "-z", normal: { x: 0, y: 0, z: 1 }, constant: -a.z }
|
|
2131
2367
|
], l = [];
|
|
2132
2368
|
for (const h of c) {
|
|
2133
|
-
const
|
|
2134
|
-
this.addPlane(
|
|
2369
|
+
const u = `${e}_${h.suffix}`;
|
|
2370
|
+
this.addPlane(u, { normal: h.normal, constant: h.constant, showHelper: n, helperColor: r }), l.push(u);
|
|
2135
2371
|
}
|
|
2136
2372
|
return l;
|
|
2137
2373
|
}
|
|
@@ -2139,7 +2375,7 @@ class pi {
|
|
|
2139
2375
|
* Add a clipping box from an object's bounding box with optional padding.
|
|
2140
2376
|
*/
|
|
2141
2377
|
addBoxFromObject(e, t, s = 0, n = {}) {
|
|
2142
|
-
const r = new
|
|
2378
|
+
const r = new V().setFromObject(t);
|
|
2143
2379
|
return r.expandByScalar(s), this.addBox(e, r, n);
|
|
2144
2380
|
}
|
|
2145
2381
|
/**
|
|
@@ -2179,7 +2415,7 @@ class pi {
|
|
|
2179
2415
|
this.hideHelper(e);
|
|
2180
2416
|
const n = this.planes.get(e);
|
|
2181
2417
|
if (!n) return;
|
|
2182
|
-
const r = new
|
|
2418
|
+
const r = new Zs(n, t, new P(s).getHex());
|
|
2183
2419
|
r.name = e, this.helpers.set(e, r), this.scene.add(r);
|
|
2184
2420
|
}
|
|
2185
2421
|
/**
|
|
@@ -2205,7 +2441,7 @@ class pi {
|
|
|
2205
2441
|
this.detach(), this.removeAll(), this.scene.remove(this.group);
|
|
2206
2442
|
}
|
|
2207
2443
|
}
|
|
2208
|
-
class
|
|
2444
|
+
class Ai {
|
|
2209
2445
|
scene;
|
|
2210
2446
|
measurements = /* @__PURE__ */ new Map();
|
|
2211
2447
|
_idCounter = 0;
|
|
@@ -2216,10 +2452,10 @@ class fi {
|
|
|
2216
2452
|
* Measure distance between two points.
|
|
2217
2453
|
*/
|
|
2218
2454
|
measureDistance(e, t, s = {}) {
|
|
2219
|
-
const { lineColor: n = 16776960 } = s, r = new
|
|
2455
|
+
const { lineColor: n = 16776960 } = s, r = new N(e.x, e.y, e.z), a = new N(t.x, t.y, t.z), o = r.distanceTo(a), c = `measure_dist_${this._idCounter++}`, l = new F();
|
|
2220
2456
|
l.name = c;
|
|
2221
|
-
const h = new
|
|
2222
|
-
l.add(
|
|
2457
|
+
const h = new q().setFromPoints([r, a]), u = new we({ color: n }), d = new xe(h, u);
|
|
2458
|
+
l.add(d), this.scene.add(l);
|
|
2223
2459
|
const p = {
|
|
2224
2460
|
id: c,
|
|
2225
2461
|
type: "distance",
|
|
@@ -2237,11 +2473,11 @@ class fi {
|
|
|
2237
2473
|
const { lineColor: s = 65280 } = t;
|
|
2238
2474
|
if (e.length < 3)
|
|
2239
2475
|
throw new Error("MeasureTool.measureArea requires at least 3 points");
|
|
2240
|
-
const n = e.map((p) => new
|
|
2476
|
+
const n = e.map((p) => new N(p.x, p.y, p.z)), r = this._calculatePolygonArea(n), a = `measure_area_${this._idCounter++}`, o = new F();
|
|
2241
2477
|
o.name = a;
|
|
2242
|
-
const c = [...n, n[0]], l = new
|
|
2243
|
-
o.add(
|
|
2244
|
-
const
|
|
2478
|
+
const c = [...n, n[0]], l = new q().setFromPoints(c), h = new we({ color: s }), u = new xe(l, h);
|
|
2479
|
+
o.add(u), this.scene.add(o);
|
|
2480
|
+
const d = {
|
|
2245
2481
|
id: a,
|
|
2246
2482
|
type: "area",
|
|
2247
2483
|
value: r,
|
|
@@ -2249,25 +2485,25 @@ class fi {
|
|
|
2249
2485
|
points: n,
|
|
2250
2486
|
object: o
|
|
2251
2487
|
};
|
|
2252
|
-
return this.measurements.set(a,
|
|
2488
|
+
return this.measurements.set(a, d), d;
|
|
2253
2489
|
}
|
|
2254
2490
|
/**
|
|
2255
2491
|
* Measure the angle between three points (vertex at the middle point).
|
|
2256
2492
|
*/
|
|
2257
2493
|
measureAngle(e, t, s, n = {}) {
|
|
2258
|
-
const { lineColor: r = 16746496 } = n, a = new
|
|
2259
|
-
|
|
2260
|
-
const
|
|
2261
|
-
|
|
2262
|
-
const
|
|
2494
|
+
const { lineColor: r = 16746496 } = n, a = new N(e.x, e.y, e.z), o = new N(t.x, t.y, t.z), c = new N(s.x, s.y, s.z), l = a.clone().sub(o).normalize(), h = c.clone().sub(o).normalize(), d = Math.acos(Math.max(-1, Math.min(1, l.dot(h)))) * 180 / Math.PI, p = `measure_angle_${this._idCounter++}`, b = new F();
|
|
2495
|
+
b.name = p;
|
|
2496
|
+
const S = new q().setFromPoints([a, o, c]), O = new we({ color: r }), I = new xe(S, O);
|
|
2497
|
+
b.add(I), this.scene.add(b);
|
|
2498
|
+
const x = {
|
|
2263
2499
|
id: p,
|
|
2264
2500
|
type: "angle",
|
|
2265
|
-
value:
|
|
2501
|
+
value: d,
|
|
2266
2502
|
unit: "°",
|
|
2267
2503
|
points: [a, o, c],
|
|
2268
|
-
object:
|
|
2504
|
+
object: b
|
|
2269
2505
|
};
|
|
2270
|
-
return this.measurements.set(p,
|
|
2506
|
+
return this.measurements.set(p, x), x;
|
|
2271
2507
|
}
|
|
2272
2508
|
/**
|
|
2273
2509
|
* Get a measurement result by id.
|
|
@@ -2302,12 +2538,12 @@ class fi {
|
|
|
2302
2538
|
* Calculate polygon area using cross product method (Newell's method).
|
|
2303
2539
|
*/
|
|
2304
2540
|
_calculatePolygonArea(e) {
|
|
2305
|
-
const t = e.length, s = new
|
|
2541
|
+
const t = e.length, s = new N();
|
|
2306
2542
|
for (let r = 0; r < t; r++) {
|
|
2307
|
-
const a = e[r], o = e[(r + 1) % t], c = new
|
|
2543
|
+
const a = e[r], o = e[(r + 1) % t], c = new N().crossVectors(a, o);
|
|
2308
2544
|
s.add(c);
|
|
2309
2545
|
}
|
|
2310
|
-
const n = new
|
|
2546
|
+
const n = new N();
|
|
2311
2547
|
if (t >= 3) {
|
|
2312
2548
|
const r = e[1].clone().sub(e[0]), a = e[2].clone().sub(e[0]);
|
|
2313
2549
|
n.crossVectors(r, a).normalize();
|
|
@@ -2318,7 +2554,7 @@ class fi {
|
|
|
2318
2554
|
this.removeAll();
|
|
2319
2555
|
}
|
|
2320
2556
|
}
|
|
2321
|
-
class
|
|
2557
|
+
class Oi {
|
|
2322
2558
|
scene;
|
|
2323
2559
|
annotations = /* @__PURE__ */ new Map();
|
|
2324
2560
|
_idCounter = 0;
|
|
@@ -2338,9 +2574,9 @@ class mi {
|
|
|
2338
2574
|
*/
|
|
2339
2575
|
add(e, t) {
|
|
2340
2576
|
this.annotations.has(e) && this.remove(e);
|
|
2341
|
-
const s = new
|
|
2577
|
+
const s = new F();
|
|
2342
2578
|
s.name = `annotation_${e}`;
|
|
2343
|
-
const n = new
|
|
2579
|
+
const n = new N(t.position.x, t.position.y, t.position.z);
|
|
2344
2580
|
s.position.copy(n);
|
|
2345
2581
|
const r = document.createElement("div");
|
|
2346
2582
|
if (r.innerHTML = t.content, r.style.cssText = `
|
|
@@ -2359,11 +2595,11 @@ class mi {
|
|
|
2359
2595
|
let a = null;
|
|
2360
2596
|
const o = t.labelOffset || { x: 0, y: 2, z: 0 };
|
|
2361
2597
|
if (t.showLeaderLine !== !1) {
|
|
2362
|
-
const { lineColor: l = 16777215 } = t, h = new
|
|
2363
|
-
new
|
|
2364
|
-
new
|
|
2365
|
-
]),
|
|
2366
|
-
a = new
|
|
2598
|
+
const { lineColor: l = 16777215 } = t, h = new q().setFromPoints([
|
|
2599
|
+
new N(0, 0, 0),
|
|
2600
|
+
new N(o.x, o.y, o.z)
|
|
2601
|
+
]), u = new we({ color: l });
|
|
2602
|
+
a = new xe(h, u), s.add(a);
|
|
2367
2603
|
}
|
|
2368
2604
|
if (this._createCSSObject) {
|
|
2369
2605
|
const l = this._createCSSObject(r);
|
|
@@ -2471,8 +2707,8 @@ class mi {
|
|
|
2471
2707
|
this.removeAll();
|
|
2472
2708
|
}
|
|
2473
2709
|
}
|
|
2474
|
-
const
|
|
2475
|
-
function
|
|
2710
|
+
const xt = new D(), xr = 1e-6, Mr = 1e-6, Mt = "uSpaceInstanceOriginalMaterialState", vt = 0, Pe = 1, vr = 2;
|
|
2711
|
+
function Sr(i) {
|
|
2476
2712
|
let e = i;
|
|
2477
2713
|
for (; e; ) {
|
|
2478
2714
|
if (!e.visible) return !1;
|
|
@@ -2480,57 +2716,57 @@ function hr(i) {
|
|
|
2480
2716
|
}
|
|
2481
2717
|
return !0;
|
|
2482
2718
|
}
|
|
2483
|
-
function
|
|
2719
|
+
function Er(i, e) {
|
|
2484
2720
|
const t = i.elements, s = e.elements;
|
|
2485
2721
|
for (let n = 0; n < 16; n++)
|
|
2486
|
-
if (Math.abs(t[n] - s[n]) >
|
|
2722
|
+
if (Math.abs(t[n] - s[n]) > xr) return !1;
|
|
2487
2723
|
return !0;
|
|
2488
2724
|
}
|
|
2489
|
-
function
|
|
2725
|
+
function cs(i) {
|
|
2490
2726
|
const e = i.material;
|
|
2491
2727
|
return Array.isArray(e) ? e : [e];
|
|
2492
2728
|
}
|
|
2493
|
-
function
|
|
2494
|
-
const e = i.userData, t = e[
|
|
2729
|
+
function ls(i) {
|
|
2730
|
+
const e = i.userData, t = e[Mt];
|
|
2495
2731
|
if (t) return t;
|
|
2496
2732
|
const s = {
|
|
2497
2733
|
transparent: i.transparent,
|
|
2498
2734
|
opacity: i.opacity
|
|
2499
2735
|
};
|
|
2500
|
-
return e[
|
|
2736
|
+
return e[Mt] = s, s;
|
|
2501
2737
|
}
|
|
2502
|
-
function
|
|
2738
|
+
function Ir(i, e) {
|
|
2503
2739
|
i.traverse((t) => {
|
|
2504
2740
|
const s = t;
|
|
2505
|
-
s.isMesh &&
|
|
2741
|
+
s.isMesh && cs(s).forEach((n) => {
|
|
2506
2742
|
if (!n) return;
|
|
2507
|
-
const r = n, a =
|
|
2743
|
+
const r = n, a = ls(r), o = a.opacity * e;
|
|
2508
2744
|
r.transparent = a.transparent || o < 1, r.opacity = o, r.needsUpdate = !0;
|
|
2509
2745
|
});
|
|
2510
2746
|
});
|
|
2511
2747
|
}
|
|
2512
|
-
function
|
|
2748
|
+
function Cr(i) {
|
|
2513
2749
|
i.traverse((e) => {
|
|
2514
2750
|
const t = e;
|
|
2515
|
-
t.isMesh &&
|
|
2751
|
+
t.isMesh && cs(t).forEach((s) => {
|
|
2516
2752
|
if (!s) return;
|
|
2517
|
-
const n = s, r =
|
|
2753
|
+
const n = s, r = ls(n);
|
|
2518
2754
|
n.transparent = r.transparent, n.opacity = r.opacity, n.needsUpdate = !0;
|
|
2519
2755
|
});
|
|
2520
2756
|
});
|
|
2521
2757
|
}
|
|
2522
|
-
class
|
|
2758
|
+
class Bi extends fe {
|
|
2523
2759
|
isInstanceObject = !0;
|
|
2524
2760
|
type = "InstanceObject";
|
|
2525
2761
|
instanceId = "";
|
|
2526
2762
|
instanceKind = "";
|
|
2527
2763
|
instanceName = "";
|
|
2528
|
-
geometry = new
|
|
2764
|
+
geometry = new q();
|
|
2529
2765
|
boundingBox = null;
|
|
2530
2766
|
boundingSphere = null;
|
|
2531
2767
|
#s = {
|
|
2532
2768
|
color: null,
|
|
2533
|
-
colorMode:
|
|
2769
|
+
colorMode: vt,
|
|
2534
2770
|
opacity: 1
|
|
2535
2771
|
};
|
|
2536
2772
|
#a = null;
|
|
@@ -2538,7 +2774,7 @@ class gi extends pe {
|
|
|
2538
2774
|
#e = null;
|
|
2539
2775
|
#r = null;
|
|
2540
2776
|
#n = /* @__PURE__ */ new Set();
|
|
2541
|
-
#o = new
|
|
2777
|
+
#o = new D();
|
|
2542
2778
|
#c = !1;
|
|
2543
2779
|
#l = !0;
|
|
2544
2780
|
#d = !1;
|
|
@@ -2565,9 +2801,9 @@ class gi extends pe {
|
|
|
2565
2801
|
setInstanceBounds(e) {
|
|
2566
2802
|
if (e.isEmpty()) return this;
|
|
2567
2803
|
this.#t && this.remove(this.#t);
|
|
2568
|
-
const t = new
|
|
2804
|
+
const t = new q();
|
|
2569
2805
|
t.boundingBox = e.clone();
|
|
2570
|
-
const s = new
|
|
2806
|
+
const s = new en();
|
|
2571
2807
|
return s.name = this.#u, s.visible = !1, s.geometry = t, s.raycast = () => {
|
|
2572
2808
|
}, this.#t = s, this.add(s), this.#h(), this.markInstanceRenderDirty(), this;
|
|
2573
2809
|
}
|
|
@@ -2590,31 +2826,31 @@ class gi extends pe {
|
|
|
2590
2826
|
return this.#r?.() ?? this.#e ?? null;
|
|
2591
2827
|
}
|
|
2592
2828
|
computeBoundingBox() {
|
|
2593
|
-
this.boundingBox === null && (this.boundingBox = new
|
|
2829
|
+
this.boundingBox === null && (this.boundingBox = new V()), this.getInstanceBoundingBox(this.boundingBox, !1);
|
|
2594
2830
|
}
|
|
2595
2831
|
computeBoundingSphere() {
|
|
2596
|
-
if (this.boundingSphere === null && (this.boundingSphere = new
|
|
2832
|
+
if (this.boundingSphere === null && (this.boundingSphere = new re()), this.boundingBox === null && this.computeBoundingBox(), !this.boundingBox || this.boundingBox.isEmpty()) {
|
|
2597
2833
|
this.boundingSphere.makeEmpty();
|
|
2598
2834
|
return;
|
|
2599
2835
|
}
|
|
2600
2836
|
this.boundingBox.getBoundingSphere(this.boundingSphere);
|
|
2601
2837
|
}
|
|
2602
|
-
getInstanceBoundingBox(e = new
|
|
2838
|
+
getInstanceBoundingBox(e = new V(), t = !1) {
|
|
2603
2839
|
const s = this.#t?.geometry?.boundingBox;
|
|
2604
|
-
return s ? (e.copy(s), t && (this.updateWorldMatrix(!0, !1), e.applyMatrix4(this.matrixWorld)), e) : this.#e ? (e.setFromObject(this.#e), t || (this.updateWorldMatrix(!0, !1),
|
|
2840
|
+
return s ? (e.copy(s), t && (this.updateWorldMatrix(!0, !1), e.applyMatrix4(this.matrixWorld)), e) : this.#e ? (e.setFromObject(this.#e), t || (this.updateWorldMatrix(!0, !1), xt.copy(this.matrixWorld).invert(), e.applyMatrix4(xt)), e) : e.makeEmpty();
|
|
2605
2841
|
}
|
|
2606
2842
|
setInstanceVisible(e) {
|
|
2607
2843
|
return this.visible === e ? this : (this.visible = e, this.markInstanceRenderDirty(), this);
|
|
2608
2844
|
}
|
|
2609
2845
|
setInstanceColor(e) {
|
|
2610
|
-
return this.#s.color = new P(e), this.#s.colorMode =
|
|
2846
|
+
return this.#s.color = new P(e), this.#s.colorMode = Pe, this.#f(), this.markInstanceRenderDirty(), this;
|
|
2611
2847
|
}
|
|
2612
2848
|
resetInstanceColor() {
|
|
2613
|
-
return this.#s.color === null ? this : (this.#s.color = null, this.#s.colorMode =
|
|
2849
|
+
return this.#s.color === null ? this : (this.#s.color = null, this.#s.colorMode = vt, this.#f(), this.markInstanceRenderDirty(), this);
|
|
2614
2850
|
}
|
|
2615
2851
|
setInstanceOpacity(e) {
|
|
2616
2852
|
const t = Math.max(0, Math.min(1, e));
|
|
2617
|
-
return Math.abs(this.#s.opacity - t) <=
|
|
2853
|
+
return Math.abs(this.#s.opacity - t) <= Mr ? this : (this.#s.opacity = t, this.#f(), this.markInstanceRenderDirty(), this);
|
|
2618
2854
|
}
|
|
2619
2855
|
getInstanceColor(e = new P()) {
|
|
2620
2856
|
const t = this.#p();
|
|
@@ -2629,7 +2865,7 @@ class gi extends pe {
|
|
|
2629
2865
|
setInstanceHighlight(e, t, s = !1) {
|
|
2630
2866
|
return this.#a = {
|
|
2631
2867
|
color: new P(e),
|
|
2632
|
-
colorMode: s ?
|
|
2868
|
+
colorMode: s ? Pe : vr,
|
|
2633
2869
|
opacity: Math.max(0, Math.min(1, t))
|
|
2634
2870
|
}, this.#f(), this.markInstanceRenderDirty(), this;
|
|
2635
2871
|
}
|
|
@@ -2652,8 +2888,8 @@ class gi extends pe {
|
|
|
2652
2888
|
super.updateWorldMatrix(e, t), this.#i();
|
|
2653
2889
|
}
|
|
2654
2890
|
#i() {
|
|
2655
|
-
const e =
|
|
2656
|
-
(!this.#c || !
|
|
2891
|
+
const e = Sr(this);
|
|
2892
|
+
(!this.#c || !Er(this.matrixWorld, this.#o) || !this.#d || e !== this.#l) && (this.#c = !0, this.#d = !0, this.#o.copy(this.matrixWorld), this.#l = e, this.markInstanceRenderDirty());
|
|
2657
2893
|
}
|
|
2658
2894
|
#h() {
|
|
2659
2895
|
this.boundingBox = null, this.boundingSphere = null;
|
|
@@ -2665,36 +2901,36 @@ class gi extends pe {
|
|
|
2665
2901
|
if (!this.#e) return;
|
|
2666
2902
|
const e = this.#p();
|
|
2667
2903
|
if (e.color) {
|
|
2668
|
-
|
|
2904
|
+
Cr(this.#e), ne.highlightColor(this.#e, {
|
|
2669
2905
|
color: e.color,
|
|
2670
2906
|
opacity: e.opacity,
|
|
2671
|
-
overwrite: e.colorMode ===
|
|
2907
|
+
overwrite: e.colorMode === Pe,
|
|
2672
2908
|
multiplyOpacity: !0
|
|
2673
2909
|
});
|
|
2674
2910
|
return;
|
|
2675
2911
|
}
|
|
2676
|
-
|
|
2912
|
+
ne.removeHighlightColor(this.#e), Ir(this.#e, e.opacity);
|
|
2677
2913
|
}
|
|
2678
2914
|
}
|
|
2679
|
-
function
|
|
2915
|
+
function _i(i) {
|
|
2680
2916
|
return i.isInstanceObject === !0;
|
|
2681
2917
|
}
|
|
2682
|
-
const
|
|
2918
|
+
const Ar = /* @__PURE__ */ new Set([
|
|
2683
2919
|
"MeshBasicMaterial",
|
|
2684
2920
|
"MeshLambertMaterial",
|
|
2685
2921
|
"MeshPhongMaterial",
|
|
2686
2922
|
"MeshStandardMaterial",
|
|
2687
2923
|
"MeshPhysicalMaterial"
|
|
2688
|
-
]),
|
|
2689
|
-
let
|
|
2690
|
-
const
|
|
2691
|
-
function
|
|
2924
|
+
]), St = /* @__PURE__ */ new WeakMap();
|
|
2925
|
+
let Or = 1;
|
|
2926
|
+
const Et = new D(), he = new D(), It = new D();
|
|
2927
|
+
function Br(i, e, t = 1e-6) {
|
|
2692
2928
|
const s = i.elements, n = e.elements;
|
|
2693
2929
|
for (let r = 0; r < 16; r++)
|
|
2694
2930
|
if (Math.abs(s[r] - n[r]) > t) return !1;
|
|
2695
2931
|
return !0;
|
|
2696
2932
|
}
|
|
2697
|
-
function
|
|
2933
|
+
function hs(i) {
|
|
2698
2934
|
let e = i;
|
|
2699
2935
|
for (; e; ) {
|
|
2700
2936
|
if (!e.visible) return !1;
|
|
@@ -2702,16 +2938,16 @@ function as(i) {
|
|
|
2702
2938
|
}
|
|
2703
2939
|
return !0;
|
|
2704
2940
|
}
|
|
2705
|
-
function
|
|
2941
|
+
function _r(i) {
|
|
2706
2942
|
const e = i.source.data;
|
|
2707
2943
|
if (!e || typeof e != "object" && typeof e != "function")
|
|
2708
2944
|
return `texture:${i.uuid}`;
|
|
2709
|
-
let t =
|
|
2710
|
-
return t === void 0 && (t =
|
|
2945
|
+
let t = St.get(e);
|
|
2946
|
+
return t === void 0 && (t = Or++, St.set(e, t)), `source:${t}`;
|
|
2711
2947
|
}
|
|
2712
|
-
function
|
|
2948
|
+
function Lr(i) {
|
|
2713
2949
|
return JSON.stringify([
|
|
2714
|
-
|
|
2950
|
+
_r(i),
|
|
2715
2951
|
i.mapping,
|
|
2716
2952
|
i.channel,
|
|
2717
2953
|
i.wrapS,
|
|
@@ -2736,30 +2972,30 @@ function br(i) {
|
|
|
2736
2972
|
"compareFunction" in i ? i.compareFunction : null
|
|
2737
2973
|
]);
|
|
2738
2974
|
}
|
|
2739
|
-
function
|
|
2740
|
-
if (Array.isArray(i)) return i.map(
|
|
2975
|
+
function We(i) {
|
|
2976
|
+
if (Array.isArray(i)) return i.map(We);
|
|
2741
2977
|
if (!i || typeof i != "object") return i;
|
|
2742
2978
|
const e = i;
|
|
2743
2979
|
return Object.fromEntries(
|
|
2744
|
-
Object.keys(e).sort().map((t) => [t,
|
|
2980
|
+
Object.keys(e).sort().map((t) => [t, We(e[t])])
|
|
2745
2981
|
);
|
|
2746
2982
|
}
|
|
2747
|
-
function
|
|
2748
|
-
if (Array.isArray(i)) return i.map((s) =>
|
|
2983
|
+
function Fe(i, e) {
|
|
2984
|
+
if (Array.isArray(i)) return i.map((s) => Fe(s, e));
|
|
2749
2985
|
if (!i || typeof i != "object")
|
|
2750
2986
|
return typeof i == "string" ? e.get(i) ?? i : i;
|
|
2751
2987
|
const t = i;
|
|
2752
2988
|
return Object.fromEntries(
|
|
2753
|
-
Object.keys(t).filter((s) => s !== "metadata" && s !== "uuid" && s !== "name").sort().map((s) => [s,
|
|
2989
|
+
Object.keys(t).filter((s) => s !== "metadata" && s !== "uuid" && s !== "name").sort().map((s) => [s, Fe(t[s], e)])
|
|
2754
2990
|
);
|
|
2755
2991
|
}
|
|
2756
|
-
function
|
|
2757
|
-
if (!
|
|
2992
|
+
function Tr(i) {
|
|
2993
|
+
if (!Ar.has(i.type) || i.transparent || i.opacity < 0.999 || i.visible === !1) return null;
|
|
2758
2994
|
const e = i;
|
|
2759
2995
|
if (Object.keys(e).some((r) => r.endsWith("Node") && e[r] != null) || Object.hasOwn(i, "onBeforeCompile")) return null;
|
|
2760
2996
|
const t = /* @__PURE__ */ new Map();
|
|
2761
2997
|
Object.values(e).forEach((r) => {
|
|
2762
|
-
r instanceof
|
|
2998
|
+
r instanceof qt && t.set(r.uuid, Lr(r));
|
|
2763
2999
|
});
|
|
2764
3000
|
const s = {
|
|
2765
3001
|
geometries: {},
|
|
@@ -2771,9 +3007,9 @@ function wr(i) {
|
|
|
2771
3007
|
animations: {},
|
|
2772
3008
|
nodes: {}
|
|
2773
3009
|
}, n = i.toJSON(s);
|
|
2774
|
-
return JSON.stringify(
|
|
3010
|
+
return JSON.stringify(We(Fe(n, t)));
|
|
2775
3011
|
}
|
|
2776
|
-
function
|
|
3012
|
+
function Rr(i) {
|
|
2777
3013
|
if (Object.keys(i.morphAttributes).length > 0 || i.drawRange.start !== 0 || i.drawRange.count !== 1 / 0) return null;
|
|
2778
3014
|
const e = Object.entries(i.attributes).sort(([t], [s]) => t.localeCompare(s)).map(([t, s]) => "isInterleavedBufferAttribute" in s ? null : [t, s.itemSize, s.normalized, s.array.constructor.name, s.gpuType]);
|
|
2779
3015
|
return e.some((t) => t === null) ? null : JSON.stringify([
|
|
@@ -2781,15 +3017,15 @@ function xr(i) {
|
|
|
2781
3017
|
e
|
|
2782
3018
|
]);
|
|
2783
3019
|
}
|
|
2784
|
-
function
|
|
3020
|
+
function Nr(i, e) {
|
|
2785
3021
|
const t = [], s = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = !e && (i.animations.length > 0 || i.mixer !== null);
|
|
2786
|
-
return r && n.add("animation"), i.updateWorldMatrix(!0, !0),
|
|
3022
|
+
return r && n.add("animation"), i.updateWorldMatrix(!0, !0), Et.copy(i.matrixWorld).invert(), i.traverseVisible((a) => {
|
|
2787
3023
|
if (!(a instanceof k)) return;
|
|
2788
3024
|
if (r) {
|
|
2789
3025
|
s.add(a);
|
|
2790
3026
|
return;
|
|
2791
3027
|
}
|
|
2792
|
-
if (a instanceof
|
|
3028
|
+
if (a instanceof sn) {
|
|
2793
3029
|
s.add(a), n.add("skinned");
|
|
2794
3030
|
return;
|
|
2795
3031
|
}
|
|
@@ -2801,7 +3037,7 @@ function Mr(i, e) {
|
|
|
2801
3037
|
s.add(a), n.add("material-array");
|
|
2802
3038
|
return;
|
|
2803
3039
|
}
|
|
2804
|
-
const o =
|
|
3040
|
+
const o = Tr(a.material), c = Rr(a.geometry);
|
|
2805
3041
|
if (!o) {
|
|
2806
3042
|
s.add(a), n.add(a.material.transparent || a.material.opacity < 0.999 ? "transparent" : `material:${a.material.type}`);
|
|
2807
3043
|
return;
|
|
@@ -2816,7 +3052,7 @@ function Mr(i, e) {
|
|
|
2816
3052
|
}
|
|
2817
3053
|
t.push({
|
|
2818
3054
|
mesh: a,
|
|
2819
|
-
localMatrix:
|
|
3055
|
+
localMatrix: Et.clone().multiply(a.matrixWorld),
|
|
2820
3056
|
materialKey: o,
|
|
2821
3057
|
geometryKey: c
|
|
2822
3058
|
});
|
|
@@ -2826,8 +3062,8 @@ function Mr(i, e) {
|
|
|
2826
3062
|
fallbackReasons: n
|
|
2827
3063
|
};
|
|
2828
3064
|
}
|
|
2829
|
-
function
|
|
2830
|
-
const t =
|
|
3065
|
+
function Pr(i, e) {
|
|
3066
|
+
const t = Ge(i), s = [], n = [];
|
|
2831
3067
|
return i.traverse((r) => {
|
|
2832
3068
|
r instanceof k && s.push(r);
|
|
2833
3069
|
}), t.traverse((r) => {
|
|
@@ -2836,8 +3072,8 @@ function vr(i, e) {
|
|
|
2836
3072
|
e.has(r) && n[a] && (n[a].visible = !1);
|
|
2837
3073
|
}), t;
|
|
2838
3074
|
}
|
|
2839
|
-
function
|
|
2840
|
-
const e =
|
|
3075
|
+
function Dr(i) {
|
|
3076
|
+
const e = Ge(i), t = /* @__PURE__ */ new Map(), s = (n) => {
|
|
2841
3077
|
let r = t.get(n);
|
|
2842
3078
|
return r || (r = n.clone(), t.set(n, r)), r;
|
|
2843
3079
|
};
|
|
@@ -2845,24 +3081,24 @@ function Sr(i) {
|
|
|
2845
3081
|
n instanceof k && (n.material = Array.isArray(n.material) ? n.material.map(s) : s(n.material));
|
|
2846
3082
|
}), e;
|
|
2847
3083
|
}
|
|
2848
|
-
function
|
|
3084
|
+
function Ur(i) {
|
|
2849
3085
|
return Math.max(1, Math.ceil(Math.sqrt(Math.max(1, i))));
|
|
2850
3086
|
}
|
|
2851
|
-
function
|
|
2852
|
-
const e = new
|
|
2853
|
-
return e.magFilter =
|
|
3087
|
+
function kr(i) {
|
|
3088
|
+
const e = new nn(new Float32Array(i * i * 4), i, i, rn, an);
|
|
3089
|
+
return e.magFilter = Ae, e.minFilter = Ae, e.generateMipmaps = !1, e.needsUpdate = !0, e;
|
|
2854
3090
|
}
|
|
2855
|
-
function
|
|
2856
|
-
const t = i.clone(), s =
|
|
2857
|
-
return t.colorNode =
|
|
3091
|
+
function zr(i, e) {
|
|
3092
|
+
const t = i.clone(), s = Mn("batchObjectIndex", "float").toInt(), n = at(vn(ot(e), at(0)).x).toConst(), r = s.mod(n).toConst(), a = s.div(n).toConst(), o = ot(e, Sn(r, a)), c = t.colorNode ?? Oe, l = K(o.a.greaterThan(1.5), c.mul(o.rgb), o.rgb);
|
|
3093
|
+
return t.colorNode = K(o.a.greaterThan(0.5), l, c), t.maskNode = o.a.greaterThan(-0.5), t.needsUpdate = !0, t;
|
|
2858
3094
|
}
|
|
2859
|
-
function
|
|
3095
|
+
function Ct(i) {
|
|
2860
3096
|
let e = 0, t = i.parent;
|
|
2861
3097
|
for (; t; )
|
|
2862
3098
|
e++, t = t.parent;
|
|
2863
3099
|
return e;
|
|
2864
3100
|
}
|
|
2865
|
-
class
|
|
3101
|
+
class jr extends Y {
|
|
2866
3102
|
objectIndices;
|
|
2867
3103
|
states;
|
|
2868
3104
|
#s;
|
|
@@ -2872,17 +3108,17 @@ class Ar extends X {
|
|
|
2872
3108
|
raycast(e, t) {
|
|
2873
3109
|
if (this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0)
|
|
2874
3110
|
return !1;
|
|
2875
|
-
this.#s === void 0 && (this.#s =
|
|
3111
|
+
this.#s === void 0 && (this.#s = Gt(this.geometry));
|
|
2876
3112
|
const s = [];
|
|
2877
3113
|
this.#s ? this.#s.raycastObject3D(this, e, s) : super.raycast(e, s), s.forEach((n) => {
|
|
2878
3114
|
const r = n.faceIndex;
|
|
2879
3115
|
if (r == null) return;
|
|
2880
3116
|
const a = r * 3, o = this.geometry.index?.getX(a) ?? a, c = this.objectIndices[o], l = c === void 0 ? void 0 : this.states[c], h = l?.instance;
|
|
2881
|
-
!l || l.materialized || !h || !
|
|
3117
|
+
!l || l.materialized || !h || !hs(h) || h.getInstanceOpacity() <= 1e-3 || (n.object = h, n.batchObjectIndex = c, t.push(n));
|
|
2882
3118
|
});
|
|
2883
3119
|
}
|
|
2884
3120
|
}
|
|
2885
|
-
class
|
|
3121
|
+
class Li extends fe {
|
|
2886
3122
|
isEditableGeometryBatchLayer = !0;
|
|
2887
3123
|
type = "EditableGeometryBatchLayer";
|
|
2888
3124
|
options;
|
|
@@ -2902,7 +3138,7 @@ class bi extends pe {
|
|
|
2902
3138
|
#e = /* @__PURE__ */ new Map();
|
|
2903
3139
|
#r = /* @__PURE__ */ new Set();
|
|
2904
3140
|
#n = null;
|
|
2905
|
-
#o = new
|
|
3141
|
+
#o = new D();
|
|
2906
3142
|
#c = !1;
|
|
2907
3143
|
#l = !1;
|
|
2908
3144
|
#d = !1;
|
|
@@ -2924,7 +3160,7 @@ class bi extends pe {
|
|
|
2924
3160
|
);
|
|
2925
3161
|
r.add(l);
|
|
2926
3162
|
});
|
|
2927
|
-
const { meshes: a, fallbackMeshes: o, fallbackReasons: c } =
|
|
3163
|
+
const { meshes: a, fallbackMeshes: o, fallbackReasons: c } = Nr(
|
|
2928
3164
|
s,
|
|
2929
3165
|
this.options.freezeAnimations
|
|
2930
3166
|
);
|
|
@@ -2935,7 +3171,7 @@ class bi extends pe {
|
|
|
2935
3171
|
meshes: a,
|
|
2936
3172
|
fallbackMeshes: o,
|
|
2937
3173
|
fallbackReasons: c,
|
|
2938
|
-
bounds: new
|
|
3174
|
+
bounds: new V().setFromObject(s)
|
|
2939
3175
|
}), a.length > 0;
|
|
2940
3176
|
}
|
|
2941
3177
|
build() {
|
|
@@ -2952,7 +3188,7 @@ class bi extends pe {
|
|
|
2952
3188
|
this.#s.forEach((r) => {
|
|
2953
3189
|
const a = [], o = [];
|
|
2954
3190
|
r.instances.forEach((l) => {
|
|
2955
|
-
l.updateWorldMatrix(!0, !1),
|
|
3191
|
+
l.updateWorldMatrix(!0, !1), he.multiplyMatrices(this.#o, l.matrixWorld), he.determinant() <= 0 ? o.push(l) : a.push({ instance: l, matrix: he.clone() });
|
|
2956
3192
|
});
|
|
2957
3193
|
const c = r.fallbackReasons.size > 0 ? r.fallbackReasons : /* @__PURE__ */ new Set(["unknown"]);
|
|
2958
3194
|
if (r.meshes.length === 0) {
|
|
@@ -2971,7 +3207,7 @@ class bi extends pe {
|
|
|
2971
3207
|
}
|
|
2972
3208
|
r.fallbackMeshes.size > 0 && s(
|
|
2973
3209
|
r,
|
|
2974
|
-
|
|
3210
|
+
Pr(
|
|
2975
3211
|
r.template,
|
|
2976
3212
|
new Set(r.meshes.map(({ mesh: l }) => l))
|
|
2977
3213
|
),
|
|
@@ -2983,50 +3219,50 @@ class bi extends pe {
|
|
|
2983
3219
|
o,
|
|
2984
3220
|
/* @__PURE__ */ new Set([...r.fallbackReasons, "negative-scale"])
|
|
2985
3221
|
), a.forEach(({ instance: l, matrix: h }) => {
|
|
2986
|
-
const
|
|
3222
|
+
const u = this.#t.length, d = () => this.materialize(l), p = {
|
|
2987
3223
|
instance: l,
|
|
2988
3224
|
template: r.template,
|
|
2989
3225
|
initialMatrix: h,
|
|
2990
|
-
objectIndex:
|
|
3226
|
+
objectIndex: u,
|
|
2991
3227
|
materialized: !1,
|
|
2992
|
-
materializer:
|
|
3228
|
+
materializer: d,
|
|
2993
3229
|
unsubscribe: () => {
|
|
2994
3230
|
}
|
|
2995
3231
|
};
|
|
2996
|
-
p.unsubscribe = l.onInstanceRenderDirty(() => this.#h(p)), this.#t.push(p), this.#e.set(l, p), l.setInstanceBounds(r.bounds), l.setInstanceMaterializer(
|
|
2997
|
-
|
|
2998
|
-
const
|
|
2999
|
-
|
|
3232
|
+
p.unsubscribe = l.onInstanceRenderDirty(() => this.#h(p)), this.#t.push(p), this.#e.set(l, p), l.setInstanceBounds(r.bounds), l.setInstanceMaterializer(d), this.#r.add(p), r.meshes.forEach(({ mesh: b, localMatrix: S, materialKey: O, geometryKey: I }) => {
|
|
3233
|
+
It.multiplyMatrices(h, S);
|
|
3234
|
+
const x = b.geometry.clone().applyMatrix4(It), g = x.getAttribute("position");
|
|
3235
|
+
x.setAttribute(
|
|
3000
3236
|
"batchObjectIndex",
|
|
3001
|
-
new
|
|
3237
|
+
new tn(new Float32Array(g.count).fill(u), 1)
|
|
3002
3238
|
);
|
|
3003
|
-
const
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
]),
|
|
3010
|
-
geometry:
|
|
3011
|
-
material:
|
|
3012
|
-
castShadow:
|
|
3013
|
-
receiveShadow:
|
|
3014
|
-
renderOrder:
|
|
3015
|
-
objectIndices: new Array(
|
|
3239
|
+
const w = JSON.stringify([
|
|
3240
|
+
O,
|
|
3241
|
+
I,
|
|
3242
|
+
b.castShadow,
|
|
3243
|
+
b.receiveShadow,
|
|
3244
|
+
b.renderOrder
|
|
3245
|
+
]), f = t.get(w), M = {
|
|
3246
|
+
geometry: x,
|
|
3247
|
+
material: b.material,
|
|
3248
|
+
castShadow: b.castShadow,
|
|
3249
|
+
receiveShadow: b.receiveShadow,
|
|
3250
|
+
renderOrder: b.renderOrder,
|
|
3251
|
+
objectIndices: new Array(g.count).fill(u)
|
|
3016
3252
|
};
|
|
3017
|
-
|
|
3253
|
+
f ? f.push(M) : t.set(w, [M]), this.stats.sourceMeshes++, this.stats.vertices += g.count, this.stats.indices += x.index?.count ?? g.count;
|
|
3018
3254
|
});
|
|
3019
3255
|
});
|
|
3020
3256
|
}), this.stats.instances = this.#t.length, this.stats.unsupportedInstances = e.reduce((r, a) => r + a.instances.length, 0);
|
|
3021
|
-
const n =
|
|
3022
|
-
return this.#n =
|
|
3257
|
+
const n = Ur(this.#t.length);
|
|
3258
|
+
return this.#n = kr(n), this.#i(), t.forEach((r) => this.#u(r)), this.stats.batches = this.children.length, this.stats.drawCallsSaved = Math.max(0, this.stats.sourceMeshes - this.stats.batches), this.children.forEach((r) => {
|
|
3023
3259
|
r instanceof k && (r.onBeforeRender = () => this.#i());
|
|
3024
3260
|
}), { stats: { ...this.stats }, unsupported: e };
|
|
3025
3261
|
}
|
|
3026
3262
|
materialize(e) {
|
|
3027
3263
|
const t = this.#e.get(e);
|
|
3028
3264
|
if (!t || t.materialized) return e.getInstanceRenderObject();
|
|
3029
|
-
const s =
|
|
3265
|
+
const s = Dr(t.template);
|
|
3030
3266
|
return s.position.set(0, 0, 0), s.quaternion.identity(), s.scale.set(1, 1, 1), s.matrix.identity(), t.materialized = !0, e.setInstanceRenderObject(s), s.updateWorldMatrix(!0, !0), this.#r.add(t), this.dispatchEvent({ type: "materialize", instance: e, object: s }), s;
|
|
3031
3267
|
}
|
|
3032
3268
|
#u(e) {
|
|
@@ -3036,16 +3272,16 @@ class bi extends pe {
|
|
|
3036
3272
|
const o = a.geometry.getAttribute("position").count, c = a.geometry.index?.count ?? o;
|
|
3037
3273
|
s.length > 0 && (n + o > this.options.maxVerticesPerBatch || r + c > this.options.maxIndicesPerBatch) && (t.push(s), s = [], n = 0, r = 0), s.push(a), n += o, r += c;
|
|
3038
3274
|
}), s.length > 0 && t.push(s), t.forEach((a) => {
|
|
3039
|
-
const o =
|
|
3040
|
-
if (a.forEach((
|
|
3275
|
+
const o = An(a.map((d) => d.geometry), !1);
|
|
3276
|
+
if (a.forEach((d) => d.geometry.dispose()), !o || !this.#n) return;
|
|
3041
3277
|
o.computeBoundingBox(), o.computeBoundingSphere();
|
|
3042
|
-
const c = a[0], l = a.flatMap((
|
|
3278
|
+
const c = a[0], l = a.flatMap((d) => d.objectIndices), h = zr(c.material, this.#n), u = new jr(
|
|
3043
3279
|
o,
|
|
3044
3280
|
h,
|
|
3045
3281
|
l,
|
|
3046
3282
|
this.#t
|
|
3047
3283
|
);
|
|
3048
|
-
|
|
3284
|
+
u.name = `EditableGeometryBatch:${this.children.length}`, u.castShadow = c.castShadow, u.receiveShadow = c.receiveShadow, u.renderOrder = c.renderOrder, u.matrixAutoUpdate = !1, this.add(u);
|
|
3049
3285
|
});
|
|
3050
3286
|
}
|
|
3051
3287
|
#i() {
|
|
@@ -3054,10 +3290,10 @@ class bi extends pe {
|
|
|
3054
3290
|
try {
|
|
3055
3291
|
this.updateWorldMatrix(!0, !1), this.#o.copy(this.matrixWorld).invert();
|
|
3056
3292
|
const e = this.#n.image.data;
|
|
3057
|
-
[...this.#r].sort((t, s) =>
|
|
3293
|
+
[...this.#r].sort((t, s) => Ct(t.instance) - Ct(s.instance)).forEach((t) => {
|
|
3058
3294
|
const { instance: s, objectIndex: n } = t;
|
|
3059
|
-
s.updateWorldMatrix(!0, !1),
|
|
3060
|
-
const r = n * 4, a = !t.materialized &&
|
|
3295
|
+
s.updateWorldMatrix(!0, !1), he.multiplyMatrices(this.#o, s.matrixWorld), !t.materialized && s.getInstanceRenderObject() !== null && !s.hasInstanceMaterializer(t.materializer) && (t.materialized = !0), !t.materialized && !Br(he, t.initialMatrix) && this.materialize(s), !t.materialized && s.getInstanceOpacity() < 0.999 && this.materialize(s);
|
|
3296
|
+
const r = n * 4, a = !t.materialized && hs(s) && s.getInstanceOpacity() > 1e-3, o = s.getInstanceColor();
|
|
3061
3297
|
e[r] = o.r, e[r + 1] = o.g, e[r + 2] = o.b, e[r + 3] = a ? s.getInstanceColorMode() : -1, this.#r.delete(t);
|
|
3062
3298
|
}), this.#n.needsUpdate = !0;
|
|
3063
3299
|
} finally {
|
|
@@ -3078,20 +3314,20 @@ class bi extends pe {
|
|
|
3078
3314
|
}), this.clear());
|
|
3079
3315
|
}
|
|
3080
3316
|
}
|
|
3081
|
-
const
|
|
3082
|
-
function
|
|
3317
|
+
const At = new D(), ye = new D(), Ot = new D(), Bt = new D(), _t = new V(), Lt = new re(), Tt = new re(), Wr = new on(), te = new P(), Rt = new j(), Nt = new N(), Pt = new D(), Dt = new D(), Ut = new re(), be = [], ds = 1e-6, H = 1e-6, us = 0.999, Fr = 0, kt = 1;
|
|
3318
|
+
function Gr(i, e, t) {
|
|
3083
3319
|
const s = i.elements;
|
|
3084
3320
|
for (let n = 0; n < 16; n++)
|
|
3085
|
-
if (Math.abs(s[n] - e[t + n]) >
|
|
3321
|
+
if (Math.abs(s[n] - e[t + n]) > ds) return !1;
|
|
3086
3322
|
return !0;
|
|
3087
3323
|
}
|
|
3088
|
-
function
|
|
3324
|
+
function Hr(i, e, t, s) {
|
|
3089
3325
|
return Math.abs(i.r - t[s]) <= H && Math.abs(i.g - t[s + 1]) <= H && Math.abs(i.b - t[s + 2]) <= H && Math.abs(e - t[s + 3]) <= H;
|
|
3090
3326
|
}
|
|
3091
|
-
function
|
|
3327
|
+
function zt(i, e) {
|
|
3092
3328
|
const t = i.elements, s = e.elements;
|
|
3093
3329
|
for (let n = 0; n < 16; n++)
|
|
3094
|
-
if (Math.abs(t[n] - s[n]) >
|
|
3330
|
+
if (Math.abs(t[n] - s[n]) > ds) return !1;
|
|
3095
3331
|
return !0;
|
|
3096
3332
|
}
|
|
3097
3333
|
function De(i) {
|
|
@@ -3102,11 +3338,11 @@ function De(i) {
|
|
|
3102
3338
|
}
|
|
3103
3339
|
return !0;
|
|
3104
3340
|
}
|
|
3105
|
-
function
|
|
3341
|
+
function $r(i) {
|
|
3106
3342
|
const e = i.geometry.morphAttributes;
|
|
3107
3343
|
return Object.values(e).some((t) => t?.length);
|
|
3108
3344
|
}
|
|
3109
|
-
function
|
|
3345
|
+
function Kr(i) {
|
|
3110
3346
|
const e = i.material;
|
|
3111
3347
|
if (!Array.isArray(e)) return !0;
|
|
3112
3348
|
if (e.length === 0 || !e.every(Boolean)) return !1;
|
|
@@ -3116,28 +3352,28 @@ function Nr(i) {
|
|
|
3116
3352
|
return Number.isInteger(s.start) && s.start >= 0 && Number.isInteger(s.count) && s.count > 0 && Number.isInteger(n) && n >= 0 && n < e.length;
|
|
3117
3353
|
});
|
|
3118
3354
|
}
|
|
3119
|
-
function
|
|
3120
|
-
return !i.isSkinnedMesh &&
|
|
3355
|
+
function qr(i) {
|
|
3356
|
+
return !i.isSkinnedMesh && !$r(i) && Kr(i);
|
|
3121
3357
|
}
|
|
3122
|
-
function
|
|
3358
|
+
function jt(i) {
|
|
3123
3359
|
return Array.isArray(i) ? i : [i];
|
|
3124
3360
|
}
|
|
3125
|
-
function
|
|
3126
|
-
return i.transparent || i.opacity <
|
|
3361
|
+
function ps(i) {
|
|
3362
|
+
return i.transparent || i.opacity < us;
|
|
3127
3363
|
}
|
|
3128
|
-
function
|
|
3129
|
-
const s = i.clone(), n =
|
|
3130
|
-
return s.colorNode =
|
|
3364
|
+
function Wt(i, e, t) {
|
|
3365
|
+
const s = i.clone(), n = ct(e, "vec4", 4, 0), r = ct(t, "float", 1, 0), a = s.colorNode ?? Oe, o = s.opacityNode ? En(s.opacityNode) : je, c = K(n.a.greaterThan(1.5), a.mul(n.rgb), n.rgb);
|
|
3366
|
+
return s.colorNode = K(n.a.greaterThan(0.5), c, a), s.opacityNode = o.mul(r), s.transparent = ps(i), s.needsUpdate = !0, s;
|
|
3131
3367
|
}
|
|
3132
|
-
function
|
|
3133
|
-
return Array.isArray(i) ? i.map((s) =>
|
|
3368
|
+
function Vr(i, e, t) {
|
|
3369
|
+
return Array.isArray(i) ? i.map((s) => Wt(s, e, t)) : Wt(i, e, t);
|
|
3134
3370
|
}
|
|
3135
|
-
function
|
|
3136
|
-
const e = [], t = new
|
|
3371
|
+
function Xr(i) {
|
|
3372
|
+
const e = [], t = new D();
|
|
3137
3373
|
let s = !1;
|
|
3138
3374
|
return i.updateWorldMatrix(!0, !0), t.copy(i.matrixWorld).invert(), i.traverse((n) => {
|
|
3139
3375
|
if (!s && !(!(n instanceof k) || !n.visible)) {
|
|
3140
|
-
if (!
|
|
3376
|
+
if (!qr(n)) {
|
|
3141
3377
|
s = !0;
|
|
3142
3378
|
return;
|
|
3143
3379
|
}
|
|
@@ -3148,27 +3384,27 @@ function Rr(i) {
|
|
|
3148
3384
|
}
|
|
3149
3385
|
}), s ? [] : e;
|
|
3150
3386
|
}
|
|
3151
|
-
function
|
|
3152
|
-
const e = new
|
|
3387
|
+
function Yr(i) {
|
|
3388
|
+
const e = new V();
|
|
3153
3389
|
return i.forEach(({ mesh: t, localMatrix: s }) => {
|
|
3154
3390
|
const n = t.geometry;
|
|
3155
|
-
n.boundingBox || n.computeBoundingBox(), n.boundingBox && (
|
|
3391
|
+
n.boundingBox || n.computeBoundingBox(), n.boundingBox && (_t.copy(n.boundingBox).applyMatrix4(s), e.union(_t));
|
|
3156
3392
|
}), e;
|
|
3157
3393
|
}
|
|
3158
|
-
function
|
|
3394
|
+
function se(i) {
|
|
3159
3395
|
const e = i;
|
|
3160
3396
|
"needsUpdate" in e && (e.needsUpdate = !0);
|
|
3161
3397
|
}
|
|
3162
|
-
function
|
|
3163
|
-
let t = Math.max(
|
|
3398
|
+
function Ft(i, e = kt) {
|
|
3399
|
+
let t = Math.max(kt, e);
|
|
3164
3400
|
for (; t < i; )
|
|
3165
3401
|
t *= 2;
|
|
3166
3402
|
return t;
|
|
3167
3403
|
}
|
|
3168
|
-
function
|
|
3404
|
+
function Qr(i) {
|
|
3169
3405
|
return i !== null && typeof i == "object" && Symbol.iterator in i;
|
|
3170
3406
|
}
|
|
3171
|
-
class
|
|
3407
|
+
class Ti extends fe {
|
|
3172
3408
|
isModelInstancedLayer = !0;
|
|
3173
3409
|
type = "ModelInstancedLayer";
|
|
3174
3410
|
#s = [];
|
|
@@ -3178,7 +3414,7 @@ class wi extends pe {
|
|
|
3178
3414
|
#r = !0;
|
|
3179
3415
|
#n = !1;
|
|
3180
3416
|
#o = !0;
|
|
3181
|
-
#c =
|
|
3417
|
+
#c = Fr;
|
|
3182
3418
|
#l;
|
|
3183
3419
|
#d;
|
|
3184
3420
|
constructor(e = {}) {
|
|
@@ -3210,7 +3446,7 @@ class wi extends pe {
|
|
|
3210
3446
|
const s = Math.max(0, e.minScreenRadius);
|
|
3211
3447
|
Math.abs(this.#c - s) > H && (this.#c = s, t = !0);
|
|
3212
3448
|
}
|
|
3213
|
-
return t && this.#s.forEach((s) => this.#
|
|
3449
|
+
return t && this.#s.forEach((s) => this.#E(s)), this;
|
|
3214
3450
|
}
|
|
3215
3451
|
setInstanceVisible(e) {
|
|
3216
3452
|
return this.visible !== e && (this.visible = e), this.#i((t) => {
|
|
@@ -3272,7 +3508,7 @@ class wi extends pe {
|
|
|
3272
3508
|
return this.removeInstances([e]) > 0;
|
|
3273
3509
|
}
|
|
3274
3510
|
removeInstances(e) {
|
|
3275
|
-
const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), n = typeof e == "string" || !
|
|
3511
|
+
const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), n = typeof e == "string" || !Qr(e) ? [e] : e;
|
|
3276
3512
|
for (const a of n)
|
|
3277
3513
|
typeof a == "string" ? t.add(a) : this.#t.has(a) && s.add(a);
|
|
3278
3514
|
t.size > 0 && (this.#w(), t.forEach((a) => {
|
|
@@ -3297,9 +3533,9 @@ class wi extends pe {
|
|
|
3297
3533
|
if (n)
|
|
3298
3534
|
return this.#M(n, s), n;
|
|
3299
3535
|
if (t.animations?.length) return null;
|
|
3300
|
-
const r =
|
|
3536
|
+
const r = Xr(t);
|
|
3301
3537
|
if (r.length === 0) return null;
|
|
3302
|
-
const a =
|
|
3538
|
+
const a = Yr(r), o = new F();
|
|
3303
3539
|
o.name = e, this.add(o);
|
|
3304
3540
|
const c = {
|
|
3305
3541
|
url: e,
|
|
@@ -3309,11 +3545,11 @@ class wi extends pe {
|
|
|
3309
3545
|
records: [],
|
|
3310
3546
|
instances: [],
|
|
3311
3547
|
unsubscribeByInstance: /* @__PURE__ */ new Map(),
|
|
3312
|
-
capacity:
|
|
3548
|
+
capacity: Ft(s)
|
|
3313
3549
|
};
|
|
3314
|
-
return r.forEach(({ mesh: l, localMatrix: h },
|
|
3315
|
-
const
|
|
3316
|
-
c.records.push(
|
|
3550
|
+
return r.forEach(({ mesh: l, localMatrix: h }, u) => {
|
|
3551
|
+
const d = this.#h(c, l, h, u);
|
|
3552
|
+
c.records.push(d), this.#s.push(d);
|
|
3317
3553
|
}), this.#a.set(e, c), this.#b(c), c;
|
|
3318
3554
|
}
|
|
3319
3555
|
#i(e) {
|
|
@@ -3325,76 +3561,76 @@ class wi extends pe {
|
|
|
3325
3561
|
});
|
|
3326
3562
|
}
|
|
3327
3563
|
#h(e, t, s, n) {
|
|
3328
|
-
const r = new
|
|
3329
|
-
r.setUsage(
|
|
3330
|
-
const o =
|
|
3564
|
+
const r = new et(new Float32Array(e.capacity * 4), 4), a = new et(new Float32Array(e.capacity).fill(1), 1);
|
|
3565
|
+
r.setUsage(Re), a.setUsage(Re);
|
|
3566
|
+
const o = Vr(
|
|
3331
3567
|
t.material,
|
|
3332
3568
|
r,
|
|
3333
3569
|
a
|
|
3334
|
-
), c =
|
|
3335
|
-
|
|
3336
|
-
), h = new
|
|
3337
|
-
h.instanceMatrix = new
|
|
3338
|
-
const
|
|
3339
|
-
|
|
3340
|
-
const
|
|
3570
|
+
), c = jt(o), l = jt(t.material).some(
|
|
3571
|
+
ps
|
|
3572
|
+
), h = new cn(t.geometry, o, e.capacity);
|
|
3573
|
+
h.instanceMatrix = new ln(e.capacity, 16), h.count = 0, h.name = t.name || `${e.url}#${n}`, h.castShadow = t.castShadow, h.receiveShadow = t.receiveShadow, h.frustumCulled = !0, h.matrixAutoUpdate = !1, h.instanceMatrix.setUsage(Re), h.userData.url = e.url;
|
|
3574
|
+
const u = new k(t.geometry, o);
|
|
3575
|
+
u.matrixAutoUpdate = !1;
|
|
3576
|
+
const d = {
|
|
3341
3577
|
batchRecord: e,
|
|
3342
3578
|
mesh: h,
|
|
3343
3579
|
boundsTree: void 0,
|
|
3344
|
-
raycastMesh:
|
|
3580
|
+
raycastMesh: u,
|
|
3345
3581
|
localMatrix: s.clone(),
|
|
3346
|
-
fullBoundingSphere: new
|
|
3582
|
+
fullBoundingSphere: new re(),
|
|
3347
3583
|
materials: c,
|
|
3348
3584
|
hasSourceTransparency: l,
|
|
3349
3585
|
colorAttribute: r,
|
|
3350
3586
|
opacityAttribute: a,
|
|
3351
3587
|
renderedInstances: [],
|
|
3352
3588
|
visibleInstances: [],
|
|
3353
|
-
lastCameraMatrixWorldInverse: new
|
|
3354
|
-
lastCameraProjectionMatrix: new
|
|
3589
|
+
lastCameraMatrixWorldInverse: new D(),
|
|
3590
|
+
lastCameraProjectionMatrix: new D(),
|
|
3355
3591
|
lastViewportHeight: 0,
|
|
3356
3592
|
hasLastCameraState: !1,
|
|
3357
3593
|
dirty: !0
|
|
3358
3594
|
};
|
|
3359
|
-
h.userData.getInstanceObjectByRenderIndex = (
|
|
3595
|
+
h.userData.getInstanceObjectByRenderIndex = (b) => d.renderedInstances[b], h.userData.raycastAcceleration = "lazy";
|
|
3360
3596
|
const p = h.raycast.bind(h);
|
|
3361
|
-
return h.raycast = (
|
|
3362
|
-
if (this.#
|
|
3363
|
-
|
|
3364
|
-
const
|
|
3365
|
-
|
|
3366
|
-
for (let
|
|
3367
|
-
const
|
|
3368
|
-
if (
|
|
3369
|
-
|
|
3597
|
+
return h.raycast = (b, S) => {
|
|
3598
|
+
if (this.#I(d), !this.#p(d, b)) return;
|
|
3599
|
+
d.boundsTree === void 0 && (d.boundsTree = Gt(d.mesh.geometry), d.mesh.userData.raycastAcceleration = d.boundsTree ? "three-mesh-bvh" : "default");
|
|
3600
|
+
const O = S.length;
|
|
3601
|
+
d.boundsTree ? this.#f(d, b, S) : p(b, S);
|
|
3602
|
+
for (let I = O; I < S.length; ) {
|
|
3603
|
+
const x = S[I], g = x.instanceId;
|
|
3604
|
+
if (g === void 0) {
|
|
3605
|
+
I++;
|
|
3370
3606
|
continue;
|
|
3371
3607
|
}
|
|
3372
|
-
const
|
|
3373
|
-
if (!
|
|
3374
|
-
|
|
3608
|
+
const w = d.renderedInstances[g];
|
|
3609
|
+
if (!w || !De(w)) {
|
|
3610
|
+
S.splice(I, 1);
|
|
3375
3611
|
continue;
|
|
3376
3612
|
}
|
|
3377
|
-
|
|
3613
|
+
x.object = w, x.instanceObject = w, x.instanceObjectId = w.instanceId, x.instanceKind = w.instanceKind || this.#l, x.instanceName = w.instanceName, x.instanceIndex = g, Object.assign(x, this.#d(w, g)), I++;
|
|
3378
3614
|
}
|
|
3379
|
-
}, h.onBeforeRender = (
|
|
3615
|
+
}, h.onBeforeRender = (b, S, O) => this.#I(d, b, O), e.batch.add(h), d;
|
|
3380
3616
|
}
|
|
3381
3617
|
#p(e, t) {
|
|
3382
3618
|
const { mesh: s } = e;
|
|
3383
|
-
return s.count === 0 ? !1 : (s.boundingSphere === null && s.computeBoundingSphere(), s.boundingSphere ? (
|
|
3619
|
+
return s.count === 0 ? !1 : (s.boundingSphere === null && s.computeBoundingSphere(), s.boundingSphere ? (Ut.copy(s.boundingSphere).applyMatrix4(s.matrixWorld), t.ray.intersectsSphere(Ut)) : !0);
|
|
3384
3620
|
}
|
|
3385
3621
|
#f(e, t, s) {
|
|
3386
3622
|
const { mesh: n, boundsTree: r, raycastMesh: a } = e;
|
|
3387
3623
|
if (!(!r || n.count === 0)) {
|
|
3388
3624
|
a.geometry = n.geometry, a.material = n.material;
|
|
3389
3625
|
for (let o = 0; o < n.count; o++)
|
|
3390
|
-
n.getMatrixAt(o,
|
|
3626
|
+
n.getMatrixAt(o, Pt), Dt.multiplyMatrices(n.matrixWorld, Pt), a.matrixWorld.copy(Dt), be.length = 0, r.raycastObject3D(a, t, be), be.forEach((c) => {
|
|
3391
3627
|
c.instanceId = o, c.object = n, s.push(c);
|
|
3392
|
-
}),
|
|
3628
|
+
}), be.length = 0;
|
|
3393
3629
|
}
|
|
3394
3630
|
}
|
|
3395
3631
|
#M(e, t) {
|
|
3396
3632
|
if (t <= e.capacity) return;
|
|
3397
|
-
e.capacity =
|
|
3633
|
+
e.capacity = Ft(t, e.capacity);
|
|
3398
3634
|
const s = new Set(e.records);
|
|
3399
3635
|
s.forEach((n) => this.#S(n)), this.#s = this.#s.filter((n) => !s.has(n)), e.records = e.templateMeshes.map(({ mesh: n, localMatrix: r }, a) => {
|
|
3400
3636
|
const o = this.#h(e, n, r, a);
|
|
@@ -3458,27 +3694,27 @@ class wi extends pe {
|
|
|
3458
3694
|
this.#r = !0;
|
|
3459
3695
|
}
|
|
3460
3696
|
#y(e) {
|
|
3461
|
-
e.records.forEach((t) => this.#
|
|
3697
|
+
e.records.forEach((t) => this.#E(t));
|
|
3462
3698
|
}
|
|
3463
|
-
#
|
|
3464
|
-
e.dirty = !0, e.hasLastCameraState = !1, e.mesh.visible = !0, e.mesh.frustumCulled = !1,
|
|
3699
|
+
#E(e) {
|
|
3700
|
+
e.dirty = !0, e.hasLastCameraState = !1, e.mesh.visible = !0, e.mesh.frustumCulled = !1, se(e.batchRecord.batch);
|
|
3465
3701
|
}
|
|
3466
|
-
#
|
|
3702
|
+
#I(e, t, s) {
|
|
3467
3703
|
const n = this.#O(t), r = this.#B(e, s, n);
|
|
3468
|
-
!e.dirty && !this.#A(e) && !r || this.#
|
|
3704
|
+
!e.dirty && !this.#A(e) && !r || this.#R(e, s, n);
|
|
3469
3705
|
}
|
|
3470
3706
|
#A(e) {
|
|
3471
3707
|
const { instances: t } = e.batchRecord;
|
|
3472
3708
|
for (let s = 0; s < t.length; s++)
|
|
3473
3709
|
if (e.visibleInstances[s] !== De(t[s]))
|
|
3474
|
-
return e.dirty = !0,
|
|
3710
|
+
return e.dirty = !0, se(e.batchRecord.batch), !0;
|
|
3475
3711
|
return !1;
|
|
3476
3712
|
}
|
|
3477
3713
|
#O(e) {
|
|
3478
|
-
return e?.getDrawingBufferSize ? (e.getDrawingBufferSize(
|
|
3714
|
+
return e?.getDrawingBufferSize ? (e.getDrawingBufferSize(Rt), Rt.y) : 0;
|
|
3479
3715
|
}
|
|
3480
3716
|
#B(e, t, s) {
|
|
3481
|
-
return this.#x(t, s) ? e.hasLastCameraState ? !
|
|
3717
|
+
return this.#x(t, s) ? e.hasLastCameraState ? !zt(e.lastCameraMatrixWorldInverse, t.matrixWorldInverse) || !zt(e.lastCameraProjectionMatrix, t.projectionMatrix) || Math.abs(e.lastViewportHeight - s) > H : !0 : !1;
|
|
3482
3718
|
}
|
|
3483
3719
|
#x(e, t) {
|
|
3484
3720
|
return this.#n && e !== void 0 && (this.#o || this.#c > 0 && t > 0);
|
|
@@ -3486,97 +3722,97 @@ class wi extends pe {
|
|
|
3486
3722
|
#_(e, t) {
|
|
3487
3723
|
if (!this.#x(e, t)) return null;
|
|
3488
3724
|
let s = null;
|
|
3489
|
-
return this.#o && (
|
|
3725
|
+
return this.#o && (Bt.multiplyMatrices(e.projectionMatrix, e.matrixWorldInverse), s = Wr.setFromProjectionMatrix(Bt)), { camera: e, frustum: s, viewportHeight: t };
|
|
3490
3726
|
}
|
|
3491
|
-
#
|
|
3492
|
-
return t ? t.frustum && !t.frustum.intersectsSphere(e) ? !1 : this.#c <= 0 || t.viewportHeight <= 0 ? !0 : this.#
|
|
3727
|
+
#L(e, t) {
|
|
3728
|
+
return t ? t.frustum && !t.frustum.intersectsSphere(e) ? !1 : this.#c <= 0 || t.viewportHeight <= 0 ? !0 : this.#T(e, t.camera, t.viewportHeight) >= this.#c : !0;
|
|
3493
3729
|
}
|
|
3494
|
-
#
|
|
3730
|
+
#T(e, t, s) {
|
|
3495
3731
|
const n = Math.abs(t.projectionMatrix.elements[5]);
|
|
3496
3732
|
if (n <= H) return 1 / 0;
|
|
3497
3733
|
if (t.isOrthographicCamera)
|
|
3498
3734
|
return e.radius * n * s * 0.5;
|
|
3499
|
-
|
|
3500
|
-
const r = -
|
|
3735
|
+
Nt.copy(e.center).applyMatrix4(t.matrixWorldInverse);
|
|
3736
|
+
const r = -Nt.z;
|
|
3501
3737
|
return r <= H ? 1 / 0 : e.radius * n * s * 0.5 / r;
|
|
3502
3738
|
}
|
|
3503
|
-
#
|
|
3504
|
-
this.updateWorldMatrix(!0, !1),
|
|
3739
|
+
#R(e, t, s = 0) {
|
|
3740
|
+
this.updateWorldMatrix(!0, !1), At.copy(this.matrixWorld).invert();
|
|
3505
3741
|
const n = e.mesh.instanceMatrix.array, r = e.colorAttribute.array, a = e.opacityAttribute.array, o = e.mesh.geometry;
|
|
3506
|
-
let c = !1, l = !1, h = !1,
|
|
3507
|
-
const
|
|
3508
|
-
o.boundingSphere || o.computeBoundingSphere(), e.fullBoundingSphere.makeEmpty(), e.renderedInstances.length = 0, e.batchRecord.instances.forEach((
|
|
3509
|
-
const
|
|
3510
|
-
e.visibleInstances[
|
|
3511
|
-
const
|
|
3512
|
-
if (!(
|
|
3742
|
+
let c = !1, l = !1, h = !1, u = 0, d = 0, p = !1;
|
|
3743
|
+
const b = e.mesh.count, S = this.#_(t, s);
|
|
3744
|
+
o.boundingSphere || o.computeBoundingSphere(), e.fullBoundingSphere.makeEmpty(), e.renderedInstances.length = 0, e.batchRecord.instances.forEach((x, g) => {
|
|
3745
|
+
const w = De(x);
|
|
3746
|
+
e.visibleInstances[g] = w, x.updateWorldMatrix(!0, !1), ye.multiplyMatrices(At, x.matrixWorld).multiply(e.localMatrix);
|
|
3747
|
+
const f = x.getInstanceOpacity();
|
|
3748
|
+
if (!(w && f > H) || (d++, o.boundingSphere && (Lt.copy(o.boundingSphere).applyMatrix4(ye), e.fullBoundingSphere.union(Lt), S && (Ot.multiplyMatrices(x.matrixWorld, e.localMatrix), Tt.copy(o.boundingSphere).applyMatrix4(Ot), !this.#L(Tt, S)))))
|
|
3513
3749
|
return;
|
|
3514
|
-
const
|
|
3515
|
-
|
|
3516
|
-
const
|
|
3517
|
-
|
|
3518
|
-
}), e.mesh.count =
|
|
3519
|
-
const
|
|
3520
|
-
e.mesh.visible !==
|
|
3521
|
-
const
|
|
3522
|
-
e.materials.forEach((
|
|
3523
|
-
|
|
3750
|
+
const y = u, v = y * 16;
|
|
3751
|
+
Gr(ye, n, v) || (e.mesh.setMatrixAt(y, ye), c = !0), te.copy(x.getInstanceColor(te));
|
|
3752
|
+
const C = x.getInstanceColorMode(), E = y * 4;
|
|
3753
|
+
Hr(te, C, r, E) || (e.colorAttribute.setXYZW(y, te.r, te.g, te.b, C), l = !0), f < us && (p = !0), Math.abs(f - a[y]) > H && (e.opacityAttribute.setX(y, f), h = !0), e.renderedInstances[y] = x, u++;
|
|
3754
|
+
}), e.mesh.count = u, b !== u && (c = !0, l = !0, h = !0, se(e.batchRecord.batch));
|
|
3755
|
+
const O = d > 0;
|
|
3756
|
+
e.mesh.visible !== O && (e.mesh.visible = O, se(e.batchRecord.batch)), e.mesh.frustumCulled !== !0 && (e.mesh.frustumCulled = !0, se(e.batchRecord.batch)), c && (e.mesh.instanceMatrix.needsUpdate = !0), l && (e.colorAttribute.needsUpdate = !0), h && (e.opacityAttribute.needsUpdate = !0), e.mesh.boundingSphere === null && (e.mesh.boundingSphere = new re()), e.mesh.boundingSphere.copy(e.fullBoundingSphere);
|
|
3757
|
+
const I = e.hasSourceTransparency || p;
|
|
3758
|
+
e.materials.forEach((x) => {
|
|
3759
|
+
x.transparent !== I && (x.transparent = I, x.needsUpdate = !0, se(e.batchRecord.batch));
|
|
3524
3760
|
}), t && this.#x(t, s) ? (e.lastCameraMatrixWorldInverse.copy(t.matrixWorldInverse), e.lastCameraProjectionMatrix.copy(t.projectionMatrix), e.lastViewportHeight = s, e.hasLastCameraState = !0) : e.hasLastCameraState = !1, e.dirty = !1;
|
|
3525
3761
|
}
|
|
3526
3762
|
}
|
|
3527
|
-
const
|
|
3528
|
-
typeof window < "u" && (window.__USPACE__ = { version:
|
|
3763
|
+
const Jr = "0.0.33";
|
|
3764
|
+
typeof window < "u" && (window.__USPACE__ = { version: Jr });
|
|
3529
3765
|
export {
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3766
|
+
Oi as AnnotationManager,
|
|
3767
|
+
fe as BaseGroup,
|
|
3768
|
+
Y as BaseMesh,
|
|
3769
|
+
ir as BaseSprite,
|
|
3770
|
+
$i as CSS2DObject,
|
|
3771
|
+
qi as CSS3DObject,
|
|
3772
|
+
Vi as CSS3DSprite,
|
|
3773
|
+
Pi as CSSRenderer,
|
|
3774
|
+
Di as CameraControls,
|
|
3775
|
+
vi as CircleMesh,
|
|
3776
|
+
Ci as ClippingTool,
|
|
3777
|
+
Li as EditableGeometryBatchLayer,
|
|
3778
|
+
es as ExtrudeMesh,
|
|
3779
|
+
vt as INSTANCE_COLOR_MODE_NONE,
|
|
3780
|
+
Pe as INSTANCE_COLOR_MODE_OVERRIDE,
|
|
3781
|
+
vr as INSTANCE_COLOR_MODE_TINT,
|
|
3782
|
+
Bi as InstanceObject,
|
|
3783
|
+
Ui as InteractionEvent,
|
|
3784
|
+
ki as InteractionManager,
|
|
3785
|
+
yi as LightManager,
|
|
3786
|
+
ne as MaterialEffects,
|
|
3787
|
+
Ai as MeasureTool,
|
|
3788
|
+
W as Model,
|
|
3789
|
+
Yn as ModelDecodeWorkerClient,
|
|
3790
|
+
Ee as ModelDecodeWorkerUnavailableError,
|
|
3791
|
+
Ti as ModelInstancedLayer,
|
|
3792
|
+
$ as ModelLoaderManager,
|
|
3793
|
+
zi as ObjectManager,
|
|
3794
|
+
Z as ObjectUtils,
|
|
3795
|
+
Mi as PlaneMesh,
|
|
3796
|
+
xi as Poi,
|
|
3797
|
+
ji as RenderPipeline,
|
|
3798
|
+
Wi as RoomEnvironment,
|
|
3799
|
+
dt as SBMLoader,
|
|
3800
|
+
lt as SBMXLoader,
|
|
3801
|
+
gi as SceneManager,
|
|
3802
|
+
mi as Selection,
|
|
3803
|
+
Zt as ShapeMesh,
|
|
3804
|
+
ar as SphereMesh,
|
|
3805
|
+
Si as TSLEffects,
|
|
3806
|
+
bi as TextureLoaderManager,
|
|
3807
|
+
wi as Topology,
|
|
3808
|
+
ut as TubeMesh,
|
|
3809
|
+
br as Tween,
|
|
3810
|
+
Fi as Viewer,
|
|
3811
|
+
Gi as enableMeshBVHRaycast,
|
|
3812
|
+
Gt as getGeometryBoundsTree,
|
|
3813
|
+
_i as isInstanceObject,
|
|
3814
|
+
Ei as reinterpretType,
|
|
3815
|
+
Xn as reuseDecodedImageContent,
|
|
3816
|
+
Ii as tweenAnimation,
|
|
3817
|
+
Jr as version
|
|
3582
3818
|
};
|