@labelbee/lb-annotation 1.27.0-alpha.7 → 1.27.0-alpha.71

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.
Files changed (47) hide show
  1. package/dist/_virtual/highlightWorker.js +1 -1
  2. package/dist/constant/keyCode.js +1 -1
  3. package/dist/constant/tool.js +1 -1
  4. package/dist/core/pointCloud/OrbitControls.js +1 -1
  5. package/dist/core/pointCloud/index.js +4 -2
  6. package/dist/core/pointCloud/matrix.js +1 -1
  7. package/dist/core/pointCloud/omniCamera.js +1 -1
  8. package/dist/core/toolOperation/ViewOperation.js +1 -1
  9. package/dist/core/toolOperation/basicToolOperation.js +1 -1
  10. package/dist/core/toolOperation/pointCloud2DRectOperation.js +1 -1
  11. package/dist/core/toolOperation/pointOperation.js +1 -1
  12. package/dist/core/toolOperation/polygonOperation.js +1 -1
  13. package/dist/core/toolOperation/rectOperation.js +2 -1
  14. package/dist/core/toolOperation/utils/reCalcRect.js +1 -0
  15. package/dist/types/constant/keyCode.d.ts +1 -0
  16. package/dist/types/constant/tool.d.ts +2 -1
  17. package/dist/types/core/pointCloud/index.d.ts +50 -3
  18. package/dist/types/core/toolOperation/ViewOperation.d.ts +22 -1
  19. package/dist/types/core/toolOperation/basicToolOperation.d.ts +1 -0
  20. package/dist/types/core/toolOperation/pointCloud2DRectOperation.d.ts +11 -2
  21. package/dist/types/core/toolOperation/pointOperation.d.ts +4 -0
  22. package/dist/types/core/toolOperation/polygonOperation.d.ts +2 -0
  23. package/dist/types/core/toolOperation/rectOperation.d.ts +22 -5
  24. package/dist/types/core/toolOperation/utils/reCalcRect.d.ts +9 -0
  25. package/dist/types/utils/MathUtils.d.ts +7 -0
  26. package/dist/types/utils/tool/AxisUtils.d.ts +3 -0
  27. package/dist/types/utils/tool/PolygonUtils.d.ts +13 -0
  28. package/dist/types/utils/tool/RectUtils.d.ts +3 -0
  29. package/dist/utils/MathUtils.js +1 -1
  30. package/dist/utils/tool/PolygonUtils.js +1 -1
  31. package/es/_virtual/highlightWorker.js +1 -1
  32. package/es/constant/keyCode.js +1 -1
  33. package/es/constant/tool.js +1 -1
  34. package/es/core/pointCloud/OrbitControls.js +1 -1
  35. package/es/core/pointCloud/index.js +4 -2
  36. package/es/core/pointCloud/matrix.js +1 -1
  37. package/es/core/pointCloud/omniCamera.js +1 -1
  38. package/es/core/toolOperation/ViewOperation.js +1 -1
  39. package/es/core/toolOperation/basicToolOperation.js +1 -1
  40. package/es/core/toolOperation/pointCloud2DRectOperation.js +1 -1
  41. package/es/core/toolOperation/pointOperation.js +1 -1
  42. package/es/core/toolOperation/polygonOperation.js +1 -1
  43. package/es/core/toolOperation/rectOperation.js +2 -1
  44. package/es/core/toolOperation/utils/reCalcRect.js +1 -0
  45. package/es/utils/MathUtils.js +2 -2
  46. package/es/utils/tool/PolygonUtils.js +1 -1
  47. package/package.json +2 -2
@@ -98,6 +98,7 @@ declare class PolygonOperation extends BasicToolOperation {
98
98
  */
99
99
  setPolygonDataByID(newPolygonData: Partial<IPolygonData>, id?: string): IPolygonData[];
100
100
  rotatePolygon(angle?: number, direction?: ERotateDirection, selectedID?: string | undefined): void;
101
+ rotatePolygonEdge(pointList: IPolygonPoint[], selectedID?: string | undefined): void;
101
102
  addPointInDrawing(e: MouseEvent): void;
102
103
  clearResult(): void;
103
104
  /**
@@ -184,6 +185,7 @@ declare class PolygonOperation extends BasicToolOperation {
184
185
  */
185
186
  emitUpdatePolygonByDrag: () => void;
186
187
  leftMouseUpdateValid(e: MouseEvent): boolean;
188
+ stopDrag(): void;
187
189
  leftMouseUp(e: MouseEvent): void;
188
190
  onMouseUp(e: MouseEvent): undefined;
189
191
  dragMouseUp(): void;
@@ -10,6 +10,7 @@ declare class RectOperation extends BasicToolOperation {
10
10
  firstCurrentPos?: ICoordinate;
11
11
  rectList: IRect[];
12
12
  hoverRectID?: string;
13
+ selectedRectTextAttribute: string;
13
14
  hoverRectPointIndex: number;
14
15
  hoverRectEdgeIndex: number;
15
16
  isFlow: boolean;
@@ -20,6 +21,9 @@ declare class RectOperation extends BasicToolOperation {
20
21
  private selection;
21
22
  private dragInfo?;
22
23
  private highlightVisible;
24
+ /** Whether or not add rect */
25
+ private enableAddRect;
26
+ renderPointCloud2DHighlight(): void;
23
27
  constructor(props: IRectOperationProps);
24
28
  setResult(rectList: IRect[]): void;
25
29
  destroy(): void;
@@ -72,7 +76,12 @@ declare class RectOperation extends BasicToolOperation {
72
76
  setMarkerIndexAndSelect: (markerIndex: number) => void;
73
77
  /** 更新文本输入,并且进行关闭 */
74
78
  updateSelectedRectTextAttribute(newTextAttribute?: string): void;
79
+ updateSelectedRectSubAttribute(key: string, value: string): void;
75
80
  getHoverRectID: (e: MouseEvent) => string;
81
+ /**
82
+ * 获取当前选中rect的文本
83
+ */
84
+ getSelectedRectTextAttribute: (hoverRectID: string) => string;
76
85
  /**
77
86
  * 获取当前的选中部分的hoverIndex
78
87
  * ../../../param e
@@ -100,6 +109,9 @@ declare class RectOperation extends BasicToolOperation {
100
109
  isHighlight?: boolean | undefined;
101
110
  label?: string | undefined;
102
111
  lineDash?: number[] | undefined;
112
+ subAttribute?: {
113
+ [key: string]: string;
114
+ } | undefined;
103
115
  };
104
116
  getRectsBoundaries(rects: IRect[], offset: ICoordinate): {
105
117
  top: number;
@@ -130,6 +142,7 @@ declare class RectOperation extends BasicToolOperation {
130
142
  setAttributeLockList(attributeLockList: string[]): void;
131
143
  setBasicResult(basicResult: any): void;
132
144
  setRectValidAndRender(id: string): void;
145
+ setDefaultSubAttribute: () => void;
133
146
  createNewDrawingRect(e: MouseEvent, basicSourceID: string): void;
134
147
  /**
135
148
  * 将绘制中的框体添加进 rectList 中
@@ -142,12 +155,14 @@ declare class RectOperation extends BasicToolOperation {
142
155
  * mouseup 下的鼠标右键
143
156
  * @param e
144
157
  */
145
- rightMouseUp(e: MouseEvent): void;
158
+ rightMouseUp(e: MouseEvent): IRect | undefined;
146
159
  shiftRightMouseUp(e: MouseEvent): void;
147
160
  updateDragResult(): void;
161
+ /** Allow/Disallow to add rect to rectList */
162
+ setEnableAddRect(isEnableAddRect: boolean): void;
148
163
  onMouseUp(e: MouseEvent): true | undefined;
149
164
  onRightDblClick(e: MouseEvent): void;
150
- deleteSelectedRect(): void;
165
+ deleteSelectedRect(e: UIEvent): void;
151
166
  onKeyDown(e: KeyboardEvent): true | undefined;
152
167
  onKeyUp(e: KeyboardEvent): void;
153
168
  onWheel(e: MouseEvent): void;
@@ -173,10 +188,10 @@ declare class RectOperation extends BasicToolOperation {
173
188
  /**
174
189
  * 绘制当前框的
175
190
  * @param rect 当前矩形框
176
- * @param zoom 是否进行缩放
177
- * @param isZoom 矩形框是否为缩放后的比例
191
+ * @param zoom 缩放比例
192
+ * @param isZoom 是否进行缩放
178
193
  */
179
- renderDrawingRect(rect: IRect, zoom?: number, isZoom?: boolean): void;
194
+ renderDrawingRect(rect: IRect, zoom?: number, isZoom?: boolean, isPointCloud2DHighlight?: boolean): void;
180
195
  /**
181
196
  * 渲染静态框体
182
197
  */
@@ -193,6 +208,7 @@ declare class RectOperation extends BasicToolOperation {
193
208
  render(): void;
194
209
  setDefaultAttribute(defaultAttribute?: string): void;
195
210
  setValid(valid: boolean): void;
211
+ private clearDrawingStatus;
196
212
  /**
197
213
  * 清楚所有的中间状态
198
214
  */
@@ -207,6 +223,7 @@ declare class RectOperation extends BasicToolOperation {
207
223
  undo(): void;
208
224
  /** 重做 */
209
225
  redo(): void;
226
+ setHoverRectID(id: string): void;
210
227
  }
211
228
  export { RectOperation, IRectOperationProps };
212
229
  export default RectOperation;
@@ -0,0 +1,9 @@
1
+ interface RectInfo {
2
+ width: number;
3
+ height: number;
4
+ x: number;
5
+ y: number;
6
+ noChange?: boolean;
7
+ }
8
+ declare const reCalcRect: (curRect: RectInfo, targetRect: RectInfo, scaleWidth: number, scaleHeight: number) => RectInfo;
9
+ export default reCalcRect;
@@ -185,5 +185,12 @@ export default class MathUtils {
185
185
  static getModifiedRectangleCoordinates(coordinates: ICoordinate[], newWidth: number, newHeight: number): ICoordinate[];
186
186
  static calculatePointsInsideBox: (params: ICalculatePointsInsideBoxParams) => number;
187
187
  static isPointInsideCube(point: I3DSpaceCoord, polygon: IPolygonPoint[], zScope: [number, number]): boolean;
188
+ static getCurrentPosFromRectCenter(size: {
189
+ width: number;
190
+ height: number;
191
+ }, centerPoint: IPolygonPoint, zoom: number): {
192
+ x: number;
193
+ y: number;
194
+ };
188
195
  }
189
196
  export {};
@@ -36,6 +36,9 @@ export default class AxisUtils {
36
36
  isHighlight?: boolean | undefined;
37
37
  label?: string | undefined;
38
38
  lineDash?: number[] | undefined;
39
+ subAttribute?: {
40
+ [key: string]: string;
41
+ } | undefined;
39
42
  };
40
43
  /**
41
44
  * 计算点在 zoom 和 currentPos 的转换
@@ -1,6 +1,13 @@
1
1
  import { ERotateDirection } from '@/constant/annotation';
2
+ import { TAnnotationViewData, TAnnotationViewLine } from '@labelbee/lb-utils';
2
3
  import { IPolygonData, IPolygonPoint } from '../../types/tool/polygon';
3
4
  import { ELineTypes } from '../../constant/tool';
5
+ export interface IConvexHullGroupType {
6
+ [id: string]: {
7
+ points: TAnnotationViewLine['annotation']['pointList'];
8
+ convexHull: ICoordinate[];
9
+ };
10
+ }
4
11
  export default class PolygonUtils {
5
12
  static getHoverPolygonID(checkPoint: IPolygonPoint, polygonPoints: {
6
13
  pointList: IPolygonPoint[];
@@ -13,6 +20,7 @@ export default class PolygonUtils {
13
20
  */
14
21
  static calcPolygonSize(pointList?: IPolygonPoint[]): number;
15
22
  static isInPolygon(checkPoint: IPolygonPoint, polygonPoints: (IPolygonPoint | ICoordinate)[], lineType?: ELineTypes): boolean;
23
+ static isPointInOrOnPolygon(point: IPolygonPoint, polygonData: (IPolygonPoint | ICoordinate)[], errorMargin?: number): boolean;
16
24
  /**
17
25
  * 通过数据转换为平滑曲线的点提交 [{x: number, y: number}...] => [x, ...smoothCurvePoints ,y]
18
26
  * @param pointList
@@ -129,4 +137,9 @@ export default class PolygonUtils {
129
137
  * @param polygonList
130
138
  */
131
139
  static composeSegmentPolygonList(polygonList: any[]): any[];
140
+ /**
141
+ * Convex hull algorithm - Graham scan
142
+ */
143
+ static computeConvexHull(points: IPolygonPoint[]): IPolygonPoint[];
144
+ static createConvexHullGroup(annotations: TAnnotationViewData[]): IConvexHullGroupType;
132
145
  }
@@ -60,6 +60,9 @@ export default class RectUtils {
60
60
  isHighlight?: boolean | undefined;
61
61
  label?: string | undefined;
62
62
  lineDash?: number[] | undefined;
63
+ subAttribute?: {
64
+ [key: string]: string;
65
+ } | undefined;
63
66
  };
64
67
  /**
65
68
  * 判断当前矩形是否不在多边形内
@@ -1,2 +1,2 @@
1
1
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var MathUtilsWorker=require("../_virtual/MathUtilsWorker.js"),tool=require("../constant/tool.js"),polygonTool=require("./tool/polygonTool.js"),PolygonUtils=require("./tool/PolygonUtils.js"),VectorUtils=require("./VectorUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__pow=Math.pow,__defNormalProp=(e,n,t)=>n in e?__defProp(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,__spreadValues=(e,n)=>{for(var t in n||(n={}))__hasOwnProp.call(n,t)&&__defNormalProp(e,t,n[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(n))__propIsEnum.call(n,t)&&__defNormalProp(e,t,n[t]);return e},__spreadProps=(e,n)=>__defProps(e,__getOwnPropDescs(n));class Trigonometric{static tanAPlusB(n,t){return(n+t)/(1-n*t)}static sinAPlusB(n,t,i,o){return o*n+t*i}static cosAPlusB(n,t,i,o){return t*o-n*i}}var CubePosition;(function(e){e[e.Outside=0]="Outside",e[e.PartiallyInside=1]="PartiallyInside",e[e.FullyInside=2]="FullyInside"})(CubePosition||(CubePosition={}));function getCubePosition(e,n,t){const i=[{x:t.x-t.width/2,y:t.y-t.height/2,z:t.z-t.depth/2},{x:t.x+t.width/2,y:t.y-t.height/2,z:t.z-t.depth/2},{x:t.x-t.width/2,y:t.y+t.height/2,z:t.z-t.depth/2},{x:t.x+t.width/2,y:t.y+t.height/2,z:t.z-t.depth/2},{x:t.x-t.width/2,y:t.y-t.height/2,z:t.z+t.depth/2},{x:t.x+t.width/2,y:t.y-t.height/2,z:t.z+t.depth/2},{x:t.x-t.width/2,y:t.y+t.height/2,z:t.z+t.depth/2},{x:t.x+t.width/2,y:t.y+t.height/2,z:t.z+t.depth/2}];let o=0;for(let s=0;s<i.length;s++)MathUtils.isPointInsideCube(i[s],e,n)&&o++;return o===0?0:o===8?2:1}const _MathUtils=class{static getRotate(e){return e+90>=360?e+90-360:e+90}static getLineLength(e,n){return Math.sqrt(Math.pow(n.y-e.y,2)+Math.pow(n.x-e.x,2))}static getTextArea(e,n,t=tool.DEFAULT_TEXT_MAX_WIDTH,i=tool.DEFAULT_FONT,o){if(typeof n!="string")return{width:0,height:0};const s=e.getContext("2d");s.font=i;let r=0;typeof o=="undefined"&&(o=e&&parseInt(window.getComputedStyle(e).lineHeight,10)||parseInt(window.getComputedStyle(document.body).lineHeight,10));const a=e&&parseInt(window.getComputedStyle(e).fontSize,10)||parseInt(window.getComputedStyle(document.body).fontSize,10)||0,c=n.split(`
2
- `);let y=0;for(let h=0;h<c.length;h++){const f=c[h].split("");let g="";for(let d=0;d<f.length;d++){const x=g+f[d],p=s.measureText(x).width;p>t&&d>0?(g=f[d],r+=o,y=t):(g=x,p>y&&(y=p))}h!==c.length-1&&(r+=o)}return{width:y,height:r+a,lineHeight:o,fontHeight:a}}static getLineCenterPoint(e){const[n,t]=e,i=VectorUtils.getVector(n,t);return{x:n.x+i.x/2,y:n.y+i.y/2}}static getPerpendicularLine(e){if(e.length!==2)return;const[n,t]=e,i={x:t.x+t.y-n.y,y:t.y-(t.x-n.x)};return[t,i]}static getPerpendicularFootOfLine(e,n){if(e.length!==2)return e;const t=this.getPerpendicularLine(e);if(!t)return e;const[i,o]=t;return this.getFootOfPerpendicular(n,i,o).footPoint}static getQuadrangleFromTriangle(e){if(e.length!==3)return e;const[n,t,i]=e,o={x:i.x+n.x-t.x,y:i.y+n.y-t.y};return[n,t,i,o]}static getRectPerpendicularOffset(e,n,t){const[i,o]=t,s=this.getFootOfPerpendicular(e,i,o).footPoint,r=this.getFootOfPerpendicular(n,i,o).footPoint,a={x:s.x-r.x,y:s.y-r.y},c=VectorUtils.add(n,a);return VectorUtils.getVector(e,c)}static getArrayIndex(e,n){return e<0?n+e:e>=n?e-n:e}static getPointListFromPointOffset(e,n,t){const i=this.getArrayIndex(n-1,e.length),o=this.getArrayIndex(n+1,e.length),s=this.getArrayIndex(n-2,e.length),r=[...e];r[n]=VectorUtils.add(r[n],t);const a=this.getFootOfPerpendicular(r[n],r[s],r[i]).footPoint,c=this.getFootOfPerpendicular(r[n],r[o],r[s]).footPoint;return r[i]=a,r[o]=c,r}static getRectCenterPoint(e){const[n,,t]=e;return{x:(n.x+t.x)/2,y:(n.y+t.y)/2}}static rotateRectPointList(e=5,n){const t=this.getRectCenterPoint(n),{PI:i}=Math,o=Math.sin(e*i/180),s=Math.cos(e*i/180);return n.map(r=>{const a=VectorUtils.getVector(t,r),c=VectorUtils.len(a),y=a.y/c,h=a.x/c;return{x:c*Trigonometric.cosAPlusB(y,h,o,s)+t.x,y:c*Trigonometric.sinAPlusB(y,h,o,s)+t.y}})}static getRectangleByRightAngle(e,n){if(n.length!==2)return n;const t=_MathUtils.getPerpendicularFootOfLine(n,e);return _MathUtils.getQuadrangleFromTriangle([...n,t])}static getRadiusFromQuadrangle(e){const[,n,t]=e,i=t.y-n.y,o=n.x-t.x,s=this.getLineLength(n,t),r=i/s,a=Math.acos(r);return o>0?Math.PI*2-a:a}static getCollectionPointByAnnotationDataPromise(e){const n=e.filter(o=>o.type==="point").map(o=>o.annotation),t=e.filter(o=>!!["polygon","line"].includes(o.type)).map(o=>o.type==="polygon"?__spreadProps(__spreadValues({},o.annotation),{pointList:PolygonUtils.concatBeginAndEnd(o.annotation.pointList)}):o.annotation),i=new MathUtilsWorker;return{promise:new Promise(function(s){i.postMessage({points:n,backgroundList:t}),i.onmessage=r=>{s(r.data),i.terminate()}}),close:()=>{i.terminate()}}}static getCollectionPointByAnnotationData(e){const n=[],t=new Set,i=e.filter(r=>r.type==="point").map(r=>r.annotation),o=e.filter(r=>!!["polygon","line"].includes(r.type)).map(r=>r.type==="polygon"?__spreadProps(__spreadValues({},r.annotation),{pointList:PolygonUtils.concatBeginAndEnd(r.annotation.pointList)}):r.annotation),s=(r,a)=>{const{dropFoot:c}=PolygonUtils.getClosestPoint(r,a,tool.ELineTypes.Line,1,{isClose:!1});if(c!==r){const y=`${c.x} + ${c.y}`;t.has(y)||n.push(r),t.add(y)}};return i.forEach(r=>{s(r,o)}),o.forEach(r=>{let a="";a=r.id,o.forEach((c,y)=>{if(c.id===a)return;const h=[...o];h.splice(y,1),c.pointList.forEach(f=>{s(f,h)})})}),{connectionPoints:n}}static getModifiedRectangleCoordinates(e,n,t){if(e.length!==4)throw new Error("Invalid number of coordinates. Four coordinates are required.");const i=e[0],o=e[1],s=e[2],r=Math.sqrt(__pow(o.x-i.x,2)+__pow(o.y-i.y,2)),a=Math.sqrt(__pow(s.x-o.x,2)+__pow(s.y-o.y,2)),c=n/r,y=t/a,h={x:i.x+(o.x-i.x)*c,y:i.y+(o.y-i.y)*c},f={x:h.x+(s.x-o.x)*y,y:h.y+(s.y-o.y)*y},g={x:i.x+(f.x-o.x),y:i.y+(f.y-o.y)};return[i,h,f,g]}static isPointInsideCube(e,n,t){const[i,o]=t;return!!(polygonTool.isInPolygon({x:e.x,y:e.y},n)&&e.z>=i&&e.z<=o)}};let MathUtils=_MathUtils;MathUtils.isInRange=(e,n)=>{const t=Math.min(...n),i=Math.max(...n),o=r=>r<=i&&r>=t;return(Array.isArray(e)?e:[e]).every(r=>o(r))},MathUtils.withinRange=(e,n)=>{const t=Math.min(...n),i=Math.max(...n);return e>i?i:e<t?t:e},MathUtils.calcViewportBoundaries=(e,n=!1,t=tool.SEGMENT_NUMBER,i=1)=>{if(!e)return{top:0,bottom:0,left:0,right:0};const o=20/i,s=[],r=[];let a=e;n&&(a=polygonTool.createSmoothCurvePointsFromPointList(e,t)),a.forEach(({x,y:u})=>{s.push(x),r.push(u)});let c=Math.min(...s),y=Math.max(...s),h=Math.min(...r),f=Math.max(...r);const g=y-c,d=f-h;if(g<o){const x=(o-g)/2;c-=x,y+=x}if(d<o){const x=(o-d)/2;h-=x,f+=x}return{top:h,bottom:f,left:c,right:y}},MathUtils.getFootOfPerpendicular=(e,n,t,i=!1,o=!1)=>{let s={x:0,y:0};const r=n.x-t.x,a=n.y-t.y;if(Math.abs(r)<1e-8&&Math.abs(a)<1e-8)return s=n,s;let c=(e.x-n.x)*(n.x-t.x)+(e.y-n.y)*(n.y-t.y);c/=r*r+a*a,s.x=n.x+c*r,s.y=n.y+c*a;const y=_MathUtils.getLineLength(e,s),h=2,f=Math.min(n.x,t.x),g=Math.max(n.x,t.x),d=Math.min(n.y,t.y),x=Math.max(n.y,t.y),u=!(_MathUtils.isInRange(e.x,[f,g])||_MathUtils.isInRange(e.y,[d,x])),p=e.x>g+h||e.x<f-h||e.y>x+h||e.y<d-h;return!o&&(i?u:p)?{footPoint:s,length:Infinity}:{footPoint:s,length:y}},MathUtils.calculatePointsInsideBox=e=>{const{indexMap:n,polygon:t,zScope:i,box:o}=e;let s=0;return n.forEach((r,a)=>{const c=a.split("@"),y=Number(c[0]),h=Number(c[1]),f=Number(c[2]),g={x:y-.5,y:h-.5,z:f-.5,width:1,height:1,depth:1},d=getCubePosition(t,i,g);d===2&&(s+=r.length),(d===1||d===0&&(o.width<=1||o.height<=1))&&r.forEach(x=>{_MathUtils.isPointInsideCube(x,t,i)&&s++})}),s};var MathUtils$1=MathUtils;exports.Trigonometric=Trigonometric,exports.default=MathUtils$1;
2
+ `);let y=0;for(let h=0;h<c.length;h++){const f=c[h].split("");let g="";for(let d=0;d<f.length;d++){const x=g+f[d],p=s.measureText(x).width;p>t&&d>0?(g=f[d],r+=o,y=t):(g=x,p>y&&(y=p))}h!==c.length-1&&(r+=o)}return{width:y,height:r+a,lineHeight:o,fontHeight:a}}static getLineCenterPoint(e){const[n,t]=e,i=VectorUtils.getVector(n,t);return{x:n.x+i.x/2,y:n.y+i.y/2}}static getPerpendicularLine(e){if(e.length!==2)return;const[n,t]=e,i={x:t.x+t.y-n.y,y:t.y-(t.x-n.x)};return[t,i]}static getPerpendicularFootOfLine(e,n){if(e.length!==2)return e;const t=this.getPerpendicularLine(e);if(!t)return e;const[i,o]=t;return this.getFootOfPerpendicular(n,i,o).footPoint}static getQuadrangleFromTriangle(e){if(e.length!==3)return e;const[n,t,i]=e,o={x:i.x+n.x-t.x,y:i.y+n.y-t.y};return[n,t,i,o]}static getRectPerpendicularOffset(e,n,t){const[i,o]=t,s=this.getFootOfPerpendicular(e,i,o).footPoint,r=this.getFootOfPerpendicular(n,i,o).footPoint,a={x:s.x-r.x,y:s.y-r.y},c=VectorUtils.add(n,a);return VectorUtils.getVector(e,c)}static getArrayIndex(e,n){return e<0?n+e:e>=n?e-n:e}static getPointListFromPointOffset(e,n,t){const i=this.getArrayIndex(n-1,e.length),o=this.getArrayIndex(n+1,e.length),s=this.getArrayIndex(n-2,e.length),r=[...e];r[n]=VectorUtils.add(r[n],t);const a=this.getFootOfPerpendicular(r[n],r[s],r[i]).footPoint,c=this.getFootOfPerpendicular(r[n],r[o],r[s]).footPoint;return r[i]=a,r[o]=c,r}static getRectCenterPoint(e){const[n,,t]=e;return{x:(n.x+t.x)/2,y:(n.y+t.y)/2}}static rotateRectPointList(e=5,n){const t=this.getRectCenterPoint(n),{PI:i}=Math,o=Math.sin(e*i/180),s=Math.cos(e*i/180);return n.map(r=>{const a=VectorUtils.getVector(t,r),c=VectorUtils.len(a),y=a.y/c,h=a.x/c;return{x:c*Trigonometric.cosAPlusB(y,h,o,s)+t.x,y:c*Trigonometric.sinAPlusB(y,h,o,s)+t.y}})}static getRectangleByRightAngle(e,n){if(n.length!==2)return n;const t=_MathUtils.getPerpendicularFootOfLine(n,e);return _MathUtils.getQuadrangleFromTriangle([...n,t])}static getRadiusFromQuadrangle(e){const[,n,t]=e,i=t.y-n.y,o=n.x-t.x,s=this.getLineLength(n,t),r=i/s,a=Math.acos(r);return o>0?Math.PI*2-a:a}static getCollectionPointByAnnotationDataPromise(e){const n=e.filter(o=>o.type==="point").map(o=>o.annotation),t=e.filter(o=>!!["polygon","line"].includes(o.type)).map(o=>o.type==="polygon"?__spreadProps(__spreadValues({},o.annotation),{pointList:PolygonUtils.concatBeginAndEnd(o.annotation.pointList)}):o.annotation),i=new MathUtilsWorker;return{promise:new Promise(function(s){i.postMessage({points:n,backgroundList:t}),i.onmessage=r=>{s(r.data),i.terminate()}}),close:()=>{i.terminate()}}}static getCollectionPointByAnnotationData(e){const n=[],t=new Set,i=e.filter(r=>r.type==="point").map(r=>r.annotation),o=e.filter(r=>!!["polygon","line"].includes(r.type)).map(r=>r.type==="polygon"?__spreadProps(__spreadValues({},r.annotation),{pointList:PolygonUtils.concatBeginAndEnd(r.annotation.pointList)}):r.annotation),s=(r,a)=>{const{dropFoot:c}=PolygonUtils.getClosestPoint(r,a,tool.ELineTypes.Line,1,{isClose:!1});if(c!==r){const y=`${c.x} + ${c.y}`;t.has(y)||n.push(r),t.add(y)}};return i.forEach(r=>{s(r,o)}),o.forEach(r=>{let a="";a=r.id,o.forEach((c,y)=>{if(c.id===a)return;const h=[...o];h.splice(y,1),c.pointList.forEach(f=>{s(f,h)})})}),{connectionPoints:n}}static getModifiedRectangleCoordinates(e,n,t){if(e.length!==4)throw new Error("Invalid number of coordinates. Four coordinates are required.");const i=e[0],o=e[1],s=e[2],r=Math.sqrt(__pow(o.x-i.x,2)+__pow(o.y-i.y,2)),a=Math.sqrt(__pow(s.x-o.x,2)+__pow(s.y-o.y,2)),c=n/r,y=t/a,h={x:i.x+(o.x-i.x)*c,y:i.y+(o.y-i.y)*c},f={x:h.x+(s.x-o.x)*y,y:h.y+(s.y-o.y)*y},g={x:i.x+(f.x-o.x),y:i.y+(f.y-o.y)};return[i,h,f,g]}static isPointInsideCube(e,n,t){const[i,o]=t;return!!(polygonTool.isInPolygon({x:e.x,y:e.y},n)&&e.z>=i&&e.z<=o)}static getCurrentPosFromRectCenter(e,n,t){return{x:e.width/2-n.x*t,y:e.height/2-n.y*t}}};let MathUtils=_MathUtils;MathUtils.isInRange=(e,n)=>{const t=Math.min(...n),i=Math.max(...n),o=r=>r<=i&&r>=t;return(Array.isArray(e)?e:[e]).every(r=>o(r))},MathUtils.withinRange=(e,n)=>{const t=Math.min(...n),i=Math.max(...n);return e>i?i:e<t?t:e},MathUtils.calcViewportBoundaries=(e,n=!1,t=tool.SEGMENT_NUMBER,i=1)=>{if(!e)return{top:0,bottom:0,left:0,right:0};const o=20/i,s=[],r=[];let a=e;n&&(a=polygonTool.createSmoothCurvePointsFromPointList(e,t)),a.forEach(({x,y:u})=>{s.push(x),r.push(u)});let c=Math.min(...s),y=Math.max(...s),h=Math.min(...r),f=Math.max(...r);const g=y-c,d=f-h;if(g<o){const x=(o-g)/2;c-=x,y+=x}if(d<o){const x=(o-d)/2;h-=x,f+=x}return{top:h,bottom:f,left:c,right:y}},MathUtils.getFootOfPerpendicular=(e,n,t,i=!1,o=!1)=>{let s={x:0,y:0};const r=n.x-t.x,a=n.y-t.y;if(Math.abs(r)<1e-8&&Math.abs(a)<1e-8)return s=n,s;let c=(e.x-n.x)*(n.x-t.x)+(e.y-n.y)*(n.y-t.y);c/=r*r+a*a,s.x=n.x+c*r,s.y=n.y+c*a;const y=_MathUtils.getLineLength(e,s),h=2,f=Math.min(n.x,t.x),g=Math.max(n.x,t.x),d=Math.min(n.y,t.y),x=Math.max(n.y,t.y),u=!(_MathUtils.isInRange(e.x,[f,g])||_MathUtils.isInRange(e.y,[d,x])),p=e.x>g+h||e.x<f-h||e.y>x+h||e.y<d-h;return!o&&(i?u:p)?{footPoint:s,length:Infinity}:{footPoint:s,length:y}},MathUtils.calculatePointsInsideBox=e=>{const{indexMap:n,polygon:t,zScope:i,box:o}=e;let s=0;return n.forEach((r,a)=>{const c=a.split("@"),y=Number(c[0]),h=Number(c[1]),f=Number(c[2]),g={x:y-.5,y:h-.5,z:f-.5,width:1,height:1,depth:1},d=getCubePosition(t,i,g);d===2&&(s+=r.length),(d===1||d===0&&(o.width<=1||o.height<=1))&&r.forEach(x=>{_MathUtils.isPointInsideCube(x,t,i)&&s++})}),s};var MathUtils$1=MathUtils;exports.Trigonometric=Trigonometric,exports.default=MathUtils$1;
@@ -1 +1 @@
1
- "use strict";var turf=require("@turf/turf"),annotation=require("../../constant/annotation.js"),CommonToolUtils=require("./CommonToolUtils.js"),tool=require("../../constant/tool.js"),AxisUtils=require("./AxisUtils.js"),MathUtils=require("../MathUtils.js"),LineToolUtils=require("./LineToolUtils.js"),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(L,e,t)=>e in L?__defProp(L,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):L[e]=t,__spreadValues=(L,e)=>{for(var t in e||(e={}))__hasOwnProp.call(e,t)&&__defNormalProp(L,t,e[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))__propIsEnum.call(e,t)&&__defNormalProp(L,t,e[t]);return L};class PolygonUtils{static getHoverPolygonID(e,t,n=3,i=tool.ELineTypes.Line){let r="",o=Infinity;const l=AxisUtils.default.axisArea(e,n);return t.forEach(s=>{s.pointList&&l.forEach(u=>{const a=this.calcPolygonSize(s.pointList);this.isInPolygon(u,s.pointList,i)&&a<o&&(r=s.id,o=a)})}),r}static calcPolygonSize(e=[]){if((e==null?void 0:e.length)<=2)return 0;const t=e.length,n=e.reduce((i,r,o,l)=>{const s=l[(o+1)%t];return i+r.x*s.y-s.x*r.y},0);return Math.abs(n)/2}static isInPolygon(e,t,n=tool.ELineTypes.Line){let i=0,r,o,l,s;t=[...t],n===tool.ELineTypes.Curve&&(t=this.createSmoothCurvePoints(t.reduce((a,h)=>[...a,h.x,h.y],[]),.5,!0,20)),[l]=t;const u=t.length;for(r=1;r<=u;r++)s=t[r%u],e.x>Math.min(l.x,s.x)&&e.x<=Math.max(l.x,s.x)&&e.y<=Math.max(l.y,s.y)&&l.x!==s.x&&(o=(e.x-l.x)*(s.y-l.y)/(s.x-l.x)+l.y,(l.y===s.y||e.y<=o)&&i++),l=s;return i%2!=0}static createSmoothCurvePointsFromPointList(e,t=tool.SEGMENT_NUMBER){return this.createSmoothCurvePoints(e.reduce((i,r)=>[...i,r.x,r.y],[]),.5,!1,t).map((i,r)=>{var o;const l=r/(tool.SEGMENT_NUMBER+1),s=Math.floor(l),u=(o=e[s])!=null?o:{};return __spreadValues(s===l?__spreadValues({},u):{specialEdge:u.specialEdge},i)})}static createSmoothCurvePoints(e,t=.5,n=!1,i=tool.SEGMENT_NUMBER){if(e.length<4)return e;const r=[],o=e.slice(0);let l,s,u,a,h,g,P,E,x,m,c,d,f;for(n?(o.unshift(e[e.length-1]),o.unshift(e[e.length-2]),o.unshift(e[e.length-1]),o.unshift(e[e.length-2]),o.push(e[0]),o.push(e[1])):(o.unshift(e[1]),o.unshift(e[0]),o.push(e[e.length-2]),o.push(e[e.length-1])),f=2;f<o.length-4;f+=2)for(u=(o[f+2]-o[f-2])*t,a=(o[f+4]-o[f-0])*t,h=(o[f+3]-o[f-1])*t,g=(o[f+5]-o[f+1])*t,d=0;d<=i;d++)c=d/i,P=2*Math.pow(c,3)-3*Math.pow(c,2)+1,E=-(2*Math.pow(c,3))+3*Math.pow(c,2),x=Math.pow(c,3)-2*Math.pow(c,2)+c,m=Math.pow(c,3)-Math.pow(c,2),l=P*o[f]+E*o[f+2]+x*u+m*a,s=P*o[f+1]+E*o[f+3]+x*h+m*g,r.push(l),r.push(s);const v=[];for(let y=0;y<r.length-1;y+=2)v.push({x:r[y],y:r[y+1]});if(n)for(let y=0;y<i+1;y++){const M=v.shift();v.push(M)}return v}static getPolygonByID(e,t){return e.find(n=>n.id===t)}static getPolygonByIDs(e,t){return t&&(t==null?void 0:t.length)>0?e.filter(n=>t.includes(n.id)):[]}static getHoverEdgeIndex(e,t,n=tool.ELineTypes.Line,i=3){let r=[...t];n===tool.ELineTypes.Curve?r=this.createSmoothCurvePoints(t.reduce((s,u)=>[...s,u.x,u.y],[]),.5,!0,tool.SEGMENT_NUMBER):n===tool.ELineTypes.Line&&r.push(r[0]);let o=-1,l=i;for(let s=0;s<r.length-1;s++){const{length:u}=MathUtils.default.getFootOfPerpendicular(e,r[s],r[s+1]);u<l&&(o=s,l=u)}return o===-1?-1:n===tool.ELineTypes.Curve?Math.floor(o/tool.SEGMENT_NUMBER):o}static getClosestPoint(e,t,n=tool.ELineTypes.Line,i=3,r){var o;let l=!1;const s=(o=r==null?void 0:r.isClose)!=null?o:!0;let u="",a=-1,h=Infinity,g=e;const P=20;let E=!1;return t.forEach(x=>{if(!E&&!!x.pointList)switch(n){case tool.ELineTypes.Line:CommonToolUtils.findAllLine(x.pointList,s).forEach((c,d)=>{if(E)return;let{length:f,footPoint:v}=MathUtils.default.getFootOfPerpendicular(e,c.point1,c.point2);const y=MathUtils.default.getLineLength(c.point1,e),M=MathUtils.default.getLineLength(c.point2,e);y<i*2&&(v=c.point1,f=y,E=!0),M<i*2&&(v=c.point2,f=M,E=!0),f<h&&f<i&&(u=x.id,a=d,h=f,g=v,l=!0)});break;case tool.ELineTypes.Curve:{const m=this.createSmoothCurvePoints(x.pointList.reduce((c,d)=>[...c,d.x,d.y],[]),.5,s,P);for(let c=0;c<m.length-1;c++){const{length:d,footPoint:f}=MathUtils.default.getFootOfPerpendicular(e,m[c],m[c+1]);d<h&&d<i&&(u=x.id,a=Math.floor(c/(P+1)),h=d,g=f,l=!0)}}break}}),{dropFoot:g,closestEdgeIndex:a,closestPolygonID:u,hasClosed:l}}static isPointListInPolygon(e,t,n=tool.ELineTypes.Line){return e.every(i=>this.isInPolygon(i,t,n))}static isPointListOutSidePolygon(e,t,n=tool.ELineTypes.Line){return e.some(i=>!this.isInPolygon(i,t,n))}static getPolygonArea(e){let t=0;for(let n=0,i=e.length;n<i;n++){const r=e[n].x,o=e[n===e.length-1?0:n+1].y,l=e[n===e.length-1?0:n+1].x,s=e[n].y;t+=r*o*.5,t-=l*s*.5}return Math.abs(t)}static updatePolygonByRotate(e,t=1,n){let i=1;return e===annotation.ERotateDirection.Anticlockwise&&(i=-1),i*=t,MathUtils.default.rotateRectPointList(i,n)}static deletePolygonLastPoint(e,t,n,i){return n===i.length-1?e:[...e,{x:t[0],y:t[1]}]}static concatBeginAndEnd(e){return e.length<1?e:[...e,e[0]]}static segmentPolygonByPolygon(e,t){var n,i;try{let r=turf.polygon([[...PolygonUtils.concatBeginAndEnd(e.map(l=>[l.x,l.y]))]]);return t.forEach(l=>{const s=turf.polygon([[...PolygonUtils.concatBeginAndEnd(l.pointList.map(a=>[a.x,a.y]))]]),u=turf.difference(r,s);u&&(r=u)}),((i=(n=r==null?void 0:r.geometry)==null?void 0:n.coordinates.map(l=>{var s;return((s=r==null?void 0:r.geometry)==null?void 0:s.type)==="MultiPolygon"?l[0].reduce(PolygonUtils.deletePolygonLastPoint,[]):l.reduce(PolygonUtils.deletePolygonLastPoint,[])}))!=null?i:[]).reduce((l,s)=>{const u=s.length,a=s.filter((h,g)=>{const P=(g+1)%u;return!AxisUtils.default.getIsInScope(h,s[P],1)});return a.length<3?l:[...l,a]},[])}catch(r){console.error(r)}}static getPolygonPointList(e,t){const n=t.find(i=>i.id===e);return n&&n.pointList&&n.pointList.length>0?n.pointList:[]}static getWrapPolygonIndex(e,t){return t.findIndex(n=>PolygonUtils.isPointListInPolygon(e,n.pointList))}static clipPolygonFromWrapPolygon(e,t){const n=PolygonUtils.isPolygonClosewise(t),i=PolygonUtils.isPolygonClosewise(e),r=PolygonUtils.getClosePointDistanceFromPolygon(e[0],t),o=t[r];let l=[...t.slice(0,r),o,...e,e[0],...t.slice(r,t.length)];return n===i&&(l=[...t.slice(0,r),o,e[0],...e.reverse(),...t.slice(r,t.length)]),l}static isPolygonClosewise(e){const t=e.length;let n,i,r,o=0,l;if(t<3)return 0;for(n=0;n<t;n++)i=(n+1)%t,r=(n+2)%t,l=(e[i].x-e[n].x)*(e[r].y-e[i].y),l-=(e[i].y-e[n].y)*(e[r].x-e[i].x),l<0?o--:l>0&&o++;return o>0?1:o<0?-1:0}static getClosePointDistanceFromPolygon(e,t){let n=Number.MAX_SAFE_INTEGER,i=-1;return t.forEach((r,o)=>{const l=LineToolUtils.default.calcDistance(e,r);l<n&&(n=l,i=o)}),i}static combinePolygonWithPolygon(e,t){var n,i;try{const r=turf.polygon([[...PolygonUtils.concatBeginAndEnd(e.pointList.map(a=>[a.x,a.y]))]]),o=turf.polygon([[...PolygonUtils.concatBeginAndEnd(t.pointList.map(a=>[a.x,a.y]))]]),l=turf.union(r,o),s=[],u=e;if(((i=(n=l==null?void 0:l.geometry)==null?void 0:n.coordinates)==null?void 0:i.length)===1){s.push(t.id);const a=l==null?void 0:l.geometry.coordinates.map(h=>{var g;return((g=l==null?void 0:l.geometry)==null?void 0:g.type)==="MultiPolygon"?h[0].reduce(PolygonUtils.deletePolygonLastPoint,[]):h.reduce(PolygonUtils.deletePolygonLastPoint,[])})[0];u.pointList=a}return{newPolygon:u,unionList:s}}catch(r){console.error(r)}}static composePointList(e,t){let n=0,i=0,r=Number.MAX_VALUE;return e.forEach((o,l)=>{t.forEach((s,u)=>{const a=LineToolUtils.default.calcDistance(o,s);a<r&&(n=l+1,i=u+1,r=a)})}),[...e.slice(0,n),...t.slice(i,t.length),...t.slice(0,i),...e.slice(n,e.length)]}static composeSegmentPolygonList(e){var t,n;const i=[];for(let r=0;r<e.length;r++)for(let o=0;o<e.length;o++){const l=(t=e[r])==null?void 0:t.pointList,s=(n=e[o])==null?void 0:n.pointList;r!==o&&l&&s&&PolygonUtils.isPointListInPolygon(s,l)&&(e[r].pointList=PolygonUtils.composePointList(l,s),i.unshift(o))}return i.forEach(r=>{e.splice(r,1)}),e}}module.exports=PolygonUtils;
1
+ "use strict";var turf=require("@turf/turf"),annotation=require("../../constant/annotation.js"),CommonToolUtils=require("./CommonToolUtils.js"),tool=require("../../constant/tool.js"),AxisUtils=require("./AxisUtils.js"),MathUtils=require("../MathUtils.js"),LineToolUtils=require("./LineToolUtils.js"),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(p,e,t)=>e in p?__defProp(p,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[e]=t,__spreadValues=(p,e)=>{for(var t in e||(e={}))__hasOwnProp.call(e,t)&&__defNormalProp(p,t,e[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))__propIsEnum.call(e,t)&&__defNormalProp(p,t,e[t]);return p};class PolygonUtils{static getHoverPolygonID(e,t,n=3,i=tool.ELineTypes.Line){let o="",r=Infinity;const l=AxisUtils.default.axisArea(e,n);return t.forEach(s=>{s.pointList&&l.forEach(c=>{const u=this.calcPolygonSize(s.pointList);this.isInPolygon(c,s.pointList,i)&&u<r&&(o=s.id,r=u)})}),o}static calcPolygonSize(e=[]){if((e==null?void 0:e.length)<=2)return 0;const t=e.length,n=e.reduce((i,o,r,l)=>{const s=l[(r+1)%t];return i+o.x*s.y-s.x*o.y},0);return Math.abs(n)/2}static isInPolygon(e,t,n=tool.ELineTypes.Line){return t=[...t],n===tool.ELineTypes.Curve&&(t=this.createSmoothCurvePoints(t.reduce((i,o)=>[...i,o.x,o.y],[]),.5,!0,20)),this.isPointInOrOnPolygon(e,t)}static isPointInOrOnPolygon(e,t,n=1e-9){const{x:i,y:o}=e;let r=!1;for(let l=0,s=t.length-1;l<t.length;s=l++){const{x:c,y:u}=t[l],{x:h,y:d}=t[s],y=i<=Math.max(c,h)&&i>=Math.min(c,h)&&o<=Math.max(u,d)&&o>=Math.min(u,d),P=(o-u)*(h-c)-(i-c)*(d-u);if(y&&Math.abs(P)<n)return!0;u>o!=d>o&&i<(h-c)*(o-u)/(d-u)+c&&(r=!r)}return r}static createSmoothCurvePointsFromPointList(e,t=tool.SEGMENT_NUMBER){return this.createSmoothCurvePoints(e.reduce((i,o)=>[...i,o.x,o.y],[]),.5,!1,t).map((i,o)=>{var r;const l=o/(tool.SEGMENT_NUMBER+1),s=Math.floor(l),c=(r=e[s])!=null?r:{};return __spreadValues(s===l?__spreadValues({},c):{specialEdge:c.specialEdge},i)})}static createSmoothCurvePoints(e,t=.5,n=!1,i=tool.SEGMENT_NUMBER){if(e.length<4)return e;const o=[],r=e.slice(0);let l,s,c,u,h,d,y,P,x,m,a,g,f;for(n?(r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.push(e[0]),r.push(e[1])):(r.unshift(e[1]),r.unshift(e[0]),r.push(e[e.length-2]),r.push(e[e.length-1])),f=2;f<r.length-4;f+=2)for(c=(r[f+2]-r[f-2])*t,u=(r[f+4]-r[f-0])*t,h=(r[f+3]-r[f-1])*t,d=(r[f+5]-r[f+1])*t,g=0;g<=i;g++)a=g/i,y=2*Math.pow(a,3)-3*Math.pow(a,2)+1,P=-(2*Math.pow(a,3))+3*Math.pow(a,2),x=Math.pow(a,3)-2*Math.pow(a,2)+a,m=Math.pow(a,3)-Math.pow(a,2),l=y*r[f]+P*r[f+2]+x*c+m*u,s=y*r[f+1]+P*r[f+3]+x*h+m*d,o.push(l),o.push(s);const v=[];for(let E=0;E<o.length-1;E+=2)v.push({x:o[E],y:o[E+1]});if(n)for(let E=0;E<i+1;E++){const L=v.shift();v.push(L)}return v}static getPolygonByID(e,t){return e.find(n=>n.id===t)}static getPolygonByIDs(e,t){return t&&(t==null?void 0:t.length)>0?e.filter(n=>t.includes(n.id)):[]}static getHoverEdgeIndex(e,t,n=tool.ELineTypes.Line,i=5){let o=[...t];n===tool.ELineTypes.Curve?o=this.createSmoothCurvePoints(t.reduce((s,c)=>[...s,c.x,c.y],[]),.5,!0,tool.SEGMENT_NUMBER):n===tool.ELineTypes.Line&&o.push(o[0]);let r=-1,l=i;for(let s=0;s<o.length-1;s++){const{length:c}=MathUtils.default.getFootOfPerpendicular(e,o[s],o[s+1],!0);c<l&&(r=s,l=c)}return r===-1?-1:n===tool.ELineTypes.Curve?Math.floor(r/tool.SEGMENT_NUMBER):r}static getClosestPoint(e,t,n=tool.ELineTypes.Line,i=3,o){var r;let l=!1;const s=(r=o==null?void 0:o.isClose)!=null?r:!0;let c="",u=-1,h=Infinity,d=e;const y=20;let P=!1;return t.forEach(x=>{if(!P&&!!x.pointList)switch(n){case tool.ELineTypes.Line:CommonToolUtils.findAllLine(x.pointList,s).forEach((a,g)=>{if(P)return;let{length:f,footPoint:v}=MathUtils.default.getFootOfPerpendicular(e,a.point1,a.point2);const E=MathUtils.default.getLineLength(a.point1,e),L=MathUtils.default.getLineLength(a.point2,e);E<i*2&&(v=a.point1,f=E,P=!0),L<i*2&&(v=a.point2,f=L,P=!0),f<h&&f<i&&(c=x.id,u=g,h=f,d=v,l=!0)});break;case tool.ELineTypes.Curve:{const m=this.createSmoothCurvePoints(x.pointList.reduce((a,g)=>[...a,g.x,g.y],[]),.5,s,y);for(let a=0;a<m.length-1;a++){const{length:g,footPoint:f}=MathUtils.default.getFootOfPerpendicular(e,m[a],m[a+1]);g<h&&g<i&&(c=x.id,u=Math.floor(a/(y+1)),h=g,d=f,l=!0)}}break}}),{dropFoot:d,closestEdgeIndex:u,closestPolygonID:c,hasClosed:l}}static isPointListInPolygon(e,t,n=tool.ELineTypes.Line){return e.every(i=>this.isInPolygon(i,t,n))}static isPointListOutSidePolygon(e,t,n=tool.ELineTypes.Line){return e.some(i=>!this.isInPolygon(i,t,n))}static getPolygonArea(e){let t=0;for(let n=0,i=e.length;n<i;n++){const o=e[n].x,r=e[n===e.length-1?0:n+1].y,l=e[n===e.length-1?0:n+1].x,s=e[n].y;t+=o*r*.5,t-=l*s*.5}return Math.abs(t)}static updatePolygonByRotate(e,t=1,n){let i=1;return e===annotation.ERotateDirection.Anticlockwise&&(i=-1),i*=t,MathUtils.default.rotateRectPointList(i,n)}static deletePolygonLastPoint(e,t,n,i){return n===i.length-1?e:[...e,{x:t[0],y:t[1]}]}static concatBeginAndEnd(e){return e.length<1?e:[...e,e[0]]}static segmentPolygonByPolygon(e,t){var n,i;try{let o=turf.polygon([[...PolygonUtils.concatBeginAndEnd(e.map(l=>[l.x,l.y]))]]);return t.forEach(l=>{const s=turf.polygon([[...PolygonUtils.concatBeginAndEnd(l.pointList.map(u=>[u.x,u.y]))]]),c=turf.difference(o,s);c&&(o=c)}),((i=(n=o==null?void 0:o.geometry)==null?void 0:n.coordinates.map(l=>{var s;return((s=o==null?void 0:o.geometry)==null?void 0:s.type)==="MultiPolygon"?l[0].reduce(PolygonUtils.deletePolygonLastPoint,[]):l.reduce(PolygonUtils.deletePolygonLastPoint,[])}))!=null?i:[]).reduce((l,s)=>{const c=s.length,u=s.filter((h,d)=>{const y=(d+1)%c;return!AxisUtils.default.getIsInScope(h,s[y],1)});return u.length<3?l:[...l,u]},[])}catch(o){console.error(o)}}static getPolygonPointList(e,t){const n=t.find(i=>i.id===e);return n&&n.pointList&&n.pointList.length>0?n.pointList:[]}static getWrapPolygonIndex(e,t){return t.findIndex(n=>PolygonUtils.isPointListInPolygon(e,n.pointList))}static clipPolygonFromWrapPolygon(e,t){const n=PolygonUtils.isPolygonClosewise(t),i=PolygonUtils.isPolygonClosewise(e),o=PolygonUtils.getClosePointDistanceFromPolygon(e[0],t),r=t[o];let l=[...t.slice(0,o),r,...e,e[0],...t.slice(o,t.length)];return n===i&&(l=[...t.slice(0,o),r,e[0],...e.reverse(),...t.slice(o,t.length)]),l}static isPolygonClosewise(e){const t=e.length;let n,i,o,r=0,l;if(t<3)return 0;for(n=0;n<t;n++)i=(n+1)%t,o=(n+2)%t,l=(e[i].x-e[n].x)*(e[o].y-e[i].y),l-=(e[i].y-e[n].y)*(e[o].x-e[i].x),l<0?r--:l>0&&r++;return r>0?1:r<0?-1:0}static getClosePointDistanceFromPolygon(e,t){let n=Number.MAX_SAFE_INTEGER,i=-1;return t.forEach((o,r)=>{const l=LineToolUtils.default.calcDistance(e,o);l<n&&(n=l,i=r)}),i}static combinePolygonWithPolygon(e,t){var n,i;try{const o=turf.polygon([[...PolygonUtils.concatBeginAndEnd(e.pointList.map(u=>[u.x,u.y]))]]),r=turf.polygon([[...PolygonUtils.concatBeginAndEnd(t.pointList.map(u=>[u.x,u.y]))]]),l=turf.union(o,r),s=[],c=e;if(((i=(n=l==null?void 0:l.geometry)==null?void 0:n.coordinates)==null?void 0:i.length)===1){s.push(t.id);const u=l==null?void 0:l.geometry.coordinates.map(h=>{var d;return((d=l==null?void 0:l.geometry)==null?void 0:d.type)==="MultiPolygon"?h[0].reduce(PolygonUtils.deletePolygonLastPoint,[]):h.reduce(PolygonUtils.deletePolygonLastPoint,[])})[0];c.pointList=u}return{newPolygon:c,unionList:s}}catch(o){console.error(o)}}static composePointList(e,t){let n=0,i=0,o=Number.MAX_VALUE;return e.forEach((r,l)=>{t.forEach((s,c)=>{const u=LineToolUtils.default.calcDistance(r,s);u<o&&(n=l+1,i=c+1,o=u)})}),[...e.slice(0,n),...t.slice(i,t.length),...t.slice(0,i),...e.slice(n,e.length)]}static composeSegmentPolygonList(e){var t,n;const i=[];for(let o=0;o<e.length;o++)for(let r=0;r<e.length;r++){const l=(t=e[o])==null?void 0:t.pointList,s=(n=e[r])==null?void 0:n.pointList;o!==r&&l&&s&&PolygonUtils.isPointListInPolygon(s,l)&&(e[o].pointList=PolygonUtils.composePointList(l,s),i.unshift(r))}return i.forEach(o=>{e.splice(o,1)}),e}static computeConvexHull(e){e.sort((o,r)=>o.x!==r.x?o.x-r.x:o.y-r.y);const t=(o,r,l)=>(r.x-o.x)*(l.y-o.y)-(r.y-o.y)*(l.x-o.x),n=[];for(const o of e){for(;n.length>=2&&t(n[n.length-2],n[n.length-1],o)<=0;)n.pop();n.push(o)}const i=[];for(let o=e.length-1;o>=0;o--){const r=e[o];for(;i.length>=2&&t(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}return i.pop(),n.pop(),n.concat(i)}static createConvexHullGroup(e){const t={};return e.forEach(n=>{n.type==="line"&&(t[n.annotation.id]||(t[n.annotation.id]={points:[],convexHull:[]}),t[n.annotation.id].points.push(...n.annotation.pointList))}),Object.keys(t).forEach(n=>{t[n].convexHull=this.computeConvexHull(t[n].points)}),t}}module.exports=PolygonUtils;
@@ -1 +1 @@
1
- import{createBase64WorkerFactory as b}from"./_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js";var d=b("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24oeCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIHAodCl7Y29uc3QgZT0tNyxpPTMsbz1pLWU7cmV0dXJuIHQ8ZSYmKHQ9ZSksdD5pJiYodD1pKSxNYXRoLmZsb29yKCh0LWUpL28qMjU1KX1mdW5jdGlvbiBoKCl7bGV0IHQ7Y29uc3QgZT1uZXcgQXJyYXkoMjU2KS5maWxsKCIiKS5tYXAoKCk9Pm5ldyBBcnJheSgzKS5maWxsKCIiKSk7Zm9yKGxldCBpPTA7aTwyMDtpKyspe2Zvcih0PTA7dDwzMjt0KyspZVt0XVswXT0xMjgrNCp0LGVbdF1bMV09MCxlW3RdWzJdPTA7Zm9yKGVbMzJdWzBdPTI1NSxlWzMyXVsxXT0wLGVbMzJdWzJdPTAsdD0wO3Q8NjM7dCsrKWVbMzMrdF1bMF09MjU1LGVbMzMrdF1bMV09NCs0KnQsZVszMyt0XVsyXT0wO2ZvcihlWzk2XVswXT0yNTQsZVs5Nl1bMV09MjU1LGVbOTZdWzJdPTIsdD0wO3Q8NjI7dCsrKWVbOTcrdF1bMF09MjUwLTQqdCxlWzk3K3RdWzFdPTI1NSxlWzk3K3RdWzJdPTYrNCp0O2ZvcihlWzE1OV1bMF09MSxlWzE1OV1bMV09MjU1LGVbMTU5XVsyXT0yNTQsdD0wO3Q8NjQ7dCsrKWVbMTYwK3RdWzBdPTAsZVsxNjArdF1bMV09MjUyLXQqNCxlWzE2MCt0XVsyXT0yNTU7Zm9yKHQ9MDt0PDMyO3QrKyllWzIyNCt0XVswXT0wLGVbMjI0K3RdWzFdPTAsZVsyMjQrdF1bMl09MjUyLTQqdH1yZXR1cm4gZX1jb25zdCBDPWgoKTtmdW5jdGlvbiBkKHQsZSxpPTApe2xldCBvPTAscyxhLHIsZjtlPVsuLi5lXSxpPT09MSYmKGU9Y3JlYXRlU21vb3RoQ3VydmVQb2ludHMoZS5yZWR1Y2UoKGMsdSk9PlsuLi5jLHUueCx1LnldLFtdKSwuNSwhMCxTRUdNRU5UX05VTUJFUikpLFtyXT1lO2NvbnN0IG49ZS5sZW5ndGg7Zm9yKHM9MTtzPD1uO3MrKylmPWVbcyVuXSx0Lng+TWF0aC5taW4oci54LGYueCkmJnQueDw9TWF0aC5tYXgoci54LGYueCkmJnQueTw9TWF0aC5tYXgoci55LGYueSkmJnIueCE9PWYueCYmKGE9KHQueC1yLngpKihmLnktci55KS8oZi54LXIueCkrci55LChyLnk9PT1mLnl8fHQueTw9YSkmJm8rKykscj1mO3JldHVybiBvJTIhPTB9ZnVuY3Rpb24gYih7ek1pbjp0LHpNYXg6ZSxwb2x5Z29uUG9pbnRMaXN0OmksYXR0cmlidXRlOm8seDpzLHk6YSx6OnIsY29sb3JMaXN0OmYsdmFsaWQ6bn0pe2lmKGQoe3g6cyx5OmF9LGkpJiZyPj10JiZyPD1lKXJldHVybiBuPT09ITE/WzEsMTAzLzI1NSwxMDIvMjU1XTpmW29dP2Zbb10ucmdiYS5zbGljZSgwLDMpLm1hcCh1PT51LzI1NSk6WzEsMCwwXX1yZXR1cm4gb25tZXNzYWdlPWZ1bmN0aW9uKGUpe2NvbnN0e3Bvc2l0aW9uOmksY29sb3I6byxjdWJvaWRMaXN0OnMsY29sb3JMaXN0OmEsaGlnaGxpZ2h0SW5kZXg6cn09ZS5kYXRhO2xldCBmPTA7Zm9yKGxldCBuPTA7bjxpLmxlbmd0aDtuKz0zKXtjb25zdCBjPWlbbl0sdT1pW24rMV0sZz1pW24rMl0sbT1zLm1hcChsPT5iKHtwb2x5Z29uUG9pbnRMaXN0OmwucG9seWdvblBvaW50TGlzdCx6TWluOmwuek1pbix6TWF4Omwuek1heCx4OmMseTp1LHo6ZyxhdHRyaWJ1dGU6bC5hdHRyaWJ1dGUsY29sb3JMaXN0OmEsdmFsaWQ6bC52YWxpZH0pKS5maWx0ZXIobD0+bCkucG9wKCk7aWYobSl7ZisrO2NvbnN0W2wseSxNXT1tO29bbl09bCxvW24rMV09eSxvW24rMl09TX1lbHNle2NvbnN0IGw9TWF0aC5mbG9vcihuLzMpO2lmKHImJnJbbF09PT0xKW9bbl09MCxvW24rMV09MCxvW24rMl09MDtlbHNle2NvbnN0IHk9cChnKSxNPUNbeV0sW3csSSxfXT1NO29bbl09dy8yNTUsb1tuKzFdPUkvMjU1LG9bbisyXT1fLzI1NX19fXBvc3RNZXNzYWdlKHtwb2ludHM6aSxjb2xvcjpvLG51bTpmfSl9LHguaXNJblBvbHlnb249ZCxPYmplY3QuZGVmaW5lUHJvcGVydHkoeCwiX19lc01vZHVsZSIse3ZhbHVlOiEwfSkseH0oe30pOwoK",null,!1);export{d as default};
1
+ import{createBase64WorkerFactory as b}from"./_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js";var l=b("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24ocCl7InVzZSBzdHJpY3QiO2NvbnN0IHY9Wy0xLC0xLC0xXTtsZXQgST0hMTtmdW5jdGlvbiBCKGUpe2NvbnN0IHQ9LTcsbz0zLG49by10O3JldHVybiBlPHQmJihlPXQpLGU+byYmKGU9byksTWF0aC5mbG9vcigoZS10KS9uKjI1NSl9ZnVuY3Rpb24gRSgpe2xldCBlO2NvbnN0IHQ9bmV3IEFycmF5KDI1NikuZmlsbCgiIikubWFwKCgpPT5uZXcgQXJyYXkoMykuZmlsbCgiIikpO2ZvcihsZXQgbz0wO288MjA7bysrKXtmb3IoZT0wO2U8MzI7ZSsrKXRbZV1bMF09MTI4KzQqZSx0W2VdWzFdPTAsdFtlXVsyXT0wO2Zvcih0WzMyXVswXT0yNTUsdFszMl1bMV09MCx0WzMyXVsyXT0wLGU9MDtlPDYzO2UrKyl0WzMzK2VdWzBdPTI1NSx0WzMzK2VdWzFdPTQrNCplLHRbMzMrZV1bMl09MDtmb3IodFs5Nl1bMF09MjU0LHRbOTZdWzFdPTI1NSx0Wzk2XVsyXT0yLGU9MDtlPDYyO2UrKyl0Wzk3K2VdWzBdPTI1MC00KmUsdFs5NytlXVsxXT0yNTUsdFs5NytlXVsyXT02KzQqZTtmb3IodFsxNTldWzBdPTEsdFsxNTldWzFdPTI1NSx0WzE1OV1bMl09MjU0LGU9MDtlPDY0O2UrKyl0WzE2MCtlXVswXT0wLHRbMTYwK2VdWzFdPTI1Mi1lKjQsdFsxNjArZV1bMl09MjU1O2ZvcihlPTA7ZTwzMjtlKyspdFsyMjQrZV1bMF09MCx0WzIyNCtlXVsxXT0wLHRbMjI0K2VdWzJdPTI1Mi00KmV9cmV0dXJuIHR9Y29uc3QgUj1FKCk7ZnVuY3Rpb24gaChlLHQsbz0wKXtsZXQgbj0wLGEseCxpLGw7dD1bLi4udF0sbz09PTEmJih0PWNyZWF0ZVNtb290aEN1cnZlUG9pbnRzKHQucmVkdWNlKCh5LGMpPT5bLi4ueSxjLngsYy55XSxbXSksLjUsITAsU0VHTUVOVF9OVU1CRVIpKSxbaV09dDtjb25zdCB1PXQubGVuZ3RoO2ZvcihhPTE7YTw9dTthKyspbD10W2EldV0sZS54Pk1hdGgubWluKGkueCxsLngpJiZlLng8PU1hdGgubWF4KGkueCxsLngpJiZlLnk8PU1hdGgubWF4KGkueSxsLnkpJiZpLnghPT1sLngmJih4PShlLngtaS54KSoobC55LWkueSkvKGwueC1pLngpK2kueSwoaS55PT09bC55fHxlLnk8PXgpJiZuKyspLGk9bDtyZXR1cm4gbiUyIT0wfWZ1bmN0aW9uIE8oe3pNaW46ZSx6TWF4OnQscG9seWdvblBvaW50TGlzdDpvLGF0dHJpYnV0ZTpuLHg6YSx5OngsejppLGNvbG9yTGlzdDpsLHZhbGlkOnV9KXtpZihoKHt4OmEseTp4fSxvKSYmaT49ZSYmaTw9dClyZXR1cm4gdT09PSExP1sxLDEwMy8yNTUsMTAyLzI1NV06bFtuXT9sW25dLnJnYmEuc2xpY2UoMCwzKS5tYXAoYz0+Yy8yNTUpOlsxLDAsMF19ZnVuY3Rpb24gbShlKXtjb25zdCB0PUIoZSksbz1SW3RdLFtuLGEseF09bztyZXR1cm5bbi8yNTUsYS8yNTUseC8yNTVdfXJldHVybiBvbm1lc3NhZ2U9ZnVuY3Rpb24odCl7Y29uc3R7cG9zaXRpb246byxjb2xvcjpuLGN1Ym9pZExpc3Q6YSxjb2xvckxpc3Q6eCxoaWdobGlnaHRJbmRleDppfT10LmRhdGE7bGV0e21vZGlmaWVkQm94SWRzOmw9W10scmVzZXRBcmVhczp1PVtdfT10LmRhdGEseT0wO2Z1bmN0aW9uIGMoKXt5Kz0xfWlmKCFvKXJldHVybjtjb25zdCBfPSEhKGk9PW51bGw/dm9pZCAwOmkubGVuZ3RoKTsoX3x8SSkmJihsPVtdLHU9W10pO2NvbnN0IHc9bC5sZW5ndGg/YS5maWx0ZXIocj0+bC5pbmNsdWRlcyhyLmlkKSk6YTtmb3IobGV0IHI9MDtyPG8ubGVuZ3RoO3IrPTMpe2NvbnN0IEM9b1tyXSxMPW9bcisxXSxkPW9bcisyXTtsZXQgZztpZih1Lmxlbmd0aD09PTEmJiFsLmxlbmd0aCloKHt4OkMseTpMfSx1WzBdKT9nPW0oZCk6Zz12O2Vsc2UgaWYodS5sZW5ndGh8fGwubGVuZ3RoKXtsZXQgcz0hMTt3LnNvbWUoZj0+e2NvbnN0IE09Tyh7cG9seWdvblBvaW50TGlzdDpmLnBvbHlnb25Qb2ludExpc3Qsek1pbjpmLnpNaW4sek1heDpmLnpNYXgseDpDLHk6TCx6OmQsYXR0cmlidXRlOmYuYXR0cmlidXRlLGNvbG9yTGlzdDp4LHZhbGlkOmYudmFsaWR9KTtyZXR1cm4gTT8oYygpLGc9TSxzPSEwLCEwKTohMX0pLCFzJiZ1Lmxlbmd0aCYmKHM9dS5zb21lKGY9Pmgoe3g6Qyx5Okx9LGYpPyhnPW0oZCksITApOiExKSksIXMmJiFfJiYoST9nPW0oZCk6Zz12KX1lbHNlIHcuc29tZShzPT57Y29uc3QgZj1PKHtwb2x5Z29uUG9pbnRMaXN0OnMucG9seWdvblBvaW50TGlzdCx6TWluOnMuek1pbix6TWF4OnMuek1heCx4OkMseTpMLHo6ZCxhdHRyaWJ1dGU6cy5hdHRyaWJ1dGUsY29sb3JMaXN0OngsdmFsaWQ6cy52YWxpZH0pO3JldHVybiBmPyhjKCksZz1mLCEwKTohMX0pO2NvbnN0IEE9cz0+e2NvbnN0IGY9TWF0aC5mbG9vcihzLzMpO3JldHVybiBpJiZpW2ZdPT09MX07aWYoZylpZihnWzBdPT09dlswXSYmQShyKSluW3JdPTAsbltyKzFdPTAsbltyKzJdPTA7ZWxzZXtjb25zdFtzLGYsTV09ZztuW3JdPXMsbltyKzFdPWYsbltyKzJdPU19ZWxzZSBpZihBKHIpKW5bcl09MCxuW3IrMV09MCxuW3IrMl09MDtlbHNle2NvbnN0W3MsZixNXT1tKGQpO25bcl09cyxuW3IrMV09ZixuW3IrMl09TX19ST1fLHBvc3RNZXNzYWdlKHtwb2ludHM6byxjb2xvcjpuLG51bTp5fSl9LHAuaXNJblBvbHlnb249aCxPYmplY3QuZGVmaW5lUHJvcGVydHkocCwiX19lc01vZHVsZSIse3ZhbHVlOiEwfSkscH0oe30pOwoK",null,!1);export{l as default};
@@ -1 +1 @@
1
- var a;(function(t){t[t.A=65]="A",t[t.B=66]="B",t[t.C=67]="C",t[t.D=68]="D",t[t.E=69]="E",t[t.F=70]="F",t[t.G=71]="G",t[t.H=72]="H",t[t.I=73]="I",t[t.O=79]="O",t[t.L=76]="L",t[t.R=82]="R",t[t.Z=90]="Z",t[t.W=87]="W",t[t.X=88]="X",t[t.Y=89]="Y",t[t.S=83]="S",t[t.Q=81]="Q",t[t.One=49]="One",t[t.Two=50]="Two",t[t.Three=51]="Three",t[t.Delete=46]="Delete",t[t.F11=122]="F11",t[t.Space=32]="Space",t[t.Esc=27]="Esc",t[t.Left=37]="Left",t[t.Up=38]="Up",t[t.Right=39]="Right",t[t.Down=40]="Down",t[t.Enter=13]="Enter",t[t.Ctrl=17]="Ctrl",t[t.Alt=18]="Alt",t[t.Shift=16]="Shift",t[t.Tab=9]="Tab",t[t.BackSpace=8]="BackSpace",t[t.Minus=189]="Minus",t[t.Equal=187]="Equal"})(a||(a={}));var n=a;export{n as default};
1
+ var a;(function(t){t[t.A=65]="A",t[t.B=66]="B",t[t.C=67]="C",t[t.D=68]="D",t[t.E=69]="E",t[t.F=70]="F",t[t.G=71]="G",t[t.H=72]="H",t[t.I=73]="I",t[t.O=79]="O",t[t.L=76]="L",t[t.R=82]="R",t[t.Z=90]="Z",t[t.W=87]="W",t[t.X=88]="X",t[t.Y=89]="Y",t[t.S=83]="S",t[t.Q=81]="Q",t[t.P=80]="P",t[t.One=49]="One",t[t.Two=50]="Two",t[t.Three=51]="Three",t[t.Delete=46]="Delete",t[t.F11=122]="F11",t[t.Space=32]="Space",t[t.Esc=27]="Esc",t[t.Left=37]="Left",t[t.Up=38]="Up",t[t.Right=39]="Right",t[t.Down=40]="Down",t[t.Enter=13]="Enter",t[t.Ctrl=17]="Ctrl",t[t.Alt=18]="Alt",t[t.Shift=16]="Shift",t[t.Tab=9]="Tab",t[t.BackSpace=8]="BackSpace",t[t.Minus=189]="Minus",t[t.Equal=187]="Equal"})(a||(a={}));var n=a;export{n as default};
@@ -1 +1 @@
1
- const M=320;var n;(function(o){o.PointCloud="pointCloudTool"})(n||(n={}));var i;(function(o){o.VideoTextTool="videoTextTool",o.VideoTagTool="videoTagTool",o.VideoClipTool="videoClipTool"})(i||(i={}));var l;(function(o){o.AudioTextTool="audioTextTool"})(l||(l={}));var e;(function(o){o[o.Rect=0]="Rect",o[o.Tag=1]="Tag"})(e||(e={}));var u;(function(o){o.Rect="rectTool",o.Tag="tagTool",o.Point="pointTool",o.PointMarker="pointMarkerTool",o.Segmentation="segmentationTool",o.Filter="filterTool",o.Text="textTool",o.Polygon="polygonTool",o.Line="lineTool",o.LineMarker="lineMarkerTool",o.Empty="emptyTool",o.FolderTag="folderTagTool",o.RectTrack="rectTrackTool",o.ScribbleTool="scribbleTool",o.Face="faceTool",o.ClientAttribute="clientAttributeTool",o.OCRRelation="OCRRelationTool",o.SegmentByRect="segmentByRectTool",o.Cuboid="cuboidTool",o.PointCloudPolygon="pointCloudPolygon",o.LLM="LLMTool",o.NLP="NLPTool"})(u||(u={}));var c;(function(o){o.Check="check"})(c||(c={}));var t;(function(o){o[o.nothing=0]="nothing",o[o.RectBG=1]="RectBG",o[o.showOrder=2]="showOrder"})(t||(t={}));const _={[u.Rect]:"\u62C9\u6846",[u.Tag]:"\u6807\u7B7E",[u.Point]:"\u6807\u70B9",[u.PointMarker]:"\u5217\u8868\u6807\u70B9",[u.Segmentation]:"\u524D\u666F\u5206\u5272",[u.Filter]:"\u7B5B\u9009",[u.Text]:"\u6587\u672C",[u.Polygon]:"\u591A\u8FB9\u5F62",[u.Line]:"\u7EBF\u6761",[u.LineMarker]:"\u5217\u8868\u7EBF\u6761",[u.FolderTag]:"\u6587\u4EF6\u5939\u6807\u7B7E",[u.RectTrack]:"\u62C9\u6846\u8DDF\u8E2A",[u.Face]:"\u4EBA\u8138106\u5DE5\u5177",[u.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[u.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177",[u.SegmentByRect]:"\u7B97\u6CD5\u5206\u5272\u8F85\u52A9\u5DE5\u5177",[i.VideoTextTool]:"\u89C6\u9891\u6587\u672C",[i.VideoTagTool]:"\u89C6\u9891\u6807\u7B7E",[i.VideoClipTool]:"\u89C6\u9891\u622A\u53D6",[n.PointCloud]:"\u70B9\u4E91",[u.Cuboid]:"\u7ACB\u4F53\u6846",[u.LLM]:"\u5927\u6A21\u578B",[u.NLP]:"NLP\u6807\u6CE8"},b={[u.Rect]:"Rect",[u.Tag]:"Tag",[u.Point]:"Point",[u.PointMarker]:"PointMarker",[u.Segmentation]:"Segmentation",[u.Filter]:"Filter",[u.Text]:"Text",[u.Polygon]:"Polygon",[u.Line]:"Line",[u.LineMarker]:"LineMarker",[u.FolderTag]:"FolderTag",[u.RectTrack]:"RectTrack",[u.Face]:"Face",[u.ClientAttribute]:"ClientAttribute",[u.OCRRelation]:"OCRRelation",[u.SegmentByRect]:"SegmentByRect",[i.VideoTextTool]:"VideoTextTool",[i.VideoTagTool]:"VideoTagTool",[i.VideoClipTool]:"VideoClipTool",[n.PointCloud]:"PointCloud",[u.Cuboid]:"Cuboid",[u.LLM]:"LLM",[u.NLP]:"NLP"};var r;(function(o){o[o.noDepend=1]="noDepend",o[o.dependOrigin=2]="dependOrigin",o[o.dependShape=3]="dependShape",o[o.dependLine=4]="dependLine",o[o.dependPolygon=5]="dependPolygon",o[o.dependPreShape=101]="dependPreShape",o[o.dependPreLine=102]="dependPreLine",o[o.dependPrePolygon=103]="dependPrePolygon"})(r||(r={}));var C;(function(o){o.lc="leftClick",o.rc="rightClick",o.clc="ctrlLeftClick",o.crc="ctrlRightClick"})(C||(C={}));const O={leftClick:"\u9F20\u6807\u5DE6\u952E",rightClick:"\u9F20\u6807\u53F3\u952E",ctrlLeftClick:"ctrl + \u9F20\u6807\u5DE6\u952E",ctrlRightClick:"ctrl + \u9F20\u6807\u53F3\u952E"};var d;(function(o){o[o.Normal=1]="Normal",o[o.Modify=2]="Modify"})(d||(d={}));var T;(function(o){o[o.Line=0]="Line",o[o.Curve=1]="Curve"})(T||(T={}));var F;(function(o){o[o.SingleColor=0]="SingleColor",o[o.MultiColor=1]="MultiColor"})(F||(F={}));var g;(function(o){o[o.Form=1]="Form",o[o.Json=2]="Json"})(g||(g={}));var L;(function(o){o[o.Point=0]="Point",o[o.Line=1]="Line",o[o.Plane=2]="Plane"})(L||(L={}));var B;(function(o){o[o.None=0]="None",o[o.Drawing=1]="Drawing",o[o.Edit=2]="Edit"})(B||(B={}));var R;(function(o){o[o.Backward=0]="Backward",o[o.Forward=1]="Forward",o[o.JumpSkip=2]="JumpSkip",o[o.None=3]="None"})(R||(R={}));var s;(function(o){o[o.Wait=0]="Wait",o[o.Pass=1]="Pass",o[o.Fail=2]="Fail",o[o.Loading=3]="Loading"})(s||(s={}));var k;(function(o){o[o.AnyString=0]="AnyString",o[o.Order=1]="Order",o[o.EnglishOnly=2]="EnglishOnly",o[o.NumberOnly=3]="NumberOnly",o[o.CustomFormat=4]="CustomFormat"})(k||(k={}));const S={0:"\u4EFB\u610F\u5B57\u7B26",1:"\u5E8F\u53F7",2:"\u4EC5\u82F1\u6587",3:"\u4EC5\u6570\u5B57"},h=1e3,I=16,P=300,V="normal normal 500 14px Arial";var a;(function(o){o[o.ImgList=1e3]="ImgList",o[o.TrackPrediction=1001]="TrackPrediction",o[o.ImgSearch=1002]="ImgSearch"})(a||(a={}));const m={[n.PointCloud]:"sensebeepc",[u.ClientAttribute]:"sensebeepc-EnumAttributeTool",[u.Face]:"sensebeepc-FacePointsLabellingTool",[u.OCRRelation]:"sensebeepc-OCRRelationTool"},y={[n.PointCloud]:"\u70B9\u4E91\u5BA2\u6237\u7AEF",[u.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[u.Face]:"\u4EBA\u8138106\u70B9\u5DE5\u5177",[u.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177"},N=16,G=10;var f;(function(o){o[o.Normal=0]="Normal",o[o.Rect=1]="Rect"})(f||(f={}));var A;(function(o){o[o.Scribble=1]="Scribble",o[o.Erase=2]="Erase"})(A||(A={}));var v;(function(o){o[o.General=1]="General",o[o.MultiMove=2]="MultiMove"})(v||(v={}));export{m as CLIENT_TOOL_HEAD_TYPE,y as CLIENT_TOOL_NAME,V as DEFAULT_FONT,P as DEFAULT_TEXT_MAX_WIDTH,d as EAnnotationMode,l as EAudioToolName,s as EAuditStatus,c as ECheckModel,r as EDependPattern,L as EDragTarget,B as EDrawPointPattern,C as EFilterToolOperation,F as ELineColor,T as ELineTypes,v as EOperationMode,R as EPageOperator,n as EPointCloudName,f as EPolygonPattern,t as ERectPattern,A as EScribblePattern,g as ESelectedType,k as ETextType,a as EThumbnailOption,u as EToolName,e as EToolType,i as EVideoToolName,O as OPERATION_LIST,N as SEGMENT_NUMBER,I as TEXT_ATTRIBUTE_LINE_HEIGHT,h as TEXT_ATTRIBUTE_MAX_LENGTH,S as TEXT_TYPE,_ as TOOL_NAME,b as TOOL_NAME_EN,G as edgeAdsorptionScope,M as editStepWidth};
1
+ const v=320;var n;(function(u){u.PointCloud="pointCloudTool"})(n||(n={}));var i;(function(u){u.VideoTextTool="videoTextTool",u.VideoTagTool="videoTagTool",u.VideoClipTool="videoClipTool"})(i||(i={}));var l;(function(u){u.AudioTextTool="audioTextTool"})(l||(l={}));var e;(function(u){u[u.Rect=0]="Rect",u[u.Tag=1]="Tag"})(e||(e={}));var o;(function(u){u.Rect="rectTool",u.Tag="tagTool",u.Point="pointTool",u.PointMarker="pointMarkerTool",u.Segmentation="segmentationTool",u.Filter="filterTool",u.Text="textTool",u.Polygon="polygonTool",u.Line="lineTool",u.LineMarker="lineMarkerTool",u.Empty="emptyTool",u.FolderTag="folderTagTool",u.RectTrack="rectTrackTool",u.ScribbleTool="scribbleTool",u.Face="faceTool",u.ClientAttribute="clientAttributeTool",u.OCRRelation="OCRRelationTool",u.SegmentByRect="segmentByRectTool",u.Cuboid="cuboidTool",u.PointCloudPolygon="pointCloudPolygon",u.LLM="LLMTool",u.NLP="NLPTool",u.LLMMultiWheel="LLMMultiWheelTool"})(o||(o={}));var c;(function(u){u.Check="check"})(c||(c={}));var t;(function(u){u[u.nothing=0]="nothing",u[u.RectBG=1]="RectBG",u[u.showOrder=2]="showOrder"})(t||(t={}));const h={[o.Rect]:"\u62C9\u6846",[o.Tag]:"\u6807\u7B7E",[o.Point]:"\u6807\u70B9",[o.PointMarker]:"\u5217\u8868\u6807\u70B9",[o.Segmentation]:"\u524D\u666F\u5206\u5272",[o.Filter]:"\u7B5B\u9009",[o.Text]:"\u6587\u672C",[o.Polygon]:"\u591A\u8FB9\u5F62",[o.Line]:"\u7EBF\u6761",[o.LineMarker]:"\u5217\u8868\u7EBF\u6761",[o.FolderTag]:"\u6587\u4EF6\u5939\u6807\u7B7E",[o.RectTrack]:"\u62C9\u6846\u8DDF\u8E2A",[o.Face]:"\u4EBA\u8138106\u5DE5\u5177",[o.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[o.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177",[o.SegmentByRect]:"\u7B97\u6CD5\u5206\u5272\u8F85\u52A9\u5DE5\u5177",[i.VideoTextTool]:"\u89C6\u9891\u6587\u672C",[i.VideoTagTool]:"\u89C6\u9891\u6807\u7B7E",[i.VideoClipTool]:"\u89C6\u9891\u622A\u53D6",[n.PointCloud]:"\u70B9\u4E91",[o.Cuboid]:"\u7ACB\u4F53\u6846",[o.LLM]:"\u5927\u6A21\u578B",[o.NLP]:"NLP\u6807\u6CE8",[o.LLMMultiWheel]:"\u5927\u6A21\u578B\uFF08\u591A\u8F6E\u5BF9\u8BDD\uFF09"},_={[o.Rect]:"Rect",[o.Tag]:"Tag",[o.Point]:"Point",[o.PointMarker]:"PointMarker",[o.Segmentation]:"Segmentation",[o.Filter]:"Filter",[o.Text]:"Text",[o.Polygon]:"Polygon",[o.Line]:"Line",[o.LineMarker]:"LineMarker",[o.FolderTag]:"FolderTag",[o.RectTrack]:"RectTrack",[o.Face]:"Face",[o.ClientAttribute]:"ClientAttribute",[o.OCRRelation]:"OCRRelation",[o.SegmentByRect]:"SegmentByRect",[i.VideoTextTool]:"VideoTextTool",[i.VideoTagTool]:"VideoTagTool",[i.VideoClipTool]:"VideoClipTool",[n.PointCloud]:"PointCloud",[o.Cuboid]:"Cuboid",[o.LLM]:"LLM",[o.NLP]:"NLP",[o.LLMMultiWheel]:"LLMMultiWheelTool"};var r;(function(u){u[u.noDepend=1]="noDepend",u[u.dependOrigin=2]="dependOrigin",u[u.dependShape=3]="dependShape",u[u.dependLine=4]="dependLine",u[u.dependPolygon=5]="dependPolygon",u[u.dependPreShape=101]="dependPreShape",u[u.dependPreLine=102]="dependPreLine",u[u.dependPrePolygon=103]="dependPrePolygon"})(r||(r={}));var C;(function(u){u.lc="leftClick",u.rc="rightClick",u.clc="ctrlLeftClick",u.crc="ctrlRightClick"})(C||(C={}));const b={leftClick:"\u9F20\u6807\u5DE6\u952E",rightClick:"\u9F20\u6807\u53F3\u952E",ctrlLeftClick:"ctrl + \u9F20\u6807\u5DE6\u952E",ctrlRightClick:"ctrl + \u9F20\u6807\u53F3\u952E"};var d;(function(u){u[u.Normal=1]="Normal",u[u.Modify=2]="Modify"})(d||(d={}));var L;(function(u){u[u.Line=0]="Line",u[u.Curve=1]="Curve"})(L||(L={}));var F;(function(u){u[u.SingleColor=0]="SingleColor",u[u.MultiColor=1]="MultiColor"})(F||(F={}));var T;(function(u){u[u.Form=1]="Form",u[u.Json=2]="Json"})(T||(T={}));var g;(function(u){u[u.Point=0]="Point",u[u.Line=1]="Line",u[u.Plane=2]="Plane"})(g||(g={}));var B;(function(u){u[u.None=0]="None",u[u.Drawing=1]="Drawing",u[u.Edit=2]="Edit"})(B||(B={}));var R;(function(u){u[u.Backward=0]="Backward",u[u.Forward=1]="Forward",u[u.JumpSkip=2]="JumpSkip",u[u.None=3]="None"})(R||(R={}));var M;(function(u){u[u.Wait=0]="Wait",u[u.Pass=1]="Pass",u[u.Fail=2]="Fail",u[u.Loading=3]="Loading"})(M||(M={}));var s;(function(u){u[u.AnyString=0]="AnyString",u[u.Order=1]="Order",u[u.EnglishOnly=2]="EnglishOnly",u[u.NumberOnly=3]="NumberOnly",u[u.CustomFormat=4]="CustomFormat"})(s||(s={}));const O={0:"\u4EFB\u610F\u5B57\u7B26",1:"\u5E8F\u53F7",2:"\u4EC5\u82F1\u6587",3:"\u4EC5\u6570\u5B57"},S=1e3,I=16,P=300,V="normal normal 500 14px Arial";var A;(function(u){u[u.ImgList=1e3]="ImgList",u[u.TrackPrediction=1001]="TrackPrediction",u[u.ImgSearch=1002]="ImgSearch"})(A||(A={}));const y={[n.PointCloud]:"sensebeepc",[o.ClientAttribute]:"sensebeepc-EnumAttributeTool",[o.Face]:"sensebeepc-FacePointsLabellingTool",[o.OCRRelation]:"sensebeepc-OCRRelationTool"},m={[n.PointCloud]:"\u70B9\u4E91\u5BA2\u6237\u7AEF",[o.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[o.Face]:"\u4EBA\u8138106\u70B9\u5DE5\u5177",[o.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177"},W=16,N=10;var k;(function(u){u[u.Normal=0]="Normal",u[u.Rect=1]="Rect"})(k||(k={}));var f;(function(u){u[u.Scribble=1]="Scribble",u[u.Erase=2]="Erase"})(f||(f={}));var a;(function(u){u[u.General=1]="General",u[u.MultiMove=2]="MultiMove"})(a||(a={}));export{y as CLIENT_TOOL_HEAD_TYPE,m as CLIENT_TOOL_NAME,V as DEFAULT_FONT,P as DEFAULT_TEXT_MAX_WIDTH,d as EAnnotationMode,l as EAudioToolName,M as EAuditStatus,c as ECheckModel,r as EDependPattern,g as EDragTarget,B as EDrawPointPattern,C as EFilterToolOperation,F as ELineColor,L as ELineTypes,a as EOperationMode,R as EPageOperator,n as EPointCloudName,k as EPolygonPattern,t as ERectPattern,f as EScribblePattern,T as ESelectedType,s as ETextType,A as EThumbnailOption,o as EToolName,e as EToolType,i as EVideoToolName,b as OPERATION_LIST,W as SEGMENT_NUMBER,I as TEXT_ATTRIBUTE_LINE_HEIGHT,S as TEXT_ATTRIBUTE_MAX_LENGTH,O as TEXT_TYPE,h as TOOL_NAME,_ as TOOL_NAME_EN,N as edgeAdsorptionScope,v as editStepWidth};
@@ -1 +1 @@
1
- import{EventDispatcher as je,Vector3 as b,MOUSE as R,TOUCH as j,Quaternion as le,Spherical as ue,Vector2 as p}from"three";var xe=Object.defineProperty,Se=(T,u,m)=>u in T?xe(T,u,{enumerable:!0,configurable:!0,writable:!0,value:m}):T[u]=m,Ie=(T,u,m)=>(Se(T,typeof u!="symbol"?u+"":u,m),m);const pe={type:"change"},Z={type:"start"},me={type:"end"};class ke extends je{constructor(u,m){super();Ie(this,"listenToKeyEvents",t=>{t.addEventListener("keydown",onKeyDown),this._domElementKeyEvents=t}),m===void 0&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),m===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=u,this.domElement=m,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new b,this.minDistance=0,this.maxDistance=Infinity,this.minZoom=0,this.maxZoom=Infinity,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-Infinity,this.maxAzimuthAngle=Infinity,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:R.ROTATE,MIDDLE:R.DOLLY,RIGHT:R.PAN},this.touches={ONE:j.ROTATE,TWO:j.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return s.phi},this.getAzimuthalAngle=function(){return s.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.saveState=function(){e.target0.copy(e.target),e.position0.copy(e.object.position),e.zoom0=e.object.zoom},this.reset=function(){e.target.copy(e.target0),e.object.position.copy(e.position0),e.object.zoom=e.zoom0,e.object.updateProjectionMatrix(),e.dispatchEvent(pe),e.update(),i=a.NONE},this.update=function(){const t=new b,n=new le().setFromUnitVectors(u.up,new b(0,1,0)),r=n.clone().invert(),c=new b,l=new le,N=2*Math.PI;return function(){const{position:ce}=e.object;t.copy(ce).sub(e.target),t.applyQuaternion(n),s.setFromVector3(t),e.autoRotate&&i===a.NONE&&C(he()),e.enableDamping?(s.theta+=h.theta*e.dampingFactor,s.phi+=h.phi*e.dampingFactor):(s.theta+=h.theta,s.phi+=h.phi);let d=e.minAzimuthAngle,f=e.maxAzimuthAngle;return isFinite(d)&&isFinite(f)&&(d<-Math.PI?d+=N:d>Math.PI&&(d-=N),f<-Math.PI?f+=N:f>Math.PI&&(f-=N),d<=f?s.theta=Math.max(d,Math.min(f,s.theta)):s.theta=s.theta>(d+f)/2?Math.max(d,s.theta):Math.min(f,s.theta)),s.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,s.phi)),s.makeSafe(),s.radius*=S,s.radius=Math.max(e.minDistance,Math.min(e.maxDistance,s.radius)),e.enableDamping===!0?e.target.addScaledVector(O,e.dampingFactor):e.target.add(O),t.setFromSpherical(s),t.applyQuaternion(r),ce.copy(e.target).add(t),e.object.lookAt(e.target),e.enableDamping===!0?(h.theta*=1-e.dampingFactor,h.phi*=1-e.dampingFactor,O.multiplyScalar(1-e.dampingFactor)):(h.set(0,0,0),O.set(0,0,0)),S=1,I||c.distanceToSquared(e.object.position)>F||8*(1-l.dot(e.object.quaternion))>F?(e.dispatchEvent(pe),c.copy(e.object.position),l.copy(e.object.quaternion),I=!1,!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",ie),e.domElement.removeEventListener("pointerdown",ne),e.domElement.removeEventListener("pointercancel",oe),e.domElement.removeEventListener("wheel",ae),e.domElement.removeEventListener("pointermove",v),e.domElement.removeEventListener("pointerup",z),e._domElementKeyEvents!==null&&e._domElementKeyEvents.removeEventListener("keydown",Le)};const e=this,a={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let i=a.NONE;const F=1e-6,s=new ue,h=new ue;let S=1;const O=new b;let I=!1;const E=new p,g=new p,w=new p,y=new p,P=new p,M=new p,A=new p,L=new p,x=new p,o=[],k={};function he(){return 2*Math.PI/60/60*e.autoRotateSpeed}function Y(){return Math.pow(.95,e.zoomSpeed)}function C(t){h.theta-=t}function X(t){h.phi-=t}const K=function(){const t=new b;return function(r,c){t.setFromMatrixColumn(c,0),t.multiplyScalar(-r),O.add(t)}}(),V=function(){const t=new b;return function(r,c){e.screenSpacePanning===!0?t.setFromMatrixColumn(c,1):(t.setFromMatrixColumn(c,0),t.crossVectors(e.object.up,t)),t.multiplyScalar(r),O.add(t)}}(),D=function(){const t=new b;return function(r,c){const l=e.domElement;if(e.object.isPerspectiveCamera){const{position:N}=e.object;t.copy(N).sub(e.target);let _=t.length();_*=Math.tan(e.object.fov/2*Math.PI/180),K(2*r*_/l.clientHeight,e.object.matrix),V(2*c*_/l.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(K(r*(e.object.right-e.object.left)/e.object.zoom/l.clientWidth,e.object.matrix),V(c*(e.object.top-e.object.bottom)/e.object.zoom/l.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function H(t){e.object.isPerspectiveCamera?S/=t:e.object.isOrthographicCamera?(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom*t)),e.object.updateProjectionMatrix(),I=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function W(t){e.object.isPerspectiveCamera?S*=t:e.object.isOrthographicCamera?(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/t)),e.object.updateProjectionMatrix(),I=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function q(t){E.set(t.clientX,t.clientY)}function de(t){A.set(t.clientX,t.clientY)}function G(t){y.set(t.clientX,t.clientY)}function fe(t){g.set(t.clientX,t.clientY),w.subVectors(g,E).multiplyScalar(e.rotateSpeed);const n=e.domElement;C(2*Math.PI*w.x/n.clientHeight),X(2*Math.PI*w.y/n.clientHeight),E.copy(g),e.update()}function be(t){L.set(t.clientX,t.clientY),x.subVectors(L,A),x.y>0?H(Y()):x.y<0&&W(Y()),A.copy(L),e.update()}function Ee(t){P.set(t.clientX,t.clientY),M.subVectors(P,y).multiplyScalar(e.panSpeed),D(M.x,M.y),y.copy(P),e.update()}function ge(t){t.deltaY<0?W(Y()):t.deltaY>0&&H(Y()),e.update()}function ye(t){let n=!1;switch(t.code){case e.keys.UP:D(0,e.keyPanSpeed),n=!0;break;case e.keys.BOTTOM:D(0,-e.keyPanSpeed),n=!0;break;case e.keys.LEFT:D(e.keyPanSpeed,0),n=!0;break;case e.keys.RIGHT:D(-e.keyPanSpeed,0),n=!0;break}n&&(t.preventDefault(),e.update())}function B(){if(o.length===1)E.set(o[0].pageX,o[0].pageY);else{const t=.5*(o[0].pageX+o[1].pageX),n=.5*(o[0].pageY+o[1].pageY);E.set(t,n)}}function Q(){if(o.length===1)y.set(o[0].pageX,o[0].pageY);else{const t=.5*(o[0].pageX+o[1].pageX),n=.5*(o[0].pageY+o[1].pageY);y.set(t,n)}}function J(){const t=o[0].pageX-o[1].pageX,n=o[0].pageY-o[1].pageY,r=Math.sqrt(t*t+n*n);A.set(0,r)}function Pe(){e.enableZoom&&J(),e.enablePan&&Q()}function Te(){e.enableZoom&&J(),e.enableRotate&&B()}function $(t){if(o.length==1)g.set(t.pageX,t.pageY);else{const r=U(t),c=.5*(t.pageX+r.x),l=.5*(t.pageY+r.y);g.set(c,l)}w.subVectors(g,E).multiplyScalar(e.rotateSpeed);const n=e.domElement;C(2*Math.PI*w.x/n.clientHeight),X(2*Math.PI*w.y/n.clientHeight),E.copy(g)}function ee(t){if(o.length===1)P.set(t.pageX,t.pageY);else{const n=U(t),r=.5*(t.pageX+n.x),c=.5*(t.pageY+n.y);P.set(r,c)}M.subVectors(P,y).multiplyScalar(e.panSpeed),D(M.x,M.y),y.copy(P)}function te(t){const n=U(t),r=t.pageX-n.x,c=t.pageY-n.y,l=Math.sqrt(r*r+c*c);L.set(0,l),x.set(0,Math.pow(L.y/A.y,e.zoomSpeed)),H(x.y),A.copy(L)}function Oe(t){e.enableZoom&&te(t),e.enablePan&&ee(t)}function we(t){e.enableZoom&&te(t),e.enableRotate&&$(t)}function ne(t){e.enabled!==!1&&(o.length===0&&(e.domElement.setPointerCapture(t.pointerId),e.domElement.addEventListener("pointermove",v),e.domElement.addEventListener("pointerup",z)),Re(t),t.pointerType==="touch"?De(t):Me(t))}function v(t){e.enabled!==!1&&(t.pointerType==="touch"?Ne(t):Ae(t))}function z(t){se(t),o.length===0&&(e.domElement.releasePointerCapture(t.pointerId),e.domElement.removeEventListener("pointermove",v),e.domElement.removeEventListener("pointerup",z)),e.dispatchEvent(me),i=a.NONE}function oe(t){se(t)}function Me(t){let n;switch(t.button){case 0:n=e.mouseButtons.LEFT;break;case 1:n=e.mouseButtons.MIDDLE;break;case 2:n=e.mouseButtons.RIGHT;break;default:n=-1}switch(n){case R.DOLLY:if(e.enableZoom===!1)return;de(t),i=a.DOLLY;break;case R.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(e.enablePan===!1)return;G(t),i=a.PAN}else{if(e.enableRotate===!1)return;q(t),i=a.ROTATE}break;case R.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(e.enableRotate===!1)return;q(t),i=a.ROTATE}else{if(e.enablePan===!1)return;G(t),i=a.PAN}break;default:i=a.NONE}i!==a.NONE&&e.dispatchEvent(Z)}function Ae(t){if(e.enabled!==!1)switch(i){case a.ROTATE:if(e.enableRotate===!1)return;fe(t);break;case a.DOLLY:if(e.enableZoom===!1)return;be(t);break;case a.PAN:if(e.enablePan===!1)return;Ee(t);break}}function ae(t){e.enabled===!1||e.enableZoom===!1||i!==a.NONE||(t.preventDefault(),e.dispatchEvent(Z),ge(t),e.dispatchEvent(me))}function Le(t){e.enabled===!1||e.enablePan===!1||ye(t)}function De(t){switch(re(t),o.length){case 1:switch(e.touches.ONE){case j.ROTATE:if(e.enableRotate===!1)return;B(),i=a.TOUCH_ROTATE;break;case j.PAN:if(e.enablePan===!1)return;Q(),i=a.TOUCH_PAN;break;default:i=a.NONE}break;case 2:switch(e.touches.TWO){case j.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Pe(),i=a.TOUCH_DOLLY_PAN;break;case j.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;Te(),i=a.TOUCH_DOLLY_ROTATE;break;default:i=a.NONE}break;default:i=a.NONE}i!==a.NONE&&e.dispatchEvent(Z)}function Ne(t){switch(re(t),i){case a.TOUCH_ROTATE:if(e.enableRotate===!1)return;$(t),e.update();break;case a.TOUCH_PAN:if(e.enablePan===!1)return;ee(t),e.update();break;case a.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Oe(t),e.update();break;case a.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;we(t),e.update();break;default:i=a.NONE}}function ie(t){e.enabled!==!1&&t.preventDefault()}function Re(t){o.push(t)}function se(t){delete k[t.pointerId];for(let n=0;n<o.length;n++)if(o[n].pointerId==t.pointerId){o.splice(n,1);return}}function re(t){let n=k[t.pointerId];n===void 0&&(n=new p,k[t.pointerId]=n),n.set(t.pageX,t.pageY)}function U(t){const n=t.pointerId===o[0].pointerId?o[1]:o[0];return k[n.pointerId]}e.domElement.addEventListener("contextmenu",ie),e.domElement.addEventListener("pointerdown",ne),e.domElement.addEventListener("pointercancel",oe),e.domElement.addEventListener("wheel",ae,{passive:!1}),this.update()}}export{ke as OrbitControls};
1
+ import{EventDispatcher as je,Vector3 as b,MOUSE as R,TOUCH as j,Quaternion as le,Spherical as ue,Vector2 as p}from"three";var xe=Object.defineProperty,Se=(T,u,m)=>u in T?xe(T,u,{enumerable:!0,configurable:!0,writable:!0,value:m}):T[u]=m,ke=(T,u,m)=>(Se(T,typeof u!="symbol"?u+"":u,m),m);const pe={type:"change"},Z={type:"start"},me={type:"end"};class Ie extends je{constructor(u,m){super();ke(this,"listenToKeyEvents",t=>{t.addEventListener("keydown",onKeyDown),this._domElementKeyEvents=t}),m===void 0&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),m===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=u,this.domElement=m,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new b,this.minDistance=0,this.maxDistance=Infinity,this.minZoom=0,this.maxZoom=Infinity,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-Infinity,this.maxAzimuthAngle=Infinity,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:R.ROTATE,MIDDLE:R.DOLLY,RIGHT:R.PAN},this.touches={ONE:j.ROTATE,TWO:j.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return s.phi},this.getAzimuthalAngle=function(){return s.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.saveState=function(){e.target0.copy(e.target),e.position0.copy(e.object.position),e.zoom0=e.object.zoom},this.reset=function(){e.target.copy(e.target0),e.object.position.copy(e.position0),e.object.zoom=e.zoom0,e.object.updateProjectionMatrix(),e.dispatchEvent(pe),e.update(),i=a.NONE},this.update=function(){const t=new b,n=new le().setFromUnitVectors(u.up,new b(0,1,0)),r=n.clone().invert(),c=new b,l=new le,N=2*Math.PI;return function(){const{position:ce}=e.object;t.copy(ce).sub(e.target),t.applyQuaternion(n),s.setFromVector3(t),e.autoRotate&&i===a.NONE&&_(he()),e.enableDamping?(s.theta+=h.theta*e.dampingFactor,s.phi+=h.phi*e.dampingFactor):(s.theta+=h.theta,s.phi+=h.phi);let d=e.minAzimuthAngle,f=e.maxAzimuthAngle;return isFinite(d)&&isFinite(f)&&(d<-Math.PI?d+=N:d>Math.PI&&(d-=N),f<-Math.PI?f+=N:f>Math.PI&&(f-=N),d<=f?s.theta=Math.max(d,Math.min(f,s.theta)):s.theta=s.theta>(d+f)/2?Math.max(d,s.theta):Math.min(f,s.theta)),s.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,s.phi)),s.makeSafe(),s.radius*=S,s.radius=Math.max(e.minDistance,Math.min(e.maxDistance,s.radius)),e.enableDamping===!0?e.target.addScaledVector(O,e.dampingFactor):e.target.add(O),t.setFromSpherical(s),t.applyQuaternion(r),ce.copy(e.target).add(t),e.object.lookAt(e.target),e.enableDamping===!0?(h.theta*=1-e.dampingFactor,h.phi*=1-e.dampingFactor,O.multiplyScalar(1-e.dampingFactor)):(h.set(0,0,0),O.set(0,0,0)),S=1,k||c.distanceToSquared(e.object.position)>F||8*(1-l.dot(e.object.quaternion))>F?(e.dispatchEvent(pe),c.copy(e.object.position),l.copy(e.object.quaternion),k=!1,!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",ie),e.domElement.removeEventListener("pointerdown",ne),e.domElement.removeEventListener("pointercancel",oe),e.domElement.removeEventListener("wheel",ae),e.domElement.removeEventListener("pointermove",v),e.domElement.removeEventListener("pointerup",z),e._domElementKeyEvents!==null&&e._domElementKeyEvents.removeEventListener("keydown",Le)};const e=this,a={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let i=a.NONE;const F=1e-6,s=new ue,h=new ue;let S=1;const O=new b;let k=!1;const E=new p,g=new p,w=new p,y=new p,P=new p,M=new p,A=new p,L=new p,x=new p,o=[],I={};function he(){return 2*Math.PI/60/60*e.autoRotateSpeed}function Y(){return Math.pow(.95,e.zoomSpeed)}function _(t){h.theta-=t}function X(t){h.phi-=t}const K=function(){const t=new b;return function(r,c){t.setFromMatrixColumn(c,0),t.multiplyScalar(-r),O.add(t)}}(),V=function(){const t=new b;return function(r,c){e.screenSpacePanning===!0?t.setFromMatrixColumn(c,1):(t.setFromMatrixColumn(c,0),t.crossVectors(e.object.up,t)),t.multiplyScalar(r),O.add(t)}}(),D=function(){const t=new b;return function(r,c){const l=e.domElement;if(e.object.isPerspectiveCamera){const{position:N}=e.object;t.copy(N).sub(e.target);let C=t.length();C*=Math.tan(e.object.fov/2*Math.PI/180),K(2*r*C/l.clientHeight,e.object.matrix),V(2*c*C/l.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(K(r*(e.object.right-e.object.left)/e.object.zoom/l.clientWidth,e.object.matrix),V(c*(e.object.top-e.object.bottom)/e.object.zoom/l.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function H(t){e.object.isPerspectiveCamera?S/=t:e.object.isOrthographicCamera?(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom*t)),e.object.updateProjectionMatrix(),k=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function W(t){e.object.isPerspectiveCamera?S*=t:e.object.isOrthographicCamera?(e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/t)),e.object.updateProjectionMatrix(),k=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function q(t){E.set(t.clientX,t.clientY)}function de(t){A.set(t.clientX,t.clientY)}function G(t){y.set(t.clientX,t.clientY)}function fe(t){g.set(t.clientX,t.clientY),w.subVectors(g,E).multiplyScalar(e.rotateSpeed);const n=e.domElement;_(2*Math.PI*w.x/n.clientHeight),X(2*Math.PI*w.y/n.clientHeight),E.copy(g),e.update()}function be(t){L.set(t.clientX,t.clientY),x.subVectors(L,A),x.y>0?H(Y()):x.y<0&&W(Y()),A.copy(L),e.update()}function Ee(t){P.set(t.clientX,t.clientY),M.subVectors(P,y).multiplyScalar(e.panSpeed),D(M.x,M.y),y.copy(P),e.update()}function ge(t){t.deltaY<0?W(Y()):t.deltaY>0&&H(Y()),e.update()}function ye(t){let n=!1;switch(t.code){case e.keys.UP:D(0,e.keyPanSpeed),n=!0;break;case e.keys.BOTTOM:D(0,-e.keyPanSpeed),n=!0;break;case e.keys.LEFT:D(e.keyPanSpeed,0),n=!0;break;case e.keys.RIGHT:D(-e.keyPanSpeed,0),n=!0;break}n&&(t.preventDefault(),e.update())}function B(){if(o.length===1)E.set(o[0].pageX,o[0].pageY);else{const t=.5*(o[0].pageX+o[1].pageX),n=.5*(o[0].pageY+o[1].pageY);E.set(t,n)}}function Q(){if(o.length===1)y.set(o[0].pageX,o[0].pageY);else{const t=.5*(o[0].pageX+o[1].pageX),n=.5*(o[0].pageY+o[1].pageY);y.set(t,n)}}function J(){const t=o[0].pageX-o[1].pageX,n=o[0].pageY-o[1].pageY,r=Math.sqrt(t*t+n*n);A.set(0,r)}function Pe(){e.enableZoom&&J(),e.enablePan&&Q()}function Te(){e.enableZoom&&J(),e.enableRotate&&B()}function $(t){if(o.length==1)g.set(t.pageX,t.pageY);else{const r=U(t),c=.5*(t.pageX+r.x),l=.5*(t.pageY+r.y);g.set(c,l)}w.subVectors(g,E).multiplyScalar(e.rotateSpeed);const n=e.domElement;_(2*Math.PI*w.x/n.clientHeight),X(2*Math.PI*w.y/n.clientHeight),E.copy(g)}function ee(t){if(o.length===1)P.set(t.pageX,t.pageY);else{const n=U(t),r=.5*(t.pageX+n.x),c=.5*(t.pageY+n.y);P.set(r,c)}M.subVectors(P,y).multiplyScalar(e.panSpeed),D(M.x,M.y),y.copy(P)}function te(t){const n=U(t),r=t.pageX-n.x,c=t.pageY-n.y,l=Math.sqrt(r*r+c*c);L.set(0,l),x.set(0,Math.pow(L.y/A.y,e.zoomSpeed)),H(x.y),A.copy(L)}function Oe(t){e.enableZoom&&te(t),e.enablePan&&ee(t)}function we(t){e.enableZoom&&te(t),e.enableRotate&&$(t)}function ne(t){e.enabled!==!1&&(o.length===0&&(e.domElement.setPointerCapture(t.pointerId),e.domElement.addEventListener("pointermove",v),e.domElement.addEventListener("pointerup",z)),Re(t),t.pointerType==="touch"?De(t):Me(t))}function v(t){e.enabled!==!1&&(t.pointerType==="touch"?Ne(t):Ae(t))}function z(t){se(t),o.length===0&&(e.domElement.releasePointerCapture(t.pointerId),e.domElement.removeEventListener("pointermove",v),e.domElement.removeEventListener("pointerup",z)),e.dispatchEvent(me),i=a.NONE}function oe(t){se(t)}function Me(t){let n;switch(t.button){case 0:n=e.mouseButtons.LEFT;break;case 1:n=e.mouseButtons.MIDDLE;break;case 2:n=e.mouseButtons.RIGHT;break;default:n=-1}switch(n){case R.DOLLY:if(e.enableZoom===!1)return;de(t),i=a.DOLLY;break;case R.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(e.enablePan===!1)return;G(t),i=a.PAN}else{if(e.enableRotate===!1)return;q(t),i=a.ROTATE}break;case R.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(e.enableRotate===!1)return;q(t),i=a.ROTATE}else{if(e.enablePan===!1)return;G(t),i=a.PAN}break;default:i=a.NONE}i!==a.NONE&&e.dispatchEvent(Z)}function Ae(t){if(e.enabled!==!1)switch(i){case a.ROTATE:if(e.enableRotate===!1)return;fe(t);break;case a.DOLLY:if(e.enableZoom===!1)return;be(t);break;case a.PAN:if(e.enablePan===!1)return;Ee(t);break}}function ae(t){e.enabled===!1||e.enableZoom===!1||i!==a.NONE||(t.preventDefault(),e.dispatchEvent(Z),ge(t),e.dispatchEvent(me))}function Le(t){e.enabled===!1||e.enablePan===!1||ye(t)}function De(t){switch(re(t),o.length){case 1:switch(e.touches.ONE){case j.ROTATE:if(e.enableRotate===!1)return;B(),i=a.TOUCH_ROTATE;break;case j.PAN:if(e.enablePan===!1)return;Q(),i=a.TOUCH_PAN;break;default:i=a.NONE}break;case 2:switch(e.touches.TWO){case j.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Pe(),i=a.TOUCH_DOLLY_PAN;break;case j.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;Te(),i=a.TOUCH_DOLLY_ROTATE;break;default:i=a.NONE}break;default:i=a.NONE}i!==a.NONE&&e.dispatchEvent(Z)}function Ne(t){switch(re(t),i){case a.TOUCH_ROTATE:if(e.enableRotate===!1)return;$(t),e.update();break;case a.TOUCH_PAN:if(e.enablePan===!1)return;ee(t),e.update();break;case a.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Oe(t),e.update();break;case a.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;we(t),e.update();break;default:i=a.NONE}}function ie(t){e.enabled!==!1&&(t.preventDefault(),e.dispatchEvent({type:"rightClick",originalEvent:t}))}function Re(t){o.push(t)}function se(t){delete I[t.pointerId];for(let n=0;n<o.length;n++)if(o[n].pointerId==t.pointerId){o.splice(n,1);return}}function re(t){let n=I[t.pointerId];n===void 0&&(n=new p,I[t.pointerId]=n),n.set(t.pageX,t.pageY)}function U(t){const n=t.pointerId===o[0].pointerId?o[1]:o[0];return I[n.pointerId]}e.domElement.addEventListener("contextmenu",ie),e.domElement.addEventListener("pointerdown",ne),e.domElement.addEventListener("pointercancel",oe),e.domElement.addEventListener("wheel",ae,{passive:!1}),this.update()}}export{Ie as OrbitControls};
@@ -1,4 +1,4 @@
1
- import*as a from"three";import{toolStyleConverter as L,PerspectiveShiftUtils as B,EPerspectiveView as C,PointCloudUtils as E,DEFAULT_SPHERE_PARAMS as O}from"@labelbee/lb-utils";import V from"../../_virtual/highlightWorker.js";import R from"../../_virtual/filterBoxWorker.js";import{isInPolygon as H}from"../../utils/tool/polygonTool.js";import k from"../../utils/uuid.js";import A from"../../utils/MathUtils.js";import W from"../../utils/ImgUtils.js";import{PCDLoader as Z}from"./PCDLoader.js";import{OrbitControls as U}from"./OrbitControls.js";import{PointCloudCache as G}from"./cache.js";import{getCuboidFromPointCloudBox as D,getHighlightIndexByPoints as $,mergeHighlightList as Y}from"./matrix.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,getHighlightIndexByPoints,isFisheyeCalibValid,isInImage,isMatrixValid,isMatrixValidByArr,lidar2FisheyeImage,lidar2image,mergeHighlightList,oCamFisheyeTransfer,omniCamera11VTransfer,point3DLidar2Image,pointCloudLidar2image,pointListLidar2Img,pointMappingLidar2image,rotatePoint,transferKitti2Matrix}from"./matrix.js";import{PointCloudSegmentOperation as X}from"./segmentation.js";import q from"./store/index.js";import K from"./render/index.js";import Q from"../toolOperation/eventListener.js";import"../../constant/tool.js";import"../scheduler.js";var J=Object.defineProperty,tt=Object.defineProperties,et=Object.getOwnPropertyDescriptors,_=Object.getOwnPropertySymbols,it=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable,j=(w,t,e)=>t in w?J(w,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):w[t]=e,b=(w,t)=>{for(var e in t||(t={}))it.call(t,e)&&j(w,e,t[e]);if(_)for(var e of _(t))rt.call(t,e)&&j(w,e,t[e]);return w},P=(w,t)=>tt(w,et(t)),S=(w,t,e)=>new Promise((i,r)=>{var o=d=>{try{s(e.next(d))}catch(n){r(n)}},h=d=>{try{s(e.throw(d))}catch(n){r(n)}},s=d=>d.done?i(d.value):Promise.resolve(d.value).then(o,h);s((e=e.apply(w,t)).next())});const nt=30,I=new V({type:"module"});class ot extends Q{constructor({container:t,noAppend:e,isOrthographicCamera:i,orthographicParams:r,backgroundColor:o="#4C4C4C",config:h,isSegment:s,checkMode:d}){super();this.zAxisLimit=10,this.initCameraPosition=this.DEFAULT_INIT_CAMERA_POSITION,this.isOrthographicCamera=!1,this.pointsUuid="",this.pointCloudObjectName="pointCloud",this.rangeObjectName="range",this.highlightGroupName="highlightBoxes",this.showDirection=!0,this.pointsMaterialSize=1,this.isSegment=!1,this.checkMode=!1,this.workerLoading=!1,this.nextTick=()=>{!this.segmentOperation||this.segmentOperation._raycasting()},this.keydown=n=>{if(!!this.store)switch(n.key){case" ":this.controls.enablePan=!0,this.store.setForbidOperation(!0);break}},this.keyup=n=>{if(!!this.store)switch(n.key){case" ":this.controls.enablePan=!1,this.store.setForbidOperation(!1);break}},this.addSphereToSense=(n,l="blue")=>{var c;const u=(c=n.id)!=null?c:k();this.removeObjectByName(u,"sphere");const{radius:m,widthSegments:f,heightSegments:p}=O,{center:g}=n,x=new a.Group,y=new a.SphereGeometry(m,f,p),M=new a.MeshBasicMaterial({color:l}),v=new a.Mesh(y,M);v.position.set(g.x,g.y,g.z),x.add(v),x.name=`sphere${u}`,this.scene.add(x)},this.generateSphere=n=>{const{fill:l}=this.getColorFromConfig(n.attribute);this.addSphereToSense(n,l),this.render()},this.generateSpheres=n=>{n.forEach(l=>{const{fill:c}=this.getColorFromConfig(l.attribute);this.addSphereToSense(l,c)}),this.render()},this.addBoxToSense=(n,l=16777215)=>{var c;const u=(c=n.id)!=null?c:k();this.removeObjectByName(u,"box");const{center:m,width:f,height:p,depth:g,rotation:x}=n,y=new a.Group,M=new a.BoxGeometry(f,p,g),v=new a.MeshBasicMaterial({color:"blue"}),z=new a.Mesh(M,v),N=new a.BoxHelper(z,l),F=this.generateBoxArrow(n),T=this.generateBoxTrackID(n);T&&y.add(T),y.add(N),y.add(F),m&&y.position.set(m.x,m.y,m.z),x&&y.rotation.set(0,0,x),y.name=`box${u}`,this.scene.add(y)},this.applyCameraTarget=n=>{if(this.camera.type==="OrthographicCamera"&&n){const l=this.getOrthographicCameraTarget(n);this.updateCameraZoom(n.zoom),this.updateCamera(n.position,l)}},this.initShaderMaterial=()=>({vertexShader:`
1
+ import*as h from"three";import{toolStyleConverter as _,PerspectiveShiftUtils as z,EPerspectiveView as M,PointCloudUtils as Z,DEFAULT_SPHERE_PARAMS as k}from"@labelbee/lb-utils";import G from"../../_virtual/highlightWorker.js";import j from"../../_virtual/filterBoxWorker.js";import{isInPolygon as $}from"../../utils/tool/polygonTool.js";import E from"../../utils/uuid.js";import N from"../../utils/MathUtils.js";import Y from"../../utils/ImgUtils.js";import{PCDLoader as K}from"./PCDLoader.js";import{OrbitControls as X}from"./OrbitControls.js";import{PointCloudCache as q}from"./cache.js";import{getCuboidFromPointCloudBox as T,getHighlightIndexByPoints as Q,mergeHighlightList as J}from"./matrix.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,getHighlightIndexByPoints,isFisheyeCalibValid,isInImage,isMatrixValid,isMatrixValidByArr,lidar2FisheyeImage,lidar2image,mergeHighlightList,oCamFisheyeTransfer,omniCamera11VTransfer,point3DLidar2Image,pointCloudLidar2image,pointListLidar2Img,pointMappingLidar2image,rotatePoint,transferKitti2Matrix}from"./matrix.js";import{PointCloudSegmentOperation as tt}from"./segmentation.js";import et from"./store/index.js";import it from"./render/index.js";import rt from"../toolOperation/eventListener.js";import"../../constant/tool.js";import"../scheduler.js";var nt=Object.defineProperty,ot=Object.defineProperties,st=Object.getOwnPropertyDescriptors,F=Object.getOwnPropertySymbols,at=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable,V=(C,t,e)=>t in C?nt(C,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):C[t]=e,v=(C,t)=>{for(var e in t||(t={}))at.call(t,e)&&V(C,e,t[e]);if(F)for(var e of F(t))ht.call(t,e)&&V(C,e,t[e]);return C},S=(C,t)=>ot(C,st(t)),B=(C,t,e)=>new Promise((i,r)=>{var a=d=>{try{s(e.next(d))}catch(p){r(p)}},c=d=>{try{s(e.throw(d))}catch(p){r(p)}},s=d=>d.done?i(d.value):Promise.resolve(d.value).then(a,c);s((e=e.apply(C,t)).next())});const ct=30,L=new G({type:"module"});class lt extends rt{constructor({container:t,noAppend:e,isOrthographicCamera:i,orthographicParams:r,backgroundColor:a="#4C4C4C",config:c,isSegment:s,checkMode:d,hiddenText:p=!1}){super();this.zAxisLimit=10,this.initCameraPosition=this.DEFAULT_INIT_CAMERA_POSITION,this.isOrthographicCamera=!1,this.pointsUuid="",this.pointCloudObjectName="pointCloud",this.rangeObjectName="range",this.highlightGroupName="highlightBoxes",this.showDirection=!0,this.pointsMaterialSize=1,this.isSegment=!1,this.checkMode=!1,this.workerLoading=!1,this.raycaster=new h.Raycaster,this.pointer=new h.Vector2,this.hiddenText=!1,this.filterBoxWorkerTimer=null,this.nextTick=()=>{!this.segmentOperation||this.segmentOperation._raycasting()},this.keydown=n=>{if(!!this.store)switch(n.key){case" ":this.controls.enablePan=!0,this.store.setForbidOperation(!0);break}},this.keyup=n=>{if(!!this.store)switch(n.key){case" ":this.controls.enablePan=!1,this.store.setForbidOperation(!1);break}},this.addSphereToSense=(n,o="blue")=>{var l;const u=(l=n.id)!=null?l:E();this.removeObjectByName(u,"sphere");const{radius:f,widthSegments:g,heightSegments:y}=k,{center:m}=n,x=new h.Group,w=new h.SphereGeometry(f,g,y),b=new h.MeshBasicMaterial({color:o}),P=new h.Mesh(w,b);P.position.set(m.x,m.y,m.z),x.add(P),x.name=`sphere${u}`,this.scene.add(x)},this.generateSphere=n=>{const{fill:o}=this.getColorFromConfig(n.attribute);this.addSphereToSense(n,o),this.render()},this.generateSpheres=n=>{n.forEach(o=>{const{fill:l}=this.getColorFromConfig(o.attribute);this.addSphereToSense(o,l)}),this.render()},this.addBoxToSense=(n,o=16777215)=>{var l;const u=(l=n.id)!=null?l:E();this.removeObjectByName(u,"box");const{center:f,width:g,height:y,depth:m,rotation:x}=n,w=new h.Group,b=new h.BoxGeometry(g,y,m),P=new h.MeshBasicMaterial({color:"blue"}),O=new h.Mesh(b,P),W=new h.BoxHelper(O,o),R=this.generateBoxArrow(n),I=this.generateBoxTrackID(n);I&&w.add(I);const D=this.generateBoxAttributeLabel(n);D&&w.add(D),w.add(W),w.add(R),f&&w.position.set(f.x,f.y,f.z),x&&w.rotation.set(0,0,x),w.name=`box${u}`;const H=new h.BoxGeometry(g,y,m),U=new h.MeshBasicMaterial({visible:!1}),A=new h.Mesh(H,U);A.userData={selectedID:u},w.add(A),this.scene.add(w)},this.applyCameraTarget=n=>{if(this.camera.type==="OrthographicCamera"&&n){const o=this.getOrthographicCameraTarget(n);this.updateCameraZoom(n.zoom),this.updateCamera(n.position,o)}},this.initShaderMaterial=()=>({vertexShader:`
2
2
  attribute vec3 dimensions;
3
3
  varying vec3 vDimensions;
4
4
  uniform float pointSize;
@@ -28,4 +28,6 @@ import*as a from"three";import{toolStyleConverter as L,PerspectiveShiftUtils as
28
28
 
29
29
  // Output the final color
30
30
  gl_FragColor = vec4(color, 1.0);
31
- }`,uniforms:{pointSize:{value:this.pointsMaterialSize}}}),this.loadPCDFile=(...n)=>S(this,[...n],function*(l=this.currentPCDSrc,c){if(!l)return;this.clearPointCloud(),this.cacheInstance.clearCache2DHighlightIndex(),this.currentPCDSrc=l;const{points:u,color:m}=yield this.cacheInstance.loadPCDFile(l),f=new a.BufferGeometry;f.setAttribute("position",new a.BufferAttribute(u,3)),this.isSegment||f.setAttribute("dimensions",new a.BufferAttribute(m,3)),this.initCloudData(u);const p=new a.Points(f);this.renderPointCloud(p,c),this.emit("loadPCDFileEnd")}),this.getHighlightIndexByMappingImgList=n=>S(this,[n],function*({mappingImgList:l,points:c}){const u=l.length===0?[]:yield Promise.all(l.map(p=>W.load(p.url))),m=l.map((p,g)=>{var x;if(this.cacheInstance.cache2DHighlightIndex.has(p.url))return(x=this.cacheInstance.cache2DHighlightIndex.get(p.url))!=null?x:[];const y=$({points:c,calib:p.calib,width:u[g].width,height:u[g].height});return this.cacheInstance.cache2DHighlightIndex.set(p.url,y),y});return Y(m)}),this.filterPreResult=(n,l,c)=>S(this,null,function*(){const{points:u}=yield this.cacheInstance.loadPCDFile(n),m=yield this.cacheInstance.loadIndexMap(n,u);return new Promise(f=>{const p=c.map(g=>{const x=A.calculatePointsInsideBox({indexMap:m,polygon:D(g).polygonPointList,zScope:[g.center.z-g.depth/2,g.center.z+g.depth/2],box:g}),y=x>=l.lowerLimitPointsNumInBox;return P(b({},g),{valid:y,count:x})});f(p)})}),this.loadPCDFileByBox=(n,l,c)=>S(this,null,function*(){const u=(p,g)=>S(this,null,function*(){const{width:x=0,height:y=0,depth:M=0}=c!=null?c:{},v=yield this.filterPointsByBox(P(b({},l),{width:l.width+x,height:l.height+y,depth:l.depth+M}),p,g);if(!v){console.error("filter Error");return}this.clearPointCloud(),this.currentPCDSrc=n;const z=new a.Points(v.geometry);z.name=this.pointCloudObjectName,this.scene.add(z),this.render()}),{points:m,color:f}=yield this.cacheInstance.loadPCDFile(n);u(m,f)}),this.generateRange=n=>{const l=this.createRange(n);this.scene.add(l)},this.generateBoxArrow=({width:n})=>{const l=new a.Vector3(1,0,0),c=new a.Vector3(n/2,0,0),u=2,m=16776960,f=new a.ArrowHelper(l,c,u,m);return f.visible=this.showDirection,f},this.generateBoxTrackID=n=>{if(!n.trackID)return;const l=new a.Texture(this.getTextCanvas(n.trackID.toString()));l.needsUpdate=!0;const c=new a.SpriteMaterial({map:l,depthWrite:!1}),u=new a.Sprite(c);return u.scale.set(5,5,5),u.position.set(-n.width/2,0,n.depth/2+.5),u},this.applyZAxisPoints=n=>{this.zAxisLimit=n,this.filterZAxisPoints(),this.render()},this.updatePointSize=({zoomIn:n,customSize:l})=>{const c=this.scene.getObjectByName(this.pointCloudObjectName);if(!c)return;const u=c.material.uniforms.pointSize.value;n?c.material.uniforms.pointSize.value=Math.min(u*1.2,10):c.material.uniforms.pointSize.value=Math.max(u/1.2,1),l&&(c.material.uniforms.pointSize.value=l,this.pointsMaterialSize=l),c.material.uniformsNeedUpdate=!0,this.render()},this.container=t,this.renderer=new a.WebGLRenderer({antialias:!0}),this.backgroundColor=o,this.config=h,this.checkMode=d!=null?d:!1,i&&r?(this.isOrthographicCamera=!0,this.camera=new a.OrthographicCamera(r.left,r.right,r.top,r.bottom,r.near,r.far)):this.camera=new a.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new a.Scene,this.controls=new U(this.camera,s?this.container:this.renderer.domElement),this.pcdLoader=new Z,this.axesHelper=new a.AxesHelper(1e3),this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=G.getInstance(),s===!0&&(this.initSegment(),this.isSegment=!0)}initSegment(){this.store=new q(this.pointCloudDelegate),this.controls.enablePan=!1,this.controls.addEventListener("start",this.orbiterStart.bind(this)),this.controls.addEventListener("change",this.orbiterChange.bind(this)),this.controls.addEventListener("end",this.orbiterEnd.bind(this)),this.segmentOperation=new X(b({dom:this.container,store:this.store},this.eventBus)),this.pointCloudRender=new K(P(b({store:this.store},this.eventBus),{nextTick:this.nextTick})),this.initMsg(),document.addEventListener("keydown",this.keydown),document.addEventListener("keyup",this.keyup)}orbiterStart(){}orbiterChange(){!this.store||(this.store.orbiting=!0)}orbiterEnd(){!this.store||(this.store.orbiting=!1)}get currentSegmentTool(){var t;return(t=this.segmentOperation)==null?void 0:t.currentToolName}get pointCloudObject(){return this.scene.getObjectByName(this.pointCloudObjectName)}initMsg(){!this.segmentOperation||(this.on("CircleSelector",this.segmentOperation.updateSelector2Circle.bind(this.segmentOperation)),this.on("LassoSelector",this.segmentOperation.updateSelector2Lasso.bind(this.segmentOperation)),this.on("RectSelector",this.segmentOperation.updateSelector2Rect.bind(this.segmentOperation)),this.on("clearPointCloud",this.clearPointCloud.bind(this)),this.on("loadPCDFile",this.loadPCDFile.bind(this)))}unbindMsg(){!this.segmentOperation||(this.unbind("CircleSelector",this.segmentOperation.updateSelector2Circle.bind(this.segmentOperation)),this.unbind("LassoSelector",this.segmentOperation.updateSelector2Lasso.bind(this.segmentOperation)),this.unbind("RectSelector",this.segmentOperation.updateSelector2Rect.bind(this.segmentOperation)),this.unbind("clearPointCloud",this.clearPointCloud.bind(this)),this.unbind("loadPCDFile",this.loadPCDFile.bind(this)))}get eventBus(){return{on:this.on.bind(this),emit:this.emit.bind(this),unbind:this.unbind.bind(this)}}get pointCloudDelegate(){return b({container:this.container,scene:this.scene,camera:this.camera,renderer:this.renderer,checkMode:this.checkMode,config:this.config},this.eventBus)}get DEFAULT_INIT_CAMERA_POSITION(){return new a.Vector3(-.01,0,1e3)}get containerWidth(){return this.container.clientWidth}get containerHeight(){return this.container.clientHeight}setInitCameraPosition(t){this.initCameraPosition=t}setConfig(t){var e;this.config=t,(e=this.store)==null||e.setConfig(t)}initOrthographicCamera(t){if(this.camera.type!=="OrthographicCamera")return;const{left:e,right:i,top:r,bottom:o,near:h,far:s}=t;this.camera.left=e,this.camera.right=i,this.camera.top=r,this.camera.bottom=o,this.camera.near=h,this.camera.far=s,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:i,z:r}=this.initCameraPosition;t.position.set(e,i,r)}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 a.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 a.Color(this.backgroundColor),this.initControls(),this.initRenderer()}removeObjectByName(t,e=""){const i=this.scene.getObjectByName(e+t);i&&i.removeFromParent()}getColorFromConfig(t){return L.getColorFromConfig({attribute:t},P(b({},this.config),{attributeConfigurable:!0}),{})}generateBox(t,e=16777215){const i=e;this.addBoxToSense(t,i),this.render()}getAllAttributeColor(t){return t.reduce((e,i)=>(e[i.attribute]=this.getColorFromConfig(i.attribute),e),{})}generateBoxes(t){t.forEach(e=>{this.addBoxToSense(e)}),this.render()}getOrthographicCamera(t){const{center:e,width:i,height:r}=t,o=10,h=e.x-i/2-o,s=e.x-i/2+o,d=e.y+r/2+o,n=e.y-r/2-o,l=100,c=-100,u=500/l;return{left:h,right:s,top:d,bottom:n,near:l,far:c,zoom:u}}updateCameraZoom(t){this.camera.zoom=t,this.camera.updateProjectionMatrix()}updateCameraByBox(t,e,i){const{center:r,width:o,height:h,depth:s,rotation:d}=t,n=this.getCameraVector(r,d,{width:o,height:h,depth:s},e);return i?(this.updateCamera(i,r),new a.Vector3(i.x,i.y,i.z)):(this.updateCamera(n,r),n)}updateCameraBySphere(t,e){const{center:i}=t,{radius:r}=O,o=this.getCameraVector(i,0,{width:r*2,height:r*2,depth:r*2},e);return this.updateCamera(o,i),o}updateOrthoCamera(t,e){const i=this.updateCameraByBox(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:i}}updateOrthoCameraBySphere(t,e){const i=this.updateCameraBySphere(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:i}}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 a.Vector3(e.x,e.y,e.z),this.controls.update()}resetCamera(){this.updateCamera(this.DEFAULT_INIT_CAMERA_POSITION,{x:0,y:0,z:0})}getOrthographicCameraTarget(t){const e=new a.Vector3(0,0,-1).applyQuaternion(t.quaternion);return t.position.clone().add(e)}createThreeMatrix4(t){return new a.Matrix4().set(...t)}filterPointsByBox(t,e,i){var r,o,h;if(!e){const s=this.scene.getObjectByName(this.pointCloudObjectName);if(!s)return console.error("There is no corresponding point cloud object"),Promise.resolve(void 0);e=(h=(o=(r=s==null?void 0:s.geometry)==null?void 0:r.attributes)==null?void 0:o.position)==null?void 0:h.array}if(window.Worker){const{zMin:s,zMax:d,polygonPointList:n}=D(t),l=e;i=i!=null?i:new Float32Array([]);const c={boxParams:t,zMin:s,zMax:d,polygonPointList:n,color:i,position:l};return new Promise(u=>{const m=new R;m.postMessage(c),m.onmessage=f=>{const{color:p,position:g,num:x}=f.data,y=new a.BufferGeometry;y.setAttribute("position",new a.Float32BufferAttribute(g,3)),y.setAttribute("color",new a.Float32BufferAttribute(p,3)),y.computeBoundingSphere(),m.terminate(),u({geometry:y,num:x})}})}return Promise.resolve(void 0)}getCameraVector(t,e,i,r=C.Front,o=nt){let h=B.frontViewMatrix4(o);switch(r){case C.Front:break;case C.Back:h=B.backViewMatrix4(o);break;case C.Left:h=B.leftViewMatrix4(o);break;case C.Right:h=B.rightViewMatrix4(o);break;case C.Top:h=B.topViewMatrix4(o);break;case C.LFT:h=B.leftFrontTopViewMatrix4(o,i);break;case C.RBT:h=B.rightBackTopViewMatrix4(o,i);break}const s=this.createThreeMatrix4(h),d=new a.Matrix4().makeTranslation(-t.x,-t.y,-t.z),n=new a.Matrix4().makeTranslation(t.x,t.y,t.z),l=new a.Matrix4().makeRotationZ(e);return new a.Vector3(t.x,t.y,t.z).clone().applyMatrix4(s).applyMatrix4(d).applyMatrix4(l).applyMatrix4(n)}createRange(t){this.removeObjectByName(this.rangeObjectName);const i=new a.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),r=new a.BufferGeometry().setFromPoints(i),o=new a.LineBasicMaterial({color:16711680}),h=new a.Line(r,o);return h.name=this.rangeObjectName,h}renderPointCloud(t,e){t.name=this.pointCloudObjectName;const i=new a.ShaderMaterial(this.initShaderMaterial());e&&this.generateRange(e),this.pointsUuid=t.uuid,t.material=i,this.filterZAxisPoints(t),this.scene.add(t),this.render()}clearAllBox(){this.clearAllGroupByPrefix("box")}clearAllSphere(){this.clearAllGroupByPrefix("sphere")}clearAllGroupByPrefix(t=""){const e=this.scene.children;for(let i=e.length-1;i>=0;i--){const r=e[i];r.type==="Group"&&r.name.startsWith(t)&&this.removeObjectByName(r.name)}}clearPointCloud(){this.removeObjectByName(this.pointCloudObjectName)}clearPointCloudAndRender(){this.clearPointCloud(),this.render()}initCloudData(t){if(!!this.store){for(let e=0;e<t.length;e+=3){const i=t[e],r=t[e+1],o=t[e+2];this.store.cloudData.set(`${i}@${r}@${o}`,{visible:!1})}this.store.setOriginPoints(t)}}handleWebworker(t){return S(this,null,function*(){return new Promise((e,i)=>{if(this.workerLoading){i(new Error("workerLoading"));return}this.workerLoading=!0,I.postMessage(t),I.onmessage=r=>{e(r.data),this.workerLoading=!1},I.onerror=r=>{i(r),this.workerLoading=!1}})})}highlightOriginPointCloud(t){return S(this,arguments,function*(e,i=[]){const r=this.scene.getObjectByName(this.pointCloudObjectName);if(!!r)return this.highlightPCDSrc=this.currentPCDSrc,new Promise((o,h)=>{if(window.Worker){const d=(e?[...e]:[]).map(c=>D(c)),n=this.getAllAttributeColor(d),l={cuboidList:d,position:r.geometry.attributes.position.array,color:r.geometry.attributes.dimensions.array,colorList:n,highlightIndex:i};this.handleWebworker(l).then(c=>{const{color:u}=c,m=new a.BufferAttribute(u,3);if(!this.highlightPCDSrc||this.highlightPCDSrc!==this.currentPCDSrc||r.geometry.attributes.position.array.length!==u.length){h(new Error("Error Path"));return}this.cacheInstance.updateColor(this.highlightPCDSrc,u),this.highlightPCDSrc=void 0,m.needsUpdate=!0,r.geometry.setAttribute("dimensions",m),r.geometry.attributes.dimensions.needsUpdate=!0,o(u),this.render()}).catch(c=>{h(c)})}})})}clearHighlightBoxes(){this.removeObjectByName(this.highlightGroupName)}clearHighlightBoxesAndRender(){this.clearHighlightBoxes(),this.render()}highlightBoxes(t){const e=new a.Group;t.forEach(i=>{const{center:{x:r,y:o,z:h},width:s,height:d,depth:n,rotation:l}=i,{fill:c}=L.getColorFromConfig({attribute:i.attribute},P(b({},this.config),{attributeConfigurable:!0}),{}),u=new a.BoxGeometry(s,d,n),m=new a.MeshBasicMaterial({color:c,transparent:!0,opacity:.2,depthTest:!1});u.rotateZ(l),u.translate(r,o,h);const f=new a.Mesh(u,m);e.add(f);const p=new a.PlaneGeometry(n,d);p.rotateY(Math.PI/2),p.rotateZ(l);const g=new a.Vector3(s/2,0,0),x=new a.Matrix4().makeRotationY(Math.PI/2).makeRotationZ(l);g.applyMatrix4(x),p.translate(r+g.x,o+g.y,h+g.z);const y=new a.MeshBasicMaterial({color:c,side:a.DoubleSide,transparent:!0,opacity:.8,depthTest:!1}),M=new a.Mesh(p,y);e.add(M)}),e.name=this.highlightGroupName,this.scene.add(e),this.render()}updateColor(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(e){const i=new a.BufferAttribute(t,3);e.geometry.setAttribute("dimensions",i),e.geometry.attributes.dimensions.needsUpdate=!0,this.render()}}setShowDirection(t){this.showDirection=t,this.scene.children.forEach(e=>{e.type==="Group"&&e.children.forEach(i=>{i.type==="ArrowHelper"&&(i.visible=t)})}),this.render()}getTextCanvas(t){const e=document.createElement("canvas"),i=e.getContext("2d");return i&&(i.font=`${50}px " bold`,i.fillStyle="white",i.textAlign="center",i.textBaseline="middle",i.fillText(t,e.width/2,e.height/2)),e}filterNoise(t){let e=[...t];e.sort((c,u)=>c.z-u.z);const i=Math.floor(e.length*.05),r=e[i];e=e.filter(({z:c})=>c>r.z+.1);const o=.005,h=Math.floor(e.length*(1-o));e=e.slice(0,h),e.sort((c,u)=>c.x-u.x);const s=Math.floor(e.length*o),d=Math.floor(e.length*(1-o));e=e.slice(s,d),e.sort((c,u)=>c.y-u.y);const n=Math.floor(e.length*o),l=Math.floor(e.length*(1-o));return e=e.slice(n,l),e.length>100?e:t}getFittedCoordinates(t,e){const i=[];let r=[...t,t[0]];e.forEach(({x:d,y:n})=>{t.forEach((l,c)=>{const u=r[c+1],m=A.getFootOfPerpendicular({x:d,y:n},l,u,!1,!0).length;(!i[c]||m<i[c].distance)&&(i[c]={distance:m,point:{x:d,y:n}})})}),r=[t[t.length-1],...t,t[0]];const o=[i[i.length-1],...i],h=t.map((d,n)=>{const l=r[n],c=r[n+1],u=r[n+2];return E.getIntersectionBySlope({p1:o[n].point,line1:[l,c],p2:o[n+1].point,line2:[c,u]})});return h.some(d=>!(Number.isFinite(d.x)&&Number.isFinite(d.y)))?t:h}getSensesPointZAxisInPolygon(t,e,i){var r,o,h;const s=this.scene.children.find(p=>p.uuid===this.pointsUuid);let d=0,n=0,l=0,c=0,u=[],m=[];const f=((h=(o=(r=s==null?void 0:s.geometry)==null?void 0:r.attributes)==null?void 0:o.position)==null?void 0:h.array)||[];for(let p=0;p<f.length;p+=3){const g=f[p],x=f[p+1],y=f[p+2];H({x:g,y:x},t)&&(y||y===0)&&m.push({x:g,y:x,z:y})}return m.length?(i&&(m=this.filterNoise(m),u=this.getFittedCoordinates(t,m)),m.sort((p,g)=>p.z-g.z),d=m[0].z-.01,n=m[m.length-1].z+.01,c=m.length,e&&(l=m.filter(({z:p})=>p>=e[0]&&p<=e[1]).length),{maxZ:n,minZ:d,count:l,zCount:c,fittedCoordinates:u}):{maxZ:n,minZ:d,count:l,zCount:c,fittedCoordinates:u}}getBasicCoordinate2Canvas(t){const e=this.containerWidth/2,i=this.containerHeight/2;return{x:t.x*e+e,y:t.y*i+i,z:t.z}}get basicCoordinate2CanvasMatrix4(){const t=this.containerWidth/2,e=this.containerHeight/2;return new a.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,i=this.containerHeight/2;return new a.Vector3(t.x/e-e/2,-(t.y/i-i/2),1)}getPolygonSidePoints(t){const{center:{x:e,y:i,z:r},height:o,width:h,depth:s}=t,d={x:e+h/2,y:i+o/2,z:r-s/2},n={x:e+h/2,y:i+o/2,z:r+s/2},l={x:e-h/2,y:i+o/2,z:r+s/2},c={x:e-h/2,y:i+o/2,z:r-s/2};return[d,n,l,c]}getPolygonBackPoints(t){const{center:{x:e,y:i,z:r},height:o,width:h,depth:s}=t,d={x:e-h/2,y:i+o/2,z:r+s/2},n={x:e-h/2,y:i+o/2,z:r-s/2},l={x:e-h/2,y:i-o/2,z:r-s/2},c={x:e-h/2,y:i-o/2,z:r+s/2};return[d,n,l,c]}getPolygonTopPoints(t){const{center:{x:e,y:i,z:r},height:o,width:h,depth:s}=t,d={x:e+h/2,y:i+o/2,z:r+s/2},n={x:e+h/2,y:i-o/2,z:r+s/2},l={x:e-h/2,y:i-o/2,z:r+s/2},c={x:e-h/2,y:i+o/2,z:r+s/2};return[d,n,l,c]}getModelTransformationMatrix(t){const{center:{x:e,y:i,z:r},rotation:o}=t,h=new a.Matrix4().makeTranslation(-e,-i,-r),s=new a.Matrix4().makeTranslation(e,i,r),d=new a.Matrix4().makeRotationZ(o);return new a.Matrix4().multiply(s).multiply(d).multiply(h)}getBoxSidePolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,C.Left)}getBoxBackPolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,C.Back)}getSphereSidePoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}getSphereBackPoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}boxParams2ViewPolygon(t,e){switch(e){case C.Left:return this.getPolygonSidePoints(t);case C.Back:return this.getPolygonBackPoints(t);default:return this.getPolygonTopPoints(t)}}getBoxPolygon2DCoordinate(t,e){const i=this.boxParams2ViewPolygon(t,e),{width:r,height:o}=t,h=new a.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),s=new a.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(h).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=s;const d=i.map(c=>new a.Vector3(c.x,c.y,c.z)).map(c=>c.applyMatrix4(this.sideMatrix)),n=this.containerWidth/r,l=this.containerHeight/o;return{polygon2d:d,zoom:Math.min(n,l)/2}}getSpherePoint2DCoordinate(t){const{center:e,attribute:i,id:r,valid:o}=t,{radius:h}=O,s={center:e,attribute:i,id:r,valid:o,width:h*2,height:h*2,depth:h*2,rotation:0},d=new a.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),n=new a.Matrix4().premultiply(this.getModelTransformationMatrix(s)).premultiply(d).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=n;const l=new a.Vector3(e.x,e.y,e.z).applyMatrix4(this.sideMatrix),c=this.containerWidth/(h*2),u=this.containerHeight/(h*2);return{point2d:l,zoom:Math.min(c,u)/2}}getSphereTopPoint2DCoordinate(t){const{center:e}=t,{radius:i}=O,r={x:-(e.y-this.containerWidth/2),y:-(e.x-this.containerHeight/2)},o=this.containerWidth/(i*2),h=this.containerHeight/(i*2);return{point2d:r,zoom:Math.min(o,h)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:i}=t,o=this.getPolygonTopPoints(t).map(d=>new a.Vector3(d.x,d.y,d.z)).map(d=>d.applyMatrix4(this.getModelTransformationMatrix(t))).map(d=>({x:d.y,y:d.x})).map(d=>({x:-(d.x-this.containerWidth/2),y:-(d.y-this.containerHeight/2)})),h=this.containerWidth/e,s=this.containerHeight/i;return{polygon2d:o,zoom:Math.min(h,s)/2}}getNewBoxBySideUpdate(t,e,i,r){const o=new a.Matrix4().makeRotationZ(r.rotation),h=new a.Vector3(-t.x,0,0).applyMatrix4(o);let s=r;return s.center={x:s.center.x+h.x,y:s.center.y+h.y,z:s.center.z-t.z},s=P(b({},s),{width:Math.abs(s.width+e),height:s.height,depth:Math.abs(s.depth+i)}),{newBoxParams:s}}getNewBoxByBackUpdate(t,e,i,r){const o=new a.Matrix4().makeRotationZ(r.rotation),h=new a.Vector3(0,-t.x,0).applyMatrix4(o);let s=r;return s.center={x:s.center.x+h.x,y:s.center.y+h.y,z:s.center.z-t.z},s=P(b({},s),{width:s.width,height:Math.abs(s.height+e),depth:Math.abs(s.depth+i)}),{newBoxParams:s}}getNewBoxBySideUpdateByPoints(t,e,i,r){var o;const h=(o=this.sideMatrix)==null?void 0:o.invert();if(!this.sideMatrix||!h){console.error("No sideMatrix");return}this.camera.zoom=1,this.camera.updateProjectionMatrix();const s=t.map(g=>new a.Vector3(g.x,g.y,g.z)).map(g=>g.applyMatrix4(h)),[d,n,l,c]=s,u=Math.max(Math.abs(d.x-l.x),Math.abs(d.x-n.x)),f=n.add(c).applyMatrix3(new a.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new a.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new a.Vector3(r.center.x,r.center.y,r.center.z));return{newBoxParams:P(b({},r),{center:{x:r.center.x-f.x,y:r.center.y-f.y,z:r.center.z-i},width:u,height:r.height,depth:r.depth+e,rotation:r.rotation})}}filterZAxisPoints(t){const e=t||this.scene.children.find(i=>i.uuid===this.pointsUuid);if(e){const{attributes:i}=e.geometry,{position:r}=i,o=[],{count:h}=r;for(let s=0;s<h;s++){const d=r.getZ(s);o.push(d>this.zAxisLimit?0:1)}e.geometry.setAttribute("visibility",new a.Float32BufferAttribute(o,1)),e.geometry.attributes.visibility.needsUpdate=!0}}render(){this.renderer.render(this.scene,this.camera)}}export{ot as PointCloud};
31
+ }`,uniforms:{pointSize:{value:this.pointsMaterialSize}}}),this.loadPCDFile=(...n)=>B(this,[...n],function*(o=this.currentPCDSrc,l){if(!o)return;this.clearPointCloud(),this.cacheInstance.clearCache2DHighlightIndex(),this.currentPCDSrc=o;const{points:u,color:f}=yield this.cacheInstance.loadPCDFile(o),g=new h.BufferGeometry;g.setAttribute("position",new h.BufferAttribute(u,3)),this.isSegment||g.setAttribute("dimensions",new h.BufferAttribute(f,3)),this.initCloudData(u);const y=new h.Points(g);this.renderPointCloud(y,l),this.emit("loadPCDFileEnd")}),this.getHighlightIndexByMappingImgList=n=>B(this,[n],function*({mappingImgList:o,points:l}){const u=m=>B(this,null,function*(){try{return yield Y.load(m)}catch(x){return console.error("Error loading image:",x),null}}),f=o.length===0?[]:(yield Promise.all(o.map(m=>B(this,null,function*(){let x=yield u(m.url);return!x&&m.fallbackUrl&&(x=yield u(m.fallbackUrl)),x})))).filter(m=>m!==null),g=o.map((m,x)=>{var w;if(this.cacheInstance.cache2DHighlightIndex.has(m.url))return(w=this.cacheInstance.cache2DHighlightIndex.get(m.url))!=null?w:[];const b=Q({points:l,calib:m.calib,width:f[x].width,height:f[x].height});return this.cacheInstance.cache2DHighlightIndex.set(m.url,b),b});return J(g)}),this.filterPreResult=(n,o,l)=>B(this,null,function*(){const{points:u}=yield this.cacheInstance.loadPCDFile(n),f=yield this.cacheInstance.loadIndexMap(n,u);return new Promise(g=>{const y=l.map(m=>{const x=N.calculatePointsInsideBox({indexMap:f,polygon:T(m).polygonPointList,zScope:[m.center.z-m.depth/2,m.center.z+m.depth/2],box:m}),w=x>=o.lowerLimitPointsNumInBox;return S(v({},m),{valid:w,count:x})});g(y)})}),this.loadPCDFileByBox=(n,o,l)=>B(this,null,function*(){const u=(y,m)=>B(this,null,function*(){const{width:x=0,height:w=0,depth:b=0}=l!=null?l:{},P=yield this.filterPointsByBox(S(v({},o),{width:o.width+x,height:o.height+w,depth:o.depth+b}),y,m);if(!P){console.error("filter Error");return}this.clearPointCloud(),this.currentPCDSrc=n;const O=new h.Points(P.geometry);O.name=this.pointCloudObjectName,this.scene.add(O),this.render()}),{points:f,color:g}=yield this.cacheInstance.loadPCDFile(n);u(f,g)}),this.generateRange=n=>{const o=this.createRange(n);this.scene.add(o)},this.generateBoxArrow=({width:n})=>{const o=new h.Vector3(1,0,0),l=new h.Vector3(n/2,0,0),u=2,f=16776960,g=new h.ArrowHelper(o,l,u,f);return g.visible=this.showDirection,g},this.generateLabel=(n,o)=>{const l=this.getTextCanvas(n),u=new h.Texture(l);u.minFilter=h.LinearFilter,u.magFilter=h.LinearFilter,u.needsUpdate=!0;const f=l.width/window.devicePixelRatio,g=l.height/window.devicePixelRatio,y=new h.SpriteMaterial({map:u,depthWrite:!1}),m=new h.Sprite(y);return m.scale.set(f/o,g/o,1),{sprite:m,canvasWidth:f,canvasHeight:g}},this.generateBoxTrackID=n=>{if(!n.trackID)return;const{sprite:o}=this.generateLabel(n.trackID.toString(),50);return o.position.set(-n.width/2,0,n.depth/2+.5),o},this.generateBoxAttributeLabel=n=>{if(!n.attribute||this.hiddenText)return;const o=this.findSubAttributeLabel(n,this.config),l=o?`${n.attribute}
32
+ ${o}`:`${n.attribute}`,{sprite:u,canvasHeight:f}=this.generateLabel(l,100);return u.position.set(-n.width/2,0,-n.depth/2-f/150),u},this.applyZAxisPoints=n=>{this.zAxisLimit=n,this.filterZAxisPoints(),this.render()},this.updatePointSize=({zoomIn:n,customSize:o})=>{const l=this.scene.getObjectByName(this.pointCloudObjectName);if(!l)return;const u=l.material.uniforms.pointSize.value;n?l.material.uniforms.pointSize.value=Math.min(u*1.2,10):l.material.uniforms.pointSize.value=Math.max(u/1.2,1),o&&(l.material.uniforms.pointSize.value=o,this.pointsMaterialSize=o),l.material.uniformsNeedUpdate=!0,this.render()},this.container=t,this.renderer=new h.WebGLRenderer({antialias:!0}),this.backgroundColor=a,this.config=c,this.checkMode=d!=null?d:!1,this.hiddenText=p,i&&r?(this.isOrthographicCamera=!0,this.camera=new h.OrthographicCamera(r.left,r.right,r.top,r.bottom,r.near,r.far)):this.camera=new h.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new h.Scene,this.controls=new X(this.camera,s?this.container:this.renderer.domElement),this.pcdLoader=new K,this.axesHelper=new h.AxesHelper(1e3),this.filterBoxWorker=new j,this.geometry=new h.BufferGeometry,this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=q.getInstance(),s===!0&&(this.initSegment(),this.isSegment=!0),this.controls.addEventListener("rightClick",n=>{var o,l,u;const f=this.renderer.domElement.getBoundingClientRect(),g=n.originalEvent.clientX-f.left,y=n.originalEvent.clientY-f.top;this.pointer.x=g/f.width*2-1,this.pointer.y=-(y/f.height)*2+1,this.raycaster.setFromCamera(this.pointer,this.camera);const m=[];this.scene.children.forEach(w=>{w instanceof h.Group&&w.children.forEach(b=>{b instanceof h.Mesh&&m.push(b)})});const x=this.raycaster.intersectObjects(m,!1);if(x.length>0){const w=x[0].object;(o=this.pipe)==null||o.setNeedUpdateCenter(!1),(l=this.pipe)==null||l.setSelectedIDs(w.userData.selectedID)}else(u=this.pipe)==null||u.setSelectedIDs(void 0)})}setHandlerPipe(t){this.pipe=t}initSegment(){this.store=new et(this.pointCloudDelegate),this.controls.enablePan=!1,this.controls.addEventListener("start",this.orbiterStart.bind(this)),this.controls.addEventListener("change",this.orbiterChange.bind(this)),this.controls.addEventListener("end",this.orbiterEnd.bind(this)),this.segmentOperation=new tt(v({dom:this.container,store:this.store},this.eventBus)),this.pointCloudRender=new it(S(v({store:this.store},this.eventBus),{nextTick:this.nextTick})),this.initMsg(),document.addEventListener("keydown",this.keydown),document.addEventListener("keyup",this.keyup)}orbiterStart(){}orbiterChange(){!this.store||(this.store.orbiting=!0)}orbiterEnd(){!this.store||(this.store.orbiting=!1)}get currentSegmentTool(){var t;return(t=this.segmentOperation)==null?void 0:t.currentToolName}get pointCloudObject(){return this.scene.getObjectByName(this.pointCloudObjectName)}initMsg(){!this.segmentOperation||(this.on("CircleSelector",this.segmentOperation.updateSelector2Circle.bind(this.segmentOperation)),this.on("LassoSelector",this.segmentOperation.updateSelector2Lasso.bind(this.segmentOperation)),this.on("RectSelector",this.segmentOperation.updateSelector2Rect.bind(this.segmentOperation)),this.on("clearPointCloud",this.clearPointCloud.bind(this)),this.on("loadPCDFile",this.loadPCDFile.bind(this)))}unbindMsg(){!this.segmentOperation||(this.unbind("CircleSelector",this.segmentOperation.updateSelector2Circle.bind(this.segmentOperation)),this.unbind("LassoSelector",this.segmentOperation.updateSelector2Lasso.bind(this.segmentOperation)),this.unbind("RectSelector",this.segmentOperation.updateSelector2Rect.bind(this.segmentOperation)),this.unbind("clearPointCloud",this.clearPointCloud.bind(this)),this.unbind("loadPCDFile",this.loadPCDFile.bind(this)))}get eventBus(){return{on:this.on.bind(this),emit:this.emit.bind(this),unbind:this.unbind.bind(this)}}get pointCloudDelegate(){return v({container:this.container,scene:this.scene,camera:this.camera,renderer:this.renderer,checkMode:this.checkMode,config:this.config},this.eventBus)}get DEFAULT_INIT_CAMERA_POSITION(){return new h.Vector3(-.01,0,1e3)}get containerWidth(){return this.container.clientWidth}get containerHeight(){return this.container.clientHeight}setInitCameraPosition(t){this.initCameraPosition=t}setConfig(t){var e;this.config=t,(e=this.store)==null||e.setConfig(t)}initOrthographicCamera(t){if(this.camera.type!=="OrthographicCamera")return;const{left:e,right:i,top:r,bottom:a,near:c,far:s}=t;this.camera.left=e,this.camera.right=i,this.camera.top=r,this.camera.bottom=a,this.camera.near=c,this.camera.far=s,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:i,z:r}=this.initCameraPosition;t.position.set(e,i,r)}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 h.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 h.Color(this.backgroundColor),this.initControls(),this.initRenderer()}removeObjectByName(t,e=""){const i=this.scene.getObjectByName(e+t);i&&i.removeFromParent()}getColorFromConfig(t){return _.getColorFromConfig({attribute:t},S(v({},this.config),{attributeConfigurable:!0}),{})}generateBox(t,e=16777215){const i=e;this.addBoxToSense(t,i),this.render()}getAllAttributeColor(t){return t.reduce((e,i)=>(e[i.attribute]=this.getColorFromConfig(i.attribute),e),{})}generateBoxes(t){t.forEach(e=>{this.addBoxToSense(e)}),this.render()}getOrthographicCamera(t){const{center:e,width:i,height:r}=t,a=10,c=e.x-i/2-a,s=e.x-i/2+a,d=e.y+r/2+a,p=e.y-r/2-a,n=100,o=-100,l=500/n;return{left:c,right:s,top:d,bottom:p,near:n,far:o,zoom:l}}updateCameraZoom(t){this.camera.zoom=t,this.camera.updateProjectionMatrix()}updateCameraByBox(t,e,i){const{center:r,width:a,height:c,depth:s,rotation:d}=t,p=this.getCameraVector(r,d,{width:a,height:c,depth:s},e);return i?(this.updateCamera(i,r),new h.Vector3(i.x,i.y,i.z)):(this.updateCamera(p,r),p)}updateCameraBySphere(t,e){const{center:i}=t,{radius:r}=k,a=this.getCameraVector(i,0,{width:r*2,height:r*2,depth:r*2},e);return this.updateCamera(a,i),a}updateOrthoCamera(t,e){const i=this.updateCameraByBox(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:i}}updateOrthoCameraBySphere(t,e){const i=this.updateCameraBySphere(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:i}}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 h.Vector3(e.x,e.y,e.z),this.controls.update()}resetCamera(){this.updateCamera(this.DEFAULT_INIT_CAMERA_POSITION,{x:0,y:0,z:0})}getOrthographicCameraTarget(t){const e=new h.Vector3(0,0,-1).applyQuaternion(t.quaternion);return t.position.clone().add(e)}createThreeMatrix4(t){return new h.Matrix4().set(...t)}filterPointsByBox(t,e,i){var r,a,c;if(!e){const s=this.scene.getObjectByName(this.pointCloudObjectName);if(!s)return console.error("There is no corresponding point cloud object"),Promise.resolve(void 0);e=(c=(a=(r=s==null?void 0:s.geometry)==null?void 0:r.attributes)==null?void 0:a.position)==null?void 0:c.array}if(window.Worker){const{zMin:s,zMax:d,polygonPointList:p}=T(t),n=e;i=i!=null?i:new Float32Array([]);const o={boxParams:t,zMin:s,zMax:d,polygonPointList:p,color:i,position:n};return this.filterBoxWorker||(this.filterBoxWorker=new j),new Promise(l=>{var u;(u=this.filterBoxWorker)==null||u.postMessage(o),this.filterBoxWorker.onmessage=f=>{const{color:g,position:y,num:m}=f.data;this.geometry.dispose(),this.geometry.setAttribute("position",new h.Float32BufferAttribute(y,3)),this.geometry.setAttribute("color",new h.Float32BufferAttribute(g,3)),this.geometry.computeBoundingSphere(),this.filterBoxWorkerTimer&&clearTimeout(this.filterBoxWorkerTimer),this.filterBoxWorkerTimer=setTimeout(()=>{this.filterBoxWorker&&(this.filterBoxWorker.terminate(),this.filterBoxWorker=null)},3e3),l({geometry:this.geometry,num:m})}})}return Promise.resolve(void 0)}getCameraVector(t,e,i,r=M.Front,a=ct){let c=z.frontViewMatrix4(a);switch(r){case M.Front:break;case M.Back:c=z.backViewMatrix4(a);break;case M.Left:c=z.leftViewMatrix4(a);break;case M.Right:c=z.rightViewMatrix4(a);break;case M.Top:c=z.topViewMatrix4(a);break;case M.LFT:c=z.leftFrontTopViewMatrix4(a,i);break;case M.RBT:c=z.rightBackTopViewMatrix4(a,i);break}const s=this.createThreeMatrix4(c),d=new h.Matrix4().makeTranslation(-t.x,-t.y,-t.z),p=new h.Matrix4().makeTranslation(t.x,t.y,t.z),n=new h.Matrix4().makeRotationZ(e);return new h.Vector3(t.x,t.y,t.z).clone().applyMatrix4(s).applyMatrix4(d).applyMatrix4(n).applyMatrix4(p)}createRange(t){this.removeObjectByName(this.rangeObjectName);const i=new h.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),r=new h.BufferGeometry().setFromPoints(i),a=new h.LineBasicMaterial({color:16711680}),c=new h.Line(r,a);return c.name=this.rangeObjectName,c}renderPointCloud(t,e){t.name=this.pointCloudObjectName;const i=new h.ShaderMaterial(this.initShaderMaterial());e&&this.generateRange(e),this.pointsUuid=t.uuid,t.material=i,this.filterZAxisPoints(t),this.scene.add(t),this.render()}clearAllBox(){this.clearAllGroupByPrefix("box")}clearAllSphere(){this.clearAllGroupByPrefix("sphere")}clearAllGroupByPrefix(t=""){const e=this.scene.children;for(let i=e.length-1;i>=0;i--){const r=e[i];r.type==="Group"&&r.name.startsWith(t)&&this.removeObjectByName(r.name)}}clearPointCloud(){this.removeObjectByName(this.pointCloudObjectName)}clearPointCloudAndRender(){this.clearPointCloud(),this.render()}initCloudData(t){if(!!this.store){for(let e=0;e<t.length;e+=3){const i=t[e],r=t[e+1],a=t[e+2];this.store.cloudData.set(`${i}@${r}@${a}`,{visible:!1})}this.store.setOriginPoints(t)}}handleWebworker(t){return B(this,null,function*(){return new Promise((e,i)=>{if(this.workerLoading){i(new Error("highlightWorker called repeatedly, new call discarded"));return}this.workerLoading=!0,L.postMessage(t),L.onmessage=r=>{e(r.data),this.workerLoading=!1},L.onerror=r=>{i(r),this.workerLoading=!1}})})}highlightOriginPointCloud(t){return B(this,arguments,function*(e,i=[],r={modifiedBoxIds:[],resetAreas:[]}){const{modifiedBoxIds:a,resetAreas:c}=r,s=this.scene.getObjectByName(this.pointCloudObjectName);if(!!s)return this.highlightPCDSrc=this.currentPCDSrc,new Promise((d,p)=>{if(window.Worker){const o=(e?[...e]:[]).map(y=>T(y)),l=this.getAllAttributeColor(o),u=s.geometry.attributes.position.array,f=s.geometry.attributes.dimensions.array,g={cuboidList:o,position:u,color:f,colorList:l,highlightIndex:i,modifiedBoxIds:a,resetAreas:c};this.handleWebworker(g).then(y=>{const{color:m}=y;let x=m;(a.length||c.length)&&(x=m.map((b,P)=>b===-1?f[P]:b));const w=new h.BufferAttribute(x,3);if(!this.highlightPCDSrc||this.highlightPCDSrc!==this.currentPCDSrc||s.geometry.attributes.position.array.length!==m.length){p(new Error("Error Path"));return}this.cacheInstance.updateColor(this.highlightPCDSrc,x),this.highlightPCDSrc=void 0,w.needsUpdate=!0,s.geometry.setAttribute("dimensions",w),s.geometry.attributes.dimensions.needsUpdate=!0,d(x),this.render()}).catch(y=>{p(y)})}})})}clearHighlightBoxes(){this.removeObjectByName(this.highlightGroupName)}clearHighlightBoxesAndRender(){this.clearHighlightBoxes(),this.render()}highlightBoxes(t){const e=new h.Group;t.forEach(i=>{const{center:{x:r,y:a,z:c},width:s,height:d,depth:p,rotation:n}=i,{fill:o}=_.getColorFromConfig({attribute:i.attribute},S(v({},this.config),{attributeConfigurable:!0}),{}),l=new h.BoxGeometry(s,d,p),u=new h.MeshBasicMaterial({color:o,transparent:!0,opacity:.2,depthTest:!1});l.rotateZ(n),l.translate(r,a,c);const f=new h.Mesh(l,u);e.add(f);const g=new h.PlaneGeometry(p,d);g.rotateY(Math.PI/2),g.rotateZ(n);const y=new h.Vector3(s/2,0,0),m=new h.Matrix4().makeRotationY(Math.PI/2).makeRotationZ(n);y.applyMatrix4(m),g.translate(r+y.x,a+y.y,c+y.z);const x=new h.MeshBasicMaterial({color:o,side:h.DoubleSide,transparent:!0,opacity:.8,depthTest:!1}),w=new h.Mesh(g,x);e.add(w)}),e.name=this.highlightGroupName,this.scene.add(e),this.render()}updateColor(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(e){const i=new h.BufferAttribute(t,3);e.geometry.setAttribute("dimensions",i),e.geometry.attributes.dimensions.needsUpdate=!0,this.render()}}setShowDirection(t){this.showDirection=t,this.scene.children.forEach(e=>{e.type==="Group"&&e.children.forEach(i=>{i.type==="ArrowHelper"&&(i.visible=t)})}),this.render()}findSubAttributeLabel(t,e){if(!(t==null?void 0:t.subAttribute)||typeof t.subAttribute!="object"||!e)return"";const{inputList:i}=e;let r="";const a=Object.keys(t.subAttribute);return a.length===0||a.forEach(c=>{const s=i.find(n=>n.value===c);if(!s||!s.subSelected)return;const{key:d,subSelected:p}=s;p.forEach(n=>{var o;const l=(o=t.subAttribute)==null?void 0:o[c];(l==null?void 0:l.includes(n.value))&&(r&&(r+="\u3001"),r+=`${d}:${n.key}`)})}),r}getTextCanvas(t){const e=document.createElement("canvas"),i=e.getContext("2d"),r=window.devicePixelRatio||1,a=50;if(i){i.font=`${a}px bold`;const c=t.split(`
33
+ `),s=Math.max(...c.map(o=>i.measureText(o).width)),d=Math.ceil(s),p=a*1.5,n=p*c.length;e.width=d*r,e.height=n*r,e.style.width=`${d}px`,e.style.height=`${n}px`,i.scale(r,r),i.font=`${a}px bold`,i.fillStyle="white",i.textAlign="left",i.textBaseline="top",c.forEach((o,l)=>{i.fillText(o,0,l*p)})}return e}updateHiddenTextAndRender(t,e){this.hiddenText=t,this.generateBoxes(e)}filterNoise(t){let e=[...t];e.sort((o,l)=>o.z-l.z);const i=Math.floor(e.length*.05),r=e[i];e=e.filter(({z:o})=>o>r.z+.1);const a=.005,c=Math.floor(e.length*(1-a));e=e.slice(0,c),e.sort((o,l)=>o.x-l.x);const s=Math.floor(e.length*a),d=Math.floor(e.length*(1-a));e=e.slice(s,d),e.sort((o,l)=>o.y-l.y);const p=Math.floor(e.length*a),n=Math.floor(e.length*(1-a));return e=e.slice(p,n),e.length>100?e:t}getFittedCoordinates(t,e){const i=[];let r=[...t,t[0]];e.forEach(({x:d,y:p})=>{t.forEach((n,o)=>{const l=r[o+1],u=N.getFootOfPerpendicular({x:d,y:p},n,l,!1,!0).length;(!i[o]||u<i[o].distance)&&(i[o]={distance:u,point:{x:d,y:p}})})}),r=[t[t.length-1],...t,t[0]];const a=[i[i.length-1],...i],c=t.map((d,p)=>{const n=r[p],o=r[p+1],l=r[p+2];return Z.getIntersectionBySlope({p1:a[p].point,line1:[n,o],p2:a[p+1].point,line2:[o,l]})});return c.some(d=>!(Number.isFinite(d.x)&&Number.isFinite(d.y)))?t:c}getSensesPointZAxisInPolygon(t,e,i){var r,a,c;const s=this.scene.children.find(g=>g.uuid===this.pointsUuid);let d=0,p=0,n=0,o=0,l=[],u=[];const f=((c=(a=(r=s==null?void 0:s.geometry)==null?void 0:r.attributes)==null?void 0:a.position)==null?void 0:c.array)||[];for(let g=0;g<f.length;g+=3){const y=f[g],m=f[g+1],x=f[g+2];$({x:y,y:m},t)&&(x||x===0)&&u.push({x:y,y:m,z:x})}return u.length?(i&&(u=this.filterNoise(u),l=this.getFittedCoordinates(t,u)),u.sort((g,y)=>g.z-y.z),d=u[0].z-.01,p=u[u.length-1].z+.01,o=u.length,e&&(n=u.filter(({z:g})=>g>=e[0]&&g<=e[1]).length),{maxZ:p,minZ:d,count:n,zCount:o,fittedCoordinates:l}):{maxZ:p,minZ:d,count:n,zCount:o,fittedCoordinates:l}}getBasicCoordinate2Canvas(t){const e=this.containerWidth/2,i=this.containerHeight/2;return{x:t.x*e+e,y:t.y*i+i,z:t.z}}get basicCoordinate2CanvasMatrix4(){const t=this.containerWidth/2,e=this.containerHeight/2;return new h.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,i=this.containerHeight/2;return new h.Vector3(t.x/e-e/2,-(t.y/i-i/2),1)}getPolygonSidePoints(t){const{center:{x:e,y:i,z:r},height:a,width:c,depth:s}=t,d={x:e+c/2,y:i+a/2,z:r-s/2},p={x:e+c/2,y:i+a/2,z:r+s/2},n={x:e-c/2,y:i+a/2,z:r+s/2},o={x:e-c/2,y:i+a/2,z:r-s/2};return[d,p,n,o]}getPolygonBackPoints(t){const{center:{x:e,y:i,z:r},height:a,width:c,depth:s}=t,d={x:e-c/2,y:i+a/2,z:r+s/2},p={x:e-c/2,y:i+a/2,z:r-s/2},n={x:e-c/2,y:i-a/2,z:r-s/2},o={x:e-c/2,y:i-a/2,z:r+s/2};return[d,p,n,o]}getPolygonTopPoints(t){const{center:{x:e,y:i,z:r},height:a,width:c,depth:s}=t,d={x:e+c/2,y:i+a/2,z:r+s/2},p={x:e+c/2,y:i-a/2,z:r+s/2},n={x:e-c/2,y:i-a/2,z:r+s/2},o={x:e-c/2,y:i+a/2,z:r+s/2};return[d,p,n,o]}getModelTransformationMatrix(t){const{center:{x:e,y:i,z:r},rotation:a}=t,c=new h.Matrix4().makeTranslation(-e,-i,-r),s=new h.Matrix4().makeTranslation(e,i,r),d=new h.Matrix4().makeRotationZ(a);return new h.Matrix4().multiply(s).multiply(d).multiply(c)}getBoxSidePolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,M.Left)}getBoxBackPolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,M.Back)}getSphereSidePoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}getSphereBackPoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}boxParams2ViewPolygon(t,e){switch(e){case M.Left:return this.getPolygonSidePoints(t);case M.Back:return this.getPolygonBackPoints(t);default:return this.getPolygonTopPoints(t)}}getBoxPolygon2DCoordinate(t,e){const i=this.boxParams2ViewPolygon(t,e),{width:r,height:a}=t,c=new h.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),s=new h.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(c).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=s;const d=i.map(o=>new h.Vector3(o.x,o.y,o.z)).map(o=>o.applyMatrix4(this.sideMatrix)),p=this.containerWidth/r,n=this.containerHeight/a;return{polygon2d:d,zoom:Math.min(p,n)/2}}getSpherePoint2DCoordinate(t){const{center:e,attribute:i,id:r,valid:a}=t,{radius:c}=k,s={center:e,attribute:i,id:r,valid:a,width:c*2,height:c*2,depth:c*2,rotation:0},d=new h.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),p=new h.Matrix4().premultiply(this.getModelTransformationMatrix(s)).premultiply(d).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=p;const n=new h.Vector3(e.x,e.y,e.z).applyMatrix4(this.sideMatrix),o=this.containerWidth/(c*2),l=this.containerHeight/(c*2);return{point2d:n,zoom:Math.min(o,l)/2}}getSphereTopPoint2DCoordinate(t){const{center:e}=t,{radius:i}=k,r={x:-(e.y-this.containerWidth/2),y:-(e.x-this.containerHeight/2)},a=this.containerWidth/(i*2),c=this.containerHeight/(i*2);return{point2d:r,zoom:Math.min(a,c)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:i}=t,a=this.getPolygonTopPoints(t).map(d=>new h.Vector3(d.x,d.y,d.z)).map(d=>d.applyMatrix4(this.getModelTransformationMatrix(t))).map(d=>({x:d.y,y:d.x})).map(d=>({x:-(d.x-this.containerWidth/2),y:-(d.y-this.containerHeight/2)})),c=this.containerWidth/e,s=this.containerHeight/i;return{polygon2d:a,zoom:Math.min(c,s)/2}}getNewBoxBySideUpdate(t,e,i,r){const a=new h.Matrix4().makeRotationZ(r.rotation),c=new h.Vector3(-t.x,0,0).applyMatrix4(a);let s=r;return s.center={x:s.center.x+c.x,y:s.center.y+c.y,z:s.center.z-t.z},s=S(v({},s),{width:Math.abs(s.width+e),height:s.height,depth:Math.abs(s.depth+i)}),{newBoxParams:s}}getNewBoxByBackUpdate(t,e,i,r){const a=new h.Matrix4().makeRotationZ(r.rotation),c=new h.Vector3(0,-t.x,0).applyMatrix4(a);let s=r;return s.center={x:s.center.x+c.x,y:s.center.y+c.y,z:s.center.z-t.z},s=S(v({},s),{width:s.width,height:Math.abs(s.height+e),depth:Math.abs(s.depth+i)}),{newBoxParams:s}}getNewBoxBySideUpdateByPoints(t,e,i,r){var a;const c=(a=this.sideMatrix)==null?void 0:a.invert();if(!this.sideMatrix||!c){console.error("No sideMatrix");return}this.camera.zoom=1,this.camera.updateProjectionMatrix();const s=t.map(y=>new h.Vector3(y.x,y.y,y.z)).map(y=>y.applyMatrix4(c)),[d,p,n,o]=s,l=Math.max(Math.abs(d.x-n.x),Math.abs(d.x-p.x)),f=p.add(o).applyMatrix3(new h.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new h.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new h.Vector3(r.center.x,r.center.y,r.center.z));return{newBoxParams:S(v({},r),{center:{x:r.center.x-f.x,y:r.center.y-f.y,z:r.center.z-i},width:l,height:r.height,depth:r.depth+e,rotation:r.rotation})}}filterZAxisPoints(t){const e=t||this.scene.children.find(i=>i.uuid===this.pointsUuid);if(e){const{attributes:i}=e.geometry,{position:r}=i,a=[],{count:c}=r;for(let s=0;s<c;s++){const d=r.getZ(s);a.push(d>this.zAxisLimit?0:1)}e.geometry.setAttribute("visibility",new h.Float32BufferAttribute(a,1)),e.geometry.attributes.visibility.needsUpdate=!0}}render(){this.renderer.render(this.scene,this.camera)}}export{lt as PointCloud};