@labelbee/lb-annotation 1.14.0-alpha.18 → 1.14.0-alpha.19
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=(
|
|
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:s,extraProps:P,config:f,checkMode:v,toolName:u,proxyMode:L}){this.updateLineList=a=>{const l=(a!=null?a:[]).map(n=>{var o;const r=(o=n.pointList)==null?void 0:o.map(d=>__spreadValues({i:d},lbUtils.PointCloudUtils.transferWorld2Canvas(d,this.toolInstance.size)));return __spreadProps(__spreadValues({},n),{pointList:r})});this.toolScheduler.updateDataByToolName(tool.EToolName.Line,l)},this.updatePolygonList=(a,l)=>{let n=a.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&&(n=n.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,n)},this.updatePointList=a=>{const l=a==null?void 0:a.map(n=>{var o;const{point2d:r}=this.pointCloudInstance.getSphereTopPoint2DCoordinate(n);return __spreadProps(__spreadValues({},r),{id:n.id,sourceID:"",valid:(o=n.valid)!=null?o:!0,attribute:n.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});s&&g.loadPCDFile(s),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((a,l)=>{let n;if(a===tool.EToolName.PointCloudPolygon){const o=p.createOperation(a,c,C);o.eventBinding(),o.setPattern(tool.EPolygonPattern.Rect),this.toolInstance=o,this.toolInstance.eventBinding(),this.pointCloud2dOperation=o}else n=p.createOperation(a,c,__spreadProps(__spreadValues({},C),{textConfigurable:!1}));l===h.length-1&&(this.toolInstance||(this.toolInstance=n,this.toolInstance.eventBinding()))}),this.pointCloudInstance=g,this.canvasScheduler=m,this.toolScheduler=p,this.config=f}updateConfig(t){this.config=t,this.pointCloud2dOperation.setConfig(JSON.stringify(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),s=new Image;s.src=e,s.onload=()=>{this.toolInstance.setImgNode(s),this.toolInstance.initImgPos()},this.pointCloud2dOperation.setCanvasSize(t)}addPolygonListOnTopView(t){const e=lbUtils.PointCloudUtils.getBoxParamsFromResultList(t),s=lbUtils.PointCloudUtils.getPolygonListFromResultList(t);this.updatePolygonList(e,s)}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,s){!this.toolInstance||!this.pointCloudInstance||(this.pointCloudInstance.loadPCDFile(t,s==null?void 0:s.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 u}from"@labelbee/lb-utils";import{EToolName as
|
|
1
|
+
import{PointCloudUtils as u}from"@labelbee/lb-utils";import{EToolName as m,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 J{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(m.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(m.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(m.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 f=[];E.isSingleTool(h)?f=[h]:f=h,f.forEach((s,l)=>{let i;if(s===m.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===f.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,this.pointCloud2dOperation.setConfig(JSON.stringify(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{J as PointCloudAnnotation};
|