@labelbee/lb-annotation 1.12.0-alpha.0 → 1.12.0-alpha.10
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/_virtual/filterBoxWorker.js +1 -1
- package/dist/_virtual/highlightWorker.js +1 -1
- package/dist/constant/style.js +1 -1
- package/dist/core/pointCloud/PCDLoader.js +2 -2
- package/dist/core/pointCloud/annotation.js +1 -1
- package/dist/core/pointCloud/cache.js +1 -1
- package/dist/core/pointCloud/index.js +2 -2
- package/dist/core/pointCloud/matrix.js +1 -1
- package/dist/core/toolOperation/pointCloud2dOperation.js +1 -1
- package/dist/core/toolOperation/pointOperation.js +1 -1
- package/dist/core/toolOperation/polygonOperation.js +1 -1
- package/dist/types/constant/style.d.ts +6 -0
- package/dist/types/core/pointCloud/PCDLoader.d.ts +1 -0
- package/dist/types/core/pointCloud/cache.d.ts +11 -1
- package/dist/types/core/pointCloud/index.d.ts +15 -3
- package/dist/types/core/pointCloud/matrix.d.ts +13 -0
- package/dist/types/core/toolOperation/pointCloud2dOperation.d.ts +1 -1
- package/dist/types/core/toolOperation/pointOperation.d.ts +5 -0
- package/dist/types/core/toolOperation/polygonOperation.d.ts +1 -0
- package/dist/types/utils/ActionsHistory.d.ts +1 -1
- package/dist/types/utils/tool/MarkerUtils.d.ts +18 -0
- package/dist/utils/ImgUtils.js +1 -1
- package/dist/utils/tool/MarkerUtils.js +1 -1
- package/es/_virtual/filterBoxWorker.js +1 -1
- package/es/_virtual/highlightWorker.js +1 -1
- package/es/constant/style.js +1 -1
- package/es/core/pointCloud/PCDLoader.js +2 -2
- package/es/core/pointCloud/annotation.js +1 -1
- package/es/core/pointCloud/cache.js +1 -1
- package/es/core/pointCloud/index.js +2 -2
- package/es/core/pointCloud/matrix.js +1 -1
- package/es/core/toolOperation/pointCloud2dOperation.js +1 -1
- package/es/core/toolOperation/pointOperation.js +1 -1
- package/es/core/toolOperation/polygonOperation.js +1 -1
- package/es/utils/ImgUtils.js +1 -1
- package/es/utils/tool/MarkerUtils.js +1 -1
- package/package.json +3 -3
|
@@ -8,9 +8,19 @@ export declare class PointCloudCache {
|
|
|
8
8
|
pcdLoader: PCDLoader;
|
|
9
9
|
MAX_SIZE: number;
|
|
10
10
|
private pointsMap;
|
|
11
|
+
private colorMap;
|
|
11
12
|
private cacheList;
|
|
12
13
|
private static instance;
|
|
13
14
|
private constructor();
|
|
14
15
|
static getInstance(): PointCloudCache;
|
|
15
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Directly update the color of PointCloud
|
|
18
|
+
* @param src
|
|
19
|
+
* @param color
|
|
20
|
+
*/
|
|
21
|
+
updateColor(src: string, color: Float32Array): void;
|
|
22
|
+
loadPCDFile: (src: string) => Promise<{
|
|
23
|
+
points: Float32Array;
|
|
24
|
+
color: Float32Array;
|
|
25
|
+
}>;
|
|
16
26
|
}
|
|
@@ -47,6 +47,13 @@ export declare class PointCloud {
|
|
|
47
47
|
private rangeObjectName;
|
|
48
48
|
private cacheInstance;
|
|
49
49
|
private showDirection;
|
|
50
|
+
private currentPCDSrc?;
|
|
51
|
+
/**
|
|
52
|
+
* Record the src of Highlight PCD.
|
|
53
|
+
*
|
|
54
|
+
* Avoiding src error problems caused by asynchronous
|
|
55
|
+
*/
|
|
56
|
+
private highlightPCDSrc?;
|
|
50
57
|
constructor({ container, noAppend, isOrthographicCamera, orthographicParams, backgroundColor, config, }: IProps);
|
|
51
58
|
get DEFAULT_INIT_CAMERA_POSITION(): THREE.Vector3;
|
|
52
59
|
get containerWidth(): number;
|
|
@@ -76,6 +83,9 @@ export declare class PointCloud {
|
|
|
76
83
|
* @param color
|
|
77
84
|
*/
|
|
78
85
|
generateBox(boxParams: IPointCloudBox, color?: number): void;
|
|
86
|
+
getAllAttributeColor(boxes: IPointCloudBox[]): {
|
|
87
|
+
[k: string]: any;
|
|
88
|
+
};
|
|
79
89
|
AddBoxToSense: (boxParams: IPointCloudBox, color?: number) => void;
|
|
80
90
|
generateBoxes(boxes: IPointCloudBox[]): void;
|
|
81
91
|
/**
|
|
@@ -92,6 +102,7 @@ export declare class PointCloud {
|
|
|
92
102
|
far: number;
|
|
93
103
|
zoom: number;
|
|
94
104
|
};
|
|
105
|
+
updateCameraZoom(zoom: number): void;
|
|
95
106
|
/**
|
|
96
107
|
* Update Camera position & target
|
|
97
108
|
* @param boxParams
|
|
@@ -123,7 +134,7 @@ export declare class PointCloud {
|
|
|
123
134
|
* @param color
|
|
124
135
|
* @returns
|
|
125
136
|
*/
|
|
126
|
-
filterPointsByBox(boxParams: IPointCloudBox, points?:
|
|
137
|
+
filterPointsByBox(boxParams: IPointCloudBox, points?: Float32Array, color?: Float32Array): Promise<{
|
|
127
138
|
geometry: any;
|
|
128
139
|
num: number;
|
|
129
140
|
} | undefined>;
|
|
@@ -140,11 +151,12 @@ export declare class PointCloud {
|
|
|
140
151
|
*/
|
|
141
152
|
loadPCDFile: (src: string, radius?: number) => Promise<void>;
|
|
142
153
|
/**
|
|
143
|
-
* It needs to be updated after load
|
|
154
|
+
* It needs to be updated after load PointCloud's data.
|
|
144
155
|
* @param boxParams
|
|
145
156
|
* @returns
|
|
146
157
|
*/
|
|
147
|
-
highlightOriginPointCloud(
|
|
158
|
+
highlightOriginPointCloud(pointCloudBoxList?: IPointCloudBox[]): Promise<THREE.BufferAttribute[] | undefined> | undefined;
|
|
159
|
+
updateColor(color: any[]): void;
|
|
148
160
|
/**
|
|
149
161
|
* Load PCD File by box
|
|
150
162
|
* @param src
|
|
@@ -34,6 +34,19 @@ export declare function getCuboidFromPointCloudBox(boxParams: IPointCloudBox): {
|
|
|
34
34
|
}[];
|
|
35
35
|
zMax: number;
|
|
36
36
|
zMin: number;
|
|
37
|
+
attribute: string;
|
|
38
|
+
center: I3DSpaceCoord;
|
|
39
|
+
id: string;
|
|
40
|
+
rotation: number;
|
|
41
|
+
valid: boolean;
|
|
42
|
+
trackID?: number | undefined;
|
|
43
|
+
subAttribute?: {
|
|
44
|
+
[k: string]: string;
|
|
45
|
+
} | undefined;
|
|
46
|
+
count?: number | undefined;
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
depth: number;
|
|
37
50
|
};
|
|
38
51
|
export declare function pointCloudLidar2image(boxParams: IPointCloudBox, cameraMatrix: {
|
|
39
52
|
P: [TMatrix14Tuple, TMatrix14Tuple, TMatrix14Tuple];
|
|
@@ -50,7 +50,7 @@ declare class PointCloud2dOperation extends PolygonOperation {
|
|
|
50
50
|
onKeyUp: () => void;
|
|
51
51
|
getLineColor(): string;
|
|
52
52
|
/** 获取当前属性颜色 */
|
|
53
|
-
getPointCloudLineColor(
|
|
53
|
+
getPointCloudLineColor(polygon: IPolygonData): string;
|
|
54
54
|
/**
|
|
55
55
|
* Add direction
|
|
56
56
|
* @override
|
|
@@ -116,6 +116,11 @@ declare class PointOperation extends BasicToolOperation {
|
|
|
116
116
|
renderPoint(point: IPointUnit, isSelected?: boolean): void;
|
|
117
117
|
renderMultiSelectedPoint(): void;
|
|
118
118
|
renderPointList(): void;
|
|
119
|
+
/**
|
|
120
|
+
* render auxiliaryLine - markerConfigurable should be true
|
|
121
|
+
* 渲染辅助线-需开启列表标注
|
|
122
|
+
*/
|
|
123
|
+
renderAuxiliaryLine(): void;
|
|
119
124
|
/**
|
|
120
125
|
* 顶层渲染图标
|
|
121
126
|
*/
|
|
@@ -139,6 +139,7 @@ declare class PolygonOperation extends BasicToolOperation {
|
|
|
139
139
|
isPolygonOutSide(selectedPointList: IPolygonPoint[]): boolean;
|
|
140
140
|
onDragMove(e: MouseEvent): void;
|
|
141
141
|
onMouseMove(e: MouseEvent): void;
|
|
142
|
+
leftMouseUpdateValid(e: MouseEvent): boolean;
|
|
142
143
|
leftMouseUp(e: MouseEvent): void;
|
|
143
144
|
onMouseUp(e: MouseEvent): undefined;
|
|
144
145
|
dragMouseUp(): void;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
declare interface IAuxiliaryLine {
|
|
2
|
+
start: IPointUnit['label'];
|
|
3
|
+
end: IPointUnit['label'];
|
|
4
|
+
}
|
|
5
|
+
declare interface IAuxiliaryLineCoord {
|
|
6
|
+
start: ICoordinate;
|
|
7
|
+
end: ICoordinate;
|
|
8
|
+
}
|
|
1
9
|
export default class MarkerUtils {
|
|
2
10
|
/**
|
|
3
11
|
* 获取列表标注的显示的数据
|
|
@@ -6,4 +14,14 @@ export default class MarkerUtils {
|
|
|
6
14
|
* @returns
|
|
7
15
|
*/
|
|
8
16
|
static getMarkerShowText(marker: string | undefined, markerList?: IInputList[]): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* v3.2.0 仅标点工具 列表标注 根据配置生成辅助线数组,start和end为IMarkerList[attr]
|
|
19
|
+
* eg:[{key:"类别1",value:"类别1",target:["class-lm"]},{key:"类别lm",value:"class-lm",target:["类别1"]}] => [{start:"类别1",end:"类别lm"}]
|
|
20
|
+
*/
|
|
21
|
+
static getAuxiliaryLineByMarkerList: (markerList: IMarkerList[], attr: 'key' | 'value') => IAuxiliaryLine[];
|
|
22
|
+
/**
|
|
23
|
+
* 根据辅助线和点数据生成辅助线首尾坐标
|
|
24
|
+
*/
|
|
25
|
+
static getAuxiliaryLineCoord: (auxiliaryLines: IAuxiliaryLine[], pointList: IPointUnit[]) => IAuxiliaryLineCoord[];
|
|
9
26
|
}
|
|
27
|
+
export {};
|
package/dist/utils/ImgUtils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";class ImgUtils{static load(s){return new Promise((o,
|
|
1
|
+
"use strict";class ImgUtils{static load(s){return new Promise((o,r)=>{const e=new Image;e.crossOrigin="anonymous",s.startsWith("file")?e.src=encodeURI(s):e.src=s,e.onload=()=>{o(e)},e.onerror=()=>{r(e)}})}}module.exports=ImgUtils;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var AttributeUtils=require("./AttributeUtils.js");class MarkerUtils{static getMarkerShowText(t,
|
|
1
|
+
"use strict";var _=require("lodash"),AttributeUtils=require("./AttributeUtils.js");class MarkerUtils{static getMarkerShowText(t,r=[]){return AttributeUtils.default.getAttributeShowText(t,r)}}MarkerUtils.getAuxiliaryLineByMarkerList=(u,t)=>{var r;const s=_.cloneDeep(u),l=[];let e=s.shift();for(;e;)(r=e.target)==null||r.forEach(a=>{const i=s.find(n=>n.value===a);i&&(e==null?void 0:e[t])&&l.push({start:e[t],end:i[t]})}),e=s.shift();return l},MarkerUtils.getAuxiliaryLineCoord=(u,t)=>{const r=[];return u.forEach(s=>{const{start:l,end:e}=s,a=t.find(n=>n.label===l);if(!a)return;const i=t.find(n=>n.label===e);!i||r.push({start:{x:a.x,y:a.y},end:{x:i.x,y:i.y}})}),r},module.exports=MarkerUtils;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createBase64WorkerFactory as
|
|
1
|
+
import{createBase64WorkerFactory as d}from"./_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js";var b=d("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24oeCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIE0odCl7Y29uc3QgZT0tNyxzPTMsZj1zLWU7cmV0dXJuIHQ8ZSYmKHQ9ZSksdD5zJiYodD1zKSxNYXRoLmZsb29yKCh0LWUpL2YqMjU1KX1mdW5jdGlvbiBtKCl7bGV0IHQ7Y29uc3QgZT1uZXcgQXJyYXkoMjU2KS5maWxsKCIiKS5tYXAoKCk9Pm5ldyBBcnJheSgzKS5maWxsKCIiKSk7Zm9yKGxldCBzPTA7czwyMDtzKyspe2Zvcih0PTA7dDwzMjt0KyspZVt0XVswXT0xMjgrNCp0LGVbdF1bMV09MCxlW3RdWzJdPTA7Zm9yKGVbMzJdWzBdPTI1NSxlWzMyXVsxXT0wLGVbMzJdWzJdPTAsdD0wO3Q8NjM7dCsrKWVbMzMrdF1bMF09MjU1LGVbMzMrdF1bMV09NCs0KnQsZVszMyt0XVsyXT0wO2ZvcihlWzk2XVswXT0yNTQsZVs5Nl1bMV09MjU1LGVbOTZdWzJdPTIsdD0wO3Q8NjI7dCsrKWVbOTcrdF1bMF09MjUwLTQqdCxlWzk3K3RdWzFdPTI1NSxlWzk3K3RdWzJdPTYrNCp0O2ZvcihlWzE1OV1bMF09MSxlWzE1OV1bMV09MjU1LGVbMTU5XVsyXT0yNTQsdD0wO3Q8NjQ7dCsrKWVbMTYwK3RdWzBdPTAsZVsxNjArdF1bMV09MjUyLXQqNCxlWzE2MCt0XVsyXT0yNTU7Zm9yKHQ9MDt0PDMyO3QrKyllWzIyNCt0XVswXT0wLGVbMjI0K3RdWzFdPTAsZVsyMjQrdF1bMl09MjUyLTQqdH1yZXR1cm4gZX1jb25zdCBkPW0oKTtmdW5jdGlvbiBoKHQsZSxzPTApe2xldCBmPTAsbCx1LG4sbztlPVsuLi5lXSxzPT09MSYmKGU9Y3JlYXRlU21vb3RoQ3VydmVQb2ludHMoZS5yZWR1Y2UoKGEscik9PlsuLi5hLHIueCxyLnldLFtdKSwuNSwhMCxTRUdNRU5UX05VTUJFUikpLFtuXT1lO2NvbnN0IGk9ZS5sZW5ndGg7Zm9yKGw9MTtsPD1pO2wrKylvPWVbbCVpXSx0Lng+TWF0aC5taW4obi54LG8ueCkmJnQueDw9TWF0aC5tYXgobi54LG8ueCkmJnQueTw9TWF0aC5tYXgobi55LG8ueSkmJm4ueCE9PW8ueCYmKHU9KHQueC1uLngpKihvLnktbi55KS8oby54LW4ueCkrbi55LChuLnk9PT1vLnl8fHQueTw9dSkmJmYrKyksbj1vO3JldHVybiBmJTIhPTB9cmV0dXJuIG9ubWVzc2FnZT1mdW5jdGlvbihlKXtjb25zdHt6TWluOnMsek1heDpmLHBvbHlnb25Qb2ludExpc3Q6bCxwb3NpdGlvbjp1LGNvbG9yOm59PWUuZGF0YSxvPVtdLGk9W107bGV0IGE9MDtmb3IobGV0IHI9MDtyPHUubGVuZ3RoO3IrPTMpe2NvbnN0IHA9dVtyXSx5PXVbcisxXSxjPXVbcisyXTtpZihoKHt4OnAseX0sbCkmJmM+PXMmJmM8PWYpe2lmKG8ucHVzaChwKSxvLnB1c2goeSksby5wdXNoKGMpLG4ubGVuZ3RoPT09MCl7Y29uc3QgZz1NKGMpLHc9ZFtnXSxbQyxfLEVdPXc7aS5wdXNoKEMvMjU1KSxpLnB1c2goXy8yNTUpLGkucHVzaChFLzI1NSl9ZWxzZSBpLnB1c2gobltyXSksaS5wdXNoKG5bcisxXSksaS5wdXNoKG5bcisyXSk7YSsrfX10aGlzLnBvc3RNZXNzYWdlKHtwb3NpdGlvbjpvLGNvbG9yOmksbnVtOmF9KX0seC5pc0luUG9seWdvbj1oLE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh4LCJfX2VzTW9kdWxlIix7dmFsdWU6ITB9KSx4fSh7fSk7Cgo=",null,!1);export{b as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createBase64WorkerFactory as
|
|
1
|
+
import{createBase64WorkerFactory as d}from"./_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js";var s=d("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24oeCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIGcodCl7Y29uc3QgZT0tNyxvPTMsaT1vLWU7cmV0dXJuIHQ8ZSYmKHQ9ZSksdD5vJiYodD1vKSxNYXRoLmZsb29yKCh0LWUpL2kqMjU1KX1mdW5jdGlvbiBwKCl7bGV0IHQ7Y29uc3QgZT1uZXcgQXJyYXkoMjU2KS5maWxsKCIiKS5tYXAoKCk9Pm5ldyBBcnJheSgzKS5maWxsKCIiKSk7Zm9yKGxldCBvPTA7bzwyMDtvKyspe2Zvcih0PTA7dDwzMjt0KyspZVt0XVswXT0xMjgrNCp0LGVbdF1bMV09MCxlW3RdWzJdPTA7Zm9yKGVbMzJdWzBdPTI1NSxlWzMyXVsxXT0wLGVbMzJdWzJdPTAsdD0wO3Q8NjM7dCsrKWVbMzMrdF1bMF09MjU1LGVbMzMrdF1bMV09NCs0KnQsZVszMyt0XVsyXT0wO2ZvcihlWzk2XVswXT0yNTQsZVs5Nl1bMV09MjU1LGVbOTZdWzJdPTIsdD0wO3Q8NjI7dCsrKWVbOTcrdF1bMF09MjUwLTQqdCxlWzk3K3RdWzFdPTI1NSxlWzk3K3RdWzJdPTYrNCp0O2ZvcihlWzE1OV1bMF09MSxlWzE1OV1bMV09MjU1LGVbMTU5XVsyXT0yNTQsdD0wO3Q8NjQ7dCsrKWVbMTYwK3RdWzBdPTAsZVsxNjArdF1bMV09MjUyLXQqNCxlWzE2MCt0XVsyXT0yNTU7Zm9yKHQ9MDt0PDMyO3QrKyllWzIyNCt0XVswXT0wLGVbMjI0K3RdWzFdPTAsZVsyMjQrdF1bMl09MjUyLTQqdH1yZXR1cm4gZX1jb25zdCBDPXAoKTtmdW5jdGlvbiBtKHQsZSxvPTApe2xldCBpPTAscyxhLHIsbjtlPVsuLi5lXSxvPT09MSYmKGU9Y3JlYXRlU21vb3RoQ3VydmVQb2ludHMoZS5yZWR1Y2UoKGMsbCk9PlsuLi5jLGwueCxsLnldLFtdKSwuNSwhMCxTRUdNRU5UX05VTUJFUikpLFtyXT1lO2NvbnN0IHU9ZS5sZW5ndGg7Zm9yKHM9MTtzPD11O3MrKyluPWVbcyV1XSx0Lng+TWF0aC5taW4oci54LG4ueCkmJnQueDw9TWF0aC5tYXgoci54LG4ueCkmJnQueTw9TWF0aC5tYXgoci55LG4ueSkmJnIueCE9PW4ueCYmKGE9KHQueC1yLngpKihuLnktci55KS8obi54LXIueCkrci55LChyLnk9PT1uLnl8fHQueTw9YSkmJmkrKykscj1uO3JldHVybiBpJTIhPTB9ZnVuY3Rpb24gYih7ek1pbjp0LHpNYXg6ZSxwb2x5Z29uUG9pbnRMaXN0Om8sYXR0cmlidXRlOmkseDpzLHk6YSx6OnIsY29sb3JMaXN0Om4sdmFsaWQ6dX0pe2lmKG0oe3g6cyx5OmF9LG8pJiZyPj10JiZyPD1lKXJldHVybiB1PT09ITE/WzEsMTAzLzI1NSwxMDIvMjU1XTpuW2ldP25baV0ucmdiYS5zbGljZSgwLDMpLm1hcChsPT5sLzI1NSk6WzEsMCwwXX1yZXR1cm4gb25tZXNzYWdlPWZ1bmN0aW9uKGUpe2NvbnN0e3Bvc2l0aW9uOm8sY29sb3I6aSxjdWJvaWRMaXN0OnMsY29sb3JMaXN0OmF9PWUuZGF0YTtsZXQgcj0wO2ZvcihsZXQgbj0wO248by5sZW5ndGg7bis9Myl7Y29uc3QgdT1vW25dLGM9b1tuKzFdLGw9b1tuKzJdLGQ9cy5tYXAoZj0+Yih7cG9seWdvblBvaW50TGlzdDpmLnBvbHlnb25Qb2ludExpc3Qsek1pbjpmLnpNaW4sek1heDpmLnpNYXgseDp1LHk6Yyx6OmwsYXR0cmlidXRlOmYuYXR0cmlidXRlLGNvbG9yTGlzdDphLHZhbGlkOmYudmFsaWR9KSkuZmlsdGVyKGY9PmYpLnBvcCgpO2lmKGQpe3IrKztjb25zdFtmLHksTV09ZDtpW25dPWYsaVtuKzFdPXksaVtuKzJdPU19ZWxzZXtjb25zdCBmPWcobCkseT1DW2ZdLFtNLHcsX109eTtpW25dPU0vMjU1LGlbbisxXT13LzI1NSxpW24rMl09Xy8yNTV9fXBvc3RNZXNzYWdlKHtwb2ludHM6byxjb2xvcjppLG51bTpyfSl9LHguaXNJblBvbHlnb249bSxPYmplY3QuZGVmaW5lUHJvcGVydHkoeCwiX19lc01vZHVsZSIse3ZhbHVlOiEwfSkseH0oe30pOwoK",null,!1);export{s as default};
|
package/es/constant/style.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import a from"../assets/attributeIcon/icon_canvasEdit0.svg.js";import i from"../assets/attributeIcon/icon_canvasEdit1.svg.js";import l from"../assets/attributeIcon/icon_canvasEdit2.svg.js";import t from"../assets/attributeIcon/icon_canvasEdit3.svg.js";import e from"../assets/attributeIcon/icon_canvasEdit4.svg.js";import b from"../assets/attributeIcon/icon_canvasEdit5.svg.js";import g from"../assets/attributeIcon/icon_canvasEdit6.svg.js";import o from"../assets/attributeIcon/icon_canvasEdit7.svg.js";import s from"../assets/attributeIcon/icon_canvasEdit8.svg.js";import v from"../assets/attributeIcon/icon_editLAN.svg.js";import d from"../assets/attributeIcon/icon_editQING.svg.js";import n from"../assets/attributeIcon/icon_editLV.svg.js";import c from"../assets/attributeIcon/icon_editHUANG.svg.js";import f from"../assets/attributeIcon/icon_editFEN.svg.js";import{EFilterToolOperation as r}from"./tool.js";export{default as INVALID_ICON}from"../assets/attributeIcon/icon_canvasEdit_miss.svg.js";const k=a,H=61,E=80,I=62,_=20,S=55,m=55,O=40,
|
|
1
|
+
import a from"../assets/attributeIcon/icon_canvasEdit0.svg.js";import i from"../assets/attributeIcon/icon_canvasEdit1.svg.js";import l from"../assets/attributeIcon/icon_canvasEdit2.svg.js";import t from"../assets/attributeIcon/icon_canvasEdit3.svg.js";import e from"../assets/attributeIcon/icon_canvasEdit4.svg.js";import b from"../assets/attributeIcon/icon_canvasEdit5.svg.js";import g from"../assets/attributeIcon/icon_canvasEdit6.svg.js";import o from"../assets/attributeIcon/icon_canvasEdit7.svg.js";import s from"../assets/attributeIcon/icon_canvasEdit8.svg.js";import v from"../assets/attributeIcon/icon_editLAN.svg.js";import d from"../assets/attributeIcon/icon_editQING.svg.js";import n from"../assets/attributeIcon/icon_editLV.svg.js";import c from"../assets/attributeIcon/icon_editHUANG.svg.js";import f from"../assets/attributeIcon/icon_editFEN.svg.js";import{EFilterToolOperation as r}from"./tool.js";export{default as INVALID_ICON}from"../assets/attributeIcon/icon_canvasEdit_miss.svg.js";const k=a,H=61,E=80,I=62,_=20,S=55,m=55,O=40,L=80,p=240,T=320,u="rgba(102, 111, 255, 1)",A=["rgba(128, 12, 249, 1)","rgba(0, 255, 48, 1)","rgba(255, 136, 247, 1)","rgba(255, 226, 50, 1)","rgba(153, 66, 23, 1)","rgba(2, 130, 250, 1)","rgba(255, 35, 35, 1)","rgba(0, 255, 234, 1)"],R=[a,g,t,o,l,s,b,i,e],j={1:v,3:d,5:n,7:c,9:f},N="rgba(255, 51, 51, 1)",C={r:255,g:51,b:51,a:1},G="rgba(204, 204, 204, 1)",D={[r.lc]:"rgba(153, 51, 255, 1)",[r.rc]:"rgba(51, 153, 255, 1)",[r.clc]:"rgba(46, 230, 46, 1)",[r.crc]:"rgba(255, 51, 51, 1)"},B='{"color":1,"width":2,"borderOpacity":9,"fillOpacity":9,"toolColor":{"1":{"valid":{"stroke":"rgba(0,0,255,0.50)","fill":"rgba(0,0,255,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(0,15,255,1.00)","fill":"rgba(0,15,255,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(0,15,255,0.80)","fill":"rgba(0,15,255,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"3":{"valid":{"stroke":"rgba(0,255,255,0.50)","fill":"rgba(0,255,255,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(0,212,255,1.00)","fill":"rgba(0,212,255,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(0,212,255,0.80)","fill":"rgba(0,212,255,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"5":{"valid":{"stroke":"rgba(0,255,0,0.50)","fill":"rgba(0,255,0,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(149,255,1.00)","fill":"rgba(149,255,0,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(149,255,0,0.80)","fill":"rgba(149,255,0,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"7":{"valid":{"stroke":"rgba(255,255,0,0.50)","fill":"rgba(255,255,0,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(255,230,102,1.00)","fill":"rgba(255,213,0,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(255,230,102,0.80)","fill":"rgba(255,230,102,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"9":{"valid":{"stroke":"rgba(255,0,255,0.50)","fill":"rgba(255,0,255,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(230,102,255,1.00)","fill":"rgba(213,0,255,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(230,102,255,0.80)","fill":"rgba(230,102,255,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}}},"attributeColor":[{"valid":{"stroke":"rgba(204,204,204,1.00)","fill":"rgba(204,204,204,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(204,204,204,1.00)","fill":"rgba(204,204,204,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(204,204,204,1.00)","fill":"rgba(204,204,204,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(128,12,249,1.00)","fill":"rgba(128,12,249,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(128,12,249,1.00)","fill":"rgba(128,12,249,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(128,12,249,1.00)","fill":"rgba(128,12,249,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(0,255,48,1.00)","fill":"rgba(0,255,48,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(0,255,48,1.00)","fill":"rgba(0,255,48,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(0,255,48,1.00)","fill":"rgba(0,255,48,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(255,136,247,1.00)","fill":"rgba(255,136,247,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(255,136,247,1.00)","fill":"rgba(255,136,247,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(255,136,247,1.00)","fill":"rgba(255,136,247,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(255,226,50,1.00)","fill":"rgba(255,226,50,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(255,226,50,1.00)","fill":"rgba(255,226,50,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(255,226,50,1.00)","fill":"rgba(255,226,50,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(153,66,23,1.00)","fill":"rgba(153,66,23,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(153,66,23,1.00)","fill":"rgba(153,66,23,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(153,66,23,1.00)","fill":"rgba(153,66,23,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(2,130,250,1.00)","fill":"rgba(2,130,250,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(2,130,250,1.00)","fill":"rgba(2,130,250,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(2,130,250,1.00)","fill":"rgba(2,130,250,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(255,35,35,1.00)","fill":"rgba(255,35,35,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(255,35,35,1.00)","fill":"rgba(255,35,35,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(255,35,35,1.00)","fill":"rgba(255,35,35,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(0,255,234,1.00)","fill":"rgba(0,255,234,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(0,255,234,1.00)","fill":"rgba(0,255,234,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(0,255,234,1.00)","fill":"rgba(0,255,234,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}}],"lineColor":{"1":"rgba(102, 111, 255, 1 )","3":"rgba(102, 230, 255, 1)","5":"rgba(191, 255, 102, 1)","7":"rgba(255, 230, 102, 1)","9":"rgba(230, 102, 255, 1)"},"attributeLineColor":["rgba(204, 204, 204, 1)","rgba(128, 12, 249, 1)","rgba(0, 255, 48, 1)","rgba(255, 136, 247, 1)","rgba(255, 226, 50, 1)","rgba(153, 66, 23, 1)","rgba(2, 130, 250, 1)","rgba(255, 35, 35, 1)","rgba(0, 255, 234, 1)"]}';export{j as BASE_ICON,A as COLORS_ARRAY,T as EDIT_STEP_WIDTH,D as FILTER_TOOL_COLOR,L as FOOTER_HEIGHT,H as HEADER_HEIGHT,R as ICON_ARRAY,N as INVALID_COLOR,C as INVALID_COLOR_RGBA,G as NULL_COLOR,k as NULL_ICON,_ as PADDING,m as PAGINATION_HEIGHT,I as SEARCH_HEIGHT,p as SIDERBAR_WIDTH,S as TABLE_ROW_HEIGHT,E as TAB_HEIGHT,u as THEME_COLOR,O as TIPS_HEIGHT,B as styleString};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Loader as z,FileLoader as C,LoaderUtils as
|
|
2
|
-
`);for(let n=0,r=
|
|
1
|
+
import{Loader as z,FileLoader as C,LoaderUtils as v,BufferGeometry as _,Float32BufferAttribute as F,PointsMaterial as b,Points as L}from"three";import{COLOR_MAP_JET as B}from"@labelbee/lb-utils";class I extends z{constructor(a){super(a);this.littleEndian=!0}load(a,c,h,g){const i=this,l=new C(i.manager);l.setPath(i.path),l.setResponseType("arraybuffer"),l.setRequestHeader(i.requestHeader),l.setWithCredentials(i.withCredentials),l.load(a,function(d){try{c(i.parse(d))}catch(f){g?g(f):console.error(f),i.manager.itemError(a)}},h,g)}parse(a){function c(o,t){const p=o.length,n=new Uint8Array(t);let r=0,e=0,s,w,u;do if(s=o[r++],s<1<<5){if(s++,e+s>t)throw new Error("Output buffer is not large enough");if(r+s>p)throw new Error("Invalid compressed data");do n[e++]=o[r++];while(--s)}else{if(w=s>>5,u=e-((s&31)<<8)-1,r>=p)throw new Error("Invalid compressed data");if(w===7&&(w+=o[r++],r>=p))throw new Error("Invalid compressed data");if(u-=o[r++],e+w+2>t)throw new Error("Output buffer is not large enough");if(u<0)throw new Error("Invalid compressed data");if(u>=e)throw new Error("Invalid compressed data");do n[e++]=n[u++];while(--w+2)}while(r<p);return n}function h(o){const t={},p=o.search(/[\n\r]data\s(\S*)\s/i),n=/[\n\r]data\s(\S*)\s/i.exec(o.slice(p-1));if(t.data=n[1],t.headerLen=n[0].length+p,t.str=o.slice(0,t.headerLen),t.str=t.str.replace(/#.*/gi,""),t.version=/version (.*)/i.exec(t.str),t.fields=/fields (.*)/i.exec(t.str),t.size=/size (.*)/i.exec(t.str),t.type=/type (.*)/i.exec(t.str),t.count=/count (.*)/i.exec(t.str),t.width=/width (.*)/i.exec(t.str),t.height=/height (.*)/i.exec(t.str),t.viewpoint=/viewpoint (.*)/i.exec(t.str),t.points=/points (.*)/i.exec(t.str),t.version!==null&&(t.version=parseFloat(t.version[1])),t.fields=t.fields!==null?t.fields[1].split(" "):[],t.type!==null&&(t.type=t.type[1].split(" ")),t.width!==null&&(t.width=parseInt(t.width[1])),t.height!==null&&(t.height=parseInt(t.height[1])),t.viewpoint!==null&&(t.viewpoint=t.viewpoint[1]),t.points!==null&&(t.points=parseInt(t.points[1],10)),t.points===null&&(t.points=t.width*t.height),t.size!==null&&(t.size=t.size[1].split(" ").map(function(e){return parseInt(e,10)})),t.count!==null)t.count=t.count[1].split(" ").map(function(e){return parseInt(e,10)});else{t.count=[];for(let e=0,s=t.fields.length;e<s;e++)t.count.push(1)}t.offset={};let r=0;for(let e=0,s=t.fields.length;e<s;e++)t.data==="ascii"?t.offset[t.fields[e]]=e:(t.offset[t.fields[e]]=r,r+=t.size[e]*t.count[e]);return t.rowSize=r,t}const g=v.decodeText(new Uint8Array(a)),i=h(g),l=[],d=[],f=[];if(i.data==="ascii"){const{offset:o}=i,p=g.slice(i.headerLen).split(`
|
|
2
|
+
`);for(let n=0,r=p.length;n<r;n++){if(p[n]==="")continue;const e=p[n].split(" ");if(o.x!==void 0&&(l.push(parseFloat(e[o.x])),l.push(parseFloat(e[o.y])),l.push(parseFloat(e[o.z]))),this.genColorByZ){const w=this.genColorByZ(parseFloat(e[o.x]),parseFloat(e[o.y]),parseFloat(e[o.z])).map(u=>u/255);f.push(...w)}o.normal_x!==void 0&&(d.push(parseFloat(e[o.normal_x])),d.push(parseFloat(e[o.normal_y])),d.push(parseFloat(e[o.normal_z])))}}if(i.data==="binary_compressed"){const o=new Uint32Array(a.slice(i.headerLen,i.headerLen+8)),t=o[0],p=o[1],n=c(new Uint8Array(a,i.headerLen+8,t),p),r=new DataView(n.buffer),{offset:e}=i;for(let s=0;s<i.points;s++)if(e.x!==void 0&&(l.push(r.getFloat32(i.points*e.x+i.size[0]*s,this.littleEndian)),l.push(r.getFloat32(i.points*e.y+i.size[1]*s,this.littleEndian)),l.push(r.getFloat32(i.points*e.z+i.size[2]*s,this.littleEndian))),e.normal_x!==void 0&&(d.push(r.getFloat32(i.points*e.normal_x+i.size[4]*s,this.littleEndian)),d.push(r.getFloat32(i.points*e.normal_y+i.size[5]*s,this.littleEndian)),d.push(r.getFloat32(i.points*e.normal_z+i.size[6]*s,this.littleEndian))),this.genColorByZ){const u=this.genColorByZ(r.getFloat32(i.points*e.x+i.size[0]*s,this.littleEndian),r.getFloat32(i.points*e.y+i.size[0]*s,this.littleEndian),r.getFloat32(i.points*e.z+i.size[0]*s,this.littleEndian)).map(E=>E/255);f.push(...u)}}if(i.data==="binary"){const o=new DataView(a,i.headerLen),{offset:t}=i;for(let p=0,n=0;p<i.points;p++,n+=i.rowSize)if(t.x!==void 0&&(l.push(o.getFloat32(n+t.x,this.littleEndian)),l.push(o.getFloat32(n+t.y,this.littleEndian)),l.push(o.getFloat32(n+t.z,this.littleEndian))),t.normal_x!==void 0&&(d.push(o.getFloat32(n+t.normal_x,this.littleEndian)),d.push(o.getFloat32(n+t.normal_y,this.littleEndian)),d.push(o.getFloat32(n+t.normal_z,this.littleEndian))),this.genColorByZ){const e=this.genColorByZ(o.getFloat32(n+t.x,this.littleEndian),o.getFloat32(n+t.y,this.littleEndian),o.getFloat32(n+t.z,this.littleEndian)).map(s=>s/255);f.push(...e)}}const x=new _;l.length>0&&x.setAttribute("position",new F(l,3)),d.length>0&&x.setAttribute("normal",new F(d,3)),f.length>0&&x.setAttribute("color",new F(f,3)),x.computeBoundingSphere();const y=new b({size:.01});return f.length>0?y.vertexColors=!0:y.color.setHex(16777215),new L(x,y)}genColorByCoord(a,c,h){return h<=0?[128,128,128]:h<5?[255,0,0]:h<10?[0,255,0]:[0,0,255]}genColorByZ(a,c,h){const g=Z(h),i=B[g];return[i[0],i[1],i[2]]}}function Z(m){const a=-7,c=3,h=c-a;return m<a&&(m=a),m>c&&(m=c),Math.floor((m-a)/h*255)}export{I as PCDLoader};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PointCloudUtils as
|
|
1
|
+
import{PointCloudUtils as u}from"@labelbee/lb-utils";import{EPolygonPattern as I}from"../../constant/tool.js";import{CanvasScheduler as D}from"../../newCore/CanvasScheduler.js";import{PointCloud as L}from"./index.js";import S from"../toolOperation/pointCloud2dOperation.js";var b=Object.defineProperty,R=Object.defineProperties,j=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,A=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable,O=(e,t,o)=>t in e?b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,x=(e,t)=>{for(var o in t||(t={}))A.call(t,o)&&O(e,o,t[o]);if(f)for(var o of f(t))E.call(t,o)&&O(e,o,t[o]);return e},N=(e,t)=>R(e,j(t));const P=e=>{const t=document.createElement("canvas");t.width=e.width,t.height=e.height;const o=t.getContext("2d");return o?(o.fillStyle="black",o.fillRect(0,0,e.width,e.height),t.toDataURL()):""};class T{constructor({size:t,container:o,pcdPath:n,polygonOperationProps:c,config:h,checkMode:v}){this.updatePolygonList=(_,m)=>{let d=_.map(i=>{var r;const{polygon2d:p}=this.pointCloudInstance.getBoxTopPolygon2DCoordinate(i);return{id:i.id,sourceID:"",pointList:p,isRect:!0,valid:(r=i.valid)!=null?r:!0,attribute:i.attribute}});m&&(d=d.concat(m.map(i=>{var r;return N(x({},i),{pointList:(r=i==null?void 0:i.pointList)==null?void 0:r.map(p=>u.transferWorld2Canvas(p,this.pointCloud2dOperation.size))})}))),this.pointCloud2dOperation.setResult(d)};const y=this.getDefaultOrthographic(t),w=P(t),g=new Image;g.src=w;const s=new D({container:o}),l=new L({container:o,noAppend:!0,isOrthographicCamera:!0,orthographicParams:y});n&&l.loadPCDFile(n),s.createCanvas(l.renderer.domElement);const C={container:o,size:t,config:JSON.stringify(h),imgNode:g,isAppend:!1,checkMode:v};c&&Object.assign(C,c);const a=new S(C);a.eventBinding(),a.setPattern(I.Rect),s.createCanvas(a.canvas,{size:t}),this.pointCloud2dOperation=a,this.pointCloudInstance=l,this.canvasScheduler=s,this.config=h}updateConfig(t){this.config=t,this.pointCloud2dOperation.setConfig(JSON.stringify(t))}getDefaultOrthographic(t){return{left:-t.width/2,right:t.width/2,top:t.height/2,bottom:-t.height/2,near:100,far:-100}}initSize(t){this.pointCloudInstance.updateTopCamera(),this.pointCloudInstance.setDefaultControls(),this.pointCloudInstance.initRenderer(),this.pointCloudInstance.initOrthographicCamera(this.getDefaultOrthographic(t)),this.pointCloudInstance.render();const o=P(t),n=new Image;n.src=o,n.onload=()=>{this.pointCloud2dOperation.setImgNode(n),this.pointCloud2dOperation.initImgPos()},this.pointCloud2dOperation.setCanvasSize(t)}addPolygonListOnTopView(t){const o=u.getBoxParamsFromResultList(t),n=u.getPolygonListFromResultList(t);this.updatePolygonList(o,n)}updateData(t,o,n){!this.pointCloud2dOperation||!this.pointCloudInstance||(this.pointCloudInstance.loadPCDFile(t,n==null?void 0:n.radius),this.addPolygonListOnTopView(o))}initAllPosition(){this.pointCloudInstance.updateTopCamera(),this.pointCloud2dOperation.initPosition()}clearAllData(){this.pointCloudInstance.clearPointCloudAndRender(),this.pointCloud2dOperation.clearResult()}}export{T as PointCloudAnnotation};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PCDLoader as
|
|
1
|
+
import{PCDLoader as h}from"./PCDLoader.js";class i{constructor(){this.MAX_SIZE=50,this.cacheList=[],this.loadPCDFile=t=>new Promise((s,c)=>{const e=this.pointsMap.get(t),a=this.colorMap.get(t);if(e&&a){s({points:e,color:a});return}if(this.cacheList.length>this.MAX_SIZE){const o=this.cacheList.shift();o&&this.pointsMap.delete(o.src)}this.cacheList.push({src:t}),this.pcdLoader.load(t,o=>{const n=o.geometry.attributes.position.array,r=o.geometry.attributes.color.array;this.pointsMap.set(t,n),this.colorMap.set(t,r),s({points:n,color:r})},()=>{},o=>{c(o)})}),this.pcdLoader=new h,this.pointsMap=new Map,this.colorMap=new Map}static getInstance(){return this.instance==null&&(this.instance=new i),this.instance}updateColor(t,s){this.colorMap.set(t,s)}}export{i as PointCloudCache};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as c from"three";import{toolStyleConverter as
|
|
1
|
+
import*as c from"three";import{toolStyleConverter as S,PerspectiveShiftUtils as w,EPerspectiveView as g}from"@labelbee/lb-utils";import V from"../../_virtual/highlightWorker.js";import k from"../../_virtual/filterBoxWorker.js";import{isInPolygon as L}from"../../utils/tool/polygonTool.js";import I from"../../utils/uuid.js";import{PCDLoader as N}from"./PCDLoader.js";import{OrbitControls as D}from"./OrbitControls.js";import{PointCloudCache as F}from"./cache.js";import{getCuboidFromPointCloudBox as z}from"./matrix.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,lidar2image,pointCloudLidar2image,rotatePoint,transferKitti2Matrix}from"./matrix.js";import"../../constant/tool.js";import"../../constant/annotation.js";import"../../utils/MathUtils.js";import"@turf/turf";import"../../utils/tool/CommonToolUtils.js";import"../../utils/tool/LineToolUtils.js";import"../../utils/tool/DrawUtils.js";import"../../constant/keyCode.js";import"../../locales/index.js";import"../../locales/constants.js";import"lodash";import"../../constant/style.js";import"../../utils/tool/CanvasUtils.js";import"../../utils/tool/ZoomUtils.js";var E=Object.defineProperty,R=Object.defineProperties,U=Object.getOwnPropertyDescriptors,A=Object.getOwnPropertySymbols,W=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable,j=(u,t,e)=>t in u?E(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,P=(u,t)=>{for(var e in t||(t={}))W.call(t,e)&&j(u,e,t[e]);if(A)for(var e of A(t))H.call(t,e)&&j(u,e,t[e]);return u},M=(u,t)=>R(u,U(t)),B=(u,t,e)=>new Promise((r,n)=>{var s=o=>{try{i(e.next(o))}catch(h){n(h)}},a=o=>{try{i(e.throw(o))}catch(h){n(h)}},i=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);i((e=e.apply(u,t)).next())});const Z=30,T=new V({type:"module"});class G{constructor({container:t,noAppend:e,isOrthographicCamera:r,orthographicParams:n,backgroundColor:s="black",config:a}){this.zAxisLimit=10,this.initCameraPosition=this.DEFAULT_INIT_CAMERA_POSITION,this.isOrthographicCamera=!1,this.pointsUuid="",this.pointCloudObjectName="pointCloud",this.rangeObjectName="range",this.showDirection=!0,this.AddBoxToSense=(i,o=16777215)=>{var h;const l=(h=i.id)!=null?h:I();this.removeObjectByName(l);const{center:d,width:m,height:y,depth:f,rotation:C}=i,p=new c.Group,b=new c.BoxGeometry(m,y,f),x=new c.MeshBasicMaterial({color:"blue"}),v=new c.Mesh(b,x),O=new c.BoxHelper(v,o),_=this.generateBoxArrow(i);p.add(O),p.add(_),p.position.set(d.x,d.y,d.z),p.rotation.set(0,0,C),p.name=l,this.scene.add(p)},this.overridePointShader=i=>{i.vertexShader=`
|
|
2
2
|
attribute float sizes;
|
|
3
3
|
attribute float visibility;
|
|
4
4
|
varying float vVisible;
|
|
@@ -8,4 +8,4 @@ import*as c from"three";import{toolStyleConverter as _,PerspectiveShiftUtils as
|
|
|
8
8
|
varying float vVisible;
|
|
9
9
|
${i.fragmentShader}`.replace("#include <clipping_planes_fragment>",`
|
|
10
10
|
if (vVisible < 0.5) discard;
|
|
11
|
-
#include <clipping_planes_fragment>`)},this.loadPCDFile=(i,o)=>v(this,null,function*(){this.clearPointCloud();const h=yield this.cacheInstance.loadPCDFile(i);h.name=this.pointCloudObjectName,this.renderPointCloud(h,o)}),this.loadPCDFileByBox=(i,o,h)=>v(this,null,function*(){const l=d=>v(this,null,function*(){const{width:f=0,height:y=0,depth:x=0}=h!=null?h:{},p=yield this.filterPointsByBox(b(C({},o),{width:o.width+f,height:o.height+y,depth:o.depth+x}),d);if(!p){console.error("filter Error");return}this.clearPointCloud();const M=new c.Points(p.geometry,d.material);M.name=this.pointCloudObjectName,this.scene.add(M),this.render()}),m=yield this.cacheInstance.loadPCDFile(i);l(m)}),this.generateRange=i=>{const o=this.createRange(i);this.scene.add(o)},this.generateBoxArrow=({width:i})=>{const o=new c.Vector3(1,0,0),h=new c.Vector3(i/2,0,0),l=2,m=16776960,d=new c.ArrowHelper(o,h,l,m);return d.visible=this.showDirection,d},this.generateBoxTrackID=i=>{if(!i.trackID)return;const o=new c.Texture(this.getTextCanvas(i.trackID.toString()));o.needsUpdate=!0;const h=new c.SpriteMaterial({map:o,depthWrite:!1}),l=new c.Sprite(h);return l.scale.set(5,5,5),l.position.set(-i.width/2,0,i.depth/2+.5),l},this.applyZAxisPoints=i=>{this.zAxisLimit=i,this.filterZAxisPoints(),this.render()},this.updatePointSize=i=>{const o=this.scene.getObjectByName(this.pointCloudObjectName);if(!o)return;const h=o.material.size;i?o.material.size=Math.min(h*1.2,10):o.material.size=Math.max(h/1.2,1),this.render()},this.container=t,this.renderer=new c.WebGLRenderer({antialias:!0}),this.backgroundColor=s,this.config=a,r&&n?(this.isOrthographicCamera=!0,this.camera=new c.OrthographicCamera(n.left,n.right,n.top,n.bottom,n.near,n.far)):this.camera=new c.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new c.Scene,this.controls=new I(this.camera,this.renderer.domElement),this.pcdLoader=new S,this.axesHelper=new c.AxesHelper(1e3),this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=N.getInstance()}get DEFAULT_INIT_CAMERA_POSITION(){return new c.Vector3(-1,0,10)}get containerWidth(){return this.container.clientWidth}get containerHeight(){return this.container.clientHeight}setInitCameraPosition(t){this.initCameraPosition=t}setConfig(t){this.config=t}initOrthographicCamera(t){if(this.camera.type!=="OrthographicCamera")return;const{left:e,right:r,top:n,bottom:s,near:a,far:i}=t;this.camera.left=e,this.camera.right=r,this.camera.top=n,this.camera.bottom=s,this.camera.near=a,this.camera.far=i,this.camera.updateProjectionMatrix()}initPerspectiveCamera(){this.camera.type==="PerspectiveCamera"&&(this.camera.fov=30,this.camera.aspect=this.containerWidth/this.containerHeight,this.camera.near=1,this.camera.far=1e3,this.camera.updateProjectionMatrix())}initCamera(){const{camera:t}=this;if(this.isOrthographicCamera){const{x:e,y:r,z:n}=this.initCameraPosition;t.position.set(e,r,n)}else t.position.set(-1,0,500);t.up.set(0,0,1)}initControls(){const{controls:t}=this;t.addEventListener("change",()=>{this.render()}),this.setDefaultControls()}setDefaultControls(){const{controls:t}=this,e=[0,0,0];t.target=new c.Vector3(...e),t.addEventListener("change",()=>{this.render()}),t.maxPolarAngle=Math.PI/2,t.update()}initRenderer(){const{renderer:t}=this;t.setPixelRatio(window.devicePixelRatio),t.setSize(this.containerWidth,this.containerHeight)}init(){const{scene:t}=this;t.background=new c.Color(this.backgroundColor),this.initControls(),this.initRenderer()}removeObjectByName(t){const e=this.scene.getObjectByName(t);e&&e.removeFromParent()}generateBox(t,e=16777215){var r,n,s,a,i;let o=e;((r=this.config)==null?void 0:r.attributeList)&&((s=(n=this.config)==null?void 0:n.attributeList)==null?void 0:s.length)>0&&t.attribute&&(o=(i=(a=_.getColorFromConfig({attribute:t.attribute},b(C({},this.config),{attributeConfigurable:!0}),{}))==null?void 0:a.hex)!=null?i:e),this.AddBoxToSense(t,o),this.render()}generateBoxes(t){t.forEach(e=>{this.generateBox(e)}),this.render()}getOrthographicCamera(t){const{center:e,width:r,height:n}=t,s=10,a=e.x-r/2-s,i=e.x-r/2+s,o=e.y+n/2+s,h=e.y-n/2-s,l=100,m=-100,d=500/l;return{left:a,right:i,top:o,bottom:h,near:l,far:m,zoom:d}}updateCameraByBox(t,e){const{center:r,width:n,height:s,depth:a,rotation:i}=t,o=this.getCameraVector(r,i,{width:n,height:s,depth:a},e);return this.updateCamera(o,r),o}updateOrthoCamera(t,e){const r=this.updateCameraByBox(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:r}}updateTopCamera(){this.setInitCameraPosition(this.DEFAULT_INIT_CAMERA_POSITION),this.camera.zoom=1,this.initCamera(),this.setDefaultControls(),this.camera.updateProjectionMatrix(),this.render()}updateCamera(t,e){this.camera.position.set(t.x,t.y,t.z),this.controls.target=new c.Vector3(e.x,e.y,e.z),this.controls.update()}resetCamera(){this.updateCamera({x:-1,y:0,z:500},{x:0,y:0,z:0})}createThreeMatrix4(t){return new c.Matrix4().set(...t)}filterPointsByBox(t,e){if(!e){const r=this.scene.getObjectByName(this.pointCloudObjectName);if(!r)return console.error("There is no corresponding point cloud object"),Promise.resolve(void 0);e=r}if(window.Worker){const{zMin:r,zMax:n,polygonPointList:s}=D(t),a=e.geometry.attributes.position.array,i=e.geometry.attributes.color.array,o={boxParams:t,zMin:r,zMax:n,polygonPointList:s,color:i,position:a};return new Promise(h=>{const l=new k;l.postMessage(o),l.onmessage=m=>{const{color:d,position:f,num:y}=m.data,x=new c.BufferGeometry;x.setAttribute("position",new c.Float32BufferAttribute(f,3)),x.setAttribute("color",new c.Float32BufferAttribute(d,3)),x.computeBoundingSphere(),l.terminate(),h({geometry:x,num:y})}})}return Promise.resolve(void 0)}getCameraVector(t,e,r,n=g.Front,s=H){let a=w.frontViewMatrix4(s);switch(n){case g.Front:break;case g.Back:a=w.backViewMatrix4(s);break;case g.Left:a=w.leftViewMatrix4(s);break;case g.Right:a=w.rightViewMatrix4(s);break;case g.Top:a=w.topViewMatrix4(s);break;case g.LFT:a=w.leftFrontTopViewMatrix4(s,r);break;case g.RBT:a=w.rightBackTopViewMatrix4(s,r);break}const i=this.createThreeMatrix4(a),o=new c.Matrix4().makeTranslation(-t.x,-t.y,-t.z),h=new c.Matrix4().makeTranslation(t.x,t.y,t.z),l=new c.Matrix4().makeRotationZ(e);return new c.Vector3(t.x,t.y,t.z).clone().applyMatrix4(i).applyMatrix4(o).applyMatrix4(l).applyMatrix4(h)}createRange(t){this.removeObjectByName(this.rangeObjectName);const r=new c.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),n=new c.BufferGeometry().setFromPoints(r),s=new c.LineBasicMaterial({color:16711680}),a=new c.Line(n,s);return a.name=this.rangeObjectName,a}renderPointCloud(t,e){t.material.size=1,t.name=this.pointCloudObjectName;const r=new c.PointsMaterial({vertexColors:!0});r.onBeforeCompile=this.overridePointShader,e&&this.generateRange(e),this.pointsUuid=t.uuid,t.material=r,this.filterZAxisPoints(t),this.scene.add(t),this.render()}clearPointCloud(){this.removeObjectByName(this.pointCloudObjectName)}clearPointCloudAndRender(){this.clearPointCloud(),this.render()}highlightOriginPointCloud(t){}setShowDirection(t){this.showDirection=t,this.scene.children.forEach(e=>{e.type==="Group"&&e.children.forEach(r=>{r.type==="ArrowHelper"&&(r.visible=t)})}),this.render()}getTextCanvas(t){const e=document.createElement("canvas"),r=e.getContext("2d");return r&&(r.font=`${50}px " bold`,r.fillStyle="white",r.textAlign="center",r.textBaseline="middle",r.fillText(t,e.width/2,e.height/2)),e}getSensesPointZAxisInPolygon(t,e){const r=this.scene.children.find(o=>o.uuid===this.pointsUuid);let n=0,s=0,a=0,i=0;if(r&&(r==null?void 0:r.geometry)){const o=r==null?void 0:r.geometry.attributes.position.array;for(let h=0;h<o.length;h+=3){const l=o[h],m=o[h+1],d=o[h+2];A({x:l,y:m},t)&&d&&(s=Math.max(d,s),n=Math.min(d,n),i++,e&&d>=e[0]&&d<=e[1]&&a++)}}return{maxZ:s,minZ:n,count:a,zCount:i}}getBasicCoordinate2Canvas(t){const e=this.containerWidth/2,r=this.containerHeight/2;return{x:t.x*e+e,y:t.y*r+r,z:t.z}}get basicCoordinate2CanvasMatrix4(){const t=this.containerWidth/2,e=this.containerHeight/2;return new c.Matrix4().set(t,0,0,t,0,e,0,e,0,0,1,0,0,0,0,1)}getCanvas2BasicCoordinate(t){const e=this.containerWidth/2,r=this.containerHeight/2;return new c.Vector3(t.x/e-e/2,-(t.y/r-r/2),1)}getPolygonSidePoints(t){const{center:{x:e,y:r,z:n},height:s,width:a,depth:i}=t,o={x:e+a/2,y:r+s/2,z:n-i/2},h={x:e+a/2,y:r+s/2,z:n+i/2},l={x:e-a/2,y:r+s/2,z:n+i/2},m={x:e-a/2,y:r+s/2,z:n-i/2};return[o,h,l,m]}getPolygonBackPoints(t){const{center:{x:e,y:r,z:n},height:s,width:a,depth:i}=t,o={x:e-a/2,y:r+s/2,z:n+i/2},h={x:e-a/2,y:r+s/2,z:n-i/2},l={x:e-a/2,y:r-s/2,z:n-i/2},m={x:e-a/2,y:r-s/2,z:n+i/2};return[o,h,l,m]}getPolygonTopPoints(t){const{center:{x:e,y:r,z:n},height:s,width:a,depth:i}=t,o={x:e+a/2,y:r+s/2,z:n+i/2},h={x:e+a/2,y:r-s/2,z:n+i/2},l={x:e-a/2,y:r-s/2,z:n+i/2},m={x:e-a/2,y:r+s/2,z:n+i/2};return[o,h,l,m]}getModelTransformationMatrix(t){const{center:{x:e,y:r,z:n},rotation:s}=t,a=new c.Matrix4().makeTranslation(-e,-r,-n),i=new c.Matrix4().makeTranslation(e,r,n),o=new c.Matrix4().makeRotationZ(s);return new c.Matrix4().multiply(i).multiply(o).multiply(a)}getBoxSidePolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,g.Left)}getBoxBackPolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,g.Back)}boxParams2ViewPolygon(t,e){switch(e){case g.Left:return this.getPolygonSidePoints(t);case g.Back:return this.getPolygonBackPoints(t);default:return this.getPolygonTopPoints(t)}}getBoxPolygon2DCoordinate(t,e){const r=this.boxParams2ViewPolygon(t,e),{width:n,height:s}=t,a=new c.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),i=new c.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(a).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=i;const o=r.map(m=>new c.Vector3(m.x,m.y,m.z)).map(m=>m.applyMatrix4(this.sideMatrix)),h=this.containerWidth/n,l=this.containerHeight/s;return{polygon2d:o,zoom:Math.min(h,l)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:r}=t,s=this.getPolygonTopPoints(t).map(o=>new c.Vector3(o.x,o.y,o.z)).map(o=>o.applyMatrix4(this.getModelTransformationMatrix(t))).map(o=>({x:o.y,y:o.x})).map(o=>({x:-(o.x-this.containerWidth/2),y:-(o.y-this.containerHeight/2)})),a=this.containerWidth/e,i=this.containerHeight/r;return{polygon2d:s,zoom:Math.min(a,i)/2}}getNewBoxBySideUpdate(t,e,r,n){const s=new c.Matrix4().makeRotationZ(n.rotation),a=new c.Vector3(-t.x,0,0).applyMatrix4(s);let i=n;return i.center={x:i.center.x+a.x,y:i.center.y+a.y,z:i.center.z-t.z},i=b(C({},i),{width:i.width+e,height:i.height,depth:i.depth+r}),{newBoxParams:i}}getNewBoxByBackUpdate(t,e,r,n){const s=new c.Matrix4().makeRotationZ(n.rotation),a=new c.Vector3(0,-t.x,0).applyMatrix4(s);let i=n;return i.center={x:i.center.x+a.x,y:i.center.y+a.y,z:i.center.z-t.z},i=b(C({},i),{width:i.width,height:i.height+e,depth:i.depth+r}),{newBoxParams:i}}getNewBoxBySideUpdateByPoints(t,e,r,n){var s;const a=(s=this.sideMatrix)==null?void 0:s.invert();if(!this.sideMatrix||!a){console.error("No sideMatrix");return}this.camera.zoom=1,this.camera.updateProjectionMatrix();const i=t.map(p=>new c.Vector3(p.x,p.y,p.z)).map(p=>p.applyMatrix4(a)),[o,h,l,m]=i,d=Math.max(Math.abs(o.x-l.x),Math.abs(o.x-h.x)),y=h.add(m).applyMatrix3(new c.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new c.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new c.Vector3(n.center.x,n.center.y,n.center.z));return{newBoxParams:b(C({},n),{center:{x:n.center.x-y.x,y:n.center.y-y.y,z:n.center.z-r},width:d,height:n.height,depth:n.depth+e,rotation:n.rotation})}}filterZAxisPoints(t){const e=t||this.scene.children.find(r=>r.uuid===this.pointsUuid);if(e){const{attributes:r}=e.geometry,{position:n}=r,s=[],{count:a}=n;for(let i=0;i<a;i++){const o=n.getZ(i);s.push(o>this.zAxisLimit?0:1)}e.geometry.setAttribute("visibility",new c.Float32BufferAttribute(s,1)),e.geometry.attributes.visibility.needsUpdate=!0}}render(){this.renderer.render(this.scene,this.camera)}}export{Z as PointCloud};
|
|
11
|
+
#include <clipping_planes_fragment>`)},this.loadPCDFile=(i,o)=>B(this,null,function*(){this.clearPointCloud(),this.currentPCDSrc=i;const{points:h,color:l}=yield this.cacheInstance.loadPCDFile(i),d=new c.BufferGeometry;d.setAttribute("position",new c.BufferAttribute(h,3)),d.setAttribute("color",new c.BufferAttribute(l,3));const m=new c.Points(d);this.renderPointCloud(m,o)}),this.loadPCDFileByBox=(i,o,h)=>B(this,null,function*(){const l=(y,f)=>B(this,null,function*(){const{width:C=0,height:p=0,depth:b=0}=h!=null?h:{},x=yield this.filterPointsByBox(M(P({},o),{width:o.width+C,height:o.height+p,depth:o.depth+b}),y,f);if(!x){console.error("filter Error");return}this.clearPointCloud(),this.currentPCDSrc=i;const v=new c.Points(x.geometry);v.name=this.pointCloudObjectName,this.scene.add(v),this.render()}),{points:d,color:m}=yield this.cacheInstance.loadPCDFile(i);l(d,m)}),this.generateRange=i=>{const o=this.createRange(i);this.scene.add(o)},this.generateBoxArrow=({width:i})=>{const o=new c.Vector3(1,0,0),h=new c.Vector3(i/2,0,0),l=2,d=16776960,m=new c.ArrowHelper(o,h,l,d);return m.visible=this.showDirection,m},this.generateBoxTrackID=i=>{if(!i.trackID)return;const o=new c.Texture(this.getTextCanvas(i.trackID.toString()));o.needsUpdate=!0;const h=new c.SpriteMaterial({map:o,depthWrite:!1}),l=new c.Sprite(h);return l.scale.set(5,5,5),l.position.set(-i.width/2,0,i.depth/2+.5),l},this.applyZAxisPoints=i=>{this.zAxisLimit=i,this.filterZAxisPoints(),this.render()},this.updatePointSize=i=>{const o=this.scene.getObjectByName(this.pointCloudObjectName);if(!o)return;const h=o.material.size;i?o.material.size=Math.min(h*1.2,10):o.material.size=Math.max(h/1.2,1),this.render()},this.container=t,this.renderer=new c.WebGLRenderer({antialias:!0}),this.backgroundColor=s,this.config=a,r&&n?(this.isOrthographicCamera=!0,this.camera=new c.OrthographicCamera(n.left,n.right,n.top,n.bottom,n.near,n.far)):this.camera=new c.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new c.Scene,this.controls=new D(this.camera,this.renderer.domElement),this.pcdLoader=new N,this.axesHelper=new c.AxesHelper(1e3),this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=F.getInstance()}get DEFAULT_INIT_CAMERA_POSITION(){return new c.Vector3(-.01,0,10)}get containerWidth(){return this.container.clientWidth}get containerHeight(){return this.container.clientHeight}setInitCameraPosition(t){this.initCameraPosition=t}setConfig(t){this.config=t}initOrthographicCamera(t){if(this.camera.type!=="OrthographicCamera")return;const{left:e,right:r,top:n,bottom:s,near:a,far:i}=t;this.camera.left=e,this.camera.right=r,this.camera.top=n,this.camera.bottom=s,this.camera.near=a,this.camera.far=i,this.camera.updateProjectionMatrix()}initPerspectiveCamera(){this.camera.type==="PerspectiveCamera"&&(this.camera.fov=30,this.camera.aspect=this.containerWidth/this.containerHeight,this.camera.near=1,this.camera.far=1e3,this.camera.updateProjectionMatrix())}initCamera(){const{camera:t}=this;if(this.isOrthographicCamera){const{x:e,y:r,z:n}=this.initCameraPosition;t.position.set(e,r,n)}else t.position.set(-1,0,500);t.up.set(0,0,1)}initControls(){const{controls:t}=this;t.addEventListener("change",()=>{this.render()}),this.setDefaultControls()}setDefaultControls(){const{controls:t}=this,e=[0,0,0];t.target=new c.Vector3(...e),t.addEventListener("change",()=>{this.render()}),t.maxPolarAngle=Math.PI/2,t.update()}initRenderer(){const{renderer:t}=this;t.setPixelRatio(window.devicePixelRatio),t.setSize(this.containerWidth,this.containerHeight)}init(){const{scene:t}=this;t.background=new c.Color(this.backgroundColor),this.initControls(),this.initRenderer()}removeObjectByName(t){const e=this.scene.getObjectByName(t);e&&e.removeFromParent()}generateBox(t,e=16777215){const r=e;this.AddBoxToSense(t,r),this.render()}getAllAttributeColor(t){return t.reduce((e,r)=>(e[r.attribute]=S.getColorFromConfig({attribute:r.attribute},M(P({},this.config),{attributeConfigurable:!0}),{}),e),{})}generateBoxes(t){t.forEach(e=>{this.generateBox(e)}),this.render()}getOrthographicCamera(t){const{center:e,width:r,height:n}=t,s=10,a=e.x-r/2-s,i=e.x-r/2+s,o=e.y+n/2+s,h=e.y-n/2-s,l=100,d=-100,m=500/l;return{left:a,right:i,top:o,bottom:h,near:l,far:d,zoom:m}}updateCameraZoom(t){this.camera.zoom=t,this.camera.updateProjectionMatrix()}updateCameraByBox(t,e){const{center:r,width:n,height:s,depth:a,rotation:i}=t,o=this.getCameraVector(r,i,{width:n,height:s,depth:a},e);return this.updateCamera(o,r),o}updateOrthoCamera(t,e){const r=this.updateCameraByBox(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:r}}updateTopCamera(){this.setInitCameraPosition(this.DEFAULT_INIT_CAMERA_POSITION),this.camera.zoom=1,this.initCamera(),this.setDefaultControls(),this.camera.updateProjectionMatrix(),this.render()}updateCamera(t,e){this.camera.position.set(t.x,t.y,t.z),this.controls.target=new c.Vector3(e.x,e.y,e.z),this.controls.update()}resetCamera(){this.updateCamera(this.DEFAULT_INIT_CAMERA_POSITION,{x:0,y:0,z:0})}createThreeMatrix4(t){return new c.Matrix4().set(...t)}filterPointsByBox(t,e,r){var n,s,a;if(!e){const i=this.scene.getObjectByName(this.pointCloudObjectName);if(!i)return console.error("There is no corresponding point cloud object"),Promise.resolve(void 0);e=(a=(s=(n=i==null?void 0:i.geometry)==null?void 0:n.attributes)==null?void 0:s.position)==null?void 0:a.array}if(window.Worker){const{zMin:i,zMax:o,polygonPointList:h}=z(t),l=e;r=r!=null?r:new Float32Array([]);const d={boxParams:t,zMin:i,zMax:o,polygonPointList:h,color:r,position:l};return new Promise(m=>{const y=new k;y.postMessage(d),y.onmessage=f=>{const{color:C,position:p,num:b}=f.data,x=new c.BufferGeometry;x.setAttribute("position",new c.Float32BufferAttribute(p,3)),x.setAttribute("color",new c.Float32BufferAttribute(C,3)),x.computeBoundingSphere(),y.terminate(),m({geometry:x,num:b})}})}return Promise.resolve(void 0)}getCameraVector(t,e,r,n=g.Front,s=Z){let a=w.frontViewMatrix4(s);switch(n){case g.Front:break;case g.Back:a=w.backViewMatrix4(s);break;case g.Left:a=w.leftViewMatrix4(s);break;case g.Right:a=w.rightViewMatrix4(s);break;case g.Top:a=w.topViewMatrix4(s);break;case g.LFT:a=w.leftFrontTopViewMatrix4(s,r);break;case g.RBT:a=w.rightBackTopViewMatrix4(s,r);break}const i=this.createThreeMatrix4(a),o=new c.Matrix4().makeTranslation(-t.x,-t.y,-t.z),h=new c.Matrix4().makeTranslation(t.x,t.y,t.z),l=new c.Matrix4().makeRotationZ(e);return new c.Vector3(t.x,t.y,t.z).clone().applyMatrix4(i).applyMatrix4(o).applyMatrix4(l).applyMatrix4(h)}createRange(t){this.removeObjectByName(this.rangeObjectName);const r=new c.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),n=new c.BufferGeometry().setFromPoints(r),s=new c.LineBasicMaterial({color:16711680}),a=new c.Line(n,s);return a.name=this.rangeObjectName,a}renderPointCloud(t,e){t.name=this.pointCloudObjectName;const r=new c.PointsMaterial({vertexColors:!0});r.onBeforeCompile=this.overridePointShader,r.size=1.2,e&&this.generateRange(e),this.pointsUuid=t.uuid,t.material=r,this.filterZAxisPoints(t),this.scene.add(t),this.render()}clearPointCloud(){this.removeObjectByName(this.pointCloudObjectName)}clearPointCloudAndRender(){this.clearPointCloud(),this.render()}highlightOriginPointCloud(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(!!e)return this.highlightPCDSrc=this.currentPCDSrc,new Promise(r=>{if(window.Worker){const s=(t?[...t]:[]).map(o=>z(o)),a=this.getAllAttributeColor(s),i={cuboidList:s,position:e.geometry.attributes.position.array,color:e.geometry.attributes.color.array,colorList:a};T.postMessage(i),T.onmessage=o=>{const{color:h}=o.data,l=new c.BufferAttribute(h,3);this.highlightPCDSrc&&(this.cacheInstance.updateColor(this.highlightPCDSrc,h),this.highlightPCDSrc=void 0),l.needsUpdate=!0,e.geometry.setAttribute("color",l),r(h),this.render()}}})}updateColor(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(e){const r=new c.BufferAttribute(t,3);r.needsUpdate=!0,e.geometry.setAttribute("color",r),this.render()}}setShowDirection(t){this.showDirection=t,this.scene.children.forEach(e=>{e.type==="Group"&&e.children.forEach(r=>{r.type==="ArrowHelper"&&(r.visible=t)})}),this.render()}getTextCanvas(t){const e=document.createElement("canvas"),r=e.getContext("2d");return r&&(r.font=`${50}px " bold`,r.fillStyle="white",r.textAlign="center",r.textBaseline="middle",r.fillText(t,e.width/2,e.height/2)),e}getSensesPointZAxisInPolygon(t,e){const r=this.scene.children.find(o=>o.uuid===this.pointsUuid);let n=0,s=0,a=0,i=0;if(r&&(r==null?void 0:r.geometry)){const o=r==null?void 0:r.geometry.attributes.position.array;for(let h=0;h<o.length;h+=3){const l=o[h],d=o[h+1],m=o[h+2];L({x:l,y:d},t)&&m&&(s=Math.max(m,s),n=Math.min(m,n),i++,e&&m>=e[0]&&m<=e[1]&&a++)}}return{maxZ:s,minZ:n,count:a,zCount:i}}getBasicCoordinate2Canvas(t){const e=this.containerWidth/2,r=this.containerHeight/2;return{x:t.x*e+e,y:t.y*r+r,z:t.z}}get basicCoordinate2CanvasMatrix4(){const t=this.containerWidth/2,e=this.containerHeight/2;return new c.Matrix4().set(t,0,0,t,0,e,0,e,0,0,1,0,0,0,0,1)}getCanvas2BasicCoordinate(t){const e=this.containerWidth/2,r=this.containerHeight/2;return new c.Vector3(t.x/e-e/2,-(t.y/r-r/2),1)}getPolygonSidePoints(t){const{center:{x:e,y:r,z:n},height:s,width:a,depth:i}=t,o={x:e+a/2,y:r+s/2,z:n-i/2},h={x:e+a/2,y:r+s/2,z:n+i/2},l={x:e-a/2,y:r+s/2,z:n+i/2},d={x:e-a/2,y:r+s/2,z:n-i/2};return[o,h,l,d]}getPolygonBackPoints(t){const{center:{x:e,y:r,z:n},height:s,width:a,depth:i}=t,o={x:e-a/2,y:r+s/2,z:n+i/2},h={x:e-a/2,y:r+s/2,z:n-i/2},l={x:e-a/2,y:r-s/2,z:n-i/2},d={x:e-a/2,y:r-s/2,z:n+i/2};return[o,h,l,d]}getPolygonTopPoints(t){const{center:{x:e,y:r,z:n},height:s,width:a,depth:i}=t,o={x:e+a/2,y:r+s/2,z:n+i/2},h={x:e+a/2,y:r-s/2,z:n+i/2},l={x:e-a/2,y:r-s/2,z:n+i/2},d={x:e-a/2,y:r+s/2,z:n+i/2};return[o,h,l,d]}getModelTransformationMatrix(t){const{center:{x:e,y:r,z:n},rotation:s}=t,a=new c.Matrix4().makeTranslation(-e,-r,-n),i=new c.Matrix4().makeTranslation(e,r,n),o=new c.Matrix4().makeRotationZ(s);return new c.Matrix4().multiply(i).multiply(o).multiply(a)}getBoxSidePolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,g.Left)}getBoxBackPolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,g.Back)}boxParams2ViewPolygon(t,e){switch(e){case g.Left:return this.getPolygonSidePoints(t);case g.Back:return this.getPolygonBackPoints(t);default:return this.getPolygonTopPoints(t)}}getBoxPolygon2DCoordinate(t,e){const r=this.boxParams2ViewPolygon(t,e),{width:n,height:s}=t,a=new c.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),i=new c.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(a).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=i;const o=r.map(d=>new c.Vector3(d.x,d.y,d.z)).map(d=>d.applyMatrix4(this.sideMatrix)),h=this.containerWidth/n,l=this.containerHeight/s;return{polygon2d:o,zoom:Math.min(h,l)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:r}=t,s=this.getPolygonTopPoints(t).map(o=>new c.Vector3(o.x,o.y,o.z)).map(o=>o.applyMatrix4(this.getModelTransformationMatrix(t))).map(o=>({x:o.y,y:o.x})).map(o=>({x:-(o.x-this.containerWidth/2),y:-(o.y-this.containerHeight/2)})),a=this.containerWidth/e,i=this.containerHeight/r;return{polygon2d:s,zoom:Math.min(a,i)/2}}getNewBoxBySideUpdate(t,e,r,n){const s=new c.Matrix4().makeRotationZ(n.rotation),a=new c.Vector3(-t.x,0,0).applyMatrix4(s);let i=n;return i.center={x:i.center.x+a.x,y:i.center.y+a.y,z:i.center.z-t.z},i=M(P({},i),{width:i.width+e,height:i.height,depth:i.depth+r}),{newBoxParams:i}}getNewBoxByBackUpdate(t,e,r,n){const s=new c.Matrix4().makeRotationZ(n.rotation),a=new c.Vector3(0,-t.x,0).applyMatrix4(s);let i=n;return i.center={x:i.center.x+a.x,y:i.center.y+a.y,z:i.center.z-t.z},i=M(P({},i),{width:i.width,height:i.height+e,depth:i.depth+r}),{newBoxParams:i}}getNewBoxBySideUpdateByPoints(t,e,r,n){var s;const a=(s=this.sideMatrix)==null?void 0:s.invert();if(!this.sideMatrix||!a){console.error("No sideMatrix");return}this.camera.zoom=1,this.camera.updateProjectionMatrix();const i=t.map(p=>new c.Vector3(p.x,p.y,p.z)).map(p=>p.applyMatrix4(a)),[o,h,l,d]=i,m=Math.max(Math.abs(o.x-l.x),Math.abs(o.x-h.x)),f=h.add(d).applyMatrix3(new c.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new c.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new c.Vector3(n.center.x,n.center.y,n.center.z));return{newBoxParams:M(P({},n),{center:{x:n.center.x-f.x,y:n.center.y-f.y,z:n.center.z-r},width:m,height:n.height,depth:n.depth+e,rotation:n.rotation})}}filterZAxisPoints(t){const e=t||this.scene.children.find(r=>r.uuid===this.pointsUuid);if(e){const{attributes:r}=e.geometry,{position:n}=r,s=[],{count:a}=n;for(let i=0;i<a;i++){const o=n.getZ(i);s.push(o>this.zAxisLimit?0:1)}e.geometry.setAttribute("visibility",new c.Float32BufferAttribute(s,1)),e.geometry.attributes.visibility.needsUpdate=!0}}render(){this.renderer.render(this.scene,this.camera)}}export{G as PointCloud};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as p from"three";import{MatrixUtils as x,PointCloudUtils as w}from"@labelbee/lb-utils";import _ from"../../utils/uuid.js";var g=Object.defineProperty,h=Object.defineProperties,z=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,M=(r,t,e)=>t in r?g(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,P=(r,t)=>{for(var e in t||(t={}))O.call(t,e)&&M(r,e,t[e]);if(m)for(var e of m(t))T.call(t,e)&&M(r,e,t[e]);return r},V=(r,t)=>h(r,z(t));function u(r){return new p.Matrix4().set(...r)}function d(r,t,e){const o=x.transferMatrix34FromKitti2Three(r),n=x.transferMatrix33FromKitti2Three(t),a=x.transferMatrix34FromKitti2Three(e),l=u(o),c=u(n),s=u(a);return{composeMatrix4:s.clone().premultiply(c).premultiply(l),PM:l,RM:c,TM:s}}function y(r,t,e){var o;const n=new p.Vector3(r.x,r.y,(o=r==null?void 0:r.z)!=null?o:1),a=new p.Matrix4().makeRotationZ(e),l=new p.Matrix4().makeTranslation(t.x,t.y,t.z),c=new p.Matrix4().makeTranslation(-t.x,-t.y,-t.z);return n.clone().applyMatrix4(c).applyMatrix4(a).applyMatrix4(l)}function v(r,t){const o=new p.Vector4(r.x,r.y,r.z).applyMatrix4(t);if(o.z<0)return;const n=1/o.z,a=new p.Matrix4().set(n,0,0,0,0,n,0,0,0,0,n,0,0,0,0,1);return o.applyMatrix4(a)}function R(r){const{center:t,width:e,height:o,depth:n,rotation:a}=r,l=[{x:t.x+e/2,y:t.y-o/2},{x:t.x+e/2,y:t.y+o/2},{x:t.x-e/2,y:t.y+o/2},{x:t.x-e/2,y:t.y-o/2}].map(i=>{const f=y(i,t,a);return{x:f.x,y:f.y}}),c=t.z+n/2,s=t.z-n/2;return V(P({},r),{polygonPointList:l,zMax:c,zMin:s})}function b(r,t){const e=w.getAllViewData(r),{P:o,R:n,T:a}=t,{composeMatrix4:l}=d(o,n,a);return e.map(s=>({type:s.type,pointList:s.pointList.map(i=>y(i,r.center,r.rotation)).map(i=>v(i,l)).map(i=>{if(!!i)return{id:_(),x:i==null?void 0:i.x,y:i==null?void 0:i.y}}).filter(i=>i!==void 0)})).filter(s=>s.pointList.length!==0)}export{u as createThreeMatrix4,R as getCuboidFromPointCloudBox,v as lidar2image,b as pointCloudLidar2image,y as rotatePoint,d as transferKitti2Matrix};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toolStyleConverter as
|
|
1
|
+
import{INVALID_COLOR as C,toolStyleConverter as _}from"@labelbee/lb-utils";import{ESortDirection as I}from"../../constant/annotation.js";import{EPolygonPattern as y}from"../../constant/tool.js";import f from"../../utils/tool/AxisUtils.js";import P from"../../utils/tool/CommonToolUtils.js";import p from"../../utils/tool/DrawUtils.js";import v from"../../utils/tool/PolygonUtils.js";import{polygonConfig as L}from"../../constant/defaultConfig.js";import b from"./polygonOperation.js";var w=Object.defineProperty,S=Object.defineProperties,A=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,x=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,m=(s,t,e)=>t in s?w(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,h=(s,t)=>{for(var e in t||(t={}))x.call(t,e)&&m(s,e,t[e]);if(D)for(var e of D(t))O.call(t,e)&&m(s,e,t[e]);return s},u=(s,t)=>S(s,A(t));class j extends b{constructor(t){super(t);this.selectedIDs=[],this.rightMouseUp=a=>{var d;if(this.drawingPointList.length>0){this.addDrawingPointToPolygonList();return}if(!this.hoverID)return;if(a.ctrlKey){this.emit("addSelectedIDs",this.hoverID);return}this.emit("setSelectedIDs",this.hoverID);const c=(d=this.polygonList.find(g=>g.id===this.hoverID))==null?void 0:d.attribute;c&&c!==this.defaultAttribute&&this.emit("syncAttribute",c)},this.onKeyDown=()=>{},this.onKeyUp=()=>{},this.renderSingleSelectedPolygon=a=>{var d;if(this.selectedPolygons){const c=this.getPointCloudLineColor(a),g=f.changePointListByZoom(a.pointList,this.zoom,this.currentPos);p.drawSelectedPolygonWithFillAndLine(this.canvas,g,{fillColor:"transparent",strokeColor:c,pointColor:"white",thickness:2,lineCap:"round",isClose:!0,lineType:(d=this.config)==null?void 0:d.lineType}),a.isRect===!0&&this.showDirectionLine===!0&&this.renderRectPolygonDirection(g)}};var e,i,o,n,r,l;this.showDirectionLine=(e=t.showDirectionLine)!=null?e:!0,this.forbidAddNew=(i=t.forbidAddNew)!=null?i:!1,this.pointCloudConfig=(o=P.jsonParser(t.config))!=null?o:{},this.checkMode=(n=t.checkMode)!=null?n:!1,this.forbidAddNew===!1&&t.checkMode===!0&&(this.forbidAddNew=!0),this.config=u(h({},L),{textConfigurable:!1,attributeConfigurable:!0,attributeList:(l=(r=this.pointCloudConfig)==null?void 0:r.attributeList)!=null?l:[]})}get getSelectedIDs(){return this.selectedIDs}setConfig(t){var e;const i=P.jsonParser(t);this.pointCloudConfig=i,this.config=u(h({},this.config),{attributeList:(e=i==null?void 0:i.attributeList)!=null?e:[]})}dragMouseDown(t){this.checkMode||super.dragMouseDown(t)}deletePolygon(t){this.checkMode||super.deletePolygon(t)}deletePolygonPoint(t){this.checkMode||super.deletePolygonPoint(t)}setSelectedIDs(t){this.selectedIDs=t,this.setSelectedID(this.selectedIDs.length===1?this.selectedIDs[0]:""),this.render()}deleteSelectedID(){super.deleteSelectedID(),this.selectedIDs=[],this.emit("deleteSelectedIDs")}get selectedPolygons(){return v.getPolygonByIDs(this.polygonList,this.selectedIDs)}getLineColor(){return"rgba(0, 255, 255, 0.5)"}getPointCloudLineColor(t){return t.valid===!1?C:_.getColorFromConfig({attribute:t.attribute},u(h({},this.pointCloudConfig),{attributeConfigurable:!0}),{}).stroke}renderStaticPolygon(){var t;this.isHidden===!1&&((t=this.polygonList)==null||t.forEach(e=>{var i,o,n;if([...this.selectedIDs,this.editPolygonID].includes(e.id))return;const r=this.getPointCloudLineColor(e),l=f.changePointListByZoom(e.pointList||[],this.zoom,this.currentPos);p.drawPolygonWithFillAndLine(this.canvas,l,{fillColor:"transparent",strokeColor:r,pointColor:"white",thickness:(o=(i=this.style)==null?void 0:i.width)!=null?o:2,lineCap:"round",isClose:!0,lineType:(n=this.config)==null?void 0:n.lineType}),e.isRect===!0&&this.showDirectionLine===!0&&this.renderRectPolygonDirection(l)}))}renderSelectedPolygon(){var t;(t=this.selectedPolygons)==null||t.forEach(e=>{this.renderSingleSelectedPolygon(e)})}renderRectPolygonDirection(t){t.length<2||p.drawLine(this.canvas,t[0],t[1],{color:"white",thickness:3,lineDash:[6]})}get currentPolygonListByPattern(){return this.polygonList.filter(t=>this.pattern===y.Rect?t.isRect===!0:this.pattern===y.Normal?t.isRect!==!0:!0)}getHoverID(t){var e;const i=this.getCoordinateUnderZoom(t),n=this.currentPolygonListByPattern.map(r=>u(h({},r),{pointList:f.changePointListByZoom(r.pointList,this.zoom)}));return v.getHoverPolygonID(i,n,10,(e=this.config)==null?void 0:e.lineType)}switchToNextPolygon(t=I.ascend){if(this.drawingPointList.length>0)return;const e=this.currentPolygonListByPattern.map(o=>{var n,r,l,a;return u(h({},o),{x:(r=(n=o.pointList[0])==null?void 0:n.x)!=null?r:0,y:(a=(l=o.pointList[0])==null?void 0:l.y)!=null?a:0})}),i=P.getNextSelectedRectID(e,t,this.selectedID);if(i)return this.setSelectedIDs([i.id]),this.render(),[i.id]}setSelectedIdAfterAddingDrawing(t){this.drawingPointList.length!==0&&this.setSelectedID(t)}setSelectedID(t){var e,i;const o=this.selectedID;t!==o&&o&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(i=this._textAttributInstance)==null||i.clearTextAttribute(),this.selectedID=t,this.render()}addPointInDrawing(t){this.forbidAddNew||super.addPointInDrawing(t)}setCanvasSize(t){var e,i;const o=this.pixelRatio;this.size=t,this.setImgInfo(t),this.updateCanvasBasicStyle(this.basicCanvas,t,0),this.updateCanvasBasicStyle(this.canvas,t,10),(e=this.ctx)==null||e.scale(o,o),(i=this.basicCtx)==null||i.scale(o,o),this.initImgPos(),this.renderBasicCanvas(),this.render()}setPolygonValidAndRender(t,e=!1){if(e){super.setPolygonValidAndRender(t);return}this.emit("validUpdate",t)}}export{j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EToolName as p,ELineTypes as A,edgeAdsorptionScope as _,EOperationMode as U}from"../../constant/tool.js";import E from"../../utils/tool/RectUtils.js";import L from"../../utils/tool/PolygonUtils.js";import j from"../../utils/tool/MarkerUtils.js";import z from"../../utils/MathUtils.js";import{EDragStatus as d,ESortDirection as k,DEFAULT_TEXT_OFFSET as N}from"../../constant/annotation.js";import S from"../../constant/keyCode.js";import y from"../../locales/index.js";import{EMessage as C}from"../../locales/constants.js";import v from"../../utils/tool/AttributeUtils.js";import c from"../../utils/tool/AxisUtils.js";import r from"../../utils/tool/CommonToolUtils.js";import x from"../../utils/tool/DrawUtils.js";import B from"../../utils/tool/StyleUtils.js";import H from"../../utils/uuid.js";import{BasicToolOperation as Z}from"./basicToolOperation.js";import W from"./textAttributeClass.js";var F=Object.defineProperty,K=Object.defineProperties,$=Object.getOwnPropertyDescriptors,w=Object.getOwnPropertySymbols,V=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,T=Math.pow,O=(g,t,e)=>t in g?F(g,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):g[t]=e,D=(g,t)=>{for(var e in t||(t={}))V.call(t,e)&&O(g,e,t[e]);if(w)for(var e of w(t))X.call(t,e)&&O(g,e,t[e]);return g},P=(g,t)=>K(g,$(t));const R=200;class q extends Z{constructor(t){super(t);this.setMarkerIndex=e=>{this.markerIndex=e},this.setMarkerIndexAndSelect=e=>{if(!this.config.markerList)return;this.markerIndex=e;const i=this.config.markerList[e].value,s=this.currentPageResult.find(o=>o.label===i);s&&(this.setSelectedID(s.id),this.config.attributeConfigurable===!0&&this.setDefaultAttribute(s.attribute)),this.emit("markIndexChange")},this.textChange=e=>{this.config.textConfigurable!==!0||!this.selectedID||(this.setPointList(v.textChange(e,this.selectedID,this.pointList)),this.emit("selectedChange"),this.render())},this.isMinDistance=e=>{const i=c.changePointByZoom(e,this.zoom);return this.pointList.some(s=>{const o=c.changePointByZoom(s,this.zoom);return z.getLineLength(o,i)<.2})},this.config=r.jsonParser(t.config),this.pointList=[],this.markerIndex=0,this.setStyle(t.style),this.createPoint=this.createPoint.bind(this),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this),this.setSelectedID=this.setSelectedID.bind(this)}get dataList(){return this.pointList}get drawOutsideTarget(){var t;return(t=this.config.drawOutsideTarget)!=null?t:this.config.drawPointOut}setNextMarker(t=this.pointList){if(this.hasMarkerConfig){const e=r.getNextMarker(this.getCurrentPageResult(t),this.config.markerList);e&&this.setMarkerIndexAndSelect(e.index)}}setResult(t){this.clearActiveStatus(),this.setPointList(t),this.setNextMarker(t),this.recoverOperationMode(),this.render()}setPointList(t,e=!1){const i=this.pointList.length;this.pointList=t,i!==t.length&&this.emit("updatePageNumber"),e&&this.emit("updateResult")}setConfig(t,e=!1){this.config=r.jsonParser(t),e===!0&&this.clearResult()}clearResult(){this.setPointList([]),this.setSelectedID(void 0),this.history.pushHistory([]),this.hoverID="",this.render()}setDefaultAttribute(t=""){const e=this.defaultAttribute;if(this.defaultAttribute=t,e!==t){this.changeStyle(t),this.emit("changeAttributeSidebar");const{selectedID:i}=this;if(i&&(this.pointList.forEach(s=>{s.id===i&&(s.attribute=t)}),this.history.pushHistory(this.pointList),this.render()),this._textAttributInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(t)){this._textAttributInstance.clearTextAttribute();return}this._textAttributInstance.updateIcon(this.getTextIconSvg(t))}}}get selectedText(){var t;return(t=this.pointList.find(e=>e.id===this.selectedID))==null?void 0:t.textAttribute}setStyle(t){var e;super.setStyle(t),this._textAttributInstance&&this.config.attributeConfigurable===!1&&((e=this._textAttributInstance)==null||e.updateIcon(this.getTextIconSvg()))}setSelectedID(t){var e,i;const s=this.selectedID;t!==s&&s&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(i=this._textAttributInstance)==null||i.clearTextAttribute(),this.selectedID=t,this.render(),this.emit("selectedChange")}getTextIconSvg(t=""){return v.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}clearActiveStatus(){this.hoverID=void 0,this.dragStatus=d.Wait,this.setSelectedID(void 0)}setBasicResult(t){super.setBasicResult(t),this.setNextMarker(),this.clearActiveStatus()}onDragMoveAll(t){var e,i;!((i=(e=this.dragInfo)==null?void 0:e.originPointList)==null?void 0:i.length)||(this.setPointList(this.dragInfo.originPointList.map(s=>P(D({},s),{x:s.x+t.x/this.zoom,y:s.y+t.y/this.zoom}))),this.render())}onMouseDown(t){if(!(super.onMouseDown(t)||this.forbidMouseOperation)){if(t.button===0&&!this.hoverID){this.recoverOperationMode(),this.createPoint(t),this.render();return}if((this.hoverID===this.selectedID||this.isMultiMoveMode&&this.hoverID)&&t.button===0){this.dragStatus=d.Start,this.isMultiMoveMode&&(this.dragInfo={dragStartCoord:this.getCoordinateUnderZoom(t),originPointList:this.pointList});return}return this.render(),!0}}onMouseMove(t){super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo||(this.hoverID=this.getHoverId(),(this.dragStatus===d.Start||this.dragStatus===d.Move)&&this.onDragMove(t),this.hoverID&&this.render())}onMouseUp(t){if(super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo)return!0;t.button===2&&this.rightMouseUp(),this.dragStatus===d.Move&&(this.history.pushHistory(this.pointList),this.dragInfo=void 0),this.dragStatus=d.Wait,this.render()}onDragMove(t){var e,i;if(!this.imgInfo)return;this.dragStatus=d.Move;const s=this.getCoordinateUnderZoom(t);if(this.isMultiMoveMode&&this.dragInfo){const n={x:s.x-this.dragInfo.dragStartCoord.x,y:s.y-this.dragInfo.dragStartCoord.y};this.onDragMoveAll(n);return}const o=c.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.drawOutsideTarget,this.basicResult,this.zoom),l=this.drawOutsideTarget?c.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos):c.changePointByZoom(o,1/this.zoom);this.drawOutsideTarget===!1&&this.dependToolName===p.Polygon&&((i=(e=this.basicResult)==null?void 0:e.pointList)==null?void 0:i.length)>0&&!L.isInPolygon(l,this.basicResult.pointList)||(this.pointList.forEach(n=>{n.id===this.selectedID&&(n.x=l.x,n.y=l.y)}),this.render())}onKeyDown(t){if(!r.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case S.Delete:this.deletePoint();break;case S.Tab:{this.onTabKeyDown(t);break}case S.Z:this.setIsHidden(!this.isHidden),this.render();break;default:{if(this.config.attributeConfigurable){const i=v.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}createPoint(t){var e,i,s,o;if(!this.imgInfo)return;const{upperLimit:l}=this.config;if(l&&this.currentPageResult.length>=l){this.emit("messageInfo",`${y.getMessagesByLocale(C.LowerLimitPoint,this.lang)}`);return}const n=r.getSourceID(this.basicResult),m=this.getCoordinateUnderZoom(t);let u=c.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(this.config.edgeAdsorption&&this.referenceData&&[p.Polygon,p.Line].includes((e=this.referenceData)==null?void 0:e.toolName)){const b=((i=this.referenceData)==null?void 0:i.toolName)===p.Polygon,{dropFoot:I,hasClosed:M}=L.getClosestPoint(u,this.referenceData.result,(o=(s=this.referenceData.config)==null?void 0:s.lineType)!=null?o:A.Line,_/this.zoom,{isClose:b});I&&(u=I),M&&this.emit("messageSuccess",`${y.getMessagesByLocale(C.SuccessfulEdgeAdsorption,this.lang)}`)}if(this.drawOutsideTarget===!1){if(this.dependToolName&&this.basicCanvas){let h=!1;switch(this.dependToolName){case p.Rect:{h=!E.isInRect(u,this.basicResult);break}case p.Polygon:{h=!L.isInPolygon(u,this.basicResult.pointList);break}}if(h)return}if(m.x<0||m.y<0||m.x>this.imgInfo.width||m.y>this.imgInfo.height)return}if(this.isMinDistance(u))return;let a=P(D({},u),{attribute:this.defaultAttribute,valid:!t.ctrlKey,id:H(8,62),sourceID:n,textAttribute:"",order:r.getMaxOrder(this.pointList.filter(h=>r.isSameSourceID(h.sourceID,n)))+1});if(this.config.textConfigurable){let h="";h=v.getTextAttribute(this.pointList.filter(b=>r.isSameSourceID(b.sourceID,n)),this.config.textCheckType),a=P(D({},a),{textAttribute:h})}if(this.hasMarkerConfig){const h=r.getNextMarker(this.currentPageResult,this.config.markerList,this.markerIndex);if(h)a=P(D({},a),{label:h.label}),this.markerIndex=h.index,this.emit("markIndexChange");else{this.emit("messageInfo",y.getMessagesByLocale(C.MarkerFinish,this.lang));return}}this.hoverID=a.id;const f=[...this.pointList,a];this.setPointList(f),this.history.pushHistory(f),this.setSelectedID(a.id)}isInPoint(t,e,i=this.zoom){return(this.style.width+2)/i>=Math.sqrt(T(t.x-e.x,2)+T(t.y-e.y,2))}getHoverId(){var t;const e=c.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos),i=(t=this.pointList)==null?void 0:t.find(s=>this.isInPoint(e,s));return i==null?void 0:i.id}rightMouseUp(){if(this.recoverOperationMode(),this.selectedID===this.hoverID){const e=this.pointList.filter(i=>i.id!==this.selectedID);this.setPointList(e),this.history.pushHistory(e),this.setSelectedID(""),this.hoverID="";return}const t=this.pointList.find(e=>e.id===this.hoverID);if(this.setSelectedID(this.hoverID),this.setDefaultAttribute(t==null?void 0:t.attribute),(t==null?void 0:t.label)&&this.hasMarkerConfig){const e=r.getCurrentMarkerIndex(t.label,this.config.markerList);e>=0&&(this.setMarkerIndex(e),this.emit("markIndexChange"))}}onTabKeyDown(t){if(t.preventDefault(),this.dragStatus===d.Move||this.dragStatus===d.Start)return;let e=k.ascend;t.shiftKey&&(e=k.descend);const[i,s]=r.getRenderResultList(this.pointList,r.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let o=[...i];s&&(o=[...o,s]);const l=r.getNextSelectedRectID(o,e,this.selectedID);l&&this.setSelectedID(l.id)}get currentPageResult(){const[t]=r.getRenderResultList(this.pointList,r.getSourceID(this.basicResult),[]);return t}getCurrentPageResult(t){const[e]=r.getRenderResultList(t,r.getSourceID(this.basicResult),[]);return e}exportData(){const{pointList:t}=this;return[t,this.basicImgInfo]}deletePoint(){var t;this.selectedID&&(this.setPointList(this.pointList.filter(e=>e.id!==this.selectedID)),this.history.pushHistory(this.pointList),(t=this._textAttributInstance)==null||t.clearTextAttribute(),this.emit("selectedChange"),this.render())}undoAndRedo(t){var e,i;if(this.dragStatus===d.Move||this.dragStatus===d.Start)return;const s=(i=(e=this.history)[t])==null?void 0:i.call(e);(s==null?void 0:s.some(o=>o.id===this.selectedID))||this.setSelectedID(""),s&&(this.setPointList(s,!0),this.render())}undo(){this.undoAndRedo("undo")}redo(){this.undoAndRedo("redo")}getCurrentSelectedData(){var t;if(!this.selectedID)return;const e=(t=this.pointList)==null?void 0:t.find(o=>o.id===this.selectedID),i=this.getColor(e==null?void 0:e.attribute),s=(e==null?void 0:e.valid)?i==null?void 0:i.valid.stroke:i==null?void 0:i.invalid.stroke;return this.dragStatus=d.Wait,{width:R*this.zoom*.6,textAttribute:(e==null?void 0:e.textAttribute)||"",color:s}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;v.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",v.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPointList(v.textChange(e,this.selectedID,this.pointList)),this.emit("updateTextAttribute"),this.render()}}renderTextAttribute(){var t,e;const i=(t=this.pointList)==null?void 0:t.find(b=>b.id===this.selectedID);if(!this.ctx||this.config.textConfigurable!==!0||!i)return;const{x:s,y:o,attribute:l,valid:n}=i,m=R*this.zoom*.6,u=c.getOffsetCoordinate({x:s,y:o},this.currentPos,this.zoom),a=this.getColor(l),f=n?a==null?void 0:a.valid.stroke:a==null?void 0:a.invalid.stroke,h=4;this._textAttributInstance||(this._textAttributInstance=new W({width:m,container:this.container,icon:this.getTextIconSvg(l),color:f,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributInstance&&!((e=this._textAttributInstance)==null?void 0:e.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${i.textAttribute}`,{left:u.x,top:u.y+h,color:f,width:m})}renderPoint(t,e=!1){var i,s,o;const{textAttribute:l="",attribute:n}=t,m=e||t.id===this.selectedID,u=this.getColor(n),a=c.changePointByZoom(t,this.zoom,this.currentPos),{width:f=2,hiddenText:h=!1}=this.style,b=B.getStrokeAndFill(u,t.valid,{isSelected:m||t.id===this.hoverID});x.drawCircle(this.canvas,a,f,{startAngleDeg:0,endAngleDeg:360,thickness:1,color:b.stroke,fill:b.fill});let I="";(((i=this.config)==null?void 0:i.isShowOrder)||((s=this.config)==null?void 0:s.showOrder))&&t.order&&(t==null?void 0:t.order)>0&&(I=`${t.order}`),t.label&&this.hasMarkerConfig&&(I=`${r.getCurrentMarkerIndex(t.label,this.config.markerList)+1}_${j.getMarkerShowText(t.label,this.config.markerList)}`),t.attribute&&(I=`${I} ${v.getAttributeShowText(t.attribute,(o=this.config)==null?void 0:o.attributeList)}`),h||x.drawText(this.canvas,{x:a.x+f/2,y:a.y-f-4},I,{textAlign:"center",color:b.stroke}),m?this.renderTextAttribute():h||x.drawText(this.canvas,{x:a.x+f,y:a.y+f+24},l,D({color:b.stroke},N))}renderMultiSelectedPoint(){!this.isMultiMoveMode||this.pointList.forEach(t=>{this.renderPoint(t,!0)})}renderPointList(){switch(this.operationMode){case U.MultiMove:this.renderMultiSelectedPoint();break;default:{const[t,e]=r.getRenderResultList(this.pointList,r.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);this.isHidden||t.forEach(i=>{this.renderPoint(i)}),e&&this.renderPoint(e)}}}renderTop(){var t,e,i;const s=this.getLineColor(this.defaultAttribute);if(this.renderCursorLine(s),this.config.edgeAdsorption&&this.referenceData){let o=c.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);const l=((t=this.referenceData)==null?void 0:t.toolName)===p.Polygon,{dropFoot:n}=L.getClosestPoint(o,this.referenceData.result,(i=(e=this.referenceData.config)==null?void 0:e.lineType)!=null?i:A.Line,_/this.zoom,{isClose:l});n&&o!==n&&o!==n&&(o=n,x.drawCircle(this.canvas,c.changePointByZoom(o,this.zoom,this.currentPos),5,{color:"white",fill:"white"}),x.drawCircle(this.canvas,c.changePointByZoom(o,this.zoom,this.currentPos),3,{fill:s,color:s}))}}render(){!this.ctx||(super.render(),this.renderPointList(),this.renderTop())}}export{q as default};
|
|
1
|
+
import{EToolName as p,ELineTypes as k,edgeAdsorptionScope as _,EOperationMode as E}from"../../constant/tool.js";import j from"../../utils/tool/RectUtils.js";import D from"../../utils/tool/PolygonUtils.js";import P from"../../utils/tool/MarkerUtils.js";import z from"../../utils/MathUtils.js";import{EDragStatus as g,ESortDirection as w,DEFAULT_TEXT_OFFSET as N}from"../../constant/annotation.js";import S from"../../constant/keyCode.js";import C from"../../locales/index.js";import{EMessage as A}from"../../locales/constants.js";import I from"../../utils/tool/AttributeUtils.js";import c from"../../utils/tool/AxisUtils.js";import r from"../../utils/tool/CommonToolUtils.js";import x from"../../utils/tool/DrawUtils.js";import B from"../../utils/tool/StyleUtils.js";import Z from"../../utils/uuid.js";import{BasicToolOperation as H}from"./basicToolOperation.js";import W from"./textAttributeClass.js";var F=Object.defineProperty,K=Object.defineProperties,$=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertySymbols,V=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,R=Math.pow,O=(m,t,e)=>t in m?F(m,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):m[t]=e,L=(m,t)=>{for(var e in t||(t={}))V.call(t,e)&&O(m,e,t[e]);if(T)for(var e of T(t))X.call(t,e)&&O(m,e,t[e]);return m},y=(m,t)=>K(m,$(t));const U=200;class q extends H{constructor(t){super(t);this.setMarkerIndex=e=>{this.markerIndex=e},this.setMarkerIndexAndSelect=e=>{if(!this.config.markerList)return;this.markerIndex=e;const i=this.config.markerList[e].value,s=this.currentPageResult.find(o=>o.label===i);s&&(this.setSelectedID(s.id),this.config.attributeConfigurable===!0&&this.setDefaultAttribute(s.attribute)),this.emit("markIndexChange")},this.textChange=e=>{this.config.textConfigurable!==!0||!this.selectedID||(this.setPointList(I.textChange(e,this.selectedID,this.pointList)),this.emit("selectedChange"),this.render())},this.isMinDistance=e=>{const i=c.changePointByZoom(e,this.zoom);return this.pointList.some(s=>{const o=c.changePointByZoom(s,this.zoom);return z.getLineLength(o,i)<.2})},this.config=r.jsonParser(t.config),this.pointList=[],this.markerIndex=0,this.setStyle(t.style),this.createPoint=this.createPoint.bind(this),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this),this.setSelectedID=this.setSelectedID.bind(this)}get dataList(){return this.pointList}get drawOutsideTarget(){var t;return(t=this.config.drawOutsideTarget)!=null?t:this.config.drawPointOut}setNextMarker(t=this.pointList){if(this.hasMarkerConfig){const e=r.getNextMarker(this.getCurrentPageResult(t),this.config.markerList);e&&this.setMarkerIndexAndSelect(e.index)}}setResult(t){this.clearActiveStatus(),this.setPointList(t),this.setNextMarker(t),this.recoverOperationMode(),this.render()}setPointList(t,e=!1){const i=this.pointList.length;this.pointList=t,i!==t.length&&this.emit("updatePageNumber"),e&&this.emit("updateResult")}setConfig(t,e=!1){this.config=r.jsonParser(t),e===!0&&this.clearResult()}clearResult(){this.setPointList([]),this.setSelectedID(void 0),this.history.pushHistory([]),this.hoverID="",this.render()}setDefaultAttribute(t=""){const e=this.defaultAttribute;if(this.defaultAttribute=t,e!==t){this.changeStyle(t),this.emit("changeAttributeSidebar");const{selectedID:i}=this;if(i&&(this.pointList.forEach(s=>{s.id===i&&(s.attribute=t)}),this.history.pushHistory(this.pointList),this.render()),this._textAttributInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(t)){this._textAttributInstance.clearTextAttribute();return}this._textAttributInstance.updateIcon(this.getTextIconSvg(t))}}}get selectedText(){var t;return(t=this.pointList.find(e=>e.id===this.selectedID))==null?void 0:t.textAttribute}setStyle(t){var e;super.setStyle(t),this._textAttributInstance&&this.config.attributeConfigurable===!1&&((e=this._textAttributInstance)==null||e.updateIcon(this.getTextIconSvg()))}setSelectedID(t){var e,i;const s=this.selectedID;t!==s&&s&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(i=this._textAttributInstance)==null||i.clearTextAttribute(),this.selectedID=t,this.render(),this.emit("selectedChange")}getTextIconSvg(t=""){return I.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}clearActiveStatus(){this.hoverID=void 0,this.dragStatus=g.Wait,this.setSelectedID(void 0)}setBasicResult(t){super.setBasicResult(t),this.setNextMarker(),this.clearActiveStatus()}onDragMoveAll(t){var e,i;!((i=(e=this.dragInfo)==null?void 0:e.originPointList)==null?void 0:i.length)||(this.setPointList(this.dragInfo.originPointList.map(s=>y(L({},s),{x:s.x+t.x/this.zoom,y:s.y+t.y/this.zoom}))),this.render())}onMouseDown(t){if(!(super.onMouseDown(t)||this.forbidMouseOperation)){if(t.button===0&&!this.hoverID){this.recoverOperationMode(),this.createPoint(t),this.render();return}if((this.hoverID===this.selectedID||this.isMultiMoveMode&&this.hoverID)&&t.button===0){this.dragStatus=g.Start,this.isMultiMoveMode&&(this.dragInfo={dragStartCoord:this.getCoordinateUnderZoom(t),originPointList:this.pointList});return}return this.render(),!0}}onMouseMove(t){super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo||(this.hoverID=this.getHoverId(),(this.dragStatus===g.Start||this.dragStatus===g.Move)&&this.onDragMove(t),this.hoverID&&this.render())}onMouseUp(t){if(super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo)return!0;t.button===2&&this.rightMouseUp(),this.dragStatus===g.Move&&(this.history.pushHistory(this.pointList),this.dragInfo=void 0),this.dragStatus=g.Wait,this.render()}onDragMove(t){var e,i;if(!this.imgInfo)return;this.dragStatus=g.Move;const s=this.getCoordinateUnderZoom(t);if(this.isMultiMoveMode&&this.dragInfo){const a={x:s.x-this.dragInfo.dragStartCoord.x,y:s.y-this.dragInfo.dragStartCoord.y};this.onDragMoveAll(a);return}const o=c.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.drawOutsideTarget,this.basicResult,this.zoom),l=this.drawOutsideTarget?c.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos):c.changePointByZoom(o,1/this.zoom);this.drawOutsideTarget===!1&&this.dependToolName===p.Polygon&&((i=(e=this.basicResult)==null?void 0:e.pointList)==null?void 0:i.length)>0&&!D.isInPolygon(l,this.basicResult.pointList)||(this.pointList.forEach(a=>{a.id===this.selectedID&&(a.x=l.x,a.y=l.y)}),this.render())}onKeyDown(t){if(!r.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case S.Delete:this.deletePoint();break;case S.Tab:{this.onTabKeyDown(t);break}case S.Z:this.setIsHidden(!this.isHidden),this.render();break;default:{if(this.config.attributeConfigurable){const i=I.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}createPoint(t){var e,i,s,o;if(!this.imgInfo)return;const{upperLimit:l}=this.config;if(l&&this.currentPageResult.length>=l){this.emit("messageInfo",`${C.getMessagesByLocale(A.LowerLimitPoint,this.lang)}`);return}const a=r.getSourceID(this.basicResult),u=this.getCoordinateUnderZoom(t);let d=c.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(this.config.edgeAdsorption&&this.referenceData&&[p.Polygon,p.Line].includes((e=this.referenceData)==null?void 0:e.toolName)){const b=((i=this.referenceData)==null?void 0:i.toolName)===p.Polygon,{dropFoot:v,hasClosed:M}=D.getClosestPoint(d,this.referenceData.result,(o=(s=this.referenceData.config)==null?void 0:s.lineType)!=null?o:k.Line,_/this.zoom,{isClose:b});v&&(d=v),M&&this.emit("messageSuccess",`${C.getMessagesByLocale(A.SuccessfulEdgeAdsorption,this.lang)}`)}if(this.drawOutsideTarget===!1){if(this.dependToolName&&this.basicCanvas){let h=!1;switch(this.dependToolName){case p.Rect:{h=!j.isInRect(d,this.basicResult);break}case p.Polygon:{h=!D.isInPolygon(d,this.basicResult.pointList);break}}if(h)return}if(u.x<0||u.y<0||u.x>this.imgInfo.width||u.y>this.imgInfo.height)return}if(this.isMinDistance(d))return;let n=y(L({},d),{attribute:this.defaultAttribute,valid:!t.ctrlKey,id:Z(8,62),sourceID:a,textAttribute:"",order:r.getMaxOrder(this.pointList.filter(h=>r.isSameSourceID(h.sourceID,a)))+1});if(this.config.textConfigurable){let h="";h=I.getTextAttribute(this.pointList.filter(b=>r.isSameSourceID(b.sourceID,a)),this.config.textCheckType),n=y(L({},n),{textAttribute:h})}if(this.hasMarkerConfig){const h=r.getNextMarker(this.currentPageResult,this.config.markerList,this.markerIndex);if(h)n=y(L({},n),{label:h.label}),this.markerIndex=h.index,this.emit("markIndexChange");else{this.emit("messageInfo",C.getMessagesByLocale(A.MarkerFinish,this.lang));return}}this.hoverID=n.id;const f=[...this.pointList,n];this.setPointList(f),this.history.pushHistory(f),this.setSelectedID(n.id)}isInPoint(t,e,i=this.zoom){return(this.style.width+2)/i>=Math.sqrt(R(t.x-e.x,2)+R(t.y-e.y,2))}getHoverId(){var t;const e=c.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos),i=(t=this.pointList)==null?void 0:t.find(s=>this.isInPoint(e,s));return i==null?void 0:i.id}rightMouseUp(){if(this.recoverOperationMode(),this.selectedID===this.hoverID){const e=this.pointList.filter(i=>i.id!==this.selectedID);this.setPointList(e),this.history.pushHistory(e),this.setSelectedID(""),this.hoverID="";return}const t=this.pointList.find(e=>e.id===this.hoverID);if(this.setSelectedID(this.hoverID),this.setDefaultAttribute(t==null?void 0:t.attribute),(t==null?void 0:t.label)&&this.hasMarkerConfig){const e=r.getCurrentMarkerIndex(t.label,this.config.markerList);e>=0&&(this.setMarkerIndex(e),this.emit("markIndexChange"))}}onTabKeyDown(t){if(t.preventDefault(),this.dragStatus===g.Move||this.dragStatus===g.Start)return;let e=w.ascend;t.shiftKey&&(e=w.descend);const[i,s]=r.getRenderResultList(this.pointList,r.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let o=[...i];s&&(o=[...o,s]);const l=r.getNextSelectedRectID(o,e,this.selectedID);l&&this.setSelectedID(l.id)}get currentPageResult(){const[t]=r.getRenderResultList(this.pointList,r.getSourceID(this.basicResult),[]);return t}getCurrentPageResult(t){const[e]=r.getRenderResultList(t,r.getSourceID(this.basicResult),[]);return e}exportData(){const{pointList:t}=this;return[t,this.basicImgInfo]}deletePoint(){var t;this.selectedID&&(this.setPointList(this.pointList.filter(e=>e.id!==this.selectedID)),this.history.pushHistory(this.pointList),(t=this._textAttributInstance)==null||t.clearTextAttribute(),this.emit("selectedChange"),this.render())}undoAndRedo(t){var e,i;if(this.dragStatus===g.Move||this.dragStatus===g.Start)return;const s=(i=(e=this.history)[t])==null?void 0:i.call(e);(s==null?void 0:s.some(o=>o.id===this.selectedID))||this.setSelectedID(""),s&&(this.setPointList(s,!0),this.render())}undo(){this.undoAndRedo("undo")}redo(){this.undoAndRedo("redo")}getCurrentSelectedData(){var t;if(!this.selectedID)return;const e=(t=this.pointList)==null?void 0:t.find(o=>o.id===this.selectedID),i=this.getColor(e==null?void 0:e.attribute),s=(e==null?void 0:e.valid)?i==null?void 0:i.valid.stroke:i==null?void 0:i.invalid.stroke;return this.dragStatus=g.Wait,{width:U*this.zoom*.6,textAttribute:(e==null?void 0:e.textAttribute)||"",color:s}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;I.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",I.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPointList(I.textChange(e,this.selectedID,this.pointList)),this.emit("updateTextAttribute"),this.render()}}renderTextAttribute(){var t,e;const i=(t=this.pointList)==null?void 0:t.find(b=>b.id===this.selectedID);if(!this.ctx||this.config.textConfigurable!==!0||!i)return;const{x:s,y:o,attribute:l,valid:a}=i,u=U*this.zoom*.6,d=c.getOffsetCoordinate({x:s,y:o},this.currentPos,this.zoom),n=this.getColor(l),f=a?n==null?void 0:n.valid.stroke:n==null?void 0:n.invalid.stroke,h=4;this._textAttributInstance||(this._textAttributInstance=new W({width:u,container:this.container,icon:this.getTextIconSvg(l),color:f,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributInstance&&!((e=this._textAttributInstance)==null?void 0:e.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${i.textAttribute}`,{left:d.x,top:d.y+h,color:f,width:u})}renderPoint(t,e=!1){var i,s,o;const{textAttribute:l="",attribute:a}=t,u=e||t.id===this.selectedID,d=this.getColor(a),n=c.changePointByZoom(t,this.zoom,this.currentPos),{width:f=2,hiddenText:h=!1}=this.style,b=B.getStrokeAndFill(d,t.valid,{isSelected:u||t.id===this.hoverID});x.drawCircle(this.canvas,n,f,{startAngleDeg:0,endAngleDeg:360,thickness:1,color:b.stroke,fill:b.fill});let v="";(((i=this.config)==null?void 0:i.isShowOrder)||((s=this.config)==null?void 0:s.showOrder))&&t.order&&(t==null?void 0:t.order)>0&&(v=`${t.order}`),t.label&&this.hasMarkerConfig&&(v=`${r.getCurrentMarkerIndex(t.label,this.config.markerList)+1}_${P.getMarkerShowText(t.label,this.config.markerList)}`),t.attribute&&(v=`${v} ${I.getAttributeShowText(t.attribute,(o=this.config)==null?void 0:o.attributeList)}`),h||x.drawText(this.canvas,{x:n.x+f/2,y:n.y-f-4},v,{textAlign:"center",color:b.stroke}),u?this.renderTextAttribute():h||x.drawText(this.canvas,{x:n.x+f,y:n.y+f+24},l,L({color:b.stroke},N))}renderMultiSelectedPoint(){!this.isMultiMoveMode||this.pointList.forEach(t=>{this.renderPoint(t,!0)})}renderPointList(){switch(this.operationMode){case E.MultiMove:this.renderMultiSelectedPoint();break;default:{const[t,e]=r.getRenderResultList(this.pointList,r.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);this.isHidden||t.forEach(i=>{this.renderPoint(i)}),e&&this.renderPoint(e)}}}renderAuxiliaryLine(){var t;if(!this.config.markerConfigurable||!((t=this.config.markerList)==null?void 0:t.length))return;const[e,i]=r.getRenderResultList(this.pointList,r.getSourceID(this.basicResult),this.attributeLockList,this.selectedID),s=e;if(i&&s.push(i),s.length<2)return;const o=P.getAuxiliaryLineByMarkerList(this.config.markerList,"value");P.getAuxiliaryLineCoord(o,s).forEach(a=>{const{start:u,end:d}=a,n=c.changePointListByZoom([u,d],this.zoom,this.currentPos);x.drawLine(this.canvas,n[0],n[1],{color:"#C5C5C5"})})}renderTop(){var t,e,i;const s=this.getLineColor(this.defaultAttribute);if(this.renderCursorLine(s),this.config.edgeAdsorption&&this.referenceData){let o=c.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);const l=((t=this.referenceData)==null?void 0:t.toolName)===p.Polygon,{dropFoot:a}=D.getClosestPoint(o,this.referenceData.result,(i=(e=this.referenceData.config)==null?void 0:e.lineType)!=null?i:k.Line,_/this.zoom,{isClose:l});a&&o!==a&&o!==a&&(o=a,x.drawCircle(this.canvas,c.changePointByZoom(o,this.zoom,this.currentPos),5,{color:"white",fill:"white"}),x.drawCircle(this.canvas,c.changePointByZoom(o,this.zoom,this.currentPos),3,{fill:s,color:s}))}}render(){!this.ctx||(super.render(),this.renderAuxiliaryLine(),this.renderPointList(),this.renderTop())}}export{q as default};
|