iflow-engine-base 4.0.14 → 4.0.16
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 +44 -13
- package/dist/bim-engine-sdk.umd.js +3892 -1785
- package/dist/chunks/EngineKernel-BLJsCrxR.js +20499 -0
- package/dist/chunks/engine-2d-DneQvSOi.js +6119 -0
- package/dist/chunks/{engine-3d-O9j7G-bi.js → engine-3d-B0D38zLu.js} +18656 -18378
- package/dist/chunks/engine-720-OdgX2p-d.js +1565 -0
- package/dist/chunks/engine-gaussian-CQdrGBYh.js +8127 -0
- package/dist/chunks/gis-tiles-vendor-Dr7piDQM.js +11386 -0
- package/dist/chunks/index-Ct7RfnLw.js +474 -0
- package/dist/chunks/index-Cyv0HpPm.js +438 -0
- package/dist/chunks/index-DZmXdy4v.js +717 -0
- package/dist/chunks/index-DjNAYhvI.js +5252 -0
- package/dist/chunks/{sdk-assets-Eo-SBV02.js → sdk-assets-Dh7PGW73.js} +10 -10
- package/dist/chunks/sdk-runtime-KslKRuwI.js +1365 -0
- package/dist/chunks/sdk-vendor-CVc1LiJj.js +31826 -0
- package/dist/chunks/three-vendor-Ds9cgGKb.js +81880 -0
- package/dist/gis-fixtures/0/0/0.png +0 -0
- package/dist/gis-fixtures/0/0/0.svg +6 -0
- package/dist/gis-fixtures/1/0/0.png +0 -0
- package/dist/gis-fixtures/1/0/0.svg +7 -0
- package/dist/gis-fixtures/1/0/1.png +0 -0
- package/dist/gis-fixtures/1/0/1.svg +7 -0
- package/dist/gis-fixtures/1/1/0.png +0 -0
- package/dist/gis-fixtures/1/1/0.svg +7 -0
- package/dist/gis-fixtures/1/1/1.png +0 -0
- package/dist/gis-fixtures/1/1/1.svg +7 -0
- package/dist/gis-fixtures/10/846/439.png +0 -0
- package/dist/gis-fixtures/10/846/440.png +0 -0
- package/dist/gis-fixtures/10/846/441.png +0 -0
- package/dist/gis-fixtures/10/847/439.png +0 -0
- package/dist/gis-fixtures/10/847/440.png +0 -0
- package/dist/gis-fixtures/10/847/441.png +0 -0
- package/dist/gis-fixtures/10/848/439.png +0 -0
- package/dist/gis-fixtures/10/848/440.png +0 -0
- package/dist/gis-fixtures/10/848/441.png +0 -0
- package/dist/gis-fixtures/11/1694/879.png +0 -0
- package/dist/gis-fixtures/11/1694/880.png +0 -0
- package/dist/gis-fixtures/11/1694/881.png +0 -0
- package/dist/gis-fixtures/11/1695/879.png +0 -0
- package/dist/gis-fixtures/11/1695/880.png +0 -0
- package/dist/gis-fixtures/11/1695/881.png +0 -0
- package/dist/gis-fixtures/11/1696/879.png +0 -0
- package/dist/gis-fixtures/11/1696/880.png +0 -0
- package/dist/gis-fixtures/11/1696/881.png +0 -0
- package/dist/gis-fixtures/12/3390/1759.png +0 -0
- package/dist/gis-fixtures/12/3390/1760.png +0 -0
- package/dist/gis-fixtures/12/3390/1761.png +0 -0
- package/dist/gis-fixtures/12/3391/1759.png +0 -0
- package/dist/gis-fixtures/12/3391/1760.png +0 -0
- package/dist/gis-fixtures/12/3391/1761.png +0 -0
- package/dist/gis-fixtures/12/3392/1759.png +0 -0
- package/dist/gis-fixtures/12/3392/1760.png +0 -0
- package/dist/gis-fixtures/12/3392/1761.png +0 -0
- package/dist/gis-fixtures/13/6782/3520.png +0 -0
- package/dist/gis-fixtures/13/6782/3521.png +0 -0
- package/dist/gis-fixtures/13/6782/3522.png +0 -0
- package/dist/gis-fixtures/13/6783/3520.png +0 -0
- package/dist/gis-fixtures/13/6783/3521.png +0 -0
- package/dist/gis-fixtures/13/6783/3522.png +0 -0
- package/dist/gis-fixtures/13/6784/3520.png +0 -0
- package/dist/gis-fixtures/13/6784/3521.png +0 -0
- package/dist/gis-fixtures/13/6784/3522.png +0 -0
- package/dist/gis-fixtures/14/13565/7041.png +0 -0
- package/dist/gis-fixtures/14/13565/7042.png +0 -0
- package/dist/gis-fixtures/14/13565/7043.png +0 -0
- package/dist/gis-fixtures/14/13566/7041.png +0 -0
- package/dist/gis-fixtures/14/13566/7042.png +0 -0
- package/dist/gis-fixtures/14/13566/7043.png +0 -0
- package/dist/gis-fixtures/14/13567/7041.png +0 -0
- package/dist/gis-fixtures/14/13567/7042.png +0 -0
- package/dist/gis-fixtures/14/13567/7043.png +0 -0
- package/dist/gis-fixtures/15/27131/14083.png +0 -0
- package/dist/gis-fixtures/15/27131/14084.png +0 -0
- package/dist/gis-fixtures/15/27131/14085.png +0 -0
- package/dist/gis-fixtures/15/27132/14083.png +0 -0
- package/dist/gis-fixtures/15/27132/14084.png +0 -0
- package/dist/gis-fixtures/15/27132/14085.png +0 -0
- package/dist/gis-fixtures/15/27133/14083.png +0 -0
- package/dist/gis-fixtures/15/27133/14084.png +0 -0
- package/dist/gis-fixtures/15/27133/14085.png +0 -0
- package/dist/gis-fixtures/16/54264/28168.png +0 -0
- package/dist/gis-fixtures/16/54264/28169.png +0 -0
- package/dist/gis-fixtures/16/54264/28170.png +0 -0
- package/dist/gis-fixtures/16/54265/28168.png +0 -0
- package/dist/gis-fixtures/16/54265/28169.png +0 -0
- package/dist/gis-fixtures/16/54265/28170.png +0 -0
- package/dist/gis-fixtures/16/54266/28168.png +0 -0
- package/dist/gis-fixtures/16/54266/28169.png +0 -0
- package/dist/gis-fixtures/16/54266/28170.png +0 -0
- package/dist/gis-fixtures/17/108530/56337.png +0 -0
- package/dist/gis-fixtures/17/108530/56338.png +0 -0
- package/dist/gis-fixtures/17/108530/56339.png +0 -0
- package/dist/gis-fixtures/17/108531/56337.png +0 -0
- package/dist/gis-fixtures/17/108531/56338.png +0 -0
- package/dist/gis-fixtures/17/108531/56339.png +0 -0
- package/dist/gis-fixtures/17/108532/56337.png +0 -0
- package/dist/gis-fixtures/17/108532/56338.png +0 -0
- package/dist/gis-fixtures/17/108532/56339.png +0 -0
- package/dist/gis-fixtures/18/217061/112676.png +0 -0
- package/dist/gis-fixtures/18/217061/112677.png +0 -0
- package/dist/gis-fixtures/18/217061/112678.png +0 -0
- package/dist/gis-fixtures/18/217062/112676.png +0 -0
- package/dist/gis-fixtures/18/217062/112677.png +0 -0
- package/dist/gis-fixtures/18/217062/112678.png +0 -0
- package/dist/gis-fixtures/18/217063/112676.png +0 -0
- package/dist/gis-fixtures/18/217063/112677.png +0 -0
- package/dist/gis-fixtures/18/217063/112678.png +0 -0
- package/dist/gis-fixtures/2/2/0.png +0 -0
- package/dist/gis-fixtures/2/2/1.png +0 -0
- package/dist/gis-fixtures/2/2/2.png +0 -0
- package/dist/gis-fixtures/2/3/0.png +0 -0
- package/dist/gis-fixtures/2/3/1.png +0 -0
- package/dist/gis-fixtures/2/3/2.png +0 -0
- package/dist/gis-fixtures/2/4/0.png +0 -0
- package/dist/gis-fixtures/2/4/1.png +0 -0
- package/dist/gis-fixtures/2/4/2.png +0 -0
- package/dist/gis-fixtures/3/5/2.png +0 -0
- package/dist/gis-fixtures/3/5/3.png +0 -0
- package/dist/gis-fixtures/3/5/4.png +0 -0
- package/dist/gis-fixtures/3/6/2.png +0 -0
- package/dist/gis-fixtures/3/6/3.png +0 -0
- package/dist/gis-fixtures/3/6/4.png +0 -0
- package/dist/gis-fixtures/3/7/2.png +0 -0
- package/dist/gis-fixtures/3/7/3.png +0 -0
- package/dist/gis-fixtures/3/7/4.png +0 -0
- package/dist/gis-fixtures/4/12/5.png +0 -0
- package/dist/gis-fixtures/4/12/6.png +0 -0
- package/dist/gis-fixtures/4/12/7.png +0 -0
- package/dist/gis-fixtures/4/13/5.png +0 -0
- package/dist/gis-fixtures/4/13/6.png +0 -0
- package/dist/gis-fixtures/4/13/7.png +0 -0
- package/dist/gis-fixtures/4/14/5.png +0 -0
- package/dist/gis-fixtures/4/14/6.png +0 -0
- package/dist/gis-fixtures/4/14/7.png +0 -0
- package/dist/gis-fixtures/5/25/12.png +0 -0
- package/dist/gis-fixtures/5/25/13.png +0 -0
- package/dist/gis-fixtures/5/25/14.png +0 -0
- package/dist/gis-fixtures/5/26/12.png +0 -0
- package/dist/gis-fixtures/5/26/13.png +0 -0
- package/dist/gis-fixtures/5/26/14.png +0 -0
- package/dist/gis-fixtures/5/27/12.png +0 -0
- package/dist/gis-fixtures/5/27/13.png +0 -0
- package/dist/gis-fixtures/5/27/14.png +0 -0
- package/dist/gis-fixtures/6/51/26.png +0 -0
- package/dist/gis-fixtures/6/51/27.png +0 -0
- package/dist/gis-fixtures/6/51/28.png +0 -0
- package/dist/gis-fixtures/6/52/26.png +0 -0
- package/dist/gis-fixtures/6/52/27.png +0 -0
- package/dist/gis-fixtures/6/52/28.png +0 -0
- package/dist/gis-fixtures/6/53/26.png +0 -0
- package/dist/gis-fixtures/6/53/27.png +0 -0
- package/dist/gis-fixtures/6/53/28.png +0 -0
- package/dist/gis-fixtures/7/104/54.png +0 -0
- package/dist/gis-fixtures/7/104/55.png +0 -0
- package/dist/gis-fixtures/7/104/56.png +0 -0
- package/dist/gis-fixtures/7/105/54.png +0 -0
- package/dist/gis-fixtures/7/105/55.png +0 -0
- package/dist/gis-fixtures/7/105/56.png +0 -0
- package/dist/gis-fixtures/7/106/54.png +0 -0
- package/dist/gis-fixtures/7/106/55.png +0 -0
- package/dist/gis-fixtures/7/106/56.png +0 -0
- package/dist/gis-fixtures/8/210/109.png +0 -0
- package/dist/gis-fixtures/8/210/110.png +0 -0
- package/dist/gis-fixtures/8/210/111.png +0 -0
- package/dist/gis-fixtures/8/211/109.png +0 -0
- package/dist/gis-fixtures/8/211/110.png +0 -0
- package/dist/gis-fixtures/8/211/111.png +0 -0
- package/dist/gis-fixtures/8/212/109.png +0 -0
- package/dist/gis-fixtures/8/212/110.png +0 -0
- package/dist/gis-fixtures/8/212/111.png +0 -0
- package/dist/gis-fixtures/9/422/219.png +0 -0
- package/dist/gis-fixtures/9/422/220.png +0 -0
- package/dist/gis-fixtures/9/422/221.png +0 -0
- package/dist/gis-fixtures/9/423/219.png +0 -0
- package/dist/gis-fixtures/9/423/220.png +0 -0
- package/dist/gis-fixtures/9/423/221.png +0 -0
- package/dist/gis-fixtures/9/424/219.png +0 -0
- package/dist/gis-fixtures/9/424/220.png +0 -0
- package/dist/gis-fixtures/9/424/221.png +0 -0
- package/dist/gis-fixtures/tilesets/xiamen-local/scene.gltf +31 -0
- package/dist/gis-fixtures/tilesets/xiamen-local/tileset.json +12 -0
- package/dist/iflow-engine-base.css +1 -1
- package/dist/index.d.ts +14699 -68
- package/package.json +11 -2
- package/dist/chunks/sdk-runtime-y-YldFea.js +0 -1177
- package/dist/chunks/sdk-vendor-DtYOqJWo.js +0 -23208
- package/dist/chunks/three-vendor-rBTtPKhu.js +0 -44788
|
@@ -1,1177 +0,0 @@
|
|
|
1
|
-
import { R as Ee, f as M, V as ae, P as xe } from "./three-vendor-rBTtPKhu.js";
|
|
2
|
-
import { a as ve, J as Te, l as Q } from "./sdk-vendor-DtYOqJWo.js";
|
|
3
|
-
class St {
|
|
4
|
-
/**
|
|
5
|
-
* 构造函数
|
|
6
|
-
* @param camera - Three.js 相机对象(用于投影计算)
|
|
7
|
-
* @param renderer - Three.js 渲染器对象(用于获取画布尺寸)
|
|
8
|
-
* @param scene - Three.js 场景对象(用于屏幕坐标转世界坐标时的射线检测,可选)
|
|
9
|
-
*/
|
|
10
|
-
constructor(e, n, r) {
|
|
11
|
-
this.camera = e, this.renderer = n, this.scene = r, this.raycaster = new Ee();
|
|
12
|
-
}
|
|
13
|
-
camera;
|
|
14
|
-
renderer;
|
|
15
|
-
scene;
|
|
16
|
-
raycaster;
|
|
17
|
-
/**
|
|
18
|
-
* 将世界坐标转换为屏幕坐标(归一化坐标,范围 -1 到 1)
|
|
19
|
-
* @param worldPos - 世界空间中的3D坐标点
|
|
20
|
-
* @returns 归一化的屏幕坐标,x 和 y 的范围都是 -1 到 1
|
|
21
|
-
* x: -1 表示屏幕左边缘,1 表示屏幕右边缘
|
|
22
|
-
* y: -1 表示屏幕下边缘,1 表示屏幕上边缘
|
|
23
|
-
*/
|
|
24
|
-
worldToScreenNormalized(e) {
|
|
25
|
-
const n = e.clone();
|
|
26
|
-
return n.project(this.camera), new M(n.x, n.y);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* 将世界坐标转换为屏幕坐标(像素坐标)
|
|
30
|
-
* @param worldPos - 世界空间中的3D坐标点
|
|
31
|
-
* @returns 屏幕像素坐标,x 和 y 表示在画布上的实际像素位置
|
|
32
|
-
* x: 0 表示屏幕左边缘,width 表示屏幕右边缘
|
|
33
|
-
* y: 0 表示屏幕上边缘,height 表示屏幕下边缘
|
|
34
|
-
*/
|
|
35
|
-
worldToScreen(e) {
|
|
36
|
-
const n = new ae();
|
|
37
|
-
return n.copy(e).project(this.camera), n.x = n.x * this.renderer.domElement.clientWidth * 0.5, n.y = -n.y * this.renderer.domElement.clientHeight * 0.5, n.z = (n.z + 1) * 0.5, n.x += this.renderer.domElement.clientWidth * 0.5, n.y += this.renderer.domElement.clientHeight * 0.5, new M(n.x, n.y);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* 将世界坐标转换为屏幕坐标,仅在点位于当前相机可见裁剪空间内时返回结果。
|
|
41
|
-
* 透视相机背后的点经过 project 后会翻转到屏幕异常位置,这里提前过滤。
|
|
42
|
-
* @param worldPos - 世界空间中的 3D 坐标点
|
|
43
|
-
* @returns 屏幕像素坐标;如果点不可见或投影结果无效,返回 null
|
|
44
|
-
*/
|
|
45
|
-
worldToScreenIfVisible(e) {
|
|
46
|
-
if (this.camera.updateMatrixWorld(!0), this.camera instanceof xe && e.clone().applyMatrix4(this.camera.matrixWorldInverse).z >= 0)
|
|
47
|
-
return null;
|
|
48
|
-
const n = e.clone().project(this.camera);
|
|
49
|
-
if (!Number.isFinite(n.x) || !Number.isFinite(n.y) || !Number.isFinite(n.z) || n.z < -1 || n.z > 1)
|
|
50
|
-
return null;
|
|
51
|
-
const r = this.renderer.domElement.clientWidth, i = this.renderer.domElement.clientHeight;
|
|
52
|
-
return new M(
|
|
53
|
-
n.x * r * 0.5 + r * 0.5,
|
|
54
|
-
-n.y * i * 0.5 + i * 0.5
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* 将屏幕坐标(像素坐标)转换为归一化坐标
|
|
59
|
-
* @param screenX - 屏幕像素 X 坐标
|
|
60
|
-
* @param screenY - 屏幕像素 Y 坐标
|
|
61
|
-
* @returns 归一化的屏幕坐标,范围 -1 到 1
|
|
62
|
-
*/
|
|
63
|
-
screenToNormalized(e, n) {
|
|
64
|
-
const r = this.renderer.domElement.clientWidth, i = this.renderer.domElement.clientHeight, o = e / r * 2 - 1, s = -(n / i * 2 - 1);
|
|
65
|
-
return new M(o, s);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* 将屏幕坐标(像素坐标)转换为世界坐标
|
|
69
|
-
* 使用射线检测,返回与场景中第一个相交对象的世界坐标点
|
|
70
|
-
* @param screenX - 屏幕像素 X 坐标
|
|
71
|
-
* @param screenY - 屏幕像素 Y 坐标
|
|
72
|
-
* @param objects - 可选,指定要检测的对象数组。如果不提供且 scene 存在,则检测场景中的所有对象
|
|
73
|
-
* @returns 世界坐标点,如果没有相交则返回 null
|
|
74
|
-
*/
|
|
75
|
-
screenToWorld(e, n, r) {
|
|
76
|
-
if (!this.scene && !r)
|
|
77
|
-
return console.warn("WorldToScreen: 需要提供 scene 或 objects 参数才能进行屏幕坐标转世界坐标"), null;
|
|
78
|
-
const i = this.screenToNormalized(e, n);
|
|
79
|
-
this.raycaster.setFromCamera(i, this.camera);
|
|
80
|
-
const o = r || this.scene.children, s = this.raycaster.intersectObjects(o, !0);
|
|
81
|
-
return s.length > 0 ? s[0].point : null;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* 将屏幕坐标转换为指定深度的世界坐标
|
|
85
|
-
* @param screenX - 屏幕像素 X 坐标
|
|
86
|
-
* @param screenY - 屏幕像素 Y 坐标
|
|
87
|
-
* @param depth - 沿射线方向的距离(世界单位)
|
|
88
|
-
* @returns 世界坐标点
|
|
89
|
-
*/
|
|
90
|
-
screenToWorldWithDepth(e, n, r = 0) {
|
|
91
|
-
const i = this.screenToNormalized(e, n);
|
|
92
|
-
this.raycaster.setFromCamera(i, this.camera);
|
|
93
|
-
const o = new ae();
|
|
94
|
-
return this.raycaster.ray.at(r, o), o;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* 更新相机引用(当相机发生变化时调用)
|
|
98
|
-
* @param camera - 新的相机对象
|
|
99
|
-
*/
|
|
100
|
-
updateCamera(e) {
|
|
101
|
-
this.camera = e;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* 更新渲染器引用(当渲染器发生变化时调用)
|
|
105
|
-
* @param renderer - 新的渲染器对象
|
|
106
|
-
*/
|
|
107
|
-
updateRenderer(e) {
|
|
108
|
-
this.renderer = e;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* 更新场景引用(当场景发生变化时调用)
|
|
112
|
-
* @param scene - 新的场景对象
|
|
113
|
-
*/
|
|
114
|
-
updateScene(e) {
|
|
115
|
-
this.scene = e;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
const Ae = "iflowbim.cn", Se = 512, Ce = 128, Le = 150, Pe = 38, z = 290, J = 190;
|
|
119
|
-
class Ct {
|
|
120
|
-
THREE;
|
|
121
|
-
text;
|
|
122
|
-
scene;
|
|
123
|
-
camera;
|
|
124
|
-
material;
|
|
125
|
-
sprites = [];
|
|
126
|
-
size;
|
|
127
|
-
viewportWidth = 0;
|
|
128
|
-
viewportHeight = 0;
|
|
129
|
-
constructor(e, n = Ae) {
|
|
130
|
-
this.THREE = e, this.text = n, this.scene = new e.Scene(), this.camera = new e.OrthographicCamera(0, 1, 1, 0, -10, 10), this.material = new e.SpriteMaterial({
|
|
131
|
-
map: new e.CanvasTexture(this.createTextTexture()),
|
|
132
|
-
transparent: !0,
|
|
133
|
-
opacity: 0.46,
|
|
134
|
-
depthTest: !1,
|
|
135
|
-
depthWrite: !1,
|
|
136
|
-
toneMapped: !1
|
|
137
|
-
}), this.size = new e.Vector2();
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* 在当前帧末尾把水印写入同一个 renderer canvas。
|
|
141
|
-
*/
|
|
142
|
-
render(e) {
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* 释放水印内部纹理和材质,跟随宿主 renderer 生命周期销毁。
|
|
146
|
-
*/
|
|
147
|
-
dispose() {
|
|
148
|
-
this.material.map?.dispose?.(), this.material.dispose?.(), this.sprites.length = 0;
|
|
149
|
-
}
|
|
150
|
-
createTextTexture() {
|
|
151
|
-
const e = document.createElement("canvas");
|
|
152
|
-
e.width = Se, e.height = Ce;
|
|
153
|
-
const n = e.getContext("2d");
|
|
154
|
-
return n && (n.clearRect(0, 0, e.width, e.height), n.textAlign = "center", n.textBaseline = "middle", n.font = "600 54px Arial, Helvetica, sans-serif", n.lineWidth = 3, n.strokeStyle = "rgba(0, 0, 0, 0.20)", n.fillStyle = "rgba(255, 255, 255, 0.24)", n.strokeText(this.text, e.width / 2, e.height / 2), n.fillText(this.text, e.width / 2, e.height / 2)), e;
|
|
155
|
-
}
|
|
156
|
-
updateLayout(e, n) {
|
|
157
|
-
if (e === this.viewportWidth && n === this.viewportHeight)
|
|
158
|
-
return;
|
|
159
|
-
this.viewportWidth = e, this.viewportHeight = n, this.camera.left = -e / 2, this.camera.right = e / 2, this.camera.top = n / 2, this.camera.bottom = -n / 2, this.camera.updateProjectionMatrix();
|
|
160
|
-
const r = Math.ceil(e / z) + 2, i = Math.ceil(n / J) + 2, o = r * i;
|
|
161
|
-
this.ensureSpriteCount(o);
|
|
162
|
-
let s = 0;
|
|
163
|
-
const a = -e / 2 - z / 2, c = -n / 2 - J / 2;
|
|
164
|
-
for (let l = 0; l < i; l += 1)
|
|
165
|
-
for (let d = 0; d < r; d += 1) {
|
|
166
|
-
const u = this.sprites[s], h = a + d * z + l % 2 * (z / 2), p = c + l * J;
|
|
167
|
-
u.position.set(h, p, 0), u.visible = !0, s += 1;
|
|
168
|
-
}
|
|
169
|
-
for (let l = s; l < this.sprites.length; l += 1)
|
|
170
|
-
this.sprites[l].visible = !1;
|
|
171
|
-
}
|
|
172
|
-
ensureSpriteCount(e) {
|
|
173
|
-
for (; this.sprites.length < e; ) {
|
|
174
|
-
const n = new this.THREE.Sprite(this.material);
|
|
175
|
-
n.scale.set(Le, Pe, 1), n.rotation.z = -0.32, n.renderOrder = 999999, this.scene.add(n), this.sprites.push(n);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
function ee(t) {
|
|
180
|
-
return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in t && t.BYTES_PER_ELEMENT === 1;
|
|
181
|
-
}
|
|
182
|
-
const te = (t) => t ? `"${t}" ` : "";
|
|
183
|
-
function ne(t, e = "") {
|
|
184
|
-
if (typeof t != "number")
|
|
185
|
-
throw new TypeError(te(e) + "expected number, got " + typeof t);
|
|
186
|
-
if (!Number.isSafeInteger(t) || t < 0)
|
|
187
|
-
throw new RangeError(te(e) + "expected integer >= 0, got " + t);
|
|
188
|
-
return t;
|
|
189
|
-
}
|
|
190
|
-
function m(t, e, n = "") {
|
|
191
|
-
if (ee(t) && (e === void 0 || t.length === e))
|
|
192
|
-
return t;
|
|
193
|
-
e !== void 0 && ne(e, "length");
|
|
194
|
-
const r = ee(t), i = e !== void 0 ? ` of length ${e}` : "", o = r ? `length=${t.length}` : `type=${typeof t}`, s = te(n) + "expected Uint8Array" + i + ", got " + o;
|
|
195
|
-
throw r ? new RangeError(s) : new TypeError(s);
|
|
196
|
-
}
|
|
197
|
-
function le(t, e = !0) {
|
|
198
|
-
if (t.destroyed)
|
|
199
|
-
throw new Error("hash was destroyed");
|
|
200
|
-
if (e && t.finished)
|
|
201
|
-
throw new Error("digest() was already called");
|
|
202
|
-
}
|
|
203
|
-
function Ie(t, e) {
|
|
204
|
-
m(t, void 0, "output");
|
|
205
|
-
const n = e.outputLen;
|
|
206
|
-
if (!(t.length >= n))
|
|
207
|
-
throw new RangeError('"output" expected length >= ' + n);
|
|
208
|
-
}
|
|
209
|
-
function Ue(t, e) {
|
|
210
|
-
if (Ie(t, e), !P(t))
|
|
211
|
-
throw new Error("invalid output, must be aligned");
|
|
212
|
-
}
|
|
213
|
-
function Be(t) {
|
|
214
|
-
return new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
|
|
215
|
-
}
|
|
216
|
-
function T(t) {
|
|
217
|
-
return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
|
|
218
|
-
}
|
|
219
|
-
function x(...t) {
|
|
220
|
-
for (let e = 0; e < t.length; e++)
|
|
221
|
-
t[e].fill(0);
|
|
222
|
-
}
|
|
223
|
-
function H(t) {
|
|
224
|
-
return new DataView(t.buffer, t.byteOffset, t.byteLength);
|
|
225
|
-
}
|
|
226
|
-
const G = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
227
|
-
function pe(t) {
|
|
228
|
-
return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
|
|
229
|
-
}
|
|
230
|
-
const y = G ? (t) => t : (t) => pe(t) >>> 0;
|
|
231
|
-
function Me(t) {
|
|
232
|
-
for (let e = 0; e < t.length; e++)
|
|
233
|
-
t[e] = pe(t[e]);
|
|
234
|
-
return t;
|
|
235
|
-
}
|
|
236
|
-
const oe = G ? (t) => t : Me;
|
|
237
|
-
function ze(t, e) {
|
|
238
|
-
if (t = m(t), e = m(e), t.length !== e.length)
|
|
239
|
-
return !1;
|
|
240
|
-
let n = 0;
|
|
241
|
-
for (let r = 0; r < t.length; r++)
|
|
242
|
-
n |= t[r] ^ e[r];
|
|
243
|
-
return n === 0;
|
|
244
|
-
}
|
|
245
|
-
function Re(t, e, n) {
|
|
246
|
-
const r = e, i = n || (() => []), o = (a, c) => r(c, ...i(a)).update(a).digest(), s = r(new Uint8Array(t), ...i(new Uint8Array(0)));
|
|
247
|
-
return o.outputLen = s.outputLen, o.blockLen = s.blockLen, o.create = (a, ...c) => r(a, ...c), o;
|
|
248
|
-
}
|
|
249
|
-
const Ke = /* @__NO_SIDE_EFFECTS__ */ (t, e) => {
|
|
250
|
-
function n(r, ...i) {
|
|
251
|
-
if (m(r, void 0, "key"), t.nonceLength !== void 0) {
|
|
252
|
-
const u = i[0];
|
|
253
|
-
m(u, t.varSizeNonce ? void 0 : t.nonceLength, "nonce");
|
|
254
|
-
}
|
|
255
|
-
const o = t.tagLength, s = t.nonceLength !== void 0 ? 1 : 0;
|
|
256
|
-
if (!t.withAAD) {
|
|
257
|
-
for (let u = s; u < i.length; u++)
|
|
258
|
-
if (ee(i[u]))
|
|
259
|
-
throw new Error("AAD not supported");
|
|
260
|
-
}
|
|
261
|
-
t.withAAD && i[s] !== void 0 && m(i[s], void 0, "AAD");
|
|
262
|
-
const a = e(r, ...i), c = (u, h) => {
|
|
263
|
-
if (h !== void 0) {
|
|
264
|
-
if (u !== 2)
|
|
265
|
-
throw new Error("cipher output not supported");
|
|
266
|
-
m(h, void 0, "output");
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
let l = !1;
|
|
270
|
-
return {
|
|
271
|
-
encrypt(u, h) {
|
|
272
|
-
if (l)
|
|
273
|
-
throw new Error("cannot encrypt() twice with same key + nonce");
|
|
274
|
-
return l = !0, m(u, void 0, "data"), c(a.encrypt.length, h), a.encrypt(u, h);
|
|
275
|
-
},
|
|
276
|
-
decrypt(u, h) {
|
|
277
|
-
if (m(u, void 0, "data"), o && u.length < o)
|
|
278
|
-
throw new Error('"ciphertext" expected length >= tagLength=' + o);
|
|
279
|
-
return c(a.decrypt.length, h), a.decrypt(u, h);
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
return Object.assign(n, t), n;
|
|
284
|
-
};
|
|
285
|
-
function _e(t, e, n = !0) {
|
|
286
|
-
if (e === void 0)
|
|
287
|
-
return new Uint8Array(t);
|
|
288
|
-
if (m(e, t, "output"), n && !P(e))
|
|
289
|
-
throw new Error("invalid output, must be aligned");
|
|
290
|
-
return e;
|
|
291
|
-
}
|
|
292
|
-
function We(t, e, n) {
|
|
293
|
-
ne(t), ne(e);
|
|
294
|
-
const r = new Uint8Array(16), i = H(r);
|
|
295
|
-
return i.setBigUint64(0, BigInt(e), n), i.setBigUint64(8, BigInt(t), n), r;
|
|
296
|
-
}
|
|
297
|
-
function P(t) {
|
|
298
|
-
return t.byteOffset % 4 === 0;
|
|
299
|
-
}
|
|
300
|
-
function I(t) {
|
|
301
|
-
return Uint8Array.from(m(t));
|
|
302
|
-
}
|
|
303
|
-
const v = 16, ge = /* @__PURE__ */ new Uint8Array(16), C = /* @__PURE__ */ T(ge), Oe = 225, $e = (t, e, n, r) => {
|
|
304
|
-
const i = r & 1;
|
|
305
|
-
return {
|
|
306
|
-
s3: n << 31 | r >>> 1,
|
|
307
|
-
s2: e << 31 | n >>> 1,
|
|
308
|
-
s1: t << 31 | e >>> 1,
|
|
309
|
-
// NIST SP 800-38D §6.3 applies `V >> 1` and XORs R on carry. In this
|
|
310
|
-
// 4x32-bit split, R = 0xe1 || 0^120 lives in the top byte of s0.
|
|
311
|
-
s0: t >>> 1 ^ Oe << 24 & -(i & 1)
|
|
312
|
-
// reduce % poly
|
|
313
|
-
};
|
|
314
|
-
}, R = (t) => (t >>> 0 & 255) << 24 | (t >>> 8 & 255) << 16 | (t >>> 16 & 255) << 8 | t >>> 24 & 255 | 0, je = (t) => t > 64 * 1024 ? 8 : t > 1024 ? 4 : 2;
|
|
315
|
-
class Ne {
|
|
316
|
-
blockLen = v;
|
|
317
|
-
outputLen = v;
|
|
318
|
-
s0 = 0;
|
|
319
|
-
s1 = 0;
|
|
320
|
-
s2 = 0;
|
|
321
|
-
s3 = 0;
|
|
322
|
-
finished = !1;
|
|
323
|
-
destroyed = !1;
|
|
324
|
-
t;
|
|
325
|
-
W;
|
|
326
|
-
windowSize;
|
|
327
|
-
// We select bits per window adaptively based on expectedLength
|
|
328
|
-
constructor(e, n) {
|
|
329
|
-
m(e, 16, "key"), e = I(e);
|
|
330
|
-
const r = H(e);
|
|
331
|
-
let i = r.getUint32(0, !1), o = r.getUint32(4, !1), s = r.getUint32(8, !1), a = r.getUint32(12, !1);
|
|
332
|
-
const c = [];
|
|
333
|
-
for (let f = 0; f < 128; f++)
|
|
334
|
-
c.push({ s0: R(i), s1: R(o), s2: R(s), s3: R(a) }), { s0: i, s1: o, s2: s, s3: a } = $e(i, o, s, a);
|
|
335
|
-
const l = je(n || 1024);
|
|
336
|
-
if (![1, 2, 4, 8].includes(l))
|
|
337
|
-
throw new Error("ghash: invalid window size, expected 2, 4 or 8");
|
|
338
|
-
this.W = l;
|
|
339
|
-
const u = 128 / l, h = this.windowSize = 2 ** l, p = [];
|
|
340
|
-
for (let f = 0; f < u; f++)
|
|
341
|
-
for (let g = 0; g < h; g++) {
|
|
342
|
-
let w = 0, b = 0, k = 0, A = 0;
|
|
343
|
-
for (let E = 0; E < l; E++) {
|
|
344
|
-
if (!(g >>> l - E - 1 & 1))
|
|
345
|
-
continue;
|
|
346
|
-
const { s0: F, s1: we, s2: be, s3: ke } = c[l * f + E];
|
|
347
|
-
w ^= F, b ^= we, k ^= be, A ^= ke;
|
|
348
|
-
}
|
|
349
|
-
p.push({ s0: w, s1: b, s2: k, s3: A });
|
|
350
|
-
}
|
|
351
|
-
this.t = p;
|
|
352
|
-
}
|
|
353
|
-
_updateBlock(e, n, r, i) {
|
|
354
|
-
e ^= this.s0, n ^= this.s1, r ^= this.s2, i ^= this.s3;
|
|
355
|
-
const { W: o, t: s, windowSize: a } = this;
|
|
356
|
-
let c = 0, l = 0, d = 0, u = 0;
|
|
357
|
-
const h = (1 << o) - 1;
|
|
358
|
-
let p = 0;
|
|
359
|
-
for (const f of [e, n, r, i])
|
|
360
|
-
for (let g = 0; g < 4; g++) {
|
|
361
|
-
const w = f >>> 8 * g & 255;
|
|
362
|
-
for (let b = 8 / o - 1; b >= 0; b--) {
|
|
363
|
-
const k = w >>> o * b & h, { s0: A, s1: E, s2: S, s3: F } = s[p * a + k];
|
|
364
|
-
c ^= A, l ^= E, d ^= S, u ^= F, p += 1;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
this.s0 = c, this.s1 = l, this.s2 = d, this.s3 = u;
|
|
368
|
-
}
|
|
369
|
-
update(e) {
|
|
370
|
-
le(this), m(e), e = I(e);
|
|
371
|
-
const n = T(e), r = Math.floor(e.length / v), i = e.length % v;
|
|
372
|
-
for (let o = 0; o < r; o++)
|
|
373
|
-
this._updateBlock(y(n[o * 4 + 0]), y(n[o * 4 + 1]), y(n[o * 4 + 2]), y(n[o * 4 + 3]));
|
|
374
|
-
return i && (ge.set(e.subarray(r * v)), this._updateBlock(y(C[0]), y(C[1]), y(C[2]), y(C[3])), x(C)), this;
|
|
375
|
-
}
|
|
376
|
-
destroy() {
|
|
377
|
-
this.destroyed = !0;
|
|
378
|
-
const { t: e } = this;
|
|
379
|
-
for (const n of e)
|
|
380
|
-
n.s0 = 0, n.s1 = 0, n.s2 = 0, n.s3 = 0;
|
|
381
|
-
}
|
|
382
|
-
digestInto(e) {
|
|
383
|
-
le(this), Ue(e, this), this.finished = !0;
|
|
384
|
-
const { s0: n, s1: r, s2: i, s3: o } = this, s = T(e);
|
|
385
|
-
s[0] = n, s[1] = r, s[2] = i, s[3] = o, G || oe(s.subarray(0, v / 4));
|
|
386
|
-
}
|
|
387
|
-
digest() {
|
|
388
|
-
const e = new Uint8Array(v);
|
|
389
|
-
return this.digestInto(e), this.destroy(), e;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
const ue = /* @__PURE__ */ Re(16, (t, e) => new Ne(t, e), (t) => [t.length]), re = 16, Ve = 4, K = /* @__PURE__ */ new Uint8Array(re), De = 283;
|
|
393
|
-
function He(t) {
|
|
394
|
-
if (![16, 24, 32].includes(t.length))
|
|
395
|
-
throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length=' + t.length);
|
|
396
|
-
}
|
|
397
|
-
function se(t) {
|
|
398
|
-
return t << 1 ^ De & -(t >> 7);
|
|
399
|
-
}
|
|
400
|
-
function de(t, e) {
|
|
401
|
-
let n = 0;
|
|
402
|
-
for (; e > 0; e >>= 1)
|
|
403
|
-
n ^= t & -(e & 1), t = se(t);
|
|
404
|
-
return n;
|
|
405
|
-
}
|
|
406
|
-
const Ge = /* @__PURE__ */ (() => {
|
|
407
|
-
const t = new Uint8Array(256);
|
|
408
|
-
for (let n = 0, r = 1; n < 256; n++, r ^= se(r))
|
|
409
|
-
t[n] = r;
|
|
410
|
-
const e = new Uint8Array(256);
|
|
411
|
-
e[0] = 99;
|
|
412
|
-
for (let n = 0; n < 255; n++) {
|
|
413
|
-
let r = t[255 - n];
|
|
414
|
-
r |= r << 8, e[t[n]] = (r ^ r >> 4 ^ r >> 5 ^ r >> 6 ^ r >> 7 ^ 99) & 255;
|
|
415
|
-
}
|
|
416
|
-
return x(t), e;
|
|
417
|
-
})(), Fe = (t) => t << 24 | t >>> 8, Y = (t) => t << 8 | t >>> 24;
|
|
418
|
-
function Je(t, e) {
|
|
419
|
-
if (t.length !== 256)
|
|
420
|
-
throw new Error("wrong sbox length");
|
|
421
|
-
const n = new Uint32Array(256).map((l, d) => e(t[d])), r = n.map(Y), i = r.map(Y), o = i.map(Y), s = new Uint32Array(256 * 256), a = new Uint32Array(256 * 256), c = new Uint16Array(256 * 256);
|
|
422
|
-
for (let l = 0; l < 256; l++)
|
|
423
|
-
for (let d = 0; d < 256; d++) {
|
|
424
|
-
const u = l * 256 + d;
|
|
425
|
-
s[u] = n[l] ^ r[d], a[u] = i[l] ^ o[d], c[u] = t[l] << 8 | t[d];
|
|
426
|
-
}
|
|
427
|
-
return { sbox: t, sbox2: c, T0: n, T1: r, T2: i, T3: o, T01: s, T23: a };
|
|
428
|
-
}
|
|
429
|
-
const ye = /* @__PURE__ */ Je(Ge, (t) => de(t, 3) << 24 | t << 16 | t << 8 | de(t, 2)), Ye = /* @__PURE__ */ (() => {
|
|
430
|
-
const t = new Uint8Array(16);
|
|
431
|
-
for (let e = 0, n = 1; e < 16; e++, n = se(n))
|
|
432
|
-
t[e] = n;
|
|
433
|
-
return t;
|
|
434
|
-
})();
|
|
435
|
-
function qe(t) {
|
|
436
|
-
m(t);
|
|
437
|
-
const e = t.length;
|
|
438
|
-
He(t);
|
|
439
|
-
const { sbox2: n } = ye, r = [];
|
|
440
|
-
(!G || !P(t)) && r.push(t = I(t));
|
|
441
|
-
const i = oe(T(t)), o = i.length, s = (c) => L(n, c, c, c, c), a = new Uint32Array(e + 28);
|
|
442
|
-
a.set(i);
|
|
443
|
-
for (let c = o; c < a.length; c++) {
|
|
444
|
-
let l = a[c - 1];
|
|
445
|
-
c % o === 0 ? l = s(Fe(l)) ^ Ye[c / o - 1] : o > 6 && c % o === 4 && (l = s(l)), a[c] = a[c - o] ^ l;
|
|
446
|
-
}
|
|
447
|
-
return x(...r), a;
|
|
448
|
-
}
|
|
449
|
-
function _(t, e, n, r, i, o) {
|
|
450
|
-
return t[n << 8 & 65280 | r >>> 8 & 255] ^ e[i >>> 8 & 65280 | o >>> 24 & 255];
|
|
451
|
-
}
|
|
452
|
-
function L(t, e, n, r, i) {
|
|
453
|
-
return t[e & 255 | n & 65280] | t[r >>> 16 & 255 | i >>> 16 & 65280] << 16;
|
|
454
|
-
}
|
|
455
|
-
function he(t, e, n, r, i) {
|
|
456
|
-
const { sbox2: o, T01: s, T23: a } = ye;
|
|
457
|
-
let c = 0;
|
|
458
|
-
e ^= t[c++], n ^= t[c++], r ^= t[c++], i ^= t[c++];
|
|
459
|
-
const l = t.length / 4 - 2;
|
|
460
|
-
for (let f = 0; f < l; f++) {
|
|
461
|
-
const g = t[c++] ^ _(s, a, e, n, r, i), w = t[c++] ^ _(s, a, n, r, i, e), b = t[c++] ^ _(s, a, r, i, e, n), k = t[c++] ^ _(s, a, i, e, n, r);
|
|
462
|
-
e = g, n = w, r = b, i = k;
|
|
463
|
-
}
|
|
464
|
-
const d = t[c++] ^ L(o, e, n, r, i), u = t[c++] ^ L(o, n, r, i, e), h = t[c++] ^ L(o, r, i, e, n), p = t[c++] ^ L(o, i, e, n, r);
|
|
465
|
-
return { s0: d, s1: u, s2: h, s3: p };
|
|
466
|
-
}
|
|
467
|
-
function W(t, e, n, r, i) {
|
|
468
|
-
m(n, re, "nonce"), m(r), i = _e(r.length, i);
|
|
469
|
-
const o = n, s = T(o), a = H(o), c = T(r), l = T(i), d = e ? 0 : 12, u = r.length;
|
|
470
|
-
let h = a.getUint32(d, e);
|
|
471
|
-
for (let f = 0; f + 4 <= c.length; f += 4) {
|
|
472
|
-
const { s0: g, s1: w, s2: b, s3: k } = he(t, y(s[0]), y(s[1]), y(s[2]), y(s[3]));
|
|
473
|
-
l[f + 0] = c[f + 0] ^ y(g), l[f + 1] = c[f + 1] ^ y(w), l[f + 2] = c[f + 2] ^ y(b), l[f + 3] = c[f + 3] ^ y(k), h = h + 1 >>> 0, a.setUint32(d, h, e);
|
|
474
|
-
}
|
|
475
|
-
const p = re * Math.floor(c.length / Ve);
|
|
476
|
-
if (p < u) {
|
|
477
|
-
const { s0: f, s1: g, s2: w, s3: b } = he(t, y(s[0]), y(s[1]), y(s[2]), y(s[3])), k = new Uint32Array([f, g, w, b]);
|
|
478
|
-
oe(k);
|
|
479
|
-
const A = Be(k);
|
|
480
|
-
for (let E = p, S = 0; E < u; E++, S++)
|
|
481
|
-
i[E] = r[E] ^ A[S];
|
|
482
|
-
x(k);
|
|
483
|
-
}
|
|
484
|
-
return i;
|
|
485
|
-
}
|
|
486
|
-
function Ze(t, e, n, r, i) {
|
|
487
|
-
const o = i ? i.length : 0, s = t.create(n, r.length + o);
|
|
488
|
-
i && s.update(i);
|
|
489
|
-
const a = We(8 * r.length, 8 * o, e);
|
|
490
|
-
s.update(r), s.update(a);
|
|
491
|
-
const c = s.digest();
|
|
492
|
-
return x(a), c;
|
|
493
|
-
}
|
|
494
|
-
const $ = /* @__PURE__ */ Ke({ blockSize: 16, nonceLength: 12, tagLength: 16, withAAD: !0, varSizeNonce: !0 }, function(e, n, r) {
|
|
495
|
-
if (n.length < 8)
|
|
496
|
-
throw new Error("aes/gcm: invalid nonce length");
|
|
497
|
-
const i = 16;
|
|
498
|
-
function o(a, c, l) {
|
|
499
|
-
const d = Ze(ue, !1, a, l, r);
|
|
500
|
-
for (let u = 0; u < c.length; u++)
|
|
501
|
-
d[u] ^= c[u];
|
|
502
|
-
return d;
|
|
503
|
-
}
|
|
504
|
-
function s() {
|
|
505
|
-
const a = qe(e), c = K.slice(), l = K.slice();
|
|
506
|
-
if (W(a, !1, l, l, c), n.length === 12)
|
|
507
|
-
l.set(n);
|
|
508
|
-
else {
|
|
509
|
-
const u = K.slice();
|
|
510
|
-
H(u).setBigUint64(8, BigInt(n.length * 8), !1);
|
|
511
|
-
const p = ue.create(c).update(n).update(u);
|
|
512
|
-
p.digestInto(l), p.destroy();
|
|
513
|
-
}
|
|
514
|
-
const d = W(a, !1, l, K);
|
|
515
|
-
return { xk: a, authKey: c, counter: l, tagMask: d };
|
|
516
|
-
}
|
|
517
|
-
return {
|
|
518
|
-
encrypt(a) {
|
|
519
|
-
const { xk: c, authKey: l, counter: d, tagMask: u } = s(), h = new Uint8Array(a.length + i), p = [c, l, d, u];
|
|
520
|
-
P(a) || p.push(a = I(a)), W(c, !1, d, a, h.subarray(0, a.length));
|
|
521
|
-
const f = o(l, u, h.subarray(0, h.length - i));
|
|
522
|
-
return p.push(f), h.set(f, a.length), x(...p), h;
|
|
523
|
-
},
|
|
524
|
-
decrypt(a) {
|
|
525
|
-
const { xk: c, authKey: l, counter: d, tagMask: u } = s(), h = [c, l, u, d];
|
|
526
|
-
P(a) || h.push(a = I(a));
|
|
527
|
-
const p = a.subarray(0, -i), f = a.subarray(-i), g = o(l, u, p);
|
|
528
|
-
if (h.push(g), !ze(g, f))
|
|
529
|
-
throw x(...h), new Error("aes-gcm: invalid tag");
|
|
530
|
-
const w = W(c, !1, d, p);
|
|
531
|
-
return x(...h), w;
|
|
532
|
-
}
|
|
533
|
-
};
|
|
534
|
-
});
|
|
535
|
-
class j {
|
|
536
|
-
static MAGIC = new TextEncoder().encode("BIMGCM01");
|
|
537
|
-
/**
|
|
538
|
-
* 检测二进制数据是否为 .pzenc 加密格式
|
|
539
|
-
* @param data 原始二进制数据
|
|
540
|
-
* @returns 是否为加密文件
|
|
541
|
-
*/
|
|
542
|
-
static isEncrypted(e) {
|
|
543
|
-
if (e.byteLength < 8) return !1;
|
|
544
|
-
const n = new Uint8Array(e);
|
|
545
|
-
for (let r = 0; r < 8; r++)
|
|
546
|
-
if (n[r] !== j.MAGIC[r]) return !1;
|
|
547
|
-
return !0;
|
|
548
|
-
}
|
|
549
|
-
/**
|
|
550
|
-
* 解密 .pzenc 自定义加密格式为 zip 二进制数据
|
|
551
|
-
*
|
|
552
|
-
* 二进制布局:
|
|
553
|
-
* [0-7] magic "BIMGCM01" (8 字节)
|
|
554
|
-
* [8] version (1 字节, 当前必须为 1)
|
|
555
|
-
* [9] nonceLen (1 字节)
|
|
556
|
-
* [10] tagLen (1 字节)
|
|
557
|
-
* [11..] nonce || tag || ciphertext
|
|
558
|
-
*
|
|
559
|
-
* @param encryptedArrayBuffer 加密的原始二进制数据
|
|
560
|
-
* @param keyBase64 Base64 编码的 AES-256 密钥 (32 字节)
|
|
561
|
-
* @returns 解密后的 zip 二进制数据 (Uint8Array)
|
|
562
|
-
*/
|
|
563
|
-
static async decryptPzEnc(e, n) {
|
|
564
|
-
const r = new Uint8Array(e), i = new TextEncoder().encode("BIMGCM01");
|
|
565
|
-
for (let g = 0; g < i.length; g++)
|
|
566
|
-
if (r[g] !== i[g])
|
|
567
|
-
throw new Error("magic 不匹配: 不是有效的 pzenc 文件");
|
|
568
|
-
const o = r[8];
|
|
569
|
-
if (o !== 1)
|
|
570
|
-
throw new Error(`不支持的 pzenc 版本: ${o}`);
|
|
571
|
-
const s = r[9], a = r[10], c = 11, l = r.slice(c, c + s), d = r.slice(c + s, c + s + a), u = r.slice(c + s + a), h = Qe(u, d), p = Xe(n);
|
|
572
|
-
if (p.length !== 32)
|
|
573
|
-
throw new Error("AES-256 密钥必须是 32 字节");
|
|
574
|
-
const f = r.slice(0, c);
|
|
575
|
-
if (globalThis.crypto?.subtle) {
|
|
576
|
-
const g = await globalThis.crypto.subtle.importKey(
|
|
577
|
-
"raw",
|
|
578
|
-
p.buffer,
|
|
579
|
-
{ name: "AES-GCM" },
|
|
580
|
-
!1,
|
|
581
|
-
["decrypt"]
|
|
582
|
-
), w = await globalThis.crypto.subtle.decrypt(
|
|
583
|
-
{
|
|
584
|
-
name: "AES-GCM",
|
|
585
|
-
iv: l.buffer,
|
|
586
|
-
additionalData: f.buffer,
|
|
587
|
-
tagLength: a * 8
|
|
588
|
-
},
|
|
589
|
-
g,
|
|
590
|
-
h.buffer
|
|
591
|
-
);
|
|
592
|
-
return new Uint8Array(w);
|
|
593
|
-
}
|
|
594
|
-
return et(p, l, f, h, a);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
function Xe(t) {
|
|
598
|
-
const e = atob(t), n = new Uint8Array(e.length);
|
|
599
|
-
for (let r = 0; r < e.length; r++)
|
|
600
|
-
n[r] = e.codePointAt(r);
|
|
601
|
-
return n;
|
|
602
|
-
}
|
|
603
|
-
function Qe(t, e) {
|
|
604
|
-
const n = new Uint8Array(t.length + e.length);
|
|
605
|
-
return n.set(t, 0), n.set(e, t.length), n;
|
|
606
|
-
}
|
|
607
|
-
function et(t, e, n, r, i) {
|
|
608
|
-
if (i !== $.tagLength)
|
|
609
|
-
throw new Error(`当前 HTTP 回退解密仅支持 ${$.tagLength} 字节 AES-GCM tag,当前文件 tagLen: ${i}`);
|
|
610
|
-
return $(t, e, n).decrypt(r);
|
|
611
|
-
}
|
|
612
|
-
function Lt(t, e, n, r) {
|
|
613
|
-
ve({
|
|
614
|
-
method: "get",
|
|
615
|
-
responseType: "arraybuffer",
|
|
616
|
-
url: t
|
|
617
|
-
}).then(async (o) => {
|
|
618
|
-
let s = o.data;
|
|
619
|
-
r && j.isEncrypted(o.data) && (s = await j.decryptPzEnc(o.data, r)), Te.loadAsync(s).then((a) => {
|
|
620
|
-
for (let c in a.files) {
|
|
621
|
-
const l = a.file(a.files[c].name);
|
|
622
|
-
l && l.async("blob").then((d) => {
|
|
623
|
-
i(d, "utf-8", function(u, h) {
|
|
624
|
-
e(h);
|
|
625
|
-
});
|
|
626
|
-
}).catch(() => {
|
|
627
|
-
n();
|
|
628
|
-
});
|
|
629
|
-
}
|
|
630
|
-
}).catch(() => {
|
|
631
|
-
n();
|
|
632
|
-
});
|
|
633
|
-
}).catch(() => {
|
|
634
|
-
n();
|
|
635
|
-
});
|
|
636
|
-
function i(o, s, a) {
|
|
637
|
-
var c = new FileReader(), l = new Blob([o]);
|
|
638
|
-
c.onload = function(d) {
|
|
639
|
-
a(null, d.target.result);
|
|
640
|
-
}, c.onerror = function() {
|
|
641
|
-
a(null, null);
|
|
642
|
-
}, c.readAsText(l, s);
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
function Pt() {
|
|
646
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(t) {
|
|
647
|
-
var e = Math.random() * 16 | 0, n = t == "x" ? e : e & 3 | 8;
|
|
648
|
-
return n.toString(16);
|
|
649
|
-
});
|
|
650
|
-
}
|
|
651
|
-
class It {
|
|
652
|
-
container;
|
|
653
|
-
labelContainer;
|
|
654
|
-
projectCoordinate;
|
|
655
|
-
pickCoordinate;
|
|
656
|
-
emitEvent;
|
|
657
|
-
labels = /* @__PURE__ */ new Map();
|
|
658
|
-
clickCallbacks = /* @__PURE__ */ new Set();
|
|
659
|
-
pickResolver = null;
|
|
660
|
-
isPicking = !1;
|
|
661
|
-
constructor(e) {
|
|
662
|
-
this.container = e.container, this.projectCoordinate = e.projectCoordinate, this.pickCoordinate = e.pickCoordinate, this.emitEvent = e.emitEvent, this.labelContainer = document.createElement("div"), this.labelContainer.className = e.className ?? "bim-engine-label-container", this.labelContainer.style.cssText = [
|
|
663
|
-
"position:absolute",
|
|
664
|
-
"left:0",
|
|
665
|
-
"top:0",
|
|
666
|
-
"width:100%",
|
|
667
|
-
"height:100%",
|
|
668
|
-
"pointer-events:none",
|
|
669
|
-
"overflow:hidden",
|
|
670
|
-
"z-index:1200"
|
|
671
|
-
].join(";"), this.container.appendChild(this.labelContainer);
|
|
672
|
-
}
|
|
673
|
-
/**
|
|
674
|
-
* 开启一次选点,下一次画布点击会返回当前引擎坐标。
|
|
675
|
-
*/
|
|
676
|
-
pickPoint() {
|
|
677
|
-
return this.cancelPick(), this.isPicking = !0, this.container.style.cursor = "crosshair", this.addPickBlockers(), this.container.addEventListener("click", this.handlePickClick, !0), new Promise((e) => {
|
|
678
|
-
this.pickResolver = e;
|
|
679
|
-
});
|
|
680
|
-
}
|
|
681
|
-
/**
|
|
682
|
-
* 兼容回调式调用,便于旧业务页面直接绑定按钮。
|
|
683
|
-
*/
|
|
684
|
-
startPickPoint(e) {
|
|
685
|
-
const n = this.pickPoint();
|
|
686
|
-
return e && n.then(e), n;
|
|
687
|
-
}
|
|
688
|
-
/**
|
|
689
|
-
* 创建标签,返回最终标签 id。
|
|
690
|
-
*/
|
|
691
|
-
createLabel(e) {
|
|
692
|
-
const n = e.id ?? this.createId();
|
|
693
|
-
if (this.labels.has(n))
|
|
694
|
-
throw new Error(`LabelManager: label "${n}" already exists`);
|
|
695
|
-
const r = this.createElement(n), i = {
|
|
696
|
-
id: n,
|
|
697
|
-
coordinate: { ...e.coordinate },
|
|
698
|
-
icon: e.icon,
|
|
699
|
-
name: e.name,
|
|
700
|
-
data: e.data,
|
|
701
|
-
size: e.iconSize ?? e.size ?? 28,
|
|
702
|
-
visible: e.visible ?? !0,
|
|
703
|
-
element: r
|
|
704
|
-
};
|
|
705
|
-
return this.labels.set(n, i), this.labelContainer.appendChild(r), this.renderLabel(i), this.updateLabelPosition(i), this.emitEvent?.("label-created", this.toPayload(i)), n;
|
|
706
|
-
}
|
|
707
|
-
/**
|
|
708
|
-
* 更新标签,支持按需修改坐标、图标、名称和业务数据。
|
|
709
|
-
*/
|
|
710
|
-
updateLabel(e, n) {
|
|
711
|
-
const r = this.labels.get(e);
|
|
712
|
-
return r ? (n.coordinate && (r.coordinate = { ...n.coordinate }), n.icon !== void 0 && (r.icon = n.icon), n.name !== void 0 && (r.name = n.name), n.data !== void 0 && (r.data = n.data), n.iconSize !== void 0 && (r.size = n.iconSize), n.size !== void 0 && (r.size = n.size), n.visible !== void 0 && (r.visible = n.visible), this.renderLabel(r), this.updateLabelPosition(r), this.emitEvent?.("label-updated", this.toPayload(r)), !0) : !1;
|
|
713
|
-
}
|
|
714
|
-
/**
|
|
715
|
-
* 删除指定标签。
|
|
716
|
-
*/
|
|
717
|
-
deleteLabel(e) {
|
|
718
|
-
const n = this.labels.get(e);
|
|
719
|
-
return n ? (n.element.remove(), this.labels.delete(e), this.emitEvent?.("label-deleted", { id: e }), !0) : !1;
|
|
720
|
-
}
|
|
721
|
-
removeLabel(e) {
|
|
722
|
-
return this.deleteLabel(e);
|
|
723
|
-
}
|
|
724
|
-
clearLabels() {
|
|
725
|
-
Array.from(this.labels.keys()).forEach((e) => this.deleteLabel(e));
|
|
726
|
-
}
|
|
727
|
-
getLabel(e) {
|
|
728
|
-
return this.labels.get(e);
|
|
729
|
-
}
|
|
730
|
-
getLabels() {
|
|
731
|
-
return Array.from(this.labels.values());
|
|
732
|
-
}
|
|
733
|
-
onLabelClick(e) {
|
|
734
|
-
return this.clickCallbacks.add(e), () => this.offLabelClick(e);
|
|
735
|
-
}
|
|
736
|
-
offLabelClick(e) {
|
|
737
|
-
this.clickCallbacks.delete(e);
|
|
738
|
-
}
|
|
739
|
-
/**
|
|
740
|
-
* 每帧同步标签屏幕位置。
|
|
741
|
-
*/
|
|
742
|
-
update() {
|
|
743
|
-
this.labels.forEach((e) => this.updateLabelPosition(e));
|
|
744
|
-
}
|
|
745
|
-
cancelPick() {
|
|
746
|
-
this.isPicking && (this.isPicking = !1, this.container.style.cursor = "", this.removePickBlockers(), this.container.removeEventListener("click", this.handlePickClick, !0), this.pickResolver?.(null), this.pickResolver = null);
|
|
747
|
-
}
|
|
748
|
-
dispose() {
|
|
749
|
-
this.cancelPick(), this.clearLabels(), this.clickCallbacks.clear(), this.labelContainer.remove();
|
|
750
|
-
}
|
|
751
|
-
createElement(e) {
|
|
752
|
-
const n = document.createElement("div");
|
|
753
|
-
return n.dataset.labelId = e, n.style.cssText = [
|
|
754
|
-
"position:absolute",
|
|
755
|
-
"display:flex",
|
|
756
|
-
"flex-direction:column",
|
|
757
|
-
"align-items:center",
|
|
758
|
-
"gap:5px",
|
|
759
|
-
"transform:translate(-50%, -100%)",
|
|
760
|
-
"pointer-events:auto",
|
|
761
|
-
"cursor:pointer",
|
|
762
|
-
"user-select:none",
|
|
763
|
-
"white-space:nowrap",
|
|
764
|
-
"font:12px/1.2 -apple-system,BlinkMacSystemFont,Segoe UI,Arial,sans-serif"
|
|
765
|
-
].join(";"), n.addEventListener("click", (r) => {
|
|
766
|
-
r.preventDefault(), r.stopPropagation();
|
|
767
|
-
const i = this.labels.get(e);
|
|
768
|
-
if (!i) return;
|
|
769
|
-
const o = {
|
|
770
|
-
id: e,
|
|
771
|
-
label: i,
|
|
772
|
-
coordinate: i.coordinate,
|
|
773
|
-
originalEvent: r
|
|
774
|
-
};
|
|
775
|
-
this.clickCallbacks.forEach((s) => s(o)), this.emitEvent?.("label-click", o);
|
|
776
|
-
}), n;
|
|
777
|
-
}
|
|
778
|
-
renderLabel(e) {
|
|
779
|
-
e.element.innerHTML = "";
|
|
780
|
-
const n = document.createElement("img"), r = this.normalizeIconSize(e.size);
|
|
781
|
-
n.src = e.icon, n.alt = e.name, n.style.cssText = [
|
|
782
|
-
`width:${r.width}px`,
|
|
783
|
-
`height:${r.height}px`,
|
|
784
|
-
"object-fit:contain",
|
|
785
|
-
"display:block",
|
|
786
|
-
"filter:drop-shadow(0 3px 5px rgba(0,0,0,.32))"
|
|
787
|
-
].join(";");
|
|
788
|
-
const i = document.createElement("span");
|
|
789
|
-
i.textContent = e.name, i.style.cssText = [
|
|
790
|
-
"max-width:160px",
|
|
791
|
-
"overflow:hidden",
|
|
792
|
-
"text-overflow:ellipsis",
|
|
793
|
-
"padding:5px 9px",
|
|
794
|
-
"border-radius:6px",
|
|
795
|
-
"background:rgba(15,23,42,.88)",
|
|
796
|
-
"color:#fff",
|
|
797
|
-
"border:1px solid rgba(255,255,255,.16)",
|
|
798
|
-
"box-shadow:0 3px 10px rgba(0,0,0,.24)"
|
|
799
|
-
].join(";"), e.element.title = e.name, e.element.appendChild(i), e.element.appendChild(n);
|
|
800
|
-
}
|
|
801
|
-
updateLabelPosition(e) {
|
|
802
|
-
const n = this.projectCoordinate(e.coordinate);
|
|
803
|
-
if (!(e.visible && n != null && n.visible !== !1) || !n) {
|
|
804
|
-
e.element.style.display = "none";
|
|
805
|
-
return;
|
|
806
|
-
}
|
|
807
|
-
e.element.style.display = "flex", e.element.style.left = `${n.x}px`, e.element.style.top = `${n.y}px`;
|
|
808
|
-
}
|
|
809
|
-
handlePickClick = (e) => {
|
|
810
|
-
e.preventDefault(), e.stopImmediatePropagation();
|
|
811
|
-
const n = this.pickCoordinate(e);
|
|
812
|
-
this.isPicking = !1, this.container.style.cursor = "", this.removePickBlockers(), this.container.removeEventListener("click", this.handlePickClick, !0), this.pickResolver?.(n), this.pickResolver = null, n && this.emitEvent?.("label-pick", n);
|
|
813
|
-
};
|
|
814
|
-
toPayload(e) {
|
|
815
|
-
return {
|
|
816
|
-
id: e.id,
|
|
817
|
-
coordinate: e.coordinate,
|
|
818
|
-
icon: e.icon,
|
|
819
|
-
name: e.name,
|
|
820
|
-
data: e.data,
|
|
821
|
-
size: e.size,
|
|
822
|
-
visible: e.visible
|
|
823
|
-
};
|
|
824
|
-
}
|
|
825
|
-
normalizeIconSize(e) {
|
|
826
|
-
return typeof e == "number" ? {
|
|
827
|
-
width: e,
|
|
828
|
-
height: e
|
|
829
|
-
} : {
|
|
830
|
-
width: this.normalizeSizeValue(e.width, 28),
|
|
831
|
-
height: this.normalizeSizeValue(e.height, 28)
|
|
832
|
-
};
|
|
833
|
-
}
|
|
834
|
-
normalizeSizeValue(e, n) {
|
|
835
|
-
return Number.isFinite(e) && e > 0 ? e : n;
|
|
836
|
-
}
|
|
837
|
-
createId() {
|
|
838
|
-
return `label-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
839
|
-
}
|
|
840
|
-
addPickBlockers() {
|
|
841
|
-
this.container.addEventListener("mousedown", this.blockPickInteraction, !0), this.container.addEventListener("mouseup", this.blockPickInteraction, !0), this.container.addEventListener("touchstart", this.blockPickInteraction, !0), this.container.addEventListener("touchmove", this.blockPickInteraction, !0), this.container.addEventListener("touchend", this.blockPickInteraction, !0);
|
|
842
|
-
}
|
|
843
|
-
removePickBlockers() {
|
|
844
|
-
this.container.removeEventListener("mousedown", this.blockPickInteraction, !0), this.container.removeEventListener("mouseup", this.blockPickInteraction, !0), this.container.removeEventListener("touchstart", this.blockPickInteraction, !0), this.container.removeEventListener("touchmove", this.blockPickInteraction, !0), this.container.removeEventListener("touchend", this.blockPickInteraction, !0);
|
|
845
|
-
}
|
|
846
|
-
blockPickInteraction = (e) => {
|
|
847
|
-
e.stopImmediatePropagation();
|
|
848
|
-
};
|
|
849
|
-
}
|
|
850
|
-
const tt = "4.0.14", nt = {
|
|
851
|
-
version: tt
|
|
852
|
-
}, N = nt.version;
|
|
853
|
-
function ce() {
|
|
854
|
-
const t = globalThis.crypto?.subtle;
|
|
855
|
-
if (!t)
|
|
856
|
-
throw new Error("[BimEngine] Web Crypto API is required for secure sdkAuth credentials mode");
|
|
857
|
-
return t;
|
|
858
|
-
}
|
|
859
|
-
function U(t) {
|
|
860
|
-
return new TextEncoder().encode(t);
|
|
861
|
-
}
|
|
862
|
-
function B(t) {
|
|
863
|
-
return t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength);
|
|
864
|
-
}
|
|
865
|
-
function fe(t) {
|
|
866
|
-
let e = "";
|
|
867
|
-
return t.forEach((n) => {
|
|
868
|
-
e += String.fromCharCode(n);
|
|
869
|
-
}), btoa(e);
|
|
870
|
-
}
|
|
871
|
-
function rt(t) {
|
|
872
|
-
const e = t.getUTCFullYear(), n = String(t.getUTCMonth() + 1).padStart(2, "0"), r = String(t.getUTCDate()).padStart(2, "0");
|
|
873
|
-
return `${e}${n}${r}`;
|
|
874
|
-
}
|
|
875
|
-
async function it(t) {
|
|
876
|
-
const e = await ce().digest("SHA-256", B(U(t)));
|
|
877
|
-
return Array.from(new Uint8Array(e)).map((n) => n.toString(16).padStart(2, "0")).join("");
|
|
878
|
-
}
|
|
879
|
-
async function ot(t, e) {
|
|
880
|
-
const n = ce(), r = await n.importKey("raw", B(t), { name: "HMAC", hash: "SHA-256" }, !1, ["sign"]);
|
|
881
|
-
return n.sign("HMAC", r, B(U(e)));
|
|
882
|
-
}
|
|
883
|
-
function st(t) {
|
|
884
|
-
return U(
|
|
885
|
-
[t.appId, t.engineType, t.requestDate, String(t.timestamp), t.nonce].join("|")
|
|
886
|
-
);
|
|
887
|
-
}
|
|
888
|
-
async function ct(t) {
|
|
889
|
-
const e = ce(), n = /* @__PURE__ */ new Date(), r = n.getTime(), i = rt(n), o = globalThis.crypto.randomUUID(), s = globalThis.crypto.getRandomValues(new Uint8Array(12)), a = await it(t.appSecret), c = await ot(U(a), i), l = await e.importKey("raw", c, "AES-GCM", !1, ["encrypt"]), d = JSON.stringify({
|
|
890
|
-
appKey: t.appKey,
|
|
891
|
-
appSecret: t.appSecret
|
|
892
|
-
}), u = await e.encrypt(
|
|
893
|
-
{
|
|
894
|
-
name: "AES-GCM",
|
|
895
|
-
iv: s,
|
|
896
|
-
additionalData: B(st({
|
|
897
|
-
appId: t.appId,
|
|
898
|
-
engineType: t.engineType,
|
|
899
|
-
requestDate: i,
|
|
900
|
-
timestamp: r,
|
|
901
|
-
nonce: o
|
|
902
|
-
})),
|
|
903
|
-
tagLength: 128
|
|
904
|
-
},
|
|
905
|
-
l,
|
|
906
|
-
B(U(d))
|
|
907
|
-
);
|
|
908
|
-
return {
|
|
909
|
-
appId: t.appId,
|
|
910
|
-
engineType: t.engineType,
|
|
911
|
-
requestDate: i,
|
|
912
|
-
timestamp: r,
|
|
913
|
-
nonce: o,
|
|
914
|
-
iv: fe(s),
|
|
915
|
-
cipherText: fe(new Uint8Array(u)),
|
|
916
|
-
sdkVersion: t.sdkVersion,
|
|
917
|
-
origin: t.origin,
|
|
918
|
-
product: t.product
|
|
919
|
-
};
|
|
920
|
-
}
|
|
921
|
-
const q = /* @__PURE__ */ new Map();
|
|
922
|
-
function V(t) {
|
|
923
|
-
return t.replace(/\/+$/, "");
|
|
924
|
-
}
|
|
925
|
-
function D(t) {
|
|
926
|
-
if (t) return t;
|
|
927
|
-
if (typeof window < "u" && typeof window.location?.origin == "string")
|
|
928
|
-
return window.location.origin;
|
|
929
|
-
}
|
|
930
|
-
function at(t, e) {
|
|
931
|
-
return JSON.stringify({
|
|
932
|
-
endpoint: V(t.endpoint),
|
|
933
|
-
token: t.token ?? "",
|
|
934
|
-
appId: t.appId ?? "",
|
|
935
|
-
appKey: t.appKey ?? "",
|
|
936
|
-
appSecret: t.appSecret ?? "",
|
|
937
|
-
origin: D(t.origin) ?? "",
|
|
938
|
-
product: t.product ?? "",
|
|
939
|
-
engineType: e,
|
|
940
|
-
sdkVersion: N
|
|
941
|
-
});
|
|
942
|
-
}
|
|
943
|
-
async function ie(t, e, n) {
|
|
944
|
-
const r = typeof AbortController < "u" ? new AbortController() : void 0, i = r ? setTimeout(() => r.abort(), n) : void 0;
|
|
945
|
-
try {
|
|
946
|
-
const o = await fetch(t, {
|
|
947
|
-
method: "POST",
|
|
948
|
-
headers: {
|
|
949
|
-
"Content-Type": "application/json"
|
|
950
|
-
},
|
|
951
|
-
body: JSON.stringify(e),
|
|
952
|
-
signal: r?.signal
|
|
953
|
-
}), s = await o.json().catch(() => ({}));
|
|
954
|
-
if (!o.ok) {
|
|
955
|
-
const a = s?.error?.message ?? s?.message ?? `SDK authentication failed with status ${o.status}`;
|
|
956
|
-
throw new Error(a);
|
|
957
|
-
}
|
|
958
|
-
return s;
|
|
959
|
-
} finally {
|
|
960
|
-
i != null && clearTimeout(i);
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
async function lt(t, e) {
|
|
964
|
-
const n = await ie(`${V(t.endpoint)}/oauth/sdk-verify`, {
|
|
965
|
-
sdkToken: t.token,
|
|
966
|
-
engineType: e,
|
|
967
|
-
sdkVersion: N,
|
|
968
|
-
origin: D(t.origin),
|
|
969
|
-
product: t.product
|
|
970
|
-
}, t.timeoutMs ?? 8e3);
|
|
971
|
-
return n.sdkToken = t.token, n;
|
|
972
|
-
}
|
|
973
|
-
async function ut(t, e) {
|
|
974
|
-
const n = await ct({
|
|
975
|
-
appId: t.appId,
|
|
976
|
-
appKey: t.appKey,
|
|
977
|
-
appSecret: t.appSecret,
|
|
978
|
-
engineType: e,
|
|
979
|
-
sdkVersion: N,
|
|
980
|
-
origin: D(t.origin),
|
|
981
|
-
product: t.product
|
|
982
|
-
}), r = await ie(
|
|
983
|
-
`${V(t.endpoint)}/oauth/sdk-token/secure`,
|
|
984
|
-
n,
|
|
985
|
-
t.timeoutMs ?? 8e3
|
|
986
|
-
), i = await ie(`${V(t.endpoint)}/oauth/sdk-verify`, {
|
|
987
|
-
sdkToken: r.sdkToken,
|
|
988
|
-
engineType: e,
|
|
989
|
-
sdkVersion: N,
|
|
990
|
-
origin: D(t.origin),
|
|
991
|
-
product: t.product
|
|
992
|
-
}, t.timeoutMs ?? 8e3);
|
|
993
|
-
return i.sdkToken = r.sdkToken, i;
|
|
994
|
-
}
|
|
995
|
-
async function dt(t, e) {
|
|
996
|
-
const n = t?.sdkAuth;
|
|
997
|
-
if (!n)
|
|
998
|
-
return null;
|
|
999
|
-
if (!n.endpoint)
|
|
1000
|
-
throw new Error("[BimEngine] sdkAuth.endpoint is required");
|
|
1001
|
-
if (!n.token && !(n.appId && n.appKey && n.appSecret))
|
|
1002
|
-
return null;
|
|
1003
|
-
const r = at(n, e), i = q.get(r);
|
|
1004
|
-
if (i) {
|
|
1005
|
-
const s = await i;
|
|
1006
|
-
return t && (t.__sdkAuthSession = s), s;
|
|
1007
|
-
}
|
|
1008
|
-
const o = (n.token ? lt(n, e) : ut(n, e)).then((s) => {
|
|
1009
|
-
if (s.authorized !== !0)
|
|
1010
|
-
throw new Error("[BimEngine] SDK authorization rejected");
|
|
1011
|
-
return t && (t.__sdkAuthSession = s), s;
|
|
1012
|
-
}).catch((s) => {
|
|
1013
|
-
throw q.delete(r), s;
|
|
1014
|
-
});
|
|
1015
|
-
return q.set(r, o), o;
|
|
1016
|
-
}
|
|
1017
|
-
const ht = "evtrsa1", Z = /* @__PURE__ */ new Map();
|
|
1018
|
-
function me(t) {
|
|
1019
|
-
return t.replace(/\/+$/, "");
|
|
1020
|
-
}
|
|
1021
|
-
function ft(t) {
|
|
1022
|
-
return new TextEncoder().encode(t);
|
|
1023
|
-
}
|
|
1024
|
-
function O(t) {
|
|
1025
|
-
let e = "";
|
|
1026
|
-
return t.forEach((n) => {
|
|
1027
|
-
e += String.fromCharCode(n);
|
|
1028
|
-
}), btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
1029
|
-
}
|
|
1030
|
-
async function pt(t, e) {
|
|
1031
|
-
const n = typeof AbortController < "u" ? new AbortController() : void 0, r = n ? setTimeout(() => n.abort(), e) : void 0;
|
|
1032
|
-
try {
|
|
1033
|
-
const i = await fetch(t, {
|
|
1034
|
-
method: "GET",
|
|
1035
|
-
headers: {
|
|
1036
|
-
Accept: "application/json"
|
|
1037
|
-
},
|
|
1038
|
-
signal: n?.signal
|
|
1039
|
-
}), o = await i.json().catch(() => ({}));
|
|
1040
|
-
if (!i.ok) {
|
|
1041
|
-
const s = o?.error?.message ?? o?.message ?? `ViewToken public key request failed with status ${i.status}`;
|
|
1042
|
-
throw new Error(s);
|
|
1043
|
-
}
|
|
1044
|
-
return o;
|
|
1045
|
-
} finally {
|
|
1046
|
-
r != null && clearTimeout(r);
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
function X(t) {
|
|
1050
|
-
const e = globalThis.crypto;
|
|
1051
|
-
if (!e?.getRandomValues)
|
|
1052
|
-
throw new Error("[BimEngine] crypto.getRandomValues is required to encrypt viewToken");
|
|
1053
|
-
return e.getRandomValues(new Uint8Array(t));
|
|
1054
|
-
}
|
|
1055
|
-
function gt(t) {
|
|
1056
|
-
let e = "";
|
|
1057
|
-
return t.forEach((n) => {
|
|
1058
|
-
e += String.fromCharCode(n);
|
|
1059
|
-
}), e;
|
|
1060
|
-
}
|
|
1061
|
-
function yt(t) {
|
|
1062
|
-
const e = new Uint8Array(t.length);
|
|
1063
|
-
for (let n = 0; n < t.length; n += 1)
|
|
1064
|
-
e[n] = t.charCodeAt(n) & 255;
|
|
1065
|
-
return e;
|
|
1066
|
-
}
|
|
1067
|
-
async function mt(t, e) {
|
|
1068
|
-
const n = `${me(t)}/models/view-token/public-key`, r = await pt(n, e);
|
|
1069
|
-
if (r.algorithm !== "RSA-OAEP-256" || !r.publicKey)
|
|
1070
|
-
throw new Error("[BimEngine] OpenAPI returned an invalid viewToken public key");
|
|
1071
|
-
return Q.pki.publicKeyFromPem(r.publicKey);
|
|
1072
|
-
}
|
|
1073
|
-
function wt(t, e) {
|
|
1074
|
-
const n = me(t), r = Z.get(n);
|
|
1075
|
-
if (r)
|
|
1076
|
-
return r;
|
|
1077
|
-
const i = mt(t, e).catch((o) => {
|
|
1078
|
-
throw Z.delete(n), o;
|
|
1079
|
-
});
|
|
1080
|
-
return Z.set(n, i), i;
|
|
1081
|
-
}
|
|
1082
|
-
async function bt(t, e, n) {
|
|
1083
|
-
const r = await wt(t, n), i = X(32), o = X(12), s = X(16), a = JSON.stringify({
|
|
1084
|
-
viewToken: e,
|
|
1085
|
-
timestamp: Date.now(),
|
|
1086
|
-
nonce: O(s)
|
|
1087
|
-
}), c = r.encrypt(
|
|
1088
|
-
gt(i),
|
|
1089
|
-
"RSA-OAEP",
|
|
1090
|
-
{
|
|
1091
|
-
md: Q.md.sha256.create(),
|
|
1092
|
-
mgf1: {
|
|
1093
|
-
md: Q.md.sha256.create()
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
), l = $(i, o).encrypt(ft(a));
|
|
1097
|
-
return [
|
|
1098
|
-
ht,
|
|
1099
|
-
O(yt(c)),
|
|
1100
|
-
O(o),
|
|
1101
|
-
O(l)
|
|
1102
|
-
].join(".");
|
|
1103
|
-
}
|
|
1104
|
-
function kt(t) {
|
|
1105
|
-
return t.replace(/\/+$/, "");
|
|
1106
|
-
}
|
|
1107
|
-
async function Et(t, e, n) {
|
|
1108
|
-
const r = typeof AbortController < "u" ? new AbortController() : void 0, i = r ? setTimeout(() => r.abort(), n) : void 0;
|
|
1109
|
-
try {
|
|
1110
|
-
const o = await fetch(t, {
|
|
1111
|
-
method: "POST",
|
|
1112
|
-
headers: {
|
|
1113
|
-
"Content-Type": "application/json"
|
|
1114
|
-
},
|
|
1115
|
-
body: JSON.stringify(e),
|
|
1116
|
-
signal: r?.signal
|
|
1117
|
-
}), s = await o.json().catch(() => ({}));
|
|
1118
|
-
if (!o.ok) {
|
|
1119
|
-
const a = s?.error?.message ?? s?.message ?? `ViewToken resolve failed with status ${o.status}`;
|
|
1120
|
-
throw new Error(a);
|
|
1121
|
-
}
|
|
1122
|
-
return s;
|
|
1123
|
-
} finally {
|
|
1124
|
-
i != null && clearTimeout(i);
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
function xt(t) {
|
|
1128
|
-
switch (t) {
|
|
1129
|
-
case "2d":
|
|
1130
|
-
return "cad_model";
|
|
1131
|
-
case "720":
|
|
1132
|
-
return "panorama";
|
|
1133
|
-
case "gaussian":
|
|
1134
|
-
return "gaussian_model";
|
|
1135
|
-
default:
|
|
1136
|
-
return "model";
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
function vt(t, e) {
|
|
1140
|
-
return {
|
|
1141
|
-
applicationId: 0,
|
|
1142
|
-
engineType: e,
|
|
1143
|
-
assetCategory: xt(e),
|
|
1144
|
-
url: t,
|
|
1145
|
-
urls: [t]
|
|
1146
|
-
};
|
|
1147
|
-
}
|
|
1148
|
-
async function Ut(t, e, n) {
|
|
1149
|
-
const r = t?.sdkAuth;
|
|
1150
|
-
if (!r?.endpoint)
|
|
1151
|
-
return vt(e, n);
|
|
1152
|
-
let i;
|
|
1153
|
-
(r.token || r.appId && r.appKey && r.appSecret) && (i = (await dt(t, n))?.sdkToken);
|
|
1154
|
-
const s = {
|
|
1155
|
-
viewToken: await bt(
|
|
1156
|
-
r.endpoint,
|
|
1157
|
-
e,
|
|
1158
|
-
r.timeoutMs ?? 8e3
|
|
1159
|
-
),
|
|
1160
|
-
engineType: n
|
|
1161
|
-
};
|
|
1162
|
-
return i && (s.sdkToken = i), Et(
|
|
1163
|
-
`${kt(r.endpoint)}/models/view-token/resolve`,
|
|
1164
|
-
s,
|
|
1165
|
-
r.timeoutMs ?? 8e3
|
|
1166
|
-
);
|
|
1167
|
-
}
|
|
1168
|
-
export {
|
|
1169
|
-
j as B,
|
|
1170
|
-
Ct as C,
|
|
1171
|
-
N as E,
|
|
1172
|
-
Lt as L,
|
|
1173
|
-
St as W,
|
|
1174
|
-
It as a,
|
|
1175
|
-
Pt as g,
|
|
1176
|
-
Ut as r
|
|
1177
|
-
};
|