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