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