@labelbee/lb-annotation 1.14.0-alpha.16 → 1.14.0-alpha.17

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),tool=require("../../constant/tool.js"),CanvasScheduler=require("../../newCore/CanvasScheduler.js"),index=require("./index.js"),scheduler=require("../scheduler.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(i,t,e)=>t in i?__defProp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,__spreadValues=(i,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(i,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(i,e,t[e]);return i},__spreadProps=(i,t)=>__defProps(i,__getOwnPropDescs(t));const createEmptyImage=i=>{const t=document.createElement("canvas");t.width=i.width,t.height=i.height;const e=t.getContext("2d");return e?(e.fillStyle="black",e.fillRect(0,0,i.width,i.height),t.toDataURL()):""};class PointCloudAnnotation{constructor({size:t,container:e,pcdPath:n,extraProps:P,config:f,checkMode:v,toolName:d,proxyMode:I}){this.updateLineList=a=>{this.toolScheduler.updateDataByToolName(tool.EToolName.Line,a!=null?a:[])},this.updatePolygonList=(a,l)=>{let s=a.map(o=>{var r;const{polygon2d:C}=this.pointCloudInstance.getBoxTopPolygon2DCoordinate(o);return{id:o.id,sourceID:"",pointList:C,isRect:!0,valid:(r=o.valid)!=null?r:!0,attribute:o.attribute}});l&&(s=s.concat(l.map(o=>{var r;return __spreadProps(__spreadValues({},o),{pointList:(r=o==null?void 0:o.pointList)==null?void 0:r.map(C=>lbUtils.PointCloudUtils.transferWorld2Canvas(C,this.toolInstance.size))})}))),this.toolScheduler.updateDataByToolName(tool.EToolName.PointCloudPolygon,s)},this.updatePointList=a=>{const l=a==null?void 0:a.map(s=>{var o;const{point2d:r}=this.pointCloudInstance.getSphereTopPoint2DCoordinate(s);return __spreadProps(__spreadValues({},r),{id:s.id,sourceID:"",valid:(o=s.valid)!=null?o:!0,attribute:s.attribute,textAttribute:""})});this.toolScheduler.updateDataByToolName(tool.EToolName.Point,l)};const O=this.getDefaultOrthographic(t),L=createEmptyImage(t),u=new Image;u.src=L;const h=new scheduler.ToolScheduler({container:e,size:t,toolName:d,proxyMode:I}),m=new CanvasScheduler.CanvasScheduler({container:e}),p=new index.PointCloud({container:e,noAppend:!0,isOrthographicCamera:!0,orthographicParams:O});n&&p.loadPCDFile(n),m.createCanvas(p.renderer.domElement);const g={size:t,config:JSON.stringify(__spreadProps(__spreadValues({},f),{attributeConfigurable:!0,hideAttribute:!0})),imgNode:u,checkMode:v};P&&Object.assign(g,P);let c=[];scheduler.HybridToolUtils.isSingleTool(d)?c=[d]:c=d,c.forEach((a,l)=>{let s;if(a===tool.EToolName.PointCloudPolygon){const o=h.createOperation(a,u,g);o.eventBinding(),o.setPattern(tool.EPolygonPattern.Rect),this.toolInstance=o,this.toolInstance.eventBinding(),this.pointCloud2dOperation=o}else s=h.createOperation(a,u,__spreadProps(__spreadValues({},g),{textConfigurable:!1}));l===c.length-1&&(this.toolInstance||(this.toolInstance=s,this.toolInstance.eventBinding()))}),this.pointCloudInstance=p,this.canvasScheduler=m,this.toolScheduler=h,this.config=f}updateConfig(t){this.config=t}updateAttributeList(t){this.config=__spreadProps(__spreadValues({},this.config),{attributeList:t}),this.toolScheduler.syncAllAttributeListInConfig(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 e=createEmptyImage(t),n=new Image;n.src=e,n.onload=()=>{this.toolInstance.setImgNode(n),this.toolInstance.initImgPos()},this.pointCloud2dOperation.setCanvasSize(t)}addPolygonListOnTopView(t){const e=lbUtils.PointCloudUtils.getBoxParamsFromResultList(t),n=lbUtils.PointCloudUtils.getPolygonListFromResultList(t);this.updatePolygonList(e,n)}addLineListOnTopView(t){const e=lbUtils.PointCloudUtils.getLineListFromResultList(t);this.updateLineList(e)}addPointListOnTopView(t){const e=lbUtils.PointCloudUtils.getSphereParamsFromResultList(t);this.updatePointList(e)}updateData(t,e,n){!this.toolInstance||!this.pointCloudInstance||(this.pointCloudInstance.loadPCDFile(t,n==null?void 0:n.radius),this.addPolygonListOnTopView(e),this.addLineListOnTopView(e),this.addPointListOnTopView(e))}switchToCanvas(t){const e=this.toolScheduler.switchToCanvas(t);return e?(e.eventBinding(),this.toolInstance=e,e):this.toolInstance}initAllPosition(){this.pointCloudInstance.updateTopCamera(),this.pointCloud2dOperation.initPosition()}clearAllData(){this.pointCloudInstance.clearPointCloudAndRender(),this.pointCloud2dOperation.clearResult()}}exports.PointCloudAnnotation=PointCloudAnnotation;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),tool=require("../../constant/tool.js"),CanvasScheduler=require("../../newCore/CanvasScheduler.js"),index=require("./index.js"),scheduler=require("../scheduler.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,t,e)=>t in n?__defProp(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,__spreadValues=(n,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(n,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(n,e,t[e]);return n},__spreadProps=(n,t)=>__defProps(n,__getOwnPropDescs(t));const createEmptyImage=n=>{const t=document.createElement("canvas");t.width=n.width,t.height=n.height;const e=t.getContext("2d");return e?(e.fillStyle="black",e.fillRect(0,0,n.width,n.height),t.toDataURL()):""};class PointCloudAnnotation{constructor({size:t,container:e,pcdPath:a,extraProps:P,config:f,checkMode:v,toolName:u,proxyMode:L}){this.updateLineList=s=>{const l=(s!=null?s:[]).map(i=>{var o;const r=(o=i.pointList)==null?void 0:o.map(d=>__spreadValues({i:d},lbUtils.PointCloudUtils.transferWorld2Canvas(d,this.toolInstance.size)));return __spreadProps(__spreadValues({},i),{pointList:r})});this.toolScheduler.updateDataByToolName(tool.EToolName.Line,l)},this.updatePolygonList=(s,l)=>{let i=s.map(o=>{var r;const{polygon2d:d}=this.pointCloudInstance.getBoxTopPolygon2DCoordinate(o);return{id:o.id,sourceID:"",pointList:d,isRect:!0,valid:(r=o.valid)!=null?r:!0,attribute:o.attribute}});l&&(i=i.concat(l.map(o=>{var r;return __spreadProps(__spreadValues({},o),{pointList:(r=o==null?void 0:o.pointList)==null?void 0:r.map(d=>lbUtils.PointCloudUtils.transferWorld2Canvas(d,this.toolInstance.size))})}))),this.toolScheduler.updateDataByToolName(tool.EToolName.PointCloudPolygon,i)},this.updatePointList=s=>{const l=s==null?void 0:s.map(i=>{var o;const{point2d:r}=this.pointCloudInstance.getSphereTopPoint2DCoordinate(i);return __spreadProps(__spreadValues({},r),{id:i.id,sourceID:"",valid:(o=i.valid)!=null?o:!0,attribute:i.attribute,textAttribute:""})});this.toolScheduler.updateDataByToolName(tool.EToolName.Point,l)};const I=this.getDefaultOrthographic(t),O=createEmptyImage(t),c=new Image;c.src=O;const p=new scheduler.ToolScheduler({container:e,size:t,toolName:u,proxyMode:L}),m=new CanvasScheduler.CanvasScheduler({container:e}),g=new index.PointCloud({container:e,noAppend:!0,isOrthographicCamera:!0,orthographicParams:I});a&&g.loadPCDFile(a),m.createCanvas(g.renderer.domElement);const C={size:t,config:JSON.stringify(__spreadProps(__spreadValues({},f),{attributeConfigurable:!0,hideAttribute:!0})),imgNode:c,checkMode:v};P&&Object.assign(C,P);let h=[];scheduler.HybridToolUtils.isSingleTool(u)?h=[u]:h=u,h.forEach((s,l)=>{let i;if(s===tool.EToolName.PointCloudPolygon){const o=p.createOperation(s,c,C);o.eventBinding(),o.setPattern(tool.EPolygonPattern.Rect),this.toolInstance=o,this.toolInstance.eventBinding(),this.pointCloud2dOperation=o}else i=p.createOperation(s,c,__spreadProps(__spreadValues({},C),{textConfigurable:!1}));l===h.length-1&&(this.toolInstance||(this.toolInstance=i,this.toolInstance.eventBinding()))}),this.pointCloudInstance=g,this.canvasScheduler=m,this.toolScheduler=p,this.config=f}updateConfig(t){this.config=t}updateAttributeList(t){this.config=__spreadProps(__spreadValues({},this.config),{attributeList:t}),this.toolScheduler.syncAllAttributeListInConfig(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 e=createEmptyImage(t),a=new Image;a.src=e,a.onload=()=>{this.toolInstance.setImgNode(a),this.toolInstance.initImgPos()},this.pointCloud2dOperation.setCanvasSize(t)}addPolygonListOnTopView(t){const e=lbUtils.PointCloudUtils.getBoxParamsFromResultList(t),a=lbUtils.PointCloudUtils.getPolygonListFromResultList(t);this.updatePolygonList(e,a)}addLineListOnTopView(t){const e=lbUtils.PointCloudUtils.getLineListFromResultList(t);this.updateLineList(e)}addPointListOnTopView(t){const e=lbUtils.PointCloudUtils.getSphereParamsFromResultList(t);this.updatePointList(e)}updateData(t,e,a){!this.toolInstance||!this.pointCloudInstance||(this.pointCloudInstance.loadPCDFile(t,a==null?void 0:a.radius),this.addPolygonListOnTopView(e),this.addLineListOnTopView(e),this.addPointListOnTopView(e))}switchToCanvas(t){const e=this.toolScheduler.switchToCanvas(t);return e?(e.eventBinding(),this.toolInstance=e,e):this.toolInstance}initAllPosition(){this.pointCloudInstance.updateTopCamera(),this.pointCloud2dOperation.initPosition()}clearAllData(){this.pointCloudInstance.clearPointCloudAndRender(),this.pointCloud2dOperation.clearResult()}}exports.PointCloudAnnotation=PointCloudAnnotation;
@@ -1 +1 @@
1
- import{PointCloudUtils as d}from"@labelbee/lb-utils";import{EToolName as f,EPolygonPattern as R}from"../../constant/tool.js";import{CanvasScheduler as A}from"../../newCore/CanvasScheduler.js";import{PointCloud as j}from"./index.js";import{ToolScheduler as B,HybridToolUtils as E}from"../scheduler.js";var V=Object.defineProperty,x=Object.defineProperties,F=Object.getOwnPropertyDescriptors,y=Object.getOwnPropertySymbols,N=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,w=(n,t,o)=>t in n?V(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,c=(n,t)=>{for(var o in t||(t={}))N.call(t,o)&&w(n,o,t[o]);if(y)for(var o of y(t))U.call(t,o)&&w(n,o,t[o]);return n},u=(n,t)=>x(n,F(t));const S=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 H{constructor({size:t,container:o,pcdPath:i,extraProps:L,config:O,checkMode:b,toolName:p,proxyMode:_}){this.updateLineList=a=>{this.toolScheduler.updateDataByToolName(f.Line,a!=null?a:[])},this.updatePolygonList=(a,l)=>{let s=a.map(e=>{var r;const{polygon2d:I}=this.pointCloudInstance.getBoxTopPolygon2DCoordinate(e);return{id:e.id,sourceID:"",pointList:I,isRect:!0,valid:(r=e.valid)!=null?r:!0,attribute:e.attribute}});l&&(s=s.concat(l.map(e=>{var r;return u(c({},e),{pointList:(r=e==null?void 0:e.pointList)==null?void 0:r.map(I=>d.transferWorld2Canvas(I,this.toolInstance.size))})}))),this.toolScheduler.updateDataByToolName(f.PointCloudPolygon,s)},this.updatePointList=a=>{const l=a==null?void 0:a.map(s=>{var e;const{point2d:r}=this.pointCloudInstance.getSphereTopPoint2DCoordinate(s);return u(c({},r),{id:s.id,sourceID:"",valid:(e=s.valid)!=null?e:!0,attribute:s.attribute,textAttribute:""})});this.toolScheduler.updateDataByToolName(f.Point,l)};const D=this.getDefaultOrthographic(t),T=S(t),h=new Image;h.src=T;const m=new B({container:o,size:t,toolName:p,proxyMode:_}),v=new A({container:o}),C=new j({container:o,noAppend:!0,isOrthographicCamera:!0,orthographicParams:D});i&&C.loadPCDFile(i),v.createCanvas(C.renderer.domElement);const P={size:t,config:JSON.stringify(u(c({},O),{attributeConfigurable:!0,hideAttribute:!0})),imgNode:h,checkMode:b};L&&Object.assign(P,L);let g=[];E.isSingleTool(p)?g=[p]:g=p,g.forEach((a,l)=>{let s;if(a===f.PointCloudPolygon){const e=m.createOperation(a,h,P);e.eventBinding(),e.setPattern(R.Rect),this.toolInstance=e,this.toolInstance.eventBinding(),this.pointCloud2dOperation=e}else s=m.createOperation(a,h,u(c({},P),{textConfigurable:!1}));l===g.length-1&&(this.toolInstance||(this.toolInstance=s,this.toolInstance.eventBinding()))}),this.pointCloudInstance=C,this.canvasScheduler=v,this.toolScheduler=m,this.config=O}updateConfig(t){this.config=t}updateAttributeList(t){this.config=u(c({},this.config),{attributeList:t}),this.toolScheduler.syncAllAttributeListInConfig(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=S(t),i=new Image;i.src=o,i.onload=()=>{this.toolInstance.setImgNode(i),this.toolInstance.initImgPos()},this.pointCloud2dOperation.setCanvasSize(t)}addPolygonListOnTopView(t){const o=d.getBoxParamsFromResultList(t),i=d.getPolygonListFromResultList(t);this.updatePolygonList(o,i)}addLineListOnTopView(t){const o=d.getLineListFromResultList(t);this.updateLineList(o)}addPointListOnTopView(t){const o=d.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.addLineListOnTopView(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{H as PointCloudAnnotation};
1
+ import{PointCloudUtils as u}from"@labelbee/lb-utils";import{EToolName as f,EPolygonPattern as R}from"../../constant/tool.js";import{CanvasScheduler as A}from"../../newCore/CanvasScheduler.js";import{PointCloud as j}from"./index.js";import{ToolScheduler as B,HybridToolUtils as E}from"../scheduler.js";var V=Object.defineProperty,x=Object.defineProperties,F=Object.getOwnPropertyDescriptors,y=Object.getOwnPropertySymbols,N=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,w=(n,t,o)=>t in n?V(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,d=(n,t)=>{for(var o in t||(t={}))N.call(t,o)&&w(n,o,t[o]);if(y)for(var o of y(t))U.call(t,o)&&w(n,o,t[o]);return n},p=(n,t)=>x(n,F(t));const S=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 W{constructor({size:t,container:o,pcdPath:a,extraProps:I,config:O,checkMode:_,toolName:h,proxyMode:b}){this.updateLineList=s=>{const l=(s!=null?s:[]).map(i=>{var e;const r=(e=i.pointList)==null?void 0:e.map(c=>d({i:c},u.transferWorld2Canvas(c,this.toolInstance.size)));return p(d({},i),{pointList:r})});this.toolScheduler.updateDataByToolName(f.Line,l)},this.updatePolygonList=(s,l)=>{let i=s.map(e=>{var r;const{polygon2d:c}=this.pointCloudInstance.getBoxTopPolygon2DCoordinate(e);return{id:e.id,sourceID:"",pointList:c,isRect:!0,valid:(r=e.valid)!=null?r:!0,attribute:e.attribute}});l&&(i=i.concat(l.map(e=>{var r;return p(d({},e),{pointList:(r=e==null?void 0:e.pointList)==null?void 0:r.map(c=>u.transferWorld2Canvas(c,this.toolInstance.size))})}))),this.toolScheduler.updateDataByToolName(f.PointCloudPolygon,i)},this.updatePointList=s=>{const l=s==null?void 0:s.map(i=>{var e;const{point2d:r}=this.pointCloudInstance.getSphereTopPoint2DCoordinate(i);return p(d({},r),{id:i.id,sourceID:"",valid:(e=i.valid)!=null?e:!0,attribute:i.attribute,textAttribute:""})});this.toolScheduler.updateDataByToolName(f.Point,l)};const D=this.getDefaultOrthographic(t),T=S(t),g=new Image;g.src=T;const C=new B({container:o,size:t,toolName:h,proxyMode:b}),v=new A({container:o}),P=new j({container:o,noAppend:!0,isOrthographicCamera:!0,orthographicParams:D});a&&P.loadPCDFile(a),v.createCanvas(P.renderer.domElement);const L={size:t,config:JSON.stringify(p(d({},O),{attributeConfigurable:!0,hideAttribute:!0})),imgNode:g,checkMode:_};I&&Object.assign(L,I);let m=[];E.isSingleTool(h)?m=[h]:m=h,m.forEach((s,l)=>{let i;if(s===f.PointCloudPolygon){const e=C.createOperation(s,g,L);e.eventBinding(),e.setPattern(R.Rect),this.toolInstance=e,this.toolInstance.eventBinding(),this.pointCloud2dOperation=e}else i=C.createOperation(s,g,p(d({},L),{textConfigurable:!1}));l===m.length-1&&(this.toolInstance||(this.toolInstance=i,this.toolInstance.eventBinding()))}),this.pointCloudInstance=P,this.canvasScheduler=v,this.toolScheduler=C,this.config=O}updateConfig(t){this.config=t}updateAttributeList(t){this.config=p(d({},this.config),{attributeList:t}),this.toolScheduler.syncAllAttributeListInConfig(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=S(t),a=new Image;a.src=o,a.onload=()=>{this.toolInstance.setImgNode(a),this.toolInstance.initImgPos()},this.pointCloud2dOperation.setCanvasSize(t)}addPolygonListOnTopView(t){const o=u.getBoxParamsFromResultList(t),a=u.getPolygonListFromResultList(t);this.updatePolygonList(o,a)}addLineListOnTopView(t){const o=u.getLineListFromResultList(t);this.updateLineList(o)}addPointListOnTopView(t){const o=u.getSphereParamsFromResultList(t);this.updatePointList(o)}updateData(t,o,a){!this.toolInstance||!this.pointCloudInstance||(this.pointCloudInstance.loadPCDFile(t,a==null?void 0:a.radius),this.addPolygonListOnTopView(o),this.addLineListOnTopView(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{W as PointCloudAnnotation};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-annotation",
3
- "version": "1.14.0-alpha.16",
3
+ "version": "1.14.0-alpha.17",
4
4
  "description": "Annotation tool collection",
5
5
  "keywords": [
6
6
  "annotation",