@labelbee/lb-annotation 1.13.1-alpha.0 → 1.14.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -0
- package/dist/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -0
- package/dist/assets/attributeIcon/icon_cuboidMore.svg.js +5 -0
- package/dist/assets/attributeIcon/icon_cuboidRight.svg.js +5 -0
- package/dist/assets/attributeIcon/icon_cuboidTop.svg.js +12 -0
- package/dist/constant/annotation.js +1 -1
- package/dist/constant/tool.js +1 -1
- package/dist/core/pointCloud/annotation.js +1 -1
- package/dist/core/pointCloud/index.js +2 -2
- package/dist/core/scheduler.js +1 -1
- package/dist/core/toolOperation/ViewOperation.js +1 -1
- package/dist/core/toolOperation/basicToolOperation.js +1 -1
- package/dist/core/toolOperation/cuboidOperation.js +1 -0
- package/dist/core/toolOperation/cuboidToggleButtonClass.js +31 -0
- package/dist/core/toolOperation/pointOperation.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types/constant/annotation.d.ts +45 -1
- package/dist/types/constant/tool.d.ts +6 -1
- package/dist/types/core/index.d.ts +1 -2
- package/dist/types/core/pointCloud/annotation.d.ts +16 -3
- package/dist/types/core/pointCloud/index.d.ts +45 -10
- package/dist/types/core/pointCloud/matrix.d.ts +1 -0
- package/dist/types/core/scheduler.d.ts +18 -2
- package/dist/types/core/toolOperation/ViewOperation.d.ts +3 -2
- package/dist/types/core/toolOperation/basicToolOperation.d.ts +11 -1
- package/dist/types/core/toolOperation/cuboidOperation.d.ts +174 -0
- package/dist/types/core/toolOperation/cuboidToggleButtonClass.d.ts +38 -0
- package/dist/types/core/toolOperation/pointOperation.d.ts +6 -1
- package/dist/types/core/toolOperation/textAttributeClass.d.ts +9 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/utils/MathUtils.d.ts +1 -1
- package/dist/types/utils/tool/AttributeUtils.d.ts +7 -0
- package/dist/types/utils/tool/AxisUtils.d.ts +50 -1
- package/dist/types/utils/tool/CuboidUtils.d.ts +267 -0
- package/dist/types/utils/tool/DrawUtils.d.ts +32 -0
- package/dist/types/utils/tool/EnhanceCommonToolUtils.d.ts +4 -2
- package/dist/types/utils/tool/PolygonUtils.d.ts +5 -2
- package/dist/utils/MathUtils.js +2 -2
- package/dist/utils/tool/AttributeUtils.js +1 -1
- package/dist/utils/tool/AxisUtils.js +1 -1
- package/dist/utils/tool/CuboidUtils.js +1 -0
- package/dist/utils/tool/DrawUtils.js +3 -3
- package/dist/utils/tool/EnhanceCommonToolUtils.js +1 -1
- package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -3
- package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -3
- package/es/assets/attributeIcon/icon_cuboidMore.svg.js +5 -3
- package/es/assets/attributeIcon/icon_cuboidRight.svg.js +5 -3
- package/es/assets/attributeIcon/icon_cuboidTop.svg.js +12 -3
- package/es/constant/annotation.js +1 -1
- package/es/constant/tool.js +1 -1
- package/es/core/pointCloud/annotation.js +1 -1
- package/es/core/pointCloud/index.js +2 -2
- package/es/core/scheduler.js +1 -1
- package/es/core/toolOperation/ViewOperation.js +1 -1
- package/es/core/toolOperation/basicToolOperation.js +1 -1
- package/es/core/toolOperation/cuboidOperation.js +1 -736
- package/es/core/toolOperation/cuboidToggleButtonClass.js +7 -150
- package/es/core/toolOperation/pointOperation.js +1 -1
- package/es/index.js +1 -1
- package/es/utils/MathUtils.js +2 -2
- package/es/utils/tool/AttributeUtils.js +1 -1
- package/es/utils/tool/AxisUtils.js +1 -1
- package/es/utils/tool/CuboidUtils.js +1 -663
- package/es/utils/tool/DrawUtils.js +3 -3
- package/es/utils/tool/EnhanceCommonToolUtils.js +1 -1
- package/package.json +3 -3
- package/dist/types/core/pointCloud/segmentation.d.ts +0 -0
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +0 -12
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +0 -7
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +0 -11
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +0 -18
- package/es/core/pointCloud/segmentation.js +0 -50
- package/es/core/toolOperation/scribbleTool2.js +0 -249
|
@@ -2,14 +2,17 @@ import { ERotateDirection } from '@/constant/annotation';
|
|
|
2
2
|
import { IPolygonData, IPolygonPoint } from '../../types/tool/polygon';
|
|
3
3
|
import { ELineTypes } from '../../constant/tool';
|
|
4
4
|
export default class PolygonUtils {
|
|
5
|
-
static getHoverPolygonID(checkPoint: IPolygonPoint, polygonPoints:
|
|
5
|
+
static getHoverPolygonID(checkPoint: IPolygonPoint, polygonPoints: {
|
|
6
|
+
pointList: IPolygonPoint[];
|
|
7
|
+
id: string;
|
|
8
|
+
}[], scope?: number, lineType?: ELineTypes): string;
|
|
6
9
|
/**
|
|
7
10
|
* 计算多边形面积(Shoelace Theorem,鞋带定理)
|
|
8
11
|
* @param pointList
|
|
9
12
|
* @returns
|
|
10
13
|
*/
|
|
11
14
|
static calcPolygonSize(pointList?: IPolygonPoint[]): number;
|
|
12
|
-
static isInPolygon(checkPoint: IPolygonPoint, polygonPoints: IPolygonPoint[], lineType?: ELineTypes): boolean;
|
|
15
|
+
static isInPolygon(checkPoint: IPolygonPoint, polygonPoints: (IPolygonPoint | ICoordinate)[], lineType?: ELineTypes): boolean;
|
|
13
16
|
/**
|
|
14
17
|
* 通过数据转换为平滑曲线的点提交 [{x: number, y: number}...] => [x, ...smoothCurvePoints ,y]
|
|
15
18
|
* @param pointList
|
package/dist/utils/MathUtils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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,__defNormalProp=(e,t,o)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,__spreadValues=(e,t)=>{for(var o in t||(t={}))__hasOwnProp.call(t,o)&&__defNormalProp(e,o,t[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(t))__propIsEnum.call(t,o)&&__defNormalProp(e,o,t[o]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));class Trigonometric{static tanAPlusB(t,o){return(t+o)/(1-t*o)}static sinAPlusB(t,o,s,r){return r*t+o*s}static cosAPlusB(t,o,s,r){return o*r-t*s}}const _MathUtils=class{static getRotate(e){return e+90>=360?e+90-360:e+90}static getLineLength(e,t){return Math.sqrt(Math.pow(t.y-e.y,2)+Math.pow(t.x-e.x,2))}static getTextArea(e,t,o=tool.DEFAULT_TEXT_MAX_WIDTH,s=tool.DEFAULT_FONT,r){if(typeof t!="string")return{width:0,height:0};const i=e.getContext("2d");i.font=s;let n=0;typeof r=="undefined"&&(r=e&&parseInt(window.getComputedStyle(e).lineHeight,10)||parseInt(window.getComputedStyle(document.body).lineHeight,10));const
|
|
2
|
-
`);let l=0;for(let u=0;u<
|
|
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,__defNormalProp=(e,t,o)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,__spreadValues=(e,t)=>{for(var o in t||(t={}))__hasOwnProp.call(t,o)&&__defNormalProp(e,o,t[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(t))__propIsEnum.call(t,o)&&__defNormalProp(e,o,t[o]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));class Trigonometric{static tanAPlusB(t,o){return(t+o)/(1-t*o)}static sinAPlusB(t,o,s,r){return r*t+o*s}static cosAPlusB(t,o,s,r){return o*r-t*s}}const _MathUtils=class{static getRotate(e){return e+90>=360?e+90-360:e+90}static getLineLength(e,t){return Math.sqrt(Math.pow(t.y-e.y,2)+Math.pow(t.x-e.x,2))}static getTextArea(e,t,o=tool.DEFAULT_TEXT_MAX_WIDTH,s=tool.DEFAULT_FONT,r){if(typeof t!="string")return{width:0,height:0};const i=e.getContext("2d");i.font=s;let n=0;typeof r=="undefined"&&(r=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=t.split(`
|
|
2
|
+
`);let l=0;for(let u=0;u<c.length;u++){const p=c[u].split("");let g="";for(let y=0;y<p.length;y++){const f=g+p[y],h=i.measureText(f).width;h>o&&y>0?(g=p[y],n+=r,l=o):(g=f,h>l&&(l=h))}u!==c.length-1&&(n+=r)}return{width:l,height:n+a,lineHeight:r,fontHeight:a}}static getLineCenterPoint(e){const[t,o]=e,s=VectorUtils.getVector(t,o);return{x:t.x+s.x/2,y:t.y+s.y/2}}static getPerpendicularLine(e){if(e.length!==2)return;const[t,o]=e,s={x:o.x+o.y-t.y,y:o.y-(o.x-t.x)};return[o,s]}static getPerpendicularFootOfLine(e,t){if(e.length!==2)return e;const o=this.getPerpendicularLine(e);if(!o)return e;const[s,r]=o;return this.getFootOfPerpendicular(t,s,r).footPoint}static getQuadrangleFromTriangle(e){if(e.length!==3)return e;const[t,o,s]=e,r={x:s.x+t.x-o.x,y:s.y+t.y-o.y};return[t,o,s,r]}static getRectPerpendicularOffset(e,t,o){const[s,r]=o,i=this.getFootOfPerpendicular(e,s,r).footPoint,n=this.getFootOfPerpendicular(t,s,r).footPoint,a={x:i.x-n.x,y:i.y-n.y},c=VectorUtils.add(t,a);return VectorUtils.getVector(e,c)}static getArrayIndex(e,t){return e<0?t+e:e>=t?e-t:e}static getPointListFromPointOffset(e,t,o){const s=this.getArrayIndex(t-1,e.length),r=this.getArrayIndex(t+1,e.length),i=this.getArrayIndex(t-2,e.length),n=[...e];n[t]=VectorUtils.add(n[t],o);const a=this.getFootOfPerpendicular(n[t],n[i],n[s]).footPoint,c=this.getFootOfPerpendicular(n[t],n[r],n[i]).footPoint;return n[s]=a,n[r]=c,n}static getRectCenterPoint(e){const[t,,o]=e;return{x:(t.x+o.x)/2,y:(t.y+o.y)/2}}static rotateRectPointList(e=5,t){const o=this.getRectCenterPoint(t),{PI:s}=Math,r=Math.sin(e*s/180),i=Math.cos(e*s/180);return t.map(n=>{const a=VectorUtils.getVector(o,n),c=VectorUtils.len(a),l=a.y/c,u=a.x/c;return{x:c*Trigonometric.cosAPlusB(l,u,r,i)+o.x,y:c*Trigonometric.sinAPlusB(l,u,r,i)+o.y}})}static getRectangleByRightAngle(e,t){if(t.length!==2)return t;const o=_MathUtils.getPerpendicularFootOfLine(t,e);return _MathUtils.getQuadrangleFromTriangle([...t,o])}static getRadiusFromQuadrangle(e){const[,t,o]=e,s=o.y-t.y,r=t.x-o.x,i=this.getLineLength(t,o),n=s/i,a=Math.acos(n);return r>0?Math.PI*2-a:a}static getCollectionPointByAnnotationDataPromise(e){const t=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=new MathUtilsWorker;return{promise:new Promise(function(i){s.postMessage({points:t,backgroundList:o}),s.onmessage=n=>{i(n.data),s.terminate()}}),close:()=>{s.terminate()}}}static getCollectionPointByAnnotationData(e){const t=[],o=new Set,s=e.filter(n=>n.type==="point").map(n=>n.annotation),r=e.filter(n=>!!["polygon","line"].includes(n.type)).map(n=>n.type==="polygon"?__spreadProps(__spreadValues({},n.annotation),{pointList:PolygonUtils.concatBeginAndEnd(n.annotation.pointList)}):n.annotation),i=(n,a)=>{const{dropFoot:c}=PolygonUtils.getClosestPoint(n,a,tool.ELineTypes.Line,1,{isClose:!1});if(c!==n){const l=`${c.x} + ${c.y}`;o.has(l)||t.push(n),o.add(l)}};return s.forEach(n=>{i(n,r)}),r.forEach(n=>{let a="";a=n.id,r.forEach((c,l)=>{if(c.id===a)return;const u=[...r];u.splice(l,1),c.pointList.forEach(p=>{i(p,u)})})}),{connectionPoints:t}}};let MathUtils=_MathUtils;MathUtils.isInRange=(e,t)=>{const o=Math.min(...t),s=Math.max(...t),r=n=>n<=s&&n>=o;return(Array.isArray(e)?e:[e]).every(n=>r(n))},MathUtils.withinRange=(e,t)=>{const o=Math.min(...t),s=Math.max(...t);return e>s?s:e<o?o:e},MathUtils.calcViewportBoundaries=(e,t=!1,o=tool.SEGMENT_NUMBER,s=1)=>{if(!e)return{top:0,bottom:0,left:0,right:0};const r=20/s,i=[],n=[];let a=e;t&&(a=polygonTool.createSmoothCurvePointsFromPointList(e,o)),a.forEach(({x:f,y:d})=>{i.push(f),n.push(d)});let c=Math.min(...i),l=Math.max(...i),u=Math.min(...n),p=Math.max(...n);const g=l-c,y=p-u;if(g<r){const f=(r-g)/2;c-=f,l+=f}if(y<r){const f=(r-y)/2;u-=f,p+=f}return{top:u,bottom:p,left:c,right:l}},MathUtils.getFootOfPerpendicular=(e,t,o,s=!1,r=!1)=>{let i={x:0,y:0};const n=t.x-o.x,a=t.y-o.y;if(Math.abs(n)<1e-8&&Math.abs(a)<1e-8)return i=t,i;let c=(e.x-t.x)*(t.x-o.x)+(e.y-t.y)*(t.y-o.y);c/=n*n+a*a,i.x=t.x+c*n,i.y=t.y+c*a;const l=_MathUtils.getLineLength(e,i),u=2,p=Math.min(t.x,o.x),g=Math.max(t.x,o.x),y=Math.min(t.y,o.y),f=Math.max(t.y,o.y),d=!(_MathUtils.isInRange(e.x,[p,g])||_MathUtils.isInRange(e.y,[y,f])),h=e.x>g+u||e.x<p-u||e.y>f+u||e.y<y-u;return!r&&(s?d:h)?{footPoint:i,length:Infinity}:{footPoint:i,length:l}};var MathUtils$1=MathUtils;exports.Trigonometric=Trigonometric,exports.default=MathUtils$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _=require("lodash"),style=require("../../constant/style.js"),tool=require("../../constant/tool.js"),index=require("../../locales/index.js"),constants=require("../../locales/constants.js"),MathUtils=require("../MathUtils.js"),icon_canvasEdit_miss=require("../../assets/attributeIcon/icon_canvasEdit_miss.svg.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _=require("lodash"),lbUtils=require("@labelbee/lb-utils"),style=require("../../constant/style.js"),tool=require("../../constant/tool.js"),index=require("../../locales/index.js"),constants=require("../../locales/constants.js"),MathUtils=require("../MathUtils.js"),icon_canvasEdit_miss=require("../../assets/attributeIcon/icon_canvasEdit_miss.svg.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(s,t,e)=>t in s?__defProp(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,__spreadValues=(s,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(s,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(s,e,t[e]);return s},__spreadProps=(s,t)=>__defProps(s,__getOwnPropDescs(t));const REGEXP_NUMBER="^[0-9]+$",REGEXP_ENGLISH="^[A-Za-z]+$";class AttributeUtils{static getAttributeIcon(t,e,r=!0){var n;const a=e.findIndex(l=>l.value===t);let i=(n=style.ICON_ARRAY[a%style.ICON_ARRAY.length])!=null?n:style.NULL_ICON;r||(i=icon_canvasEdit_miss),i="";const u=new Image;return u.src=i,u}static checkString(t,e){let r="";switch(t){case tool.ETextType.Order:case tool.ETextType.NumberOnly:r=REGEXP_NUMBER;break;case tool.ETextType.EnglishOnly:r=REGEXP_ENGLISH;break;case tool.ETextType.CustomFormat:r=e;break}return r}static checkTextAttibute(t,e){if(t===void 0||t==="")return!0;try{return new RegExp(e).test(t)}catch(r){return!1}}static getAttributeShowText(t,e=[]){var r,n;try{const a=e.findIndex(i=>i.value===t);return(n=(r=e[a])==null?void 0:r.key)!=null?n:t}catch(a){return t}}static getAttributeIndex(t,e){try{const r=e.findIndex(n=>n.value===t);return r>=8?r%8:r}catch(r){return-1}}static getAttributeColor(t,e){try{const r=this.getAttributeIndex(t,e);return r===-1?style.NULL_COLOR:style.COLORS_ARRAY[r%style.COLORS_ARRAY.length]}catch(r){return style.NULL_COLOR}}static getTextAttribute(t,e){try{if(e===tool.ETextType.Order){const r=t.map(a=>parseInt(a.textAttribute,10)).filter(a=>_.isNumber(a)&&a<Number.MAX_SAFE_INTEGER&&a>=0);return r.sort((a,i)=>a-i),`${(r.pop()||0)+1}`}return""}catch(r){return""}}static textChange(t,e,r){return r.map(n=>n.id===e?__spreadProps(__spreadValues({},n),{textAttribute:t}):n)}static getErrorNotice(t,e){switch(t){case tool.ETextType.Order:case tool.ETextType.NumberOnly:return index.getMessagesByLocale(constants.EMessage.TextCheckNumberErrorNotice,e);case tool.ETextType.EnglishOnly:return index.getMessagesByLocale(constants.EMessage.TextCheckEnglishErrorNotice,e);case tool.ETextType.CustomFormat:return index.getMessagesByLocale(constants.EMessage.TextCheckCustomErrorNotice,e);default:return""}}static textAttributeValidate(t,e,r){try{return new RegExp(this.checkString(t,e)).test(r)}catch(n){}}static checkTextAttribute(t,e,r,n){let a=!1;return r.forEach(i=>{(i==null?void 0:i.textAttribute)===void 0||(i==null?void 0:i.textAttribute)===""||(n?i.id===n:!0)&&!this.textAttributeValidate(t,e,i.textAttribute)&&(a=!0)}),!!a}static changeTextAttributeInLog(t,e){return t==null?void 0:t.map(r=>r==null?void 0:r.map(n=>{if((e==null?void 0:e.findIndex(a=>(a==null?void 0:a.id)===(n==null?void 0:n.id)))>-1){const a=e==null?void 0:e.find(i=>(i==null?void 0:i.id)===(n==null?void 0:n.id));return __spreadProps(__spreadValues({},n),{textAttribute:a==null?void 0:a.textAttribute})}return n}))}static getTextIconSvg(t="",e,r=!1,n){var a;if(r===!0){const i=(e==null?void 0:e.findIndex(l=>(l==null?void 0:l.value)===t))%style.COLORS_ARRAY.length+1,u=(a=e==null?void 0:e.find(l=>l.value===t))==null?void 0:a.color;if(u){const l=lbUtils.ToolStyleUtils.rgbaStringToHex(u);return this.generateIconAttribute({fill:l})}return style.ICON_ARRAY[i]}return n}static generateIconAttribute({fill:t,width:e=16,height:r=16,xmlns:n="http://www.w3.org/2000/svg",xlink:a="http://www.w3.org/1999/xlink"}){return`<span style={color:${t}}><svg xmlns=${n} xmlns:xlink=${a} width=${e} height=${r} viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill='currentColor'/></g></g></svg></span>`}static getAttributeByKeycode(t,e){var r;let n;return MathUtils.default.isInRange(t,[48,57])&&(n=t-48),MathUtils.default.isInRange(t,[96,105])&&(n=t-96),n===0?"":n?(r=e[n-1])==null?void 0:r.value:void 0}}exports.REGEXP_ENGLISH=REGEXP_ENGLISH,exports.REGEXP_NUMBER=REGEXP_NUMBER,exports.default=AttributeUtils;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tool=require("../../constant/tool.js"),MathUtils=require("../MathUtils.js"),PolygonUtils=require("./PolygonUtils.js"),LineToolUtils=require("./LineToolUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tool=require("../../constant/tool.js"),MathUtils=require("../MathUtils.js"),PolygonUtils=require("./PolygonUtils.js"),LineToolUtils=require("./LineToolUtils.js"),CuboidUtils=require("./CuboidUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(h,t,e)=>t in h?__defProp(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,__spreadValues=(h,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(h,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(h,e,t[e]);return h},__spreadProps=(h,t)=>__defProps(h,__getOwnPropDescs(t));class AxisUtils{static getOffsetCoordinate(t,e,i){return{x:t.x*i+e.x,y:t.y*i+e.y}}static changeDrawOutsideTarget(t,e,i,s,n,o){return typeof s=="boolean"&&!s&&(n&&o?(t.x-e.x>(n.x+n.width)*o&&(t.x=(n.x+n.width)*o+e.x),t.x-e.x<n.x*o&&(t.x=n.x*o+e.x),t.y-e.y>(n.y+n.height)*o&&(t.y=(n.y+n.height)*o+e.y),t.y-e.y<n.y*o&&(t.y=n.y*o+e.y)):(t.x-e.x>i.width&&(t.x=i.width+e.x),t.x-e.x<0&&(t.x=e.x),t.y-e.y>i.height&&(t.y=i.height+e.y),t.y-e.y<0&&(t.y=e.y))),t}static changeCoordinateByRotate(t,e,i){const{width:s,height:n}=i,{x:o,y:r}=t;switch(e%360){case 90:return{x:n-r,y:o};case 180:return{x:s-o,y:n-r};case 270:return{x:r,y:s-o};default:return t}}static changeRectByZoom(t,e,i={x:0,y:0}){return __spreadProps(__spreadValues({},t),{x:t.x*e+i.x,y:t.y*e+i.y,width:t.width*e,height:t.height*e})}static changePointByZoom(t,e,i={x:0,y:0}){return __spreadProps(__spreadValues({},t),{x:t.x*e+i.x,y:t.y*e+i.y})}static changePointListByZoom(t,e,i={x:0,y:0}){return t==null?void 0:t.map(s=>this.changePointByZoom(s,e,i))}static changePlanePointByZoom(t,e,i={x:0,y:0}){return Object.entries(t).reduce((s,[n,o])=>{const r=AxisUtils.changePointByZoom(o,e,i);return __spreadProps(__spreadValues({},s),{[n]:r})},{})}static changeCuboidByZoom(t,e,i={x:0,y:0}){return __spreadProps(__spreadValues({},t),{frontPoints:this.changePlanePointByZoom(t.frontPoints,e,i),backPoints:t.backPoints?this.changePlanePointByZoom(t.backPoints,e,i):t.backPoints})}static transformPlain2PointList({tl:t,tr:e,br:i,bl:s}){return[t,e,i,s]}static axisArea(t,e=3){const{x:i,y:s}=t,n=[];for(let o=i-e;o<i+e;o+=e/3)for(let r=s-e;r<s+e;r+=e/3)n.push({x:o,y:r});return n}static getOriginCoordinateWithOffsetCoordinate(t,e=1,i={x:0,y:0}){return{x:(t.x-i.x)/e,y:(t.y-i.y)/e}}static returnClosePointIndex(t,e,i=3){let s=-1;for(let n=0;n<e.length;n++){const o=e[n];this.getIsInScope(t,o,i)&&(s=n)}return s}static isCloseCuboid(t,e,i={scope:5,zoom:1}){const s=CuboidUtils.getHighlightPoints(e),{scope:n=5}=i;for(let r=0;r<s.length;r++){const g=s[r];if(this.getIsInScope(t,g.point,n))return!0}const o=CuboidUtils.getHighlightLines(e);for(let r=0;r<o.length;r++){const g=o[r],{length:y}=MathUtils.default.getFootOfPerpendicular(t,g.p1,g.p2,!0);if(y<n)return!0}return!!PolygonUtils.isInPolygon(t,CuboidUtils.getCuboidHoverRange(e))}static isCloseCuboidList(t,e,i={scope:5,zoom:1}){return e.some(s=>this.isCloseCuboid(t,s,i))}static returnClosePointOrLineInCuboid(t,e,i={scope:5,zoom:1}){const s=CuboidUtils.getHighlightPoints(e),{scope:n=5,zoom:o=1}=i;for(let a=0;a<s.length;a++){const l=s[a];if(this.getIsInScope(t,l.point,n))return[{type:"point",points:[this.changePointByZoom(s[a].point,o)],originCuboid:e,positions:l.positions}]}let r=n;const g=CuboidUtils.getHighlightLines(e);let y;for(let a=0;a<g.length;a++){const l=g[a],{length:p}=MathUtils.default.getFootOfPerpendicular(t,l.p1,l.p2,!0);p<r&&(r=p,y=[{type:"line",points:this.changePointListByZoom([l.p1,l.p2],o),originCuboid:e,positions:l.positions}])}if(y)return y}static getIsInScope(t,e,i){return Math.abs(t.x-e.x)<i&&Math.abs(t.y-e.y)<i}}class CoordinateUtils{constructor(t){this.currentPos=t.currentPos,this.zoom=t.zoom,this.basicImgInfo=t.basicImgInfo,this.dependToolName=""}get isDependPolygon(){return this.dependToolName===tool.EToolName.Polygon}get isDependRect(){return this.dependToolName===tool.EToolName.Rect}get isDependOriginalImage(){return this.dependToolName===""}getAbsCoord(t){return{x:(t.x-this.currentPos.x)/this.zoom,y:(t.y-this.currentPos.y)/this.zoom}}getRenderCoord(t){return{x:t.x*this.zoom+this.currentPos.x,y:t.y*this.zoom+this.currentPos.y}}coordInsideRect(t,e){const{x:i,y:s,width:n,height:o}=e;return{x:MathUtils.default.withinRange(t.x,[i,i+n]),y:MathUtils.default.withinRange(t.y,[s,s+o])}}getPolygonPointList(t,e){return t===tool.ELineTypes.Curve?PolygonUtils.createSmoothCurvePointsFromPointList(e):e}getIntersection(t,e,i){const s=this.getRenderCoord(e),n=this.getRenderCoord(t),o={pointA:s,pointB:n};return LineToolUtils.default.calcOptimalIntersection(i,o,s,LineToolUtils.POINT_RADIUS,this.zoom)}coordInsidePolygon(t,e,i,s){const{pointList:n}=i,o=s==null?void 0:s.lineType;if(n.length===0)return t;const r=this.getPolygonPointList(o,n);if(PolygonUtils.isInPolygon(t,r))return t;const y=r.concat(r[0]).map(l=>this.getRenderCoord(l)),a=this.getIntersection(t,e,y);return a?this.getAbsCoord(a==null?void 0:a.point):t}coordInsideImage(t){return this.coordInsideRect(t,__spreadProps(__spreadValues({},this.basicImgInfo),{x:0,y:0}))}getNextCoordByDependTool(t,e){if(this.isDependRect)return this.coordInsideRect(t,this.basicResult);if(this.isDependPolygon)return this.coordInsidePolygon(t,e,this.basicResult,this.dependToolConfig);if(this.isDependOriginalImage)return this.coordInsideImage(t)}setDependInfo(t,e){this.dependToolName=t!=null?t:"",this.dependToolConfig=t?e:void 0}setBasicImgInfo(t){this.basicImgInfo=t}setBasicResult(t){this.basicResult=t}setZoomAndCurrentPos(t,e){this.zoom=t,this.currentPos=e}isCoordInsideTarget(t){if(this.isDependPolygon)return this.isInBasicPolygon(t);if(this.isDependRect){const{x:e,y:i,width:s,height:n}=this.basicResult,o=[e,e+s],r=[i,i+n];return MathUtils.default.isInRange(t.x,o)&&MathUtils.default.isInRange(t.y,r)}return MathUtils.default.isInRange(t.x,[0,this.basicImgInfo.width])&&MathUtils.default.isInRange(t.y,[0,this.basicImgInfo.height])}isInBasicPolygon(t){var e,i;return PolygonUtils.isInPolygon(t,((e=this.basicResult)==null?void 0:e.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}}exports.CoordinateUtils=CoordinateUtils,exports.default=AxisUtils;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _=require("lodash"),annotation=require("../../constant/annotation.js"),AxisUtils=require("./AxisUtils.js"),VectorUtils=require("../VectorUtils.js"),LineToolUtils=require("./LineToolUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(i,t,n)=>t in i?__defProp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,__spreadValues=(i,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(i,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(i,n,t[n]);return i},__spreadProps=(i,t)=>__defProps(i,__getOwnPropDescs(t));function getPlanePointsBasicInfo({tr:i,tl:t,br:n}){return{width:Math.abs(i.x-t.x),height:Math.abs(n.y-i.y),centerPoints:{x:(t.x+n.x)/2,y:(t.y+n.y)/2}}}function getCuboidBasicInfo({frontPoints:i,backPoints:t}){const{width:n,height:o,centerPoints:r}=getPlanePointsBasicInfo(i),{width:e,height:s,centerPoints:l}=getPlanePointsBasicInfo(t);return{frontCenter:r,backCenter:l,frontWidth:n,frontHeight:o,backWidth:e,backHeight:s,isLeftSide:l.x<r.x}}function getPlainPointsByDiagonalPoints(i,t){return{tl:{x:Math.min(i.x,t.x),y:Math.min(i.y,t.y)},tr:{x:Math.max(i.x,t.x),y:Math.min(i.y,t.y)},bl:{x:Math.min(i.x,t.x),y:Math.max(i.y,t.y)},br:{x:Math.max(i.x,t.x),y:Math.max(i.y,t.y)}}}function getMaxExternalQuadrilateral(i){const t=Object.values(i).reduce((e,s)=>s.x<e?s.x:e,Number.MAX_SAFE_INTEGER),n=Object.values(i).reduce((e,s)=>s.x>e?s.x:e,0),o=Object.values(i).reduce((e,s)=>s.y<e?s.y:e,Number.MAX_SAFE_INTEGER),r=Object.values(i).reduce((e,s)=>s.y>e?s.y:e,0);return{tl:{x:t,y:o},tr:{x:n,y:o},bl:{x:t,y:r},br:{x:n,y:r}}}function judgeCuboidLineIsRowOrColumn(i){const[t,n]=i;if(annotation.CUBOID_ROW[t.position]===n.position)return annotation.ECuboidLineDirection.Row;if(annotation.CUBOID_COLUMN[t.position]===n.position)return annotation.ECuboidLineDirection.Column}function getPointsByBottomRightPoint({coord:i,points:t}){const{width:n,height:o}=getPlanePointsBasicInfo(t);return{br:i,tr:{x:i.x,y:i.y-o},tl:{x:i.x-n,y:i.y-o},bl:{x:i.x-n,y:i.y}}}function getPointsByBottomLeftPoint({coord:i,points:t}){const{width:n,height:o}=getPlanePointsBasicInfo(t);return{bl:i,tr:{x:i.x+n,y:i.y-o},tl:{x:i.x,y:i.y-o},br:{x:i.x+n,y:i.y}}}function getCuboidShowingSideLine({frontPoints:i,backPoints:t}){const{isLeftSide:n}=getCuboidBasicInfo({frontPoints:i,backPoints:t});return n?{top:{p1:i.tl,p2:t.tl},bottom:{p1:i.bl,p2:t.bl}}:{top:{p1:i.tr,p2:t.tr},bottom:{p1:i.br,p2:t.br}}}function getPointsByIntersection({frontPoints:i,backPoints:t}){const{isLeftSide:n}=getCuboidBasicInfo({frontPoints:i,backPoints:t});let o=__spreadValues({},t);const r=getCuboidShowingSideLine({frontPoints:i,backPoints:t}),e=LineToolUtils.default.lineIntersection({pointA:r.bottom.p1,pointB:r.bottom.p2},{pointA:r.top.p1,pointB:r.top.p2});if(n){const s=LineToolUtils.default.lineIntersection({pointA:t.bl,pointB:t.br},{pointA:i.br,pointB:e});s&&(o=__spreadProps(__spreadValues({},t),{br:s,tr:{x:s.x,y:t.tl.y}}))}else{const s=LineToolUtils.default.lineIntersection({pointA:t.bl,pointB:t.br},{pointA:i.bl,pointB:e});s&&(o=__spreadProps(__spreadValues({},t),{bl:s,tl:{x:s.x,y:t.tr.y}}))}return{backPoints:o}}function getBackPointsByFrontPoints({frontPoints:i,backPoints:t}){const{isLeftSide:n,frontHeight:o,backHeight:r}=getCuboidBasicInfo({frontPoints:i,backPoints:t});let e=__spreadValues({},t);return n?e=getPointsByBottomLeftPoint({coord:t.bl,points:i}):e=getPointsByBottomRightPoint({coord:t.br,points:i}),o>r&&(e=getPointsByIntersection({frontPoints:i,backPoints:t}).backPoints),{frontPoints:i,backPoints:e}}function getFrontPointsByBackPoints({frontPoints:i,backPoints:t}){const{isLeftSide:n,frontHeight:o,backHeight:r,frontWidth:e,backWidth:s}=getCuboidBasicInfo({frontPoints:i,backPoints:t});let l=__spreadValues({},i),a=t;return n||s>e?l=getPointsByBottomLeftPoint({coord:i.bl,points:t}):l=getPointsByBottomRightPoint({coord:i.br,points:t}),o>r&&(l.tl.y=i.tl.y,l.tr.y=i.tr.y,a=getPointsByIntersection({backPoints:t,frontPoints:i}).backPoints),e>=s&&Object.keys(l).forEach(u=>{l[u].x=i[u].x}),{frontPoints:l,backPoints:a}}function getCuboidAllSideLine({frontPoints:i,backPoints:t}){return[{p1:i.bl,p2:t.bl},{p1:i.tl,p2:t.tl},{p1:i.tr,p2:t.tr},{p1:i.br,p2:t.br}]}function getHighlightLines(i){const{frontPoints:t,backPoints:n}=i,{isLeftSide:o}=getCuboidBasicInfo(i),r=[{p1:t.tl,p2:t.tr,positions:[{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.TL},{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.TR}]},{p1:t.tr,p2:t.br,plain:annotation.ECuboidPlain.Front,positions:[{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.TR},{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.BR}]},{p1:t.br,p2:t.bl,plain:annotation.ECuboidPlain.Front,positions:[{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.BR},{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.BL}]},{p1:t.bl,p2:t.tl,plain:annotation.ECuboidPlain.Front,positions:[{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.BL},{plain:annotation.ECuboidPlain.Front,position:annotation.ECuboidPosition.TL}]}];return o?[...r,{p1:n.tl,p2:n.bl,positions:[{plain:annotation.ECuboidPlain.Back,position:annotation.ECuboidPosition.TL},{plain:annotation.ECuboidPlain.Back,position:annotation.ECuboidPosition.BL}]}]:[...r,{p1:n.tr,p2:n.br,positions:[{plain:annotation.ECuboidPlain.Back,position:annotation.ECuboidPosition.TR},{plain:annotation.ECuboidPlain.Back,position:annotation.ECuboidPosition.BR}]}]}function getHighlightPoints(i){const{backPoints:t}=i,{isLeftSide:n}=getCuboidBasicInfo(i),o=Object.entries(i.frontPoints).map(([r,e])=>({positions:[{plain:annotation.ECuboidPlain.Front,position:r}],point:e}));return n?[{point:t.tl,positions:[{position:annotation.ECuboidPosition.TL,plain:annotation.ECuboidPlain.Back}]},{point:t.bl,positions:[{position:annotation.ECuboidPosition.BL,plain:annotation.ECuboidPlain.Back}]},...o]:[{point:t.tr,positions:[{position:annotation.ECuboidPosition.TR,plain:annotation.ECuboidPlain.Back}]},{point:t.br,positions:[{position:annotation.ECuboidPosition.BR,plain:annotation.ECuboidPlain.Back}]},...o]}function getCuboidHoverRange(i){const{frontPoints:t,backPoints:n}=i,{backCenter:o,frontCenter:r,frontHeight:e,frontWidth:s,backHeight:l,backWidth:a,isLeftSide:u}=getCuboidBasicInfo(i),p=Math.abs(s-a),c=Math.abs(e-l),d=Math.abs(r.x-o.x),x=Math.abs(r.y-o.y),f=d>p,b=x>c;return f||b?b&&!f?[t.tl,n.tl,n.tr,t.tr,t.br,t.bl]:f&&!b?u?[t.tl,t.tr,t.br,t.bl,n.bl,n.tl]:[t.tl,t.tr,n.tr,n.br,t.br,t.bl]:f&&b?u?[n.tl,n.tr,t.tr,t.br,t.bl,n.bl]:[t.tl,n.tl,n.tr,n.br,t.br,t.bl]:[]:[t.tl,t.tr,t.br,t.bl]}function getNewPointsAfterOffset({offset:i,frontPoints:t,backPoints:n,positions:o}){let r=_.cloneDeep(t),e=_.cloneDeep(n);if((o==null?void 0:o.length)===2){const s=o.every(b=>b.plain===annotation.ECuboidPlain.Front),l=!s,a=judgeCuboidLineIsRowOrColumn([o[0],o[1]]),u=a===annotation.ECuboidLineDirection.Row,p=a===annotation.ECuboidLineDirection.Column;let c=i;u&&(c={x:0,y:i.y}),p&&(c={y:0,x:i.x}),s&&(o==null||o.forEach(({position:b})=>{const g=r,y=g[b];g[b]={x:y.x+c.x,y:y.y+c.y}}),r=getMaxExternalQuadrilateral(r),e=getMaxExternalQuadrilateral(e)),l&&Object.keys(e).forEach(b=>{e[b]={x:e[b].x+c.x,y:e[b].y+c.y}});const d=s?getBackPointsByFrontPoints:getFrontPointsByBackPoints,{frontPoints:x,backPoints:f}=d({frontPoints:r,backPoints:e});r=x,e=f}return{frontPoints:r,backPoints:e}}function moveCuboidByCuboid({offset:i,cuboid:t}){const{frontPoints:n,backPoints:o}=t,r=Object.entries(n).reduce((s,[l,a])=>__spreadProps(__spreadValues({},s),{[l]:{x:a.x+i.x,y:a.y+i.y}}),{}),e=Object.entries(o).reduce((s,[l,a])=>__spreadProps(__spreadValues({},s),{[l]:{x:a.x+i.x,y:a.y+i.y}}),{});return{frontPoints:r,backPoints:e}}function moveCuboidByLine({offset:i,cuboid:t,positions:n}){const{frontPoints:o,backPoints:r}=t;return getNewPointsAfterOffset({offset:i,frontPoints:o,backPoints:r,positions:n})}function moveCuboidByPoints({offset:i,cuboid:t,positions:n}){if(!(n==null?void 0:n[0]))return;const{frontPoints:o,backPoints:r}=t,e=n[0],s=e.plain===annotation.ECuboidPlain.Front,l=s?o:r;let a=l[e.position];const u=l[annotation.DIAGONAL_POINT[e.position]];if(!a||!u)return;a=VectorUtils.add(a,i);const p=getPlainPointsByDiagonalPoints(a,u),c=s?getBackPointsByFrontPoints:getFrontPointsByBackPoints;let d={frontPoints:o,backPoints:p};return s&&(d={frontPoints:p,backPoints:r}),c(d)}function getCuboidDragMove({offset:i,cuboid:t,dragTarget:n,positions:o}){switch(n){case annotation.EDragTarget.Cuboid:{const r=moveCuboidByCuboid({offset:i,cuboid:t});return __spreadValues(__spreadValues({},t),r)}case annotation.EDragTarget.Line:{const r=moveCuboidByLine({offset:i,cuboid:t,positions:o});return __spreadValues(__spreadValues({},t),r)}case annotation.EDragTarget.Point:{const r=moveCuboidByPoints({cuboid:t,offset:i,positions:o});if(r)return __spreadValues(__spreadValues({},t),r);break}default:{console.error("No DragTarget");break}}}function getPointListsByDirection({direction:i,frontPoints:t,backPoints:n}){if(i&&t&&n){let o=t;switch(i){case annotation.ECuboidDirection.Back:o=n;break;case annotation.ECuboidDirection.Left:o={bl:n.bl,br:t.bl,tl:n.tl,tr:t.tl};break;case annotation.ECuboidDirection.Right:o={bl:n.br,br:t.br,tl:n.tr,tr:t.tr};break;case annotation.ECuboidDirection.Top:o={bl:n.tl,br:t.tl,tl:n.tr,tr:t.tr};break;default:o=t;break}return AxisUtils.default.transformPlain2PointList(o)}}function getToggleDirectionButtonOffset({cuboid:i,currentPos:t,zoom:n}){const{frontPoints:o}=i,r={width:40,height:74},e={x:(o.bl.x+o.tl.x)/2,y:(o.bl.y+o.tl.y)/2},s=r.width+10,l=r.height/2,a={x:e.x,y:e.y},u=AxisUtils.default.getOffsetCoordinate(a,t,n);return{left:u.x-s,top:u.y-l}}function getCuboidTextAttributeOffset({cuboid:i,currentPos:t,zoom:n,leftOffset:o=16,topOffset:r=2}){const{frontPoints:e}=i,s={x:e.bl.x,y:e.bl.y},l=AxisUtils.default.getOffsetCoordinate(s,t,n);return{left:l.x+o,top:l.y+r}}function isCuboidWithInLimits({cuboid:i,config:t}){const{minHeight:n,minWidth:o}=t,{width:r,height:e}=getPlanePointsBasicInfo(i.frontPoints);return r>=o&&e>=n}exports.getBackPointsByFrontPoints=getBackPointsByFrontPoints,exports.getCuboidAllSideLine=getCuboidAllSideLine,exports.getCuboidBasicInfo=getCuboidBasicInfo,exports.getCuboidDragMove=getCuboidDragMove,exports.getCuboidHoverRange=getCuboidHoverRange,exports.getCuboidShowingSideLine=getCuboidShowingSideLine,exports.getCuboidTextAttributeOffset=getCuboidTextAttributeOffset,exports.getFrontPointsByBackPoints=getFrontPointsByBackPoints,exports.getHighlightLines=getHighlightLines,exports.getHighlightPoints=getHighlightPoints,exports.getMaxExternalQuadrilateral=getMaxExternalQuadrilateral,exports.getNewPointsAfterOffset=getNewPointsAfterOffset,exports.getPlainPointsByDiagonalPoints=getPlainPointsByDiagonalPoints,exports.getPlanePointsBasicInfo=getPlanePointsBasicInfo,exports.getPointListsByDirection=getPointListsByDirection,exports.getPointsByBottomLeftPoint=getPointsByBottomLeftPoint,exports.getPointsByBottomRightPoint=getPointsByBottomRightPoint,exports.getPointsByIntersection=getPointsByIntersection,exports.getToggleDirectionButtonOffset=getToggleDirectionButtonOffset,exports.isCuboidWithInLimits=isCuboidWithInLimits,exports.judgeCuboidLineIsRowOrColumn=judgeCuboidLineIsRowOrColumn;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var tool=require("../../constant/tool.js"),PolygonUtils=require("./PolygonUtils.js"),UnitUtils=require("./UnitUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(
|
|
2
|
-
`,""))!=null?
|
|
3
|
-
`);for(let
|
|
1
|
+
"use strict";var tool=require("../../constant/tool.js"),PolygonUtils=require("./PolygonUtils.js"),UnitUtils=require("./UnitUtils.js"),AxisUtils=require("./AxisUtils.js"),CuboidUtils=require("./CuboidUtils.js"),AttributeUtils=require("./AttributeUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(r,t,i)=>t in r?__defProp(r,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[t]=i,__spreadValues=(r,t)=>{for(var i in t||(t={}))__hasOwnProp.call(t,i)&&__defNormalProp(r,i,t[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(t))__propIsEnum.call(t,i)&&__defNormalProp(r,i,t[i]);return r},__spreadProps=(r,t)=>__defProps(r,__getOwnPropDescs(t));const DEFAULT_ZOOM=1,DEFAULT_CURRENT_POS={x:0,y:0},DEFAULT_ROTATE=0,DEFAULT_COLOR="",_DrawUtils=class{static drawLine(r,t,i,e={}){const o=r.getContext("2d"),{color:l=DEFAULT_COLOR,thickness:s=1,lineCap:a="round",lineDash:d}=e;o.save(),o.strokeStyle=l,o.lineWidth=s,o.lineCap=a,d&&o.setLineDash(d),o.beginPath(),o.moveTo(t.x,t.y),o.lineTo(i.x+1,i.y+1),o.stroke(),o.restore()}static drawRect(r,t,i={}){const e=r.getContext("2d"),{color:o=DEFAULT_COLOR,thickness:l=1,lineCap:s="round",hiddenText:a=!1,lineDash:d}=i;if(e.save(),e.strokeStyle=o,e.lineWidth=l,e.lineCap=s,Array.isArray(d)&&e.setLineDash(d),e.fillStyle=o,e.strokeRect(t.x,t.y,t.width,t.height),a===!1){let n="";if(t.attribute&&(n=`${n} ${t.attribute}`),this.drawText(r,{x:t.x,y:t.y-5},n),t.textAttribute){const c=`${~~t.width} * ${~~t.height}`.length*7,u=0,y=Math.max(20,t.width-c);this.drawText(r,{x:t.x,y:t.y+t.height+20+u},t.textAttribute,{textMaxWidth:y})}}e.restore()}static drawRectWithFill(r,t,i={}){const e=r.getContext("2d"),{color:o=DEFAULT_COLOR}=i;e.save(),e.fillStyle=o,e.fillRect(t.x,t.y,t.width,t.height),e.restore()}static drawTagByDom(r,t,i){const e=r;if(!((t==null?void 0:t.length)>0))return;const o=document.createElement("div");return o.innerHTML=t,o.setAttribute("id",i),e==null||e.appendChild(o),o}static drawTag(r,t){var i;const e=r==null?void 0:r.parentNode,o=window.self.document.getElementById("tagToolTag");if(o&&e&&e.contains(o)&&(e==null||e.removeChild(o)),!((t==null?void 0:t.length)>0))return;const l=document.createElement("div");return l.innerHTML=(i=t.reduce((s,a)=>`${s}${a.keyName}: ${a.value.join(" \u3001 ")}
|
|
2
|
+
`,""))!=null?i:"",l.setAttribute("id","tagToolTag"),e==null||e.appendChild(l),l}static drawLineWithPointList(r,t,i={}){if(t.length<2)return;const e=r.getContext("2d"),{color:o=DEFAULT_COLOR,thickness:l=1,lineCap:s="round",lineType:a=tool.ELineTypes.Line,lineDash:d,hoverEdgeIndex:n}=i;e.save(),(()=>{e.strokeStyle=o,e.lineWidth=l,e.lineCap=s,Array.isArray(d)?e.setLineDash(d):e.setLineDash([])})(),a===tool.ELineTypes.Curve?(n!==void 0&&n>-1&&t.push(t[0]),t=PolygonUtils.createSmoothCurvePointsFromPointList([...t],tool.SEGMENT_NUMBER),n!==void 0&&n>-1&&(t=t.slice((tool.SEGMENT_NUMBER+1)*n,(tool.SEGMENT_NUMBER+1)*(n+1)))):n!==void 0&&n>-1&&(t=[...t,t[0]],t=t.slice(n,n+2));const c=[];e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let h=0;h<t.length-1;h++)t[h].specialEdge&&c.push({i1:h,i2:h+1}),e.lineTo(t[h+1].x,t[h+1].y);e.stroke(),e.save(),e.lineWidth=l*.8,e.lineCap="butt",e.strokeStyle="white",e.setLineDash([3,3]),c.forEach(h=>{const w=t[h.i1],x=t[h.i2];e.beginPath(),e.moveTo(w.x,w.y),e.lineTo(x.x,x.y),e.stroke()}),e.restore();const u=4,y=2;return t.forEach(h=>{h.specialPoint&&(this.drawSpecialPoint(r,h,u+y,o),this.drawSpecialPoint(r,h,u,"white"))}),e.restore(),t}static drawCircle(r,t,i,e={}){const o=r.getContext("2d"),{startAngleDeg:l=0,endAngleDeg:s=360,thickness:a=1,color:d=DEFAULT_COLOR,fill:n=DEFAULT_COLOR}=e,f=UnitUtils.deg2rad(l),c=UnitUtils.deg2rad(s);o.save(),o.beginPath(),o.strokeStyle=d,o.fillStyle=n,o.lineWidth=a,o.arc(t.x,t.y,i,f,c,!1),o.stroke(),n&&o.fill(),o.closePath(),o.restore()}static drawCircleWithFill(r,t,i=3,e={}){const o=r.getContext("2d"),{color:l=DEFAULT_COLOR}=e;o.save();const s=UnitUtils.deg2rad(0),a=UnitUtils.deg2rad(360);o.fillStyle=l,o.beginPath(),o.arc(t.x,t.y,i,s,a,!1),o.fill(),o.restore()}static drawSpecialPoint(r,t,i=6,e){const o=r.getContext("2d"),{x:l,y:s}=t;o.save(),o.beginPath(),o.fillStyle=e;const a=i*1.5,d=a*Math.sqrt(3)/2,n=a/2;o.moveTo(l,s-a),o.lineTo(l-d,s+n),o.lineTo(l+d,s+n),o.closePath(),o.fill(),o.restore()}static drawPolygon(r,t,i={}){const{isClose:e=!1,lineType:o=tool.ELineTypes.Line}=i;return e===!0&&(t=[...t,t[0]]),o===tool.ELineTypes.Curve&&(t=PolygonUtils.createSmoothCurvePointsFromPointList([...t])),this.drawLineWithPointList(r,t,__spreadProps(__spreadValues({},i),{lineType:tool.ELineTypes.Line})),t}static drawPolygonWithFill(r,t,i={}){if(t.length<2)return;const e=r.getContext("2d"),{color:o=DEFAULT_COLOR,lineType:l=tool.ELineTypes.Line}=i;e.save(),e.fillStyle=o,e.beginPath(),l===tool.ELineTypes.Curve&&(t=PolygonUtils.createSmoothCurvePointsFromPointList([...t,t[0]]));const[s,...a]=t;return e.moveTo(s.x,s.y),a.forEach(d=>{e.lineTo(d.x,d.y)}),e.fill(),e.restore(),t}static drawPolygonWithFillAndLine(r,t,i={}){const{strokeColor:e,fillColor:o,thickness:l,lineCap:s,isClose:a,lineType:d}=i,n=this.drawPolygon(r,t,{color:e,thickness:l,lineCap:s,isClose:a,lineType:d});return this.drawPolygonWithFill(r,t,{color:o,lineType:d}),n}static drawPolygonWithKeyPoint(r,t,i={}){const{pointColor:e="white",strokeColor:o}=i,l=this.drawPolygon(r,t,i);return l.forEach(s=>{this.drawCircleWithFill(r,s,4,{color:o}),this.drawCircleWithFill(r,s,3,{color:e})}),l}static drawSelectedPolygonWithFillAndLine(r,t,i={}){const{pointColor:e="white",strokeColor:o}=i,l=this.drawPolygonWithFillAndLine(r,t,i);return l.forEach(s=>{this.drawCircleWithFill(r,s,4,{color:o}),this.drawCircleWithFill(r,s,3,{color:e})}),l}static drawText(r,t,i,e={}){if(!i)return;const o=r.getContext("2d"),{color:l=DEFAULT_COLOR,font:s=tool.DEFAULT_FONT,shadowColor:a="",shadowBlur:d=0,shadowOffsetX:n=0,shadowOffsetY:f=0,textMaxWidth:c=164,offsetX:u=0,offsetY:y=0,textAlign:h="start",lineHeight:w}=e;o.save(),o.textAlign=h,o.fillStyle=l!=null?l:"white",o.font=s,o.shadowColor=a,o.shadowOffsetX=n,o.shadowOffsetY=f,o.shadowBlur=d,this.wrapText(r,`${i}`,t.x+u,t.y+y,c,w),o.restore()}static wrapText(r,t,i,e,o,l){if(typeof t!="string"||typeof i!="number"||typeof e!="number")return;const s=r.getContext("2d");typeof o=="undefined"&&(o=r&&r.width||300),typeof l=="undefined"&&(l=r&&parseInt(window.getComputedStyle(r).lineHeight,10)||parseInt(window.getComputedStyle(document.body).lineHeight,10));const a=t.split(`
|
|
3
|
+
`);for(let d=0;d<a.length;d++){const n=a[d].split("");let f="";for(let c=0;c<n.length;c++){const u=f+n[c],h=s.measureText(u).width;o||(o=300),h>o&&c>0?(s.fillText(f,i,e),f=n[c],e+=l):f=u}s.fillText(f,i,e),e+=l}}static drawArrow(r,t,i,e={}){const{color:o=DEFAULT_COLOR,thickness:l=1,lineCap:s="round",theta:a=30,headLen:d=10}=e,n=Math.atan2(t.y-i.y,t.x-i.x)*180/Math.PI,f=(n+a)*Math.PI/180,c=(n-a)*Math.PI/180,u=d*Math.cos(f),y=d*Math.sin(f),h=d*Math.cos(c),w=d*Math.sin(c);r.save(),r.strokeStyle=o,r.lineWidth=l,r.lineCap=s,r.beginPath(),r.moveTo(i.x+u,i.y+y),r.lineTo(i.x,i.y),r.lineTo(i.x+h,i.y+w),r.stroke(),r.restore()}static drawArrowByCanvas(r,t,i,e={}){const o=r.getContext("2d");this.drawArrow(o,t,i,e)}static drawCuboid(r,t,i={}){const{backPoints:e,direction:o,frontPoints:l}=t,{strokeColor:s,thickness:a,fillColor:d}=i,n={color:s,thickness:a};if(e){const c=AxisUtils.default.transformPlain2PointList(e);_DrawUtils.drawPolygon(r,c,__spreadProps(__spreadValues({},n),{isClose:!0}));const u=CuboidUtils.getCuboidAllSideLine(t);u==null||u.forEach(y=>{_DrawUtils.drawLine(r,y.p1,y.p2,__spreadValues({},n))})}const f=AxisUtils.default.transformPlain2PointList(l);if(o&&e&&l){const c=CuboidUtils.getPointListsByDirection({direction:o,frontPoints:l,backPoints:e});c&&_DrawUtils.drawPolygonWithFill(r,c,{color:d})}_DrawUtils.drawPolygon(r,f,__spreadProps(__spreadValues({},n),{isClose:!0}))}static drawCuboidWithText(r,t,i,e){const{strokeColor:o}=i,l=o,{config:s,hiddenText:a,currentPos:d,zoom:n,selectedID:f,headerText:c,bottomText:u}=e,{backPoints:y,frontPoints:h,textAttribute:w}=t,x=h.br.x-h.bl.x;_DrawUtils.drawCuboid(r,t,i);let g="";(s==null?void 0:s.isShowOrder)&&t.order&&(t==null?void 0:t.order)>0&&(g=`${t.order}`),t.attribute&&(g=`${g} ${AttributeUtils.default.getAttributeShowText(t.attribute,s==null?void 0:s.attributeList)}`),!a&&y&&g&&_DrawUtils.drawText(r,{x:y.tl.x,y:y.tl.y-5},c!=null?c:g,{color:o,textMaxWidth:300});const T=CuboidUtils.getCuboidTextAttributeOffset({cuboid:t,currentPos:d,zoom:n,topOffset:16,leftOffset:0});if(!a&&w&&t.id!==f){const C=Math.max(20,x*.8);_DrawUtils.drawText(r,{x:T.left,y:T.top},u!=null?u:w,{color:l,textMaxWidth:C})}}};let DrawUtils=_DrawUtils;DrawUtils.drawImg=(r,t,i={})=>{const e=r.getContext("2d"),{zoom:o=DEFAULT_ZOOM,currentPos:l=DEFAULT_CURRENT_POS,rotate:s=DEFAULT_ROTATE,imgAttribute:a}=i;switch(e.save(),s){case 0:e.translate(l.x,l.y);break;case 90:e.translate(l.x+t.height*o,l.y),e.rotate(90*Math.PI/180);break;case 180:e.translate(l.x+t.width*o,l.y+t.height*o),e.rotate(Math.PI);break;case 270:e.translate(l.x,l.y+t.width*o),e.rotate(270*Math.PI/180);break;default:e.translate(l.x,l.y);break}if(a){const{contrast:d,saturation:n,brightness:f}=a;e.filter=`saturate(${n+100}%) contrast(${d+100}%) brightness(${f+100}%)`}e.drawImage(t,0,0,t.width*o,t.height*o),e.restore()},module.exports=DrawUtils;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tool=require("../../constant/tool.js"),ScribbleTool=require("../../core/toolOperation/ScribbleTool.js"),checkOperation=require("../../core/toolOperation/checkOperation.js"),polygonOperation=require("../../core/toolOperation/polygonOperation.js"),rectOperation=require("../../core/toolOperation/rectOperation.js"),tagOperation=require("../../core/toolOperation/tagOperation.js"),LineToolOperation=require("../../core/toolOperation/LineToolOperation.js"),pointOperation=require("../../core/toolOperation/pointOperation.js"),TextToolOperation=require("../../core/toolOperation/TextToolOperation.js"),segmentByRect=require("../../core/toolOperation/segmentByRect.js"),CommonToolUtils=require("./CommonToolUtils.js");const getCurrentOperation=e=>{switch(e){case tool.EToolName.Rect:case tool.EToolName.RectTrack:return rectOperation.RectOperation;case tool.EToolName.SegmentByRect:return segmentByRect;case tool.EToolName.Tag:return tagOperation;case tool.EToolName.Polygon:return polygonOperation;case tool.ECheckModel.Check:return checkOperation;case tool.EToolName.Line:return LineToolOperation.default;case tool.EToolName.Point:return pointOperation;case tool.EToolName.Text:return TextToolOperation;case tool.EToolName.ScribbleTool:return ScribbleTool;default:throw new Error("not match tool")}};class EnhanceCommonToolUtils extends CommonToolUtils{}EnhanceCommonToolUtils.getCurrentOperation=getCurrentOperation,exports.default=EnhanceCommonToolUtils,exports.getCurrentOperation=getCurrentOperation;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tool=require("../../constant/tool.js"),ScribbleTool=require("../../core/toolOperation/ScribbleTool.js"),cuboidOperation=require("../../core/toolOperation/cuboidOperation.js"),pointCloud2dOperation=require("../../core/toolOperation/pointCloud2dOperation.js"),checkOperation=require("../../core/toolOperation/checkOperation.js"),polygonOperation=require("../../core/toolOperation/polygonOperation.js"),rectOperation=require("../../core/toolOperation/rectOperation.js"),tagOperation=require("../../core/toolOperation/tagOperation.js"),LineToolOperation=require("../../core/toolOperation/LineToolOperation.js"),pointOperation=require("../../core/toolOperation/pointOperation.js"),TextToolOperation=require("../../core/toolOperation/TextToolOperation.js"),segmentByRect=require("../../core/toolOperation/segmentByRect.js"),CommonToolUtils=require("./CommonToolUtils.js");const getCurrentOperation=e=>{switch(e){case tool.EToolName.Rect:case tool.EToolName.RectTrack:return rectOperation.RectOperation;case tool.EToolName.SegmentByRect:return segmentByRect;case tool.EToolName.Tag:return tagOperation;case tool.EToolName.Polygon:return polygonOperation;case tool.ECheckModel.Check:return checkOperation;case tool.EToolName.Line:return LineToolOperation.default;case tool.EToolName.Point:return pointOperation;case tool.EToolName.Text:return TextToolOperation;case tool.EToolName.ScribbleTool:return ScribbleTool;case tool.EToolName.Cuboid:return cuboidOperation;case tool.EToolName.PointCloudPolygon:return pointCloud2dOperation;default:throw new Error("not match tool")}};class EnhanceCommonToolUtils extends CommonToolUtils{}EnhanceCommonToolUtils.getCurrentOperation=getCurrentOperation,exports.default=EnhanceCommonToolUtils,exports.getCurrentOperation=getCurrentOperation;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var C=`<svg width="27" height="27" viewBox="0 0 27 27" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path
|
|
3
|
+
d="M13.5525 3.01367C7.75439 3.01367 3.03467 7.73076 3.03467 13.5289C3.0373 19.3297 7.75439 24.0468 13.5525 24.0468C19.3507 24.0468 24.0678 19.3297 24.0678 13.5315C24.0678 7.7334 19.3507 3.01367 13.5525 3.01367ZM19.3085 15.9072V15.9521C19.3085 15.9652 19.3059 15.9784 19.3059 15.9942C19.3059 16.0021 19.3059 16.0101 19.3032 16.018C19.3032 16.0312 19.3006 16.0443 19.2979 16.0575C19.2979 16.0654 19.2953 16.076 19.2953 16.0839C19.2927 16.0944 19.2927 16.105 19.29 16.1155C19.2874 16.1261 19.2848 16.1393 19.2848 16.1498C19.2821 16.1577 19.2821 16.1656 19.2795 16.1709C19.2769 16.1867 19.2716 16.2025 19.2689 16.2184C19.2689 16.221 19.2663 16.2236 19.2663 16.2263C19.2083 16.4504 19.0923 16.664 18.9156 16.8406L15.8386 19.9177C15.3112 20.445 14.449 20.445 13.9243 19.9177C13.397 19.3903 13.397 18.5281 13.9243 18.0034L14.6863 17.2414H9.14922C8.40303 17.2414 7.79394 16.6323 7.79394 15.8861C7.79394 15.1399 8.40303 14.5309 9.14922 14.5309H17.9559C18.3039 14.5309 18.652 14.6627 18.9156 14.9264C19.1793 15.19 19.3111 15.5381 19.3111 15.8861C19.3111 15.894 19.3085 15.902 19.3085 15.9072ZM19.3111 11.1743C19.3111 11.9205 18.7021 12.5296 17.9559 12.5296H9.14922C8.80117 12.5296 8.45312 12.3978 8.18945 12.1341C7.92578 11.8704 7.79394 11.5224 7.79394 11.1743V11.1532V11.111C7.79394 11.0979 7.79658 11.082 7.79658 11.0688C7.79658 11.0609 7.79658 11.053 7.79922 11.0451C7.79922 11.0319 7.80186 11.0187 7.80449 11.0056C7.80449 10.9977 7.80713 10.9871 7.80713 10.9792C7.80977 10.9687 7.80976 10.9581 7.8124 10.9476C7.81504 10.937 7.81768 10.9238 7.81768 10.9133C7.82031 10.9054 7.82031 10.8975 7.82295 10.8922C7.82559 10.8764 7.83086 10.8605 7.8335 10.8447C7.8335 10.8421 7.83613 10.8395 7.83613 10.8368C7.89414 10.6127 8.01016 10.3991 8.18682 10.2225L11.2612 7.14805C11.7886 6.6207 12.6508 6.6207 13.1755 7.14805C13.7028 7.67539 13.7028 8.5376 13.1755 9.0623L12.4187 9.82168H17.9559C18.6994 9.82168 19.3111 10.4308 19.3111 11.1743Z"
|
|
4
|
+
fill="#2C7EFF" />
|
|
5
|
+
</svg>`;export{C as default};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var L=`<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path
|
|
3
|
+
d="M16.425 5.04961C16.35 4.82461 16.2 4.67461 15.975 4.59961L9.525 1.14961C9.225 0.999609 8.85 0.999609 8.55 1.14961L2.025 4.59961C1.725 4.74961 1.5 5.12461 1.5 5.49961V12.2496C1.5 12.6246 1.725 12.9996 2.025 13.1496L8.475 16.5996C8.7 16.6746 8.925 16.7496 9.15 16.6746C9.225 16.6746 9.375 16.5996 9.45 16.5996L15.9 13.1496C16.275 12.9996 16.5 12.6246 16.5 12.2496V5.49961C16.5 5.34961 16.425 5.19961 16.425 5.04961ZM9.15 8.87461V15.2496L9 15.3996L2.85 12.0996V5.64961L9 2.34961L15.15 5.64961L9.15 8.87461Z"
|
|
4
|
+
fill="#2C7EFF" />
|
|
5
|
+
<path d="M9 8.5V2.5L8.5 2L2.5 5.5V12.5L9 8.5Z" fill="#2C7EFF" />
|
|
6
|
+
<path d="M15.5 6L15 5.5L14.5 6L9 8.5V15.5H9.5L15.5 12.5V6Z" fill="white" />
|
|
7
|
+
</svg>`;export{L as default};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var c=`<svg width="16" height="4" viewBox="0 0 16 4" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<circle cx="2" cy="2" r="2" fill="#2C7EFF" />
|
|
3
|
+
<circle cx="8" cy="2" r="2" fill="#2C7EFF" />
|
|
4
|
+
<circle cx="14" cy="2" r="2" fill="#2C7EFF" />
|
|
5
|
+
</svg>`;export{c as default};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var C=`<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path
|
|
3
|
+
d="M16.425 5.04961C16.35 4.82461 16.2 4.67461 15.975 4.59961L9.525 1.14961C9.225 0.999609 8.85 0.999609 8.55 1.14961L2.025 4.59961C1.725 4.74961 1.5 5.12461 1.5 5.49961V12.2496C1.5 12.6246 1.725 12.9996 2.025 13.1496L8.475 16.5996C8.7 16.6746 8.925 16.7496 9.15 16.6746C9.225 16.6746 9.375 16.5996 9.45 16.5996L15.9 13.1496C16.275 12.9996 16.5 12.6246 16.5 12.2496V5.49961C16.5 5.34961 16.425 5.19961 16.425 5.04961ZM9.15 8.87461V15.2496L9 15.3996L2.85 12.0996V5.64961L9 2.34961L15.15 5.64961L9.15 8.87461Z"
|
|
4
|
+
fill="#2C7EFF" />
|
|
5
|
+
</svg>`;export{C as default};
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var t=`<svg width="25" height="25" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g clip-path="url(#clip0_2295_37199)">
|
|
3
|
+
<path
|
|
4
|
+
d="M5.16087 7.8398C5.00351 8.01726 4.94861 8.22216 4.99615 8.45452L5.23337 15.7654C5.25346 16.1002 5.44096 16.4249 5.72087 16.6098L11.9712 20.5356C12.2511 20.7204 12.6883 20.7277 13.0131 20.5402L18.8587 17.1652C19.1835 16.9777 19.3958 16.5954 19.3757 16.2606L19.1385 8.94971C19.0909 8.71735 19.0434 8.485 18.8659 8.32764C18.8284 8.26269 18.6885 8.17029 18.651 8.10533L12.4382 4.24447C12.1208 3.99471 11.6835 3.98735 11.3587 4.17485L5.51308 7.54985C5.38317 7.62485 5.29077 7.7648 5.16087 7.8398ZM12.1109 12.2276L17.6318 9.04014L17.8367 9.09505L18.0538 16.0711L12.468 19.2961L6.5351 15.62L6.31798 8.64399L12.1109 12.2276Z"
|
|
5
|
+
fill="#2C7EFF" />
|
|
6
|
+
</g>
|
|
7
|
+
<defs>
|
|
8
|
+
<clipPath id="clip0_2295_37199">
|
|
9
|
+
<rect width="18" height="18" fill="white" transform="translate(9 24.5898) rotate(-120)" />
|
|
10
|
+
</clipPath>
|
|
11
|
+
</defs>
|
|
12
|
+
</svg>`;export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const B=61,R=40,i=40,t=240;var o;(function(n){n[n.ANNOTATION=1]="ANNOTATION",n[n.QUALITY_INSPECTION=2]="QUALITY_INSPECTION",n[n.PRE_ANNOTATION=3]="PRE_ANNOTATION",n[n.MANUAL_CORRECTION=4]="MANUAL_CORRECTION"})(o||(o={}));const v=1e3;var N;(function(n){n[n.Backward=0]="Backward",n[n.Forward=1]="Forward",n[n.JumpSkip=2]="JumpSkip",n[n.None=3]="None"})(N||(N={}));var T;(function(n){n[n.Start=0]="Start",n[n.Stop=1]="Stop",n[n.Wait=2]="Wait",n[n.Move=3]="Move"})(T||(T={}));var f;(function(n){n[n.Point=0]="Point",n[n.Line=1]="Line",n[n.Plane=2]="Plane",n[n.Cuboid=3]="Cuboid"})(f||(f={}));var A;(function(n){n[n.ascend=0]="ascend",n[n.descend=1]="descend"})(A||(A={}));var L;(function(n){n[n.Intelligence=0]="Intelligence",n[n.Linear=1]="Linear"})(L||(L={}));var s;(function(n){n.Zh="zh_CN",n.US="en_US"})(s||(s={}));var I;(function(n){n[n.Clockwise=0]="Clockwise",n[n.Anticlockwise=1]="Anticlockwise"})(I||(I={}));const d={offsetX:-10,offsetY:-10},k={shadowColor:"rgba(0, 0, 0, 1)",shadowOffsetX:1,shadowOffsetY:1,shadowBlur:0},w={x:8,y:26};var O;(function(n){n.Front="front",n.Back="back",n.Side="side"})(O||(O={}));var c;(function(n){n.TL="tl",n.TR="tr",n.BL="bl",n.BR="br"})(c||(c={}));var l;(function(n){n.Front="front",n.Back="back",n.Left="left",n.Right="right",n.Top="top"})(l||(l={}));const U={tl:"br",tr:"bl",br:"tl",bl:"tr"};var _;(function(n){n.Row="row",n.Column="column"})(_||(_={}));const h={[c.TL]:c.TR,[c.TR]:c.TL,[c.BL]:c.BR,[c.BR]:c.BL},C={[c.TL]:c.BL,[c.TR]:c.BR,[c.BL]:c.TL,[c.BR]:c.TR};export{v as ANNOTATION_MAX_SIZE,C as CUBOID_COLUMN,h as CUBOID_ROW,d as DEFAULT_TEXT_OFFSET,k as DEFAULT_TEXT_SHADOW,U as DIAGONAL_POINT,l as ECuboidDirection,_ as ECuboidLineDirection,O as ECuboidPlain,c as ECuboidPosition,T as EDragStatus,f as EDragTarget,L as EGrowthMode,s as ELang,N as EPageOperator,I as ERotateDirection,A as ESortDirection,o as EStepType,w as TEXT_ATTRIBUTE_OFFSET,i as footerHeight,B as headerHeight,t as sidebarWidth,R as tipsHeight};
|
package/es/constant/tool.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const A=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
|
|
1
|
+
const A=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[o.Rect=0]="Rect",o[o.Tag=1]="Tag"})(l||(l={}));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"})(u||(u={}));var e;(function(o){o.Check="check"})(e||(e={}));var c;(function(o){o[o.nothing=0]="nothing",o[o.RectBG=1]="RectBG",o[o.showOrder=2]="showOrder"})(c||(c={}));const M={[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.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"};var t;(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"})(t||(t={}));var r;(function(o){o.lc="leftClick",o.rc="rightClick",o.clc="ctrlLeftClick",o.crc="ctrlRightClick"})(r||(r={}));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 C;(function(o){o[o.Normal=1]="Normal",o[o.Modify=2]="Modify"})(C||(C={}));var d;(function(o){o[o.Line=0]="Line",o[o.Curve=1]="Curve"})(d||(d={}));var F;(function(o){o[o.SingleColor=0]="SingleColor",o[o.MultiColor=1]="MultiColor"})(F||(F={}));var T;(function(o){o[o.Form=1]="Form",o[o.Json=2]="Json"})(T||(T={}));var g;(function(o){o[o.Point=0]="Point",o[o.Line=1]="Line",o[o.Plane=2]="Plane"})(g||(g={}));var R;(function(o){o[o.None=0]="None",o[o.Drawing=1]="Drawing",o[o.Edit=2]="Edit"})(R||(R={}));var B;(function(o){o[o.Backward=0]="Backward",o[o.Forward=1]="Forward",o[o.JumpSkip=2]="JumpSkip",o[o.None=3]="None"})(B||(B={}));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 O={0:"\u4EFB\u610F\u5B57\u7B26",1:"\u5E8F\u53F7",2:"\u4EC5\u82F1\u6587",3:"\u4EC5\u6570\u5B57"},S=1e3,h=16,I=300,m="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 V={[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"},G=16,P=10;var f;(function(o){o[o.Normal=0]="Normal",o[o.Rect=1]="Rect"})(f||(f={}));var L;(function(o){o[o.Scribble=1]="Scribble",o[o.Erase=2]="Erase"})(L||(L={}));var v;(function(o){o[o.General=1]="General",o[o.MultiMove=2]="MultiMove"})(v||(v={}));export{V as CLIENT_TOOL_HEAD_TYPE,y as CLIENT_TOOL_NAME,m as DEFAULT_FONT,I as DEFAULT_TEXT_MAX_WIDTH,C as EAnnotationMode,s as EAuditStatus,e as ECheckModel,t as EDependPattern,g as EDragTarget,R as EDrawPointPattern,r as EFilterToolOperation,F as ELineColor,d as ELineTypes,v as EOperationMode,B as EPageOperator,n as EPointCloudName,f as EPolygonPattern,c as ERectPattern,L as EScribblePattern,T as ESelectedType,k as ETextType,a as EThumbnailOption,u as EToolName,l as EToolType,i as EVideoToolName,b as OPERATION_LIST,G as SEGMENT_NUMBER,h as TEXT_ATTRIBUTE_LINE_HEIGHT,S as TEXT_ATTRIBUTE_MAX_LENGTH,O as TEXT_TYPE,M as TOOL_NAME,_ as TOOL_NAME_EN,P as edgeAdsorptionScope,A as editStepWidth};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PointCloudUtils as
|
|
1
|
+
import{PointCloudUtils as p}from"@labelbee/lb-utils";import{EToolName as f,EPolygonPattern as T}from"../../constant/tool.js";import{CanvasScheduler as R}from"../../newCore/CanvasScheduler.js";import{PointCloud as j}from"./index.js";import{ToolScheduler as B,HybridToolUtils as E}from"../scheduler.js";var A=Object.defineProperty,x=Object.defineProperties,F=Object.getOwnPropertyDescriptors,w=Object.getOwnPropertySymbols,N=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable,S=(n,t,o)=>t in n?A(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,P=(n,t)=>{for(var o in t||(t={}))N.call(t,o)&&S(n,o,t[o]);if(w)for(var o of w(t))V.call(t,o)&&S(n,o,t[o]);return n},O=(n,t)=>x(n,F(t));const _=n=>{const t=document.createElement("canvas");t.width=n.width,t.height=n.height;const o=t.getContext("2d");return o?(o.fillStyle="black",o.fillRect(0,0,n.width,n.height),t.toDataURL()):""};class U{constructor({size:t,container:o,pcdPath:i,extraProps:I,config:v,checkMode:L,toolName:d}){this.updatePolygonList=(a,l)=>{let r=a.map(e=>{var s;const{polygon2d:m}=this.pointCloudInstance.getBoxTopPolygon2DCoordinate(e);return{id:e.id,sourceID:"",pointList:m,isRect:!0,valid:(s=e.valid)!=null?s:!0,attribute:e.attribute}});l&&(r=r.concat(l.map(e=>{var s;return O(P({},e),{pointList:(s=e==null?void 0:e.pointList)==null?void 0:s.map(m=>p.transferWorld2Canvas(m,this.pointCloud2dOperation.size))})}))),this.toolScheduler.updateDataByToolName(f.PointCloudPolygon,r)},this.updatePointList=a=>{const l=a==null?void 0:a.map(r=>{var e;const{point2d:s}=this.pointCloudInstance.getSphereTopPoint2DCoordinate(r);return O(P({},s),{id:r.id,sourceID:"",valid:(e=r.valid)!=null?e:!0,attribute:r.attribute,textAttribute:""})});this.toolScheduler.updateDataByToolName(f.Point,l)};const b=this.getDefaultOrthographic(t),D=_(t),c=new Image;c.src=D;const h=new B({container:o,size:t,toolName:d}),y=new R({container:o}),g=new j({container:o,noAppend:!0,isOrthographicCamera:!0,orthographicParams:b});i&&g.loadPCDFile(i),y.createCanvas(g.renderer.domElement);const C={size:t,config:JSON.stringify(O(P({},v),{attributeConfigurable:!0,hideAttribute:!0})),imgNode:c,checkMode:L};I&&Object.assign(C,I);let u=[];E.isSingleTool(d)?u=[d]:u=d,u.forEach((a,l)=>{let r;if(a===f.PointCloudPolygon){const e=h.createOperation(a,c,C);e.eventBinding(),e.setPattern(T.Rect),this.toolInstance=e,this.toolInstance.eventBinding(),this.pointCloud2dOperation=e}else r=h.createOperation(a,c,C);l===u.length-1&&(this.toolInstance||(this.toolInstance=r,this.toolInstance.eventBinding()))}),this.pointCloudInstance=g,this.canvasScheduler=y,this.toolScheduler=h,this.config=v}updateConfig(t){this.config=t,this.pointCloud2dOperation.setConfig(JSON.stringify(t))}getDefaultOrthographic(t){return{left:-t.width/2,right:t.width/2,top:t.height/2,bottom:-t.height/2,near:100,far:-100}}initSize(t){this.pointCloudInstance.updateTopCamera(),this.pointCloudInstance.setDefaultControls(),this.pointCloudInstance.initRenderer(),this.pointCloudInstance.initOrthographicCamera(this.getDefaultOrthographic(t)),this.pointCloudInstance.render();const o=_(t),i=new Image;i.src=o,i.onload=()=>{this.toolInstance.setImgNode(i),this.toolInstance.initImgPos()},this.pointCloud2dOperation.setCanvasSize(t)}addPolygonListOnTopView(t){const o=p.getBoxParamsFromResultList(t),i=p.getPolygonListFromResultList(t);this.updatePolygonList(o,i)}addPointListOnTopView(t){const o=p.getSphereParamsFromResultList(t);this.updatePointList(o)}updateData(t,o,i){!this.toolInstance||!this.pointCloudInstance||(this.pointCloudInstance.loadPCDFile(t,i==null?void 0:i.radius),this.addPolygonListOnTopView(o),this.addPointListOnTopView(o))}switchToCanvas(t){const o=this.toolScheduler.switchToCanvas(t);return o?(o.eventBinding(),this.toolInstance=o,o):this.toolInstance}initAllPosition(){this.pointCloudInstance.updateTopCamera(),this.pointCloud2dOperation.initPosition()}clearAllData(){this.pointCloudInstance.clearPointCloudAndRender(),this.pointCloud2dOperation.clearResult()}}export{U as PointCloudAnnotation};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as c from"three";import{toolStyleConverter as
|
|
1
|
+
import*as c from"three";import{toolStyleConverter as B,PerspectiveShiftUtils as b,EPerspectiveView as w,PointCloudUtils as k,DEFAULT_SPHERE_PARAMS as z}from"@labelbee/lb-utils";import D from"../../_virtual/highlightWorker.js";import L from"../../_virtual/filterBoxWorker.js";import{isInPolygon as N}from"../../utils/tool/polygonTool.js";import T from"../../utils/uuid.js";import F from"../../utils/MathUtils.js";import{PCDLoader as E}from"./PCDLoader.js";import{OrbitControls as R}from"./OrbitControls.js";import{PointCloudCache as W}from"./cache.js";import{getCuboidFromPointCloudBox as A}from"./matrix.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,lidar2image,pointCloudLidar2image,rotatePoint,transferKitti2Matrix}from"./matrix.js";import"../../constant/tool.js";import"../scheduler.js";var Z=Object.defineProperty,H=Object.defineProperties,U=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,_=(f,t,e)=>t in f?Z(f,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):f[t]=e,M=(f,t)=>{for(var e in t||(t={}))G.call(t,e)&&_(f,e,t[e]);if(O)for(var e of O(t))$.call(t,e)&&_(f,e,t[e]);return f},P=(f,t)=>H(f,U(t)),S=(f,t,e)=>new Promise((r,n)=>{var s=o=>{try{i(e.next(o))}catch(h){n(h)}},a=o=>{try{i(e.throw(o))}catch(h){n(h)}},i=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);i((e=e.apply(f,t)).next())});const X=30,j=new D({type:"module"});class Y{constructor({container:t,noAppend:e,isOrthographicCamera:r,orthographicParams:n,backgroundColor:s="#4C4C4C",config:a}){this.zAxisLimit=10,this.initCameraPosition=this.DEFAULT_INIT_CAMERA_POSITION,this.isOrthographicCamera=!1,this.pointsUuid="",this.pointCloudObjectName="pointCloud",this.rangeObjectName="range",this.showDirection=!0,this.addSphereToSense=(i,o="blue")=>{var h;const l=(h=i.id)!=null?h:T();this.removeObjectByName(l);const{radius:d,widthSegments:p,heightSegments:g}=z,{center:x}=i,u=new c.Group,m=new c.SphereGeometry(d,p,g),C=new c.MeshBasicMaterial({color:o}),y=new c.Mesh(m,C);y.position.set(x.x,x.y,x.z),u.add(y),u.name=l,this.scene.add(u)},this.generateSphere=i=>{const{fill:o}=B.getColorFromConfig({attribute:i.attribute},P(M({},this.config),{attributeConfigurable:!0}),{});this.addSphereToSense(i,o),this.render()},this.generateSpheres=i=>{i.forEach(o=>{const{fill:h}=B.getColorFromConfig({attribute:o.attribute},P(M({},this.config),{attributeConfigurable:!0}),{});this.addSphereToSense(o,h)}),this.render()},this.AddBoxToSense=(i,o=16777215)=>{var h;const l=(h=i.id)!=null?h:T();this.removeObjectByName(l);const{center:d,width:p,height:g,depth:x,rotation:u}=i,m=new c.Group,C=new c.BoxGeometry(p,g,x),y=new c.MeshBasicMaterial({color:"blue"}),v=new c.Mesh(C,y),I=new c.BoxHelper(v,o),V=this.generateBoxArrow(i);m.add(I),m.add(V),m.position.set(d.x,d.y,d.z),m.rotation.set(0,0,u),m.name=l,this.scene.add(m)},this.applyCameraTarget=i=>{if(this.camera.type==="OrthographicCamera"&&i){const o=this.getOrthographicCameraTarget(i);this.updateCameraZoom(i.zoom),this.updateCamera(i.position,o)}},this.overridePointShader=i=>{i.vertexShader=`
|
|
2
2
|
attribute float sizes;
|
|
3
3
|
attribute float visibility;
|
|
4
4
|
varying float vVisible;
|
|
@@ -8,4 +8,4 @@ import*as c from"three";import{toolStyleConverter as S,PerspectiveShiftUtils as
|
|
|
8
8
|
varying float vVisible;
|
|
9
9
|
${i.fragmentShader}`.replace("#include <clipping_planes_fragment>",`
|
|
10
10
|
if (vVisible < 0.5) discard;
|
|
11
|
-
#include <clipping_planes_fragment>`)},this.loadPCDFile=(i,n)=>z(this,null,function*(){this.clearPointCloud(),this.currentPCDSrc=i;const{points:h,color:l}=yield this.cacheInstance.loadPCDFile(i),p=new c.BufferGeometry;p.setAttribute("position",new c.BufferAttribute(h,3)),p.setAttribute("color",new c.BufferAttribute(l,3));const d=new c.Points(p);this.renderPointCloud(d,n)}),this.loadPCDFileByBox=(i,n,h)=>z(this,null,function*(){const l=(y,f)=>z(this,null,function*(){const{width:C=0,height:m=0,depth:b=0}=h!=null?h:{},x=yield this.filterPointsByBox(M(P({},n),{width:n.width+C,height:n.height+m,depth:n.depth+b}),y,f);if(!x){console.error("filter Error");return}this.clearPointCloud(),this.currentPCDSrc=i;const v=new c.Points(x.geometry);v.name=this.pointCloudObjectName,this.scene.add(v),this.render()}),{points:p,color:d}=yield this.cacheInstance.loadPCDFile(i);l(p,d)}),this.generateRange=i=>{const n=this.createRange(i);this.scene.add(n)},this.generateBoxArrow=({width:i})=>{const n=new c.Vector3(1,0,0),h=new c.Vector3(i/2,0,0),l=2,p=16776960,d=new c.ArrowHelper(n,h,l,p);return d.visible=this.showDirection,d},this.generateBoxTrackID=i=>{if(!i.trackID)return;const n=new c.Texture(this.getTextCanvas(i.trackID.toString()));n.needsUpdate=!0;const h=new c.SpriteMaterial({map:n,depthWrite:!1}),l=new c.Sprite(h);return l.scale.set(5,5,5),l.position.set(-i.width/2,0,i.depth/2+.5),l},this.applyZAxisPoints=i=>{this.zAxisLimit=i,this.filterZAxisPoints(),this.render()},this.updatePointSize=({zoomIn:i,customSize:n})=>{const h=this.scene.getObjectByName(this.pointCloudObjectName);if(!h)return;const l=h.material.size;i?h.material.size=Math.min(l*1.2,10):h.material.size=Math.max(l/1.2,1),n&&(h.material.size=n,this.pointsMaterialSize=n),this.render()},this.container=t,this.renderer=new c.WebGLRenderer({antialias:!0}),this.backgroundColor=s,this.config=a,r&&o?(this.isOrthographicCamera=!0,this.camera=new c.OrthographicCamera(o.left,o.right,o.top,o.bottom,o.near,o.far)):this.camera=new c.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new c.Scene,this.controls=new N(this.camera,this.renderer.domElement),this.pcdLoader=new I,this.axesHelper=new c.AxesHelper(1e3),this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=E.getInstance()}get DEFAULT_INIT_CAMERA_POSITION(){return new c.Vector3(-.01,0,10)}get containerWidth(){return this.container.clientWidth}get containerHeight(){return this.container.clientHeight}setInitCameraPosition(t){this.initCameraPosition=t}setConfig(t){this.config=t}initOrthographicCamera(t){if(this.camera.type!=="OrthographicCamera")return;const{left:e,right:r,top:o,bottom:s,near:a,far:i}=t;this.camera.left=e,this.camera.right=r,this.camera.top=o,this.camera.bottom=s,this.camera.near=a,this.camera.far=i,this.camera.updateProjectionMatrix()}initPerspectiveCamera(){this.camera.type==="PerspectiveCamera"&&(this.camera.fov=30,this.camera.aspect=this.containerWidth/this.containerHeight,this.camera.near=1,this.camera.far=1e3,this.camera.updateProjectionMatrix())}initCamera(){const{camera:t}=this;if(this.isOrthographicCamera){const{x:e,y:r,z:o}=this.initCameraPosition;t.position.set(e,r,o)}else t.position.set(-1,0,500);t.up.set(0,0,1)}initControls(){const{controls:t}=this;t.addEventListener("change",()=>{this.render()}),this.setDefaultControls()}setDefaultControls(){const{controls:t}=this,e=[0,0,0];t.target=new c.Vector3(...e),t.addEventListener("change",()=>{this.render()}),t.maxPolarAngle=Math.PI/2,t.update()}initRenderer(){const{renderer:t}=this;t.setPixelRatio(window.devicePixelRatio),t.setSize(this.containerWidth,this.containerHeight)}init(){const{scene:t}=this;t.background=new c.Color(this.backgroundColor),this.initControls(),this.initRenderer()}removeObjectByName(t){const e=this.scene.getObjectByName(t);e&&e.removeFromParent()}generateBox(t,e=16777215){const r=e;this.addBoxToSense(t,r),this.render()}getAllAttributeColor(t){return t.reduce((e,r)=>(e[r.attribute]=S.getColorFromConfig({attribute:r.attribute},M(P({},this.config),{attributeConfigurable:!0}),{}),e),{})}generateBoxes(t){t.forEach(e=>{this.addBoxToSense(e)}),this.render()}getOrthographicCamera(t){const{center:e,width:r,height:o}=t,s=10,a=e.x-r/2-s,i=e.x-r/2+s,n=e.y+o/2+s,h=e.y-o/2-s,l=100,p=-100,d=500/l;return{left:a,right:i,top:n,bottom:h,near:l,far:p,zoom:d}}updateCameraZoom(t){this.camera.zoom=t,this.camera.updateProjectionMatrix()}updateCameraByBox(t,e,r){const{center:o,width:s,height:a,depth:i,rotation:n}=t,h=this.getCameraVector(o,n,{width:s,height:a,depth:i},e);return r?(this.updateCamera(r,o),new c.Vector3(r.x,r.y,r.z)):(this.updateCamera(h,o),h)}updateOrthoCamera(t,e){const r=this.updateCameraByBox(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:r}}updateTopCamera(){this.setInitCameraPosition(this.DEFAULT_INIT_CAMERA_POSITION),this.camera.zoom=1,this.initCamera(),this.setDefaultControls(),this.camera.updateProjectionMatrix(),this.render()}updateCamera(t,e){this.camera.position.set(t.x,t.y,t.z),this.controls.target=new c.Vector3(e.x,e.y,e.z),this.controls.update()}resetCamera(){this.updateCamera(this.DEFAULT_INIT_CAMERA_POSITION,{x:0,y:0,z:0})}getOrthographicCameraTarget(t){const e=new c.Vector3(0,0,-1).applyQuaternion(t.quaternion);return t.position.clone().add(e)}createThreeMatrix4(t){return new c.Matrix4().set(...t)}filterPointsByBox(t,e,r){var o,s,a;if(!e){const i=this.scene.getObjectByName(this.pointCloudObjectName);if(!i)return console.error("There is no corresponding point cloud object"),Promise.resolve(void 0);e=(a=(s=(o=i==null?void 0:i.geometry)==null?void 0:o.attributes)==null?void 0:s.position)==null?void 0:a.array}if(window.Worker){const{zMin:i,zMax:n,polygonPointList:h}=B(t),l=e;r=r!=null?r:new Float32Array([]);const p={boxParams:t,zMin:i,zMax:n,polygonPointList:h,color:r,position:l};return new Promise(d=>{const y=new V;y.postMessage(p),y.onmessage=f=>{const{color:C,position:m,num:b}=f.data,x=new c.BufferGeometry;x.setAttribute("position",new c.Float32BufferAttribute(m,3)),x.setAttribute("color",new c.Float32BufferAttribute(C,3)),x.computeBoundingSphere(),y.terminate(),d({geometry:x,num:b})}})}return Promise.resolve(void 0)}getCameraVector(t,e,r,o=g.Front,s=H){let a=w.frontViewMatrix4(s);switch(o){case g.Front:break;case g.Back:a=w.backViewMatrix4(s);break;case g.Left:a=w.leftViewMatrix4(s);break;case g.Right:a=w.rightViewMatrix4(s);break;case g.Top:a=w.topViewMatrix4(s);break;case g.LFT:a=w.leftFrontTopViewMatrix4(s,r);break;case g.RBT:a=w.rightBackTopViewMatrix4(s,r);break}const i=this.createThreeMatrix4(a),n=new c.Matrix4().makeTranslation(-t.x,-t.y,-t.z),h=new c.Matrix4().makeTranslation(t.x,t.y,t.z),l=new c.Matrix4().makeRotationZ(e);return new c.Vector3(t.x,t.y,t.z).clone().applyMatrix4(i).applyMatrix4(n).applyMatrix4(l).applyMatrix4(h)}createRange(t){this.removeObjectByName(this.rangeObjectName);const r=new c.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),o=new c.BufferGeometry().setFromPoints(r),s=new c.LineBasicMaterial({color:16711680}),a=new c.Line(o,s);return a.name=this.rangeObjectName,a}renderPointCloud(t,e){t.name=this.pointCloudObjectName;const r=new c.PointsMaterial({vertexColors:!0});r.onBeforeCompile=this.overridePointShader,r.size=this.pointsMaterialSize,e&&this.generateRange(e),this.pointsUuid=t.uuid,t.material=r,this.filterZAxisPoints(t),this.scene.add(t),this.render()}clearPointCloud(){this.removeObjectByName(this.pointCloudObjectName)}clearPointCloudAndRender(){this.clearPointCloud(),this.render()}highlightOriginPointCloud(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(!!e)return this.highlightPCDSrc=this.currentPCDSrc,new Promise((r,o)=>{if(window.Worker){const a=(t?[...t]:[]).map(h=>B(h)),i=this.getAllAttributeColor(a),n={cuboidList:a,position:e.geometry.attributes.position.array,color:e.geometry.attributes.color.array,colorList:i};j.postMessage(n),j.onmessage=h=>{const{color:l}=h.data,p=new c.BufferAttribute(l,3);if(!this.highlightPCDSrc||this.highlightPCDSrc!==this.currentPCDSrc||e.geometry.attributes.position.array.length!==l.length){o(new Error("Error Path"));return}this.cacheInstance.updateColor(this.highlightPCDSrc,l),this.highlightPCDSrc=void 0,p.needsUpdate=!0,e.geometry.setAttribute("color",p),r(l),this.render()}}})}updateColor(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(e){const r=new c.BufferAttribute(t,3);r.needsUpdate=!0,e.geometry.setAttribute("color",r),this.render()}}setShowDirection(t){this.showDirection=t,this.scene.children.forEach(e=>{e.type==="Group"&&e.children.forEach(r=>{r.type==="ArrowHelper"&&(r.visible=t)})}),this.render()}getTextCanvas(t){const e=document.createElement("canvas"),r=e.getContext("2d");return r&&(r.font=`${50}px " bold`,r.fillStyle="white",r.textAlign="center",r.textBaseline="middle",r.fillText(t,e.width/2,e.height/2)),e}getSensesPointZAxisInPolygon(t,e){const r=this.scene.children.find(n=>n.uuid===this.pointsUuid);let o=0,s=0,a=0,i=0;if(r&&(r==null?void 0:r.geometry)){const n=r==null?void 0:r.geometry.attributes.position.array;for(let h=0;h<n.length;h+=3){const l=n[h],p=n[h+1],d=n[h+2];L({x:l,y:p},t)&&d&&(s=Math.max(d,s),o=Math.min(d,o),i++,e&&d>=e[0]&&d<=e[1]&&a++)}}return{maxZ:s,minZ:o,count:a,zCount:i}}getBasicCoordinate2Canvas(t){const e=this.containerWidth/2,r=this.containerHeight/2;return{x:t.x*e+e,y:t.y*r+r,z:t.z}}get basicCoordinate2CanvasMatrix4(){const t=this.containerWidth/2,e=this.containerHeight/2;return new c.Matrix4().set(t,0,0,t,0,e,0,e,0,0,1,0,0,0,0,1)}getCanvas2BasicCoordinate(t){const e=this.containerWidth/2,r=this.containerHeight/2;return new c.Vector3(t.x/e-e/2,-(t.y/r-r/2),1)}getPolygonSidePoints(t){const{center:{x:e,y:r,z:o},height:s,width:a,depth:i}=t,n={x:e+a/2,y:r+s/2,z:o-i/2},h={x:e+a/2,y:r+s/2,z:o+i/2},l={x:e-a/2,y:r+s/2,z:o+i/2},p={x:e-a/2,y:r+s/2,z:o-i/2};return[n,h,l,p]}getPolygonBackPoints(t){const{center:{x:e,y:r,z:o},height:s,width:a,depth:i}=t,n={x:e-a/2,y:r+s/2,z:o+i/2},h={x:e-a/2,y:r+s/2,z:o-i/2},l={x:e-a/2,y:r-s/2,z:o-i/2},p={x:e-a/2,y:r-s/2,z:o+i/2};return[n,h,l,p]}getPolygonTopPoints(t){const{center:{x:e,y:r,z:o},height:s,width:a,depth:i}=t,n={x:e+a/2,y:r+s/2,z:o+i/2},h={x:e+a/2,y:r-s/2,z:o+i/2},l={x:e-a/2,y:r-s/2,z:o+i/2},p={x:e-a/2,y:r+s/2,z:o+i/2};return[n,h,l,p]}getModelTransformationMatrix(t){const{center:{x:e,y:r,z:o},rotation:s}=t,a=new c.Matrix4().makeTranslation(-e,-r,-o),i=new c.Matrix4().makeTranslation(e,r,o),n=new c.Matrix4().makeRotationZ(s);return new c.Matrix4().multiply(i).multiply(n).multiply(a)}getBoxSidePolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,g.Left)}getBoxBackPolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,g.Back)}boxParams2ViewPolygon(t,e){switch(e){case g.Left:return this.getPolygonSidePoints(t);case g.Back:return this.getPolygonBackPoints(t);default:return this.getPolygonTopPoints(t)}}getBoxPolygon2DCoordinate(t,e){const r=this.boxParams2ViewPolygon(t,e),{width:o,height:s}=t,a=new c.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),i=new c.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(a).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=i;const n=r.map(p=>new c.Vector3(p.x,p.y,p.z)).map(p=>p.applyMatrix4(this.sideMatrix)),h=this.containerWidth/o,l=this.containerHeight/s;return{polygon2d:n,zoom:Math.min(h,l)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:r}=t,s=this.getPolygonTopPoints(t).map(n=>new c.Vector3(n.x,n.y,n.z)).map(n=>n.applyMatrix4(this.getModelTransformationMatrix(t))).map(n=>({x:n.y,y:n.x})).map(n=>({x:-(n.x-this.containerWidth/2),y:-(n.y-this.containerHeight/2)})),a=this.containerWidth/e,i=this.containerHeight/r;return{polygon2d:s,zoom:Math.min(a,i)/2}}getNewBoxBySideUpdate(t,e,r,o){const s=new c.Matrix4().makeRotationZ(o.rotation),a=new c.Vector3(-t.x,0,0).applyMatrix4(s);let i=o;return i.center={x:i.center.x+a.x,y:i.center.y+a.y,z:i.center.z-t.z},i=M(P({},i),{width:i.width+e,height:i.height,depth:i.depth+r}),{newBoxParams:i}}getNewBoxByBackUpdate(t,e,r,o){const s=new c.Matrix4().makeRotationZ(o.rotation),a=new c.Vector3(0,-t.x,0).applyMatrix4(s);let i=o;return i.center={x:i.center.x+a.x,y:i.center.y+a.y,z:i.center.z-t.z},i=M(P({},i),{width:i.width,height:i.height+e,depth:i.depth+r}),{newBoxParams:i}}getNewBoxBySideUpdateByPoints(t,e,r,o){var s;const a=(s=this.sideMatrix)==null?void 0:s.invert();if(!this.sideMatrix||!a){console.error("No sideMatrix");return}this.camera.zoom=1,this.camera.updateProjectionMatrix();const i=t.map(m=>new c.Vector3(m.x,m.y,m.z)).map(m=>m.applyMatrix4(a)),[n,h,l,p]=i,d=Math.max(Math.abs(n.x-l.x),Math.abs(n.x-h.x)),f=h.add(p).applyMatrix3(new c.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new c.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new c.Vector3(o.center.x,o.center.y,o.center.z));return{newBoxParams:M(P({},o),{center:{x:o.center.x-f.x,y:o.center.y-f.y,z:o.center.z-r},width:d,height:o.height,depth:o.depth+e,rotation:o.rotation})}}filterZAxisPoints(t){const e=t||this.scene.children.find(r=>r.uuid===this.pointsUuid);if(e){const{attributes:r}=e.geometry,{position:o}=r,s=[],{count:a}=o;for(let i=0;i<a;i++){const n=o.getZ(i);s.push(n>this.zAxisLimit?0:1)}e.geometry.setAttribute("visibility",new c.Float32BufferAttribute(s,1)),e.geometry.attributes.visibility.needsUpdate=!0}}render(){this.renderer.render(this.scene,this.camera)}}export{G as PointCloud};
|
|
11
|
+
#include <clipping_planes_fragment>`)},this.loadPCDFile=(i,o)=>S(this,null,function*(){this.clearPointCloud(),this.currentPCDSrc=i;const{points:h,color:l}=yield this.cacheInstance.loadPCDFile(i),d=new c.BufferGeometry;d.setAttribute("position",new c.BufferAttribute(h,3)),d.setAttribute("color",new c.BufferAttribute(l,3));const p=new c.Points(d);this.renderPointCloud(p,o)}),this.loadPCDFileByBox=(i,o,h)=>S(this,null,function*(){const l=(g,x)=>S(this,null,function*(){const{width:u=0,height:m=0,depth:C=0}=h!=null?h:{},y=yield this.filterPointsByBox(P(M({},o),{width:o.width+u,height:o.height+m,depth:o.depth+C}),g,x);if(!y){console.error("filter Error");return}this.clearPointCloud(),this.currentPCDSrc=i;const v=new c.Points(y.geometry);v.name=this.pointCloudObjectName,this.scene.add(v),this.render()}),{points:d,color:p}=yield this.cacheInstance.loadPCDFile(i);l(d,p)}),this.generateRange=i=>{const o=this.createRange(i);this.scene.add(o)},this.generateBoxArrow=({width:i})=>{const o=new c.Vector3(1,0,0),h=new c.Vector3(i/2,0,0),l=2,d=16776960,p=new c.ArrowHelper(o,h,l,d);return p.visible=this.showDirection,p},this.generateBoxTrackID=i=>{if(!i.trackID)return;const o=new c.Texture(this.getTextCanvas(i.trackID.toString()));o.needsUpdate=!0;const h=new c.SpriteMaterial({map:o,depthWrite:!1}),l=new c.Sprite(h);return l.scale.set(5,5,5),l.position.set(-i.width/2,0,i.depth/2+.5),l},this.applyZAxisPoints=i=>{this.zAxisLimit=i,this.filterZAxisPoints(),this.render()},this.updatePointSize=i=>{const o=this.scene.getObjectByName(this.pointCloudObjectName);if(!o)return;const h=o.material.size;i?o.material.size=Math.min(h*1.2,10):o.material.size=Math.max(h/1.2,1),this.render()},this.container=t,this.renderer=new c.WebGLRenderer({antialias:!0}),this.backgroundColor=s,this.config=a,r&&n?(this.isOrthographicCamera=!0,this.camera=new c.OrthographicCamera(n.left,n.right,n.top,n.bottom,n.near,n.far)):this.camera=new c.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new c.Scene,this.controls=new R(this.camera,this.renderer.domElement),this.pcdLoader=new E,this.axesHelper=new c.AxesHelper(1e3),this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=W.getInstance()}get DEFAULT_INIT_CAMERA_POSITION(){return new c.Vector3(-.01,0,10)}get containerWidth(){return this.container.clientWidth}get containerHeight(){return this.container.clientHeight}setInitCameraPosition(t){this.initCameraPosition=t}setConfig(t){this.config=t}initOrthographicCamera(t){if(this.camera.type!=="OrthographicCamera")return;const{left:e,right:r,top:n,bottom:s,near:a,far:i}=t;this.camera.left=e,this.camera.right=r,this.camera.top=n,this.camera.bottom=s,this.camera.near=a,this.camera.far=i,this.camera.updateProjectionMatrix()}initPerspectiveCamera(){this.camera.type==="PerspectiveCamera"&&(this.camera.fov=30,this.camera.aspect=this.containerWidth/this.containerHeight,this.camera.near=1,this.camera.far=1e3,this.camera.updateProjectionMatrix())}initCamera(){const{camera:t}=this;if(this.isOrthographicCamera){const{x:e,y:r,z:n}=this.initCameraPosition;t.position.set(e,r,n)}else t.position.set(-1,0,500);t.up.set(0,0,1)}initControls(){const{controls:t}=this;t.addEventListener("change",()=>{this.render()}),this.setDefaultControls()}setDefaultControls(){const{controls:t}=this,e=[0,0,0];t.target=new c.Vector3(...e),t.addEventListener("change",()=>{this.render()}),t.maxPolarAngle=Math.PI/2,t.update()}initRenderer(){const{renderer:t}=this;t.setPixelRatio(window.devicePixelRatio),t.setSize(this.containerWidth,this.containerHeight)}init(){const{scene:t}=this;t.background=new c.Color(this.backgroundColor),this.initControls(),this.initRenderer()}removeObjectByName(t){const e=this.scene.getObjectByName(t);e&&e.removeFromParent()}generateBox(t,e=16777215){const r=e;this.AddBoxToSense(t,r),this.render()}getAllAttributeColor(t){return t.reduce((e,r)=>(e[r.attribute]=B.getColorFromConfig({attribute:r.attribute},P(M({},this.config),{attributeConfigurable:!0}),{}),e),{})}generateBoxes(t){t.forEach(e=>{this.generateBox(e)}),this.render()}getOrthographicCamera(t){const{center:e,width:r,height:n}=t,s=10,a=e.x-r/2-s,i=e.x-r/2+s,o=e.y+n/2+s,h=e.y-n/2-s,l=100,d=-100,p=500/l;return{left:a,right:i,top:o,bottom:h,near:l,far:d,zoom:p}}updateCameraZoom(t){this.camera.zoom=t,this.camera.updateProjectionMatrix()}updateCameraByBox(t,e,r){const{center:n,width:s,height:a,depth:i,rotation:o}=t,h=this.getCameraVector(n,o,{width:s,height:a,depth:i},e);return r?(this.updateCamera(r,n),new c.Vector3(r.x,r.y,r.z)):(this.updateCamera(h,n),h)}updateCameraBySphere(t,e){const{center:r}=t,{radius:n}=z,s=this.getCameraVector(r,0,{width:n*2,height:n*2,depth:n*2},e);return this.updateCamera(s,r),s}updateOrthoCamera(t,e){const r=this.updateCameraByBox(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:r}}updateOrthoCameraBySphere(t,e){const r=this.updateCameraBySphere(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:r}}updateTopCamera(){this.setInitCameraPosition(this.DEFAULT_INIT_CAMERA_POSITION),this.camera.zoom=1,this.initCamera(),this.setDefaultControls(),this.camera.updateProjectionMatrix(),this.render()}updateCamera(t,e){this.camera.position.set(t.x,t.y,t.z),this.controls.target=new c.Vector3(e.x,e.y,e.z),this.controls.update()}resetCamera(){this.updateCamera(this.DEFAULT_INIT_CAMERA_POSITION,{x:0,y:0,z:0})}getOrthographicCameraTarget(t){const e=new c.Vector3(0,0,-1).applyQuaternion(t.quaternion);return t.position.clone().add(e)}createThreeMatrix4(t){return new c.Matrix4().set(...t)}filterPointsByBox(t,e,r){var n,s,a;if(!e){const i=this.scene.getObjectByName(this.pointCloudObjectName);if(!i)return console.error("There is no corresponding point cloud object"),Promise.resolve(void 0);e=(a=(s=(n=i==null?void 0:i.geometry)==null?void 0:n.attributes)==null?void 0:s.position)==null?void 0:a.array}if(window.Worker){const{zMin:i,zMax:o,polygonPointList:h}=A(t),l=e;r=r!=null?r:new Float32Array([]);const d={boxParams:t,zMin:i,zMax:o,polygonPointList:h,color:r,position:l};return new Promise(p=>{const g=new L;g.postMessage(d),g.onmessage=x=>{const{color:u,position:m,num:C}=x.data,y=new c.BufferGeometry;y.setAttribute("position",new c.Float32BufferAttribute(m,3)),y.setAttribute("color",new c.Float32BufferAttribute(u,3)),y.computeBoundingSphere(),g.terminate(),p({geometry:y,num:C})}})}return Promise.resolve(void 0)}getCameraVector(t,e,r,n=w.Front,s=X){let a=b.frontViewMatrix4(s);switch(n){case w.Front:break;case w.Back:a=b.backViewMatrix4(s);break;case w.Left:a=b.leftViewMatrix4(s);break;case w.Right:a=b.rightViewMatrix4(s);break;case w.Top:a=b.topViewMatrix4(s);break;case w.LFT:a=b.leftFrontTopViewMatrix4(s,r);break;case w.RBT:a=b.rightBackTopViewMatrix4(s,r);break}const i=this.createThreeMatrix4(a),o=new c.Matrix4().makeTranslation(-t.x,-t.y,-t.z),h=new c.Matrix4().makeTranslation(t.x,t.y,t.z),l=new c.Matrix4().makeRotationZ(e);return new c.Vector3(t.x,t.y,t.z).clone().applyMatrix4(i).applyMatrix4(o).applyMatrix4(l).applyMatrix4(h)}createRange(t){this.removeObjectByName(this.rangeObjectName);const r=new c.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),n=new c.BufferGeometry().setFromPoints(r),s=new c.LineBasicMaterial({color:16711680}),a=new c.Line(n,s);return a.name=this.rangeObjectName,a}renderPointCloud(t,e){t.name=this.pointCloudObjectName;const r=new c.PointsMaterial({vertexColors:!0});r.onBeforeCompile=this.overridePointShader,r.size=1.2,e&&this.generateRange(e),this.pointsUuid=t.uuid,t.material=r,this.filterZAxisPoints(t),this.scene.add(t),this.render()}clearPointCloud(){this.removeObjectByName(this.pointCloudObjectName)}clearPointCloudAndRender(){this.clearPointCloud(),this.render()}highlightOriginPointCloud(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(!!e)return this.highlightPCDSrc=this.currentPCDSrc,new Promise(r=>{if(window.Worker){const s=(t?[...t]:[]).map(o=>A(o)),a=this.getAllAttributeColor(s),i={cuboidList:s,position:e.geometry.attributes.position.array,color:e.geometry.attributes.color.array,colorList:a};j.postMessage(i),j.onmessage=o=>{const{color:h}=o.data,l=new c.BufferAttribute(h,3);this.highlightPCDSrc&&(this.cacheInstance.updateColor(this.highlightPCDSrc,h),this.highlightPCDSrc=void 0),l.needsUpdate=!0,e.geometry.setAttribute("color",l),r(h),this.render()}}})}updateColor(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(e){const r=new c.BufferAttribute(t,3);r.needsUpdate=!0,e.geometry.setAttribute("color",r),this.render()}}setShowDirection(t){this.showDirection=t,this.scene.children.forEach(e=>{e.type==="Group"&&e.children.forEach(r=>{r.type==="ArrowHelper"&&(r.visible=t)})}),this.render()}getTextCanvas(t){const e=document.createElement("canvas"),r=e.getContext("2d");return r&&(r.font=`${50}px " bold`,r.fillStyle="white",r.textAlign="center",r.textBaseline="middle",r.fillText(t,e.width/2,e.height/2)),e}filterNoise(t){let e=[...t];e.sort((d,p)=>d.z-p.z);const r=Math.floor(e.length*.05),n=e[r];e=e.filter(({z:d})=>d>n.z+.1);const s=.005,a=Math.floor(e.length*(1-s));e=e.slice(0,a),e.sort((d,p)=>d.x-p.x);const i=Math.floor(e.length*s),o=Math.floor(e.length*(1-s));e=e.slice(i,o),e.sort((d,p)=>d.y-p.y);const h=Math.floor(e.length*s),l=Math.floor(e.length*(1-s));return e=e.slice(h,l),e.length>100?e:t}getFittedCoordinates(t,e){const r=[];let n=[...t,t[0]];e.forEach(({x:i,y:o})=>{t.forEach((h,l)=>{const d=n[l+1],p=F.getFootOfPerpendicular({x:i,y:o},h,d,!1,!0).length;(!r[l]||p<r[l].distance)&&(r[l]={distance:p,point:{x:i,y:o}})})}),n=[t[t.length-1],...t,t[0]];const s=[r[r.length-1],...r];return t.map((i,o)=>{const h=n[o],l=n[o+1],d=n[o+2];return k.getIntersectionBySlope({p1:s[o].point,k1:(h.y-l.y)/(h.x-l.x),p2:s[o+1].point,k2:(l.y-d.y)/(l.x-d.x)})})}getSensesPointZAxisInPolygon(t,e,r){var n,s,a;const i=this.scene.children.find(u=>u.uuid===this.pointsUuid);let o=0,h=0,l=0,d=0,p=[],g=[];const x=((a=(s=(n=i==null?void 0:i.geometry)==null?void 0:n.attributes)==null?void 0:s.position)==null?void 0:a.array)||[];for(let u=0;u<x.length;u+=3){const m=x[u],C=x[u+1],y=x[u+2];N({x:m,y:C},t)&&(y||y===0)&&g.push({x:m,y:C,z:y})}return g.length?(r&&(g=this.filterNoise(g),p=this.getFittedCoordinates(t,g)),g.sort((u,m)=>u.z-m.z),o=g[0].z-.01,h=g[g.length-1].z+.01,d=g.length,e&&(l=g.filter(({z:u})=>u>=e[0]&&u<=e[1]).length),{maxZ:h,minZ:o,count:l,zCount:d,fittedCoordinates:p}):{maxZ:h,minZ:o,count:l,zCount:d,fittedCoordinates:p}}getBasicCoordinate2Canvas(t){const e=this.containerWidth/2,r=this.containerHeight/2;return{x:t.x*e+e,y:t.y*r+r,z:t.z}}get basicCoordinate2CanvasMatrix4(){const t=this.containerWidth/2,e=this.containerHeight/2;return new c.Matrix4().set(t,0,0,t,0,e,0,e,0,0,1,0,0,0,0,1)}getCanvas2BasicCoordinate(t){const e=this.containerWidth/2,r=this.containerHeight/2;return new c.Vector3(t.x/e-e/2,-(t.y/r-r/2),1)}getPolygonSidePoints(t){const{center:{x:e,y:r,z:n},height:s,width:a,depth:i}=t,o={x:e+a/2,y:r+s/2,z:n-i/2},h={x:e+a/2,y:r+s/2,z:n+i/2},l={x:e-a/2,y:r+s/2,z:n+i/2},d={x:e-a/2,y:r+s/2,z:n-i/2};return[o,h,l,d]}getPolygonBackPoints(t){const{center:{x:e,y:r,z:n},height:s,width:a,depth:i}=t,o={x:e-a/2,y:r+s/2,z:n+i/2},h={x:e-a/2,y:r+s/2,z:n-i/2},l={x:e-a/2,y:r-s/2,z:n-i/2},d={x:e-a/2,y:r-s/2,z:n+i/2};return[o,h,l,d]}getPolygonTopPoints(t){const{center:{x:e,y:r,z:n},height:s,width:a,depth:i}=t,o={x:e+a/2,y:r+s/2,z:n+i/2},h={x:e+a/2,y:r-s/2,z:n+i/2},l={x:e-a/2,y:r-s/2,z:n+i/2},d={x:e-a/2,y:r+s/2,z:n+i/2};return[o,h,l,d]}getModelTransformationMatrix(t){const{center:{x:e,y:r,z:n},rotation:s}=t,a=new c.Matrix4().makeTranslation(-e,-r,-n),i=new c.Matrix4().makeTranslation(e,r,n),o=new c.Matrix4().makeRotationZ(s);return new c.Matrix4().multiply(i).multiply(o).multiply(a)}getBoxSidePolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,w.Left)}getBoxBackPolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,w.Back)}getSphereSidePoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}getSphereBackPoint2DCoordinate(t){return this.getSpherePoint2DCoordinate(t)}boxParams2ViewPolygon(t,e){switch(e){case w.Left:return this.getPolygonSidePoints(t);case w.Back:return this.getPolygonBackPoints(t);default:return this.getPolygonTopPoints(t)}}getBoxPolygon2DCoordinate(t,e){const r=this.boxParams2ViewPolygon(t,e),{width:n,height:s}=t,a=new c.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),i=new c.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(a).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=i;const o=r.map(d=>new c.Vector3(d.x,d.y,d.z)).map(d=>d.applyMatrix4(this.sideMatrix)),h=this.containerWidth/n,l=this.containerHeight/s;return{polygon2d:o,zoom:Math.min(h,l)/2}}getSpherePoint2DCoordinate(t){const{center:e,attribute:r,id:n,valid:s}=t,{radius:a}=z,i={center:e,attribute:r,id:n,valid:s,width:a*2,height:a*2,depth:a*2,rotation:0},o=new c.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),h=new c.Matrix4().premultiply(this.getModelTransformationMatrix(i)).premultiply(o).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=h;const l=new c.Vector3(e.x,e.y,e.z).applyMatrix4(this.sideMatrix),d=this.containerWidth/(a*2),p=this.containerHeight/(a*2);return{point2d:l,zoom:Math.min(d,p)/2}}getSphereTopPoint2DCoordinate(t){const{center:e}=t,{radius:r}=z,n={x:-(e.y-this.containerWidth/2),y:-(e.x-this.containerHeight/2)},s=this.containerWidth/(r*2),a=this.containerHeight/(r*2);return{point2d:n,zoom:Math.min(s,a)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:r}=t,s=this.getPolygonTopPoints(t).map(o=>new c.Vector3(o.x,o.y,o.z)).map(o=>o.applyMatrix4(this.getModelTransformationMatrix(t))).map(o=>({x:o.y,y:o.x})).map(o=>({x:-(o.x-this.containerWidth/2),y:-(o.y-this.containerHeight/2)})),a=this.containerWidth/e,i=this.containerHeight/r;return{polygon2d:s,zoom:Math.min(a,i)/2}}getNewBoxBySideUpdate(t,e,r,n){const s=new c.Matrix4().makeRotationZ(n.rotation),a=new c.Vector3(-t.x,0,0).applyMatrix4(s);let i=n;return i.center={x:i.center.x+a.x,y:i.center.y+a.y,z:i.center.z-t.z},i=P(M({},i),{width:i.width+e,height:i.height,depth:i.depth+r}),{newBoxParams:i}}getNewBoxByBackUpdate(t,e,r,n){const s=new c.Matrix4().makeRotationZ(n.rotation),a=new c.Vector3(0,-t.x,0).applyMatrix4(s);let i=n;return i.center={x:i.center.x+a.x,y:i.center.y+a.y,z:i.center.z-t.z},i=P(M({},i),{width:i.width,height:i.height+e,depth:i.depth+r}),{newBoxParams:i}}getNewBoxBySideUpdateByPoints(t,e,r,n){var s;const a=(s=this.sideMatrix)==null?void 0:s.invert();if(!this.sideMatrix||!a){console.error("No sideMatrix");return}this.camera.zoom=1,this.camera.updateProjectionMatrix();const i=t.map(m=>new c.Vector3(m.x,m.y,m.z)).map(m=>m.applyMatrix4(a)),[o,h,l,d]=i,p=Math.max(Math.abs(o.x-l.x),Math.abs(o.x-h.x)),x=h.add(d).applyMatrix3(new c.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new c.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new c.Vector3(n.center.x,n.center.y,n.center.z));return{newBoxParams:P(M({},n),{center:{x:n.center.x-x.x,y:n.center.y-x.y,z:n.center.z-r},width:p,height:n.height,depth:n.depth+e,rotation:n.rotation})}}filterZAxisPoints(t){const e=t||this.scene.children.find(r=>r.uuid===this.pointsUuid);if(e){const{attributes:r}=e.geometry,{position:n}=r,s=[],{count:a}=n;for(let i=0;i<a;i++){const o=n.getZ(i);s.push(o>this.zAxisLimit?0:1)}e.geometry.setAttribute("visibility",new c.Float32BufferAttribute(s,1)),e.geometry.attributes.visibility.needsUpdate=!0}}render(){this.renderer.render(this.scene,this.camera)}}export{Y as PointCloud};
|
package/es/core/scheduler.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getConfig as f,styleDefaultConfig as
|
|
1
|
+
import{getConfig as f,styleDefaultConfig as L}from"../constant/defaultConfig.js";import{getCurrentOperation as y}from"../utils/tool/EnhanceCommonToolUtils.js";import{BasicToolOperation as v}from"./toolOperation/basicToolOperation.js";const D=e=>{const t=document.createElement("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");return i?(i.fillStyle="transparent",i.fillRect(0,0,e.width,e.height),t.toDataURL()):""},p=(e,t,i)=>{const o=e[t];return e[t]=e[i],e[i]=o,e},g=class{static isSingleTool(e){return!this.isHybridTool(e)}static isHybridTool(e){return Array.isArray(e)}};let u=g;u.getTopToolName=e=>g.isHybridTool(e)?e[e.length-1]:e;class I{constructor(t){this.toolOperationList=[],this.toolOperationDom=[],this.toolOperationNameList=[];var i,o;this.init(),this.container=t.container,this.size=t.size,this.imgNode=t.imgNode,this.config=(i=t.config)!=null?i:JSON.stringify(f(u.getTopToolName(t.toolName))),this.style=(o=t.style)!=null?o:L}setImgNode(t,i){this.toolOperationList.forEach(o=>{o.setImgNode(t,i)})}setImgAttribute(t){this.toolOperationList.forEach(i=>{i.setImgAttribute(t)})}setSize(t){this.toolOperationList.forEach(i=>{i.setSize(t)})}syncPosition(t,i,o,s){this.toolOperationList.forEach(a=>{s!==a&&(a.setCurrentPos(t),a.setZoom(i),a.setImgInfo(o),a.renderBasicCanvas(),a.render())})}get defaultSize(){var t,i;return{width:((t=this.imgNode)==null?void 0:t.width)||this.size.width,height:((i=this.imgNode)==null?void 0:i.height)||this.size.height}}createDom(){const{width:t,height:i}=this.defaultSize,o=window.document.createElement("div");o.style.position="absolute",o.style.left="0",o.style.top="0",o.style.width=`${t}px`,o.style.height=`${i}px`;const s=this.toolOperationList.length+1;return o.style.zIndex=`${s}`,o}getEmptyImage(t,i){const o=D({width:t,height:i}),s=new Image;return s.src=o,s}createOperation(t,i,o){var s;const{width:a,height:l}=this.defaultSize,r=this.createDom(),d=this.getEmptyImage(a,l),h={container:r,size:this.size,config:(s=this==null?void 0:this.config)!=null?s:"{}",drawOutSideTarget:!1,style:this.style,imgNode:i||d,hiddenImg:!!t};o&&Object.assign(h,o);let n;if(!t)n=new v(h),r.style.zIndex="0",n.init();else{const c=y(t);if(!c)return;n=new c(h)}return n==null||n.init(),n.canvas.id=t!=null?t:"basicCanvas",n.on("dragMove",({currentPos:c,zoom:m,imgInfo:O})=>{this.syncPosition(c,m,O,n)}),n.on("renderZoom",(c,m,O)=>{c&&m&&this.syncPosition(m,c,O,n)}),t?(this.container.appendChild(r),this.toolOperationList.push(n),this.toolOperationNameList.push(t),this.toolOperationDom.push(r),n):(this.container.insertBefore(r,this.container.childNodes[0]),this.toolOperationList.unshift(n),this.toolOperationDom.unshift(r),n)}switchLastTwoCanvas(){if(this.toolOperationDom.length<3){console.error("switchLastTwoCanvas is just used the layer which has 3 canvas");return}const t=this.toolOperationDom.length,i=t-1,o=t-2,s=this.toolOperationDom[i],a=this.toolOperationDom[o];if(!(!a||!s))return s.style.zIndex=`${i-1}`,a.style.zIndex=`${i}`,this.toolOperationList[i].clearActiveStatus(),this.toolOperationList[i].clearCursorLine(),this.toolOperationList[i].render(),this.toolOperationList=p(this.toolOperationList,i,o),this.toolOperationDom=p(this.toolOperationDom,i,o),this.toolOperationList[i]}getFirstToolOperation(){return this.toolOperationList.length>1?this.toolOperationList[1]:this.toolOperationList[0]}switchToCanvas(t){var i,o,s,a;const l=this.toolOperationNameList.indexOf(t);if(l<0||this.toolOperationList.length<1||l>this.toolOperationDom.length-1)return;const r=this.toolOperationDom.length-1,d=this.toolOperationDom[l],h=this.toolOperationDom[r];if(!d||!h)return;const n=h.style.zIndex;return h.style.zIndex=`${d.style.zIndex}`,d.style.zIndex=`${n}`,(o=(i=this.toolOperationList[r]).clearActiveStatus)==null||o.call(i),(a=(s=this.toolOperationList[r]).clearCursorLine)==null||a.call(s),this.toolOperationList[r].render(),this.toolOperationList=p(this.toolOperationList,r,l),this.toolOperationDom=p(this.toolOperationDom,r,l),this.toolOperationNameList=p(this.toolOperationNameList,r,l),this.toolOperationList[r]}updateDataByToolName(t,i){const o=this.toolOperationNameList.indexOf(t);o>=0&&this.toolOperationList[o].setResult(i)}clearStatusAndResult(){this.toolOperationList.forEach(t=>{var i;(i=t.clearActiveStatus)==null||i.call(t),t.clearResult()})}destroyAllLayer(){this.toolOperationList.forEach(t=>{t.destroyCanvas(),this.init()})}init(){this.toolOperationList=[],this.toolOperationDom=[]}}export{u as HybridToolUtils,I as ToolScheduler};
|