iflow-engine-base 3.9.20 → 3.9.21
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/README.md +118 -0
- package/dist/bim-engine-sdk.es.js +7 -7
- package/dist/bim-engine-sdk.umd.js +696 -696
- package/dist/chunks/{engine-2d-mQsokiAx.js → engine-2d-DAiE1uAy.js} +98 -85
- package/dist/chunks/{engine-3d-CeUaONqH.js → engine-3d-CdsLfd0i.js} +1124 -1113
- package/dist/chunks/{engine-720-BrYzIaAW.js → engine-720-K9uF9wMA.js} +40 -26
- package/dist/chunks/{engine-gaussian-BDphGvln.js → engine-gaussian-x3jsCp15.js} +141 -126
- package/dist/chunks/{engine-gis-nj5ISJb2.js → engine-gis-BStgPU0Q.js} +778 -578
- package/dist/chunks/{sdk-assets-F7qFhuao.js → sdk-assets-1SXx8Tbf.js} +1 -1
- package/dist/chunks/{sdk-runtime-DLvF5IZ2.js → sdk-runtime-cY1Wn7o-.js} +1554 -1350
- package/dist/index.d.ts +74 -1
- package/dist2d/dwg-preview.es.js +1075 -859
- package/dist2d/dwg-preview.umd.js +17 -17
- package/distGaussian/gaussian.es.js +396 -75
- package/distGaussian/gaussian.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
3
|
-
var
|
|
4
|
-
class
|
|
1
|
+
import * as c from "three";
|
|
2
|
+
import * as x from "@mkkellogg/gaussian-splats-3d";
|
|
3
|
+
var l = /* @__PURE__ */ ((i) => (i.LoadStart = "gaussian-load-start", i.LoadProgress = "gaussian-load-progress", i.Loaded = "gaussian-loaded", i.LoadError = "gaussian-load-error", i.SceneRemoved = "gaussian-scene-removed", i.FpsUpdated = "gaussian-fps-updated", i.ViewChanged = "gaussian-view-changed", i))(l || {});
|
|
4
|
+
class T {
|
|
5
5
|
listeners = /* @__PURE__ */ new Map();
|
|
6
6
|
on(e, t) {
|
|
7
|
-
const
|
|
8
|
-
this.listeners.has(
|
|
7
|
+
const n = String(e);
|
|
8
|
+
this.listeners.has(n) || this.listeners.set(n, []), this.listeners.get(n).push(t);
|
|
9
9
|
}
|
|
10
10
|
off(e, t) {
|
|
11
|
-
const
|
|
11
|
+
const n = String(e), r = this.listeners.get(n);
|
|
12
12
|
if (!r)
|
|
13
13
|
return;
|
|
14
14
|
const s = r.indexOf(t);
|
|
15
|
-
s !== -1 && r.splice(s, 1), r.length === 0 && this.listeners.delete(
|
|
15
|
+
s !== -1 && r.splice(s, 1), r.length === 0 && this.listeners.delete(n);
|
|
16
16
|
}
|
|
17
17
|
trigger(e, t) {
|
|
18
|
-
const
|
|
19
|
-
!
|
|
18
|
+
const n = this.listeners.get(String(e));
|
|
19
|
+
!n || n.length === 0 || [...n].forEach((r) => {
|
|
20
20
|
try {
|
|
21
21
|
r(t);
|
|
22
22
|
} catch (s) {
|
|
@@ -31,32 +31,32 @@ class c {
|
|
|
31
31
|
this.clear();
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
class
|
|
34
|
+
class E {
|
|
35
35
|
scene;
|
|
36
36
|
constructor(e) {
|
|
37
|
-
this.scene = new
|
|
37
|
+
this.scene = new c.Scene(), e && (this.scene.background = new c.Color(e));
|
|
38
38
|
}
|
|
39
39
|
getScene() {
|
|
40
40
|
return this.scene;
|
|
41
41
|
}
|
|
42
42
|
setBackgroundColor(e) {
|
|
43
|
-
this.scene.background = e == null ? null : new
|
|
43
|
+
this.scene.background = e == null ? null : new c.Color(e);
|
|
44
44
|
}
|
|
45
45
|
dispose() {
|
|
46
46
|
this.scene.clear(), this.scene.background = null, this.scene.environment = null;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
class
|
|
49
|
+
class b {
|
|
50
50
|
camera;
|
|
51
51
|
container;
|
|
52
52
|
cameraUp;
|
|
53
53
|
initialLookAt;
|
|
54
|
-
constructor(e, t,
|
|
55
|
-
this.container = e, this.cameraUp = t, this.initialLookAt = r, this.camera = this.createCamera(
|
|
54
|
+
constructor(e, t, n, r) {
|
|
55
|
+
this.container = e, this.cameraUp = t, this.initialLookAt = r, this.camera = this.createCamera(n);
|
|
56
56
|
}
|
|
57
57
|
createCamera(e) {
|
|
58
|
-
const t = Math.max(this.container.clientWidth, 1),
|
|
59
|
-
return r.position.fromArray(e), r.up.fromArray(this.cameraUp).normalize(), r.lookAt(new
|
|
58
|
+
const t = Math.max(this.container.clientWidth, 1), n = Math.max(this.container.clientHeight, 1), r = new c.PerspectiveCamera(65, t / n, 0.1, 5e3);
|
|
59
|
+
return r.position.fromArray(e), r.up.fromArray(this.cameraUp).normalize(), r.lookAt(new c.Vector3().fromArray(this.initialLookAt)), r.updateProjectionMatrix(), r;
|
|
60
60
|
}
|
|
61
61
|
getCamera() {
|
|
62
62
|
return this.camera;
|
|
@@ -65,13 +65,81 @@ class u {
|
|
|
65
65
|
this.camera.aspect = Math.max(e, 1) / Math.max(t, 1), this.camera.updateProjectionMatrix();
|
|
66
66
|
}
|
|
67
67
|
reset(e, t) {
|
|
68
|
-
e && this.camera.position.fromArray(e), this.camera.lookAt(new
|
|
68
|
+
e && this.camera.position.fromArray(e), this.camera.lookAt(new c.Vector3().fromArray(t ?? this.initialLookAt)), this.camera.updateMatrixWorld(!0);
|
|
69
69
|
}
|
|
70
70
|
dispose() {
|
|
71
71
|
this.camera = null;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
const P = "iflowbim.cn", z = 512, L = 128, U = 150, O = 38, g = 290, y = 190;
|
|
75
|
+
class F {
|
|
76
|
+
THREE;
|
|
77
|
+
text;
|
|
78
|
+
scene;
|
|
79
|
+
camera;
|
|
80
|
+
material;
|
|
81
|
+
sprites = [];
|
|
82
|
+
size;
|
|
83
|
+
viewportWidth = 0;
|
|
84
|
+
viewportHeight = 0;
|
|
85
|
+
constructor(e, t = P) {
|
|
86
|
+
this.THREE = e, this.text = t, this.scene = new e.Scene(), this.camera = new e.OrthographicCamera(0, 1, 1, 0, -10, 10), this.material = new e.SpriteMaterial({
|
|
87
|
+
map: new e.CanvasTexture(this.createTextTexture()),
|
|
88
|
+
transparent: !0,
|
|
89
|
+
opacity: 0.46,
|
|
90
|
+
depthTest: !1,
|
|
91
|
+
depthWrite: !1,
|
|
92
|
+
toneMapped: !1
|
|
93
|
+
}), this.size = new e.Vector2();
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 在当前帧末尾把水印写入同一个 renderer canvas。
|
|
97
|
+
*/
|
|
98
|
+
render(e) {
|
|
99
|
+
if (!e?.domElement || e.domElement.width <= 0 || e.domElement.height <= 0)
|
|
100
|
+
return;
|
|
101
|
+
e.getSize(this.size);
|
|
102
|
+
const t = Math.max(1, Math.floor(this.size.x)), n = Math.max(1, Math.floor(this.size.y));
|
|
103
|
+
this.updateLayout(t, n);
|
|
104
|
+
const r = e.autoClear, s = e.getRenderTarget?.() ?? null, a = e.xr?.enabled;
|
|
105
|
+
e.autoClear = !1, e.xr && (e.xr.enabled = !1), e.setRenderTarget?.(null), e.clearDepth?.(), e.render(this.scene, this.camera), e.setRenderTarget?.(s), e.xr && a !== void 0 && (e.xr.enabled = a), e.autoClear = r;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 释放水印内部纹理和材质,跟随宿主 renderer 生命周期销毁。
|
|
109
|
+
*/
|
|
110
|
+
dispose() {
|
|
111
|
+
this.material.map?.dispose?.(), this.material.dispose?.(), this.sprites.length = 0;
|
|
112
|
+
}
|
|
113
|
+
createTextTexture() {
|
|
114
|
+
const e = document.createElement("canvas");
|
|
115
|
+
e.width = z, e.height = L;
|
|
116
|
+
const t = e.getContext("2d");
|
|
117
|
+
return t && (t.clearRect(0, 0, e.width, e.height), t.textAlign = "center", t.textBaseline = "middle", t.font = "600 54px Arial, Helvetica, sans-serif", t.lineWidth = 3, t.strokeStyle = "rgba(0, 0, 0, 0.20)", t.fillStyle = "rgba(255, 255, 255, 0.24)", t.strokeText(this.text, e.width / 2, e.height / 2), t.fillText(this.text, e.width / 2, e.height / 2)), e;
|
|
118
|
+
}
|
|
119
|
+
updateLayout(e, t) {
|
|
120
|
+
if (e === this.viewportWidth && t === this.viewportHeight)
|
|
121
|
+
return;
|
|
122
|
+
this.viewportWidth = e, this.viewportHeight = t, this.camera.left = -e / 2, this.camera.right = e / 2, this.camera.top = t / 2, this.camera.bottom = -t / 2, this.camera.updateProjectionMatrix();
|
|
123
|
+
const n = Math.ceil(e / g) + 2, r = Math.ceil(t / y) + 2, s = n * r;
|
|
124
|
+
this.ensureSpriteCount(s);
|
|
125
|
+
let a = 0;
|
|
126
|
+
const d = -e / 2 - g / 2, k = -t / 2 - y / 2;
|
|
127
|
+
for (let o = 0; o < r; o += 1)
|
|
128
|
+
for (let h = 0; h < n; h += 1) {
|
|
129
|
+
const f = this.sprites[a], R = d + h * g + o % 2 * (g / 2), I = k + o * y;
|
|
130
|
+
f.position.set(R, I, 0), f.visible = !0, a += 1;
|
|
131
|
+
}
|
|
132
|
+
for (let o = a; o < this.sprites.length; o += 1)
|
|
133
|
+
this.sprites[o].visible = !1;
|
|
134
|
+
}
|
|
135
|
+
ensureSpriteCount(e) {
|
|
136
|
+
for (; this.sprites.length < e; ) {
|
|
137
|
+
const t = new this.THREE.Sprite(this.material);
|
|
138
|
+
t.scale.set(U, O, 1), t.rotation.z = -0.32, t.renderOrder = 999999, this.scene.add(t), this.sprites.push(t);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
class W {
|
|
75
143
|
renderer;
|
|
76
144
|
viewer;
|
|
77
145
|
container;
|
|
@@ -80,14 +148,15 @@ class m {
|
|
|
80
148
|
fpsFrameCount = 0;
|
|
81
149
|
fpsLastTime = performance.now();
|
|
82
150
|
fpsInfo = { fps: 0, frameTimeMs: 0, minFps: 0 };
|
|
151
|
+
watermark;
|
|
83
152
|
onBeforeRenderCallback;
|
|
84
153
|
onAfterRenderCallback;
|
|
85
154
|
onFpsUpdatedCallback;
|
|
86
|
-
constructor(e, t,
|
|
87
|
-
this.container = e, this.renderer = this.createRenderer(r.antialias), this.viewer = new
|
|
155
|
+
constructor(e, t, n, r) {
|
|
156
|
+
this.container = e, this.renderer = this.createRenderer(r.antialias), this.watermark = new F(c), this.viewer = new x.Viewer({
|
|
88
157
|
selfDrivenMode: !1,
|
|
89
158
|
renderer: this.renderer,
|
|
90
|
-
camera:
|
|
159
|
+
camera: n,
|
|
91
160
|
threeScene: t,
|
|
92
161
|
rootElement: e,
|
|
93
162
|
useBuiltInControls: !0,
|
|
@@ -101,7 +170,7 @@ class m {
|
|
|
101
170
|
});
|
|
102
171
|
}
|
|
103
172
|
createRenderer(e) {
|
|
104
|
-
const t = new
|
|
173
|
+
const t = new c.WebGLRenderer({
|
|
105
174
|
antialias: e,
|
|
106
175
|
alpha: !0,
|
|
107
176
|
preserveDrawingBuffer: !1
|
|
@@ -128,18 +197,18 @@ class m {
|
|
|
128
197
|
this.animationId = requestAnimationFrame(() => this.animate()), this.render();
|
|
129
198
|
}
|
|
130
199
|
render() {
|
|
131
|
-
this.onBeforeRenderCallback?.(), this.viewer.update(this.renderer), this.viewer.render(), this.onAfterRenderCallback?.(), this.updateFps();
|
|
200
|
+
this.onBeforeRenderCallback?.(), this.viewer.update(this.renderer), this.viewer.render(), this.watermark.render(this.renderer), this.onAfterRenderCallback?.(), this.updateFps();
|
|
132
201
|
}
|
|
133
202
|
updateFps() {
|
|
134
203
|
this.fpsFrameCount++;
|
|
135
204
|
const e = performance.now(), t = e - this.fpsLastTime;
|
|
136
205
|
if (t < 1e3)
|
|
137
206
|
return;
|
|
138
|
-
const
|
|
207
|
+
const n = Math.round(this.fpsFrameCount * 1e3 / t);
|
|
139
208
|
this.fpsInfo = {
|
|
140
|
-
fps:
|
|
141
|
-
frameTimeMs:
|
|
142
|
-
minFps: this.fpsInfo.minFps === 0 ?
|
|
209
|
+
fps: n,
|
|
210
|
+
frameTimeMs: n > 0 ? 1e3 / n : 0,
|
|
211
|
+
minFps: this.fpsInfo.minFps === 0 ? n : Math.min(this.fpsInfo.minFps, n)
|
|
143
212
|
}, this.fpsFrameCount = 0, this.fpsLastTime = e, this.onFpsUpdatedCallback?.({ ...this.fpsInfo });
|
|
144
213
|
}
|
|
145
214
|
resetFpsStats() {
|
|
@@ -170,10 +239,10 @@ class m {
|
|
|
170
239
|
return { ...this.fpsInfo };
|
|
171
240
|
}
|
|
172
241
|
async dispose() {
|
|
173
|
-
this.pauseRendering(), await this.viewer.dispose(), this.container.contains(this.renderer.domElement) && this.container.removeChild(this.renderer.domElement), this.renderer.dispose(), this.renderer.forceContextLoss();
|
|
242
|
+
this.pauseRendering(), await this.viewer.dispose(), this.container.contains(this.renderer.domElement) && this.container.removeChild(this.renderer.domElement), this.watermark.dispose(), this.renderer.dispose(), this.renderer.forceContextLoss();
|
|
174
243
|
}
|
|
175
244
|
}
|
|
176
|
-
const
|
|
245
|
+
const D = {
|
|
177
246
|
identity: [0, 0, 0, 1],
|
|
178
247
|
"x-90": [-0.7071068, 0, 0, 0.7071068],
|
|
179
248
|
x90: [0.7071068, 0, 0, 0.7071068],
|
|
@@ -184,7 +253,7 @@ const g = {
|
|
|
184
253
|
z90: [0, 0, 0.7071068, 0.7071068],
|
|
185
254
|
z180: [0, 0, 1, 0]
|
|
186
255
|
};
|
|
187
|
-
class
|
|
256
|
+
class K {
|
|
188
257
|
orientationPreset;
|
|
189
258
|
constructor(e = "x180") {
|
|
190
259
|
this.orientationPreset = e;
|
|
@@ -196,7 +265,7 @@ class p {
|
|
|
196
265
|
return this.orientationPreset;
|
|
197
266
|
}
|
|
198
267
|
getOrientationRotation() {
|
|
199
|
-
return [...
|
|
268
|
+
return [...D[this.orientationPreset]];
|
|
200
269
|
}
|
|
201
270
|
active() {
|
|
202
271
|
}
|
|
@@ -207,10 +276,10 @@ class p {
|
|
|
207
276
|
dispose() {
|
|
208
277
|
}
|
|
209
278
|
}
|
|
210
|
-
function
|
|
211
|
-
return `${
|
|
279
|
+
function _(i, e) {
|
|
280
|
+
return `${i}#${e}`;
|
|
212
281
|
}
|
|
213
|
-
class
|
|
282
|
+
class H {
|
|
214
283
|
viewer;
|
|
215
284
|
getDefaultRotation;
|
|
216
285
|
scenes = /* @__PURE__ */ new Map();
|
|
@@ -218,7 +287,7 @@ class M {
|
|
|
218
287
|
this.viewer = e, this.getDefaultRotation = t;
|
|
219
288
|
}
|
|
220
289
|
async loadModel(e, t = {}) {
|
|
221
|
-
const
|
|
290
|
+
const n = this.viewer.getSceneCount(), r = {
|
|
222
291
|
showLoadingUI: !0,
|
|
223
292
|
progressiveLoad: !1,
|
|
224
293
|
position: [0, 0, 0],
|
|
@@ -228,23 +297,23 @@ class M {
|
|
|
228
297
|
};
|
|
229
298
|
await this.viewer.addSplatScene(e, r);
|
|
230
299
|
const s = {
|
|
231
|
-
id: r.id ??
|
|
300
|
+
id: r.id ?? _(e, n),
|
|
232
301
|
name: r.name ?? e.split(/[\\/]/).pop() ?? e,
|
|
233
302
|
url: e,
|
|
234
|
-
index:
|
|
303
|
+
index: n,
|
|
235
304
|
options: r
|
|
236
305
|
};
|
|
237
306
|
return this.scenes.set(s.id, s), s;
|
|
238
307
|
}
|
|
239
308
|
async loadModels(e) {
|
|
240
309
|
const t = [];
|
|
241
|
-
for (const
|
|
242
|
-
t.push(await this.loadModel(
|
|
310
|
+
for (const n of e)
|
|
311
|
+
t.push(await this.loadModel(n.url, n.options));
|
|
243
312
|
return t;
|
|
244
313
|
}
|
|
245
314
|
async unloadModel(e, t = !0) {
|
|
246
|
-
const
|
|
247
|
-
|
|
315
|
+
const n = this.scenes.get(e);
|
|
316
|
+
n && (await this.viewer.removeSplatScene(n.index, t), this.scenes.delete(e), this.reindexScenesAfterRemove(n.index));
|
|
248
317
|
}
|
|
249
318
|
getModel(e) {
|
|
250
319
|
return this.scenes.get(e);
|
|
@@ -257,7 +326,7 @@ class M {
|
|
|
257
326
|
return t == null ? void 0 : this.viewer.getSplatScene(t);
|
|
258
327
|
}
|
|
259
328
|
async clear(e = !1) {
|
|
260
|
-
const t = this.getAllModels().map((
|
|
329
|
+
const t = this.getAllModels().map((n) => n.index);
|
|
261
330
|
t.length > 0 && await this.viewer.removeSplatScenes(t, e), this.scenes.clear();
|
|
262
331
|
}
|
|
263
332
|
reindexScenesAfterRemove(e) {
|
|
@@ -266,10 +335,248 @@ class M {
|
|
|
266
335
|
});
|
|
267
336
|
}
|
|
268
337
|
}
|
|
269
|
-
const
|
|
270
|
-
version:
|
|
271
|
-
},
|
|
272
|
-
|
|
338
|
+
const B = "3.9.20", V = {
|
|
339
|
+
version: B
|
|
340
|
+
}, u = V.version;
|
|
341
|
+
function C() {
|
|
342
|
+
const i = globalThis.crypto?.subtle;
|
|
343
|
+
if (!i)
|
|
344
|
+
throw new Error("[BimEngine] Web Crypto API is required for secure sdkAuth credentials mode");
|
|
345
|
+
return i;
|
|
346
|
+
}
|
|
347
|
+
function p(i) {
|
|
348
|
+
return new TextEncoder().encode(i);
|
|
349
|
+
}
|
|
350
|
+
function m(i) {
|
|
351
|
+
return i.buffer.slice(i.byteOffset, i.byteOffset + i.byteLength);
|
|
352
|
+
}
|
|
353
|
+
function A(i) {
|
|
354
|
+
let e = "";
|
|
355
|
+
return i.forEach((t) => {
|
|
356
|
+
e += String.fromCharCode(t);
|
|
357
|
+
}), btoa(e);
|
|
358
|
+
}
|
|
359
|
+
function $(i) {
|
|
360
|
+
const e = i.getUTCFullYear(), t = String(i.getUTCMonth() + 1).padStart(2, "0"), n = String(i.getUTCDate()).padStart(2, "0");
|
|
361
|
+
return `${e}${t}${n}`;
|
|
362
|
+
}
|
|
363
|
+
async function G(i) {
|
|
364
|
+
const e = await C().digest("SHA-256", m(p(i)));
|
|
365
|
+
return Array.from(new Uint8Array(e)).map((t) => t.toString(16).padStart(2, "0")).join("");
|
|
366
|
+
}
|
|
367
|
+
async function N(i, e) {
|
|
368
|
+
const t = C(), n = await t.importKey("raw", m(i), { name: "HMAC", hash: "SHA-256" }, !1, ["sign"]);
|
|
369
|
+
return t.sign("HMAC", n, m(p(e)));
|
|
370
|
+
}
|
|
371
|
+
function j(i) {
|
|
372
|
+
return p(
|
|
373
|
+
[i.appId, i.engineType, i.requestDate, String(i.timestamp), i.nonce].join("|")
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
async function q(i) {
|
|
377
|
+
const e = C(), t = /* @__PURE__ */ new Date(), n = t.getTime(), r = $(t), s = globalThis.crypto.randomUUID(), a = globalThis.crypto.getRandomValues(new Uint8Array(12)), d = await G(i.appSecret), k = await N(p(d), r), o = await e.importKey("raw", k, "AES-GCM", !1, ["encrypt"]), h = JSON.stringify({
|
|
378
|
+
appKey: i.appKey,
|
|
379
|
+
appSecret: i.appSecret
|
|
380
|
+
}), f = await e.encrypt(
|
|
381
|
+
{
|
|
382
|
+
name: "AES-GCM",
|
|
383
|
+
iv: a,
|
|
384
|
+
additionalData: m(j({
|
|
385
|
+
appId: i.appId,
|
|
386
|
+
engineType: i.engineType,
|
|
387
|
+
requestDate: r,
|
|
388
|
+
timestamp: n,
|
|
389
|
+
nonce: s
|
|
390
|
+
})),
|
|
391
|
+
tagLength: 128
|
|
392
|
+
},
|
|
393
|
+
o,
|
|
394
|
+
m(p(h))
|
|
395
|
+
);
|
|
396
|
+
return {
|
|
397
|
+
appId: i.appId,
|
|
398
|
+
engineType: i.engineType,
|
|
399
|
+
requestDate: r,
|
|
400
|
+
timestamp: n,
|
|
401
|
+
nonce: s,
|
|
402
|
+
iv: A(a),
|
|
403
|
+
cipherText: A(new Uint8Array(f)),
|
|
404
|
+
sdkVersion: i.sdkVersion,
|
|
405
|
+
origin: i.origin,
|
|
406
|
+
product: i.product
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
const S = /* @__PURE__ */ new Map();
|
|
410
|
+
function w(i) {
|
|
411
|
+
return i.replace(/\/+$/, "");
|
|
412
|
+
}
|
|
413
|
+
function M(i) {
|
|
414
|
+
if (i) return i;
|
|
415
|
+
if (typeof window < "u" && typeof window.location?.origin == "string")
|
|
416
|
+
return window.location.origin;
|
|
417
|
+
}
|
|
418
|
+
function J(i, e) {
|
|
419
|
+
return JSON.stringify({
|
|
420
|
+
endpoint: w(i.endpoint),
|
|
421
|
+
token: i.token ?? "",
|
|
422
|
+
appId: i.appId ?? "",
|
|
423
|
+
appKey: i.appKey ?? "",
|
|
424
|
+
appSecret: i.appSecret ?? "",
|
|
425
|
+
origin: M(i.origin) ?? "",
|
|
426
|
+
product: i.product ?? "",
|
|
427
|
+
engineType: e,
|
|
428
|
+
sdkVersion: u
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
async function v(i, e, t) {
|
|
432
|
+
const n = typeof AbortController < "u" ? new AbortController() : void 0, r = n ? setTimeout(() => n.abort(), t) : void 0;
|
|
433
|
+
try {
|
|
434
|
+
const s = await fetch(i, {
|
|
435
|
+
method: "POST",
|
|
436
|
+
headers: {
|
|
437
|
+
"Content-Type": "application/json"
|
|
438
|
+
},
|
|
439
|
+
body: JSON.stringify(e),
|
|
440
|
+
signal: n?.signal
|
|
441
|
+
}), a = await s.json().catch(() => ({}));
|
|
442
|
+
if (!s.ok) {
|
|
443
|
+
const d = a?.error?.message ?? a?.message ?? `SDK authentication failed with status ${s.status}`;
|
|
444
|
+
throw new Error(d);
|
|
445
|
+
}
|
|
446
|
+
return a;
|
|
447
|
+
} finally {
|
|
448
|
+
r != null && clearTimeout(r);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
async function X(i, e) {
|
|
452
|
+
const t = await v(`${w(i.endpoint)}/oauth/sdk-verify`, {
|
|
453
|
+
sdkToken: i.token,
|
|
454
|
+
engineType: e,
|
|
455
|
+
sdkVersion: u,
|
|
456
|
+
origin: M(i.origin),
|
|
457
|
+
product: i.product
|
|
458
|
+
}, i.timeoutMs ?? 8e3);
|
|
459
|
+
return t.sdkToken = i.token, t;
|
|
460
|
+
}
|
|
461
|
+
async function Y(i, e) {
|
|
462
|
+
const t = await q({
|
|
463
|
+
appId: i.appId,
|
|
464
|
+
appKey: i.appKey,
|
|
465
|
+
appSecret: i.appSecret,
|
|
466
|
+
engineType: e,
|
|
467
|
+
sdkVersion: u,
|
|
468
|
+
origin: M(i.origin),
|
|
469
|
+
product: i.product
|
|
470
|
+
}), n = await v(
|
|
471
|
+
`${w(i.endpoint)}/oauth/sdk-token/secure`,
|
|
472
|
+
t,
|
|
473
|
+
i.timeoutMs ?? 8e3
|
|
474
|
+
), r = await v(`${w(i.endpoint)}/oauth/sdk-verify`, {
|
|
475
|
+
sdkToken: n.sdkToken,
|
|
476
|
+
engineType: e,
|
|
477
|
+
sdkVersion: u,
|
|
478
|
+
origin: M(i.origin),
|
|
479
|
+
product: i.product
|
|
480
|
+
}, i.timeoutMs ?? 8e3);
|
|
481
|
+
return r.sdkToken = n.sdkToken, r;
|
|
482
|
+
}
|
|
483
|
+
async function Q(i, e) {
|
|
484
|
+
const t = i?.sdkAuth;
|
|
485
|
+
if (!t)
|
|
486
|
+
return null;
|
|
487
|
+
if (!t.endpoint)
|
|
488
|
+
throw new Error("[BimEngine] sdkAuth.endpoint is required");
|
|
489
|
+
if (!t.token && !(t.appId && t.appKey && t.appSecret))
|
|
490
|
+
return null;
|
|
491
|
+
const n = J(t, e), r = S.get(n);
|
|
492
|
+
if (r) {
|
|
493
|
+
const a = await r;
|
|
494
|
+
return i && (i.__sdkAuthSession = a), a;
|
|
495
|
+
}
|
|
496
|
+
const s = (t.token ? X(t, e) : Y(t, e)).then((a) => {
|
|
497
|
+
if (a.authorized !== !0)
|
|
498
|
+
throw new Error("[BimEngine] SDK authorization rejected");
|
|
499
|
+
return i && (i.__sdkAuthSession = a), a;
|
|
500
|
+
}).catch((a) => {
|
|
501
|
+
throw S.delete(n), a;
|
|
502
|
+
});
|
|
503
|
+
return S.set(n, s), s;
|
|
504
|
+
}
|
|
505
|
+
function Z(i) {
|
|
506
|
+
return i.replace(/\/+$/, "");
|
|
507
|
+
}
|
|
508
|
+
async function ee(i, e, t) {
|
|
509
|
+
const n = typeof AbortController < "u" ? new AbortController() : void 0, r = n ? setTimeout(() => n.abort(), t) : void 0;
|
|
510
|
+
try {
|
|
511
|
+
const s = await fetch(i, {
|
|
512
|
+
method: "POST",
|
|
513
|
+
headers: {
|
|
514
|
+
"Content-Type": "application/json"
|
|
515
|
+
},
|
|
516
|
+
body: JSON.stringify(e),
|
|
517
|
+
signal: n?.signal
|
|
518
|
+
}), a = await s.json().catch(() => ({}));
|
|
519
|
+
if (!s.ok) {
|
|
520
|
+
const d = a?.error?.message ?? a?.message ?? `ViewToken resolve failed with status ${s.status}`;
|
|
521
|
+
throw new Error(d);
|
|
522
|
+
}
|
|
523
|
+
return a;
|
|
524
|
+
} finally {
|
|
525
|
+
r != null && clearTimeout(r);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
function te(i) {
|
|
529
|
+
switch (i) {
|
|
530
|
+
case "2d":
|
|
531
|
+
return "cad_model";
|
|
532
|
+
case "720":
|
|
533
|
+
return "panorama";
|
|
534
|
+
case "gis":
|
|
535
|
+
return "gis_scene";
|
|
536
|
+
case "gaussian":
|
|
537
|
+
return "gaussian_model";
|
|
538
|
+
case "3d":
|
|
539
|
+
default:
|
|
540
|
+
return "model";
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
function ie(i) {
|
|
544
|
+
return {
|
|
545
|
+
models: [
|
|
546
|
+
{
|
|
547
|
+
modelType: i.toLowerCase().endsWith(".json") ? "3dtiles" : "glb",
|
|
548
|
+
url: i
|
|
549
|
+
}
|
|
550
|
+
]
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
function ne(i, e) {
|
|
554
|
+
return {
|
|
555
|
+
applicationId: 0,
|
|
556
|
+
engineType: e,
|
|
557
|
+
assetCategory: te(e),
|
|
558
|
+
url: i,
|
|
559
|
+
urls: [i],
|
|
560
|
+
info: e === "gis" ? ie(i) : void 0
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
async function re(i, e, t) {
|
|
564
|
+
const n = i?.sdkAuth;
|
|
565
|
+
if (!n?.endpoint)
|
|
566
|
+
return ne(e, t);
|
|
567
|
+
let r;
|
|
568
|
+
(n.token || n.appId && n.appKey && n.appSecret) && (r = (await Q(i, t))?.sdkToken);
|
|
569
|
+
const s = {
|
|
570
|
+
viewToken: e,
|
|
571
|
+
engineType: t
|
|
572
|
+
};
|
|
573
|
+
return r && (s.sdkToken = r), ee(
|
|
574
|
+
`${Z(n.endpoint)}/models/view-token/resolve`,
|
|
575
|
+
s,
|
|
576
|
+
n.timeoutMs ?? 8e3
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
class se {
|
|
273
580
|
eventModule;
|
|
274
581
|
sceneModule;
|
|
275
582
|
cameraModule;
|
|
@@ -277,9 +584,10 @@ class I {
|
|
|
277
584
|
controlModule;
|
|
278
585
|
loaderModule;
|
|
279
586
|
isInitialized = !1;
|
|
280
|
-
|
|
587
|
+
options;
|
|
588
|
+
version = u;
|
|
281
589
|
constructor(e) {
|
|
282
|
-
this.initialize(e);
|
|
590
|
+
this.options = e, this.initialize(e);
|
|
283
591
|
}
|
|
284
592
|
initialize(e) {
|
|
285
593
|
const t = {
|
|
@@ -295,49 +603,62 @@ class I {
|
|
|
295
603
|
sphericalHarmonicsDegree: e.sphericalHarmonicsDegree ?? 0,
|
|
296
604
|
orientationPreset: e.orientationPreset ?? "x180",
|
|
297
605
|
viewerOptions: e.viewerOptions
|
|
298
|
-
},
|
|
299
|
-
if (!
|
|
606
|
+
}, n = document.getElementById(t.containerId);
|
|
607
|
+
if (!n)
|
|
300
608
|
throw new Error(`Container with id "${t.containerId}" not found`);
|
|
301
|
-
this.eventModule = new
|
|
302
|
-
|
|
609
|
+
this.eventModule = new T(), this.sceneModule = new E(t.backgroundColor), this.cameraModule = new b(
|
|
610
|
+
n,
|
|
303
611
|
t.cameraUp,
|
|
304
612
|
t.initialCameraPosition,
|
|
305
613
|
t.initialCameraLookAt
|
|
306
|
-
), this.controlModule = new
|
|
307
|
-
|
|
614
|
+
), this.controlModule = new K(t.orientationPreset), this.renderModule = new W(
|
|
615
|
+
n,
|
|
308
616
|
this.sceneModule.getScene(),
|
|
309
617
|
this.cameraModule.getCamera(),
|
|
310
618
|
t
|
|
311
|
-
), this.loaderModule = new
|
|
619
|
+
), this.loaderModule = new H(
|
|
312
620
|
this.renderModule.getViewer(),
|
|
313
621
|
() => this.controlModule.getOrientationRotation()
|
|
314
622
|
), this.renderModule.setOnBeforeRender(() => {
|
|
315
623
|
this.controlModule.update();
|
|
316
624
|
}), this.renderModule.setOnFpsUpdated((r) => {
|
|
317
|
-
this.eventModule.trigger(
|
|
625
|
+
this.eventModule.trigger(l.FpsUpdated, r);
|
|
318
626
|
}), this.renderModule.startRenderLoop(), this.isInitialized = !0;
|
|
319
627
|
}
|
|
320
628
|
async loadModel(e, t = {}) {
|
|
321
|
-
this.checkInitialized(), this.eventModule.trigger(
|
|
629
|
+
this.checkInitialized(), this.eventModule.trigger(l.LoadStart, { url: e, name: t.name });
|
|
322
630
|
try {
|
|
323
|
-
const
|
|
631
|
+
const n = await this.loaderModule.loadModel(e, {
|
|
324
632
|
showLoadingUI: !0,
|
|
325
633
|
...t,
|
|
326
|
-
onProgress: (r, s,
|
|
327
|
-
this.eventModule.trigger(
|
|
634
|
+
onProgress: (r, s, a) => {
|
|
635
|
+
this.eventModule.trigger(l.LoadProgress, { url: e, name: t.name, progress: r }), t.onProgress?.(r, s, a);
|
|
328
636
|
}
|
|
329
637
|
});
|
|
330
|
-
return this.eventModule.trigger(
|
|
331
|
-
} catch (
|
|
332
|
-
throw this.eventModule.trigger(
|
|
638
|
+
return this.eventModule.trigger(l.Loaded, { url: e, name: n.name, progress: 100 }), n;
|
|
639
|
+
} catch (n) {
|
|
640
|
+
throw this.eventModule.trigger(l.LoadError, {
|
|
333
641
|
url: e,
|
|
334
642
|
name: t.name,
|
|
335
|
-
error:
|
|
336
|
-
}),
|
|
643
|
+
error: n instanceof Error ? n : new Error(String(n))
|
|
644
|
+
}), n;
|
|
337
645
|
}
|
|
338
646
|
}
|
|
647
|
+
/**
|
|
648
|
+
* 通过 viewToken 解析 Gaussian 资源地址,再复用现有 URL 加载逻辑。
|
|
649
|
+
*/
|
|
650
|
+
async loadModelByViewToken(e, t = {}) {
|
|
651
|
+
const n = await re(
|
|
652
|
+
this.options,
|
|
653
|
+
e,
|
|
654
|
+
"gaussian"
|
|
655
|
+
);
|
|
656
|
+
if (n.assetCategory === "composite_model" && n.urls.length > 1)
|
|
657
|
+
throw new Error("EngineKernelGaussian: composite_model viewToken is not supported");
|
|
658
|
+
return this.loadModel(n.url, t);
|
|
659
|
+
}
|
|
339
660
|
async unloadModel(e) {
|
|
340
|
-
this.checkInitialized(), await this.loaderModule.unloadModel(e, !1), this.eventModule.trigger(
|
|
661
|
+
this.checkInitialized(), await this.loaderModule.unloadModel(e, !1), this.eventModule.trigger(l.SceneRemoved, { id: e });
|
|
341
662
|
}
|
|
342
663
|
setOrientationPreset(e) {
|
|
343
664
|
this.checkInitialized(), this.controlModule.setOrientationPreset(e);
|
|
@@ -347,7 +668,7 @@ class I {
|
|
|
347
668
|
}
|
|
348
669
|
resize(e, t) {
|
|
349
670
|
this.checkInitialized();
|
|
350
|
-
const
|
|
671
|
+
const n = this.renderModule.getDomElement(), r = e ?? n.parentElement?.clientWidth ?? n.clientWidth, s = t ?? n.parentElement?.clientHeight ?? n.clientHeight;
|
|
351
672
|
this.renderModule.resize(r, s), this.cameraModule.updateAspectRatio(r, s);
|
|
352
673
|
}
|
|
353
674
|
pauseRendering() {
|
|
@@ -379,12 +700,12 @@ class I {
|
|
|
379
700
|
throw new Error("EngineKernelGaussian: Not initialized");
|
|
380
701
|
}
|
|
381
702
|
}
|
|
382
|
-
function
|
|
383
|
-
return new
|
|
703
|
+
function ae(i) {
|
|
704
|
+
return new se(i);
|
|
384
705
|
}
|
|
385
706
|
export {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
707
|
+
se as EngineKernelGaussian,
|
|
708
|
+
l as EventTypeGaussian,
|
|
709
|
+
x as GaussianSplats3D,
|
|
710
|
+
ae as createEngineGaussian
|
|
390
711
|
};
|