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.
@@ -1,24 +1,24 @@
1
- import * as d from "three";
2
- import * as A from "@mkkellogg/gaussian-splats-3d";
3
- var a = /* @__PURE__ */ ((t) => (t.LoadStart = "gaussian-load-start", t.LoadProgress = "gaussian-load-progress", t.Loaded = "gaussian-loaded", t.LoadError = "gaussian-load-error", t.SceneRemoved = "gaussian-scene-removed", t.FpsUpdated = "gaussian-fps-updated", t.ViewChanged = "gaussian-view-changed", t))(a || {});
4
- class C {
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, n) {
7
- const i = String(e);
8
- this.listeners.has(i) || this.listeners.set(i, []), this.listeners.get(i).push(n);
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, n) {
11
- const i = String(e), r = this.listeners.get(i);
12
- if (!r)
10
+ off(e, t) {
11
+ const n = String(e), i = this.listeners.get(n);
12
+ if (!i)
13
13
  return;
14
- const s = r.indexOf(n);
15
- s !== -1 && r.splice(s, 1), r.length === 0 && this.listeners.delete(i);
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, n) {
18
- const i = this.listeners.get(String(e));
19
- !i || i.length === 0 || [...i].forEach((r) => {
17
+ trigger(e, t) {
18
+ const n = this.listeners.get(String(e));
19
+ !n || n.length === 0 || [...n].forEach((i) => {
20
20
  try {
21
- r(n);
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 I {
34
+ class E {
35
35
  scene;
36
36
  constructor(e) {
37
- this.scene = new d.Scene(), e && (this.scene.background = new d.Color(e));
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 d.Color(e);
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 R {
49
+ class b {
50
50
  camera;
51
51
  container;
52
52
  cameraUp;
53
53
  initialLookAt;
54
- constructor(e, n, i, r) {
55
- this.container = e, this.cameraUp = n, this.initialLookAt = r, this.camera = this.createCamera(i);
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 n = Math.max(this.container.clientWidth, 1), i = Math.max(this.container.clientHeight, 1), r = new d.PerspectiveCamera(65, n / i, 0.1, 5e3);
59
- return r.position.fromArray(e), r.up.fromArray(this.cameraUp).normalize(), r.lookAt(new d.Vector3().fromArray(this.initialLookAt)), r.updateProjectionMatrix(), r;
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, n) {
65
- this.camera.aspect = Math.max(e, 1) / Math.max(n, 1), this.camera.updateProjectionMatrix();
64
+ updateAspectRatio(e, t) {
65
+ this.camera.aspect = Math.max(e, 1) / Math.max(t, 1), this.camera.updateProjectionMatrix();
66
66
  }
67
- reset(e, n) {
68
- e && this.camera.position.fromArray(e), this.camera.lookAt(new d.Vector3().fromArray(n ?? this.initialLookAt)), this.camera.updateMatrixWorld(!0);
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
- class E {
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, r) {
87
- this.container = e, this.renderer = this.createRenderer(r.antialias), this.viewer = new A.Viewer({
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: i,
91
- threeScene: n,
152
+ camera: n,
153
+ threeScene: t,
92
154
  rootElement: e,
93
155
  useBuiltInControls: !0,
94
- cameraUp: r.cameraUp,
95
- initialCameraPosition: r.initialCameraPosition,
96
- initialCameraLookAt: r.initialCameraLookAt,
97
- sharedMemoryForWorkers: r.sharedMemoryForWorkers,
98
- gpuAcceleratedSort: r.gpuAcceleratedSort,
99
- sphericalHarmonicsDegree: r.sphericalHarmonicsDegree,
100
- ...r.viewerOptions ?? {}
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 n = new d.WebGLRenderer({
166
+ const t = new c.WebGLRenderer({
105
167
  antialias: e,
106
168
  alpha: !0,
107
169
  preserveDrawingBuffer: !1
108
170
  });
109
- return n.setSize(Math.max(this.container.clientWidth, 1), Math.max(this.container.clientHeight, 1)), n.setPixelRatio(Math.min(window.devicePixelRatio, 2)), this.container.appendChild(n.domElement), n;
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(), n = e - this.fpsLastTime;
136
- if (n < 1e3)
197
+ const e = performance.now(), t = e - this.fpsLastTime;
198
+ if (t < 1e3)
137
199
  return;
138
- const i = Math.round(this.fpsFrameCount * 1e3 / n);
200
+ const n = Math.round(this.fpsFrameCount * 1e3 / t);
139
201
  this.fpsInfo = {
140
- fps: i,
141
- frameTimeMs: i > 0 ? 1e3 / i : 0,
142
- minFps: this.fpsInfo.minFps === 0 ? i : Math.min(this.fpsInfo.minFps, i)
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, n) {
158
- this.renderer.setSize(Math.max(e, 1), Math.max(n, 1)), this.renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
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 P = {
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 T {
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 [...P[this.orientationPreset]];
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 b(t, e) {
211
- return `${t}#${e}`;
272
+ function _(r, e) {
273
+ return `${r}#${e}`;
212
274
  }
213
- class x {
275
+ class H {
214
276
  viewer;
215
277
  getDefaultRotation;
216
278
  scenes = /* @__PURE__ */ new Map();
217
- constructor(e, n) {
218
- this.viewer = e, this.getDefaultRotation = n;
279
+ constructor(e, t) {
280
+ this.viewer = e, this.getDefaultRotation = t;
219
281
  }
220
- async loadModel(e, n = {}) {
221
- const i = this.viewer.getSceneCount(), r = {
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
- ...n
289
+ ...t
228
290
  };
229
- await this.viewer.addSplatScene(e, r);
291
+ await this.viewer.addSplatScene(e, i);
230
292
  const s = {
231
- id: r.id ?? b(e, i),
232
- name: r.name ?? e.split(/[\\/]/).pop() ?? e,
293
+ id: i.id ?? _(e, n),
294
+ name: i.name ?? e.split(/[\\/]/).pop() ?? e,
233
295
  url: e,
234
- index: i,
235
- options: r
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 n = [];
241
- for (const i of e)
242
- n.push(await this.loadModel(i.url, i.options));
243
- return n;
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, n = !0) {
246
- const i = this.scenes.get(e);
247
- i && (await this.viewer.removeSplatScene(i.index, n), this.scenes.delete(e), this.reindexScenesAfterRemove(i.index));
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 n = typeof e == "number" ? e : this.scenes.get(e)?.index;
257
- return n == null ? void 0 : this.viewer.getSplatScene(n);
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 n = this.getAllModels().map((i) => i.index);
261
- n.length > 0 && await this.viewer.removeSplatScenes(n, e), this.scenes.clear();
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((n) => {
265
- n.index > e && (n.index -= 1);
326
+ this.scenes.forEach((t) => {
327
+ t.index > e && (t.index -= 1);
266
328
  });
267
329
  }
268
330
  }
269
- const L = "3.9.205", z = {
270
- version: L
271
- }, l = z.version;
272
- function w() {
273
- const t = globalThis.crypto?.subtle;
274
- if (!t)
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 t;
338
+ return r;
277
339
  }
278
- function h(t) {
279
- return new TextEncoder().encode(t);
340
+ function p(r) {
341
+ return new TextEncoder().encode(r);
280
342
  }
281
- function u(t) {
282
- return t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength);
343
+ function m(r) {
344
+ return r.buffer.slice(r.byteOffset, r.byteOffset + r.byteLength);
283
345
  }
284
- function k(t) {
346
+ function C(r) {
285
347
  let e = "";
286
- return t.forEach((n) => {
287
- e += String.fromCharCode(n);
348
+ return r.forEach((t) => {
349
+ e += String.fromCharCode(t);
288
350
  }), btoa(e);
289
351
  }
290
- function F(t) {
291
- const e = t.getUTCFullYear(), n = String(t.getUTCMonth() + 1).padStart(2, "0"), i = String(t.getUTCDate()).padStart(2, "0");
292
- return `${e}${n}${i}`;
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 O(t) {
295
- const e = await w().digest("SHA-256", u(h(t)));
296
- return Array.from(new Uint8Array(e)).map((n) => n.toString(16).padStart(2, "0")).join("");
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 U(t, e) {
299
- const n = w(), i = await n.importKey("raw", u(t), { name: "HMAC", hash: "SHA-256" }, !1, ["sign"]);
300
- return n.sign("HMAC", i, u(h(e)));
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 B(t) {
303
- return h(
304
- [t.appId, t.engineType, t.requestDate, String(t.timestamp), t.nonce].join("|")
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 K(t) {
308
- const e = w(), n = /* @__PURE__ */ new Date(), i = n.getTime(), r = F(n), s = globalThis.crypto.randomUUID(), o = globalThis.crypto.getRandomValues(new Uint8Array(12)), c = await O(t.appSecret), M = await U(h(c), r), y = await e.importKey("raw", M, "AES-GCM", !1, ["encrypt"]), S = JSON.stringify({
309
- appKey: t.appKey,
310
- appSecret: t.appSecret
311
- }), v = await e.encrypt(
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: o,
315
- additionalData: u(B({
316
- appId: t.appId,
317
- engineType: t.engineType,
318
- requestDate: r,
319
- timestamp: i,
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
- y,
325
- u(h(S))
386
+ o,
387
+ m(p(h))
326
388
  );
327
389
  return {
328
- appId: t.appId,
329
- engineType: t.engineType,
330
- requestDate: r,
331
- timestamp: i,
390
+ appId: r.appId,
391
+ engineType: r.engineType,
392
+ requestDate: i,
393
+ timestamp: n,
332
394
  nonce: s,
333
- iv: k(o),
334
- cipherText: k(new Uint8Array(v)),
335
- sdkVersion: t.sdkVersion,
336
- origin: t.origin,
337
- product: t.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 f = /* @__PURE__ */ new Map();
341
- function p(t) {
342
- return t.replace(/\/+$/, "");
402
+ const S = /* @__PURE__ */ new Map();
403
+ function w(r) {
404
+ return r.replace(/\/+$/, "");
343
405
  }
344
- function m(t) {
345
- if (t) return t;
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 D(t, e) {
411
+ function J(r, e) {
350
412
  return JSON.stringify({
351
- endpoint: p(t.endpoint),
352
- token: t.token ?? "",
353
- appId: t.appId ?? "",
354
- appKey: t.appKey ?? "",
355
- appSecret: t.appSecret ?? "",
356
- origin: m(t.origin) ?? "",
357
- product: t.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: l
421
+ sdkVersion: u
360
422
  });
361
423
  }
362
- async function g(t, e, n) {
363
- const i = typeof AbortController < "u" ? new AbortController() : void 0, r = i ? setTimeout(() => i.abort(), n) : void 0;
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(t, {
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: i?.signal
372
- }), o = await s.json().catch(() => ({}));
433
+ signal: n?.signal
434
+ }), a = await s.json().catch(() => ({}));
373
435
  if (!s.ok) {
374
- const c = o?.error?.message ?? o?.message ?? `SDK authentication failed with status ${s.status}`;
375
- throw new Error(c);
436
+ const d = a?.error?.message ?? a?.message ?? `SDK authentication failed with status ${s.status}`;
437
+ throw new Error(d);
376
438
  }
377
- return o;
439
+ return a;
378
440
  } finally {
379
- r != null && clearTimeout(r);
441
+ i != null && clearTimeout(i);
380
442
  }
381
443
  }
382
- async function V(t, e) {
383
- const n = await g(`${p(t.endpoint)}/oauth/sdk-verify`, {
384
- sdkToken: t.token,
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: l,
387
- origin: m(t.origin),
388
- product: t.product
389
- }, t.timeoutMs ?? 8e3);
390
- return n.sdkToken = t.token, n;
391
- }
392
- async function $(t, e) {
393
- const n = await K({
394
- appId: t.appId,
395
- appKey: t.appKey,
396
- appSecret: t.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: l,
399
- origin: m(t.origin),
400
- product: t.product
401
- }), i = await g(
402
- `${p(t.endpoint)}/oauth/sdk-token/secure`,
403
- n,
404
- t.timeoutMs ?? 8e3
405
- ), r = await g(`${p(t.endpoint)}/oauth/sdk-verify`, {
406
- sdkToken: i.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: l,
409
- origin: m(t.origin),
410
- product: t.product
411
- }, t.timeoutMs ?? 8e3);
412
- return r.sdkToken = i.sdkToken, r;
413
- }
414
- async function H(t, e) {
415
- const n = t?.sdkAuth;
416
- if (!n)
417
- throw new Error("[BimEngine] sdkAuth is required. Provide sdkAuth.token or sdkAuth.appId/appKey/appSecret");
418
- if (!n.endpoint)
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 (!n.token && !(n.appId && n.appKey && n.appSecret))
421
- throw new Error("[BimEngine] Provide sdkAuth.token or sdkAuth.appId/appKey/appSecret");
422
- const i = D(n, e), r = f.get(i);
423
- if (r) {
424
- const o = await r;
425
- return t && (t.__sdkAuthSession = o), o;
426
- }
427
- const s = (n.token ? V(n, e) : $(n, e)).then((o) => {
428
- if (o.authorized !== !0)
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 t && (t.__sdkAuthSession = o), o;
431
- }).catch((o) => {
432
- throw f.delete(i), o;
492
+ return r && (r.__sdkAuthSession = a), a;
493
+ }).catch((a) => {
494
+ throw S.delete(n), a;
433
495
  });
434
- return f.set(i, s), s;
496
+ return S.set(n, s), s;
435
497
  }
436
- function W(t) {
437
- return t.replace(/\/+$/, "");
498
+ function Z(r) {
499
+ return r.replace(/\/+$/, "");
438
500
  }
439
- async function j(t, e, n) {
440
- const i = typeof AbortController < "u" ? new AbortController() : void 0, r = i ? setTimeout(() => i.abort(), n) : void 0;
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(t, {
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: i?.signal
449
- }), o = await s.json().catch(() => ({}));
510
+ signal: n?.signal
511
+ }), a = await s.json().catch(() => ({}));
450
512
  if (!s.ok) {
451
- const c = o?.error?.message ?? o?.message ?? `ViewToken resolve failed with status ${s.status}`;
452
- throw new Error(c);
513
+ const d = a?.error?.message ?? a?.message ?? `ViewToken resolve failed with status ${s.status}`;
514
+ throw new Error(d);
453
515
  }
454
- return o;
516
+ return a;
455
517
  } finally {
456
- r != null && clearTimeout(r);
518
+ i != null && clearTimeout(i);
457
519
  }
458
520
  }
459
- async function N(t, e, n) {
460
- const i = await H(t, n), r = t?.sdkAuth;
461
- if (!r?.endpoint)
462
- throw new Error("[BimEngine] sdkAuth.endpoint is required for viewToken loading");
463
- if (!i?.sdkToken)
464
- throw new Error("[BimEngine] sdkToken is missing after SDK authorization");
465
- return j(
466
- `${W(r.endpoint)}/models/view-token/resolve`,
467
- {
468
- sdkToken: i.sdkToken,
469
- viewToken: e,
470
- engineType: n
471
- },
472
- r.timeoutMs ?? 8e3
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 G {
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 = l;
581
+ version = u;
485
582
  constructor(e) {
486
583
  this.options = e, this.initialize(e);
487
584
  }
488
585
  initialize(e) {
489
- const n = {
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
- }, i = document.getElementById(n.containerId);
503
- if (!i)
504
- throw new Error(`Container with id "${n.containerId}" not found`);
505
- this.eventModule = new C(), this.sceneModule = new I(n.backgroundColor), this.cameraModule = new R(
506
- i,
507
- n.cameraUp,
508
- n.initialCameraPosition,
509
- n.initialCameraLookAt
510
- ), this.controlModule = new T(n.orientationPreset), this.renderModule = new E(
511
- i,
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
- n
515
- ), this.loaderModule = new x(
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((r) => {
521
- this.eventModule.trigger(a.FpsUpdated, r);
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, n = {}) {
525
- this.checkInitialized(), this.eventModule.trigger(a.LoadStart, { url: e, name: n.name });
621
+ async loadModel(e, t = {}) {
622
+ this.checkInitialized(), this.eventModule.trigger(l.LoadStart, { url: e, name: t.name });
526
623
  try {
527
- const i = await this.loaderModule.loadModel(e, {
624
+ const n = await this.loaderModule.loadModel(e, {
528
625
  showLoadingUI: !0,
529
- ...n,
530
- onProgress: (r, s, o) => {
531
- this.eventModule.trigger(a.LoadProgress, { url: e, name: n.name, progress: r }), n.onProgress?.(r, s, o);
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(a.Loaded, { url: e, name: i.name, progress: 100 }), i;
535
- } catch (i) {
536
- throw this.eventModule.trigger(a.LoadError, {
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: n.name,
539
- error: i instanceof Error ? i : new Error(String(i))
540
- }), i;
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, n = {}) {
547
- const i = await N(
643
+ async loadModelByViewToken(e, t = {}) {
644
+ const n = await ie(
548
645
  this.options,
549
646
  e,
550
647
  "gaussian"
551
648
  );
552
- if (i.assetCategory === "composite_model" && i.urls.length > 1)
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(i.url, n);
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(a.SceneRemoved, { id: e });
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, n) {
662
+ resize(e, t) {
566
663
  this.checkInitialized();
567
- const i = this.renderModule.getDomElement(), r = e ?? i.parentElement?.clientWidth ?? i.clientWidth, s = n ?? i.parentElement?.clientHeight ?? i.clientHeight;
568
- this.renderModule.resize(r, s), this.cameraModule.updateAspectRatio(r, s);
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, n) {
583
- this.checkInitialized(), this.eventModule.on(e, n);
679
+ on(e, t) {
680
+ this.checkInitialized(), this.eventModule.on(e, t);
584
681
  }
585
- off(e, n) {
586
- this.checkInitialized(), this.eventModule.off(e, n);
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 _(t) {
600
- return new G(t);
696
+ function ae(r) {
697
+ return new se(r);
601
698
  }
602
699
  export {
603
- G as EngineKernelGaussian,
604
- a as EventTypeGaussian,
605
- A as GaussianSplats3D,
606
- _ as createEngineGaussian
700
+ se as EngineKernelGaussian,
701
+ l as EventTypeGaussian,
702
+ T as GaussianSplats3D,
703
+ ae as createEngineGaussian
607
704
  };