@aibee/crc-bmap 0.14.29 → 0.14.31
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/lib/index.cjs +70 -90
- package/lib/index.esm.min.js +70 -90
- package/lib/meta.json +101 -10
- package/lib/src/elements/graphic.d.ts +27 -2
- package/lib/src/factory/material.d.ts +9 -4
- package/lib/src/utils/translate.d.ts +27 -0
- package/lib/worker/{loader.worker-SKK7VPJG.js → loader.worker-52WGVNK2.js} +175 -175
- package/package.json +1 -1
package/lib/meta.json
CHANGED
|
@@ -617,7 +617,7 @@
|
|
|
617
617
|
"format": "esm"
|
|
618
618
|
},
|
|
619
619
|
"../lib/src/utils/translate.js": {
|
|
620
|
-
"bytes":
|
|
620
|
+
"bytes": 8231,
|
|
621
621
|
"imports": [
|
|
622
622
|
{
|
|
623
623
|
"path": "core-js/modules/es.json.stringify.js",
|
|
@@ -628,6 +628,51 @@
|
|
|
628
628
|
"path": "core-js/modules/web.dom-collections.iterator.js",
|
|
629
629
|
"kind": "import-statement",
|
|
630
630
|
"external": true
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
"path": "core-js/modules/es.set.difference.v2.js",
|
|
634
|
+
"kind": "import-statement",
|
|
635
|
+
"external": true
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
"path": "core-js/modules/es.set.intersection.v2.js",
|
|
639
|
+
"kind": "import-statement",
|
|
640
|
+
"external": true
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
"path": "core-js/modules/es.set.is-disjoint-from.v2.js",
|
|
644
|
+
"kind": "import-statement",
|
|
645
|
+
"external": true
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
"path": "core-js/modules/es.set.is-subset-of.v2.js",
|
|
649
|
+
"kind": "import-statement",
|
|
650
|
+
"external": true
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
"path": "core-js/modules/es.set.is-superset-of.v2.js",
|
|
654
|
+
"kind": "import-statement",
|
|
655
|
+
"external": true
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
"path": "core-js/modules/es.set.symmetric-difference.v2.js",
|
|
659
|
+
"kind": "import-statement",
|
|
660
|
+
"external": true
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
"path": "core-js/modules/es.set.union.v2.js",
|
|
664
|
+
"kind": "import-statement",
|
|
665
|
+
"external": true
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
"path": "core-js/modules/es.array.push.js",
|
|
669
|
+
"kind": "import-statement",
|
|
670
|
+
"external": true
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
"path": "core-js/modules/es.array.sort.js",
|
|
674
|
+
"kind": "import-statement",
|
|
675
|
+
"external": true
|
|
631
676
|
}
|
|
632
677
|
],
|
|
633
678
|
"format": "esm"
|
|
@@ -1066,7 +1111,7 @@
|
|
|
1066
1111
|
"format": "esm"
|
|
1067
1112
|
},
|
|
1068
1113
|
"../lib/src/factory/material.js": {
|
|
1069
|
-
"bytes":
|
|
1114
|
+
"bytes": 17404,
|
|
1070
1115
|
"imports": [
|
|
1071
1116
|
{
|
|
1072
1117
|
"path": "core-js/modules/web.dom-collections.iterator.js",
|
|
@@ -1717,7 +1762,7 @@
|
|
|
1717
1762
|
"format": "esm"
|
|
1718
1763
|
},
|
|
1719
1764
|
"../lib/src/elements/graphic.js": {
|
|
1720
|
-
"bytes":
|
|
1765
|
+
"bytes": 18300,
|
|
1721
1766
|
"imports": [
|
|
1722
1767
|
{
|
|
1723
1768
|
"path": "../../../node_modules/.pnpm/@swc+helpers@0.5.17/node_modules/@swc/helpers/esm/_extends.js",
|
|
@@ -2058,7 +2103,7 @@
|
|
|
2058
2103
|
"format": "esm"
|
|
2059
2104
|
},
|
|
2060
2105
|
"../src/factory/material.ts": {
|
|
2061
|
-
"bytes":
|
|
2106
|
+
"bytes": 17779,
|
|
2062
2107
|
"imports": [
|
|
2063
2108
|
{
|
|
2064
2109
|
"path": "three/examples/jsm/lines/LineMaterial.js",
|
|
@@ -2452,7 +2497,7 @@
|
|
|
2452
2497
|
"format": "esm"
|
|
2453
2498
|
},
|
|
2454
2499
|
"../src/utils/translate.ts": {
|
|
2455
|
-
"bytes":
|
|
2500
|
+
"bytes": 7704,
|
|
2456
2501
|
"imports": [
|
|
2457
2502
|
{
|
|
2458
2503
|
"path": "../types",
|
|
@@ -7378,6 +7423,51 @@
|
|
|
7378
7423
|
"kind": "import-statement",
|
|
7379
7424
|
"external": true
|
|
7380
7425
|
},
|
|
7426
|
+
{
|
|
7427
|
+
"path": "core-js/modules/es.array.push.js",
|
|
7428
|
+
"kind": "import-statement",
|
|
7429
|
+
"external": true
|
|
7430
|
+
},
|
|
7431
|
+
{
|
|
7432
|
+
"path": "core-js/modules/es.array.sort.js",
|
|
7433
|
+
"kind": "import-statement",
|
|
7434
|
+
"external": true
|
|
7435
|
+
},
|
|
7436
|
+
{
|
|
7437
|
+
"path": "core-js/modules/es.set.difference.v2.js",
|
|
7438
|
+
"kind": "import-statement",
|
|
7439
|
+
"external": true
|
|
7440
|
+
},
|
|
7441
|
+
{
|
|
7442
|
+
"path": "core-js/modules/es.set.intersection.v2.js",
|
|
7443
|
+
"kind": "import-statement",
|
|
7444
|
+
"external": true
|
|
7445
|
+
},
|
|
7446
|
+
{
|
|
7447
|
+
"path": "core-js/modules/es.set.is-disjoint-from.v2.js",
|
|
7448
|
+
"kind": "import-statement",
|
|
7449
|
+
"external": true
|
|
7450
|
+
},
|
|
7451
|
+
{
|
|
7452
|
+
"path": "core-js/modules/es.set.is-subset-of.v2.js",
|
|
7453
|
+
"kind": "import-statement",
|
|
7454
|
+
"external": true
|
|
7455
|
+
},
|
|
7456
|
+
{
|
|
7457
|
+
"path": "core-js/modules/es.set.is-superset-of.v2.js",
|
|
7458
|
+
"kind": "import-statement",
|
|
7459
|
+
"external": true
|
|
7460
|
+
},
|
|
7461
|
+
{
|
|
7462
|
+
"path": "core-js/modules/es.set.symmetric-difference.v2.js",
|
|
7463
|
+
"kind": "import-statement",
|
|
7464
|
+
"external": true
|
|
7465
|
+
},
|
|
7466
|
+
{
|
|
7467
|
+
"path": "core-js/modules/es.set.union.v2.js",
|
|
7468
|
+
"kind": "import-statement",
|
|
7469
|
+
"external": true
|
|
7470
|
+
},
|
|
7381
7471
|
{
|
|
7382
7472
|
"path": "core-js/modules/web.dom-collections.iterator.js",
|
|
7383
7473
|
"kind": "import-statement",
|
|
@@ -9648,6 +9738,7 @@
|
|
|
9648
9738
|
"Wall",
|
|
9649
9739
|
"WorkerPool",
|
|
9650
9740
|
"addAlphaToHexColor",
|
|
9741
|
+
"assignGraphicDepthLevel",
|
|
9651
9742
|
"buildSdfTextGeometry",
|
|
9652
9743
|
"calc_angle",
|
|
9653
9744
|
"calc_direction",
|
|
@@ -9835,7 +9926,7 @@
|
|
|
9835
9926
|
"bytesInOutput": 414
|
|
9836
9927
|
},
|
|
9837
9928
|
"../lib/src/utils/translate.js": {
|
|
9838
|
-
"bytesInOutput":
|
|
9929
|
+
"bytesInOutput": 2491
|
|
9839
9930
|
},
|
|
9840
9931
|
"../lib/src/utils/tween.js": {
|
|
9841
9932
|
"bytesInOutput": 931
|
|
@@ -9865,10 +9956,10 @@
|
|
|
9865
9956
|
"bytesInOutput": 3434
|
|
9866
9957
|
},
|
|
9867
9958
|
"../lib/src/elements/graphic.js": {
|
|
9868
|
-
"bytesInOutput":
|
|
9959
|
+
"bytesInOutput": 7516
|
|
9869
9960
|
},
|
|
9870
9961
|
"../lib/src/factory/material.js": {
|
|
9871
|
-
"bytesInOutput":
|
|
9962
|
+
"bytesInOutput": 13988
|
|
9872
9963
|
},
|
|
9873
9964
|
"../lib/src/factory/sdf-text.js": {
|
|
9874
9965
|
"bytesInOutput": 7718
|
|
@@ -9970,7 +10061,7 @@
|
|
|
9970
10061
|
"bytesInOutput": 4578
|
|
9971
10062
|
},
|
|
9972
10063
|
"../src/factory/material.ts": {
|
|
9973
|
-
"bytesInOutput":
|
|
10064
|
+
"bytesInOutput": 13989
|
|
9974
10065
|
},
|
|
9975
10066
|
"../src/factory/unique-key.ts": {
|
|
9976
10067
|
"bytesInOutput": 368
|
|
@@ -10249,7 +10340,7 @@
|
|
|
10249
10340
|
"bytesInOutput": 0
|
|
10250
10341
|
}
|
|
10251
10342
|
},
|
|
10252
|
-
"bytes":
|
|
10343
|
+
"bytes": 451684
|
|
10253
10344
|
}
|
|
10254
10345
|
}
|
|
10255
10346
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Object3D, ExtrudeGeometry, Mesh, MeshBasicMaterial, Raycaster, Object3DEventMap, Vector3, BufferGeometry, LineBasicMaterial, LineSegments, ShaderMaterial, LineDashedMaterial } from "three";
|
|
1
|
+
import { Object3D, ExtrudeGeometry, Mesh, Box3, MeshBasicMaterial, Raycaster, Object3DEventMap, Vector3, BufferGeometry, LineBasicMaterial, LineSegments, ShaderMaterial, LineDashedMaterial } from "three";
|
|
2
2
|
import { GraphicOptions } from "src/types";
|
|
3
3
|
import { Context } from "../context/context";
|
|
4
4
|
export type GraphicOptionsParam = Partial<GraphicOptions>;
|
|
@@ -24,12 +24,37 @@ export declare class Graphic extends Object3D<GraphicEventMap> {
|
|
|
24
24
|
constructor(context: Context, options: GraphicOptionsParam);
|
|
25
25
|
getCenter(): Vector3;
|
|
26
26
|
getSize(): Vector3;
|
|
27
|
+
/**
|
|
28
|
+
* 图元中心位置:多边形返回包围盒中心 + height / 2,也就是顶面中心
|
|
29
|
+
*
|
|
30
|
+
* 注意 center.setZ 是原地修改,center.z 改完之后就已经是顶面高度了,
|
|
31
|
+
* 不能再加一次 height / 2,否则锚点会跑到几何体上方(z = 1.5 * height)。
|
|
32
|
+
*/
|
|
27
33
|
getPosition(): Vector3;
|
|
28
34
|
init(): void;
|
|
29
35
|
initDoor(): void;
|
|
30
36
|
initGeometry(): ExtrudeGeometry;
|
|
31
37
|
initSingleMaterial(): MeshBasicMaterial | MeshBasicMaterial[];
|
|
32
|
-
|
|
38
|
+
/**
|
|
39
|
+
* 几何体本地包围盒(shader 里 position 用的就是这个坐标系)
|
|
40
|
+
*
|
|
41
|
+
* 不能用 Box3.setFromObject(this):它给的是世界坐标包围盒。图元摆到楼层上之后,
|
|
42
|
+
* 端点会带上楼层高度 / airHeight / deltaHeight 的偏移,而 shader 用的是本地 position,
|
|
43
|
+
* 坐标系不一致会让渐变整体平移(偏移量 = dot(Δ, lineVec) / |lineVec|²)。
|
|
44
|
+
*/
|
|
45
|
+
getLocalBox(): Box3;
|
|
46
|
+
/**
|
|
47
|
+
* 沿 direction 取渐变线段的两个端点
|
|
48
|
+
*
|
|
49
|
+
* 线性投影的极值一定落在包围盒角点上,遍历 8 个角点即可。
|
|
50
|
+
* 端点恒在包围盒内、且与 shader 的 position 同坐标系:
|
|
51
|
+
* 不会出现射线求交打空退化成 (0, 0, 0)(t = 0/0 = NaN → 整面纯色),
|
|
52
|
+
* 也不受图元摆放位置、airHeight、deltaHeight 影响。
|
|
53
|
+
*
|
|
54
|
+
* min = 沿 direction 投影较小的一端(shader 里 t = 0 → uColor),
|
|
55
|
+
* max = 投影较大的一端(t = 1 → uGradualColor)。
|
|
56
|
+
*/
|
|
57
|
+
getGradualEndpoints(box: Box3, direction: Vector3): {
|
|
33
58
|
max: Vector3;
|
|
34
59
|
min: Vector3;
|
|
35
60
|
};
|
|
@@ -16,12 +16,17 @@ interface MeshBasicMaterialOptions {
|
|
|
16
16
|
}
|
|
17
17
|
interface ShaderMaterialOptions {
|
|
18
18
|
gradualColor: string[];
|
|
19
|
-
center: Vector3;
|
|
20
|
-
maxValue: number;
|
|
21
19
|
opacity: number;
|
|
22
|
-
|
|
20
|
+
/** 渐变线段的两端,必须是几何体本地坐标系(与 shader 里的 position 同系) */
|
|
23
21
|
max: Vector3;
|
|
24
22
|
min: Vector3;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated 渐变轴只由 min / max 决定,center / maxValue / direction
|
|
25
|
+
* 已不参与渲染,仅为兼容旧调用保留。
|
|
26
|
+
*/
|
|
27
|
+
center?: Vector3;
|
|
28
|
+
maxValue?: number;
|
|
29
|
+
direction?: Vector3;
|
|
25
30
|
}
|
|
26
31
|
interface Line2MaterialMapOptions {
|
|
27
32
|
color: string;
|
|
@@ -45,7 +50,7 @@ export declare class MaterialFactory {
|
|
|
45
50
|
static createLineMaterial({ color, opacity, vertexColors }: LineMaterialOptions): LineBasicMaterial;
|
|
46
51
|
static createMeshStandardMaterial({ color, opacity }: MeshStandardMaterialOptions): MeshStandardMaterial;
|
|
47
52
|
static createMeshBasicMaterial({ color, opacity, vertexColors }: MeshBasicMaterialOptions): MeshBasicMaterial;
|
|
48
|
-
static createShaderMaterial({ gradualColor,
|
|
53
|
+
static createShaderMaterial({ gradualColor, opacity, max, min, }: ShaderMaterialOptions): ShaderMaterial;
|
|
49
54
|
static createLine2MaterialMap({ color, width, dashed, resolution, vertexColors }: Line2MaterialMapOptions): LineMaterial;
|
|
50
55
|
private static lineDashedMaterialMap;
|
|
51
56
|
static createLineDashedMaterial(options: {
|
|
@@ -2,6 +2,8 @@ import { PointGeometry, PolygonGeometry, Door } from "../types";
|
|
|
2
2
|
export declare function transformGraphicData(data: {
|
|
3
3
|
geometry: PolygonGeometry | PointGeometry;
|
|
4
4
|
deltaHeight?: number;
|
|
5
|
+
height?: number;
|
|
6
|
+
airHeight?: number;
|
|
5
7
|
doors?: Door[];
|
|
6
8
|
center?: [number, number];
|
|
7
9
|
center_x?: number;
|
|
@@ -11,3 +13,28 @@ export declare function transformGraphicData(data: {
|
|
|
11
13
|
center_coord_y?: number;
|
|
12
14
|
}[], center: [number, number], baseIndex?: number): void;
|
|
13
15
|
export declare function translatePosToCenter(cds: [number, number], center: [number, number]): [number, number];
|
|
16
|
+
interface DepthLevelItem {
|
|
17
|
+
geometry: PolygonGeometry | PointGeometry;
|
|
18
|
+
height?: number;
|
|
19
|
+
airHeight?: number;
|
|
20
|
+
deltaHeight?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 给「同高度且包围盒相交」的图元分配不同的深度层级,写回 deltaHeight。
|
|
24
|
+
*
|
|
25
|
+
* 原来这里是 `item.deltaHeight = 0.00001 * (baseIndex + i + 1)`,有两个问题:
|
|
26
|
+
* 1. 量级(1e-5)远小于 1 个深度量化步长(≈0.0036),等于没做;
|
|
27
|
+
* 2. 随索引线性累加,图元一多末尾就整体抬起来 —— 要放大到有效量级(step >= 0.004),
|
|
28
|
+
* B1 这种 1530 个图元的楼层末尾会抬 6 个世界单位,超过房间高度(3)。
|
|
29
|
+
*
|
|
30
|
+
* 现在按「高度分组 + 扫描线 + 贪心着色」分层:
|
|
31
|
+
* 1. 先按顶面高度(airHeight + height)分组,只有同高度的图元才可能共面;
|
|
32
|
+
* 2. 组内按 bbox.minX 排序做扫描线,只和 x 区间有交叠的元素比较
|
|
33
|
+
* (B1 实测比较次数从 117 万降到 3.5 万);
|
|
34
|
+
* 3. 用 bbox 相交建图:它是「真实重叠」的超集,只会多要一两层,不会漏;
|
|
35
|
+
* 4. 贪心着色后,互相重叠的图元一定拿到不同层级,深度差 >= 1 个量化步长,不再闪烁。
|
|
36
|
+
*
|
|
37
|
+
* B1 实测:7 层封顶,总抬升 0.056 世界单位,全流程(含 bbox)约 9ms,只在加载时算一次。
|
|
38
|
+
*/
|
|
39
|
+
export declare function assignGraphicDepthLevel(data: DepthLevelItem[], baseIndex?: number): void;
|
|
40
|
+
export {};
|