rm-graphical-computing 1.0.35 → 1.0.36
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/index.cjs +1 -1
- package/dist/index.js +41 -38
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(e&&(t=e(e=0)),t),s=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),c=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},l=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},u=(n,r,a)=>(a=n==null?{}:e(i(n)),l(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),d=e=>a.call(e,`module.exports`)?e[`module.exports`]:l(t({},`__esModule`,{value:!0}),e);let f=require(`three`);f=u(f);function p(e,t=!1){let n=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),a={},o={},s=e[0].morphTargetsRelative,c=new f.BufferGeometry,l=0;for(let u=0;u<e.length;++u){let d=e[u],f=0;if(n!==(d.index!==null))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.`),null;for(let e in d.attributes){if(!r.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. All geometries must have compatible attributes; make sure "`+e+`" attribute exists among all geometries, or in none of them.`),null;a[e]===void 0&&(a[e]=[]),a[e].push(d.attributes[e]),f++}if(f!==r.size)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. Make sure all geometries have the same number of attributes.`),null;if(s!==d.morphTargetsRelative)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. .morphTargetsRelative must be consistent throughout all geometries.`),null;for(let e in d.morphAttributes){if(!i.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. .morphAttributes must be consistent throughout all geometries.`),null;o[e]===void 0&&(o[e]=[]),o[e].push(d.morphAttributes[e])}if(t){let e;if(n)e=d.index.count;else if(d.attributes.position!==void 0)e=d.attributes.position.count;else return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. The geometry must have either an index or a position attribute`),null;c.addGroup(l,e,u),l+=e}}if(n){let t=0,n=[];for(let r=0;r<e.length;++r){let i=e[r].index;for(let e=0;e<i.count;++e)n.push(i.getX(e)+t);t+=e[r].attributes.position.count}c.setIndex(n)}for(let e in a){let t=m(a[e]);if(!t)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` attribute.`),null;c.setAttribute(e,t)}for(let e in o){let t=o[e][0].length;if(t===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[e]=[];for(let n=0;n<t;++n){let t=[];for(let r=0;r<o[e].length;++r)t.push(o[e][r][n]);let r=m(t);if(!r)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` morphAttribute.`),null;c.morphAttributes[e].push(r)}}return c}function m(e){let t,n,r,i=-1,a=0;for(let o=0;o<e.length;++o){let s=e[o];if(t===void 0&&(t=s.array.constructor),t!==s.array.constructor)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.`),null;if(n===void 0&&(n=s.itemSize),n!==s.itemSize)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.`),null;if(r===void 0&&(r=s.normalized),r!==s.normalized)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.`),null;if(i===-1&&(i=s.gpuType),i!==s.gpuType)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.`),null;a+=s.count*n}let o=new t(a),s=new f.BufferAttribute(o,n,r),c=0;for(let t=0;t<e.length;++t){let r=e[t];if(r.isInterleavedBufferAttribute){let e=c/n;for(let t=0,i=r.count;t<i;t++)for(let i=0;i<n;i++){let n=r.getComponent(t,i);s.setComponent(t+e,i,n)}}else o.set(r.array,c);c+=r.count*n}return i!==void 0&&(s.gpuType=i),s}var h=class extends f.Object3D{constructor(e=document.createElement(`div`)){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position=`absolute`,this.element.style.userSelect=`none`,this.element.setAttribute(`draggable`,!1),this.center=new f.Vector2(.5,.5),this.addEventListener(`removed`,function(){this.traverse(function(e){e.element&&e.element instanceof e.element.ownerDocument.defaultView.Element&&e.element.parentNode!==null&&e.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}};new f.Vector3,new f.Matrix4,new f.Matrix4,new f.Vector3,new f.Vector3;var g=(e,t,n,r,i=1e-8)=>{let a=t.x-e.x,o=t.y-e.y,s=r.x-n.x,c=r.y-n.y,l=a*c-o*s;if(Math.abs(l)<i)return null;let u=((n.x-e.x)*c-(n.y-e.y)*s)/l,d=((n.x-e.x)*o-(n.y-e.y)*a)/l;return u<-i||u>1+i||d<-i||d>1+i?null:{point:new f.Vector3(e.x+u*a,e.y+u*o,e.z)}},_=(e,t,n={})=>{let{fontSize:r=36,fontFamily:i=`sans-serif`,backgroundColor:a=`rgba(0,0,0,0)`,textColor:o=`#ffffff`,padding:s=10,maxWidth:c=256}=n,l=document.createElement(`canvas`).getContext(`2d`);l.font=`bold ${r}px ${i}`;let u=l.measureText(e).width,d=Math.min(u+s*2,c),p=r+s*2,m=document.createElement(`canvas`);m.width=d,m.height=p;let h=m.getContext(`2d`);h.fillStyle=a,h.fillRect(0,0,d,p),h.fillStyle=o,h.font=`bold ${r}px ${i}`,h.textAlign=`center`,h.textBaseline=`middle`,u>c-s*2?v(h,e,d/2,p/2,c,r):h.fillText(e,d/2,p/2);let g=new f.CanvasTexture(m),_=new f.SpriteMaterial({map:g,depthTest:!1,transparent:!0}),y=new f.Sprite(_);y.position.set(t.x,t.y,t.z);let b=.005;return y.scale.set(d*b,p*b,1),y};function v(e,t,n,r,i,a){let o=t.split(``),s=``,c=a*1.2,l=r;for(let t=0;t<o.length;t++){let r=s+o[t];e.measureText(r).width>i&&t>0?(e.fillText(s,n,l),s=o[t],l+=c):s=r}e.fillText(s,n,l)}var y=(e,t,n=.01)=>{let r=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z),i=Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z);if(r<1e-10||i<1e-10)return{parallel:!1,sameDirection:null,angle:NaN};let a={x:e.x/r,y:e.y/r,z:e.z/r},o={x:t.x/i,y:t.y/i,z:t.z/i},s=a.x*o.x+a.y*o.y+a.z*o.z;s=Math.max(-1,Math.min(1,s));let c=Math.acos(Math.abs(s)),l=c<=n;return{parallel:l,sameDirection:l?s>0:null,angle:c}};function b(e,t,n){let r=new f.BufferGeometry,i=[],a=[];e.forEach(e=>i.push(e.x,e.y,e.z)),t.forEach(e=>i.push(e.x,e.y,e.z)),a.push(0,2,1,0,3,2),a.push(4,5,6,4,6,7),a.push(0,1,5,0,5,4),a.push(1,2,6,1,6,5),a.push(2,3,7,2,7,6),a.push(3,0,4,3,4,7),r.setAttribute(`position`,new f.Float32BufferAttribute(i,3)),r.setIndex(a),r.computeVertexNormals();let o=new f.MeshBasicMaterial({color:n==`door`?`green`:`#a7cc00`,transparent:!0,opacity:.5,side:f.DoubleSide});return new f.Mesh(r,o)}var x=class{constructor(e={}){this.config={value:e.value||`0.0000m`,position:e.position||new f.Vector3(0,0,0),style:{fontFamily:e.style?.fontFamily||`Arial, sans-serif`,fontSize:e.style?.fontSize||`16px`,fontWeight:e.style?.fontWeight||`normal`,fontStyle:e.style?.fontStyle||`normal`},backgroundOpacity:e.backgroundOpacity||.7},this.label=null,this.labelElement=null,this.createLabel()}createLabel(){return this.labelElement=document.createElement(`div`),this.labelElement.textContent=this.config.value,this.applyBlackWhiteStyle(),this.label=new h(this.labelElement),this.label.position.copy(this.config.position),this.label}applyBlackWhiteStyle(){let e=this.labelElement.style,t=this.config;e.fontFamily=t.style.fontFamily,e.fontSize=t.style.fontSize,e.fontWeight=t.style.fontWeight,e.fontStyle=t.style.fontStyle,e.color=`#FFFFFF`,e.textShadow=`0 1px 2px rgba(0, 0, 0, 0.5)`,e.backgroundColor=`rgba(0, 0, 0, ${t.backgroundOpacity})`,e.padding=`6px 12px`,e.borderRadius=`4px`,e.position=`absolute`,e.whiteSpace=`nowrap`,e.userSelect=`none`,e.pointerEvents=`none`,e.zIndex=`1000`,e.textAlign=`center`,e.lineHeight=`1.2`}updateValue(e){this.labelElement&&(this.labelElement.textContent=e)}updatePosition(e){this.label&&this.label.position.copy(e)}updateFontStyle(e){if(this.labelElement){let t=this.labelElement.style;e.fontFamily&&(t.fontFamily=e.fontFamily),e.fontSize&&(t.fontSize=e.fontSize),e.fontWeight&&(t.fontWeight=e.fontWeight),e.fontStyle&&(t.fontStyle=e.fontStyle)}}getLabel(){return this.label}getLabelElement(){return this.labelElement}dispose(){this.labelElement&&this.labelElement.parentNode&&this.labelElement.parentNode.removeChild(this.labelElement),this.label=null,this.labelElement=null}},S=e=>{let t=new f.Group,n=new f.Group;if(e&&e.length){let r=`green.red.pink.white.azure.yellow.bisque.grey.blanchedalmond.blue.blueviolet.brown.burlywood.cadetblue.chartreuse.chocolate.coral.cornflowerblue.cornsilk.crimson.cyan.darkblue.darkcyan.darkgoldenrod.darkgray.darkgreen.darkgrey.darkkhaki.darkmagenta.darkolivegreen.darkorange.darkorchid.darkred.darksalmon.darkseagreen.darkslateblue.darkslategray.darkslategrey.darkturquoise.darkviolet.deeppink.deepskyblue.dimgray.dimgrey.dodgerblue.firebrick.floralwhite.forestgreen.fuchsia.gainsboro.ghostwhite.gold.goldenrod.gray.aliceblue.greenyellow.black.honeydew.hotpink.indianred.indigo.ivory.khaki.lavender.lavenderblush.lawngreen.lemonchiffon.lightblue.lightcoral.lightcyan.lightgoldenrodyellow.lightgray.lightgreen.lightgrey.lightpink.lightsalmon.lightseagreen.lightskyblue.lightslategray.lightslategrey.lightsteelblue.lightyellow.lime.limegreen.linen.magenta.maroon.mediumaquamarine.mediumblue.mediumorchid.mediumpurple.mediumseagreen.mediumslateblue.mediumspringgreen.mediumturquoise.mediumvioletred.midnightblue.mintcream.mistyrose.moccasin.navajowhite.navy.oldlace.olive.olivedrab.orange.orangered.orchid.palegoldenrod.palegreen.paleturquoise.palevioletred.papayawhip.peachpuff.peru.pink.plum.powderblue.purple.rebeccapurple.yellow.rosybrown.royalblue.saddlebrown.salmon.sandybrown.seagreen.seashell.sienna.silver.skyblue.slateblue.slategray.slategrey.snow.springgreen.steelblue.tan.teal.thistle.tomato.turquoise.violet.wheat.white.whitesmoke.yellow.yellowgreen`.split(`.`);e.forEach((e,i)=>{let a=r[i],o=new f.Group,{pcdPoints:s,category:c,name:l,center:u,box:d,obbBox:p,contour:m,nline:h,coordinatesByWidth:g,coordinatesByArea:_}=e,v=s.length,y=new f.Box3(new f.Vector3(d.min.x,d.min.y,d.min.z),new f.Vector3(d.max.x,d.max.y,d.max.z)),S=new f.Box3Helper(y,a);o.add(S);let C=new x({value:l,position:new f.Vector3(u.x,u.y,u.z)}).getLabel();o.add(C);let w=new f.InstancedMesh(new f.SphereGeometry(.007,8,8),new f.MeshBasicMaterial({color:a}),v);o.add(w);let T=new f.Matrix4,E=0;if(s.forEach(e=>{T.setPosition(e.x,e.y,e.z),w.setMatrixAt(E,T),E++}),w.instanceMatrix.needsUpdate=!0,h){let e=new f.BufferGeometry;e.setFromPoints([new f.Vector3(h.start.x,h.start.y,h.start.z),new f.Vector3(h.end.x,h.end.y,h.end.z)]);let t=new f.LineBasicMaterial({color:`red`,depthTest:!1,depthWrite:!1});new f.Line(e,t);let n=new f.Vector3().copy(new f.Vector3(h.start.x,h.start.y,h.start.z)).add(new f.Vector3(h.end.x,h.end.y,h.end.z)).multiplyScalar(.5),r=new f.Vector3(h.centerDir.x,h.centerDir.y,h.centerDir.z);new f.ArrowHelper(r,n,1,`red`)}if(m){let e=[];m.forEach((t,n)=>{e.push(new f.Vector3(t.x,t.y,t.z))});let r=new f.BufferGeometry;r.setFromPoints(e);let i=new f.LineBasicMaterial({color:`yellow`,depthTest:!1,depthWrite:!1}),a=new f.Line(r,i);c==`door`?t.add(a):n.add(a)}if(_){let e=[],r=[];_.coordinates.forEach((t,n)=>{e.push(new f.Vector3(t.x,t.y,t.z)),r.length<4&&r.push(new f.Vector3(t.x,t.y,t.z))});let i=new f.BufferGeometry;i.setFromPoints(e);let a=new f.LineBasicMaterial({color:`green`,depthTest:!1,depthWrite:!1}),o=new f.Line(i,a);c==`door`?t.add(o):n.add(o);let s=b(r.map(e=>new f.Vector3(e.x,e.y,_.heightData.minZ)),r.map(e=>new f.Vector3(e.x,e.y,e.z)),c);c==`door`?t.add(s):n.add(s);let[l,u,d]=e,p=l.distanceTo(u),m=new f.Vector3().copy(l).add(u).multiplyScalar(.5);new x({value:String(p.toFixed(3)),position:m}).getLabel();let h=u.distanceTo(d),g=new f.Vector3().copy(u).add(d).multiplyScalar(.5);new x({value:String(h.toFixed(3)),position:g}).getLabel()}if(p){let e=new f.BoxGeometry(p.size.x,p.size.y,p.size.z),r=new f.LineBasicMaterial({color:a,linewidth:2}),i=new f.EdgesGeometry(e),o=new f.LineSegments(i,r),s=new Vector3(p.center.x,p.center.y,p.center.z),l=new Quaternion(p.rotation.x,p.rotation.y,p.rotation.z,p.rotation.w);o.position.copy(s),o.quaternion.copy(l),c==`door`?t.add(o):n.add(o)}})}return{AiProjectionGroup:t,AiProjectionGroup2:n}},C=(e,t,n,r)=>{let i=e,a=[];if(r&&r.length&&(a=r.map(e=>e.clone())),!i||i.length<4)return{};let o=new f.Vector3().subVectors(i[1],i[0]).normalize(),s=new f.Vector3().subVectors(i[3],i[0]).normalize(),c=o.clone().cross(s).normalize(),l=1/0,u=-1/0,d=1/0,p=-1/0;for(let e of i){let t=e.dot(o),n=e.dot(s);t<l&&(l=t),t>u&&(u=t),n<d&&(d=n),n>p&&(p=n)}let m=i[0].dot(c),h=o.clone().multiplyScalar(l).add(s.clone().multiplyScalar(d)).add(c.clone().multiplyScalar(m)),g=o.clone().multiplyScalar(u).add(s.clone().multiplyScalar(d)).add(c.clone().multiplyScalar(m)),_=o.clone().multiplyScalar(u).add(s.clone().multiplyScalar(p)).add(c.clone().multiplyScalar(m)),v=o.clone().multiplyScalar(l).add(s.clone().multiplyScalar(p)).add(c.clone().multiplyScalar(m)),b=[h,g,_,v],x=y(new f.Vector3().subVectors(h,g),new f.Vector3(0,0,1));x&&x.parallel&&(b=[h,v,_,g]);let S=0;if(r.length>0){let e=new f.Vector3().subVectors(b[1],b[0]).normalize(),r=e.clone().negate(),i=new f.Vector3().subVectors(b[3],b[0]).normalize(),o=i.clone().negate(),s=b[0].distanceTo(b[1]),c=b[0].distanceTo(b[3]),l=s/t,u=c/n,d=.001;for(let r=0;r<l;r++){let r=b[0],o=0;for(let s=0;s<u;s++){let s=r.clone().addScaledVector(e,t),c=s.clone().addScaledVector(i,n),l=r.clone().addScaledVector(i,n),u=new f.Vector3().add(r).add(s).add(c).add(l).multiplyScalar(.25);for(let e=0;e<a.length;e++)if(a[e].distanceTo(u)<d){o++;break}r=l}if(o>=u/2)break;S+=o,b[0]=b[0].addScaledVector(e,t),b[3]=b[3].addScaledVector(e,t)}s=b[0].distanceTo(b[1]),l=s/t;for(let e=0;e<l;e++){let e=b[1],o=0;for(let s=0;s<u;s++){let s=e.clone().addScaledVector(r,t),c=s.clone().addScaledVector(i,n),l=e.clone().addScaledVector(i,n),u=new f.Vector3().add(e).add(s).add(c).add(l).multiplyScalar(.25);for(let e=0;e<a.length;e++)if(a[e].distanceTo(u)<d){o++;break}e=l}if(o>=u/2)break;S+=o,b[1]=b[1].addScaledVector(r,t),b[2]=b[2].addScaledVector(r,t)}s=b[0].distanceTo(b[1]),l=s/t;for(let r=0;r<u;r++){let r=b[3],i=0;for(let s=0;s<l;s++){let s=r.clone().addScaledVector(e,t),c=s.clone().addScaledVector(o,n),l=r.clone().addScaledVector(o,n),u=new f.Vector3().add(r).add(s).add(c).add(l).multiplyScalar(.25);for(let e=0;e<a.length;e++)if(a[e].distanceTo(u)<d){i++;break}r=s}if(i>=l/2)break;S+=i,b[2]=b[2].addScaledVector(o,n),b[3]=b[3].addScaledVector(o,n)}}let C=b[0].distanceTo(b[1])*b[0].distanceTo(b[3]);return{facePoints:b,boxArea:C,totalInPlaneNum:S}},w=(e,t,n,r,i=f.MathUtils.degToRad(8))=>{let a=new f.Vector3,o=new f.Vector3;a.subVectors(new f.Vector3(t.x,t.y,0),new f.Vector3(e.x,e.y,0)).normalize(),o.subVectors(new f.Vector3(r.x,r.y,0),new f.Vector3(n.x,n.y,0)).normalize();let s=a.dot(o),c=Math.acos(Math.min(Math.abs(s),1)),l=1-Math.min(c/i,1),u=s>0?`same`:`opposite`;return{parallelism:l,angle:c,angleDeg:f.MathUtils.radToDeg(c),isParallel:c<i,direction:u,vectors:{v1:a,v2:o}}},T=(e,t,n,r)=>{let i=new f.Vector3().subVectors(t,e),a=new f.Vector3().subVectors(r,n),o=i.length(),s=a.length();if(o===0||s===0)return{rate:NaN,angle:NaN,isPerpendicular:!1,isParallel:!1};i.normalize(),a.normalize();let c=Math.abs(i.dot(a)),l=Math.min(1,Math.max(0,c)),u=Math.acos(l),d=f.MathUtils.radToDeg(u),p=1-l;return{rate:p,percent:`${(p*100).toFixed(2)}%`,angle:d,isPerpendicular:Math.abs(d-90)<.01,isParallel:d<.01}},E=(e,t,n=!1)=>new f.Vector3((e.x+t.x)/2,(e.y+t.y)/2,n?0:(e.z+t.z)/2),D=(e,t,n,r,i={})=>{let{parallelAngleMax:a=f.MathUtils.degToRad(10),collinearAngleMax:o=f.MathUtils.degToRad(7),distanceThreshold:s=2,overlapThreshold:c=.01}=i,l=new f.Vector3().subVectors(t,e),u=new f.Vector3().subVectors(r,n),d=l.clone().normalize(),p=u.clone().normalize(),m=f.MathUtils.clamp(d.dot(p),-1,1),h=Math.acos(Math.abs(m)),g=f.MathUtils.radToDeg(h);if(h>a)return{type:`not_parallel`,angleDeg:g,avgPerpendicularDistance:null,maxPerpendicularDistance:null,gap:null,overlap:null,closestDistance:null};m<0&&p.negate();let _=new f.Vector3().addVectors(d,p).normalize(),v=new f.Vector3().addVectors(e,t).multiplyScalar(.5),y=O(n,v,d),b=O(r,v,d),x=(y+b)/2,S=Math.max(y,b),C=e.dot(_),w=t.dot(_),T=n.dot(_),E=r.dot(_),D=Math.min(C,w),A=Math.max(C,w),j=Math.min(T,E),M=Math.max(T,E),N=A-D,P=M-j,F=Math.min(N,P),I=Math.min(A,M)-Math.max(D,j),ee=I<0?-I:0,L=I>0?I:0,R=F>0?L/F:0,z=k(e,t,n,r),B=h<=o&&x<s,V;return B?V=R>.5?`collinear_overlap`:`collinear_gap`:h<=a&&(V=`parallel_offset`),{type:V,angleDeg:g,avgPerpendicularDistance:x,maxPerpendicularDistance:S,gap:ee,overlap:L,closestDistance:z}};function O(e,t,n){let r=new f.Vector3().subVectors(e,t),i=r.dot(n),a=n.clone().multiplyScalar(i);return new f.Vector3().subVectors(r,a).length()}function k(e,t,n,r){let i=new f.Vector3().subVectors(t,e),a=new f.Vector3().subVectors(r,n),o=new f.Vector3().subVectors(n,e),s=i.dot(i),c=i.dot(a),l=a.dot(a),u=i.dot(o),d=a.dot(o),p=s*l-c*c,m,h;p<1e-10?(m=0,h=l===0?0:d/l):(m=(c*d-l*u)/p,h=(s*d-c*u)/p),m=f.MathUtils.clamp(m,0,1),h=l===0?0:f.MathUtils.clamp((c*m+d)/l,0,1),m=s===0?0:f.MathUtils.clamp((c*h-u)/s,0,1);let g=e.clone().add(i.clone().multiplyScalar(m)),_=n.clone().add(a.clone().multiplyScalar(h));return g.distanceTo(_)}var A=(e,t,n,r=.05,i=.02)=>{let[a,o,s,c]=e,l=new f.Vector3().subVectors(o,a),u=new f.Vector3().subVectors(c,a),d=new f.Vector3().crossVectors(l,u).normalize(),p=l.length(),m=u.length(),h=l.clone().normalize(),g=u.clone().normalize(),_=n-r,v=n+r,y=new f.Vector3,b=[],x=Math.ceil(p/i),S=Math.ceil(m/i),C=p/x,w=m/S,T=new Uint8Array(x*S);for(let e=0;e<t.length;e++){y.subVectors(t[e],a);let n=Math.abs(y.dot(d));if(n<_||n>v)continue;let r=y.dot(h),i=y.dot(g);if(r<0||r>p||i<0||i>m)continue;b.push(new f.Vector3(t[e].x,t[e].y,t[e].z));let o=Math.min(Math.floor(r/C),x-1),s=Math.min(Math.floor(i/w),S-1);T[s*x+o]=1}let E=0;for(let e=0;e<T.length;e++)T[e]&&E++;let D=x*S,O=p*m,k=E==0||D==0?0:E/D*O;return{filteredPoints:b,coveragePercent:E==0||D==0?0:E/D*100,quadArea:O,coveredArea:k}},j=(e,t)=>Math.round(Math.max(5,Math.min(350,t*Math.sqrt(e)))),M=e=>{let t=new f.Vector3(e.start.x,e.start.y,e.start.z),n=new f.Vector3(e.end.x,e.end.y,e.end.z),r=t.distanceTo(n),i=e.rooftopPz-e.start.z,a=j(r,100),o=j(i,70),s=i/o,c=new Map;for(let e=0;e<o;e++)c.set((e+1)*s,{count:0,minZ:1/0,maxZ:-1/0});let l=new f.Line3(t,n),u=e.originalPoints,d=new f.Vector3;for(let e=0;e<u.length;e++){let t=u[e],n=l.closestPointToPoint(t,!0,d).distanceTo(t),r=Math.floor(n/s);if(r<o){let e=c.get((r+1)*s);e.count++,t.z<e.minZ&&(e.minZ=t.z),t.z>e.maxZ&&(e.maxZ=t.z)}}let p,m,h=a/2;for(let[e,t]of c)if(t.count>=h){p=t.minZ;break}for(let[e,t]of[...c.entries()].reverse())if(t.count>=h){m=t.maxZ;break}return{minZ:p,maxZ:m}},N=(e,t,n)=>{let r=new f.Plane,i=new f.Vector3(e.x,e.y,e.z),a=new f.Vector3(t.x,t.y,t.z),o=new f.Vector3(t.x,t.y,t.z+5);r.setFromCoplanarPoints(i,a,o);let s=[];n.forEach(e=>{let t=new f.Vector3;r.projectPoint(e,t),t.z=i.z,s.push(t)});let c=new f.Vector3,l=new f.Vector3;r.projectPoint(i,c),r.projectPoint(a,l);let u=new f.Line3(c,l),d=[],p=[],m=new f.Vector3;return s.forEach((e,t)=>{u.closestPointToPoint(e,!0,m).distanceTo(e)<.001?d.push(n[t]):p.push(e)}),{newOriginalPoints:d,newProjectPoints:p}},P=e=>{function t(e,t,n,r,i,a,o,s,c){let l=new f.Line3(e,t),u=new Map,d=new f.Vector3,p=e.clone(),m=t.clone(),h=0;for(;;){let g=new Map,_=0;for(let e=0;e<c.checkResults.length;e++)if(!(c.checkResults[e].allCenterPoints.length/s*100<1))for(let t=0;t<c.checkResults[e].allCenterPoints.length;t++){if(u.has(e)&&u.get(e).removePtsIndex.includes(t))continue;let n=c.checkResults[e].allCenterPoints[t];n=new f.Vector3(n.x,n.y,n.z);let r=l.closestPointToPoint(n,!0,d),a=n.distanceTo(r);Math.abs(a-i)<.01&&(_++,g.has(e)?g.get(e).removePtsIndex.push(t):g.set(e,{index:e,removePtsIndex:[t]}))}if(h==o){e=p,t=m;break}if(_<a/20*18||_==0){g.clear(),o-h<5&&(e=p,t=m,u.clear());break}else{h++;for(let[e,t]of g)u.has(e)?u.get(e).removePtsIndex.push(...t.removePtsIndex):u.set(e,t);g.clear(),e=e.addScaledVector(n,r),t=t.addScaledVector(n,r),l.set(e,t)}}if(u.size>0&&h!=o)for(let[e,t]of u){let n=[],r=[];for(let i=0;i<c.checkResults[e].allCenterPoints.length;i++)t.removePtsIndex.includes(i)||(n.push(c.checkResults[e].allCenterPoints[i]),r.push(c.checkResults[e].originalVertices[i]));c.checkResults[e].allCenterPoints=n,c.checkResults[e].originalVertices=r}}for(let n=0;n<e.length;n++){let r=e[n];if(r.length<.5)continue;let i=-1,a=-1;if(!r.checkResults||r.checkResults.length<=0)continue;if(r.checkResults[0].originalVertices&&r.checkResults[0].originalVertices.length>0){let[e,t,n,o]=r.checkResults[0].originalVertices[0];e=new f.Vector3(e.x,e.y,e.z),t=new f.Vector3(t.x,t.y,t.z),n=new f.Vector3(n.x,n.y,n.z),o=new f.Vector3(o.x,o.y,o.z),i=e.distanceTo(t),a=e.distanceTo(o);let s=y(new f.Vector3().subVectors(e,t).normalize(),new f.Vector3(0,0,1));s&&s.parallel&&([a,i]=[i,a])}if(i<0||a<0)continue;let o=new f.Vector3(r.start.x,r.start.y,r.start.z),s=new f.Vector3(r.end.x,r.end.y,r.end.z),c=o.distanceTo(s),l=r.rooftopPz-r.start.z,u=Math.ceil(c/i),d=Math.ceil(l/a),p=o.clone(),m=s.clone(),h=m.clone().add(new f.Vector3(0,0,l)),g=p.clone().add(new f.Vector3(0,0,l)),_=new f.Vector3().subVectors(m,p).normalize(),v=_.clone().negate();new f.Vector3().subVectors(h,p).normalize().clone().negate();let b=i/2;a/2;let x=c*l/(i*a);t(p,g,_,i,b,d,u,x,r),t(m,h,v,i,b,d,u,x,r),r.start=p,r.end=m;let{newOriginalPoints:S}=N(p,m,r.originalPoints);r.originalPoints=S}},F=(e,t)=>new f.Vector3(e.x,e.y,0).distanceTo(new f.Vector3(t.x,t.y,0)),I=(e,t,n=1e-6)=>{let r=new f.Vector3;return e.closestPointToPoint(t,!0,r),r.distanceTo(t)<n},ee=e=>{let t=0,n=[];for(let r=0;r<e.length;r++)for(let i=r+1;i<e.length;i++){let a=e[r].distanceTo(e[i]);a>t&&(t=a,n=[e[r],e[i]])}return n},L=(e,t,n=.03)=>Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n&&Math.abs(e.z-t.z)<n,R=e=>{let t=[];e.children.forEach(e=>{e.type==`GridHelper`||e.type==`DirectionalLight`||e.type==`AmbientLight`||t.push(e)}),t.forEach(t=>{e.remove(t),B(t)})},z=()=>`#${Math.floor(Math.random()*75+180).toString(16).padStart(2,`0`)}${Math.floor(Math.random()*75+180).toString(16).padStart(2,`0`)}${Math.floor(Math.random()*75+180).toString(16).padStart(2,`0`)}`;function B(e){for(;e.children&&e.children.length>0;){let t=e.children[0];e.remove(t),B(t)}e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(e=>V(e)):V(e.material))}function V(e){for(let t of Object.keys(e)){let n=e[t];n&&typeof n==`object`&&typeof n.dispose==`function`&&n.dispose()}e.dispose()}var te=class{results;clusterResults;constructor(){this.results=null}initLimits1(e,t){let n,r;return n=e<.3?5:e<.5?8:e<.8?10:e<1?15:e<2?30:e<3?35:e<4?40:e<5?45:e<6?50:e<7?60:e<8.5?70:e<10?80:e<15?100:e<20?120:e<25?140:e<30?160:e<35?180:e<40?200:e<45?230:e<50?250:350,t<1?r=30:t<2?r=40:t<2.5?r=45:t<3?r=60:t<3.6?r=70:t<4&&(r=80),{horizontalSubdivisions:n,verticalSubdivisions:r}}initLimits2(e,t){return{horizontalSubdivisions:Math.round(Math.max(5,Math.min(350,e/.08))),verticalSubdivisions:Math.round(Math.max(30,Math.min(80,t/.06)))}}initLimits4(e,t){return{horizontalSubdivisions:Math.round(Math.max(5,Math.min(350,65*Math.sqrt(e))))*1,verticalSubdivisions:Math.round(Math.max(30,Math.min(80,15*Math.sqrt(t))))*1}}initLimits3(e,t){let n;return n=e<2?.06:e<10?.1:.15,{horizontalSubdivisions:Math.round(Math.max(5,Math.min(350,e/n))),verticalSubdivisions:Math.round(Math.max(30,Math.min(80,t/.06)))}}createWallPlaneMeshFromFourPoints(e,t,n,r,i,a,o=16777215){let s=[e,t,n,r];for(let e=0;e<s.length;e++)this.isValidVector3(s[e])||(console.error(`点${e+1}包含无效数据:`,s[e]),s[e]=new f.Vector3(e,0,e));let c=new f.BufferGeometry,l=new Float32Array([s[0].x,s[0].y,s[0].z,s[1].x,s[1].y,s[1].z,s[2].x,s[2].y,s[2].z,s[3].x,s[3].y,s[3].z]),u=[0,1,2,0,2,3],d=new Float32Array([0,0,1,0,1,1,0,1]);c.setAttribute(`position`,new f.BufferAttribute(l,3)),c.setAttribute(`uv`,new f.BufferAttribute(d,2)),c.setIndex(u),c.computeVertexNormals();let p=new f.Mesh(c,i),m=new f.EdgesGeometry(c),h=new f.LineSegments(m,new f.LineBasicMaterial({color:o}));return a.add(h),p}createSubdividedWallPlane(e,t,n,r,i){let a=[];if(!e||!e.start||!e.end||isNaN(e.rooftopPz))return a;let o=new f.Vector3(e.start.x,e.start.y,e.start.z),s=new f.Vector3(e.end.x,e.end.y,e.end.z),c=[o,s,new f.Vector3(e.end.x,e.end.y,e.rooftopPz),new f.Vector3(e.start.x,e.start.y,e.rooftopPz)];for(let e=0;e<c.length;e++)if(!this.isValidVector3(c[e]))return console.error(`墙体基础点${e}无效:`,c[e]),a;let l=o.distanceTo(s),u=Math.abs(e.rooftopPz-e.start.z);if(l===0||u===0)return console.error(`墙体宽度或高度为0`),console.log(`line.rooftopPz`,e.rooftopPz),console.log(`bottomLeft`,o),console.log(`bottomRight`,s),console.log(e.length),a;let d=l/n,p=u/t,m=new f.Vector3().subVectors(s,o).normalize(),h=new f.Vector3(0,0,1);for(let e=0;e<t;e++)for(let t=0;t<n;t++)try{let n={points:[new f.Vector3().copy(o).add(m.clone().multiplyScalar(t*d)).add(h.clone().multiplyScalar(e*p)),new f.Vector3().copy(o).add(m.clone().multiplyScalar((t+1)*d)).add(h.clone().multiplyScalar(e*p)),new f.Vector3().copy(o).add(m.clone().multiplyScalar((t+1)*d)).add(h.clone().multiplyScalar((e+1)*p)),new f.Vector3().copy(o).add(m.clone().multiplyScalar(t*d)).add(h.clone().multiplyScalar((e+1)*p))],userData:{}};n.userData={type:`wallSegment`,row:e,col:t,originalMaterial:r,width:d,height:p},a.push(n)}catch(n){console.error(`创建墙体小平面(${e}, ${t})时出错:`,n)}return a}calculateMinRequiredPoints(e){let t=Math.floor(Math.log1p(e)*.5);return Math.max(1,t)}calculateExpectedDensity(e){return e<1?10:e<4?5:2}evaluateSegmentByArea(e,t,n,r){if(t===0)return!1;let i=e.area,a=e.minRequiredPoints,o=e.expectedDensity,s=t/Math.max(i,.001),c=t>=a,l=s>=o*.3,u=!0;return i<.5&&t>0&&(u=this.checkSmallAreaDistribution(e,n,r)),c&&l&&u}checkSmallAreaDistribution(e,t,n){if(t.length<2)return!0;let r=t.map(e=>n[e]);e.bounds;let i=e.center,a=0,o=Math.sqrt(e.area)*.3;return r.forEach(e=>{e.distanceTo(i)<=o&&a++}),a/r.length>=.3}getFailureReason(e,t){let n=e.area,r=e.minRequiredPoints,i=e.expectedDensity,a=t/Math.max(n,.001),o=[];return t===0?o.push(`无点`):(t<r&&o.push(`点数不足: ${t}/${r}`),a<i*.3&&o.push(`密度不足: ${a.toFixed(2)}/${i.toFixed(2)}`),n<.5&&t>0&&(this.checkSmallAreaDistribution(e,[],[])||o.push(`小平面分布不均`))),o.length>0?o.join(`, `):`未知原因`}calculateMedian(e){let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2==0?(t[n-1]+t[n])/2:t[n]}isPointInBoundingBox(e,t,n=.1){return e.x>=t.min[0]-n&&e.x<=t.max[0]+n&&e.y>=t.min[1]-n&&e.y<=t.max[1]+n&&e.z>=t.min[2]-n&&e.z<=t.max[2]+n}getSegmentPlane(e){let t=e.geometry;if(!t||!t.attributes.position)return null;let n=t.attributes.position;if(n.count<3)return null;let r=new f.Vector3().fromBufferAttribute(n,0),i=new f.Vector3().fromBufferAttribute(n,1),a=new f.Vector3().fromBufferAttribute(n,2);r.applyMatrix4(e.matrixWorld),i.applyMatrix4(e.matrixWorld),a.applyMatrix4(e.matrixWorld);let o=new f.Plane;return o.setFromCoplanarPoints(r,i,a),o}analyzePointDistribution(e,t,n=.01){this.results={totalSegments:0,segmentsWithPoints:0,segmentsWithoutPoints:0,missingSegments:[],pointsInSegments:new Map,segmentsByPoint:new Map,segmentDetails:new Map,tolerance:n,analysisTime:null};let r=performance.now(),i=[];e.forEach(e=>{if(e.userData&&e.userData.type===`wallSegment`){let t=this.getWorldVerticesNew(e.points);if(t.length<4)return;let n=new f.Vector3().add(t[0]).add(t[1]).add(t[2]).add(t[3]).multiplyScalar(.25);e.userData.center=n,e.vertices=t,i.push(e)}}),this.results.totalSegments=i.length;for(let e of i){if(e.vertices.length<4)continue;let r=e.userData.center,i=`row${e.userData.row}_col${e.userData.col}`,[a,o,s,c]=e.vertices,l=new f.Vector3().subVectors(o,a).normalize(),u=new f.Vector3().subVectors(c,a).normalize(),d=a.distanceTo(o),p=a.distanceTo(c),m=new f.Plane;m.setFromCoplanarPoints(a,o,c);let h=d/2,g=p/2;for(let e=0;e<t.length;e++)this.isPointInWallSegmentOptimized(t[e],r,m,a,l,u,d,p,h,g,n)&&(this.results.pointsInSegments.has(i)||this.results.pointsInSegments.set(i,[]),this.results.pointsInSegments.get(i).push(e))}return i.forEach(e=>{let t=`row${e.userData.row}_col${e.userData.col}`,n=this.results.pointsInSegments.has(t)?this.results.pointsInSegments.get(t).length:0;n>=1?this.results.segmentsWithPoints++:(this.results.segmentsWithoutPoints++,this.results.missingSegments.push({row:e.userData.row,col:e.userData.col,width:e.userData.width,height:e.userData.height,segmentKey:t,vertices:e.vertices,center:e.userData.center,mesh:e,pointCount:n,hasPointsButNotEnough:n>0&&n<1}))}),this.results.analysisTime=performance.now()-r,this.printAnalysisResults(),this.results}isPointInWallSegmentOptimized(e,t,n,r,i,a,o,s,c,l,u){if(Math.abs(n.distanceToPoint(e))>u)return!1;let d=new f.Vector3().subVectors(e,t),p=Math.abs(d.dot(i)),m=Math.abs(d.dot(a));if(p>c&&m>l)return!1;let h=new f.Vector3().subVectors(e,r),g=h.dot(i),_=h.dot(a),v=g>=-u&&g<=o+u,y=_>=-u&&_<=s+u;return v&&y}isPointInWallSegment(e,t,n,r=.1){if(!e.geometry)return!1;try{let i=this.getWorldVertices(e);return i.length<4?!1:this.isPointInRotatedWall(i,t,n,r)}catch(e){return console.error(`判断点是否在墙体平面内时出错:`,e),!1}}isPointInRotatedWall(e,t,n,r=.1){let[i,a,o,s]=e,c=new f.Plane;if(c.setFromCoplanarPoints(i,a,s),Math.abs(c.distanceToPoint(t))>r)return!1;let l=new f.Vector3().subVectors(a,i).normalize(),u=new f.Vector3().subVectors(s,i).normalize();new f.Vector3().crossVectors(l,u).normalize();let d=new f.Vector3().subVectors(t,i),p=d.dot(l),m=d.dot(u),h=i.distanceTo(a),g=i.distanceTo(s),_=p>=-r&&p<=h+r,v=m>=-r&&m<=g+r;return _&&v&&n.distanceTo(t)<h/2&&n.distanceTo(t)<g/2}getWorldVertices(e){if(e._cachedWorldVertices&&e.matrixWorld.equals(e._cachedMatrixWorld))return e._cachedWorldVertices;let t=e.geometry.getAttribute(`position`),n=[];for(let r=0;r<Math.min(4,t.count);r++){let i=new f.Vector3;i.fromBufferAttribute(t,r),i.applyMatrix4(e.matrixWorld),n.push(i)}return e._cachedWorldVertices=n,e._cachedMatrixWorld=e.matrixWorld.clone(),n}getWorldVerticesNew(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n].clone();t.push(r)}return t}getWallSegmentBounds(e){if(!e.geometry)return null;let t=e.geometry.getAttribute(`position`),n=new f.Box3;for(let r=0;r<t.count;r++){let i=new f.Vector3;i.fromBufferAttribute(t,r),i.applyMatrix4(e.matrixWorld),n.expandByPoint(i)}return{min:n.min.toArray(),max:n.max.toArray(),center:n.getCenter(new f.Vector3).toArray(),size:n.getSize(new f.Vector3).toArray()}}highlightEmptySegments(e,t,n,r=1){if(!this.results){console.warn(`请先运行分析函数`);return}let i=new Map,a=new Map;this.results.missingSegments.forEach(e=>{i.set(e.segmentKey,e),a.has(e.row)||a.set(e.row,new Map),a.get(e.row).set(e.col,{segmentKey:e.segmentKey,isEmpty:!0,visited:!1})}),e.forEach(e=>{if(e.userData&&e.userData.type===`wallSegment`){let t=`row${e.userData.row}_col${e.userData.col}`,n=i.has(t);a.has(e.userData.row)||a.set(e.userData.row,new Map),a.get(e.userData.row).has(e.userData.col)||a.get(e.userData.row).set(e.userData.col,{segmentKey:t,isEmpty:n,visited:!1})}});let o=[],s=[[0,1],[1,0],[0,-1],[-1,0]];for(let[e,t]of i){let e=a.get(t.row)?.get(t.col);if(e&&!e.visited){let n=[],c=[[t.row,t.col]];for(e.visited=!0;c.length>0;){let[e,t]=c.shift(),r=`row${e}_col${t}`;i.has(r)&&n.push(i.get(r));for(let[n,r]of s){let i=e+n,o=t+r;if(a.has(i)&&a.get(i).has(o)){let e=a.get(i).get(o);!e.visited&&e.isEmpty&&(e.visited=!0,c.push([i,o]))}}}n.length>=r&&o.push(n)}}let c=this.createClusterMaterials(o.length),l=[];return this.clusterResults={clusters:o.sort((e,t)=>t.length-e.length),highlightedMeshes:l,clusterMaterials:c,totalClusters:o.length,totalHighlighted:l.length},this.clusterResults}calculateBoundaryRegularity(e,t,n,r,i){let a=0,o=0,s=t,c=!0;for(let t=r;t<=i;t++)e.has(s)&&e.get(s).has(t)?o++:c=!1;c&&a++;let l=n,u=!0;for(let t=r;t<=i;t++)e.has(l)&&e.get(l).has(t)?o++:u=!1;u&&a++;let d=r,f=!0;for(let r=t;r<=n;r++)e.has(r)&&e.get(r).has(d)?o++:f=!1;f&&a++;let p=i,m=!0;for(let r=t;r<=n;r++)e.has(r)&&e.get(r).has(p)?o++:m=!1;return m&&a++,a/4}calculateClusterQualityScore(e){let t=1/Math.max(1,e.aspectRatio);return e.compactness*.4+e.boundaryRegularity*.4+t*.2}calculateStrictClusterBounds(e){if(e.length===0)return{width:0,height:0};let t=[];if(e.forEach(e=>{e.vertices&&e.vertices.length>0&&t.push(...e.vertices)}),t.length===0){let t=[...new Set(e.map(e=>e.row))];return{width:[...new Set(e.map(e=>e.col))].length*(e[0].bounds?.width||1),height:t.length*(e[0].bounds?.height||1)}}let n=Math.min(...t.map(e=>e.x)),r=Math.max(...t.map(e=>e.x)),i=Math.min(...t.map(e=>e.y)),a=Math.max(...t.map(e=>e.y)),o=Math.min(...t.map(e=>e.z)),s=Math.max(...t.map(e=>e.z));return{width:Math.abs(r-n),height:Math.max(Math.abs(a-i),Math.abs(s-o))}}createClusterMaterials(e){let t=[],n=[16711935,65535,16753920,16738740,9055202,3329330,`lavenderblush`,`lawngreen`,`lemonchiffon`,`lightblue`,`lightcoral`];for(let r=0;r<e;r++){let e=n[r%n.length],i=new f.MeshBasicMaterial({color:e,transparent:!0,opacity:.6,side:f.DoubleSide});t.push(i)}return t}clearHighlights(e){this.clusterResults&&this.clusterResults.highlightedMeshes&&(this.clusterResults.highlightedMeshes.forEach(t=>{e.remove(t),t.material&&t.material.dispose()}),this.results&&this.results.segmentDetails&&this.results.segmentDetails.forEach((e,t)=>{e.mesh&&e.mesh.userData.originalMaterial&&(e.mesh.material=e.mesh.userData.originalMaterial)}),this.clusterResults.highlightedMeshes=[])}getClusterInfo(){return this.clusterResults?{totalClusters:this.clusterResults.totalClusters,clusterSizes:this.clusterResults.clusters.map((e,t)=>({clusterIndex:t,size:e.length,segments:e.map(e=>e.segmentKey)})),largestCluster:Math.max(...this.clusterResults.clusters.map(e=>e.length)),smallestCluster:Math.min(...this.clusterResults.clusters.map(e=>e.length))}:null}restoreOriginalMaterials(e){let t=0;e.traverse(e=>{e.userData&&e.userData.originalMaterial&&(e.material=e.userData.originalMaterial,delete e.userData.originalMaterial,t++)}),console.log(`恢复了 ${t} 个平面的原始材质`)}createDebugHelpers(e){let t=new f.Group;return e.traverse(e=>{if(e.userData&&e.userData.type===`wallSegment`){let n=this.getWorldVertices(e);if(n.length<4)return;let r=new f.Vector3().add(n[0]).add(n[1]).add(n[2]).add(n[3]).multiplyScalar(.25),i=new f.Vector3().subVectors(n[1],n[0]).normalize(),a=new f.Vector3().subVectors(n[3],n[0]).normalize(),o=new f.Vector3().crossVectors(i,a).normalize(),s=new f.ArrowHelper(o,r,.3,16711680),c=new f.ArrowHelper(i,r,.2,65280),l=new f.ArrowHelper(a,r,.2,255);t.add(s),t.add(c),t.add(l)}}),t}printAnalysisResults(){if(!this.results){console.warn(`没有可用的分析结果`);return}this.results.missingSegments.length>0&&this.results.missingSegments.forEach(e=>{}),this.results.pointsInSegments.forEach((e,t)=>{})}isValidVector3(e){return e&&!isNaN(e.x)&&!isNaN(e.y)&&!isNaN(e.z)&&isFinite(e.x)&&isFinite(e.y)&&isFinite(e.z)}mergeWallGroupMeshes(e){let t=[];if(e.traverse(e=>{e.isMesh&&e.geometry&&t.push(e)}),t.length===0)return null;try{let e=t.map(e=>e.geometry);e.forEach((e,n)=>{e.applyMatrix4(t[n].matrixWorld)});let n=p(e),r=t[0].material.clone(),i=new f.Mesh(n,r);return i.name=`mergedWalls`,i}catch(e){return console.error(`合并网格时出错:`,e),null}}},ne=e=>{let t={},n=[],r=[],i=[];return e[0].width,e[0].height,e.forEach(e=>{r.push(...e.vertices),i.push(e.center),n.push(e.vertices)}),t.originalVertices=n,t.allCenterPoints=i,t},re=e=>{let t=new f.Vector3().copy(e.start).add(e.end).multiplyScalar(.5),n=new f.Vector3().subVectors(new f.Vector3(t.x,t.y,t.z+1),t).normalize(),r=new f.Vector3(e.direction.x,e.direction.y,0);r.applyAxisAngle(n,Math.PI/2);let i=new f.Vector3().copy(t).add(r.clone().multiplyScalar(e.length)),a=new f.Vector3().copy(t).sub(r.clone().multiplyScalar(e.length));return t.z=e.start.z,i.z=e.start.z,a.z=e.start.z,{start:i,end:a,center:t,direction:r}},ie=(e,t,n=!0)=>{let r=[];if(!e)return[];for(let i=0;i<e.length;i++){let a=e[i];if(!a)continue;let o=new f.Vector3(a.start.x,a.start.y,a.start.z);o.applyEuler(new f.Euler(-Math.PI/2,0,0));let s=new f.Vector3(a.end.x,a.end.y,a.end.z);if(s.applyEuler(new f.Euler(-Math.PI/2,0,0)),t.add(_(String(i),new f.Vector3((o.x+s.x)/2,(o.y+s.y)/2,(o.z+s.z)/2))),(a.isBayWindow||a.isWindow)&&n)continue;let c=new f.Plane().setFromCoplanarPoints(new f.Vector3(a.start.x,a.start.y,a.start.z),new f.Vector3(a.end.x,a.end.y,a.end.z),new f.Vector3(a.start.x,a.start.y,a.rooftopPz)),l=[];a.originalPoints.forEach((e,t)=>{let n=new f.Vector3;c.projectPoint(e,n),l.push(n)});let u=new f.Vector3(a.start.x,a.start.y,a.start.z).distanceTo(new f.Vector3(a.end.x,a.end.y,a.end.z)),d=Math.abs(a.rooftopPz-a.start.z),p=new f.MeshBasicMaterial({color:`red`,side:f.DoubleSide,wireframe:!1,transparent:!0,opacity:.5}),m=new f.Group,h=new te,{horizontalSubdivisions:g,verticalSubdivisions:v}=h.initLimits4(u,d),y=h.createSubdividedWallPlane(a,v,g,p,m);h.analyzePointDistribution(y,l,.01);let b=new f.MeshBasicMaterial({color:`black`,transparent:!0,opacity:.8,side:f.DoubleSide}),x=h.highlightEmptySegments(y,b,m),S=[];for(let e of x.clusters){let t=ne(e);t&&S.push(t)}let C=re(a).direction;a.checkResults=S,a.verticalDirection=C,a.originaIndex=i,r.push(a)}return r},ae=async(e,t,n,r)=>{R(r);let i=await fetch(e);if(!i)return;let a=await i.json(),o=new f.Group,s=new f.Group,c=new f.Group,l=new f.Group,u=new f.Group,d=new f.Group,m=new f.Group,h=new f.Group;for(let e=0;e<a.length;e++){let t=a[e];if(!t)continue;let n=new f.Vector3(t.start.x,t.start.y,t.start.z);n.applyEuler(new f.Euler(-Math.PI/2,0,0));let r=new f.Vector3(t.end.x,t.end.y,t.end.z);r.applyEuler(new f.Euler(-Math.PI/2,0,0)),h.add(_(String(e),new f.Vector3((n.x+r.x)/2,(n.y+r.y)/2,(n.z+r.z)/2)))}a.sort((e,t)=>e.originalIndex-t.originalIndex),console.log(`lins`,a);let g=await fetch(t);if(!g)return;let v=await g.json(),y=Array.isArray(v)?v:Object.values(v),b=await fetch(n);if(console.log(`respcd`,b),!b)return;let x=await b.json(),C=0;for(let e=0;e<x.length;e++){let t=x[e];if(t.isFindBeam=!1,t.category==`door`){let e=new f.Vector3(t.center.x,t.center.y,t.center.z);e.applyEuler(new f.Euler(-Math.PI/2,0,0)),h.add(_(`door:${C}`,e)),C++}}r.add(h),console.time();let{beamGroup:w}=await oe(a,y,x,r);console.timeEnd(),console.log(`beamGroup`,w);let T=new f.MeshBasicMaterial({color:`#cffd00`,transparent:!0,opacity:.4,side:f.DoubleSide}),E=new f.MeshBasicMaterial({color:`#ff0000`,transparent:!0,opacity:.4,side:f.DoubleSide}),D=new f.MeshBasicMaterial({color:`#e100ff`,transparent:!0,opacity:.4,side:f.DoubleSide}),O=new f.MeshBasicMaterial({color:`#0400ff`,transparent:!0,opacity:.4,side:f.DoubleSide}),k=new f.LineBasicMaterial({color:`#cffd00`}),A=[];for(let e=0;e<a.length;e++){let t=a[e];if(t.checkResults)for(let e of t.checkResults)for(let t of e.originalVertices){let[e,n,r,i]=t,a=new f.BufferGeometry,o=new Float32Array([e.x,e.y,e.z,n.x,n.y,n.z,r.x,r.y,r.z,i.x,i.y,i.z]);a.setAttribute(`position`,new f.BufferAttribute(o,3)),a.setIndex([0,1,2,0,2,3]),a.computeVertexNormals();let s=new f.EdgesGeometry(a,1);A.push(s)}}if(A.length>0){let e=p(A,!1);e.rotateX(-Math.PI/2),o.add(new f.LineSegments(e,k)),o.visible=!1,r.add(o),A.forEach(e=>e.dispose())}new f.PointsMaterial({color:65535,size:.01});for(let e of a){if(!e.originalPoints||e.originalPoints.length===0)continue;let t=new Float32Array(e.originalPoints.length*3);e.originalPoints.forEach((e,n)=>{t[n*3]=e.x,t[n*3+1]=e.y,t[n*3+2]=e.z});let n=new f.BufferGeometry;n.setAttribute(`position`,new f.BufferAttribute(t,3)),n.rotateX(-Math.PI/2),s.add(new f.Points(n,new f.PointsMaterial({color:z(),size:.02})));let r=[];r.push(new f.Vector3(e.start.x,e.start.y,e.start.z)),r.push(new f.Vector3(e.end.x,e.end.y,e.end.z));let i=new f.BufferGeometry;i.setFromPoints(r),i.rotateX(-Math.PI/2),d.add(new f.Line(i,k))}d.visible=!1,r.add(s),r.add(d);let j=[],M=[],N=new f.LineBasicMaterial({color:`#f30606`}),P=new f.MeshBasicMaterial({color:`#071ac4`});for(let e=0;e<y.length;e++){let t=new f.SphereGeometry(.05);t.translate(y[e].x,y[e].y,y[e].z);let n=[],r=new f.Vector3(y[e].x,y[e].y,y[e].z),i=new f.Quaternion(y[e].qx,y[e].qy,y[e].qz,y[e].qw),a=new f.Vector3(0,0,-1).applyQuaternion(i),o=r.clone().addScaledVector(a,.001);n.push(r),n.push(o);let s=new f.BufferGeometry;s.setFromPoints(n),M.push(s),j.push(t)}if(j.length>0){let e=p(j,!1);e.rotateX(-Math.PI/2),c.add(new f.Mesh(e,P)),j.forEach(e=>e.dispose())}if(M.length>0){let e=p(M,!1);e.rotateX(-Math.PI/2),c.add(new f.Line(e,N)),M.forEach(e=>e.dispose())}r.add(c);let{AiProjectionGroup:F,AiProjectionGroup2:I}=S(x);return l.add(F),l.rotateX(-Math.PI/2),r.add(l),u.add(I),u.visible=!1,u.rotateX(-Math.PI/2),r.add(u),console.log(`jsonpcdData`,x),a.forEach(e=>{e.doorAndBeamData&&e.doorAndBeamData.length>0&&(e.doorAndBeamData.forEach(e=>{if(e.beamStart){let t=new f.BufferGeometry,n=new Float32Array([e.beamStart.x,e.beamStart.y,e.beamStart.z,e.beamEnd.x,e.beamEnd.y,e.beamEnd.z,e.beamEnd.x,e.beamEnd.y,e.beamEnd.z+e.beamHeight,e.beamStart.x,e.beamStart.y,e.beamStart.z+e.beamHeight]);t.setAttribute(`position`,new f.BufferAttribute(n,3)),t.setIndex([0,1,2,0,2,3]),t.computeVertexNormals(),t.rotateX(-Math.PI/2),m.add(new f.Mesh(t,T))}let t=new f.BufferGeometry,n=new Float32Array([e.doorStart.x,e.doorStart.y,e.doorStart.z,e.doorEnd.x,e.doorEnd.y,e.doorEnd.z,e.doorEnd.x,e.doorEnd.y,e.doorEnd.z+e.doorHeight,e.doorStart.x,e.doorStart.y,e.doorStart.z+e.doorHeight]);t.setAttribute(`position`,new f.BufferAttribute(n,3)),t.setIndex([0,1,2,0,2,3]),t.computeVertexNormals(),t.rotateX(-Math.PI/2),e.isDoor?m.add(new f.Mesh(t,O)):e.type==`beam`?m.add(new f.Mesh(t,D)):m.add(new f.Mesh(t,E));let r=`id:${e.id},Nid:${e.nearId}`,i=new f.Vector3((e.doorStart.x+e.doorEnd.x)/2,(e.doorStart.y+e.doorEnd.y)/2,e.doorStart.z+e.doorHeight);i.applyEuler(new f.Euler(-Math.PI/2,0,0)),m.add(_(r,i))}),r.add(m))}),{checkResultGroup:o,pointCloudGroup:s,runData:c,pcdGroup:l,pcdGroup2:u,pointLineGroup:d,beamDoorGroup:m,lineIndexGroup:h}},oe=async(e,t,n,r)=>{if(P(e,r),e.length<=0||t.length<=0)return e;n||=[];for(let t of e){let e=[];if(!(!t.checkResults||t.checkResults.length<=0)){for(let n=0;n<t.checkResults.length;n++){let r=t.checkResults[n];if(r.isDoor=!1,!r.originalVertices||r.originalVertices.length==0)continue;let i=[];r.originalVertices.forEach(e=>{let t=[];e.forEach(e=>{t.push(new f.Vector3(e.x,e.y,e.z))}),i.push(t)});let a=i.length,o=Array.from({length:a},(e,t)=>t);function s(e){for(;o[e]!==e;)o[e]=o[o[e]],e=o[e];return e}for(let e=0;e<a;e++)for(let t=e+1;t<a;t++){let n=i[e],r=i[t];if(n.some(e=>r.some(t=>e.equals(t)))){let n=s(e),r=s(t);n!==r&&(o[n]=r)}}let c=new Map,l=-1,u=-1;for(let e=0;e<a;e++){let t=s(e);c.has(t)||c.set(t,{points:[],area:0,originalVertices:[],index:-1,gridWidth:-1,gridHeight:-1,centerPts:[]});let r=c.get(t),[a,o,d,p]=i[e],m=new f.Vector3().add(a).add(o).add(d).add(p).multiplyScalar(.25);if(r.points.push(...i[e]),r.area+=a.distanceTo(o)*a.distanceTo(p),r.originalVertices.push(i[e]),r.index=n,r.centerPts.push(m),l==-1||u==-1){let e=new f.Vector3().subVectors(a,o).normalize();u=a.distanceTo(p),l=a.distanceTo(o);let t=y(e,new f.Vector3(0,0,1));t&&t.parallel&&([u,l]=[l,u])}r.gridWidth=l,r.gridHeight=u}e.push(...c.values())}t.mergeCheckRegion=e}}let i=new Map;for(let t of e){if(t.length<.3)continue;let e=t.rooftopPz-t.start.z,n=Math.floor(t.rooftopPz-t.start.z);i.has(n)?i.set(n,{num:i.get(n).num+1,totalHeight:i.get(n).totalHeight+e}):i.set(n,{num:1,totalHeight:e})}let a=[...i.entries()].reduce((e,t)=>t[1].num>e[1].num?t:e),o=a[0];a[1].totalHeight/a[1].num;let s=[];for(let e=0;e<n.length;e++){let t=n[e];if(t.isFindBeam=!1,t.category==`door`){let n=[];t.coordinatesByArea.coordinates.forEach(e=>{n.push(new f.Vector3(e.x,e.y,e.z))}),n[0].equals(n[n.length-1])&&n.pop();let r=n[0].distanceTo(n[1]),i=n[0].distanceTo(n[3]);i>r&&([r,i]=[i,r],n=[n[0],n[3],n[2],n[1]]);let a=E(n[0],n[3],!0),o=E(n[1],n[2],!0);s.push({doorStartPt:a,doorEndPt:o,boxPoints:n,minZ:t.coordinatesByArea.heightData.minZ,maxZ:t.coordinatesByArea.heightData.maxZ,index:e,isFind:!1,inWall:!1})}}for(let t=0;t<s.length;t++){let n=s[t];for(let t=0;t<e.length;t++){if(e[t].length<.5)continue;let r=[],i=E(e[t].start,e[t].end,!0);r.push(i),r.push(E(i,e[t].start,!0)),r.push(E(i,e[t].end,!0));let a=!1,o=n.boxPoints.length;for(let e=0;e<r.length;e++){let t=r[e].x,i=r[e].y;for(let e=0,r=o-1;e<o;r=e++){let o=n.boxPoints[e].x,s=n.boxPoints[e].y,c=n.boxPoints[r].x,l=n.boxPoints[r].y;s>i!=l>i&&t<(c-o)*(i-s)/(l-s)+o&&(a=!a)}if(a)break}if(a){let r=new f.Vector3(e[t].start.x,e[t].start.y,0),i=new f.Vector3(e[t].end.x,e[t].end.y,0),a=n.doorStartPt.distanceTo(n.doorEndPt),o=r.distanceTo(i),s=w(n.doorStartPt,n.doorEndPt,r,i);if(Math.abs(o-a)<.5&&s&&s.isParallel){n.doorStartPt=new f.Vector3(e[t].start.x,e[t].start.y,0),n.doorEndPt=new f.Vector3(e[t].end.x,e[t].end.y,0);break}else if(Math.abs(o-a)>1.3&&s&&s.isParallel){let e=D(n.doorStartPt,n.doorEndPt,r,i),t=n.doorStartPt.distanceTo(r),a=n.doorStartPt.distanceTo(i),o=n.doorEndPt.distanceTo(r),s=n.doorEndPt.distanceTo(i),c=t<.2||a<.2||o<.2||s<.2;if(e&&e.type==`collinear_overlap`&&e.maxPerpendicularDistance<.1&&!c){n.inWall=!0;break}}}else continue}}let c=0,l=[],u=[],d=[],p=[],m=.2;for(let r=0;r<e.length;r++){let i=e[r];if(!i.mergeCheckRegion||i.mergeCheckRegion.length==0)continue;i.doorAndBeamData=[],i.completePointAreaPercentage=-1;let a=new f.Box3;a.setFromPoints(i.originalPoints);let h=a.max.z,_=a.min.z,v=new f.Vector3(i.start.x,i.start.y,i.start.z),b=new f.Vector3(i.end.x,i.end.y,i.end.z),x=i.rooftopPz-i.start.z;if(x<o-.5||x>o+2)continue;let S=0;for(let a of i.mergeCheckRegion){let{facePoints:o,boxArea:O,totalInPlaneNum:k}=C(a.points,a.gridWidth,a.gridHeight,a.centerPts);if(!o||o.length<=0)continue;o[0].distanceTo(o[1]);let A=o[0].distanceTo(o[3]),j=a.gridHeight*(A/a.gridHeight/3*2)+a.gridHeight/2,M=new f.Vector3(o[0].x,o[0].y,o[0].z+j),P=new f.Vector3(o[1].x,o[1].y,o[1].z+j),L=new f.Line3(M,P),R=[],z=new f.Vector3;a.points.forEach(e=>{L.closestPointToPoint(e,!0,z).distanceTo(e)<a.gridHeight+.01&&R.push(e)});let B=[],V=[];for(;;){let e=[];for(let t=0;t<R.length;t++)V.includes(t)||e.length==0&&(e.push(R[t]),V.push(t));for(let t=0;t<R.length;t++)if(!V.includes(t)){for(let n=0;n<e.length;n++)if(R[t].distanceTo(e[n])<a.gridWidth+.01){e.push(R[t]),V.push(t),t=-1;break}}if(e.length==0)break;B.push(e)}let te=[];for(let e=0;e<B.length;e++){let t={lineSt:new f.Vector3,lineEd:new f.Vector3,facePoints:[]},n=ee(B[e]);Array.isArray(n)&&n.length==2&&(t.lineSt=n[0],t.lineEd=n[1],t.facePoints.push(new f.Vector3(n[0].x,n[0].y,o[0].z)),t.facePoints.push(new f.Vector3(n[1].x,n[1].y,o[0].z)),t.facePoints.push(new f.Vector3(n[1].x,n[1].y,o[2].z)),t.facePoints.push(new f.Vector3(n[0].x,n[0].y,o[2].z)),te.push(t))}S+=a.area;let ne=0;if(k!=0&&(ne=a.gridHeight*a.gridWidth*k),(a.area-ne)/O*100>70&&te.length==1||te.length>1)for(let o=0;o<te.length;o++){let S=te[o],C=S.facePoints[0].distanceTo(S.facePoints[1]),O=S.facePoints[0].distanceTo(S.facePoints[3]),k=C/i.length*100,A=i.rooftopPz-S.facePoints[2].z;if(O<1.5||h<S.facePoints[2].z||A>x/3*2)continue;let j=!1,M=!1,P=!1,L=[],R=S.facePoints[2].clone(),z=S.facePoints[3].clone(),B=S.facePoints[0].clone(),V=S.facePoints[1].clone(),ne=!1,re=-1;if(Math.abs(S.facePoints[0].z-i.start.z)<.25){if(C>.17&&i.length>.5){let t=F(v,B),n=F(v,V),a=F(b,B),o=F(b,V),s=.1;if(t<s||n<s){let{newOriginalPoints:n}=N(B,V,i.originalPoints),a=[],o=[];if(n.forEach(e=>{e.z>=R.z?a.push(e):e.z<=B.z&&o.push(e)}),a.length>10){let n=new f.Vector3(i.start.x,i.start.y,0),a=new f.Vector3(i.end.x,i.end.y,0),o=new f.Vector3().subVectors(n,a).normalize(),c=new f.Vector3,l=1/0,u=-1,d=!1;for(let t=0;t<e.length;t++){if(t==r)continue;let i=new f.Vector3(e[t].start.x,e[t].start.y,0),s=new f.Vector3(e[t].end.x,e[t].end.y,0),p=g(n,a,i,s),m=T(n,a,i,s);if(p!=null){if(m&&m.angle>85){let e=p.point.distanceTo(n);if(p.point.distanceTo(a),e<.3){l=1/0,u=-1;break}}continue}if(m&&m.angle>65){let e=w(n,a,new f.Line3(i,s).closestPointToPoint(n,!0,c),n);if(!e||e.direction!=`same`)continue;let r=n.clone().addScaledVector(o,10),d=a.clone().addScaledVector(o.clone().negate(),10),p=new f.Vector3().subVectors(s,i).normalize(),m=g(r,d,i.clone().addScaledVector(p.clone().negate(),.03),s.clone().addScaledVector(p,.03));if(m==null)continue;let h=n.distanceTo(m.point);h<l&&(l=h,u=t)}else if(m&&m.angle<5){let e=new f.Vector3(B.x,B.y,0),t=new f.Vector3(V.x,V.y,0),n=F(e,i),r=F(e,s),a=F(t,i),o=F(t,s);if(n<.08||r<.08||a<.08||o<.08){d=!0,l=1/0,u=-1;break}}}if(l!=1/0&&l<2)e[u].length>.25&&C+l>.5&&(ne=!0,t<s?(z=z.addScaledVector(o,l),B=B.addScaledVector(o,l)):(R=R.addScaledVector(o,l),V=V.addScaledVector(o,l)));else if(!d){let n=.05,i=v.clone().addScaledVector(o,n),a=v.clone().addScaledVector(o.clone().negate(),n);i.z=a.z=0;let c=!1;for(let u=0;u<e.length;u++){if(u==r)continue;let d=new f.Vector3(e[u].start.x,e[u].start.y,0),p=new f.Vector3(e[u].end.x,e[u].end.y,0),m=new f.Vector3().subVectors(p,d).normalize();d=d.clone().addScaledVector(m.clone().negate(),n),p=p.clone().addScaledVector(m,n);let h=g(i,a,d,p);if(h){h.point.z=v.z;let e=h.point.distanceTo(v);if(h.point.distanceTo(b)<e)continue;l>e&&(l=e),c=!0}if(c)break;l!=1/0&&l<2&&(t<s?(z=z.addScaledVector(o.clone().negate(),l),B=B.addScaledVector(o.clone().negate(),l)):(R=R.addScaledVector(o.clone().negate(),l),V=V.addScaledVector(o.clone().negate(),l)))}if(!c)continue}}else continue}else if(a<s||o<s){let{newOriginalPoints:t}=N(B,V,i.originalPoints),n=[],o=[];if(t.forEach(e=>{e.z>=R.z?n.push(e):e.z<=B.z&&o.push(e)}),n.length>10){let t=new f.Vector3(i.start.x,i.start.y,0),n=new f.Vector3(i.end.x,i.end.y,0),o=new f.Vector3().subVectors(n,t).normalize(),c=new f.Vector3,l=1/0,u=-1,d=!1;for(let i=0;i<e.length;i++){if(i==r)continue;let a=new f.Vector3(e[i].start.x,e[i].start.y,0),s=new f.Vector3(e[i].end.x,e[i].end.y,0),p=g(t,n,a,s),m=T(t,n,a,s);if(p!=null){if(m&&m.angle>85&&(p.point.distanceTo(t),p.point.distanceTo(n)<.3)){l=1/0,u=-1;break}continue}if(m&&m.angle>65){let e=w(n,t,new f.Line3(a,s).closestPointToPoint(n,!0,c),n);if(!e||e.direction!=`same`)continue;let r=t.clone().addScaledVector(o.clone().negate(),10),d=n.clone().addScaledVector(o,10),p=new f.Vector3().subVectors(s,a).normalize(),m=g(r,d,a.clone().addScaledVector(p.clone().negate(),.03),s.clone().addScaledVector(p,.03));if(m==null)continue;let h=n.distanceTo(m.point);h<l&&(l=h,u=i)}else if(m&&m.angle<5){let e=new f.Vector3(B.x,B.y,0),t=new f.Vector3(V.x,V.y,0),n=F(e,a),r=F(e,s),i=F(t,a),o=F(t,s);if(n<.08||r<.08||i<.08||o<.08){d=!0,l=1/0,u=-1;break}}}if(l!=1/0&&l<2)e[u].length>.25&&C+l>.5&&(ne=!0,a<s?(z=z.addScaledVector(o,l),B=B.addScaledVector(o,l)):(R=R.addScaledVector(o,l),V=V.addScaledVector(o,l)));else if(!d){let t=.05,n=b.clone().addScaledVector(o,t),i=v.clone();n.z=i.z=0;let c=!1;for(let a=0;a<e.length;a++){if(a==r)continue;let o=new f.Vector3(e[a].start.x,e[a].start.y,0),s=new f.Vector3(e[a].end.x,e[a].end.y,0),u=new f.Vector3().subVectors(s,o).normalize();o=o.clone().addScaledVector(u.clone().negate(),t),s=s.clone().addScaledVector(u,t);let d=g(n,i,o,s);if(d){d.point.z=b.z;let e=d.point.distanceTo(b);if(d.point.distanceTo(v)<e)continue;l>e&&(l=e),c=!0}}if(!c)continue;l!=1/0&&l<2&&(a<s?(z=z.addScaledVector(o.clone().negate(),l),B=B.addScaledVector(o.clone().negate(),l)):(R=R.addScaledVector(o.clone().negate(),l),V=V.addScaledVector(o.clone().negate(),l)))}}else continue}C=z.distanceTo(R)}if(k<85&&C>.35||C>.7&&O>x-x/3){let e=!1;for(let n=0;n<t.length;n++){let r=n+1;if(r>=t.length)continue;let i=new f.Vector3(t[n].x,t[n].y,t[n].z),a=new f.Vector3(t[r].x,t[r].y,t[r].z);if(g(new f.Vector3(i.x,i.y,0),new f.Vector3(a.x,a.y,0),new f.Vector3(S.facePoints[0].x,S.facePoints[0].y,0),new f.Vector3(S.facePoints[1].x,S.facePoints[1].y,0),.1)!=null){e=!0;break}}for(let e=0;e<s.length;e++){let t=new f.Vector3(s[e].doorStartPt.x,s[e].doorStartPt.y,0),r=new f.Vector3(s[e].doorEndPt.x,s[e].doorEndPt.y,0),a=new f.Vector3(S.facePoints[0].x,S.facePoints[0].y,0),o=new f.Vector3(S.facePoints[1].x,S.facePoints[1].y,0),c=S.facePoints[2].z<s[e].maxZ||Math.abs(S.facePoints[2].z-s[e].maxZ)<.3;if(Math.abs(S.facePoints[2].z-s[e].maxZ),c){let c=D(t.clone(),r.clone(),a.clone(),o.clone(),{distanceThreshold:2});if(c&&c.type==`collinear_gap`){let l=E(t,r),u=new f.Line3(new f.Vector3(i.start.x,i.start.y,0),new f.Vector3(i.end.x,i.end.y,0)),d=new f.Vector3,p=u.closestPointToPoint(l,!0,d);if(l.distanceTo(p)<.15){let i=a.distanceTo(t),l=o.distanceTo(t);if(i>.25&&l>.25){let e=a.distanceTo(r),t=o.distanceTo(r);if(e>.2&&t>.2)continue}M=!0,P=!0,L.push(s[e].index),s[e].isFind=!0,re=e,n[s[e].index].isFindBeam=!0;let u=new f.Vector3().subVectors(a,o).normalize(),d=t.distanceTo(r)-c.overlap;l<i&&u.negate(),i>l?(R=S.facePoints[2].clone().addScaledVector(u,d),z=S.facePoints[3].clone(),B=z.clone(),V=R.clone(),B.z=V.z=S.facePoints[0].z):(R=S.facePoints[2].clone(),z=S.facePoints[3].clone().addScaledVector(u,d),B=z.clone(),V=R.clone(),B.z=V.z=S.facePoints[0].z)}}else if(c&&c.type==`collinear_overlap`&&c.maxPerpendicularDistance<.35){let i=a.distanceTo(o),l=r.distanceTo(t);if(Math.abs(i-c.overlap)<.25||Math.abs(l-c.overlap)<.25){if(l>i&&Math.abs(l-c.overlap)>1){let e=a.distanceTo(t),n=a.distanceTo(r),i=o.distanceTo(t),s=o.distanceTo(r),u=e<n?e:n,d=i<s?i:s,p=new f.Vector3().subVectors(a,o).normalize(),m=l-c.overlap;u<d?(p.negate(),R=S.facePoints[2].clone().addScaledVector(p,m),z=S.facePoints[3].clone(),B=z.clone(),V=R.clone(),B.z=V.z=S.facePoints[0].z):(R=S.facePoints[2].clone(),z=S.facePoints[3].clone().addScaledVector(p,m),B=z.clone(),V=R.clone(),B.z=V.z=S.facePoints[0].z)}M=!0,P=!0,L.push(s[e].index),s[e].isFind=!0,n[s[e].index].isFindBeam=!0,re=e}}}}if(!P)for(let e=0;e<s.length;e++){if(s[e].inWall)continue;let t=new f.Vector3(s[e].doorStartPt.x,s[e].doorStartPt.y,0),r=new f.Vector3(s[e].doorEndPt.x,s[e].doorEndPt.y,0),i=new f.Vector3(S.facePoints[0].x,S.facePoints[0].y,0),a=new f.Vector3(S.facePoints[1].x,S.facePoints[1].y,0),o=new f.Vector3().subVectors(t,r).normalize(),c=new f.Vector3().subVectors(i,a).normalize(),l=.2,u=g(t.clone().addScaledVector(o,l),r.clone().addScaledVector(o.clone().negate(),l),i.clone().addScaledVector(c,l),a.clone().addScaledVector(c.clone().negate(),l)),d=S.facePoints[2].z<s[e].maxZ||Math.abs(S.facePoints[2].z-s[e].maxZ)<.3,p=t.distanceTo(i),h=t.distanceTo(a),_=r.distanceTo(i),v=r.distanceTo(a);(p<m||h<m||_<m||v<m||u)&&d&&(n[s[e].index].isFindBeam=!0,M=!0,s[e].isFind=!0,re=e)}(M||e||Math.abs(O-x)>.1&&O>x/2&&C>.3&&Math.abs(_-i.start.z)<.4)&&(j=!0)}}if(j){let t=!1;for(let e=0;e<d.length;e++){let n=D(d[e].start,d[e].end,B,V);if(n&&n.type==`collinear_overlap`&&n.maxPerpendicularDistance<.01){t=!0;break}}if(t){re!=-1&&(n[s[re].index].isFindBeam=!1,s[re].isFind=!1);continue}d.push({start:B,end:V});{let e=new f.Vector3().subVectors(B,V),t=new f.Vector3().subVectors(V,B),n=1/0,r=1/0,a=B.clone(),o=V.clone(),s=[];if(i.originalPoints.forEach(e=>{e.z-B.z<O/2+.1&&e.z-B.z>O/2-.1&&s.push(e)}),s.length>0){let{newProjectPoints:i}=N(B,V,s);for(let e of i)e.z=B.z;i.forEach(i=>{let s=new f.Vector3(i.x,i.y,B.z),c=new f.Vector3().subVectors(s,V),l=y(e,new f.Vector3().subVectors(s,B)),u=y(t,c);if(l&&l.parallel&&l.sameDirection){let e=s.distanceTo(B);e<n&&(n=e,a=s)}else if(u&&u.parallel&&u.sameDirection){let e=s.distanceTo(V);e<r&&(r=e,o=s)}})}a.equals(B)||(B=a,z=new f.Vector3(B.x,B.y,z.z)),o.equals(V)||(V=o,R=new f.Vector3(V.x,V.y,R.z))}let o=V.distanceTo(B);if(o<.4&&!M||o<.3&&M)continue;u.includes(r)||u.push(r),i.checkResults[a.index].isDoor=!0;let m=``,h={id:c,beamStart:R,beamEnd:z,beamHeight:i.rooftopPz-S.facePoints[2].z,doorStart:B,doorEnd:V,doorHeight:O,nearId:-1,type:m,isExtend:ne,isDoor:M,isPullOutDoor:P,pcbDoorIndexs:L},_=!1,v=new f.Vector3,b=new f.Vector3,x=-1;for(let t=0;t<l.length;t++){let n=e[l[t].linesIndex].doorAndBeamData[l[t].doorIndex];if(n.nearId!=-1)continue;let r=w(R.clone(),z.clone(),n.beamStart.clone(),n.beamEnd.clone());if(r&&r.isParallel){let e=R.distanceTo(z),t=n.beamStart.distanceTo(n.beamEnd),r=new f.Line3(R.clone(),z.clone());r.start.z=0,r.end.z=0;let i=E(n.beamStart,n.beamEnd,!0);t>e&&(r.start=new f.Vector3(n.beamStart.x,n.beamStart.y,0),r.end=new f.Vector3(n.beamEnd.x,n.beamEnd.y,0),i=E(R,z,!0));let a=new f.Vector3,o=r.closestPointToPoint(i,!0,a),s=o.distanceTo(i),l=new f.Vector3().subVectors(i,o).normalize(),u=l.clone().negate(),d=i.clone().addScaledVector(u,s+.1),p=g(r.start,r.end,i,d),m=!M&&!n.isDoor&&(e>t*2||t>e*2);if(s<.4&&p!=null&&!m){n.nearId=c,h.nearId=n.id;let r=.8;(n.isDoor||h.isDoor)&&(n.isDoor=!0,h.isDoor=!0);let i=L.some(e=>n.pcbDoorIndexs.includes(e));e<t?e>r&&!n.isPullOutDoor?(n.beamStart=R.clone().addScaledVector(u,s),n.beamEnd=z.clone().addScaledVector(u,s),n.doorStart=B.clone().addScaledVector(u,s),n.doorEnd=V.clone().addScaledVector(u,s),n.doorHeight=h.doorHeight,n.beamStart.z=n.beamEnd.z=n.doorStart.z+n.doorHeight):!P||P&&n.isPullOutDoor&&i?(h.beamStart=n.beamStart.clone().addScaledVector(l,s),h.beamEnd=n.beamEnd.clone().addScaledVector(l,s),h.doorStart=n.doorStart.clone().addScaledVector(l,s),h.doorEnd=n.doorEnd.clone().addScaledVector(l,s),h.doorHeight=n.doorHeight,h.beamStart.z=h.beamEnd.z=h.doorStart.z+h.doorHeight):(n.beamStart=R.clone().addScaledVector(u,s),n.beamEnd=z.clone().addScaledVector(u,s),n.doorStart=B.clone().addScaledVector(u,s),n.doorEnd=V.clone().addScaledVector(u,s),n.doorHeight=h.doorHeight,n.beamStart.z=n.beamEnd.z=n.doorStart.z+n.doorHeight):e>t&&(t>r&&!P?(h.beamStart=n.beamStart.clone().addScaledVector(u,s),h.beamEnd=n.beamEnd.clone().addScaledVector(u,s),h.doorStart=n.doorStart.clone().addScaledVector(u,s),h.doorEnd=n.doorEnd.clone().addScaledVector(u,s),h.doorHeight=n.doorHeight,h.beamStart.z=h.beamEnd.z=h.doorStart.z+h.doorHeight):!n.isPullOutDoor||P&&n.isPullOutDoor&&i?(n.beamStart=R.clone().addScaledVector(l,s),n.beamEnd=z.clone().addScaledVector(l,s),n.doorStart=B.clone().addScaledVector(l,s),n.doorEnd=V.clone().addScaledVector(l,s),n.doorHeight=h.doorHeight,n.beamStart.z=n.beamEnd.z=n.doorStart.z+n.doorHeight):(h.beamStart=n.beamStart.clone().addScaledVector(u,s),h.beamEnd=n.beamEnd.clone().addScaledVector(u,s),h.doorStart=n.doorStart.clone().addScaledVector(u,s),h.doorEnd=n.doorEnd.clone().addScaledVector(u,s),h.doorHeight=n.doorHeight,h.beamStart.z=h.beamEnd.z=h.doorStart.z+h.doorHeight)),x=h.nearId,v=n.beamStart.clone(),b=n.beamEnd.clone(),_=!0;break}}}let T=!1;if(!_){let i=new f.Line3(B.clone(),V.clone());for(let a=0;a<e.length;a++){if(e[a].length<.5||a==r||!e[a].checkResults)continue;let o=D(new f.Vector3(e[a].start.x,e[a].start.y,e[a].start.z),new f.Vector3(e[a].end.x,e[a].end.y,e[a].end.z),B,V);if(o&&o.maxPerpendicularDistance<.3){for(let r=0;r<e[a].checkResults.length;r++){let r=[];e[a].originalPoints.forEach(e=>{e.z>B.z&&e.z<B.z+O/2&&r.push(new f.Vector3(e.x,e.y,B.z))});let o=new f.Vector3,c=[],l=[];for(let e=0;e<r.length;e++){let t=i.closestPointToPoint(r[e],!0,o);t.distanceTo(r[e])<.15&&(c.push(r[e]),l.push(t.clone()))}for(let e=0;e<l.length;e++)I(i,l[e])&&c.push(l[e]);if(c=l,c.length<500)continue;let u=ee(c);if(u.length==2){let e=u[0].distanceTo(u[1]);if(Math.abs(e-i.distance())<.3){t=!0,re!=-1&&(n[s[re].index].isFindBeam=!1,s[re].isFind=!1);break}}}if(t)break}else o&&o.type==`collinear_overlap`&&o.maxPerpendicularDistance>.3&&o.maxPerpendicularDistance<.7&&(T=!0)}if(t)continue}let k=!1;if(x!=-1)for(let e=0;e<p.length&&!(p[e].length==1&&(p[e][0].id==c?(p[e].push({id:x,beamStart:v,beamEnd:b}),k=!0):p[e][0].id==x&&(p[e].push({id:c,beamStart:R,beamEnd:z}),k=!0),k));e++);k||p.push([{id:c,beamStart:R,beamEnd:z}]);let A=h.doorStart.distanceTo(h.doorEnd);if(m=M?`door`:A>1.8||T&&A>1?`beam`:`hole`,h.type=m,h.nearId!=-1&&m==`hole`){let t=!1;for(let n=0;n<e.length;n++)if(e[n].doorAndBeamData){for(let r=0;r<e[n].doorAndBeamData.length;r++)if(e[n].doorAndBeamData[r].nearId==c&&e[n].doorAndBeamData[r].type==`beam`){e[n].doorAndBeamData[r].type=m,t=!0;break}if(t)break}}if(i.doorAndBeamData.push(h),l.push({linesIndex:r,doorIndex:i.doorAndBeamData.length-1}),c++,P&&C<2)break}}}let O=i.length*(i.rooftopPz-i.start.z);i.completePointAreaPercentage=S/O*100}if(u.length>1)for(let t=0;t<u.length;t++){let n=[];for(let r=0;r<e[u[t]].doorAndBeamData.length;r++){let i=e[u[t]].doorAndBeamData[r].doorStart.clone(),a=e[u[t]].doorAndBeamData[r].doorEnd.clone();i.z=a.z=0;let o=i.distanceTo(a),s=!1;for(let n=0;n<u.length;n++)if(t!=n)for(let t=0;t<e[u[n]].doorAndBeamData.length;t++){let r=e[u[n]].doorAndBeamData[t].doorStart.clone(),c=e[u[n]].doorAndBeamData[t].doorEnd.clone();r.z=c.z=0,r.distanceTo(c);let l=D(i,a,r,c);if(l.type==`collinear_overlap`&&l.maxPerpendicularDistance<.2){let e=new f.Line3(r,c),t=E(i,a),n=e.closestPointToPoint(t,!0,new f.Vector3),u=t.distanceTo(n);if(Math.abs(o-l.overlap)<.1&&u<.04){s=!0;break}}}s||n.push(e[u[t]].doorAndBeamData[r])}n.length!=e[u[t]].doorAndBeamData.length&&(e[u[t]].doorAndBeamData=n)}let h=.65,_=[],v=[];for(let t=0;t<s.length;t++){if(s[t].isFind)continue;let r=new f.Vector3(s[t].doorStartPt.x,s[t].doorStartPt.y,0),i=new f.Vector3(s[t].doorEndPt.x,s[t].doorEndPt.y,0),a=new f.Vector3().subVectors(r,i).normalize();for(let o=0;o<e.length;o++){if(e[o].length<.7||e[o].completePointAreaPercentage>60)continue;let l=new f.Vector3(e[o].start.x,e[o].start.y,0),u=new f.Vector3(e[o].end.x,e[o].end.y,0),d=new f.Vector3().subVectors(l,u).normalize(),y=.3,b=r.clone().addScaledVector(a,y),x=i.clone().addScaledVector(a.clone().negate(),y),S=l.clone().addScaledVector(d,y),C=u.clone().addScaledVector(d.clone().negate(),y);g(b,x,S,C);let E=w(b,x,S,C),O=r.distanceTo(l)>i.distanceTo(l)?i:r,k=O.distanceTo(l),A=O.distanceTo(u);if((k<m||A<m)&&E&&!E.isParallel){let a=r.distanceTo(l)<r.distanceTo(u)?l:u,d=!1;for(let y=0;y<e.length;y++){if(y==o||_.includes(y)||e[y].length<.7)continue;let b=new f.Vector3(e[y].start.x,e[y].start.y,0),x=new f.Vector3(e[y].end.x,e[y].end.y,0),S=new f.Vector3().subVectors(b,x).normalize(),C=S.clone().negate(),E=b.clone().addScaledVector(S,5),O=x.clone().addScaledVector(C,5),k=T(l,u,b,x),A=D(l,u,b,x),j=g(l,u,E,O),M=!0;if(j!=null&&(M=j.point.distanceTo(l)<m||j.point.distanceTo(u)<m),(k&&k.angle>85||A&&A.type==`collinear_gap`)&&M){let m=new f.Line3(l,u),g=new f.Vector3,S=m.closestPointToPoint(b,!0,g),C=m.closestPointToPoint(x,!0,g),T=S.distanceTo(b),E=C.distanceTo(x),O,k;if(T>E&&E>h)O=x,k=C;else if(T<E&&T>h)O=b,k=S;else continue;if(T=a.distanceTo(b),E=a.distanceTo(x),T>2&&E>2)continue;let A=w(O,k,b,x);if(!A||!A.isParallel)continue;let j=D(r,i,O,k);if(j&&j.type==`collinear_overlap`&&j.maxPerpendicularDistance<.2)continue;O.z=k.z=e[y].start.z;let M=!1;for(let e=0;e<v.length;e++){let t=D(v[e].start,v[e].end,O,k);if(t&&t.type==`collinear_overlap`&&t.maxPerpendicularDistance<.2){M=!0;break}}if(M)continue;for(let t=0;t<e.length;t++){if(e[t].length<.5)continue;let n=D(new f.Vector3(e[t].start.x,e[t].start.y,e[t].start.z),new f.Vector3(e[t].end.x,e[t].end.y,e[t].end.z),O,k);if(n&&n.type==`collinear_overlap`&&n.maxPerpendicularDistance<.1){M=!0;break}}if(M)continue;v.push({start:O,end:k}),_.push(y);let N=e[y].rooftopPz-e[y].start.z,P=e[o].rooftopPz-e[o].start.z,F=N<P?N:P;e[y].doorAndBeamData||(e[y].doorAndBeamData=[]),e[y].doorAndBeamData.push({id:c,beamStart:O,beamEnd:k,beamHeight:F,doorStart:O,doorEnd:k,doorHeight:F,nearId:-1,type:`onlyDoor`,isDoor:!0}),n[s[t].index].isFindBeam=!0,n[s[t].index].isFindOnlyDoor=!0,p.push([{id:c,beamStart:O,beamEnd:k}]),c++,d=!0;break}}if(d)break}}}return{lines:e,beamGroup:p}},se=(e,t)=>{if(e.length<=0)return e;for(let t of e){let e=[];for(let n=0;n<t.checkResults.length;n++){let r=t.checkResults[n];if(r.isDoor=!1,!r.originalVertices||r.originalVertices.length==0)continue;let i=[];r.originalVertices.forEach(e=>{let t=[];e.forEach(e=>{t.push(new f.Vector3(e.x,e.y,e.z))}),i.push(t)});let a=i.length,o=Array.from({length:a},(e,t)=>t);function s(e){for(;o[e]!==e;)o[e]=o[o[e]],e=o[e];return e}for(let e=0;e<a;e++)for(let t=e+1;t<a;t++){let n=i[e],r=i[t];if(n.some(e=>r.some(t=>e.equals(t)))){let n=s(e),r=s(t);n!==r&&(o[n]=r)}}let c=new Map,l=-1,u=-1;for(let e=0;e<a;e++){let t=s(e);c.has(t)||c.set(t,{points:[],area:0,originalVertices:[],index:-1,gridWidth:-1,gridHeight:-1,centerPts:[]});let r=c.get(t),[a,o,d,p]=i[e],m=new f.Vector3().add(a).add(o).add(d).add(p).multiplyScalar(.25);if(r.points.push(...i[e]),r.area+=a.distanceTo(o)*a.distanceTo(p),r.originalVertices.push(i[e]),r.index=n,r.centerPts.push(m),l==-1||u==-1){let e=new f.Vector3().subVectors(a,o).normalize();u=a.distanceTo(p),l=a.distanceTo(o);let t=y(e,new f.Vector3(0,0,1));t&&t.parallel&&([u,l]=[l,u])}r.gridWidth=l,r.gridHeight=u}e.push(...c.values())}t.mergeCheckRegion=e}let n=new Map;for(let t of e){let e=t.rooftopPz-t.start.z,r=Math.floor(t.rooftopPz-t.start.z);n.has(r)?n.set(r,{num:n.get(r).num+1,totalHeight:n.get(r).totalHeight+e}):n.set(r,{num:1,totalHeight:e})}let r=[...n.entries()].reduce((e,t)=>t[1].num>e[1].num?t:e),i=r[0];r[1].totalHeight/r[1].num,new f.MeshBasicMaterial({color:`#cffd00`,transparent:!0,opacity:.4,side:f.DoubleSide}),new f.PointsMaterial({color:65535,size:.01});for(let n=0;n<e.length;n++){let r=e[n],{minZ:a,maxZ:o}=M(r);if(a==null||o==null)continue;r.doorAndBeamData=[],r.completePointAreaPercentage=-1,o-a;let s=r.rooftopPz-r.start.z;if(s<i-.5||s>i+2||Math.abs(a-r.start.z)>.3||r.length<1)continue;let c=new f.Vector3(r.start.x,r.start.y,0),l=new f.Vector3(r.end.x,r.end.y,0);for(let r=0;r<e.length;r++){if(r==n||e[r].length<1)continue;let i=e[r],a=new f.Vector3(i.start.x,i.start.y,0),s=new f.Vector3(i.end.x,i.end.y,0),u=w(c,l,a,s),d=E(c,l),p=new f.Line3(a,s).closestPointToPoint(d,!0,new f.Vector3),m=d.distanceTo(p),h=M(i);if(!(h.minZ===void 0||h.maxZ===void 0)&&!(h.maxZ-h.minZ>1)&&u&&u.isParallel&&m<.25&&Math.abs(o-h.minZ)<.1){let i=E(c,l),o=E(a,s);i.z=o.z=1,i.applyEuler(new f.Euler(-Math.PI/2,0,0)),o.applyEuler(new f.Euler(-Math.PI/2,0,0));let u=`w:${e[n].originaIndex},b:${e[r].originaIndex}`,d=`b:${e[r].originaIndex},w:${e[n].originaIndex}`;t.add(_(u,i,{textColor:`#fd0000`})),t.add(_(d,o,{textColor:`#fd0000`}))}}}return e},ce=(e,t)=>{let n={rectangles:[],threeEdgeRect:[]},r=new Set,i=.2,a=1.5,o=.15;for(let t=0;t<e.length;t++){let s=e[t].length;if(r.has(t)||s<i||s>a)continue;let c=[],l=new f.Vector3(e[t].start.x,e[t].start.y,e[t].start.z),u=new f.Vector3(e[t].end.x,e[t].end.y,e[t].end.z),d=new f.Vector3().subVectors(u,l).normalize().clone().negate(),p=new f.Vector3,m=new f.Vector3,h=new f.Vector3;new f.Vector3;for(let n=0;n<e.length;n++){let r=e[n].length;if(n==t||r<i||r>a)continue;let g=new f.Vector3(e[n].start.x,e[n].start.y,e[n].start.z),_=new f.Vector3(e[n].end.x,e[n].end.y,e[n].end.z),v=T(l,u,g,_);if(!v||v.angle<85)continue;let b=L(g,l),x=L(g,u),S=L(_,l),C=L(_,u);if(!(!b&&!x&&!S&&!C)){b||x?(p=g.clone(),m=_.clone()):(p=_.clone(),m=g.clone()),h=new f.Vector3().subVectors(m,p).normalize(),h.clone().negate();for(let p=0;p<e.length;p++){let h=e[p].length;if(p==t||p==n||h<i||h>a)continue;let v=new f.Vector3(e[p].start.x,e[p].start.y,e[p].start.z),b=new f.Vector3(e[p].end.x,e[p].end.y,e[p].end.z),x=T(g,_,v,b);if(!x||x.angle<85)continue;let S=L(v,m),C=L(b,m);if(!S&&!C)continue;new f.Vector3;let w=new f.Vector3,E=new f.Vector3;S?(E=new f.Vector3().subVectors(b,v).normalize(),v.clone(),w=b.clone()):(E=new f.Vector3().subVectors(v,b).normalize(),b.clone(),w=v.clone());let D=y(d,E,.1);if(!(!D||!D.parallel||!D.sameDirection)){for(let d=0;d<e.length;d++){let m=e[d].length;if(d==t||d==n||d==p||m<i||m>a)continue;let h=new f.Vector3(e[d].start.x,e[d].start.y,e[d].start.z),g=new f.Vector3(e[d].end.x,e[d].end.y,e[d].end.z),_=T(h,g,v,b);if(!_||_.angle<85)continue;let y=L(h,w),x=L(g,w);if(!y&&!x)continue;new f.Vector3;let S=new f.Vector3;y?(h.clone(),S=g.clone()):(g.clone(),S=h.clone());let C=L(S,l),E=L(S,u);if(!C&&!E)continue;let D=s*r;if(!(D<o||D>2)){c=[t,n,p,d];break}}if(c.length==4)break}}if(c.length==4)break}}c.length==4&&(c.forEach(e=>r.add(e)),n.rectangles.push(c))}for(let t=0;t<e.length;t++){let s=e[t].length;if(r.has(t)||s<i||s>a)continue;let c={indexs:[],missingEdge:{start:new f.Vector3,end:new f.Vector3}},l=new f.Vector3(e[t].start.x,e[t].start.y,e[t].start.z),u=new f.Vector3(e[t].end.x,e[t].end.y,e[t].end.z),d=!0,p=!0;for(let n=0;n<e.length;n++){if(n==t)continue;let r=new f.Vector3(e[n].start.x,e[n].start.y,e[n].start.z),i=new f.Vector3(e[n].end.x,e[n].end.y,e[n].end.z),a=L(r,l),o=L(i,l),s=L(r,u),c=L(i,u);if(a||o?d=!1:(s||c)&&(p=!1),!d&&!p)break}if(!d&&!p)continue;let m=new f.Vector3;d||([l,u]=[u,l]),m=new f.Vector3().subVectors(u,l).normalize();let h=m.clone().negate();for(let n=0;n<e.length;n++){let d=e[n].length;if(n==t||r.has(n)||d<i||d>a)continue;let p=new f.Vector3(e[n].start.x,e[n].start.y,e[n].start.z),m=new f.Vector3(e[n].end.x,e[n].end.y,e[n].end.z),g=T(l,u,p,m);if(!g||g.angle<85)continue;let _=L(p,u),v=L(m,u);if(!_&&!v)continue;new f.Vector3;let b=new f.Vector3;_?(p.clone(),b=m.clone()):(m.clone(),b=p.clone());for(let u=0;u<e.length;u++){let g=e[u].length;if(u==t||u==n||r.has(u)||g<i||g>a)continue;let _=new f.Vector3(e[u].start.x,e[u].start.y,e[u].start.z),v=new f.Vector3(e[u].end.x,e[u].end.y,e[u].end.z),x=T(p,m,_,v);if(!x||x.angle<85)continue;let S=L(_,b),C=L(v,b);if(!S&&!C)continue;let w=new f.Vector3,E=new f.Vector3;S?(w=_.clone(),E=v.clone()):(w=v.clone(),E=_.clone());let D=y(h,new f.Vector3().subVectors(E,w).normalize(),.1);if(!D||!D.parallel||!D.sameDirection)continue;let O=!0,k=!0;for(let t=0;t<e.length;t++){if(t==u)continue;let n=new f.Vector3(e[t].start.x,e[t].start.y,e[t].start.z),r=new f.Vector3(e[t].end.x,e[t].end.y,e[t].end.z),i=L(n,_),a=L(r,_),o=L(n,v),s=L(r,v);if(i||a?O=!1:(o||s)&&(k=!1),!O&&!k)break}if(!O&&!k)continue;let A=s*d;if(!(A<o||A>2)){c.indexs=[t,n,u],c.missingEdge.start=E,c.missingEdge.end=l;break}}if(c.indexs.length==3)break}c.indexs.length==3&&(c.indexs.forEach(e=>r.add(e)),n.threeEdgeRect.push(c))}return n},H=11102230246251565e-32,U=134217729,le=(3+8*H)*H;function ue(e,t,n,r,i){let a,o,s,c,l=t[0],u=r[0],d=0,f=0;u>l==u>-l?(a=l,l=t[++d]):(a=u,u=r[++f]);let p=0;if(d<e&&f<n)for(u>l==u>-l?(o=l+a,s=a-(o-l),l=t[++d]):(o=u+a,s=a-(o-u),u=r[++f]),a=o,s!==0&&(i[p++]=s);d<e&&f<n;)u>l==u>-l?(o=a+l,c=o-a,s=a-(o-c)+(l-c),l=t[++d]):(o=a+u,c=o-a,s=a-(o-c)+(u-c),u=r[++f]),a=o,s!==0&&(i[p++]=s);for(;d<e;)o=a+l,c=o-a,s=a-(o-c)+(l-c),l=t[++d],a=o,s!==0&&(i[p++]=s);for(;f<n;)o=a+u,c=o-a,s=a-(o-c)+(u-c),u=r[++f],a=o,s!==0&&(i[p++]=s);return(a!==0||p===0)&&(i[p++]=a),p}function de(e,t){let n=t[0];for(let r=1;r<e;r++)n+=t[r];return n}function W(e){return new Float64Array(e)}var fe=(3+16*H)*H,pe=(2+12*H)*H,me=(9+64*H)*H*H,he=W(4),ge=W(8),_e=W(12),ve=W(16),G=W(4);function ye(e,t,n,r,i,a,o){let s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T=e-i,E=n-i,D=t-a,O=r-a;b=T*O,f=U*T,p=f-(f-T),m=T-p,f=U*O,h=f-(f-O),g=O-h,x=m*g-(b-p*h-m*h-p*g),S=D*E,f=U*D,p=f-(f-D),m=D-p,f=U*E,h=f-(f-E),g=E-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,he[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,he[1]=y-(_+d)+(d-S),w=v+_,d=w-v,he[2]=v-(w-d)+(_-d),he[3]=w;let k=de(4,he),A=pe*o;if(k>=A||-k>=A||(d=e-T,s=e-(T+d)+(d-i),d=n-E,l=n-(E+d)+(d-i),d=t-D,c=t-(D+d)+(d-a),d=r-O,u=r-(O+d)+(d-a),s===0&&c===0&&l===0&&u===0)||(A=me*o+le*Math.abs(k),k+=T*u+O*s-(D*l+E*c),k>=A||-k>=A))return k;b=s*O,f=U*s,p=f-(f-s),m=s-p,f=U*O,h=f-(f-O),g=O-h,x=m*g-(b-p*h-m*h-p*g),S=c*E,f=U*c,p=f-(f-c),m=c-p,f=U*E,h=f-(f-E),g=E-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,G[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,G[1]=y-(_+d)+(d-S),w=v+_,d=w-v,G[2]=v-(w-d)+(_-d),G[3]=w;let j=ue(4,he,4,G,ge);b=T*u,f=U*T,p=f-(f-T),m=T-p,f=U*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=D*l,f=U*D,p=f-(f-D),m=D-p,f=U*l,h=f-(f-l),g=l-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,G[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,G[1]=y-(_+d)+(d-S),w=v+_,d=w-v,G[2]=v-(w-d)+(_-d),G[3]=w;let M=ue(j,ge,4,G,_e);return b=s*u,f=U*s,p=f-(f-s),m=s-p,f=U*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=c*l,f=U*c,p=f-(f-c),m=c-p,f=U*l,h=f-(f-l),g=l-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,G[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,G[1]=y-(_+d)+(d-S),w=v+_,d=w-v,G[2]=v-(w-d)+(_-d),G[3]=w,ve[ue(M,_e,4,G,ve)-1]}function be(e,t,n,r,i,a){let o=(t-a)*(n-i),s=(e-i)*(r-a),c=o-s,l=Math.abs(o+s);return Math.abs(c)>=fe*l?c:-ye(e,t,n,r,i,a,l)}(7+56*H)*H,(3+28*H)*H,(26+288*H)*H*H,W(4),W(4),W(4),W(4),W(4),W(4),W(4),W(4),W(4),W(8),W(8),W(8),W(4),W(8),W(8),W(16),W(12),W(192),W(192),(10+96*H)*H,(4+48*H)*H,(44+576*H)*H*H,W(4),W(4),W(4),W(4),W(4),W(4),W(4),W(4),W(8),W(8),W(8),W(8),W(8),W(8),W(8),W(8),W(8),W(4),W(4),W(4),W(8),W(16),W(16),W(16),W(32),W(32),W(48),W(64),W(1152),W(1152),(16+224*H)*H,(5+72*H)*H,(71+1408*H)*H*H,W(4),W(4),W(4),W(4),W(4),W(4),W(4),W(4),W(4),W(4),W(24),W(24),W(24),W(24),W(24),W(24),W(24),W(24),W(24),W(24),W(1152),W(1152),W(1152),W(1152),W(1152),W(2304),W(2304),W(3456),W(5760),W(8),W(8),W(8),W(16),W(24),W(48),W(48),W(96),W(192),W(384),W(384),W(384),W(768),W(96),W(96),W(96),W(1152);var xe=2**-52,Se=new Uint32Array(512),Ce=class e{static from(t,n=je,r=Me){let i=t.length,a=new Float64Array(i*2);for(let e=0;e<i;e++){let i=t[e];a[2*e]=n(i),a[2*e+1]=r(i)}return new e(a)}constructor(e){let t=e.length>>1;if(t>0&&typeof e[0]!=`number`)throw Error(`Expected coords to contain numbers.`);this.coords=e;let n=Math.max(2*t-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.trianglesLen=0,this._cx=0,this._cy=0,this._hullStart=0,this.hull=this._triangles,this.triangles=this._triangles,this.halfedges=this._halfedges,this.update()}update(){let{coords:e,_hullPrev:t,_hullNext:n,_hullTri:r,_hullHash:i}=this,a=e.length>>1,o=1/0,s=1/0,c=-1/0,l=-1/0;for(let t=0;t<a;t++){let n=e[2*t],r=e[2*t+1];n<o&&(o=n),r<s&&(s=r),n>c&&(c=n),r>l&&(l=r),this._ids[t]=t}let u=(o+c)/2,d=(s+l)/2,f=0,p=0,m=0;for(let t=0,n=1/0;t<a;t++){let r=Te(u,d,e[2*t],e[2*t+1]);r<n&&(f=t,n=r)}let h=e[2*f],g=e[2*f+1];for(let t=0,n=1/0;t<a;t++){if(t===f)continue;let r=Te(h,g,e[2*t],e[2*t+1]);r<n&&r>0&&(p=t,n=r)}let _=e[2*p],v=e[2*p+1],y=1/0;for(let t=0;t<a;t++){if(t===f||t===p)continue;let n=De(h,g,_,v,e[2*t],e[2*t+1]);n<y&&(m=t,y=n)}let b=e[2*m],x=e[2*m+1];if(y===1/0){for(let t=0;t<a;t++)this._dists[t]=e[2*t]-e[0]||e[2*t+1]-e[1];ke(this._ids,this._dists,0,a-1);let t=new Uint32Array(a),n=0;for(let e=0,r=-1/0;e<a;e++){let i=this._ids[e],a=this._dists[i];a>r&&(t[n++]=i,r=a)}this.hull=t.subarray(0,n),this.triangles=new Uint32Array,this.halfedges=new Int32Array;return}if(be(h,g,_,v,b,x)<0){let e=p,t=_,n=v;p=m,_=b,v=x,m=e,b=t,x=n}let S=Oe(h,g,_,v,b,x);this._cx=S.x,this._cy=S.y;for(let t=0;t<a;t++)this._dists[t]=Te(e[2*t],e[2*t+1],S.x,S.y);ke(this._ids,this._dists,0,a-1),this._hullStart=f;let C=3;n[f]=t[m]=p,n[p]=t[f]=m,n[m]=t[p]=f,r[f]=0,r[p]=1,r[m]=2,i.fill(-1),i[this._hashKey(h,g)]=f,i[this._hashKey(_,v)]=p,i[this._hashKey(b,x)]=m,this.trianglesLen=0,this._addTriangle(f,p,m,-1,-1,-1);for(let a=0,o=0,s=0;a<this._ids.length;a++){let c=this._ids[a],l=e[2*c],u=e[2*c+1];if(a>0&&Math.abs(l-o)<=xe&&Math.abs(u-s)<=xe||(o=l,s=u,c===f||c===p||c===m))continue;let d=0;for(let e=0,t=this._hashKey(l,u);e<this._hashSize&&(d=i[(t+e)%this._hashSize],!(d!==-1&&d!==n[d]));e++);d=t[d];let h=d,g;for(;g=n[h],be(l,u,e[2*h],e[2*h+1],e[2*g],e[2*g+1])>=0;)if(h=g,h===d){h=-1;break}if(h===-1)continue;let _=this._addTriangle(h,c,n[h],-1,-1,r[h]);r[c]=this._legalize(_+2),r[h]=_,C++;let v=n[h];for(;g=n[v],be(l,u,e[2*v],e[2*v+1],e[2*g],e[2*g+1])<0;)_=this._addTriangle(v,c,g,r[c],-1,r[v]),r[c]=this._legalize(_+2),n[v]=v,C--,v=g;if(h===d)for(;g=t[h],be(l,u,e[2*g],e[2*g+1],e[2*h],e[2*h+1])<0;)_=this._addTriangle(g,c,h,-1,r[h],r[g]),this._legalize(_+2),r[g]=_,n[h]=h,C--,h=g;this._hullStart=t[c]=h,n[h]=t[v]=c,n[c]=v,i[this._hashKey(l,u)]=c,i[this._hashKey(e[2*h],e[2*h+1])]=h}this.hull=new Uint32Array(C);for(let e=0,t=this._hullStart;e<C;e++)this.hull[e]=t,t=n[t];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(e,t){return Math.floor(we(e-this._cx,t-this._cy)*this._hashSize)%this._hashSize}_legalize(e){let{_triangles:t,_halfedges:n,coords:r}=this,i=0,a=0;for(;;){let o=n[e],s=e-e%3;if(a=s+(e+2)%3,o===-1){if(i===0)break;e=Se[--i];continue}let c=o-o%3,l=s+(e+1)%3,u=c+(o+2)%3,d=t[a],f=t[e],p=t[l],m=t[u];if(Ee(r[2*d],r[2*d+1],r[2*f],r[2*f+1],r[2*p],r[2*p+1],r[2*m],r[2*m+1])){t[e]=m,t[o]=d;let r=n[u];if(r===-1){let t=this._hullStart;do{if(this._hullTri[t]===u){this._hullTri[t]=e;break}t=this._hullPrev[t]}while(t!==this._hullStart)}this._link(e,r),this._link(o,n[a]),this._link(a,u);let s=c+(o+1)%3;i<Se.length&&(Se[i++]=s)}else{if(i===0)break;e=Se[--i]}}return a}_link(e,t){this._halfedges[e]=t,t!==-1&&(this._halfedges[t]=e)}_addTriangle(e,t,n,r,i,a){let o=this.trianglesLen;return this._triangles[o]=e,this._triangles[o+1]=t,this._triangles[o+2]=n,this._link(o,r),this._link(o+1,i),this._link(o+2,a),this.trianglesLen+=3,o}};function we(e,t){let n=e/(Math.abs(e)+Math.abs(t));return(t>0?3-n:1+n)/4}function Te(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}function Ee(e,t,n,r,i,a,o,s){let c=e-o,l=t-s,u=n-o,d=r-s,f=i-o,p=a-s,m=c*c+l*l,h=u*u+d*d,g=f*f+p*p;return c*(d*g-h*p)-l*(u*g-h*f)+m*(u*p-d*f)<0}function De(e,t,n,r,i,a){let o=n-e,s=r-t,c=i-e,l=a-t,u=o*o+s*s,d=c*c+l*l,f=.5/(o*l-s*c),p=(l*u-s*d)*f,m=(o*d-c*u)*f;return p*p+m*m}function Oe(e,t,n,r,i,a){let o=n-e,s=r-t,c=i-e,l=a-t,u=o*o+s*s,d=c*c+l*l,f=.5/(o*l-s*c);return{x:e+(l*u-s*d)*f,y:t+(o*d-c*u)*f}}function ke(e,t,n,r){if(r-n<=20)for(let i=n+1;i<=r;i++){let r=e[i],a=t[r],o=i-1;for(;o>=n&&t[e[o]]>a;)e[o+1]=e[o--];e[o+1]=r}else{let i=n+r>>1,a=n+1,o=r;Ae(e,i,a),t[e[n]]>t[e[r]]&&Ae(e,n,r),t[e[a]]>t[e[r]]&&Ae(e,a,r),t[e[n]]>t[e[a]]&&Ae(e,n,a);let s=e[a],c=t[s];for(;;){do a++;while(t[e[a]]<c);do o--;while(t[e[o]]>c);if(o<a)break;Ae(e,a,o)}e[n+1]=e[o],e[o]=s,r-a+1>=o-n?(ke(e,t,a,r),ke(e,t,n,o-1)):(ke(e,t,n,o-1),ke(e,t,a,r))}}function Ae(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function je(e){return e[0]}function Me(e){return e[1]}var Ne=1e-6,Pe=class{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=``}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+=`Z`)}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,n){e=+e,t=+t,n=+n;let r=e+n,i=t;if(n<0)throw Error(`negative radius`);this._x1===null?this._+=`M${r},${i}`:(Math.abs(this._x1-r)>Ne||Math.abs(this._y1-i)>Ne)&&(this._+=`L`+r+`,`+i),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=r},${this._y1=i}`)}rect(e,t,n,r){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+r}h${-n}Z`}value(){return this._||null}},Fe=class{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}},Ie=class{constructor(e,[t,n,r,i]=[0,0,960,500]){if(!((r=+r)>=(t=+t))||!((i=+i)>=(n=+n)))throw Error(`invalid bounds`);this.delaunay=e,this._circumcenters=new Float64Array(e.points.length*2),this.vectors=new Float64Array(e.points.length*2),this.xmax=r,this.xmin=t,this.ymax=i,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){let{delaunay:{points:e,hull:t,triangles:n},vectors:r}=this,i,a,o=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let r=0,s=0,c=n.length,l,u;r<c;r+=3,s+=2){let c=n[r]*2,d=n[r+1]*2,f=n[r+2]*2,p=e[c],m=e[c+1],h=e[d],g=e[d+1],_=e[f],v=e[f+1],y=h-p,b=g-m,x=_-p,S=v-m,C=(y*S-b*x)*2;if(Math.abs(C)<1e-9){if(i===void 0){i=a=0;for(let n of t)i+=e[n*2],a+=e[n*2+1];i/=t.length,a/=t.length}let n=1e9*Math.sign((i-p)*S-(a-m)*x);l=(p+_)/2-n*S,u=(m+v)/2+n*x}else{let e=1/C,t=y*y+b*b,n=x*x+S*S;l=p+(S*t-b*n)*e,u=m+(y*n-x*t)*e}o[s]=l,o[s+1]=u}let s=t[t.length-1],c,l=s*4,u,d=e[2*s],f,p=e[2*s+1];r.fill(0);for(let n=0;n<t.length;++n)s=t[n],c=l,u=d,f=p,l=s*4,d=e[2*s],p=e[2*s+1],r[c+2]=r[l]=f-p,r[c+3]=r[l+1]=d-u}render(e){let t=e==null?e=new Pe:void 0,{delaunay:{halfedges:n,inedges:r,hull:i},circumcenters:a,vectors:o}=this;if(i.length<=1)return null;for(let t=0,r=n.length;t<r;++t){let r=n[t];if(r<t)continue;let i=Math.floor(t/3)*2,o=Math.floor(r/3)*2,s=a[i],c=a[i+1],l=a[o],u=a[o+1];this._renderSegment(s,c,l,u,e)}let s,c=i[i.length-1];for(let t=0;t<i.length;++t){s=c,c=i[t];let n=Math.floor(r[c]/3)*2,l=a[n],u=a[n+1],d=s*4,f=this._project(l,u,o[d+2],o[d+3]);f&&this._renderSegment(l,u,f[0],f[1],e)}return t&&t.value()}renderBounds(e){let t=e==null?e=new Pe:void 0;return e.rect(this.xmin,this.ymin,this.xmax-this.xmin,this.ymax-this.ymin),t&&t.value()}renderCell(e,t){let n=t==null?t=new Pe:void 0,r=this._clip(e);if(r===null||!r.length)return;t.moveTo(r[0],r[1]);let i=r.length;for(;r[0]===r[i-2]&&r[1]===r[i-1]&&i>1;)i-=2;for(let e=2;e<i;e+=2)(r[e]!==r[e-2]||r[e+1]!==r[e-1])&&t.lineTo(r[e],r[e+1]);return t.closePath(),n&&n.value()}*cellPolygons(){let{delaunay:{points:e}}=this;for(let t=0,n=e.length/2;t<n;++t){let e=this.cellPolygon(t);e&&(e.index=t,yield e)}}cellPolygon(e){let t=new Fe;return this.renderCell(e,t),t.value()}_renderSegment(e,t,n,r,i){let a,o=this._regioncode(e,t),s=this._regioncode(n,r);o===0&&s===0?(i.moveTo(e,t),i.lineTo(n,r)):(a=this._clipSegment(e,t,n,r,o,s))&&(i.moveTo(a[0],a[1]),i.lineTo(a[2],a[3]))}contains(e,t,n){return(t=+t,t!==t)||(n=+n,n!==n)?!1:this.delaunay._step(e,t,n)===e}*neighbors(e){let t=this._clip(e);if(t)for(let n of this.delaunay.neighbors(e)){let e=this._clip(n);if(e){loop:for(let r=0,i=t.length;r<i;r+=2)for(let a=0,o=e.length;a<o;a+=2)if(t[r]===e[a]&&t[r+1]===e[a+1]&&t[(r+2)%i]===e[(a+o-2)%o]&&t[(r+3)%i]===e[(a+o-1)%o]){yield n;break loop}}}}_cell(e){let{circumcenters:t,delaunay:{inedges:n,halfedges:r,triangles:i}}=this,a=n[e];if(a===-1)return null;let o=[],s=a;do{let n=Math.floor(s/3);if(o.push(t[n*2],t[n*2+1]),s=s%3==2?s-2:s+1,i[s]!==e)break;s=r[s]}while(s!==a&&s!==-1);return o}_clip(e){if(e===0&&this.delaunay.hull.length===1)return[this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];let t=this._cell(e);if(t===null)return null;let{vectors:n}=this,r=e*4;return this._simplify(n[r]||n[r+1]?this._clipInfinite(e,t,n[r],n[r+1],n[r+2],n[r+3]):this._clipFinite(e,t))}_clipFinite(e,t){let n=t.length,r=null,i,a,o=t[n-2],s=t[n-1],c,l=this._regioncode(o,s),u,d=0;for(let f=0;f<n;f+=2)if(i=o,a=s,o=t[f],s=t[f+1],c=l,l=this._regioncode(o,s),c===0&&l===0)u=d,d=0,r?r.push(o,s):r=[o,s];else{let t,n,f,p,m;if(c===0){if((t=this._clipSegment(i,a,o,s,c,l))===null)continue;[n,f,p,m]=t}else{if((t=this._clipSegment(o,s,i,a,l,c))===null)continue;[p,m,n,f]=t,u=d,d=this._edgecode(n,f),u&&d&&this._edge(e,u,d,r,r.length),r?r.push(n,f):r=[n,f]}u=d,d=this._edgecode(p,m),u&&d&&this._edge(e,u,d,r,r.length),r?r.push(p,m):r=[p,m]}if(r)u=d,d=this._edgecode(r[0],r[1]),u&&d&&this._edge(e,u,d,r,r.length);else if(this.contains(e,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2))return[this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];return r}_clipSegment(e,t,n,r,i,a){let o=i<a;for(o&&([e,t,n,r,i,a]=[n,r,e,t,a,i]);;){if(i===0&&a===0)return o?[n,r,e,t]:[e,t,n,r];if(i&a)return null;let s,c,l=i||a;l&8?(s=e+(n-e)*(this.ymax-t)/(r-t),c=this.ymax):l&4?(s=e+(n-e)*(this.ymin-t)/(r-t),c=this.ymin):l&2?(c=t+(r-t)*(this.xmax-e)/(n-e),s=this.xmax):(c=t+(r-t)*(this.xmin-e)/(n-e),s=this.xmin),i?(e=s,t=c,i=this._regioncode(e,t)):(n=s,r=c,a=this._regioncode(n,r))}}_clipInfinite(e,t,n,r,i,a){let o=Array.from(t),s;if((s=this._project(o[0],o[1],n,r))&&o.unshift(s[0],s[1]),(s=this._project(o[o.length-2],o[o.length-1],i,a))&&o.push(s[0],s[1]),o=this._clipFinite(e,o))for(let t=0,n=o.length,r,i=this._edgecode(o[n-2],o[n-1]);t<n;t+=2)r=i,i=this._edgecode(o[t],o[t+1]),r&&i&&(t=this._edge(e,r,i,o,t),n=o.length);else this.contains(e,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2)&&(o=[this.xmin,this.ymin,this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax]);return o}_edge(e,t,n,r,i){for(;t!==n;){let n,a;switch(t){case 5:t=4;continue;case 4:t=6,n=this.xmax,a=this.ymin;break;case 6:t=2;continue;case 2:t=10,n=this.xmax,a=this.ymax;break;case 10:t=8;continue;case 8:t=9,n=this.xmin,a=this.ymax;break;case 9:t=1;continue;case 1:t=5,n=this.xmin,a=this.ymin;break}(r[i]!==n||r[i+1]!==a)&&this.contains(e,n,a)&&(r.splice(i,0,n,a),i+=2)}return i}_project(e,t,n,r){let i=1/0,a,o,s;if(r<0){if(t<=this.ymin)return null;(a=(this.ymin-t)/r)<i&&(s=this.ymin,o=e+(i=a)*n)}else if(r>0){if(t>=this.ymax)return null;(a=(this.ymax-t)/r)<i&&(s=this.ymax,o=e+(i=a)*n)}if(n>0){if(e>=this.xmax)return null;(a=(this.xmax-e)/n)<i&&(o=this.xmax,s=t+(i=a)*r)}else if(n<0){if(e<=this.xmin)return null;(a=(this.xmin-e)/n)<i&&(o=this.xmin,s=t+(i=a)*r)}return[o,s]}_edgecode(e,t){return(e===this.xmin?1:e===this.xmax?2:0)|(t===this.ymin?4:t===this.ymax?8:0)}_regioncode(e,t){return(e<this.xmin?1:e>this.xmax?2:0)|(t<this.ymin?4:t>this.ymax?8:0)}_simplify(e){if(e&&e.length>4){for(let t=0;t<e.length;t+=2){let n=(t+2)%e.length,r=(t+4)%e.length;(e[t]===e[n]&&e[n]===e[r]||e[t+1]===e[n+1]&&e[n+1]===e[r+1])&&(e.splice(n,2),t-=2)}e.length||(e=null)}return e}},Le=2*Math.PI,Re=Math.pow;function ze(e){return e[0]}function Be(e){return e[1]}function Ve(e){let{triangles:t,coords:n}=e;for(let e=0;e<t.length;e+=3){let r=2*t[e],i=2*t[e+1],a=2*t[e+2];if((n[a]-n[r])*(n[i+1]-n[r+1])-(n[i]-n[r])*(n[a+1]-n[r+1])>1e-10)return!1}return!0}function He(e,t,n){return[e+Math.sin(e+t)*n,t+Math.cos(e-t)*n]}var Ue=class e{static from(t,n=ze,r=Be,i){return new e(`length`in t?We(t,n,r,i):Float64Array.from(Ge(t,n,r,i)))}constructor(e){this._delaunator=new Ce(e),this.inedges=new Int32Array(e.length/2),this._hullIndex=new Int32Array(e.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){let e=this._delaunator,t=this.points;if(e.hull&&e.hull.length>2&&Ve(e)){this.collinear=Int32Array.from({length:t.length/2},(e,t)=>t).sort((e,n)=>t[2*e]-t[2*n]||t[2*e+1]-t[2*n+1]);let e=this.collinear[0],n=this.collinear[this.collinear.length-1],r=[t[2*e],t[2*e+1],t[2*n],t[2*n+1]],i=1e-8*Math.hypot(r[3]-r[1],r[2]-r[0]);for(let e=0,n=t.length/2;e<n;++e){let n=He(t[2*e],t[2*e+1],i);t[2*e]=n[0],t[2*e+1]=n[1]}this._delaunator=new Ce(t)}else delete this.collinear;let n=this.halfedges=this._delaunator.halfedges,r=this.hull=this._delaunator.hull,i=this.triangles=this._delaunator.triangles,a=this.inedges.fill(-1),o=this._hullIndex.fill(-1);for(let e=0,t=n.length;e<t;++e){let t=i[e%3==2?e-2:e+1];(n[e]===-1||a[t]===-1)&&(a[t]=e)}for(let e=0,t=r.length;e<t;++e)o[r[e]]=e;r.length<=2&&r.length>0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],a[r[0]]=1,r.length===2&&(a[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(e){return new Ie(this,e)}*neighbors(e){let{inedges:t,hull:n,_hullIndex:r,halfedges:i,triangles:a,collinear:o}=this;if(o){let t=o.indexOf(e);t>0&&(yield o[t-1]),t<o.length-1&&(yield o[t+1]);return}let s=t[e];if(s===-1)return;let c=s,l=-1;do{if(yield l=a[c],c=c%3==2?c-2:c+1,a[c]!==e)return;if(c=i[c],c===-1){let t=n[(r[e]+1)%n.length];t!==l&&(yield t);return}}while(c!==s)}find(e,t,n=0){if((e=+e,e!==e)||(t=+t,t!==t))return-1;let r=n,i;for(;(i=this._step(n,e,t))>=0&&i!==n&&i!==r;)n=i;return i}_step(e,t,n){let{inedges:r,hull:i,_hullIndex:a,halfedges:o,triangles:s,points:c}=this;if(r[e]===-1||!c.length)return(e+1)%(c.length>>1);let l=e,u=Re(t-c[e*2],2)+Re(n-c[e*2+1],2),d=r[e],f=d;do{let r=s[f],d=Re(t-c[r*2],2)+Re(n-c[r*2+1],2);if(d<u&&(u=d,l=r),f=f%3==2?f-2:f+1,s[f]!==e)break;if(f=o[f],f===-1){if(f=i[(a[e]+1)%i.length],f!==r&&Re(t-c[f*2],2)+Re(n-c[f*2+1],2)<u)return f;break}}while(f!==d);return l}render(e){let t=e==null?e=new Pe:void 0,{points:n,halfedges:r,triangles:i}=this;for(let t=0,a=r.length;t<a;++t){let a=r[t];if(a<t)continue;let o=i[t]*2,s=i[a]*2;e.moveTo(n[o],n[o+1]),e.lineTo(n[s],n[s+1])}return this.renderHull(e),t&&t.value()}renderPoints(e,t){t===void 0&&(!e||typeof e.moveTo!=`function`)&&(t=e,e=null),t=t==null?2:+t;let n=e==null?e=new Pe:void 0,{points:r}=this;for(let n=0,i=r.length;n<i;n+=2){let i=r[n],a=r[n+1];e.moveTo(i+t,a),e.arc(i,a,t,0,Le)}return n&&n.value()}renderHull(e){let t=e==null?e=new Pe:void 0,{hull:n,points:r}=this,i=n[0]*2,a=n.length;e.moveTo(r[i],r[i+1]);for(let t=1;t<a;++t){let i=2*n[t];e.lineTo(r[i],r[i+1])}return e.closePath(),t&&t.value()}hullPolygon(){let e=new Fe;return this.renderHull(e),e.value()}renderTriangle(e,t){let n=t==null?t=new Pe:void 0,{points:r,triangles:i}=this,a=i[e*=3]*2,o=i[e+1]*2,s=i[e+2]*2;return t.moveTo(r[a],r[a+1]),t.lineTo(r[o],r[o+1]),t.lineTo(r[s],r[s+1]),t.closePath(),n&&n.value()}*trianglePolygons(){let{triangles:e}=this;for(let t=0,n=e.length/3;t<n;++t)yield this.trianglePolygon(t)}trianglePolygon(e){let t=new Fe;return this.renderTriangle(e,t),t.value()}};function We(e,t,n,r){let i=e.length,a=new Float64Array(i*2);for(let o=0;o<i;++o){let i=e[o];a[o*2]=t.call(r,i,o,e),a[o*2+1]=n.call(r,i,o,e)}return a}function*Ge(e,t,n,r){let i=0;for(let a of e)yield t.call(r,a,i,e),yield n.call(r,a,i,e),++i}function Ke(e,t,n,r){return 1+(e[t][0]===0||e[n][0]===0||e[r][0]===0?1:0)}function qe(e,t,n,r,i,a){let o=Math.hypot(n-i,r-a),s=Math.hypot(e-i,t-a),c=Math.hypot(e-n,t-r),l=Math.abs((n-e)*(a-t)-(i-e)*(r-t))/2;return l===0?1/0:o*s*c/(4*l)}function Je(e){if(!e||e.length<3)return[];let t=new Set,n=[];for(let r of e){let e=`${r[0]}_${r[1]}`;t.has(e)||(t.add(e),n.push(r))}if(n.length<3)return[];let{triangles:r}=new Ue(Float64Array.from(n.flat()));if(!r.length)return[];let i=new Map,a=(e,t)=>e<t?`${e}_${t}`:`${t}_${e}`;for(let e=0;e<r.length;e+=3){let t=r[e],o=r[e+1],s=r[e+2],[c,l]=n[t],[u,d]=n[o],[f,p]=n[s];if(qe(c,l,u,d,f,p)<=1/Ke(n,t,o,s))for(let[e,n]of[[t,o],[o,s],[s,t]]){let t=a(e,n);i.set(t,(i.get(t)||0)+1)}}let o=[];for(let[e,t]of i)t===1&&o.push(e.split(`_`).map(Number));if(!o.length)return[];let s=new Map;for(let[e,t]of o)(s.get(e)||s.set(e,[]).get(e)).push(t),(s.get(t)||s.set(t,[]).get(t)).push(e);let c=o[0][0],l=[],u=new Set,d=c,f=-1;do{l.push(n[d]),u.add(d);let e=s.get(d)||[],t=e.find(e=>e!==f&&!u.has(e));if(t===void 0&&(t=e.find(e=>e!==f)),t===void 0)break;f=d,d=t}while(d!==c&&l.length<=o.length+1);return l}var K={c:null,u:[new f.Vector3,new f.Vector3,new f.Vector3],e:[]},q={c:null,u:[new f.Vector3,new f.Vector3,new f.Vector3],e:[]},J=[[],[],[]],Y=[[],[],[]],X=[],Ye=new f.Vector3,Xe=new f.Vector3,Ze=new f.Vector3,Z=new f.Vector3,Qe=new f.Vector3,$e=new f.Vector3,Q=new f.Matrix3,et=new f.Box3,tt=new f.Matrix4,nt=new f.Matrix4,rt=new f.Ray,it=class{constructor(e=new f.Vector3,t=new f.Vector3,n=new f.Matrix3){this.center=e,this.halfSize=t,this.rotation=n}set(e,t,n){return this.center=e,this.halfSize=t,this.rotation=n,this}copy(e){return this.center.copy(e.center),this.halfSize.copy(e.halfSize),this.rotation.copy(e.rotation),this}clone(){return new this.constructor().copy(this)}getSize(e){return e.copy(this.halfSize).multiplyScalar(2)}clampPoint(e,t){let n=this.halfSize;Z.subVectors(e,this.center),this.rotation.extractBasis(Ye,Xe,Ze),t.copy(this.center);let r=f.MathUtils.clamp(Z.dot(Ye),-n.x,n.x);t.add(Ye.multiplyScalar(r));let i=f.MathUtils.clamp(Z.dot(Xe),-n.y,n.y);t.add(Xe.multiplyScalar(i));let a=f.MathUtils.clamp(Z.dot(Ze),-n.z,n.z);return t.add(Ze.multiplyScalar(a)),t}containsPoint(e){return Z.subVectors(e,this.center),this.rotation.extractBasis(Ye,Xe,Ze),Math.abs(Z.dot(Ye))<=this.halfSize.x&&Math.abs(Z.dot(Xe))<=this.halfSize.y&&Math.abs(Z.dot(Ze))<=this.halfSize.z}intersectsBox3(e){return this.intersectsOBB(at.fromBox3(e))}intersectsSphere(e){return this.clampPoint(e.center,$e),$e.distanceToSquared(e.center)<=e.radius*e.radius}intersectsOBB(e,t=2**-52){K.c=this.center,K.e[0]=this.halfSize.x,K.e[1]=this.halfSize.y,K.e[2]=this.halfSize.z,this.rotation.extractBasis(K.u[0],K.u[1],K.u[2]),q.c=e.center,q.e[0]=e.halfSize.x,q.e[1]=e.halfSize.y,q.e[2]=e.halfSize.z,e.rotation.extractBasis(q.u[0],q.u[1],q.u[2]);for(let e=0;e<3;e++)for(let t=0;t<3;t++)J[e][t]=K.u[e].dot(q.u[t]);Z.subVectors(q.c,K.c),X[0]=Z.dot(K.u[0]),X[1]=Z.dot(K.u[1]),X[2]=Z.dot(K.u[2]);for(let e=0;e<3;e++)for(let n=0;n<3;n++)Y[e][n]=Math.abs(J[e][n])+t;let n,r;for(let e=0;e<3;e++)if(n=K.e[e],r=q.e[0]*Y[e][0]+q.e[1]*Y[e][1]+q.e[2]*Y[e][2],Math.abs(X[e])>n+r)return!1;for(let e=0;e<3;e++)if(n=K.e[0]*Y[0][e]+K.e[1]*Y[1][e]+K.e[2]*Y[2][e],r=q.e[e],Math.abs(X[0]*J[0][e]+X[1]*J[1][e]+X[2]*J[2][e])>n+r)return!1;return n=K.e[1]*Y[2][0]+K.e[2]*Y[1][0],r=q.e[1]*Y[0][2]+q.e[2]*Y[0][1],!(Math.abs(X[2]*J[1][0]-X[1]*J[2][0])>n+r||(n=K.e[1]*Y[2][1]+K.e[2]*Y[1][1],r=q.e[0]*Y[0][2]+q.e[2]*Y[0][0],Math.abs(X[2]*J[1][1]-X[1]*J[2][1])>n+r)||(n=K.e[1]*Y[2][2]+K.e[2]*Y[1][2],r=q.e[0]*Y[0][1]+q.e[1]*Y[0][0],Math.abs(X[2]*J[1][2]-X[1]*J[2][2])>n+r)||(n=K.e[0]*Y[2][0]+K.e[2]*Y[0][0],r=q.e[1]*Y[1][2]+q.e[2]*Y[1][1],Math.abs(X[0]*J[2][0]-X[2]*J[0][0])>n+r)||(n=K.e[0]*Y[2][1]+K.e[2]*Y[0][1],r=q.e[0]*Y[1][2]+q.e[2]*Y[1][0],Math.abs(X[0]*J[2][1]-X[2]*J[0][1])>n+r)||(n=K.e[0]*Y[2][2]+K.e[2]*Y[0][2],r=q.e[0]*Y[1][1]+q.e[1]*Y[1][0],Math.abs(X[0]*J[2][2]-X[2]*J[0][2])>n+r)||(n=K.e[0]*Y[1][0]+K.e[1]*Y[0][0],r=q.e[1]*Y[2][2]+q.e[2]*Y[2][1],Math.abs(X[1]*J[0][0]-X[0]*J[1][0])>n+r)||(n=K.e[0]*Y[1][1]+K.e[1]*Y[0][1],r=q.e[0]*Y[2][2]+q.e[2]*Y[2][0],Math.abs(X[1]*J[0][1]-X[0]*J[1][1])>n+r)||(n=K.e[0]*Y[1][2]+K.e[1]*Y[0][2],r=q.e[0]*Y[2][1]+q.e[1]*Y[2][0],Math.abs(X[1]*J[0][2]-X[0]*J[1][2])>n+r))}intersectsPlane(e){this.rotation.extractBasis(Ye,Xe,Ze);let t=this.halfSize.x*Math.abs(e.normal.dot(Ye))+this.halfSize.y*Math.abs(e.normal.dot(Xe))+this.halfSize.z*Math.abs(e.normal.dot(Ze)),n=e.normal.dot(this.center)-e.constant;return Math.abs(n)<=t}intersectRay(e,t){return this.getSize(Qe),et.setFromCenterAndSize(Z.set(0,0,0),Qe),tt.setFromMatrix3(this.rotation),tt.setPosition(this.center),nt.copy(tt).invert(),rt.copy(e).applyMatrix4(nt),rt.intersectBox(et,t)?t.applyMatrix4(tt):null}intersectsRay(e){return this.intersectRay(e,Z)!==null}fromBox3(e){return e.getCenter(this.center),e.getSize(this.halfSize).multiplyScalar(.5),this.rotation.identity(),this}equals(e){return e.center.equals(this.center)&&e.halfSize.equals(this.halfSize)&&e.rotation.equals(this.rotation)}applyMatrix4(e){let t=e.elements,n=Z.set(t[0],t[1],t[2]).length(),r=Z.set(t[4],t[5],t[6]).length(),i=Z.set(t[8],t[9],t[10]).length();e.determinant()<0&&(n=-n),Q.setFromMatrix4(e);let a=1/n,o=1/r,s=1/i;return Q.elements[0]*=a,Q.elements[1]*=a,Q.elements[2]*=a,Q.elements[3]*=o,Q.elements[4]*=o,Q.elements[5]*=o,Q.elements[6]*=s,Q.elements[7]*=s,Q.elements[8]*=s,this.rotation.multiply(Q),this.halfSize.x*=n,this.halfSize.y*=r,this.halfSize.z*=i,Z.setFromMatrixPosition(e),this.center.add(Z),this}},at=new it,$=6371008.8,ot={centimeters:$*100,centimetres:$*100,degrees:360/(2*Math.PI),feet:$*3.28084,inches:$*39.37,kilometers:$/1e3,kilometres:$/1e3,meters:$,metres:$,miles:$/1609.344,millimeters:$*1e3,millimetres:$*1e3,nauticalmiles:$/1852,radians:1,yards:$*1.0936};function st(e,t,n={}){let r={type:`Feature`};return(n.id===0||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=t||{},r.geometry=e,r}function ct(e,t,n={}){if(!e)throw Error(`coordinates is required`);if(!Array.isArray(e))throw Error(`coordinates must be an Array`);if(e.length<2)throw Error(`coordinates must be at least 2 numbers long`);if(!ht(e[0])||!ht(e[1]))throw Error(`coordinates must contain numbers`);return st({type:`Point`,coordinates:e},t,n)}function lt(e,t,n={}){for(let t of e){if(t.length<4)throw Error(`Each LinearRing of a Polygon must have 4 or more Positions.`);if(t[t.length-1].length!==t[0].length)throw Error(`First and last Position are not equivalent.`);for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw Error(`First and last Position are not equivalent.`)}return st({type:`Polygon`,coordinates:e},t,n)}function ut(e,t=`kilometers`){let n=ot[t];if(!n)throw Error(t+` units is invalid`);return e*n}function dt(e,t=`kilometers`){let n=ot[t];if(!n)throw Error(t+` units is invalid`);return e/n}function ft(e){return e%(2*Math.PI)*180/Math.PI}function pt(e){return e%360*Math.PI/180}function mt(e,t=`kilometers`,n=`kilometers`){if(!(e>=0))throw Error(`length must be a positive number`);return ut(dt(e,t),n)}function ht(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function gt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _t(e,t,n){if(e!==null)for(var r,i,a,o,s,c,l,u=0,d=0,f,p=e.type,m=p===`FeatureCollection`,h=p===`Feature`,g=m?e.features.length:1,_=0;_<g;_++){l=m?e.features[_].geometry:h?e.geometry:e,f=l?l.type===`GeometryCollection`:!1,s=f?l.geometries.length:1;for(var v=0;v<s;v++){var y=0,b=0;if(o=f?l.geometries[v]:l,o!==null){c=o.coordinates;var x=o.type;switch(u=n&&(x===`Polygon`||x===`MultiPolygon`)?1:0,x){case null:break;case`Point`:if(t(c,d,_,y,b)===!1)return!1;d++,y++;break;case`LineString`:case`MultiPoint`:for(r=0;r<c.length;r++){if(t(c[r],d,_,y,b)===!1)return!1;d++,x===`MultiPoint`&&y++}x===`LineString`&&y++;break;case`Polygon`:case`MultiLineString`:for(r=0;r<c.length;r++){for(i=0;i<c[r].length-u;i++){if(t(c[r][i],d,_,y,b)===!1)return!1;d++}x===`MultiLineString`&&y++,x===`Polygon`&&b++}x===`Polygon`&&y++;break;case`MultiPolygon`:for(r=0;r<c.length;r++){for(b=0,i=0;i<c[r].length;i++){for(a=0;a<c[r][i].length-u;a++){if(t(c[r][i][a],d,_,y,b)===!1)return!1;d++}b++}y++}break;case`GeometryCollection`:for(r=0;r<o.geometries.length;r++)if(_t(o.geometries[r],t,n)===!1)return!1;break;default:throw Error(`Unknown Geometry Type`)}}}}}function vt(e){var t=[];return _t(e,function(e){t.push(e)}),t}function yt(e,t){var n,r,i,a,o,s,c,l,u,d,f=0,p=e.type===`FeatureCollection`,m=e.type===`Feature`,h=p?e.features.length:1;for(n=0;n<h;n++){for(s=p?e.features[n].geometry:m?e.geometry:e,l=p?e.features[n].properties:m?e.properties:{},u=p?e.features[n].bbox:m?e.bbox:void 0,d=p?e.features[n].id:m?e.id:void 0,c=s?s.type===`GeometryCollection`:!1,o=c?s.geometries.length:1,i=0;i<o;i++){if(a=c?s.geometries[i]:s,a===null){if(t(null,f,l,u,d)===!1)return!1;continue}switch(a.type){case`Point`:case`LineString`:case`MultiPoint`:case`Polygon`:case`MultiLineString`:case`MultiPolygon`:if(t(a,f,l,u,d)===!1)return!1;break;case`GeometryCollection`:for(r=0;r<a.geometries.length;r++)if(t(a.geometries[r],f,l,u,d)===!1)return!1;break;default:throw Error(`Unknown Geometry Type`)}}f++}}function bt(e,t,n){var r=n;return yt(e,function(e,i,a,o,s){r=i===0&&n===void 0?e:t(r,e,i,a,o,s)}),r}var xt=s(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n||=self).RBush=r()})(e,function(){"use strict";function e(e,r,i,a,o){(function e(n,r,i,a,o){for(;a>i;){if(a-i>600){var s=a-i+1,c=r-i+1,l=Math.log(s),u=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*u*(s-u)/s)*(c-s/2<0?-1:1);e(n,r,Math.max(i,Math.floor(r-c*u/s+d)),Math.min(a,Math.floor(r+(s-c)*u/s+d)),o)}var f=n[r],p=i,m=a;for(t(n,i,r),o(n[a],f)>0&&t(n,i,a);p<m;){for(t(n,p,m),p++,m--;o(n[p],f)<0;)p++;for(;o(n[m],f)>0;)m--}o(n[i],f)===0?t(n,i,m):t(n,++m,a),m<=r&&(i=m+1),r<=m&&(a=m-1)}})(e,r,i||0,a||e.length-1,o||n)}function t(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function n(e,t){return e<t?-1:e>t?1:0}var r=function(e){e===void 0&&(e=9),this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function i(e,t,n){if(!n)return t.indexOf(e);for(var r=0;r<t.length;r++)if(n(e,t[r]))return r;return-1}function a(e,t){o(e,0,e.children.length,t,e)}function o(e,t,n,r,i){i||=m(null),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(var a=t;a<n;a++){var o=e.children[a];s(i,e.leaf?r(o):o)}return i}function s(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function c(e,t){return e.minX-t.minX}function l(e,t){return e.minY-t.minY}function u(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function d(e){return e.maxX-e.minX+(e.maxY-e.minY)}function f(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function p(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function m(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function h(t,n,r,i,a){for(var o=[n,r];o.length;)if(!((r=o.pop())-(n=o.pop())<=i)){var s=n+Math.ceil((r-n)/i/2)*i;e(t,s,n,r,a),o.push(n,s,s,r)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(e){var t=this.data,n=[];if(!p(e,t))return n;for(var r=this.toBBox,i=[];t;){for(var a=0;a<t.children.length;a++){var o=t.children[a],s=t.leaf?r(o):o;p(e,s)&&(t.leaf?n.push(o):f(e,s)?this._all(o,n):i.push(o))}t=i.pop()}return n},r.prototype.collides=function(e){var t=this.data;if(!p(e,t))return!1;for(var n=[];t;){for(var r=0;r<t.children.length;r++){var i=t.children[r],a=t.leaf?this.toBBox(i):i;if(p(e,a)){if(t.leaf||f(e,a))return!0;n.push(i)}}t=n.pop()}return!1},r.prototype.load=function(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(var t=0;t<e.length;t++)this.insert(e[t]);return this}var n=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){var r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this},r.prototype.insert=function(e){return e&&this._insert(e,this.data.height-1),this},r.prototype.clear=function(){return this.data=m([]),this},r.prototype.remove=function(e,t){if(!e)return this;for(var n,r,a,o=this.data,s=this.toBBox(e),c=[],l=[];o||c.length;){if(o||(o=c.pop(),r=c[c.length-1],n=l.pop(),a=!0),o.leaf){var u=i(e,o.children,t);if(u!==-1)return o.children.splice(u,1),c.push(o),this._condense(c),this}a||o.leaf||!f(o,s)?r?(n++,o=r.children[n],a=!1):o=null:(c.push(o),l.push(n),n=0,r=o,o=o.children[0])}return this},r.prototype.toBBox=function(e){return e},r.prototype.compareMinX=function(e,t){return e.minX-t.minX},r.prototype.compareMinY=function(e,t){return e.minY-t.minY},r.prototype.toJSON=function(){return this.data},r.prototype.fromJSON=function(e){return this.data=e,this},r.prototype._all=function(e,t){for(var n=[];e;)e.leaf?t.push.apply(t,e.children):n.push.apply(n,e.children),e=n.pop();return t},r.prototype._build=function(e,t,n,r){var i,o=n-t+1,s=this._maxEntries;if(o<=s)return a(i=m(e.slice(t,n+1)),this.toBBox),i;r||(r=Math.ceil(Math.log(o)/Math.log(s)),s=Math.ceil(o/s**(r-1))),(i=m([])).leaf=!1,i.height=r;var c=Math.ceil(o/s),l=c*Math.ceil(Math.sqrt(s));h(e,t,n,l,this.compareMinX);for(var u=t;u<=n;u+=l){var d=Math.min(u+l-1,n);h(e,u,d,c,this.compareMinY);for(var f=u;f<=d;f+=c){var p=Math.min(f+c-1,d);i.children.push(this._build(e,f,p,r-1))}}return a(i,this.toBBox),i},r.prototype._chooseSubtree=function(e,t,n,r){for(;r.push(t),!t.leaf&&r.length-1!==n;){for(var i=1/0,a=1/0,o=void 0,s=0;s<t.children.length;s++){var c=t.children[s],l=u(c),d=(f=e,p=c,(Math.max(p.maxX,f.maxX)-Math.min(p.minX,f.minX))*(Math.max(p.maxY,f.maxY)-Math.min(p.minY,f.minY))-l);d<a?(a=d,i=l<i?l:i,o=c):d===a&&l<i&&(i=l,o=c)}t=o||t.children[0]}var f,p;return t},r.prototype._insert=function(e,t,n){var r=n?e:this.toBBox(e),i=[],a=this._chooseSubtree(r,this.data,t,i);for(a.children.push(e),s(a,r);t>=0&&i[t].children.length>this._maxEntries;)this._split(i,t),t--;this._adjustParentBBoxes(r,i,t)},r.prototype._split=function(e,t){var n=e[t],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);var o=this._chooseSplitIndex(n,i,r),s=m(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,a(n,this.toBBox),a(s,this.toBBox),t?e[t-1].children.push(s):this._splitRoot(n,s)},r.prototype._splitRoot=function(e,t){this.data=m([e,t]),this.data.height=e.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(e,t,n){for(var r,i,a,s,c,l,d,f=1/0,p=1/0,m=t;m<=n-t;m++){var h=o(e,0,m,this.toBBox),g=o(e,m,n,this.toBBox),_=(i=h,a=g,s=void 0,c=void 0,l=void 0,d=void 0,s=Math.max(i.minX,a.minX),c=Math.max(i.minY,a.minY),l=Math.min(i.maxX,a.maxX),d=Math.min(i.maxY,a.maxY),Math.max(0,l-s)*Math.max(0,d-c)),v=u(h)+u(g);_<f?(f=_,r=m,p=v<p?v:p):_===f&&v<p&&(p=v,r=m)}return r||n-t},r.prototype._chooseSplitAxis=function(e,t,n){var r=e.leaf?this.compareMinX:c,i=e.leaf?this.compareMinY:l;this._allDistMargin(e,t,n,r)<this._allDistMargin(e,t,n,i)&&e.children.sort(r)},r.prototype._allDistMargin=function(e,t,n,r){e.children.sort(r);for(var i=this.toBBox,a=o(e,0,t,i),c=o(e,n-t,n,i),l=d(a)+d(c),u=t;u<n-t;u++){var f=e.children[u];s(a,e.leaf?i(f):f),l+=d(a)}for(var p=n-t-1;p>=t;p--){var m=e.children[p];s(c,e.leaf?i(m):m),l+=d(c)}return l},r.prototype._adjustParentBBoxes=function(e,t,n){for(var r=n;r>=0;r--)s(t[r],e)},r.prototype._condense=function(e){for(var t=e.length-1,n=void 0;t>=0;t--)e[t].children.length===0?t>0?(n=e[t-1].children).splice(n.indexOf(e[t]),1):this.clear():a(e[t],this.toBBox)},r})})),St=c({default:()=>wt});function Ct(e,t){return e<t?-1:e>t?1:0}var wt,Tt=o((()=>{wt=class{constructor(e=[],t=Ct){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;let e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:n}=this,r=t[e];for(;e>0;){let i=e-1>>1,a=t[i];if(n(r,a)>=0)break;t[e]=a,e=i}t[e]=r}_down(e){let{data:t,compare:n}=this,r=this.length>>1,i=t[e];for(;e<r;){let r=(e<<1)+1,a=t[r],o=r+1;if(o<this.length&&n(t[o],a)<0&&(r=o,a=t[o]),n(a,i)>=0)break;t[e]=a,e=r}t[e]=i}}})),Et=s(((e,t)=>{t.exports=function(e,t,n,r){var i=e[0],a=e[1],o=!1;n===void 0&&(n=0),r===void 0&&(r=t.length);for(var s=(r-n)/2,c=0,l=s-1;c<s;l=c++){var u=t[n+c*2+0],d=t[n+c*2+1],f=t[n+l*2+0],p=t[n+l*2+1];d>a!=p>a&&i<(f-u)*(a-d)/(p-d)+u&&(o=!o)}return o}})),Dt=s(((e,t)=>{t.exports=function(e,t,n,r){var i=e[0],a=e[1],o=!1;n===void 0&&(n=0),r===void 0&&(r=t.length);for(var s=r-n,c=0,l=s-1;c<s;l=c++){var u=t[c+n][0],d=t[c+n][1],f=t[l+n][0],p=t[l+n][1];d>a!=p>a&&i<(f-u)*(a-d)/(p-d)+u&&(o=!o)}return o}})),Ot=s(((e,t)=>{var n=Et(),r=Dt();t.exports=function(e,t,i,a){return t.length>0&&Array.isArray(t[0])?r(e,t,i,a):n(e,t,i,a)},t.exports.nested=r,t.exports.flat=n})),kt=s(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):r((n||=self).predicates={})})(e,function(e){"use strict";let t=134217729;function n(e,t,n,r,i){let a,o,s,c,l=t[0],u=r[0],d=0,f=0;u>l==u>-l?(a=l,l=t[++d]):(a=u,u=r[++f]);let p=0;if(d<e&&f<n)for(u>l==u>-l?(s=a-((o=l+a)-l),l=t[++d]):(s=a-((o=u+a)-u),u=r[++f]),a=o,s!==0&&(i[p++]=s);d<e&&f<n;)u>l==u>-l?(s=a-((o=a+l)-(c=o-a))+(l-c),l=t[++d]):(s=a-((o=a+u)-(c=o-a))+(u-c),u=r[++f]),a=o,s!==0&&(i[p++]=s);for(;d<e;)s=a-((o=a+l)-(c=o-a))+(l-c),l=t[++d],a=o,s!==0&&(i[p++]=s);for(;f<n;)s=a-((o=a+u)-(c=o-a))+(u-c),u=r[++f],a=o,s!==0&&(i[p++]=s);return a===0&&p!==0||(i[p++]=a),p}function r(e){return new Float64Array(e)}let i=r(4),a=r(8),o=r(12),s=r(16),c=r(4);e.orient2d=function(e,r,l,u,d,f){let p=(r-f)*(l-d),m=(e-d)*(u-f),h=p-m;if(p===0||m===0||p>0!=m>0)return h;let g=Math.abs(p+m);return Math.abs(h)>=33306690738754716e-32*g?h:-function(e,r,l,u,d,f,p){let m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M=e-d,N=l-d,P=r-f,F=u-f;v=(O=(x=M-(b=(y=t*M)-(y-M)))*(C=F-(S=(y=t*F)-(y-F)))-((D=M*F)-b*S-x*S-b*C))-(w=O-(A=(x=P-(b=(y=t*P)-(y-P)))*(C=N-(S=(y=t*N)-(y-N)))-((k=P*N)-b*S-x*S-b*C))),i[0]=O-(w+v)+(v-A),v=(E=D-((T=D+w)-(v=T-D))+(w-v))-(w=E-k),i[1]=E-(w+v)+(v-k),v=(j=T+w)-T,i[2]=T-(j-v)+(w-v),i[3]=j;let I=function(e,t){let n=t[0];for(let r=1;r<e;r++)n+=t[r];return n}(4,i),ee=22204460492503146e-32*p;if(I>=ee||-I>=ee||(m=e-(M+(v=e-M))+(v-d),g=l-(N+(v=l-N))+(v-d),h=r-(P+(v=r-P))+(v-f),_=u-(F+(v=u-F))+(v-f),m===0&&h===0&&g===0&&_===0)||(ee=11093356479670487e-47*p+33306690738754706e-32*Math.abs(I),(I+=M*_+F*m-(P*g+N*h))>=ee||-I>=ee))return I;v=(O=(x=m-(b=(y=t*m)-(y-m)))*(C=F-(S=(y=t*F)-(y-F)))-((D=m*F)-b*S-x*S-b*C))-(w=O-(A=(x=h-(b=(y=t*h)-(y-h)))*(C=N-(S=(y=t*N)-(y-N)))-((k=h*N)-b*S-x*S-b*C))),c[0]=O-(w+v)+(v-A),v=(E=D-((T=D+w)-(v=T-D))+(w-v))-(w=E-k),c[1]=E-(w+v)+(v-k),v=(j=T+w)-T,c[2]=T-(j-v)+(w-v),c[3]=j;let L=n(4,i,4,c,a);v=(O=(x=M-(b=(y=t*M)-(y-M)))*(C=_-(S=(y=t*_)-(y-_)))-((D=M*_)-b*S-x*S-b*C))-(w=O-(A=(x=P-(b=(y=t*P)-(y-P)))*(C=g-(S=(y=t*g)-(y-g)))-((k=P*g)-b*S-x*S-b*C))),c[0]=O-(w+v)+(v-A),v=(E=D-((T=D+w)-(v=T-D))+(w-v))-(w=E-k),c[1]=E-(w+v)+(v-k),v=(j=T+w)-T,c[2]=T-(j-v)+(w-v),c[3]=j;let R=n(L,a,4,c,o);return v=(O=(x=m-(b=(y=t*m)-(y-m)))*(C=_-(S=(y=t*_)-(y-_)))-((D=m*_)-b*S-x*S-b*C))-(w=O-(A=(x=h-(b=(y=t*h)-(y-h)))*(C=g-(S=(y=t*g)-(y-g)))-((k=h*g)-b*S-x*S-b*C))),c[0]=O-(w+v)+(v-A),v=(E=D-((T=D+w)-(v=T-D))+(w-v))-(w=E-k),c[1]=E-(w+v)+(v-k),v=(j=T+w)-T,c[2]=T-(j-v)+(w-v),c[3]=j,s[n(R,o,4,c,s)-1]}(e,r,l,u,d,f,g)},e.orient2dfast=function(e,t,n,r,i,a){return(t-a)*(n-i)-(e-i)*(r-a)},Object.defineProperty(e,`__esModule`,{value:!0})})})),At=u(s(((e,t)=>{var n=xt(),r=(Tt(),d(St)),i=Ot(),a=kt().orient2d;r.default&&(r=r.default),t.exports=o,t.exports.default=o;function o(e,t,r){t=Math.max(0,t===void 0?2:t),r||=0;var i=g(e),a=new n(16);a.toBBox=function(e){return{minX:e[0],minY:e[1],maxX:e[0],maxY:e[1]}},a.compareMinX=function(e,t){return e[0]-t[0]},a.compareMinY=function(e,t){return e[1]-t[1]},a.load(e);for(var o=[],c=0,l;c<i.length;c++){var u=i[c];a.remove(u),l=_(u,l),o.push(l)}var d=new n(16);for(c=0;c<o.length;c++)d.insert(h(o[c]));for(var f=t*t,p=r*r;o.length;){var m=o.shift(),y=m.p,b=m.next.p,x=v(y,b);if(!(x<p)){var S=x/f;u=s(a,m.prev.p,y,b,m.next.next.p,S,d),u&&Math.min(v(u,y),v(u,b))<=S&&(o.push(m),o.push(_(u,m)),a.remove(u),d.remove(m),d.insert(h(m)),d.insert(h(m.next)))}}m=l;var C=[];do C.push(m.p),m=m.next;while(m!==l);return C.push(m.p),C}function s(e,t,n,i,a,o,s){for(var u=new r([],c),d=e.data;d;){for(var p=0;p<d.children.length;p++){var m=d.children[p],h=d.leaf?y(m,n,i):l(n,i,m);h>o||u.push({node:m,dist:h})}for(;u.length&&!u.peek().node.children;){var g=u.pop(),_=g.node,v=y(_,t,n),b=y(_,i,a);if(g.dist<v&&g.dist<b&&f(n,_,s)&&f(i,_,s))return _}d=u.pop(),d&&=d.node}return null}function c(e,t){return e.dist-t.dist}function l(e,t,n){if(u(e,n)||u(t,n))return 0;var r=b(e[0],e[1],t[0],t[1],n.minX,n.minY,n.maxX,n.minY);if(r===0)return 0;var i=b(e[0],e[1],t[0],t[1],n.minX,n.minY,n.minX,n.maxY);if(i===0)return 0;var a=b(e[0],e[1],t[0],t[1],n.maxX,n.minY,n.maxX,n.maxY);if(a===0)return 0;var o=b(e[0],e[1],t[0],t[1],n.minX,n.maxY,n.maxX,n.maxY);return o===0?0:Math.min(r,i,a,o)}function u(e,t){return e[0]>=t.minX&&e[0]<=t.maxX&&e[1]>=t.minY&&e[1]<=t.maxY}function f(e,t,n){for(var r=Math.min(e[0],t[0]),i=Math.min(e[1],t[1]),a=Math.max(e[0],t[0]),o=Math.max(e[1],t[1]),s=n.search({minX:r,minY:i,maxX:a,maxY:o}),c=0;c<s.length;c++)if(m(s[c].p,s[c].next.p,e,t))return!1;return!0}function p(e,t,n){return a(e[0],e[1],t[0],t[1],n[0],n[1])}function m(e,t,n,r){return e!==r&&t!==n&&p(e,t,n)>0!=p(e,t,r)>0&&p(n,r,e)>0!=p(n,r,t)>0}function h(e){var t=e.p,n=e.next.p;return e.minX=Math.min(t[0],n[0]),e.minY=Math.min(t[1],n[1]),e.maxX=Math.max(t[0],n[0]),e.maxY=Math.max(t[1],n[1]),e}function g(e){for(var t=e[0],n=e[0],r=e[0],a=e[0],o=0;o<e.length;o++){var s=e[o];s[0]<t[0]&&(t=s),s[0]>r[0]&&(r=s),s[1]<n[1]&&(n=s),s[1]>a[1]&&(a=s)}var c=[t,n,r,a],l=c.slice();for(o=0;o<e.length;o++)i(e[o],c)||l.push(e[o]);return S(l)}function _(e,t){var n={p:e,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return t?(n.next=t.next,n.prev=t,t.next.prev=n,t.next=n):(n.prev=n,n.next=n),n}function v(e,t){var n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r}function y(e,t,n){var r=t[0],i=t[1],a=n[0]-r,o=n[1]-i;if(a!==0||o!==0){var s=((e[0]-r)*a+(e[1]-i)*o)/(a*a+o*o);s>1?(r=n[0],i=n[1]):s>0&&(r+=a*s,i+=o*s)}return a=e[0]-r,o=e[1]-i,a*a+o*o}function b(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=e-i,p=t-a,m=c*c+l*l,h=c*u+l*d,g=u*u+d*d,_=c*f+l*p,v=u*f+d*p,y=m*g-h*h,b,x,S,C,w=y,T=y;y===0?(x=0,w=1,C=v,T=g):(x=h*v-g*_,C=m*v-h*_,x<0?(x=0,C=v,T=g):x>w&&(x=w,C=v+h,T=g)),C<0?(C=0,-_<0?x=0:-_>m?x=w:(x=-_,w=m)):C>T&&(C=T,-_+h<0?x=0:-_+h>m?x=w:(x=-_+h,w=m)),b=x===0?0:x/w,S=C===0?0:C/T;var E=(1-b)*e+b*n,D=(1-b)*t+b*r,O=(1-S)*i+S*o,k=(1-S)*a+S*s,A=O-E,j=k-D;return A*A+j*j}function x(e,t){return e[0]===t[0]?e[1]-t[1]:e[0]-t[0]}function S(e){e.sort(x);for(var t=[],n=0;n<e.length;n++){for(;t.length>=2&&p(t[t.length-2],t[t.length-1],e[n])<=0;)t.pop();t.push(e[n])}for(var r=[],i=e.length-1;i>=0;i--){for(;r.length>=2&&p(r[r.length-2],r[r.length-1],e[i])<=0;)r.pop();r.push(e[i])}return r.pop(),t.pop(),t.concat(r)}}))(),1);function jt(e,t={}){t.concavity=t.concavity||1/0;let n=[];if(_t(e,e=>{n.push([e[0],e[1]])}),!n.length)return null;let r=(0,At.default)(n,t.concavity);return r.length>3?lt([r]):null}function Mt(e,t={}){let n=0,r=0,i=0;return _t(e,function(e){n+=e[0],r+=e[1],i++},!0),ct([n/i,r/i],t.properties)}function Nt(e){if(!e)throw Error(`coord is required`);if(!Array.isArray(e)){if(e.type===`Feature`&&e.geometry!==null&&e.geometry.type===`Point`)return[...e.geometry.coordinates];if(e.type===`Point`)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw Error(`coord must be GeoJSON Point or an Array of numbers`)}function Pt(e){if(Array.isArray(e))return e;if(e.type===`Feature`){if(e.geometry!==null)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw Error(`coords must be GeoJSON Feature, Geometry Object or an Array`)}function Ft(e,t,n={}){let r;return r=n.final?It(Nt(t),Nt(e)):It(Nt(e),Nt(t)),r>180?-(360-r):r}function It(e,t){let n=pt(e[1]),r=pt(t[1]),i=pt(t[0]-e[0]);i>Math.PI&&(i-=2*Math.PI),i<-Math.PI&&(i+=2*Math.PI);let a=Math.log(Math.tan(r/2+Math.PI/4)/Math.tan(n/2+Math.PI/4));return(ft(Math.atan2(i,a))+360)%360}function Lt(e,t,n={}){let r=Nt(e),i=Nt(t);return i[0]+=i[0]-r[0]>180?-360:r[0]-i[0]>180?360:0,mt(Rt(r,i),`meters`,n.units)}function Rt(e,t,n){n=n===void 0?$:Number(n);let r=n,i=e[1]*Math.PI/180,a=t[1]*Math.PI/180,o=a-i,s=Math.abs(t[0]-e[0])*Math.PI/180;s>Math.PI&&(s-=2*Math.PI);let c=Math.log(Math.tan(a/2+Math.PI/4)/Math.tan(i/2+Math.PI/4)),l=Math.abs(c)>1e-11?o/c:Math.cos(i);return Math.sqrt(o*o+l*l*s*s)*r}function zt(e,t,n,r={}){let i=t<0,a=mt(Math.abs(t),r.units,`meters`);i&&(a=-Math.abs(a));let o=Nt(e),s=Bt(o,a,n);return s[0]+=s[0]-o[0]>180?-360:o[0]-s[0]>180?360:0,ct(s,r.properties)}function Bt(e,t,n,r){r=r===void 0?$:Number(r);let i=t/r,a=e[0]*Math.PI/180,o=pt(e[1]),s=pt(n),c=i*Math.cos(s),l=o+c;Math.abs(l)>Math.PI/2&&(l=l>0?Math.PI-l:-Math.PI-l);let u=Math.log(Math.tan(l/2+Math.PI/4)/Math.tan(o/2+Math.PI/4)),d=Math.abs(u)>1e-11?c/u:Math.cos(o);return[((a+i*Math.sin(s)/d)*180/Math.PI+540)%360-180,l*180/Math.PI]}function Vt(e){if(!e)throw Error(`geojson is required`);switch(e.type){case`Feature`:return Ht(e);case`FeatureCollection`:return Wt(e);case`Point`:case`LineString`:case`Polygon`:case`MultiPoint`:case`MultiLineString`:case`MultiPolygon`:case`GeometryCollection`:return Gt(e);default:throw Error(`unknown GeoJSON type`)}}function Ht(e){let t={type:`Feature`};return Object.keys(e).forEach(n=>{switch(n){case`type`:case`properties`:case`geometry`:return;default:t[n]=e[n]}}),t.properties=Ut(e.properties),e.geometry==null?t.geometry=null:t.geometry=Gt(e.geometry),t}function Ut(e){let t={};return e&&Object.keys(e).forEach(n=>{let r=e[n];typeof r==`object`?r===null?t[n]=null:Array.isArray(r)?t[n]=r.map(e=>e):t[n]=Ut(r):t[n]=r}),t}function Wt(e){let t={type:`FeatureCollection`};return Object.keys(e).forEach(n=>{switch(n){case`type`:case`features`:return;default:t[n]=e[n]}}),t.features=e.features.map(e=>Ht(e)),t}function Gt(e){let t={type:e.type};return e.bbox&&(t.bbox=e.bbox),e.type===`GeometryCollection`?(t.geometries=e.geometries.map(e=>Gt(e)),t):(t.coordinates=Kt(e.coordinates),t)}function Kt(e){let t=e;return typeof t[0]==`object`?t.map(e=>Kt(e)):t.slice()}function qt(e,t,n){if(n||={},!gt(n))throw Error(`options is invalid`);let r=n.pivot,i=n.mutate;if(!e)throw Error(`geojson is required`);if(t==null||isNaN(t))throw Error(`angle is required`);if(t===0)return e;let a=r??Mt(e);return(i===!1||i===void 0)&&(e=Vt(e)),_t(e,function(e){let n=Ft(a,e)+t,r=Pt(zt(a,Lt(a,e),n));e[0]=r[0],e[1]=r[1]}),e}function Jt(e,t,n={}){if(n.final===!0)return Yt(e,t);let r=Nt(e),i=Nt(t),a=pt(r[0]),o=pt(i[0]),s=pt(r[1]),c=pt(i[1]),l=Math.sin(o-a)*Math.cos(c),u=Math.cos(s)*Math.sin(c)-Math.sin(s)*Math.cos(c)*Math.cos(o-a);return ft(Math.atan2(l,u))}function Yt(e,t){let n=Jt(t,e);return n=(n+180)%360,n}function Xt(e,t={}){if(e.bbox!=null&&!0!==t.recompute)return e.bbox;let n=[1/0,1/0,-1/0,-1/0];return _t(e,e=>{n[0]>e[0]&&(n[0]=e[0]),n[1]>e[1]&&(n[1]=e[1]),n[2]<e[0]&&(n[2]=e[0]),n[3]<e[1]&&(n[3]=e[1])}),n}function Zt(e,t={}){let n=Number(e[0]),r=Number(e[1]),i=Number(e[2]),a=Number(e[3]);if(e.length===6)throw Error(`@turf/bbox-polygon does not support BBox with 6 positions`);let o=[n,r];return lt([[o,[i,r],[i,a],[n,a],o]],t.properties,{bbox:e,id:t.id})}function Qt(e){return Zt(Xt(e))}function $t(e){return bt(e,(e,t)=>e+en(t),0)}function en(e){let t=0,n;switch(e.type){case`Polygon`:return tn(e.coordinates);case`MultiPolygon`:for(n=0;n<e.coordinates.length;n++)t+=tn(e.coordinates[n]);return t;case`Point`:case`MultiPoint`:case`LineString`:case`MultiLineString`:return 0}return 0}function tn(e){let t=0;if(e&&e.length>0){t+=Math.abs(an(e[0]));for(let n=1;n<e.length;n++)t-=Math.abs(an(e[n]))}return t}var nn=$*$/2,rn=Math.PI/180;function an(e){let t=e.length-1;if(t<=2)return 0;let n=0,r=0;for(;r<t;){let i=e[r],a=e[r+1===t?0:r+1],o=e[r+2>=t?(r+2)%t:r+2],s=i[0]*rn,c=a[1]*rn,l=o[0]*rn;n+=(l-s)*Math.sin(c),r++}return n*nn}function on(e){let t=jt(e);if(!t)throw Error(`Can't calculate smallestSurroundingRectangleByArea for given geometry`);let n=Mt(t),r=vt(t),i=2**53-1,a=null;for(let e=0;e<r.length-1;e++){let o=Jt(r[e],r[e+1]),s=Qt(qt(t,-1*o,{pivot:n})),c=$t(s);c<i&&(i=c,a=qt(s,o,{pivot:n}))}return a}function sn(e,t){let n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)}function cn(e){let t=1/0,n=-1/0,r=1/0,i=-1/0;for(let[a,o]of e)a<t&&(t=a),a>n&&(n=a),o<r&&(r=o),o>i&&(i=o);return[(n+t)*.5,(i+r)*.5]}var ln=class e extends it{getBoxMesh(){un.identity(),un.setFromMatrix3(this.rotation),un.decompose(mn,dn,new f.Vector3);let e=this.halfSize.clone().multiplyScalar(2),t=new f.Mesh(new f.BoxGeometry(e.x,e.y,e.z));return t.position.copy(this.center),t.rotation.setFromQuaternion(dn),t}getBoxEdge(e=16776960){let t=this.getBoxMesh();hn.setFromObject(t);let n=new f.EdgesGeometry(t.geometry.clone().applyMatrix4(t.matrixWorld));return new f.LineSegments(n,new f.LineBasicMaterial({color:e,toneMapped:!1}))}toJson(){return un.identity(),un.setFromMatrix3(this.rotation),un.decompose(mn,dn,new f.Vector3),{size:this.halfSize.toArray(),center:this.center.toArray(),quaternion:dn.toArray()}}static from(t,n,r,i=new e){if(r instanceof f.Euler)dn.setFromEuler(r);else if(r instanceof f.Quaternion)dn.copy(r);else throw Error(`传入的旋转不是欧拉角或者四元数`);return un.compose(n,dn,pn),i.center.copy(n),i.halfSize.copy(t.multiplyScalar(.5)),i.rotation.setFromMatrix4(un),i}static fromByPath2D(t,n,r,i=new e){let a=on({type:`Polygon`,coordinates:[t.map(e=>[e.x,e.y])]});if(!a)throw Error(`2d obb 获取失败`);let o=a.geometry.coordinates[0],s=sn(o[0],o[1]),c=sn(o[1],o[2]),l=Math.atan2(o[1][1]-o[0][1],o[1][0]-o[0][0]);mn.set(s,c,r),fn.set(0,0,l);let[u,d]=cn(o);return n.x=u,n.y=d,this.from(mn,n,fn,i)}},un=new f.Matrix4,dn=new f.Quaternion,fn=new f.Euler,pn=new f.Vector3(1,1,1),mn=new f.Vector3,hn=new f.Box3;function gn(e,t,n=.005,r=.2){if(!e.length||!t.length)return 0;let i=Math.max(n*3,.05),a=n*n,o=new Map,s=(e,t,n)=>`${Math.floor(e/i)},${Math.floor(t/i)},${Math.floor(n/i)}`;for(let e of t){let t=s(e.x,e.y,e.z);o.has(t)||o.set(t,[]),o.get(t).push(e)}let c=0,l=Math.ceil(n/i)+1,u=[];for(let e=-l;e<=l;e++)for(let t=-l;t<=l;t++)for(let n=-l;n<=l;n++)e*e+t*t+n*n<=l*l&&u.push([e,t,n]);for(let t of e){let n=Math.floor(t.x/i),s=Math.floor(t.y/i),l=Math.floor(t.z/i),d=!1;for(let[e,r,i]of u){let c=`${n+e},${s+r},${l+i}`;if(o.has(c)){for(let e of o.get(c))if(t.distanceToSquared(e)<a){d=!0;break}if(d)break}}if(d&&(c++,c/e.length>r))return c/e.length}return c/e.length}function _n(e,t,n=.5){let r=0,i=0;for(let a of e)if(t.containsPoint(a)&&(r++,i=r/e.length,i>n))break;return i}function vn(e,t,n,r){if(e.intersectsOBB(t))return!0;{let i=bn(e,r),a=bn(t,n);if(i||a)return!0}return!1}function yn(e,t){let n=new f.Vector3,r=new f.Vector3;e.getSize(n),t.getSize(r);let i=n.x*n.y*n.z,a=r.x*r.y*r.z;return i>a?1:i<a?-1:0}function bn(e,t){let n=!0;for(let r=0;r<t.length;r++)if(!e.containsPoint(t[r])){n=!1;break}return n}function xn(e){if(e.length===0)return{x:0,y:0,z:0,h:0};let t=0,n=0,r=-1/0,i=1/0;for(let a of e)t+=a.x,n+=a.y,r=Math.max(r,a.z),i=Math.min(i,a.z);return{x:t/e.length,y:n/e.length,z:0,maxz:r,minz:i,h:r-i}}function Sn(e,t,n,r){let i=[];for(let t=0;t<e.length;t++)i.push(new f.Vector3(e[t][0],e[t][1],0));if(i.length==0)return null;let a=ln.fromByPath2D(i,t,n);return a.center.z=r,a}var Cn=e=>{if(e.length==0)return[];let t=[];for(let n=0;n<e.length;n++){let r=e[n].points.map(e=>[e.x,e.y]),i=xn(e[n].points),a=e[n].obj_id;a=a.replace(/calcony railing/g,`balcony railing`).replace(/glass balcony railing/g,`balcony railing`).replace(/metal balcony railing/g,`balcony railing`).replace(/temporary construction guardrail/g,`balcony railing`),a.split(`_`).slice(1,3).join(`_`).split(`.`)[0].split(`_`)[0];let o=a.indexOf(`_`)+1,s=a.lastIndexOf(`_`),c=a.substring(o,s),l=[];for(let t=0;t<e[n].points.length;t++)l.push(new f.Vector3(e[n].points[t].x,e[n].points[t].y,e[n].points[t].z));let u={points:l,path:Je(r),h:i.h,minz:i.minz,maxz:i.maxz,center:{x:i.x,y:i.y,z:i.z},obj_id:e[n].obj_id,type:c,averagePz:e[n].averagePz,obb:null,isDel:!1,obj_id:a,positionArr:[e[n].position]};if(u.obb=Sn(u.path,u.center,u.h,(u.maxz+u.minz)/2),u.obb==null)continue;let d=-1;for(let e=0;e<t.length;e++)if(t[e].type==c){d=e;break}d==-1?t.push({type:c,array:[u]}):t[d].array.push(u)}for(let e=0;e<t.length;e++){let n=t[e].array,r=[],i=[];for(let e=0;e<n.length;e++){if(n[e].obb==null||r.includes(e))continue;let t={...n[e],obb:n[e].obb.clone()};for(let i=e+1;i<n.length;i++)if(!(n[i].obb==null||r.includes(i))&&t.obb.intersectsOBB(n[i].obb)){r.push(i),t.points.push(...n[i].points),t.path=Je(t.points.map(e=>[e.x,e.y]));let a=xn(t.points);t.h=a.h,t.minz=a.minz,t.maxz=a.maxz,t.center={x:a.x,y:a.y,z:a.z},t.obb=Sn(t.path,t.center,t.h,(t.maxz+t.minz)/2),t.positionArr.push(...n[i].positionArr),i=e}t.path.length>n[e].path.length&&(r.push(e),i.push(t))}let a=[];for(let e=0;e<n.length;e++)r.includes(e)||a.push(n[e]);a.push(...i),t[e].array=a}for(let e=0;e<t.length;e++){let n=t[e].type,r=t[e].array;for(let i=0;i<r.length;i++){let a=r[i].obb,o=r[i].minz;r[i].maxz;let s=r[i].averagePz;if(n===`window`||n===`door`||n===`tv`||n===`chair`||n===`cabinet`||n===`table`){let e=new f.Vector3;a.getSize(e);let t=[e.x,e.y,e.z],n=0;for(let e of t)if(e<.2&&(n++,n===2)){r[i].isDel=!0;break}}if(!r[i].isDel)for(let c=e+1;c<t.length;c++){let e=t[c].type,l=t[c].array;for(let t=0;t<l.length;t++){if(l[t].isDel)continue;let c=l[t].obb,u=l[t].minz;if(l[t].maxz,a.intersectsOBB(c)){_n(l[t].points,a);let d=_n(r[i].points,c),f=yn(a,c);if(d>=.3&&f==-1){r[i].isDel=!0;break}if(n!==`wall`&&n!==`floor`&&n!==`roof`){if(n===`window`){if(e===`balcony railing`&&containsObb(a,l[t].points)){l[t].isDel=!0;continue}if(e===`balcony railing`&&containsObb(c,r[i].points)){r[i].isDel=!0;break}if(e===`balcony railing`&&vn(a,c,r[i].points,l[t].points)&&(Math.abs(o-u)<.1||Math.abs(u-s)>.3)){l[t].isDel=!0;continue}}else if(n===`balcony railing`){if(e===`window`&&containsObb(a,l[t].points)){l[t].isDel=!0;continue}if(e===`window`&&containsObb(c,r[i].points)){r[i].isDel=!0;break}if(e===`window`&&vn(a,c,r[i].points,l[t].points)&&(Math.abs(o-u)<.1||Math.abs(o-s)>.3)){r[i].isDel=!0;break}}let d=!1,f=[],p=[],m=r[i].points,h=l[t].points;if(m.length>h.length?(d=!0,f=m,p=h):(f=h,p=m),gn(p,f,.03,.5)>.5){if(e===`people`){l[t].isDel=!0;continue}else if(n===`people`){r[i].isDel=!0;break}if(d)l[t].isDel=!0;else{r[i].isDel=!0;break}}else if(vn(a,c)){if(e===`people`){l[t].isDel=!0;continue}else if(n===`people`){r[i].isDel=!0;break}let o=yn(a,c);if(o===1||o===0){if(e===`switch`)continue;_n(p,a)>=.5&&(l[t].isDel=!0)}else{if(n===`switch`)continue;if(_n(p,c)>=.5){r[i].isDel=!0;break}}}}}}if(r[i].isDel)break}}}for(let e=0;e<t.length;e++){let n=t[e].type,r=t[e].array;for(let e=0;e<r.length;e++){let t=r[e].maxz,i=r[e].minz,a=n===`switch`?.1:.3,o=r[e].averagePz;if(Math.abs(t-o)<a){r[e].isDel=!0;continue}if(n===`window`||n===`door`||n===`tv`){let i=Math.abs(t-o);n!==`window`&&i<1.6&&(r[e].isDel=!0),n===`window`&&i<1&&(r[e].isDel=!0)}if(n===`chair`){let t=new f.Vector3;r[e].obb.getSize(t),(t.x<.1||t.y<.1)&&(r[e].isDel=!0)}n===`balcony railing`&&(Math.abs(t-i)<.4&&(r[e].isDel=!0),(i<o&&Math.abs(i-o)>1||i>o&&Math.abs(i-o)>1)&&(r[e].isDel=!0),t<o&&(r[e].isDel=!0))}}for(let e=0;e<t.length;e++)t[e].array=t[e].array.filter(e=>!e.isDel);let n=[];for(let e=0;e<t.length;e++){let r=t[e].array;for(let e=0;e<r.length;e++)n.push({obbBox:r[e].obb,box:new f.Box3().setFromPoints(r[e].points),category:r[e].type,center:{x:r[e].center.x,y:r[e].center.y,z:(r[e].minz+r[e].maxz)/2},name:r[e].obj_id,obj_id:r[e].obj_id,pcdPoints:r[e].points,positionArr:r[e].positionArr})}return n};exports.classifySegments=D,exports.getAllGeometry=ie,exports.getBeamLine=oe,exports.getColLine=ce,exports.getMainBeamLine=se,exports.getMergeMeaning=Cn,exports.getParallelism=w,exports.getPointCloudMinMax=M,exports.getPointCoverageOnQuad=A,exports.isParallel=y,exports.perpendicularInfo=T,exports.removeNoisePoints=P,exports.segmentsIntersect2D=g,exports.usegetBeamLine=ae;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(e&&(t=e(e=0)),t),s=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),c=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},l=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},u=(n,r,a)=>(a=n==null?{}:e(i(n)),l(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),d=e=>a.call(e,`module.exports`)?e[`module.exports`]:l(t({},`__esModule`,{value:!0}),e);let f=require(`three`);f=u(f);function p(e,t=!1){let n=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),a={},o={},s=e[0].morphTargetsRelative,c=new f.BufferGeometry,l=0;for(let u=0;u<e.length;++u){let d=e[u],f=0;if(n!==(d.index!==null))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.`),null;for(let e in d.attributes){if(!r.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. All geometries must have compatible attributes; make sure "`+e+`" attribute exists among all geometries, or in none of them.`),null;a[e]===void 0&&(a[e]=[]),a[e].push(d.attributes[e]),f++}if(f!==r.size)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. Make sure all geometries have the same number of attributes.`),null;if(s!==d.morphTargetsRelative)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. .morphTargetsRelative must be consistent throughout all geometries.`),null;for(let e in d.morphAttributes){if(!i.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. .morphAttributes must be consistent throughout all geometries.`),null;o[e]===void 0&&(o[e]=[]),o[e].push(d.morphAttributes[e])}if(t){let e;if(n)e=d.index.count;else if(d.attributes.position!==void 0)e=d.attributes.position.count;else return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. The geometry must have either an index or a position attribute`),null;c.addGroup(l,e,u),l+=e}}if(n){let t=0,n=[];for(let r=0;r<e.length;++r){let i=e[r].index;for(let e=0;e<i.count;++e)n.push(i.getX(e)+t);t+=e[r].attributes.position.count}c.setIndex(n)}for(let e in a){let t=m(a[e]);if(!t)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` attribute.`),null;c.setAttribute(e,t)}for(let e in o){let t=o[e][0].length;if(t===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[e]=[];for(let n=0;n<t;++n){let t=[];for(let r=0;r<o[e].length;++r)t.push(o[e][r][n]);let r=m(t);if(!r)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` morphAttribute.`),null;c.morphAttributes[e].push(r)}}return c}function m(e){let t,n,r,i=-1,a=0;for(let o=0;o<e.length;++o){let s=e[o];if(t===void 0&&(t=s.array.constructor),t!==s.array.constructor)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.`),null;if(n===void 0&&(n=s.itemSize),n!==s.itemSize)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.`),null;if(r===void 0&&(r=s.normalized),r!==s.normalized)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.`),null;if(i===-1&&(i=s.gpuType),i!==s.gpuType)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.`),null;a+=s.count*n}let o=new t(a),s=new f.BufferAttribute(o,n,r),c=0;for(let t=0;t<e.length;++t){let r=e[t];if(r.isInterleavedBufferAttribute){let e=c/n;for(let t=0,i=r.count;t<i;t++)for(let i=0;i<n;i++){let n=r.getComponent(t,i);s.setComponent(t+e,i,n)}}else o.set(r.array,c);c+=r.count*n}return i!==void 0&&(s.gpuType=i),s}var h=class extends f.Object3D{constructor(e=document.createElement(`div`)){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position=`absolute`,this.element.style.userSelect=`none`,this.element.setAttribute(`draggable`,!1),this.center=new f.Vector2(.5,.5),this.addEventListener(`removed`,function(){this.traverse(function(e){e.element&&e.element instanceof e.element.ownerDocument.defaultView.Element&&e.element.parentNode!==null&&e.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}};new f.Vector3,new f.Matrix4,new f.Matrix4,new f.Vector3,new f.Vector3;var g=(e,t,n,r,i=1e-8)=>{let a=t.x-e.x,o=t.y-e.y,s=r.x-n.x,c=r.y-n.y,l=a*c-o*s;if(Math.abs(l)<i)return null;let u=((n.x-e.x)*c-(n.y-e.y)*s)/l,d=((n.x-e.x)*o-(n.y-e.y)*a)/l;return u<-i||u>1+i||d<-i||d>1+i?null:{point:new f.Vector3(e.x+u*a,e.y+u*o,e.z)}},_=(e,t,n={})=>{let{fontSize:r=36,fontFamily:i=`sans-serif`,backgroundColor:a=`rgba(0,0,0,0)`,textColor:o=`#ffffff`,padding:s=10,maxWidth:c=256}=n,l=document.createElement(`canvas`).getContext(`2d`);l.font=`bold ${r}px ${i}`;let u=l.measureText(e).width,d=Math.min(u+s*2,c),p=r+s*2,m=document.createElement(`canvas`);m.width=d,m.height=p;let h=m.getContext(`2d`);h.fillStyle=a,h.fillRect(0,0,d,p),h.fillStyle=o,h.font=`bold ${r}px ${i}`,h.textAlign=`center`,h.textBaseline=`middle`,u>c-s*2?v(h,e,d/2,p/2,c,r):h.fillText(e,d/2,p/2);let g=new f.CanvasTexture(m),_=new f.SpriteMaterial({map:g,depthTest:!1,transparent:!0}),y=new f.Sprite(_);y.position.set(t.x,t.y,t.z);let b=.005;return y.scale.set(d*b,p*b,1),y};function v(e,t,n,r,i,a){let o=t.split(``),s=``,c=a*1.2,l=r;for(let t=0;t<o.length;t++){let r=s+o[t];e.measureText(r).width>i&&t>0?(e.fillText(s,n,l),s=o[t],l+=c):s=r}e.fillText(s,n,l)}var y=(e,t,n=.01)=>{let r=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z),i=Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z);if(r<1e-10||i<1e-10)return{parallel:!1,sameDirection:null,angle:NaN};let a={x:e.x/r,y:e.y/r,z:e.z/r},o={x:t.x/i,y:t.y/i,z:t.z/i},s=a.x*o.x+a.y*o.y+a.z*o.z;s=Math.max(-1,Math.min(1,s));let c=Math.acos(Math.abs(s)),l=c<=n;return{parallel:l,sameDirection:l?s>0:null,angle:c}};function b(e,t,n){let r=new f.BufferGeometry,i=[],a=[];e.forEach(e=>i.push(e.x,e.y,e.z)),t.forEach(e=>i.push(e.x,e.y,e.z)),a.push(0,2,1,0,3,2),a.push(4,5,6,4,6,7),a.push(0,1,5,0,5,4),a.push(1,2,6,1,6,5),a.push(2,3,7,2,7,6),a.push(3,0,4,3,4,7),r.setAttribute(`position`,new f.Float32BufferAttribute(i,3)),r.setIndex(a),r.computeVertexNormals();let o=new f.MeshBasicMaterial({color:n==`door`?`green`:`#a7cc00`,transparent:!0,opacity:.5,side:f.DoubleSide});return new f.Mesh(r,o)}var x=class{constructor(e={}){this.config={value:e.value||`0.0000m`,position:e.position||new f.Vector3(0,0,0),style:{fontFamily:e.style?.fontFamily||`Arial, sans-serif`,fontSize:e.style?.fontSize||`16px`,fontWeight:e.style?.fontWeight||`normal`,fontStyle:e.style?.fontStyle||`normal`},backgroundOpacity:e.backgroundOpacity||.7},this.label=null,this.labelElement=null,this.createLabel()}createLabel(){return this.labelElement=document.createElement(`div`),this.labelElement.textContent=this.config.value,this.applyBlackWhiteStyle(),this.label=new h(this.labelElement),this.label.position.copy(this.config.position),this.label}applyBlackWhiteStyle(){let e=this.labelElement.style,t=this.config;e.fontFamily=t.style.fontFamily,e.fontSize=t.style.fontSize,e.fontWeight=t.style.fontWeight,e.fontStyle=t.style.fontStyle,e.color=`#FFFFFF`,e.textShadow=`0 1px 2px rgba(0, 0, 0, 0.5)`,e.backgroundColor=`rgba(0, 0, 0, ${t.backgroundOpacity})`,e.padding=`6px 12px`,e.borderRadius=`4px`,e.position=`absolute`,e.whiteSpace=`nowrap`,e.userSelect=`none`,e.pointerEvents=`none`,e.zIndex=`1000`,e.textAlign=`center`,e.lineHeight=`1.2`}updateValue(e){this.labelElement&&(this.labelElement.textContent=e)}updatePosition(e){this.label&&this.label.position.copy(e)}updateFontStyle(e){if(this.labelElement){let t=this.labelElement.style;e.fontFamily&&(t.fontFamily=e.fontFamily),e.fontSize&&(t.fontSize=e.fontSize),e.fontWeight&&(t.fontWeight=e.fontWeight),e.fontStyle&&(t.fontStyle=e.fontStyle)}}getLabel(){return this.label}getLabelElement(){return this.labelElement}dispose(){this.labelElement&&this.labelElement.parentNode&&this.labelElement.parentNode.removeChild(this.labelElement),this.label=null,this.labelElement=null}},S=e=>{let t=new f.Group,n=new f.Group;if(e&&e.length){let r=`green.red.pink.white.azure.yellow.bisque.grey.blanchedalmond.blue.blueviolet.brown.burlywood.cadetblue.chartreuse.chocolate.coral.cornflowerblue.cornsilk.crimson.cyan.darkblue.darkcyan.darkgoldenrod.darkgray.darkgreen.darkgrey.darkkhaki.darkmagenta.darkolivegreen.darkorange.darkorchid.darkred.darksalmon.darkseagreen.darkslateblue.darkslategray.darkslategrey.darkturquoise.darkviolet.deeppink.deepskyblue.dimgray.dimgrey.dodgerblue.firebrick.floralwhite.forestgreen.fuchsia.gainsboro.ghostwhite.gold.goldenrod.gray.aliceblue.greenyellow.black.honeydew.hotpink.indianred.indigo.ivory.khaki.lavender.lavenderblush.lawngreen.lemonchiffon.lightblue.lightcoral.lightcyan.lightgoldenrodyellow.lightgray.lightgreen.lightgrey.lightpink.lightsalmon.lightseagreen.lightskyblue.lightslategray.lightslategrey.lightsteelblue.lightyellow.lime.limegreen.linen.magenta.maroon.mediumaquamarine.mediumblue.mediumorchid.mediumpurple.mediumseagreen.mediumslateblue.mediumspringgreen.mediumturquoise.mediumvioletred.midnightblue.mintcream.mistyrose.moccasin.navajowhite.navy.oldlace.olive.olivedrab.orange.orangered.orchid.palegoldenrod.palegreen.paleturquoise.palevioletred.papayawhip.peachpuff.peru.pink.plum.powderblue.purple.rebeccapurple.yellow.rosybrown.royalblue.saddlebrown.salmon.sandybrown.seagreen.seashell.sienna.silver.skyblue.slateblue.slategray.slategrey.snow.springgreen.steelblue.tan.teal.thistle.tomato.turquoise.violet.wheat.white.whitesmoke.yellow.yellowgreen`.split(`.`);e.forEach((e,i)=>{let a=r[i],o=new f.Group,{pcdPoints:s,category:c,name:l,center:u,box:d,obbBox:p,contour:m,nline:h,coordinatesByWidth:g,coordinatesByArea:_}=e,v=s.length,y=new f.Box3(new f.Vector3(d.min.x,d.min.y,d.min.z),new f.Vector3(d.max.x,d.max.y,d.max.z)),S=new f.Box3Helper(y,a);o.add(S);let C=new x({value:l,position:new f.Vector3(u.x,u.y,u.z)}).getLabel();o.add(C);let w=new f.InstancedMesh(new f.SphereGeometry(.007,8,8),new f.MeshBasicMaterial({color:a}),v);o.add(w);let T=new f.Matrix4,E=0;if(s.forEach(e=>{T.setPosition(e.x,e.y,e.z),w.setMatrixAt(E,T),E++}),w.instanceMatrix.needsUpdate=!0,h){let e=new f.BufferGeometry;e.setFromPoints([new f.Vector3(h.start.x,h.start.y,h.start.z),new f.Vector3(h.end.x,h.end.y,h.end.z)]);let t=new f.LineBasicMaterial({color:`red`,depthTest:!1,depthWrite:!1});new f.Line(e,t);let n=new f.Vector3().copy(new f.Vector3(h.start.x,h.start.y,h.start.z)).add(new f.Vector3(h.end.x,h.end.y,h.end.z)).multiplyScalar(.5),r=new f.Vector3(h.centerDir.x,h.centerDir.y,h.centerDir.z);new f.ArrowHelper(r,n,1,`red`)}if(m){let e=[];m.forEach((t,n)=>{e.push(new f.Vector3(t.x,t.y,t.z))});let r=new f.BufferGeometry;r.setFromPoints(e);let i=new f.LineBasicMaterial({color:`yellow`,depthTest:!1,depthWrite:!1}),a=new f.Line(r,i);c==`door`?t.add(a):n.add(a)}if(_){let e=[],r=[];_.coordinates.forEach((t,n)=>{e.push(new f.Vector3(t.x,t.y,t.z)),r.length<4&&r.push(new f.Vector3(t.x,t.y,t.z))});let i=new f.BufferGeometry;i.setFromPoints(e);let a=new f.LineBasicMaterial({color:`green`,depthTest:!1,depthWrite:!1}),o=new f.Line(i,a);c==`door`?t.add(o):n.add(o);let s=b(r.map(e=>new f.Vector3(e.x,e.y,_.heightData.minZ)),r.map(e=>new f.Vector3(e.x,e.y,e.z)),c);c==`door`?t.add(s):n.add(s);let[l,u,d]=e,p=l.distanceTo(u),m=new f.Vector3().copy(l).add(u).multiplyScalar(.5);new x({value:String(p.toFixed(3)),position:m}).getLabel();let h=u.distanceTo(d),g=new f.Vector3().copy(u).add(d).multiplyScalar(.5);new x({value:String(h.toFixed(3)),position:g}).getLabel()}if(p){let e=new f.BoxGeometry(p.size.x,p.size.y,p.size.z),r=new f.LineBasicMaterial({color:a,linewidth:2}),i=new f.EdgesGeometry(e),o=new f.LineSegments(i,r),s=new Vector3(p.center.x,p.center.y,p.center.z),l=new Quaternion(p.rotation.x,p.rotation.y,p.rotation.z,p.rotation.w);o.position.copy(s),o.quaternion.copy(l),c==`door`?t.add(o):n.add(o)}})}return{AiProjectionGroup:t,AiProjectionGroup2:n}},C=(e,t,n,r)=>{let i=e,a=[];if(r&&r.length&&(a=r.map(e=>e.clone())),!i||i.length<4)return{};let o=new f.Vector3().subVectors(i[1],i[0]).normalize(),s=new f.Vector3().subVectors(i[3],i[0]).normalize(),c=o.clone().cross(s).normalize(),l=1/0,u=-1/0,d=1/0,p=-1/0;for(let e of i){let t=e.dot(o),n=e.dot(s);t<l&&(l=t),t>u&&(u=t),n<d&&(d=n),n>p&&(p=n)}let m=i[0].dot(c),h=o.clone().multiplyScalar(l).add(s.clone().multiplyScalar(d)).add(c.clone().multiplyScalar(m)),g=o.clone().multiplyScalar(u).add(s.clone().multiplyScalar(d)).add(c.clone().multiplyScalar(m)),_=o.clone().multiplyScalar(u).add(s.clone().multiplyScalar(p)).add(c.clone().multiplyScalar(m)),v=o.clone().multiplyScalar(l).add(s.clone().multiplyScalar(p)).add(c.clone().multiplyScalar(m)),b=[h,g,_,v],x=y(new f.Vector3().subVectors(h,g),new f.Vector3(0,0,1));x&&x.parallel&&(b=[h,v,_,g]);let S=0;if(r.length>0){let e=new f.Vector3().subVectors(b[1],b[0]).normalize(),r=e.clone().negate(),i=new f.Vector3().subVectors(b[3],b[0]).normalize(),o=i.clone().negate(),s=b[0].distanceTo(b[1]),c=b[0].distanceTo(b[3]),l=s/t,u=c/n,d=.001;for(let r=0;r<l;r++){let r=b[0],o=0;for(let s=0;s<u;s++){let s=r.clone().addScaledVector(e,t),c=s.clone().addScaledVector(i,n),l=r.clone().addScaledVector(i,n),u=new f.Vector3().add(r).add(s).add(c).add(l).multiplyScalar(.25);for(let e=0;e<a.length;e++)if(a[e].distanceTo(u)<d){o++;break}r=l}if(o>=u/2)break;S+=o,b[0]=b[0].addScaledVector(e,t),b[3]=b[3].addScaledVector(e,t)}s=b[0].distanceTo(b[1]),l=s/t;for(let e=0;e<l;e++){let e=b[1],o=0;for(let s=0;s<u;s++){let s=e.clone().addScaledVector(r,t),c=s.clone().addScaledVector(i,n),l=e.clone().addScaledVector(i,n),u=new f.Vector3().add(e).add(s).add(c).add(l).multiplyScalar(.25);for(let e=0;e<a.length;e++)if(a[e].distanceTo(u)<d){o++;break}e=l}if(o>=u/2)break;S+=o,b[1]=b[1].addScaledVector(r,t),b[2]=b[2].addScaledVector(r,t)}s=b[0].distanceTo(b[1]),l=s/t;for(let r=0;r<u;r++){let r=b[3],i=0;for(let s=0;s<l;s++){let s=r.clone().addScaledVector(e,t),c=s.clone().addScaledVector(o,n),l=r.clone().addScaledVector(o,n),u=new f.Vector3().add(r).add(s).add(c).add(l).multiplyScalar(.25);for(let e=0;e<a.length;e++)if(a[e].distanceTo(u)<d){i++;break}r=s}if(i>=l/2)break;S+=i,b[2]=b[2].addScaledVector(o,n),b[3]=b[3].addScaledVector(o,n)}}let C=b[0].distanceTo(b[1])*b[0].distanceTo(b[3]);return{facePoints:b,boxArea:C,totalInPlaneNum:S}},w=(e,t,n,r,i=f.MathUtils.degToRad(8))=>{let a=new f.Vector3,o=new f.Vector3;a.subVectors(new f.Vector3(t.x,t.y,0),new f.Vector3(e.x,e.y,0)).normalize(),o.subVectors(new f.Vector3(r.x,r.y,0),new f.Vector3(n.x,n.y,0)).normalize();let s=a.dot(o),c=Math.acos(Math.min(Math.abs(s),1)),l=1-Math.min(c/i,1),u=s>0?`same`:`opposite`;return{parallelism:l,angle:c,angleDeg:f.MathUtils.radToDeg(c),isParallel:c<i,direction:u,vectors:{v1:a,v2:o}}},T=(e,t,n,r)=>{let i=new f.Vector3().subVectors(t,e),a=new f.Vector3().subVectors(r,n),o=i.length(),s=a.length();if(o===0||s===0)return{rate:NaN,angle:NaN,isPerpendicular:!1,isParallel:!1};i.normalize(),a.normalize();let c=Math.abs(i.dot(a)),l=Math.min(1,Math.max(0,c)),u=Math.acos(l),d=f.MathUtils.radToDeg(u),p=1-l;return{rate:p,percent:`${(p*100).toFixed(2)}%`,angle:d,isPerpendicular:Math.abs(d-90)<.01,isParallel:d<.01}},E=(e,t,n=!1)=>new f.Vector3((e.x+t.x)/2,(e.y+t.y)/2,n?0:(e.z+t.z)/2),D=(e,t,n,r,i={})=>{let{parallelAngleMax:a=f.MathUtils.degToRad(10),collinearAngleMax:o=f.MathUtils.degToRad(7),distanceThreshold:s=2,overlapThreshold:c=.01}=i,l=new f.Vector3().subVectors(t,e),u=new f.Vector3().subVectors(r,n),d=l.clone().normalize(),p=u.clone().normalize(),m=f.MathUtils.clamp(d.dot(p),-1,1),h=Math.acos(Math.abs(m)),g=f.MathUtils.radToDeg(h);if(h>a)return{type:`not_parallel`,angleDeg:g,avgPerpendicularDistance:null,maxPerpendicularDistance:null,gap:null,overlap:null,closestDistance:null};m<0&&p.negate();let _=new f.Vector3().addVectors(d,p).normalize(),v=new f.Vector3().addVectors(e,t).multiplyScalar(.5),y=O(n,v,d),b=O(r,v,d),x=(y+b)/2,S=Math.max(y,b),C=e.dot(_),w=t.dot(_),T=n.dot(_),E=r.dot(_),D=Math.min(C,w),A=Math.max(C,w),j=Math.min(T,E),M=Math.max(T,E),N=A-D,P=M-j,F=Math.min(N,P),I=Math.min(A,M)-Math.max(D,j),ee=I<0?-I:0,L=I>0?I:0,R=F>0?L/F:0,z=k(e,t,n,r),B=h<=o&&x<s,V;return B?V=R>.5?`collinear_overlap`:`collinear_gap`:h<=a&&(V=`parallel_offset`),{type:V,angleDeg:g,avgPerpendicularDistance:x,maxPerpendicularDistance:S,gap:ee,overlap:L,closestDistance:z}};function O(e,t,n){let r=new f.Vector3().subVectors(e,t),i=r.dot(n),a=n.clone().multiplyScalar(i);return new f.Vector3().subVectors(r,a).length()}function k(e,t,n,r){let i=new f.Vector3().subVectors(t,e),a=new f.Vector3().subVectors(r,n),o=new f.Vector3().subVectors(n,e),s=i.dot(i),c=i.dot(a),l=a.dot(a),u=i.dot(o),d=a.dot(o),p=s*l-c*c,m,h;p<1e-10?(m=0,h=l===0?0:d/l):(m=(c*d-l*u)/p,h=(s*d-c*u)/p),m=f.MathUtils.clamp(m,0,1),h=l===0?0:f.MathUtils.clamp((c*m+d)/l,0,1),m=s===0?0:f.MathUtils.clamp((c*h-u)/s,0,1);let g=e.clone().add(i.clone().multiplyScalar(m)),_=n.clone().add(a.clone().multiplyScalar(h));return g.distanceTo(_)}var A=(e,t,n,r=.05,i=.02)=>{let[a,o,s,c]=e,l=new f.Vector3().subVectors(o,a),u=new f.Vector3().subVectors(c,a),d=new f.Vector3().crossVectors(l,u).normalize(),p=l.length(),m=u.length(),h=l.clone().normalize(),g=u.clone().normalize(),_=n-r,v=n+r,y=new f.Vector3,b=[],x=Math.ceil(p/i),S=Math.ceil(m/i),C=p/x,w=m/S,T=new Uint8Array(x*S);for(let e=0;e<t.length;e++){y.subVectors(t[e],a);let n=Math.abs(y.dot(d));if(n<_||n>v)continue;let r=y.dot(h),i=y.dot(g);if(r<0||r>p||i<0||i>m)continue;b.push(new f.Vector3(t[e].x,t[e].y,t[e].z));let o=Math.min(Math.floor(r/C),x-1),s=Math.min(Math.floor(i/w),S-1);T[s*x+o]=1}let E=0;for(let e=0;e<T.length;e++)T[e]&&E++;let D=x*S,O=p*m,k=E==0||D==0?0:E/D*O;return{filteredPoints:b,coveragePercent:E==0||D==0?0:E/D*100,quadArea:O,coveredArea:k}},j=(e,t)=>Math.round(Math.max(5,Math.min(350,t*Math.sqrt(e)))),M=e=>{let t=new f.Vector3(e.start.x,e.start.y,e.start.z),n=new f.Vector3(e.end.x,e.end.y,e.end.z),r=t.distanceTo(n),i=e.rooftopPz-e.start.z,a=j(r,100),o=j(i,70),s=i/o,c=new Map;for(let e=0;e<o;e++)c.set((e+1)*s,{count:0,minZ:1/0,maxZ:-1/0});let l=new f.Line3(t,n),u=e.originalPoints,d=new f.Vector3;for(let e=0;e<u.length;e++){let t=u[e],n=l.closestPointToPoint(t,!0,d).distanceTo(t),r=Math.floor(n/s);if(r<o){let e=c.get((r+1)*s);e.count++,t.z<e.minZ&&(e.minZ=t.z),t.z>e.maxZ&&(e.maxZ=t.z)}}let p,m,h=a/2;for(let[e,t]of c)if(t.count>=h){p=t.minZ;break}for(let[e,t]of[...c.entries()].reverse())if(t.count>=h){m=t.maxZ;break}return{minZ:p,maxZ:m}},N=(e,t,n)=>{let r=new f.Plane,i=new f.Vector3(e.x,e.y,e.z),a=new f.Vector3(t.x,t.y,t.z),o=new f.Vector3(t.x,t.y,t.z+5);r.setFromCoplanarPoints(i,a,o);let s=[];n.forEach(e=>{let t=new f.Vector3;r.projectPoint(e,t),t.z=i.z,s.push(t)});let c=new f.Vector3,l=new f.Vector3;r.projectPoint(i,c),r.projectPoint(a,l);let u=new f.Line3(c,l),d=[],p=[],m=new f.Vector3;return s.forEach((e,t)=>{u.closestPointToPoint(e,!0,m).distanceTo(e)<.001?d.push(n[t]):p.push(e)}),{newOriginalPoints:d,newProjectPoints:p}},P=e=>{function t(e,t,n,r,i,a,o,s,c){let l=new f.Line3(e,t),u=new Map,d=new f.Vector3,p=e.clone(),m=t.clone(),h=0;for(;;){let g=new Map,_=0;for(let e=0;e<c.checkResults.length;e++)if(!(c.checkResults[e].allCenterPoints.length/s*100<1))for(let t=0;t<c.checkResults[e].allCenterPoints.length;t++){if(u.has(e)&&u.get(e).removePtsIndex.includes(t))continue;let n=c.checkResults[e].allCenterPoints[t];n=new f.Vector3(n.x,n.y,n.z);let r=l.closestPointToPoint(n,!0,d),a=n.distanceTo(r);Math.abs(a-i)<.01&&(_++,g.has(e)?g.get(e).removePtsIndex.push(t):g.set(e,{index:e,removePtsIndex:[t]}))}if(h==o){e=p,t=m;break}if(_<a/20*18||_==0){g.clear(),o-h<5&&(e=p,t=m,u.clear());break}else{h++;for(let[e,t]of g)u.has(e)?u.get(e).removePtsIndex.push(...t.removePtsIndex):u.set(e,t);g.clear(),e=e.addScaledVector(n,r),t=t.addScaledVector(n,r),l.set(e,t)}}if(u.size>0&&h!=o)for(let[e,t]of u){let n=[],r=[];for(let i=0;i<c.checkResults[e].allCenterPoints.length;i++)t.removePtsIndex.includes(i)||(n.push(c.checkResults[e].allCenterPoints[i]),r.push(c.checkResults[e].originalVertices[i]));c.checkResults[e].allCenterPoints=n,c.checkResults[e].originalVertices=r}}for(let n=0;n<e.length;n++){let r=e[n];if(r.length<.5)continue;let i=-1,a=-1;if(!r.checkResults||r.checkResults.length<=0)continue;if(r.checkResults[0].originalVertices&&r.checkResults[0].originalVertices.length>0){let[e,t,n,o]=r.checkResults[0].originalVertices[0];e=new f.Vector3(e.x,e.y,e.z),t=new f.Vector3(t.x,t.y,t.z),n=new f.Vector3(n.x,n.y,n.z),o=new f.Vector3(o.x,o.y,o.z),i=e.distanceTo(t),a=e.distanceTo(o);let s=y(new f.Vector3().subVectors(e,t).normalize(),new f.Vector3(0,0,1));s&&s.parallel&&([a,i]=[i,a])}if(i<0||a<0)continue;let o=new f.Vector3(r.start.x,r.start.y,r.start.z),s=new f.Vector3(r.end.x,r.end.y,r.end.z),c=o.distanceTo(s),l=r.rooftopPz-r.start.z,u=Math.ceil(c/i),d=Math.ceil(l/a),p=o.clone(),m=s.clone(),h=m.clone().add(new f.Vector3(0,0,l)),g=p.clone().add(new f.Vector3(0,0,l)),_=new f.Vector3().subVectors(m,p).normalize(),v=_.clone().negate();new f.Vector3().subVectors(h,p).normalize().clone().negate();let b=i/2;a/2;let x=c*l/(i*a);t(p,g,_,i,b,d,u,x,r),t(m,h,v,i,b,d,u,x,r),r.start=p,r.end=m;let{newOriginalPoints:S}=N(p,m,r.originalPoints);r.originalPoints=S}},F=(e,t)=>new f.Vector3(e.x,e.y,0).distanceTo(new f.Vector3(t.x,t.y,0)),I=(e,t,n=1e-6)=>{let r=new f.Vector3;return e.closestPointToPoint(t,!0,r),r.distanceTo(t)<n},ee=e=>{let t=0,n=[];for(let r=0;r<e.length;r++)for(let i=r+1;i<e.length;i++){let a=e[r].distanceTo(e[i]);a>t&&(t=a,n=[e[r],e[i]])}return n},L=(e,t,n=.03)=>Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n&&Math.abs(e.z-t.z)<n,R=e=>{let t=[];e.children.forEach(e=>{e.type==`GridHelper`||e.type==`DirectionalLight`||e.type==`AmbientLight`||t.push(e)}),t.forEach(t=>{e.remove(t),B(t)})},z=()=>`#${Math.floor(Math.random()*75+180).toString(16).padStart(2,`0`)}${Math.floor(Math.random()*75+180).toString(16).padStart(2,`0`)}${Math.floor(Math.random()*75+180).toString(16).padStart(2,`0`)}`;function B(e){for(;e.children&&e.children.length>0;){let t=e.children[0];e.remove(t),B(t)}e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(e=>V(e)):V(e.material))}function V(e){for(let t of Object.keys(e)){let n=e[t];n&&typeof n==`object`&&typeof n.dispose==`function`&&n.dispose()}e.dispose()}var te=class{results;clusterResults;constructor(){this.results=null}initLimits1(e,t){let n,r;return n=e<.3?5:e<.5?8:e<.8?10:e<1?15:e<2?30:e<3?35:e<4?40:e<5?45:e<6?50:e<7?60:e<8.5?70:e<10?80:e<15?100:e<20?120:e<25?140:e<30?160:e<35?180:e<40?200:e<45?230:e<50?250:350,t<1?r=30:t<2?r=40:t<2.5?r=45:t<3?r=60:t<3.6?r=70:t<4&&(r=80),{horizontalSubdivisions:n,verticalSubdivisions:r}}initLimits2(e,t){return{horizontalSubdivisions:Math.round(Math.max(5,Math.min(350,e/.08))),verticalSubdivisions:Math.round(Math.max(30,Math.min(80,t/.06)))}}initLimits4(e,t){return{horizontalSubdivisions:Math.round(Math.max(5,Math.min(350,65*Math.sqrt(e))))*1,verticalSubdivisions:Math.round(Math.max(30,Math.min(80,15*Math.sqrt(t))))*1}}initLimits3(e,t){let n;return n=e<2?.06:e<10?.1:.15,{horizontalSubdivisions:Math.round(Math.max(5,Math.min(350,e/n))),verticalSubdivisions:Math.round(Math.max(30,Math.min(80,t/.06)))}}createWallPlaneMeshFromFourPoints(e,t,n,r,i,a,o=16777215){let s=[e,t,n,r];for(let e=0;e<s.length;e++)this.isValidVector3(s[e])||(console.error(`点${e+1}包含无效数据:`,s[e]),s[e]=new f.Vector3(e,0,e));let c=new f.BufferGeometry,l=new Float32Array([s[0].x,s[0].y,s[0].z,s[1].x,s[1].y,s[1].z,s[2].x,s[2].y,s[2].z,s[3].x,s[3].y,s[3].z]),u=[0,1,2,0,2,3],d=new Float32Array([0,0,1,0,1,1,0,1]);c.setAttribute(`position`,new f.BufferAttribute(l,3)),c.setAttribute(`uv`,new f.BufferAttribute(d,2)),c.setIndex(u),c.computeVertexNormals();let p=new f.Mesh(c,i),m=new f.EdgesGeometry(c),h=new f.LineSegments(m,new f.LineBasicMaterial({color:o}));return a.add(h),p}createSubdividedWallPlane(e,t,n,r,i){let a=[];if(!e||!e.start||!e.end||isNaN(e.rooftopPz))return a;let o=new f.Vector3(e.start.x,e.start.y,e.start.z),s=new f.Vector3(e.end.x,e.end.y,e.end.z),c=[o,s,new f.Vector3(e.end.x,e.end.y,e.rooftopPz),new f.Vector3(e.start.x,e.start.y,e.rooftopPz)];for(let e=0;e<c.length;e++)if(!this.isValidVector3(c[e]))return console.error(`墙体基础点${e}无效:`,c[e]),a;let l=o.distanceTo(s),u=Math.abs(e.rooftopPz-e.start.z);if(l===0||u===0)return console.error(`墙体宽度或高度为0`),console.log(`line.rooftopPz`,e.rooftopPz),console.log(`bottomLeft`,o),console.log(`bottomRight`,s),console.log(e.length),a;let d=l/n,p=u/t,m=new f.Vector3().subVectors(s,o).normalize(),h=new f.Vector3(0,0,1);for(let e=0;e<t;e++)for(let t=0;t<n;t++)try{let n={points:[new f.Vector3().copy(o).add(m.clone().multiplyScalar(t*d)).add(h.clone().multiplyScalar(e*p)),new f.Vector3().copy(o).add(m.clone().multiplyScalar((t+1)*d)).add(h.clone().multiplyScalar(e*p)),new f.Vector3().copy(o).add(m.clone().multiplyScalar((t+1)*d)).add(h.clone().multiplyScalar((e+1)*p)),new f.Vector3().copy(o).add(m.clone().multiplyScalar(t*d)).add(h.clone().multiplyScalar((e+1)*p))],userData:{}};n.userData={type:`wallSegment`,row:e,col:t,originalMaterial:r,width:d,height:p},a.push(n)}catch(n){console.error(`创建墙体小平面(${e}, ${t})时出错:`,n)}return a}calculateMinRequiredPoints(e){let t=Math.floor(Math.log1p(e)*.5);return Math.max(1,t)}calculateExpectedDensity(e){return e<1?10:e<4?5:2}evaluateSegmentByArea(e,t,n,r){if(t===0)return!1;let i=e.area,a=e.minRequiredPoints,o=e.expectedDensity,s=t/Math.max(i,.001),c=t>=a,l=s>=o*.3,u=!0;return i<.5&&t>0&&(u=this.checkSmallAreaDistribution(e,n,r)),c&&l&&u}checkSmallAreaDistribution(e,t,n){if(t.length<2)return!0;let r=t.map(e=>n[e]);e.bounds;let i=e.center,a=0,o=Math.sqrt(e.area)*.3;return r.forEach(e=>{e.distanceTo(i)<=o&&a++}),a/r.length>=.3}getFailureReason(e,t){let n=e.area,r=e.minRequiredPoints,i=e.expectedDensity,a=t/Math.max(n,.001),o=[];return t===0?o.push(`无点`):(t<r&&o.push(`点数不足: ${t}/${r}`),a<i*.3&&o.push(`密度不足: ${a.toFixed(2)}/${i.toFixed(2)}`),n<.5&&t>0&&(this.checkSmallAreaDistribution(e,[],[])||o.push(`小平面分布不均`))),o.length>0?o.join(`, `):`未知原因`}calculateMedian(e){let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2==0?(t[n-1]+t[n])/2:t[n]}isPointInBoundingBox(e,t,n=.1){return e.x>=t.min[0]-n&&e.x<=t.max[0]+n&&e.y>=t.min[1]-n&&e.y<=t.max[1]+n&&e.z>=t.min[2]-n&&e.z<=t.max[2]+n}getSegmentPlane(e){let t=e.geometry;if(!t||!t.attributes.position)return null;let n=t.attributes.position;if(n.count<3)return null;let r=new f.Vector3().fromBufferAttribute(n,0),i=new f.Vector3().fromBufferAttribute(n,1),a=new f.Vector3().fromBufferAttribute(n,2);r.applyMatrix4(e.matrixWorld),i.applyMatrix4(e.matrixWorld),a.applyMatrix4(e.matrixWorld);let o=new f.Plane;return o.setFromCoplanarPoints(r,i,a),o}analyzePointDistribution(e,t,n=.01){this.results={totalSegments:0,segmentsWithPoints:0,segmentsWithoutPoints:0,missingSegments:[],pointsInSegments:new Map,segmentsByPoint:new Map,segmentDetails:new Map,tolerance:n,analysisTime:null};let r=performance.now(),i=[];e.forEach(e=>{if(e.userData&&e.userData.type===`wallSegment`){let t=this.getWorldVerticesNew(e.points);if(t.length<4)return;let n=new f.Vector3().add(t[0]).add(t[1]).add(t[2]).add(t[3]).multiplyScalar(.25);e.userData.center=n,e.vertices=t,i.push(e)}}),this.results.totalSegments=i.length;for(let e of i){if(e.vertices.length<4)continue;let r=e.userData.center,i=`row${e.userData.row}_col${e.userData.col}`,[a,o,s,c]=e.vertices,l=new f.Vector3().subVectors(o,a).normalize(),u=new f.Vector3().subVectors(c,a).normalize(),d=a.distanceTo(o),p=a.distanceTo(c),m=new f.Plane;m.setFromCoplanarPoints(a,o,c);let h=d/2,g=p/2;for(let e=0;e<t.length;e++)this.isPointInWallSegmentOptimized(t[e],r,m,a,l,u,d,p,h,g,n)&&(this.results.pointsInSegments.has(i)||this.results.pointsInSegments.set(i,[]),this.results.pointsInSegments.get(i).push(e))}return i.forEach(e=>{let t=`row${e.userData.row}_col${e.userData.col}`,n=this.results.pointsInSegments.has(t)?this.results.pointsInSegments.get(t).length:0;n>=1?this.results.segmentsWithPoints++:(this.results.segmentsWithoutPoints++,this.results.missingSegments.push({row:e.userData.row,col:e.userData.col,width:e.userData.width,height:e.userData.height,segmentKey:t,vertices:e.vertices,center:e.userData.center,mesh:e,pointCount:n,hasPointsButNotEnough:n>0&&n<1}))}),this.results.analysisTime=performance.now()-r,this.printAnalysisResults(),this.results}isPointInWallSegmentOptimized(e,t,n,r,i,a,o,s,c,l,u){if(Math.abs(n.distanceToPoint(e))>u)return!1;let d=new f.Vector3().subVectors(e,t),p=Math.abs(d.dot(i)),m=Math.abs(d.dot(a));if(p>c&&m>l)return!1;let h=new f.Vector3().subVectors(e,r),g=h.dot(i),_=h.dot(a),v=g>=-u&&g<=o+u,y=_>=-u&&_<=s+u;return v&&y}isPointInWallSegment(e,t,n,r=.1){if(!e.geometry)return!1;try{let i=this.getWorldVertices(e);return i.length<4?!1:this.isPointInRotatedWall(i,t,n,r)}catch(e){return console.error(`判断点是否在墙体平面内时出错:`,e),!1}}isPointInRotatedWall(e,t,n,r=.1){let[i,a,o,s]=e,c=new f.Plane;if(c.setFromCoplanarPoints(i,a,s),Math.abs(c.distanceToPoint(t))>r)return!1;let l=new f.Vector3().subVectors(a,i).normalize(),u=new f.Vector3().subVectors(s,i).normalize();new f.Vector3().crossVectors(l,u).normalize();let d=new f.Vector3().subVectors(t,i),p=d.dot(l),m=d.dot(u),h=i.distanceTo(a),g=i.distanceTo(s),_=p>=-r&&p<=h+r,v=m>=-r&&m<=g+r;return _&&v&&n.distanceTo(t)<h/2&&n.distanceTo(t)<g/2}getWorldVertices(e){if(e._cachedWorldVertices&&e.matrixWorld.equals(e._cachedMatrixWorld))return e._cachedWorldVertices;let t=e.geometry.getAttribute(`position`),n=[];for(let r=0;r<Math.min(4,t.count);r++){let i=new f.Vector3;i.fromBufferAttribute(t,r),i.applyMatrix4(e.matrixWorld),n.push(i)}return e._cachedWorldVertices=n,e._cachedMatrixWorld=e.matrixWorld.clone(),n}getWorldVerticesNew(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n].clone();t.push(r)}return t}getWallSegmentBounds(e){if(!e.geometry)return null;let t=e.geometry.getAttribute(`position`),n=new f.Box3;for(let r=0;r<t.count;r++){let i=new f.Vector3;i.fromBufferAttribute(t,r),i.applyMatrix4(e.matrixWorld),n.expandByPoint(i)}return{min:n.min.toArray(),max:n.max.toArray(),center:n.getCenter(new f.Vector3).toArray(),size:n.getSize(new f.Vector3).toArray()}}highlightEmptySegments(e,t,n,r=1){if(!this.results){console.warn(`请先运行分析函数`);return}let i=new Map,a=new Map;this.results.missingSegments.forEach(e=>{i.set(e.segmentKey,e),a.has(e.row)||a.set(e.row,new Map),a.get(e.row).set(e.col,{segmentKey:e.segmentKey,isEmpty:!0,visited:!1})}),e.forEach(e=>{if(e.userData&&e.userData.type===`wallSegment`){let t=`row${e.userData.row}_col${e.userData.col}`,n=i.has(t);a.has(e.userData.row)||a.set(e.userData.row,new Map),a.get(e.userData.row).has(e.userData.col)||a.get(e.userData.row).set(e.userData.col,{segmentKey:t,isEmpty:n,visited:!1})}});let o=[],s=[[0,1],[1,0],[0,-1],[-1,0]];for(let[e,t]of i){let e=a.get(t.row)?.get(t.col);if(e&&!e.visited){let n=[],c=[[t.row,t.col]];for(e.visited=!0;c.length>0;){let[e,t]=c.shift(),r=`row${e}_col${t}`;i.has(r)&&n.push(i.get(r));for(let[n,r]of s){let i=e+n,o=t+r;if(a.has(i)&&a.get(i).has(o)){let e=a.get(i).get(o);!e.visited&&e.isEmpty&&(e.visited=!0,c.push([i,o]))}}}n.length>=r&&o.push(n)}}let c=this.createClusterMaterials(o.length),l=[];return this.clusterResults={clusters:o.sort((e,t)=>t.length-e.length),highlightedMeshes:l,clusterMaterials:c,totalClusters:o.length,totalHighlighted:l.length},this.clusterResults}calculateBoundaryRegularity(e,t,n,r,i){let a=0,o=0,s=t,c=!0;for(let t=r;t<=i;t++)e.has(s)&&e.get(s).has(t)?o++:c=!1;c&&a++;let l=n,u=!0;for(let t=r;t<=i;t++)e.has(l)&&e.get(l).has(t)?o++:u=!1;u&&a++;let d=r,f=!0;for(let r=t;r<=n;r++)e.has(r)&&e.get(r).has(d)?o++:f=!1;f&&a++;let p=i,m=!0;for(let r=t;r<=n;r++)e.has(r)&&e.get(r).has(p)?o++:m=!1;return m&&a++,a/4}calculateClusterQualityScore(e){let t=1/Math.max(1,e.aspectRatio);return e.compactness*.4+e.boundaryRegularity*.4+t*.2}calculateStrictClusterBounds(e){if(e.length===0)return{width:0,height:0};let t=[];if(e.forEach(e=>{e.vertices&&e.vertices.length>0&&t.push(...e.vertices)}),t.length===0){let t=[...new Set(e.map(e=>e.row))];return{width:[...new Set(e.map(e=>e.col))].length*(e[0].bounds?.width||1),height:t.length*(e[0].bounds?.height||1)}}let n=Math.min(...t.map(e=>e.x)),r=Math.max(...t.map(e=>e.x)),i=Math.min(...t.map(e=>e.y)),a=Math.max(...t.map(e=>e.y)),o=Math.min(...t.map(e=>e.z)),s=Math.max(...t.map(e=>e.z));return{width:Math.abs(r-n),height:Math.max(Math.abs(a-i),Math.abs(s-o))}}createClusterMaterials(e){let t=[],n=[16711935,65535,16753920,16738740,9055202,3329330,`lavenderblush`,`lawngreen`,`lemonchiffon`,`lightblue`,`lightcoral`];for(let r=0;r<e;r++){let e=n[r%n.length],i=new f.MeshBasicMaterial({color:e,transparent:!0,opacity:.6,side:f.DoubleSide});t.push(i)}return t}clearHighlights(e){this.clusterResults&&this.clusterResults.highlightedMeshes&&(this.clusterResults.highlightedMeshes.forEach(t=>{e.remove(t),t.material&&t.material.dispose()}),this.results&&this.results.segmentDetails&&this.results.segmentDetails.forEach((e,t)=>{e.mesh&&e.mesh.userData.originalMaterial&&(e.mesh.material=e.mesh.userData.originalMaterial)}),this.clusterResults.highlightedMeshes=[])}getClusterInfo(){return this.clusterResults?{totalClusters:this.clusterResults.totalClusters,clusterSizes:this.clusterResults.clusters.map((e,t)=>({clusterIndex:t,size:e.length,segments:e.map(e=>e.segmentKey)})),largestCluster:Math.max(...this.clusterResults.clusters.map(e=>e.length)),smallestCluster:Math.min(...this.clusterResults.clusters.map(e=>e.length))}:null}restoreOriginalMaterials(e){let t=0;e.traverse(e=>{e.userData&&e.userData.originalMaterial&&(e.material=e.userData.originalMaterial,delete e.userData.originalMaterial,t++)}),console.log(`恢复了 ${t} 个平面的原始材质`)}createDebugHelpers(e){let t=new f.Group;return e.traverse(e=>{if(e.userData&&e.userData.type===`wallSegment`){let n=this.getWorldVertices(e);if(n.length<4)return;let r=new f.Vector3().add(n[0]).add(n[1]).add(n[2]).add(n[3]).multiplyScalar(.25),i=new f.Vector3().subVectors(n[1],n[0]).normalize(),a=new f.Vector3().subVectors(n[3],n[0]).normalize(),o=new f.Vector3().crossVectors(i,a).normalize(),s=new f.ArrowHelper(o,r,.3,16711680),c=new f.ArrowHelper(i,r,.2,65280),l=new f.ArrowHelper(a,r,.2,255);t.add(s),t.add(c),t.add(l)}}),t}printAnalysisResults(){if(!this.results){console.warn(`没有可用的分析结果`);return}this.results.missingSegments.length>0&&this.results.missingSegments.forEach(e=>{}),this.results.pointsInSegments.forEach((e,t)=>{})}isValidVector3(e){return e&&!isNaN(e.x)&&!isNaN(e.y)&&!isNaN(e.z)&&isFinite(e.x)&&isFinite(e.y)&&isFinite(e.z)}mergeWallGroupMeshes(e){let t=[];if(e.traverse(e=>{e.isMesh&&e.geometry&&t.push(e)}),t.length===0)return null;try{let e=t.map(e=>e.geometry);e.forEach((e,n)=>{e.applyMatrix4(t[n].matrixWorld)});let n=p(e),r=t[0].material.clone(),i=new f.Mesh(n,r);return i.name=`mergedWalls`,i}catch(e){return console.error(`合并网格时出错:`,e),null}}},ne=e=>{let t={},n=[],r=[],i=[];return e[0].width,e[0].height,e.forEach(e=>{r.push(...e.vertices),i.push(e.center),n.push(e.vertices)}),t.originalVertices=n,t.allCenterPoints=i,t},re=e=>{let t=new f.Vector3().copy(e.start).add(e.end).multiplyScalar(.5),n=new f.Vector3().subVectors(new f.Vector3(t.x,t.y,t.z+1),t).normalize(),r=new f.Vector3(e.direction.x,e.direction.y,0);r.applyAxisAngle(n,Math.PI/2);let i=new f.Vector3().copy(t).add(r.clone().multiplyScalar(e.length)),a=new f.Vector3().copy(t).sub(r.clone().multiplyScalar(e.length));return t.z=e.start.z,i.z=e.start.z,a.z=e.start.z,{start:i,end:a,center:t,direction:r}},ie=(e,t,n=!0)=>{let r=[];if(!e)return[];for(let i=0;i<e.length;i++){let a=e[i];if(!a)continue;let o=new f.Vector3(a.start.x,a.start.y,a.start.z);o.applyEuler(new f.Euler(-Math.PI/2,0,0));let s=new f.Vector3(a.end.x,a.end.y,a.end.z);if(s.applyEuler(new f.Euler(-Math.PI/2,0,0)),t.add(_(String(i),new f.Vector3((o.x+s.x)/2,(o.y+s.y)/2,(o.z+s.z)/2))),(a.isBayWindow||a.isWindow)&&n)continue;let c=new f.Plane().setFromCoplanarPoints(new f.Vector3(a.start.x,a.start.y,a.start.z),new f.Vector3(a.end.x,a.end.y,a.end.z),new f.Vector3(a.start.x,a.start.y,a.rooftopPz)),l=[];a.originalPoints.forEach((e,t)=>{let n=new f.Vector3;c.projectPoint(e,n),l.push(n)});let u=new f.Vector3(a.start.x,a.start.y,a.start.z).distanceTo(new f.Vector3(a.end.x,a.end.y,a.end.z)),d=Math.abs(a.rooftopPz-a.start.z),p=new f.MeshBasicMaterial({color:`red`,side:f.DoubleSide,wireframe:!1,transparent:!0,opacity:.5}),m=new f.Group,h=new te,{horizontalSubdivisions:g,verticalSubdivisions:v}=h.initLimits4(u,d),y=h.createSubdividedWallPlane(a,v,g,p,m);h.analyzePointDistribution(y,l,.01);let b=new f.MeshBasicMaterial({color:`black`,transparent:!0,opacity:.8,side:f.DoubleSide}),x=h.highlightEmptySegments(y,b,m),S=[];for(let e of x.clusters){let t=ne(e);t&&S.push(t)}let C=re(a).direction;a.checkResults=S,a.verticalDirection=C,a.originaIndex=i,r.push(a)}return r},ae=async(e,t,n,r)=>{R(r);let i=await fetch(e);if(!i)return;let a=await i.json(),o=new f.Group,s=new f.Group,c=new f.Group,l=new f.Group,u=new f.Group,d=new f.Group,m=new f.Group,h=new f.Group;for(let e=0;e<a.length;e++){let t=a[e];if(!t)continue;let n=new f.Vector3(t.start.x,t.start.y,t.start.z);n.applyEuler(new f.Euler(-Math.PI/2,0,0));let r=new f.Vector3(t.end.x,t.end.y,t.end.z);r.applyEuler(new f.Euler(-Math.PI/2,0,0)),h.add(_(String(e),new f.Vector3((n.x+r.x)/2,(n.y+r.y)/2,(n.z+r.z)/2)))}a.sort((e,t)=>e.originalIndex-t.originalIndex),console.log(`lins`,a);let g=await fetch(t);if(!g)return;let v=await g.json(),y=Array.isArray(v)?v:Object.values(v),b=await fetch(n);if(console.log(`respcd`,b),!b)return;let x=await b.json(),C=0;for(let e=0;e<x.length;e++){let t=x[e];if(t.isFindBeam=!1,t.category==`door`){let e=new f.Vector3(t.center.x,t.center.y,t.center.z);e.applyEuler(new f.Euler(-Math.PI/2,0,0)),h.add(_(`door:${C}`,e)),C++}}r.add(h),console.time();let{beamGroup:w}=await oe(a,y,x,r);console.timeEnd(),console.log(`beamGroup`,w),new f.MeshBasicMaterial({color:`#cffd00`,transparent:!0,opacity:.4,side:f.DoubleSide});let T=new f.MeshBasicMaterial({color:`#ff0000`,transparent:!0,opacity:.4,side:f.DoubleSide}),E=new f.MeshBasicMaterial({color:`#e100ff`,transparent:!0,opacity:.4,side:f.DoubleSide}),D=new f.MeshBasicMaterial({color:`#0400ff`,transparent:!0,opacity:.4,side:f.DoubleSide}),O=new f.LineBasicMaterial({color:`#cffd00`}),k=[];for(let e=0;e<a.length;e++){let t=a[e];if(t.checkResults)for(let e of t.checkResults)for(let t of e.originalVertices){let[e,n,r,i]=t,a=new f.BufferGeometry,o=new Float32Array([e.x,e.y,e.z,n.x,n.y,n.z,r.x,r.y,r.z,i.x,i.y,i.z]);a.setAttribute(`position`,new f.BufferAttribute(o,3)),a.setIndex([0,1,2,0,2,3]),a.computeVertexNormals();let s=new f.EdgesGeometry(a,1);k.push(s)}}if(k.length>0){let e=p(k,!1);e.rotateX(-Math.PI/2),o.add(new f.LineSegments(e,O)),o.visible=!1,r.add(o),k.forEach(e=>e.dispose())}new f.PointsMaterial({color:65535,size:.01});for(let e of a){if(!e.originalPoints||e.originalPoints.length===0)continue;let t=new Float32Array(e.originalPoints.length*3);e.originalPoints.forEach((e,n)=>{t[n*3]=e.x,t[n*3+1]=e.y,t[n*3+2]=e.z});let n=new f.BufferGeometry;n.setAttribute(`position`,new f.BufferAttribute(t,3)),n.rotateX(-Math.PI/2),s.add(new f.Points(n,new f.PointsMaterial({color:z(),size:.02})));let r=[];r.push(new f.Vector3(e.start.x,e.start.y,e.start.z)),r.push(new f.Vector3(e.end.x,e.end.y,e.end.z));let i=new f.BufferGeometry;i.setFromPoints(r),i.rotateX(-Math.PI/2),d.add(new f.Line(i,O))}d.visible=!1,r.add(s),r.add(d);let A=[],j=[],M=new f.LineBasicMaterial({color:`#f30606`}),N=new f.MeshBasicMaterial({color:`#071ac4`});for(let e=0;e<y.length;e++){let t=new f.SphereGeometry(.05);t.translate(y[e].x,y[e].y,y[e].z);let n=[],r=new f.Vector3(y[e].x,y[e].y,y[e].z),i=new f.Quaternion(y[e].qx,y[e].qy,y[e].qz,y[e].qw),a=new f.Vector3(0,0,-1).applyQuaternion(i),o=r.clone().addScaledVector(a,.001);n.push(r),n.push(o);let s=new f.BufferGeometry;s.setFromPoints(n),j.push(s),A.push(t)}if(A.length>0){let e=p(A,!1);e.rotateX(-Math.PI/2),c.add(new f.Mesh(e,N)),A.forEach(e=>e.dispose())}if(j.length>0){let e=p(j,!1);e.rotateX(-Math.PI/2),c.add(new f.Line(e,M)),j.forEach(e=>e.dispose())}r.add(c);let{AiProjectionGroup:P,AiProjectionGroup2:F}=S(x);return l.add(P),l.rotateX(-Math.PI/2),r.add(l),u.add(F),u.visible=!1,u.rotateX(-Math.PI/2),r.add(u),console.log(`jsonpcdData`,x),a.forEach(e=>{e.doorAndBeamData&&e.doorAndBeamData.length>0&&(e.doorAndBeamData.forEach(e=>{if(e.beamStart){let t=new f.BufferGeometry,n=new Float32Array([e.beamStart.x,e.beamStart.y,e.beamStart.z,e.beamEnd.x,e.beamEnd.y,e.beamEnd.z,e.beamEnd.x,e.beamEnd.y,e.beamEnd.z+e.beamHeight,e.beamStart.x,e.beamStart.y,e.beamStart.z+e.beamHeight]);t.setAttribute(`position`,new f.BufferAttribute(n,3)),t.setIndex([0,1,2,0,2,3]),t.computeVertexNormals(),t.rotateX(-Math.PI/2)}let t=new f.BufferGeometry,n=new Float32Array([e.doorStart.x,e.doorStart.y,e.doorStart.z,e.doorEnd.x,e.doorEnd.y,e.doorEnd.z,e.doorEnd.x,e.doorEnd.y,e.doorEnd.z+e.doorHeight,e.doorStart.x,e.doorStart.y,e.doorStart.z+e.doorHeight]);t.setAttribute(`position`,new f.BufferAttribute(n,3)),t.setIndex([0,1,2,0,2,3]),t.computeVertexNormals(),t.rotateX(-Math.PI/2),e.isDoor?m.add(new f.Mesh(t,D)):e.type==`beam`?m.add(new f.Mesh(t,E)):m.add(new f.Mesh(t,T)),`${e.id}${e.nearId}`,new f.Vector3((e.doorStart.x+e.doorEnd.x)/2,(e.doorStart.y+e.doorEnd.y)/2,e.doorStart.z+e.doorHeight).applyEuler(new f.Euler(-Math.PI/2,0,0))}),r.add(m))}),{checkResultGroup:o,pointCloudGroup:s,runData:c,pcdGroup:l,pcdGroup2:u,pointLineGroup:d,beamDoorGroup:m,lineIndexGroup:h}},oe=async(e,t,n,r)=>{if(P(e,r),e.length<=0||t.length<=0)return e;n||=[];for(let t of e){let e=[];if(!(!t.checkResults||t.checkResults.length<=0)){for(let n=0;n<t.checkResults.length;n++){let r=t.checkResults[n];if(r.isDoor=!1,!r.originalVertices||r.originalVertices.length==0)continue;let i=[];r.originalVertices.forEach(e=>{let t=[];e.forEach(e=>{t.push(new f.Vector3(e.x,e.y,e.z))}),i.push(t)});let a=i.length,o=Array.from({length:a},(e,t)=>t);function s(e){for(;o[e]!==e;)o[e]=o[o[e]],e=o[e];return e}for(let e=0;e<a;e++)for(let t=e+1;t<a;t++){let n=i[e],r=i[t];if(n.some(e=>r.some(t=>e.equals(t)))){let n=s(e),r=s(t);n!==r&&(o[n]=r)}}let c=new Map,l=-1,u=-1;for(let e=0;e<a;e++){let t=s(e);c.has(t)||c.set(t,{points:[],area:0,originalVertices:[],index:-1,gridWidth:-1,gridHeight:-1,centerPts:[]});let r=c.get(t),[a,o,d,p]=i[e],m=new f.Vector3().add(a).add(o).add(d).add(p).multiplyScalar(.25);if(r.points.push(...i[e]),r.area+=a.distanceTo(o)*a.distanceTo(p),r.originalVertices.push(i[e]),r.index=n,r.centerPts.push(m),l==-1||u==-1){let e=new f.Vector3().subVectors(a,o).normalize();u=a.distanceTo(p),l=a.distanceTo(o);let t=y(e,new f.Vector3(0,0,1));t&&t.parallel&&([u,l]=[l,u])}r.gridWidth=l,r.gridHeight=u}e.push(...c.values())}t.mergeCheckRegion=e}}let i=new Map;for(let t of e){if(t.length<.3)continue;let e=t.rooftopPz-t.start.z,n=Math.floor(t.rooftopPz-t.start.z);i.has(n)?i.set(n,{num:i.get(n).num+1,totalHeight:i.get(n).totalHeight+e}):i.set(n,{num:1,totalHeight:e})}let a=[...i.entries()].reduce((e,t)=>t[1].num>e[1].num?t:e),o=a[0];a[1].totalHeight/a[1].num;let s=[];for(let e=0;e<n.length;e++){let t=n[e];if(t.isFindBeam=!1,t.category==`door`){let n=[];t.coordinatesByArea.coordinates.forEach(e=>{n.push(new f.Vector3(e.x,e.y,e.z))}),n[0].equals(n[n.length-1])&&n.pop();let r=n[0].distanceTo(n[1]),i=n[0].distanceTo(n[3]);i>r&&([r,i]=[i,r],n=[n[0],n[3],n[2],n[1]]);let a=E(n[0],n[3],!0),o=E(n[1],n[2],!0);s.push({doorStartPt:a,doorEndPt:o,boxPoints:n,minZ:t.coordinatesByArea.heightData.minZ,maxZ:t.coordinatesByArea.heightData.maxZ,index:e,isFind:!1,inWall:!1})}}for(let t=0;t<s.length;t++){let n=s[t];for(let t=0;t<e.length;t++){if(e[t].length<.5)continue;let r=[],i=E(e[t].start,e[t].end,!0);r.push(i),r.push(E(i,e[t].start,!0)),r.push(E(i,e[t].end,!0));let a=!1,o=n.boxPoints.length;for(let e=0;e<r.length;e++){let t=r[e].x,i=r[e].y;for(let e=0,r=o-1;e<o;r=e++){let o=n.boxPoints[e].x,s=n.boxPoints[e].y,c=n.boxPoints[r].x,l=n.boxPoints[r].y;s>i!=l>i&&t<(c-o)*(i-s)/(l-s)+o&&(a=!a)}if(a)break}if(a){let r=new f.Vector3(e[t].start.x,e[t].start.y,0),i=new f.Vector3(e[t].end.x,e[t].end.y,0),a=n.doorStartPt.distanceTo(n.doorEndPt),o=r.distanceTo(i),s=w(n.doorStartPt,n.doorEndPt,r,i);if(Math.abs(o-a)<.5&&s&&s.isParallel){n.doorStartPt=new f.Vector3(e[t].start.x,e[t].start.y,0),n.doorEndPt=new f.Vector3(e[t].end.x,e[t].end.y,0);break}else if(Math.abs(o-a)>1.3&&s&&s.isParallel){let e=D(n.doorStartPt,n.doorEndPt,r,i),t=n.doorStartPt.distanceTo(r),a=n.doorStartPt.distanceTo(i),o=n.doorEndPt.distanceTo(r),s=n.doorEndPt.distanceTo(i),c=t<.2||a<.2||o<.2||s<.2;if(e&&e.type==`collinear_overlap`&&e.maxPerpendicularDistance<.1&&!c){n.inWall=!0;break}}}else continue}}let c=0,l=[],u=[],d=[],p=[],m=.2;for(let r=0;r<e.length;r++){let i=e[r];if(!i.mergeCheckRegion||i.mergeCheckRegion.length==0)continue;i.doorAndBeamData=[],i.completePointAreaPercentage=-1;let a=new f.Box3;a.setFromPoints(i.originalPoints);let h=a.max.z,_=a.min.z,v=new f.Vector3(i.start.x,i.start.y,i.start.z),b=new f.Vector3(i.end.x,i.end.y,i.end.z),x=i.rooftopPz-i.start.z;if(x<o-.5||x>o+2)continue;let S=0;for(let a of i.mergeCheckRegion){let{facePoints:o,boxArea:O,totalInPlaneNum:k}=C(a.points,a.gridWidth,a.gridHeight,a.centerPts);if(!o||o.length<=0)continue;o[0].distanceTo(o[1]);let A=o[0].distanceTo(o[3]),j=a.gridHeight*(A/a.gridHeight/3*2)+a.gridHeight/2,M=new f.Vector3(o[0].x,o[0].y,o[0].z+j),P=new f.Vector3(o[1].x,o[1].y,o[1].z+j),L=new f.Line3(M,P),R=[],z=new f.Vector3;a.points.forEach(e=>{L.closestPointToPoint(e,!0,z).distanceTo(e)<a.gridHeight+.01&&R.push(e)});let B=[],V=[];for(;;){let e=[];for(let t=0;t<R.length;t++)V.includes(t)||e.length==0&&(e.push(R[t]),V.push(t));for(let t=0;t<R.length;t++)if(!V.includes(t)){for(let n=0;n<e.length;n++)if(R[t].distanceTo(e[n])<a.gridWidth+.01){e.push(R[t]),V.push(t),t=-1;break}}if(e.length==0)break;B.push(e)}let te=[];for(let e=0;e<B.length;e++){let t={lineSt:new f.Vector3,lineEd:new f.Vector3,facePoints:[]},n=ee(B[e]);Array.isArray(n)&&n.length==2&&(t.lineSt=n[0],t.lineEd=n[1],t.facePoints.push(new f.Vector3(n[0].x,n[0].y,o[0].z)),t.facePoints.push(new f.Vector3(n[1].x,n[1].y,o[0].z)),t.facePoints.push(new f.Vector3(n[1].x,n[1].y,o[2].z)),t.facePoints.push(new f.Vector3(n[0].x,n[0].y,o[2].z)),te.push(t))}S+=a.area;let ne=0;if(k!=0&&(ne=a.gridHeight*a.gridWidth*k),(a.area-ne)/O*100>70&&te.length==1||te.length>1)for(let o=0;o<te.length;o++){let S=te[o],C=S.facePoints[0].distanceTo(S.facePoints[1]),O=S.facePoints[0].distanceTo(S.facePoints[3]),k=C/i.length*100,A=i.rooftopPz-S.facePoints[2].z;if(O<1.5||h<S.facePoints[2].z||A>x/3*2)continue;let j=!1,M=!1,P=!1,L=[],R=S.facePoints[2].clone(),z=S.facePoints[3].clone(),B=S.facePoints[0].clone(),V=S.facePoints[1].clone(),ne=!1,re=-1;if(Math.abs(S.facePoints[0].z-i.start.z)<.25){if(C>.17&&i.length>.5){let t=F(v,B),n=F(v,V),a=F(b,B),o=F(b,V),s=.1;if(t<s||n<s){let{newOriginalPoints:n}=N(B,V,i.originalPoints),a=[],o=[];if(n.forEach(e=>{e.z>=R.z?a.push(e):e.z<=B.z&&o.push(e)}),a.length>10){let n=new f.Vector3(i.start.x,i.start.y,0),a=new f.Vector3(i.end.x,i.end.y,0),o=new f.Vector3().subVectors(n,a).normalize(),c=new f.Vector3,l=1/0,u=-1,d=!1;for(let t=0;t<e.length;t++){if(t==r)continue;let i=new f.Vector3(e[t].start.x,e[t].start.y,0),s=new f.Vector3(e[t].end.x,e[t].end.y,0),p=g(n,a,i,s),m=T(n,a,i,s);if(p!=null){if(m&&m.angle>85){let e=p.point.distanceTo(n);if(p.point.distanceTo(a),e<.3){l=1/0,u=-1;break}}continue}if(m&&m.angle>65){let e=w(n,a,new f.Line3(i,s).closestPointToPoint(n,!0,c),n);if(!e||e.direction!=`same`)continue;let r=n.clone().addScaledVector(o,10),d=a.clone().addScaledVector(o.clone().negate(),10),p=new f.Vector3().subVectors(s,i).normalize(),m=g(r,d,i.clone().addScaledVector(p.clone().negate(),.03),s.clone().addScaledVector(p,.03));if(m==null)continue;let h=n.distanceTo(m.point);h<l&&(l=h,u=t)}else if(m&&m.angle<5){let e=new f.Vector3(B.x,B.y,0),t=new f.Vector3(V.x,V.y,0),n=F(e,i),r=F(e,s),a=F(t,i),o=F(t,s);if(n<.08||r<.08||a<.08||o<.08){d=!0,l=1/0,u=-1;break}}}if(l!=1/0&&l<2)e[u].length>.25&&C+l>.5&&(ne=!0,t<s?(z=z.addScaledVector(o,l),B=B.addScaledVector(o,l)):(R=R.addScaledVector(o,l),V=V.addScaledVector(o,l)));else if(!d){let n=.05,i=v.clone().addScaledVector(o,n),a=v.clone().addScaledVector(o.clone().negate(),n);i.z=a.z=0;let c=!1;for(let u=0;u<e.length;u++){if(u==r)continue;let d=new f.Vector3(e[u].start.x,e[u].start.y,0),p=new f.Vector3(e[u].end.x,e[u].end.y,0),m=new f.Vector3().subVectors(p,d).normalize();d=d.clone().addScaledVector(m.clone().negate(),n),p=p.clone().addScaledVector(m,n);let h=g(i,a,d,p);if(h){h.point.z=v.z;let e=h.point.distanceTo(v);if(h.point.distanceTo(b)<e)continue;l>e&&(l=e),c=!0}if(c)break;l!=1/0&&l<2&&(t<s?(z=z.addScaledVector(o.clone().negate(),l),B=B.addScaledVector(o.clone().negate(),l)):(R=R.addScaledVector(o.clone().negate(),l),V=V.addScaledVector(o.clone().negate(),l)))}if(!c)continue}}else continue}else if(a<s||o<s){let{newOriginalPoints:t}=N(B,V,i.originalPoints),n=[],o=[];if(t.forEach(e=>{e.z>=R.z?n.push(e):e.z<=B.z&&o.push(e)}),n.length>10){let t=new f.Vector3(i.start.x,i.start.y,0),n=new f.Vector3(i.end.x,i.end.y,0),o=new f.Vector3().subVectors(n,t).normalize(),c=new f.Vector3,l=1/0,u=-1,d=!1;for(let i=0;i<e.length;i++){if(i==r)continue;let a=new f.Vector3(e[i].start.x,e[i].start.y,0),s=new f.Vector3(e[i].end.x,e[i].end.y,0),p=g(t,n,a,s),m=T(t,n,a,s);if(p!=null){if(m&&m.angle>85&&(p.point.distanceTo(t),p.point.distanceTo(n)<.3)){l=1/0,u=-1;break}continue}if(m&&m.angle>65){let e=w(n,t,new f.Line3(a,s).closestPointToPoint(n,!0,c),n);if(!e||e.direction!=`same`)continue;let r=t.clone().addScaledVector(o.clone().negate(),10),d=n.clone().addScaledVector(o,10),p=new f.Vector3().subVectors(s,a).normalize(),m=g(r,d,a.clone().addScaledVector(p.clone().negate(),.03),s.clone().addScaledVector(p,.03));if(m==null)continue;let h=n.distanceTo(m.point);h<l&&(l=h,u=i)}else if(m&&m.angle<5){let e=new f.Vector3(B.x,B.y,0),t=new f.Vector3(V.x,V.y,0),n=F(e,a),r=F(e,s),i=F(t,a),o=F(t,s);if(n<.08||r<.08||i<.08||o<.08){d=!0,l=1/0,u=-1;break}}}if(l!=1/0&&l<2)e[u].length>.25&&C+l>.5&&(ne=!0,a<s?(z=z.addScaledVector(o,l),B=B.addScaledVector(o,l)):(R=R.addScaledVector(o,l),V=V.addScaledVector(o,l)));else if(!d){let t=.05,n=b.clone().addScaledVector(o,t),i=v.clone();n.z=i.z=0;let c=!1;for(let a=0;a<e.length;a++){if(a==r)continue;let o=new f.Vector3(e[a].start.x,e[a].start.y,0),s=new f.Vector3(e[a].end.x,e[a].end.y,0),u=new f.Vector3().subVectors(s,o).normalize();o=o.clone().addScaledVector(u.clone().negate(),t),s=s.clone().addScaledVector(u,t);let d=g(n,i,o,s);if(d){d.point.z=b.z;let e=d.point.distanceTo(b);if(d.point.distanceTo(v)<e)continue;l>e&&(l=e),c=!0}}if(!c)continue;l!=1/0&&l<2&&(a<s?(z=z.addScaledVector(o.clone().negate(),l),B=B.addScaledVector(o.clone().negate(),l)):(R=R.addScaledVector(o.clone().negate(),l),V=V.addScaledVector(o.clone().negate(),l)))}}else continue}C=z.distanceTo(R)}if(k<85&&C>.35||C>.7&&O>x-x/3){let e=!1;for(let n=0;n<t.length;n++){let r=n+1;if(r>=t.length)continue;let i=new f.Vector3(t[n].x,t[n].y,t[n].z),a=new f.Vector3(t[r].x,t[r].y,t[r].z);if(g(new f.Vector3(i.x,i.y,0),new f.Vector3(a.x,a.y,0),new f.Vector3(S.facePoints[0].x,S.facePoints[0].y,0),new f.Vector3(S.facePoints[1].x,S.facePoints[1].y,0),.1)!=null){e=!0;break}}for(let e=0;e<s.length;e++){let t=new f.Vector3(s[e].doorStartPt.x,s[e].doorStartPt.y,0),r=new f.Vector3(s[e].doorEndPt.x,s[e].doorEndPt.y,0),a=new f.Vector3(S.facePoints[0].x,S.facePoints[0].y,0),o=new f.Vector3(S.facePoints[1].x,S.facePoints[1].y,0),c=S.facePoints[2].z<s[e].maxZ||Math.abs(S.facePoints[2].z-s[e].maxZ)<.3;if(Math.abs(S.facePoints[2].z-s[e].maxZ),c){let c=D(t.clone(),r.clone(),a.clone(),o.clone(),{distanceThreshold:2});if(c&&c.type==`collinear_gap`){let l=E(t,r),u=new f.Line3(new f.Vector3(i.start.x,i.start.y,0),new f.Vector3(i.end.x,i.end.y,0)),d=new f.Vector3,p=u.closestPointToPoint(l,!0,d);if(l.distanceTo(p)<.15){let i=a.distanceTo(t),l=o.distanceTo(t);if(i>.25&&l>.25){let e=a.distanceTo(r),t=o.distanceTo(r);if(e>.2&&t>.2)continue}M=!0,P=!0,L.push(s[e].index),s[e].isFind=!0,re=e,n[s[e].index].isFindBeam=!0;let u=new f.Vector3().subVectors(a,o).normalize(),d=t.distanceTo(r)-c.overlap;l<i&&u.negate(),i>l?(R=S.facePoints[2].clone().addScaledVector(u,d),z=S.facePoints[3].clone(),B=z.clone(),V=R.clone(),B.z=V.z=S.facePoints[0].z):(R=S.facePoints[2].clone(),z=S.facePoints[3].clone().addScaledVector(u,d),B=z.clone(),V=R.clone(),B.z=V.z=S.facePoints[0].z)}}else if(c&&c.type==`collinear_overlap`&&c.maxPerpendicularDistance<.35){let i=a.distanceTo(o),l=r.distanceTo(t);if(Math.abs(i-c.overlap)<.25||Math.abs(l-c.overlap)<.25){if(l>i&&Math.abs(l-c.overlap)>1){let e=a.distanceTo(t),n=a.distanceTo(r),i=o.distanceTo(t),s=o.distanceTo(r),u=e<n?e:n,d=i<s?i:s,p=new f.Vector3().subVectors(a,o).normalize(),m=l-c.overlap;u<d?(p.negate(),R=S.facePoints[2].clone().addScaledVector(p,m),z=S.facePoints[3].clone(),B=z.clone(),V=R.clone(),B.z=V.z=S.facePoints[0].z):(R=S.facePoints[2].clone(),z=S.facePoints[3].clone().addScaledVector(p,m),B=z.clone(),V=R.clone(),B.z=V.z=S.facePoints[0].z)}M=!0,P=!0,L.push(s[e].index),s[e].isFind=!0,n[s[e].index].isFindBeam=!0,re=e}}}}if(!P)for(let e=0;e<s.length;e++){if(s[e].inWall)continue;let t=new f.Vector3(s[e].doorStartPt.x,s[e].doorStartPt.y,0),r=new f.Vector3(s[e].doorEndPt.x,s[e].doorEndPt.y,0),i=new f.Vector3(S.facePoints[0].x,S.facePoints[0].y,0),a=new f.Vector3(S.facePoints[1].x,S.facePoints[1].y,0),o=new f.Vector3().subVectors(t,r).normalize(),c=new f.Vector3().subVectors(i,a).normalize(),l=.2,u=g(t.clone().addScaledVector(o,l),r.clone().addScaledVector(o.clone().negate(),l),i.clone().addScaledVector(c,l),a.clone().addScaledVector(c.clone().negate(),l)),d=S.facePoints[2].z<s[e].maxZ||Math.abs(S.facePoints[2].z-s[e].maxZ)<.3,p=t.distanceTo(i),h=t.distanceTo(a),_=r.distanceTo(i),v=r.distanceTo(a);(p<m||h<m||_<m||v<m||u)&&d&&(n[s[e].index].isFindBeam=!0,M=!0,s[e].isFind=!0,re=e)}(M||e||Math.abs(O-x)>.1&&O>x/2&&C>.3&&Math.abs(_-i.start.z)<.4)&&(j=!0)}}if(j){let t=!1;for(let e=0;e<d.length;e++){let n=D(d[e].start,d[e].end,B,V);if(n&&n.type==`collinear_overlap`&&n.maxPerpendicularDistance<.01){t=!0;break}}if(t){re!=-1&&(n[s[re].index].isFindBeam=!1,s[re].isFind=!1);continue}d.push({start:B,end:V});{let e=new f.Vector3().subVectors(B,V),t=new f.Vector3().subVectors(V,B),n=1/0,r=1/0,a=B.clone(),o=V.clone(),s=[],c=[],l=new f.Line3(R,z),u=new f.Vector3,d=999999;if(i.originalPoints.forEach(n=>{if(n.z-B.z<O/2+.1&&n.z-B.z>O/2-.1&&s.push(n),n.z>R.z){let r=l.closestPointToPoint(n,!0,u),i=r.distanceTo(n),a=new f.Vector3().subVectors(r,R),o=y(e,new f.Vector3().subVectors(r,z)),s=y(t,a);o&&o.parallel&&!o.sameDirection&&s&&s.parallel&&!s.sameDirection&&i<.1&&i>.02&&(d>i&&(d=i),c.push(n))}}),s.length>0){let{newProjectPoints:i}=N(B,V,s);for(let e of i)e.z=B.z;i.forEach(i=>{let s=new f.Vector3(i.x,i.y,B.z),c=new f.Vector3().subVectors(s,V),l=y(e,new f.Vector3().subVectors(s,B)),u=y(t,c);if(l&&l.parallel&&l.sameDirection){let e=s.distanceTo(B);e<n&&(n=e,a=s)}else if(u&&u.parallel&&u.sameDirection){let e=s.distanceTo(V);e<r&&(r=e,o=s)}})}a.equals(B)||(B=a,z=new f.Vector3(B.x,B.y,z.z)),o.equals(V)||(V=o,R=new f.Vector3(V.x,V.y,R.z)),c.length>10&&(R.z=z.z+d,O+=d)}let o=V.distanceTo(B);if(o<.4&&!M||o<.3&&M)continue;u.includes(r)||u.push(r),i.checkResults[a.index].isDoor=!0;let m=``,h={id:c,beamStart:R,beamEnd:z,beamHeight:i.rooftopPz-R.z,doorStart:B,doorEnd:V,doorHeight:O,nearId:-1,type:m,isExtend:ne,isDoor:M,isPullOutDoor:P,pcbDoorIndexs:L},_=!1,v=new f.Vector3,b=new f.Vector3,x=-1;for(let t=0;t<l.length;t++){let n=e[l[t].linesIndex].doorAndBeamData[l[t].doorIndex];if(n.nearId!=-1)continue;let r=w(R.clone(),z.clone(),n.beamStart.clone(),n.beamEnd.clone());if(r&&r.isParallel){let e=R.distanceTo(z),t=n.beamStart.distanceTo(n.beamEnd),r=new f.Line3(R.clone(),z.clone());r.start.z=0,r.end.z=0;let i=E(n.beamStart,n.beamEnd,!0);t>e&&(r.start=new f.Vector3(n.beamStart.x,n.beamStart.y,0),r.end=new f.Vector3(n.beamEnd.x,n.beamEnd.y,0),i=E(R,z,!0));let a=new f.Vector3,o=r.closestPointToPoint(i,!0,a),s=o.distanceTo(i),l=new f.Vector3().subVectors(i,o).normalize(),u=l.clone().negate(),d=i.clone().addScaledVector(u,s+.1),p=g(r.start,r.end,i,d),m=!M&&!n.isDoor&&(e>t*2||t>e*2);if(s<.4&&p!=null&&!m){n.nearId=c,h.nearId=n.id;let r=.8;(n.isDoor||h.isDoor)&&(n.isDoor=!0,h.isDoor=!0);let i=L.some(e=>n.pcbDoorIndexs.includes(e));e<t?e>r&&!n.isPullOutDoor?(n.beamStart=R.clone().addScaledVector(u,s),n.beamEnd=z.clone().addScaledVector(u,s),n.doorStart=B.clone().addScaledVector(u,s),n.doorEnd=V.clone().addScaledVector(u,s),n.doorHeight=h.doorHeight,n.beamStart.z=n.beamEnd.z=n.doorStart.z+n.doorHeight):!P||P&&n.isPullOutDoor&&i?(h.beamStart=n.beamStart.clone().addScaledVector(l,s),h.beamEnd=n.beamEnd.clone().addScaledVector(l,s),h.doorStart=n.doorStart.clone().addScaledVector(l,s),h.doorEnd=n.doorEnd.clone().addScaledVector(l,s),h.doorHeight=n.doorHeight,h.beamStart.z=h.beamEnd.z=h.doorStart.z+h.doorHeight):(n.beamStart=R.clone().addScaledVector(u,s),n.beamEnd=z.clone().addScaledVector(u,s),n.doorStart=B.clone().addScaledVector(u,s),n.doorEnd=V.clone().addScaledVector(u,s),n.doorHeight=h.doorHeight,n.beamStart.z=n.beamEnd.z=n.doorStart.z+n.doorHeight):e>t&&(t>r&&!P?(h.beamStart=n.beamStart.clone().addScaledVector(u,s),h.beamEnd=n.beamEnd.clone().addScaledVector(u,s),h.doorStart=n.doorStart.clone().addScaledVector(u,s),h.doorEnd=n.doorEnd.clone().addScaledVector(u,s),h.doorHeight=n.doorHeight,h.beamStart.z=h.beamEnd.z=h.doorStart.z+h.doorHeight):!n.isPullOutDoor||P&&n.isPullOutDoor&&i?(n.beamStart=R.clone().addScaledVector(l,s),n.beamEnd=z.clone().addScaledVector(l,s),n.doorStart=B.clone().addScaledVector(l,s),n.doorEnd=V.clone().addScaledVector(l,s),n.doorHeight=h.doorHeight,n.beamStart.z=n.beamEnd.z=n.doorStart.z+n.doorHeight):(h.beamStart=n.beamStart.clone().addScaledVector(u,s),h.beamEnd=n.beamEnd.clone().addScaledVector(u,s),h.doorStart=n.doorStart.clone().addScaledVector(u,s),h.doorEnd=n.doorEnd.clone().addScaledVector(u,s),h.doorHeight=n.doorHeight,h.beamStart.z=h.beamEnd.z=h.doorStart.z+h.doorHeight)),x=h.nearId,v=n.beamStart.clone(),b=n.beamEnd.clone(),_=!0;break}}}let S=!1;if(!_){let i=new f.Line3(B.clone(),V.clone());for(let a=0;a<e.length;a++){if(e[a].length<.5||a==r||!e[a].checkResults)continue;let o=D(new f.Vector3(e[a].start.x,e[a].start.y,e[a].start.z),new f.Vector3(e[a].end.x,e[a].end.y,e[a].end.z),B,V);if(o&&o.maxPerpendicularDistance<.3){for(let r=0;r<e[a].checkResults.length;r++){let r=[];e[a].originalPoints.forEach(e=>{e.z>B.z&&e.z<B.z+O/2&&r.push(new f.Vector3(e.x,e.y,B.z))});let o=new f.Vector3,c=[],l=[];for(let e=0;e<r.length;e++){let t=i.closestPointToPoint(r[e],!0,o);t.distanceTo(r[e])<.15&&(c.push(r[e]),l.push(t.clone()))}for(let e=0;e<l.length;e++)I(i,l[e])&&c.push(l[e]);if(c=l,c.length<500)continue;let u=ee(c);if(u.length==2){let e=u[0].distanceTo(u[1]);if(Math.abs(e-i.distance())<.3){t=!0,re!=-1&&(n[s[re].index].isFindBeam=!1,s[re].isFind=!1);break}}}if(t)break}else o&&o.type==`collinear_overlap`&&o.maxPerpendicularDistance>.3&&o.maxPerpendicularDistance<.7&&(S=!0)}if(t)continue}let T=!1;if(x!=-1)for(let e=0;e<p.length&&!(p[e].length==1&&(p[e][0].id==c?(p[e].push({id:x,beamStart:v,beamEnd:b}),T=!0):p[e][0].id==x&&(p[e].push({id:c,beamStart:R,beamEnd:z}),T=!0),T));e++);T||p.push([{id:c,beamStart:R,beamEnd:z}]);let k=h.doorStart.distanceTo(h.doorEnd);if(m=M?`door`:k>1.8||S&&k>1?`beam`:`hole`,h.type=m,h.nearId!=-1&&m==`hole`){let t=!1;for(let n=0;n<e.length;n++)if(e[n].doorAndBeamData){for(let r=0;r<e[n].doorAndBeamData.length;r++)if(e[n].doorAndBeamData[r].nearId==c&&e[n].doorAndBeamData[r].type==`beam`){e[n].doorAndBeamData[r].type=m,t=!0;break}if(t)break}}if(i.doorAndBeamData.push(h),l.push({linesIndex:r,doorIndex:i.doorAndBeamData.length-1}),c++,P&&C<2)break}}}let O=i.length*(i.rooftopPz-i.start.z);i.completePointAreaPercentage=S/O*100}if(u.length>1)for(let t=0;t<u.length;t++){let n=[];for(let r=0;r<e[u[t]].doorAndBeamData.length;r++){let i=e[u[t]].doorAndBeamData[r].doorStart.clone(),a=e[u[t]].doorAndBeamData[r].doorEnd.clone();i.z=a.z=0;let o=i.distanceTo(a),s=!1;for(let n=0;n<u.length;n++)if(t!=n)for(let t=0;t<e[u[n]].doorAndBeamData.length;t++){let r=e[u[n]].doorAndBeamData[t].doorStart.clone(),c=e[u[n]].doorAndBeamData[t].doorEnd.clone();r.z=c.z=0,r.distanceTo(c);let l=D(i,a,r,c);if(l.type==`collinear_overlap`&&l.maxPerpendicularDistance<.2){let e=new f.Line3(r,c),t=E(i,a),n=e.closestPointToPoint(t,!0,new f.Vector3),u=t.distanceTo(n);if(Math.abs(o-l.overlap)<.1&&u<.04){s=!0;break}}}s||n.push(e[u[t]].doorAndBeamData[r])}n.length!=e[u[t]].doorAndBeamData.length&&(e[u[t]].doorAndBeamData=n)}let h=.65,_=[],v=[];for(let t=0;t<s.length;t++){if(s[t].isFind)continue;let r=new f.Vector3(s[t].doorStartPt.x,s[t].doorStartPt.y,0),i=new f.Vector3(s[t].doorEndPt.x,s[t].doorEndPt.y,0),a=new f.Vector3().subVectors(r,i).normalize();for(let o=0;o<e.length;o++){if(e[o].length<.7||e[o].completePointAreaPercentage>60)continue;let l=new f.Vector3(e[o].start.x,e[o].start.y,0),u=new f.Vector3(e[o].end.x,e[o].end.y,0),d=new f.Vector3().subVectors(l,u).normalize(),y=.3,b=r.clone().addScaledVector(a,y),x=i.clone().addScaledVector(a.clone().negate(),y),S=l.clone().addScaledVector(d,y),C=u.clone().addScaledVector(d.clone().negate(),y);g(b,x,S,C);let E=w(b,x,S,C),O=r.distanceTo(l)>i.distanceTo(l)?i:r,k=O.distanceTo(l),A=O.distanceTo(u);if((k<m||A<m)&&E&&!E.isParallel){let a=r.distanceTo(l)<r.distanceTo(u)?l:u,d=!1;for(let y=0;y<e.length;y++){if(y==o||_.includes(y)||e[y].length<.7)continue;let b=new f.Vector3(e[y].start.x,e[y].start.y,0),x=new f.Vector3(e[y].end.x,e[y].end.y,0),S=new f.Vector3().subVectors(b,x).normalize(),C=S.clone().negate(),E=b.clone().addScaledVector(S,5),O=x.clone().addScaledVector(C,5),k=T(l,u,b,x),A=D(l,u,b,x),j=g(l,u,E,O),M=!0;if(j!=null&&(M=j.point.distanceTo(l)<m||j.point.distanceTo(u)<m),(k&&k.angle>85||A&&A.type==`collinear_gap`)&&M){let m=new f.Line3(l,u),g=new f.Vector3,S=m.closestPointToPoint(b,!0,g),C=m.closestPointToPoint(x,!0,g),T=S.distanceTo(b),E=C.distanceTo(x),O,k;if(T>E&&E>h)O=x,k=C;else if(T<E&&T>h)O=b,k=S;else continue;if(T=a.distanceTo(b),E=a.distanceTo(x),T>2&&E>2)continue;let A=w(O,k,b,x);if(!A||!A.isParallel)continue;let j=D(r,i,O,k);if(j&&j.type==`collinear_overlap`&&j.maxPerpendicularDistance<.2)continue;O.z=k.z=e[y].start.z;let M=!1;for(let e=0;e<v.length;e++){let t=D(v[e].start,v[e].end,O,k);if(t&&t.type==`collinear_overlap`&&t.maxPerpendicularDistance<.2){M=!0;break}}if(M)continue;for(let t=0;t<e.length;t++){if(e[t].length<.5)continue;let n=D(new f.Vector3(e[t].start.x,e[t].start.y,e[t].start.z),new f.Vector3(e[t].end.x,e[t].end.y,e[t].end.z),O,k);if(n&&n.type==`collinear_overlap`&&n.maxPerpendicularDistance<.1){M=!0;break}}if(M)continue;v.push({start:O,end:k}),_.push(y);let N=e[y].rooftopPz-e[y].start.z,P=e[o].rooftopPz-e[o].start.z,F=N<P?N:P;e[y].doorAndBeamData||(e[y].doorAndBeamData=[]),e[y].doorAndBeamData.push({id:c,beamStart:O,beamEnd:k,beamHeight:F,doorStart:O,doorEnd:k,doorHeight:F,nearId:-1,type:`onlyDoor`,isDoor:!0}),n[s[t].index].isFindBeam=!0,n[s[t].index].isFindOnlyDoor=!0,p.push([{id:c,beamStart:O,beamEnd:k}]),c++,d=!0;break}}if(d)break}}}return{lines:e,beamGroup:p}},se=(e,t)=>{if(e.length<=0)return e;for(let t of e){let e=[];for(let n=0;n<t.checkResults.length;n++){let r=t.checkResults[n];if(r.isDoor=!1,!r.originalVertices||r.originalVertices.length==0)continue;let i=[];r.originalVertices.forEach(e=>{let t=[];e.forEach(e=>{t.push(new f.Vector3(e.x,e.y,e.z))}),i.push(t)});let a=i.length,o=Array.from({length:a},(e,t)=>t);function s(e){for(;o[e]!==e;)o[e]=o[o[e]],e=o[e];return e}for(let e=0;e<a;e++)for(let t=e+1;t<a;t++){let n=i[e],r=i[t];if(n.some(e=>r.some(t=>e.equals(t)))){let n=s(e),r=s(t);n!==r&&(o[n]=r)}}let c=new Map,l=-1,u=-1;for(let e=0;e<a;e++){let t=s(e);c.has(t)||c.set(t,{points:[],area:0,originalVertices:[],index:-1,gridWidth:-1,gridHeight:-1,centerPts:[]});let r=c.get(t),[a,o,d,p]=i[e],m=new f.Vector3().add(a).add(o).add(d).add(p).multiplyScalar(.25);if(r.points.push(...i[e]),r.area+=a.distanceTo(o)*a.distanceTo(p),r.originalVertices.push(i[e]),r.index=n,r.centerPts.push(m),l==-1||u==-1){let e=new f.Vector3().subVectors(a,o).normalize();u=a.distanceTo(p),l=a.distanceTo(o);let t=y(e,new f.Vector3(0,0,1));t&&t.parallel&&([u,l]=[l,u])}r.gridWidth=l,r.gridHeight=u}e.push(...c.values())}t.mergeCheckRegion=e}let n=new Map;for(let t of e){let e=t.rooftopPz-t.start.z,r=Math.floor(t.rooftopPz-t.start.z);n.has(r)?n.set(r,{num:n.get(r).num+1,totalHeight:n.get(r).totalHeight+e}):n.set(r,{num:1,totalHeight:e})}let r=[...n.entries()].reduce((e,t)=>t[1].num>e[1].num?t:e),i=r[0];r[1].totalHeight/r[1].num,new f.MeshBasicMaterial({color:`#cffd00`,transparent:!0,opacity:.4,side:f.DoubleSide}),new f.PointsMaterial({color:65535,size:.01});for(let n=0;n<e.length;n++){let r=e[n],{minZ:a,maxZ:o}=M(r);if(a==null||o==null)continue;r.doorAndBeamData=[],r.completePointAreaPercentage=-1,o-a;let s=r.rooftopPz-r.start.z;if(s<i-.5||s>i+2||Math.abs(a-r.start.z)>.3||r.length<1)continue;let c=new f.Vector3(r.start.x,r.start.y,0),l=new f.Vector3(r.end.x,r.end.y,0);for(let r=0;r<e.length;r++){if(r==n||e[r].length<1)continue;let i=e[r],a=new f.Vector3(i.start.x,i.start.y,0),s=new f.Vector3(i.end.x,i.end.y,0),u=w(c,l,a,s),d=E(c,l),p=new f.Line3(a,s).closestPointToPoint(d,!0,new f.Vector3),m=d.distanceTo(p),h=M(i);if(!(h.minZ===void 0||h.maxZ===void 0)&&!(h.maxZ-h.minZ>1)&&u&&u.isParallel&&m<.25&&Math.abs(o-h.minZ)<.1){let i=E(c,l),o=E(a,s);i.z=o.z=1,i.applyEuler(new f.Euler(-Math.PI/2,0,0)),o.applyEuler(new f.Euler(-Math.PI/2,0,0));let u=`w:${e[n].originaIndex},b:${e[r].originaIndex}`,d=`b:${e[r].originaIndex},w:${e[n].originaIndex}`;t.add(_(u,i,{textColor:`#fd0000`})),t.add(_(d,o,{textColor:`#fd0000`}))}}}return e},ce=(e,t)=>{let n={rectangles:[],threeEdgeRect:[]},r=new Set,i=.2,a=1.5,o=.15;for(let t=0;t<e.length;t++){let s=e[t].length;if(r.has(t)||s<i||s>a)continue;let c=[],l=new f.Vector3(e[t].start.x,e[t].start.y,e[t].start.z),u=new f.Vector3(e[t].end.x,e[t].end.y,e[t].end.z),d=new f.Vector3().subVectors(u,l).normalize().clone().negate(),p=new f.Vector3,m=new f.Vector3,h=new f.Vector3;new f.Vector3;for(let n=0;n<e.length;n++){let r=e[n].length;if(n==t||r<i||r>a)continue;let g=new f.Vector3(e[n].start.x,e[n].start.y,e[n].start.z),_=new f.Vector3(e[n].end.x,e[n].end.y,e[n].end.z),v=T(l,u,g,_);if(!v||v.angle<85)continue;let b=L(g,l),x=L(g,u),S=L(_,l),C=L(_,u);if(!(!b&&!x&&!S&&!C)){b||x?(p=g.clone(),m=_.clone()):(p=_.clone(),m=g.clone()),h=new f.Vector3().subVectors(m,p).normalize(),h.clone().negate();for(let p=0;p<e.length;p++){let h=e[p].length;if(p==t||p==n||h<i||h>a)continue;let v=new f.Vector3(e[p].start.x,e[p].start.y,e[p].start.z),b=new f.Vector3(e[p].end.x,e[p].end.y,e[p].end.z),x=T(g,_,v,b);if(!x||x.angle<85)continue;let S=L(v,m),C=L(b,m);if(!S&&!C)continue;new f.Vector3;let w=new f.Vector3,E=new f.Vector3;S?(E=new f.Vector3().subVectors(b,v).normalize(),v.clone(),w=b.clone()):(E=new f.Vector3().subVectors(v,b).normalize(),b.clone(),w=v.clone());let D=y(d,E,.1);if(!(!D||!D.parallel||!D.sameDirection)){for(let d=0;d<e.length;d++){let m=e[d].length;if(d==t||d==n||d==p||m<i||m>a)continue;let h=new f.Vector3(e[d].start.x,e[d].start.y,e[d].start.z),g=new f.Vector3(e[d].end.x,e[d].end.y,e[d].end.z),_=T(h,g,v,b);if(!_||_.angle<85)continue;let y=L(h,w),x=L(g,w);if(!y&&!x)continue;new f.Vector3;let S=new f.Vector3;y?(h.clone(),S=g.clone()):(g.clone(),S=h.clone());let C=L(S,l),E=L(S,u);if(!C&&!E)continue;let D=s*r;if(!(D<o||D>2)){c=[t,n,p,d];break}}if(c.length==4)break}}if(c.length==4)break}}c.length==4&&(c.forEach(e=>r.add(e)),n.rectangles.push(c))}for(let t=0;t<e.length;t++){let s=e[t].length;if(r.has(t)||s<i||s>a)continue;let c={indexs:[],missingEdge:{start:new f.Vector3,end:new f.Vector3}},l=new f.Vector3(e[t].start.x,e[t].start.y,e[t].start.z),u=new f.Vector3(e[t].end.x,e[t].end.y,e[t].end.z),d=!0,p=!0;for(let n=0;n<e.length;n++){if(n==t)continue;let r=new f.Vector3(e[n].start.x,e[n].start.y,e[n].start.z),i=new f.Vector3(e[n].end.x,e[n].end.y,e[n].end.z),a=L(r,l),o=L(i,l),s=L(r,u),c=L(i,u);if(a||o?d=!1:(s||c)&&(p=!1),!d&&!p)break}if(!d&&!p)continue;let m=new f.Vector3;d||([l,u]=[u,l]),m=new f.Vector3().subVectors(u,l).normalize();let h=m.clone().negate();for(let n=0;n<e.length;n++){let d=e[n].length;if(n==t||r.has(n)||d<i||d>a)continue;let p=new f.Vector3(e[n].start.x,e[n].start.y,e[n].start.z),m=new f.Vector3(e[n].end.x,e[n].end.y,e[n].end.z),g=T(l,u,p,m);if(!g||g.angle<85)continue;let _=L(p,u),v=L(m,u);if(!_&&!v)continue;new f.Vector3;let b=new f.Vector3;_?(p.clone(),b=m.clone()):(m.clone(),b=p.clone());for(let u=0;u<e.length;u++){let g=e[u].length;if(u==t||u==n||r.has(u)||g<i||g>a)continue;let _=new f.Vector3(e[u].start.x,e[u].start.y,e[u].start.z),v=new f.Vector3(e[u].end.x,e[u].end.y,e[u].end.z),x=T(p,m,_,v);if(!x||x.angle<85)continue;let S=L(_,b),C=L(v,b);if(!S&&!C)continue;let w=new f.Vector3,E=new f.Vector3;S?(w=_.clone(),E=v.clone()):(w=v.clone(),E=_.clone());let D=y(h,new f.Vector3().subVectors(E,w).normalize(),.1);if(!D||!D.parallel||!D.sameDirection)continue;let O=!0,k=!0;for(let t=0;t<e.length;t++){if(t==u)continue;let n=new f.Vector3(e[t].start.x,e[t].start.y,e[t].start.z),r=new f.Vector3(e[t].end.x,e[t].end.y,e[t].end.z),i=L(n,_),a=L(r,_),o=L(n,v),s=L(r,v);if(i||a?O=!1:(o||s)&&(k=!1),!O&&!k)break}if(!O&&!k)continue;let A=s*d;if(!(A<o||A>2)){c.indexs=[t,n,u],c.missingEdge.start=E,c.missingEdge.end=l;break}}if(c.indexs.length==3)break}c.indexs.length==3&&(c.indexs.forEach(e=>r.add(e)),n.threeEdgeRect.push(c))}return n},H=11102230246251565e-32,U=134217729,le=(3+8*H)*H;function ue(e,t,n,r,i){let a,o,s,c,l=t[0],u=r[0],d=0,f=0;u>l==u>-l?(a=l,l=t[++d]):(a=u,u=r[++f]);let p=0;if(d<e&&f<n)for(u>l==u>-l?(o=l+a,s=a-(o-l),l=t[++d]):(o=u+a,s=a-(o-u),u=r[++f]),a=o,s!==0&&(i[p++]=s);d<e&&f<n;)u>l==u>-l?(o=a+l,c=o-a,s=a-(o-c)+(l-c),l=t[++d]):(o=a+u,c=o-a,s=a-(o-c)+(u-c),u=r[++f]),a=o,s!==0&&(i[p++]=s);for(;d<e;)o=a+l,c=o-a,s=a-(o-c)+(l-c),l=t[++d],a=o,s!==0&&(i[p++]=s);for(;f<n;)o=a+u,c=o-a,s=a-(o-c)+(u-c),u=r[++f],a=o,s!==0&&(i[p++]=s);return(a!==0||p===0)&&(i[p++]=a),p}function de(e,t){let n=t[0];for(let r=1;r<e;r++)n+=t[r];return n}function W(e){return new Float64Array(e)}var fe=(3+16*H)*H,pe=(2+12*H)*H,me=(9+64*H)*H*H,he=W(4),ge=W(8),_e=W(12),ve=W(16),G=W(4);function ye(e,t,n,r,i,a,o){let s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T=e-i,E=n-i,D=t-a,O=r-a;b=T*O,f=U*T,p=f-(f-T),m=T-p,f=U*O,h=f-(f-O),g=O-h,x=m*g-(b-p*h-m*h-p*g),S=D*E,f=U*D,p=f-(f-D),m=D-p,f=U*E,h=f-(f-E),g=E-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,he[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,he[1]=y-(_+d)+(d-S),w=v+_,d=w-v,he[2]=v-(w-d)+(_-d),he[3]=w;let k=de(4,he),A=pe*o;if(k>=A||-k>=A||(d=e-T,s=e-(T+d)+(d-i),d=n-E,l=n-(E+d)+(d-i),d=t-D,c=t-(D+d)+(d-a),d=r-O,u=r-(O+d)+(d-a),s===0&&c===0&&l===0&&u===0)||(A=me*o+le*Math.abs(k),k+=T*u+O*s-(D*l+E*c),k>=A||-k>=A))return k;b=s*O,f=U*s,p=f-(f-s),m=s-p,f=U*O,h=f-(f-O),g=O-h,x=m*g-(b-p*h-m*h-p*g),S=c*E,f=U*c,p=f-(f-c),m=c-p,f=U*E,h=f-(f-E),g=E-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,G[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,G[1]=y-(_+d)+(d-S),w=v+_,d=w-v,G[2]=v-(w-d)+(_-d),G[3]=w;let j=ue(4,he,4,G,ge);b=T*u,f=U*T,p=f-(f-T),m=T-p,f=U*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=D*l,f=U*D,p=f-(f-D),m=D-p,f=U*l,h=f-(f-l),g=l-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,G[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,G[1]=y-(_+d)+(d-S),w=v+_,d=w-v,G[2]=v-(w-d)+(_-d),G[3]=w;let M=ue(j,ge,4,G,_e);return b=s*u,f=U*s,p=f-(f-s),m=s-p,f=U*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=c*l,f=U*c,p=f-(f-c),m=c-p,f=U*l,h=f-(f-l),g=l-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,G[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,G[1]=y-(_+d)+(d-S),w=v+_,d=w-v,G[2]=v-(w-d)+(_-d),G[3]=w,ve[ue(M,_e,4,G,ve)-1]}function be(e,t,n,r,i,a){let o=(t-a)*(n-i),s=(e-i)*(r-a),c=o-s,l=Math.abs(o+s);return Math.abs(c)>=fe*l?c:-ye(e,t,n,r,i,a,l)}(7+56*H)*H,(3+28*H)*H,(26+288*H)*H*H,W(4),W(4),W(4),W(4),W(4),W(4),W(4),W(4),W(4),W(8),W(8),W(8),W(4),W(8),W(8),W(16),W(12),W(192),W(192),(10+96*H)*H,(4+48*H)*H,(44+576*H)*H*H,W(4),W(4),W(4),W(4),W(4),W(4),W(4),W(4),W(8),W(8),W(8),W(8),W(8),W(8),W(8),W(8),W(8),W(4),W(4),W(4),W(8),W(16),W(16),W(16),W(32),W(32),W(48),W(64),W(1152),W(1152),(16+224*H)*H,(5+72*H)*H,(71+1408*H)*H*H,W(4),W(4),W(4),W(4),W(4),W(4),W(4),W(4),W(4),W(4),W(24),W(24),W(24),W(24),W(24),W(24),W(24),W(24),W(24),W(24),W(1152),W(1152),W(1152),W(1152),W(1152),W(2304),W(2304),W(3456),W(5760),W(8),W(8),W(8),W(16),W(24),W(48),W(48),W(96),W(192),W(384),W(384),W(384),W(768),W(96),W(96),W(96),W(1152);var xe=2**-52,Se=new Uint32Array(512),Ce=class e{static from(t,n=je,r=Me){let i=t.length,a=new Float64Array(i*2);for(let e=0;e<i;e++){let i=t[e];a[2*e]=n(i),a[2*e+1]=r(i)}return new e(a)}constructor(e){let t=e.length>>1;if(t>0&&typeof e[0]!=`number`)throw Error(`Expected coords to contain numbers.`);this.coords=e;let n=Math.max(2*t-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.trianglesLen=0,this._cx=0,this._cy=0,this._hullStart=0,this.hull=this._triangles,this.triangles=this._triangles,this.halfedges=this._halfedges,this.update()}update(){let{coords:e,_hullPrev:t,_hullNext:n,_hullTri:r,_hullHash:i}=this,a=e.length>>1,o=1/0,s=1/0,c=-1/0,l=-1/0;for(let t=0;t<a;t++){let n=e[2*t],r=e[2*t+1];n<o&&(o=n),r<s&&(s=r),n>c&&(c=n),r>l&&(l=r),this._ids[t]=t}let u=(o+c)/2,d=(s+l)/2,f=0,p=0,m=0;for(let t=0,n=1/0;t<a;t++){let r=Te(u,d,e[2*t],e[2*t+1]);r<n&&(f=t,n=r)}let h=e[2*f],g=e[2*f+1];for(let t=0,n=1/0;t<a;t++){if(t===f)continue;let r=Te(h,g,e[2*t],e[2*t+1]);r<n&&r>0&&(p=t,n=r)}let _=e[2*p],v=e[2*p+1],y=1/0;for(let t=0;t<a;t++){if(t===f||t===p)continue;let n=De(h,g,_,v,e[2*t],e[2*t+1]);n<y&&(m=t,y=n)}let b=e[2*m],x=e[2*m+1];if(y===1/0){for(let t=0;t<a;t++)this._dists[t]=e[2*t]-e[0]||e[2*t+1]-e[1];ke(this._ids,this._dists,0,a-1);let t=new Uint32Array(a),n=0;for(let e=0,r=-1/0;e<a;e++){let i=this._ids[e],a=this._dists[i];a>r&&(t[n++]=i,r=a)}this.hull=t.subarray(0,n),this.triangles=new Uint32Array,this.halfedges=new Int32Array;return}if(be(h,g,_,v,b,x)<0){let e=p,t=_,n=v;p=m,_=b,v=x,m=e,b=t,x=n}let S=Oe(h,g,_,v,b,x);this._cx=S.x,this._cy=S.y;for(let t=0;t<a;t++)this._dists[t]=Te(e[2*t],e[2*t+1],S.x,S.y);ke(this._ids,this._dists,0,a-1),this._hullStart=f;let C=3;n[f]=t[m]=p,n[p]=t[f]=m,n[m]=t[p]=f,r[f]=0,r[p]=1,r[m]=2,i.fill(-1),i[this._hashKey(h,g)]=f,i[this._hashKey(_,v)]=p,i[this._hashKey(b,x)]=m,this.trianglesLen=0,this._addTriangle(f,p,m,-1,-1,-1);for(let a=0,o=0,s=0;a<this._ids.length;a++){let c=this._ids[a],l=e[2*c],u=e[2*c+1];if(a>0&&Math.abs(l-o)<=xe&&Math.abs(u-s)<=xe||(o=l,s=u,c===f||c===p||c===m))continue;let d=0;for(let e=0,t=this._hashKey(l,u);e<this._hashSize&&(d=i[(t+e)%this._hashSize],!(d!==-1&&d!==n[d]));e++);d=t[d];let h=d,g;for(;g=n[h],be(l,u,e[2*h],e[2*h+1],e[2*g],e[2*g+1])>=0;)if(h=g,h===d){h=-1;break}if(h===-1)continue;let _=this._addTriangle(h,c,n[h],-1,-1,r[h]);r[c]=this._legalize(_+2),r[h]=_,C++;let v=n[h];for(;g=n[v],be(l,u,e[2*v],e[2*v+1],e[2*g],e[2*g+1])<0;)_=this._addTriangle(v,c,g,r[c],-1,r[v]),r[c]=this._legalize(_+2),n[v]=v,C--,v=g;if(h===d)for(;g=t[h],be(l,u,e[2*g],e[2*g+1],e[2*h],e[2*h+1])<0;)_=this._addTriangle(g,c,h,-1,r[h],r[g]),this._legalize(_+2),r[g]=_,n[h]=h,C--,h=g;this._hullStart=t[c]=h,n[h]=t[v]=c,n[c]=v,i[this._hashKey(l,u)]=c,i[this._hashKey(e[2*h],e[2*h+1])]=h}this.hull=new Uint32Array(C);for(let e=0,t=this._hullStart;e<C;e++)this.hull[e]=t,t=n[t];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(e,t){return Math.floor(we(e-this._cx,t-this._cy)*this._hashSize)%this._hashSize}_legalize(e){let{_triangles:t,_halfedges:n,coords:r}=this,i=0,a=0;for(;;){let o=n[e],s=e-e%3;if(a=s+(e+2)%3,o===-1){if(i===0)break;e=Se[--i];continue}let c=o-o%3,l=s+(e+1)%3,u=c+(o+2)%3,d=t[a],f=t[e],p=t[l],m=t[u];if(Ee(r[2*d],r[2*d+1],r[2*f],r[2*f+1],r[2*p],r[2*p+1],r[2*m],r[2*m+1])){t[e]=m,t[o]=d;let r=n[u];if(r===-1){let t=this._hullStart;do{if(this._hullTri[t]===u){this._hullTri[t]=e;break}t=this._hullPrev[t]}while(t!==this._hullStart)}this._link(e,r),this._link(o,n[a]),this._link(a,u);let s=c+(o+1)%3;i<Se.length&&(Se[i++]=s)}else{if(i===0)break;e=Se[--i]}}return a}_link(e,t){this._halfedges[e]=t,t!==-1&&(this._halfedges[t]=e)}_addTriangle(e,t,n,r,i,a){let o=this.trianglesLen;return this._triangles[o]=e,this._triangles[o+1]=t,this._triangles[o+2]=n,this._link(o,r),this._link(o+1,i),this._link(o+2,a),this.trianglesLen+=3,o}};function we(e,t){let n=e/(Math.abs(e)+Math.abs(t));return(t>0?3-n:1+n)/4}function Te(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}function Ee(e,t,n,r,i,a,o,s){let c=e-o,l=t-s,u=n-o,d=r-s,f=i-o,p=a-s,m=c*c+l*l,h=u*u+d*d,g=f*f+p*p;return c*(d*g-h*p)-l*(u*g-h*f)+m*(u*p-d*f)<0}function De(e,t,n,r,i,a){let o=n-e,s=r-t,c=i-e,l=a-t,u=o*o+s*s,d=c*c+l*l,f=.5/(o*l-s*c),p=(l*u-s*d)*f,m=(o*d-c*u)*f;return p*p+m*m}function Oe(e,t,n,r,i,a){let o=n-e,s=r-t,c=i-e,l=a-t,u=o*o+s*s,d=c*c+l*l,f=.5/(o*l-s*c);return{x:e+(l*u-s*d)*f,y:t+(o*d-c*u)*f}}function ke(e,t,n,r){if(r-n<=20)for(let i=n+1;i<=r;i++){let r=e[i],a=t[r],o=i-1;for(;o>=n&&t[e[o]]>a;)e[o+1]=e[o--];e[o+1]=r}else{let i=n+r>>1,a=n+1,o=r;Ae(e,i,a),t[e[n]]>t[e[r]]&&Ae(e,n,r),t[e[a]]>t[e[r]]&&Ae(e,a,r),t[e[n]]>t[e[a]]&&Ae(e,n,a);let s=e[a],c=t[s];for(;;){do a++;while(t[e[a]]<c);do o--;while(t[e[o]]>c);if(o<a)break;Ae(e,a,o)}e[n+1]=e[o],e[o]=s,r-a+1>=o-n?(ke(e,t,a,r),ke(e,t,n,o-1)):(ke(e,t,n,o-1),ke(e,t,a,r))}}function Ae(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function je(e){return e[0]}function Me(e){return e[1]}var Ne=1e-6,Pe=class{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=``}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+=`Z`)}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,n){e=+e,t=+t,n=+n;let r=e+n,i=t;if(n<0)throw Error(`negative radius`);this._x1===null?this._+=`M${r},${i}`:(Math.abs(this._x1-r)>Ne||Math.abs(this._y1-i)>Ne)&&(this._+=`L`+r+`,`+i),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=r},${this._y1=i}`)}rect(e,t,n,r){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+r}h${-n}Z`}value(){return this._||null}},Fe=class{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}},Ie=class{constructor(e,[t,n,r,i]=[0,0,960,500]){if(!((r=+r)>=(t=+t))||!((i=+i)>=(n=+n)))throw Error(`invalid bounds`);this.delaunay=e,this._circumcenters=new Float64Array(e.points.length*2),this.vectors=new Float64Array(e.points.length*2),this.xmax=r,this.xmin=t,this.ymax=i,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){let{delaunay:{points:e,hull:t,triangles:n},vectors:r}=this,i,a,o=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let r=0,s=0,c=n.length,l,u;r<c;r+=3,s+=2){let c=n[r]*2,d=n[r+1]*2,f=n[r+2]*2,p=e[c],m=e[c+1],h=e[d],g=e[d+1],_=e[f],v=e[f+1],y=h-p,b=g-m,x=_-p,S=v-m,C=(y*S-b*x)*2;if(Math.abs(C)<1e-9){if(i===void 0){i=a=0;for(let n of t)i+=e[n*2],a+=e[n*2+1];i/=t.length,a/=t.length}let n=1e9*Math.sign((i-p)*S-(a-m)*x);l=(p+_)/2-n*S,u=(m+v)/2+n*x}else{let e=1/C,t=y*y+b*b,n=x*x+S*S;l=p+(S*t-b*n)*e,u=m+(y*n-x*t)*e}o[s]=l,o[s+1]=u}let s=t[t.length-1],c,l=s*4,u,d=e[2*s],f,p=e[2*s+1];r.fill(0);for(let n=0;n<t.length;++n)s=t[n],c=l,u=d,f=p,l=s*4,d=e[2*s],p=e[2*s+1],r[c+2]=r[l]=f-p,r[c+3]=r[l+1]=d-u}render(e){let t=e==null?e=new Pe:void 0,{delaunay:{halfedges:n,inedges:r,hull:i},circumcenters:a,vectors:o}=this;if(i.length<=1)return null;for(let t=0,r=n.length;t<r;++t){let r=n[t];if(r<t)continue;let i=Math.floor(t/3)*2,o=Math.floor(r/3)*2,s=a[i],c=a[i+1],l=a[o],u=a[o+1];this._renderSegment(s,c,l,u,e)}let s,c=i[i.length-1];for(let t=0;t<i.length;++t){s=c,c=i[t];let n=Math.floor(r[c]/3)*2,l=a[n],u=a[n+1],d=s*4,f=this._project(l,u,o[d+2],o[d+3]);f&&this._renderSegment(l,u,f[0],f[1],e)}return t&&t.value()}renderBounds(e){let t=e==null?e=new Pe:void 0;return e.rect(this.xmin,this.ymin,this.xmax-this.xmin,this.ymax-this.ymin),t&&t.value()}renderCell(e,t){let n=t==null?t=new Pe:void 0,r=this._clip(e);if(r===null||!r.length)return;t.moveTo(r[0],r[1]);let i=r.length;for(;r[0]===r[i-2]&&r[1]===r[i-1]&&i>1;)i-=2;for(let e=2;e<i;e+=2)(r[e]!==r[e-2]||r[e+1]!==r[e-1])&&t.lineTo(r[e],r[e+1]);return t.closePath(),n&&n.value()}*cellPolygons(){let{delaunay:{points:e}}=this;for(let t=0,n=e.length/2;t<n;++t){let e=this.cellPolygon(t);e&&(e.index=t,yield e)}}cellPolygon(e){let t=new Fe;return this.renderCell(e,t),t.value()}_renderSegment(e,t,n,r,i){let a,o=this._regioncode(e,t),s=this._regioncode(n,r);o===0&&s===0?(i.moveTo(e,t),i.lineTo(n,r)):(a=this._clipSegment(e,t,n,r,o,s))&&(i.moveTo(a[0],a[1]),i.lineTo(a[2],a[3]))}contains(e,t,n){return(t=+t,t!==t)||(n=+n,n!==n)?!1:this.delaunay._step(e,t,n)===e}*neighbors(e){let t=this._clip(e);if(t)for(let n of this.delaunay.neighbors(e)){let e=this._clip(n);if(e){loop:for(let r=0,i=t.length;r<i;r+=2)for(let a=0,o=e.length;a<o;a+=2)if(t[r]===e[a]&&t[r+1]===e[a+1]&&t[(r+2)%i]===e[(a+o-2)%o]&&t[(r+3)%i]===e[(a+o-1)%o]){yield n;break loop}}}}_cell(e){let{circumcenters:t,delaunay:{inedges:n,halfedges:r,triangles:i}}=this,a=n[e];if(a===-1)return null;let o=[],s=a;do{let n=Math.floor(s/3);if(o.push(t[n*2],t[n*2+1]),s=s%3==2?s-2:s+1,i[s]!==e)break;s=r[s]}while(s!==a&&s!==-1);return o}_clip(e){if(e===0&&this.delaunay.hull.length===1)return[this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];let t=this._cell(e);if(t===null)return null;let{vectors:n}=this,r=e*4;return this._simplify(n[r]||n[r+1]?this._clipInfinite(e,t,n[r],n[r+1],n[r+2],n[r+3]):this._clipFinite(e,t))}_clipFinite(e,t){let n=t.length,r=null,i,a,o=t[n-2],s=t[n-1],c,l=this._regioncode(o,s),u,d=0;for(let f=0;f<n;f+=2)if(i=o,a=s,o=t[f],s=t[f+1],c=l,l=this._regioncode(o,s),c===0&&l===0)u=d,d=0,r?r.push(o,s):r=[o,s];else{let t,n,f,p,m;if(c===0){if((t=this._clipSegment(i,a,o,s,c,l))===null)continue;[n,f,p,m]=t}else{if((t=this._clipSegment(o,s,i,a,l,c))===null)continue;[p,m,n,f]=t,u=d,d=this._edgecode(n,f),u&&d&&this._edge(e,u,d,r,r.length),r?r.push(n,f):r=[n,f]}u=d,d=this._edgecode(p,m),u&&d&&this._edge(e,u,d,r,r.length),r?r.push(p,m):r=[p,m]}if(r)u=d,d=this._edgecode(r[0],r[1]),u&&d&&this._edge(e,u,d,r,r.length);else if(this.contains(e,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2))return[this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];return r}_clipSegment(e,t,n,r,i,a){let o=i<a;for(o&&([e,t,n,r,i,a]=[n,r,e,t,a,i]);;){if(i===0&&a===0)return o?[n,r,e,t]:[e,t,n,r];if(i&a)return null;let s,c,l=i||a;l&8?(s=e+(n-e)*(this.ymax-t)/(r-t),c=this.ymax):l&4?(s=e+(n-e)*(this.ymin-t)/(r-t),c=this.ymin):l&2?(c=t+(r-t)*(this.xmax-e)/(n-e),s=this.xmax):(c=t+(r-t)*(this.xmin-e)/(n-e),s=this.xmin),i?(e=s,t=c,i=this._regioncode(e,t)):(n=s,r=c,a=this._regioncode(n,r))}}_clipInfinite(e,t,n,r,i,a){let o=Array.from(t),s;if((s=this._project(o[0],o[1],n,r))&&o.unshift(s[0],s[1]),(s=this._project(o[o.length-2],o[o.length-1],i,a))&&o.push(s[0],s[1]),o=this._clipFinite(e,o))for(let t=0,n=o.length,r,i=this._edgecode(o[n-2],o[n-1]);t<n;t+=2)r=i,i=this._edgecode(o[t],o[t+1]),r&&i&&(t=this._edge(e,r,i,o,t),n=o.length);else this.contains(e,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2)&&(o=[this.xmin,this.ymin,this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax]);return o}_edge(e,t,n,r,i){for(;t!==n;){let n,a;switch(t){case 5:t=4;continue;case 4:t=6,n=this.xmax,a=this.ymin;break;case 6:t=2;continue;case 2:t=10,n=this.xmax,a=this.ymax;break;case 10:t=8;continue;case 8:t=9,n=this.xmin,a=this.ymax;break;case 9:t=1;continue;case 1:t=5,n=this.xmin,a=this.ymin;break}(r[i]!==n||r[i+1]!==a)&&this.contains(e,n,a)&&(r.splice(i,0,n,a),i+=2)}return i}_project(e,t,n,r){let i=1/0,a,o,s;if(r<0){if(t<=this.ymin)return null;(a=(this.ymin-t)/r)<i&&(s=this.ymin,o=e+(i=a)*n)}else if(r>0){if(t>=this.ymax)return null;(a=(this.ymax-t)/r)<i&&(s=this.ymax,o=e+(i=a)*n)}if(n>0){if(e>=this.xmax)return null;(a=(this.xmax-e)/n)<i&&(o=this.xmax,s=t+(i=a)*r)}else if(n<0){if(e<=this.xmin)return null;(a=(this.xmin-e)/n)<i&&(o=this.xmin,s=t+(i=a)*r)}return[o,s]}_edgecode(e,t){return(e===this.xmin?1:e===this.xmax?2:0)|(t===this.ymin?4:t===this.ymax?8:0)}_regioncode(e,t){return(e<this.xmin?1:e>this.xmax?2:0)|(t<this.ymin?4:t>this.ymax?8:0)}_simplify(e){if(e&&e.length>4){for(let t=0;t<e.length;t+=2){let n=(t+2)%e.length,r=(t+4)%e.length;(e[t]===e[n]&&e[n]===e[r]||e[t+1]===e[n+1]&&e[n+1]===e[r+1])&&(e.splice(n,2),t-=2)}e.length||(e=null)}return e}},Le=2*Math.PI,Re=Math.pow;function ze(e){return e[0]}function Be(e){return e[1]}function Ve(e){let{triangles:t,coords:n}=e;for(let e=0;e<t.length;e+=3){let r=2*t[e],i=2*t[e+1],a=2*t[e+2];if((n[a]-n[r])*(n[i+1]-n[r+1])-(n[i]-n[r])*(n[a+1]-n[r+1])>1e-10)return!1}return!0}function He(e,t,n){return[e+Math.sin(e+t)*n,t+Math.cos(e-t)*n]}var Ue=class e{static from(t,n=ze,r=Be,i){return new e(`length`in t?We(t,n,r,i):Float64Array.from(Ge(t,n,r,i)))}constructor(e){this._delaunator=new Ce(e),this.inedges=new Int32Array(e.length/2),this._hullIndex=new Int32Array(e.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){let e=this._delaunator,t=this.points;if(e.hull&&e.hull.length>2&&Ve(e)){this.collinear=Int32Array.from({length:t.length/2},(e,t)=>t).sort((e,n)=>t[2*e]-t[2*n]||t[2*e+1]-t[2*n+1]);let e=this.collinear[0],n=this.collinear[this.collinear.length-1],r=[t[2*e],t[2*e+1],t[2*n],t[2*n+1]],i=1e-8*Math.hypot(r[3]-r[1],r[2]-r[0]);for(let e=0,n=t.length/2;e<n;++e){let n=He(t[2*e],t[2*e+1],i);t[2*e]=n[0],t[2*e+1]=n[1]}this._delaunator=new Ce(t)}else delete this.collinear;let n=this.halfedges=this._delaunator.halfedges,r=this.hull=this._delaunator.hull,i=this.triangles=this._delaunator.triangles,a=this.inedges.fill(-1),o=this._hullIndex.fill(-1);for(let e=0,t=n.length;e<t;++e){let t=i[e%3==2?e-2:e+1];(n[e]===-1||a[t]===-1)&&(a[t]=e)}for(let e=0,t=r.length;e<t;++e)o[r[e]]=e;r.length<=2&&r.length>0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],a[r[0]]=1,r.length===2&&(a[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(e){return new Ie(this,e)}*neighbors(e){let{inedges:t,hull:n,_hullIndex:r,halfedges:i,triangles:a,collinear:o}=this;if(o){let t=o.indexOf(e);t>0&&(yield o[t-1]),t<o.length-1&&(yield o[t+1]);return}let s=t[e];if(s===-1)return;let c=s,l=-1;do{if(yield l=a[c],c=c%3==2?c-2:c+1,a[c]!==e)return;if(c=i[c],c===-1){let t=n[(r[e]+1)%n.length];t!==l&&(yield t);return}}while(c!==s)}find(e,t,n=0){if((e=+e,e!==e)||(t=+t,t!==t))return-1;let r=n,i;for(;(i=this._step(n,e,t))>=0&&i!==n&&i!==r;)n=i;return i}_step(e,t,n){let{inedges:r,hull:i,_hullIndex:a,halfedges:o,triangles:s,points:c}=this;if(r[e]===-1||!c.length)return(e+1)%(c.length>>1);let l=e,u=Re(t-c[e*2],2)+Re(n-c[e*2+1],2),d=r[e],f=d;do{let r=s[f],d=Re(t-c[r*2],2)+Re(n-c[r*2+1],2);if(d<u&&(u=d,l=r),f=f%3==2?f-2:f+1,s[f]!==e)break;if(f=o[f],f===-1){if(f=i[(a[e]+1)%i.length],f!==r&&Re(t-c[f*2],2)+Re(n-c[f*2+1],2)<u)return f;break}}while(f!==d);return l}render(e){let t=e==null?e=new Pe:void 0,{points:n,halfedges:r,triangles:i}=this;for(let t=0,a=r.length;t<a;++t){let a=r[t];if(a<t)continue;let o=i[t]*2,s=i[a]*2;e.moveTo(n[o],n[o+1]),e.lineTo(n[s],n[s+1])}return this.renderHull(e),t&&t.value()}renderPoints(e,t){t===void 0&&(!e||typeof e.moveTo!=`function`)&&(t=e,e=null),t=t==null?2:+t;let n=e==null?e=new Pe:void 0,{points:r}=this;for(let n=0,i=r.length;n<i;n+=2){let i=r[n],a=r[n+1];e.moveTo(i+t,a),e.arc(i,a,t,0,Le)}return n&&n.value()}renderHull(e){let t=e==null?e=new Pe:void 0,{hull:n,points:r}=this,i=n[0]*2,a=n.length;e.moveTo(r[i],r[i+1]);for(let t=1;t<a;++t){let i=2*n[t];e.lineTo(r[i],r[i+1])}return e.closePath(),t&&t.value()}hullPolygon(){let e=new Fe;return this.renderHull(e),e.value()}renderTriangle(e,t){let n=t==null?t=new Pe:void 0,{points:r,triangles:i}=this,a=i[e*=3]*2,o=i[e+1]*2,s=i[e+2]*2;return t.moveTo(r[a],r[a+1]),t.lineTo(r[o],r[o+1]),t.lineTo(r[s],r[s+1]),t.closePath(),n&&n.value()}*trianglePolygons(){let{triangles:e}=this;for(let t=0,n=e.length/3;t<n;++t)yield this.trianglePolygon(t)}trianglePolygon(e){let t=new Fe;return this.renderTriangle(e,t),t.value()}};function We(e,t,n,r){let i=e.length,a=new Float64Array(i*2);for(let o=0;o<i;++o){let i=e[o];a[o*2]=t.call(r,i,o,e),a[o*2+1]=n.call(r,i,o,e)}return a}function*Ge(e,t,n,r){let i=0;for(let a of e)yield t.call(r,a,i,e),yield n.call(r,a,i,e),++i}function Ke(e,t,n,r){return 1+(e[t][0]===0||e[n][0]===0||e[r][0]===0?1:0)}function qe(e,t,n,r,i,a){let o=Math.hypot(n-i,r-a),s=Math.hypot(e-i,t-a),c=Math.hypot(e-n,t-r),l=Math.abs((n-e)*(a-t)-(i-e)*(r-t))/2;return l===0?1/0:o*s*c/(4*l)}function Je(e){if(!e||e.length<3)return[];let t=new Set,n=[];for(let r of e){let e=`${r[0]}_${r[1]}`;t.has(e)||(t.add(e),n.push(r))}if(n.length<3)return[];let{triangles:r}=new Ue(Float64Array.from(n.flat()));if(!r.length)return[];let i=new Map,a=(e,t)=>e<t?`${e}_${t}`:`${t}_${e}`;for(let e=0;e<r.length;e+=3){let t=r[e],o=r[e+1],s=r[e+2],[c,l]=n[t],[u,d]=n[o],[f,p]=n[s];if(qe(c,l,u,d,f,p)<=1/Ke(n,t,o,s))for(let[e,n]of[[t,o],[o,s],[s,t]]){let t=a(e,n);i.set(t,(i.get(t)||0)+1)}}let o=[];for(let[e,t]of i)t===1&&o.push(e.split(`_`).map(Number));if(!o.length)return[];let s=new Map;for(let[e,t]of o)(s.get(e)||s.set(e,[]).get(e)).push(t),(s.get(t)||s.set(t,[]).get(t)).push(e);let c=o[0][0],l=[],u=new Set,d=c,f=-1;do{l.push(n[d]),u.add(d);let e=s.get(d)||[],t=e.find(e=>e!==f&&!u.has(e));if(t===void 0&&(t=e.find(e=>e!==f)),t===void 0)break;f=d,d=t}while(d!==c&&l.length<=o.length+1);return l}var K={c:null,u:[new f.Vector3,new f.Vector3,new f.Vector3],e:[]},q={c:null,u:[new f.Vector3,new f.Vector3,new f.Vector3],e:[]},J=[[],[],[]],Y=[[],[],[]],X=[],Ye=new f.Vector3,Xe=new f.Vector3,Ze=new f.Vector3,Z=new f.Vector3,Qe=new f.Vector3,$e=new f.Vector3,Q=new f.Matrix3,et=new f.Box3,tt=new f.Matrix4,nt=new f.Matrix4,rt=new f.Ray,it=class{constructor(e=new f.Vector3,t=new f.Vector3,n=new f.Matrix3){this.center=e,this.halfSize=t,this.rotation=n}set(e,t,n){return this.center=e,this.halfSize=t,this.rotation=n,this}copy(e){return this.center.copy(e.center),this.halfSize.copy(e.halfSize),this.rotation.copy(e.rotation),this}clone(){return new this.constructor().copy(this)}getSize(e){return e.copy(this.halfSize).multiplyScalar(2)}clampPoint(e,t){let n=this.halfSize;Z.subVectors(e,this.center),this.rotation.extractBasis(Ye,Xe,Ze),t.copy(this.center);let r=f.MathUtils.clamp(Z.dot(Ye),-n.x,n.x);t.add(Ye.multiplyScalar(r));let i=f.MathUtils.clamp(Z.dot(Xe),-n.y,n.y);t.add(Xe.multiplyScalar(i));let a=f.MathUtils.clamp(Z.dot(Ze),-n.z,n.z);return t.add(Ze.multiplyScalar(a)),t}containsPoint(e){return Z.subVectors(e,this.center),this.rotation.extractBasis(Ye,Xe,Ze),Math.abs(Z.dot(Ye))<=this.halfSize.x&&Math.abs(Z.dot(Xe))<=this.halfSize.y&&Math.abs(Z.dot(Ze))<=this.halfSize.z}intersectsBox3(e){return this.intersectsOBB(at.fromBox3(e))}intersectsSphere(e){return this.clampPoint(e.center,$e),$e.distanceToSquared(e.center)<=e.radius*e.radius}intersectsOBB(e,t=2**-52){K.c=this.center,K.e[0]=this.halfSize.x,K.e[1]=this.halfSize.y,K.e[2]=this.halfSize.z,this.rotation.extractBasis(K.u[0],K.u[1],K.u[2]),q.c=e.center,q.e[0]=e.halfSize.x,q.e[1]=e.halfSize.y,q.e[2]=e.halfSize.z,e.rotation.extractBasis(q.u[0],q.u[1],q.u[2]);for(let e=0;e<3;e++)for(let t=0;t<3;t++)J[e][t]=K.u[e].dot(q.u[t]);Z.subVectors(q.c,K.c),X[0]=Z.dot(K.u[0]),X[1]=Z.dot(K.u[1]),X[2]=Z.dot(K.u[2]);for(let e=0;e<3;e++)for(let n=0;n<3;n++)Y[e][n]=Math.abs(J[e][n])+t;let n,r;for(let e=0;e<3;e++)if(n=K.e[e],r=q.e[0]*Y[e][0]+q.e[1]*Y[e][1]+q.e[2]*Y[e][2],Math.abs(X[e])>n+r)return!1;for(let e=0;e<3;e++)if(n=K.e[0]*Y[0][e]+K.e[1]*Y[1][e]+K.e[2]*Y[2][e],r=q.e[e],Math.abs(X[0]*J[0][e]+X[1]*J[1][e]+X[2]*J[2][e])>n+r)return!1;return n=K.e[1]*Y[2][0]+K.e[2]*Y[1][0],r=q.e[1]*Y[0][2]+q.e[2]*Y[0][1],!(Math.abs(X[2]*J[1][0]-X[1]*J[2][0])>n+r||(n=K.e[1]*Y[2][1]+K.e[2]*Y[1][1],r=q.e[0]*Y[0][2]+q.e[2]*Y[0][0],Math.abs(X[2]*J[1][1]-X[1]*J[2][1])>n+r)||(n=K.e[1]*Y[2][2]+K.e[2]*Y[1][2],r=q.e[0]*Y[0][1]+q.e[1]*Y[0][0],Math.abs(X[2]*J[1][2]-X[1]*J[2][2])>n+r)||(n=K.e[0]*Y[2][0]+K.e[2]*Y[0][0],r=q.e[1]*Y[1][2]+q.e[2]*Y[1][1],Math.abs(X[0]*J[2][0]-X[2]*J[0][0])>n+r)||(n=K.e[0]*Y[2][1]+K.e[2]*Y[0][1],r=q.e[0]*Y[1][2]+q.e[2]*Y[1][0],Math.abs(X[0]*J[2][1]-X[2]*J[0][1])>n+r)||(n=K.e[0]*Y[2][2]+K.e[2]*Y[0][2],r=q.e[0]*Y[1][1]+q.e[1]*Y[1][0],Math.abs(X[0]*J[2][2]-X[2]*J[0][2])>n+r)||(n=K.e[0]*Y[1][0]+K.e[1]*Y[0][0],r=q.e[1]*Y[2][2]+q.e[2]*Y[2][1],Math.abs(X[1]*J[0][0]-X[0]*J[1][0])>n+r)||(n=K.e[0]*Y[1][1]+K.e[1]*Y[0][1],r=q.e[0]*Y[2][2]+q.e[2]*Y[2][0],Math.abs(X[1]*J[0][1]-X[0]*J[1][1])>n+r)||(n=K.e[0]*Y[1][2]+K.e[1]*Y[0][2],r=q.e[0]*Y[2][1]+q.e[1]*Y[2][0],Math.abs(X[1]*J[0][2]-X[0]*J[1][2])>n+r))}intersectsPlane(e){this.rotation.extractBasis(Ye,Xe,Ze);let t=this.halfSize.x*Math.abs(e.normal.dot(Ye))+this.halfSize.y*Math.abs(e.normal.dot(Xe))+this.halfSize.z*Math.abs(e.normal.dot(Ze)),n=e.normal.dot(this.center)-e.constant;return Math.abs(n)<=t}intersectRay(e,t){return this.getSize(Qe),et.setFromCenterAndSize(Z.set(0,0,0),Qe),tt.setFromMatrix3(this.rotation),tt.setPosition(this.center),nt.copy(tt).invert(),rt.copy(e).applyMatrix4(nt),rt.intersectBox(et,t)?t.applyMatrix4(tt):null}intersectsRay(e){return this.intersectRay(e,Z)!==null}fromBox3(e){return e.getCenter(this.center),e.getSize(this.halfSize).multiplyScalar(.5),this.rotation.identity(),this}equals(e){return e.center.equals(this.center)&&e.halfSize.equals(this.halfSize)&&e.rotation.equals(this.rotation)}applyMatrix4(e){let t=e.elements,n=Z.set(t[0],t[1],t[2]).length(),r=Z.set(t[4],t[5],t[6]).length(),i=Z.set(t[8],t[9],t[10]).length();e.determinant()<0&&(n=-n),Q.setFromMatrix4(e);let a=1/n,o=1/r,s=1/i;return Q.elements[0]*=a,Q.elements[1]*=a,Q.elements[2]*=a,Q.elements[3]*=o,Q.elements[4]*=o,Q.elements[5]*=o,Q.elements[6]*=s,Q.elements[7]*=s,Q.elements[8]*=s,this.rotation.multiply(Q),this.halfSize.x*=n,this.halfSize.y*=r,this.halfSize.z*=i,Z.setFromMatrixPosition(e),this.center.add(Z),this}},at=new it,$=6371008.8,ot={centimeters:$*100,centimetres:$*100,degrees:360/(2*Math.PI),feet:$*3.28084,inches:$*39.37,kilometers:$/1e3,kilometres:$/1e3,meters:$,metres:$,miles:$/1609.344,millimeters:$*1e3,millimetres:$*1e3,nauticalmiles:$/1852,radians:1,yards:$*1.0936};function st(e,t,n={}){let r={type:`Feature`};return(n.id===0||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=t||{},r.geometry=e,r}function ct(e,t,n={}){if(!e)throw Error(`coordinates is required`);if(!Array.isArray(e))throw Error(`coordinates must be an Array`);if(e.length<2)throw Error(`coordinates must be at least 2 numbers long`);if(!ht(e[0])||!ht(e[1]))throw Error(`coordinates must contain numbers`);return st({type:`Point`,coordinates:e},t,n)}function lt(e,t,n={}){for(let t of e){if(t.length<4)throw Error(`Each LinearRing of a Polygon must have 4 or more Positions.`);if(t[t.length-1].length!==t[0].length)throw Error(`First and last Position are not equivalent.`);for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw Error(`First and last Position are not equivalent.`)}return st({type:`Polygon`,coordinates:e},t,n)}function ut(e,t=`kilometers`){let n=ot[t];if(!n)throw Error(t+` units is invalid`);return e*n}function dt(e,t=`kilometers`){let n=ot[t];if(!n)throw Error(t+` units is invalid`);return e/n}function ft(e){return e%(2*Math.PI)*180/Math.PI}function pt(e){return e%360*Math.PI/180}function mt(e,t=`kilometers`,n=`kilometers`){if(!(e>=0))throw Error(`length must be a positive number`);return ut(dt(e,t),n)}function ht(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function gt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _t(e,t,n){if(e!==null)for(var r,i,a,o,s,c,l,u=0,d=0,f,p=e.type,m=p===`FeatureCollection`,h=p===`Feature`,g=m?e.features.length:1,_=0;_<g;_++){l=m?e.features[_].geometry:h?e.geometry:e,f=l?l.type===`GeometryCollection`:!1,s=f?l.geometries.length:1;for(var v=0;v<s;v++){var y=0,b=0;if(o=f?l.geometries[v]:l,o!==null){c=o.coordinates;var x=o.type;switch(u=n&&(x===`Polygon`||x===`MultiPolygon`)?1:0,x){case null:break;case`Point`:if(t(c,d,_,y,b)===!1)return!1;d++,y++;break;case`LineString`:case`MultiPoint`:for(r=0;r<c.length;r++){if(t(c[r],d,_,y,b)===!1)return!1;d++,x===`MultiPoint`&&y++}x===`LineString`&&y++;break;case`Polygon`:case`MultiLineString`:for(r=0;r<c.length;r++){for(i=0;i<c[r].length-u;i++){if(t(c[r][i],d,_,y,b)===!1)return!1;d++}x===`MultiLineString`&&y++,x===`Polygon`&&b++}x===`Polygon`&&y++;break;case`MultiPolygon`:for(r=0;r<c.length;r++){for(b=0,i=0;i<c[r].length;i++){for(a=0;a<c[r][i].length-u;a++){if(t(c[r][i][a],d,_,y,b)===!1)return!1;d++}b++}y++}break;case`GeometryCollection`:for(r=0;r<o.geometries.length;r++)if(_t(o.geometries[r],t,n)===!1)return!1;break;default:throw Error(`Unknown Geometry Type`)}}}}}function vt(e){var t=[];return _t(e,function(e){t.push(e)}),t}function yt(e,t){var n,r,i,a,o,s,c,l,u,d,f=0,p=e.type===`FeatureCollection`,m=e.type===`Feature`,h=p?e.features.length:1;for(n=0;n<h;n++){for(s=p?e.features[n].geometry:m?e.geometry:e,l=p?e.features[n].properties:m?e.properties:{},u=p?e.features[n].bbox:m?e.bbox:void 0,d=p?e.features[n].id:m?e.id:void 0,c=s?s.type===`GeometryCollection`:!1,o=c?s.geometries.length:1,i=0;i<o;i++){if(a=c?s.geometries[i]:s,a===null){if(t(null,f,l,u,d)===!1)return!1;continue}switch(a.type){case`Point`:case`LineString`:case`MultiPoint`:case`Polygon`:case`MultiLineString`:case`MultiPolygon`:if(t(a,f,l,u,d)===!1)return!1;break;case`GeometryCollection`:for(r=0;r<a.geometries.length;r++)if(t(a.geometries[r],f,l,u,d)===!1)return!1;break;default:throw Error(`Unknown Geometry Type`)}}f++}}function bt(e,t,n){var r=n;return yt(e,function(e,i,a,o,s){r=i===0&&n===void 0?e:t(r,e,i,a,o,s)}),r}var xt=s(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n||=self).RBush=r()})(e,function(){"use strict";function e(e,r,i,a,o){(function e(n,r,i,a,o){for(;a>i;){if(a-i>600){var s=a-i+1,c=r-i+1,l=Math.log(s),u=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*u*(s-u)/s)*(c-s/2<0?-1:1);e(n,r,Math.max(i,Math.floor(r-c*u/s+d)),Math.min(a,Math.floor(r+(s-c)*u/s+d)),o)}var f=n[r],p=i,m=a;for(t(n,i,r),o(n[a],f)>0&&t(n,i,a);p<m;){for(t(n,p,m),p++,m--;o(n[p],f)<0;)p++;for(;o(n[m],f)>0;)m--}o(n[i],f)===0?t(n,i,m):t(n,++m,a),m<=r&&(i=m+1),r<=m&&(a=m-1)}})(e,r,i||0,a||e.length-1,o||n)}function t(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function n(e,t){return e<t?-1:e>t?1:0}var r=function(e){e===void 0&&(e=9),this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function i(e,t,n){if(!n)return t.indexOf(e);for(var r=0;r<t.length;r++)if(n(e,t[r]))return r;return-1}function a(e,t){o(e,0,e.children.length,t,e)}function o(e,t,n,r,i){i||=m(null),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(var a=t;a<n;a++){var o=e.children[a];s(i,e.leaf?r(o):o)}return i}function s(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function c(e,t){return e.minX-t.minX}function l(e,t){return e.minY-t.minY}function u(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function d(e){return e.maxX-e.minX+(e.maxY-e.minY)}function f(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function p(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function m(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function h(t,n,r,i,a){for(var o=[n,r];o.length;)if(!((r=o.pop())-(n=o.pop())<=i)){var s=n+Math.ceil((r-n)/i/2)*i;e(t,s,n,r,a),o.push(n,s,s,r)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(e){var t=this.data,n=[];if(!p(e,t))return n;for(var r=this.toBBox,i=[];t;){for(var a=0;a<t.children.length;a++){var o=t.children[a],s=t.leaf?r(o):o;p(e,s)&&(t.leaf?n.push(o):f(e,s)?this._all(o,n):i.push(o))}t=i.pop()}return n},r.prototype.collides=function(e){var t=this.data;if(!p(e,t))return!1;for(var n=[];t;){for(var r=0;r<t.children.length;r++){var i=t.children[r],a=t.leaf?this.toBBox(i):i;if(p(e,a)){if(t.leaf||f(e,a))return!0;n.push(i)}}t=n.pop()}return!1},r.prototype.load=function(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(var t=0;t<e.length;t++)this.insert(e[t]);return this}var n=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){var r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this},r.prototype.insert=function(e){return e&&this._insert(e,this.data.height-1),this},r.prototype.clear=function(){return this.data=m([]),this},r.prototype.remove=function(e,t){if(!e)return this;for(var n,r,a,o=this.data,s=this.toBBox(e),c=[],l=[];o||c.length;){if(o||(o=c.pop(),r=c[c.length-1],n=l.pop(),a=!0),o.leaf){var u=i(e,o.children,t);if(u!==-1)return o.children.splice(u,1),c.push(o),this._condense(c),this}a||o.leaf||!f(o,s)?r?(n++,o=r.children[n],a=!1):o=null:(c.push(o),l.push(n),n=0,r=o,o=o.children[0])}return this},r.prototype.toBBox=function(e){return e},r.prototype.compareMinX=function(e,t){return e.minX-t.minX},r.prototype.compareMinY=function(e,t){return e.minY-t.minY},r.prototype.toJSON=function(){return this.data},r.prototype.fromJSON=function(e){return this.data=e,this},r.prototype._all=function(e,t){for(var n=[];e;)e.leaf?t.push.apply(t,e.children):n.push.apply(n,e.children),e=n.pop();return t},r.prototype._build=function(e,t,n,r){var i,o=n-t+1,s=this._maxEntries;if(o<=s)return a(i=m(e.slice(t,n+1)),this.toBBox),i;r||(r=Math.ceil(Math.log(o)/Math.log(s)),s=Math.ceil(o/s**(r-1))),(i=m([])).leaf=!1,i.height=r;var c=Math.ceil(o/s),l=c*Math.ceil(Math.sqrt(s));h(e,t,n,l,this.compareMinX);for(var u=t;u<=n;u+=l){var d=Math.min(u+l-1,n);h(e,u,d,c,this.compareMinY);for(var f=u;f<=d;f+=c){var p=Math.min(f+c-1,d);i.children.push(this._build(e,f,p,r-1))}}return a(i,this.toBBox),i},r.prototype._chooseSubtree=function(e,t,n,r){for(;r.push(t),!t.leaf&&r.length-1!==n;){for(var i=1/0,a=1/0,o=void 0,s=0;s<t.children.length;s++){var c=t.children[s],l=u(c),d=(f=e,p=c,(Math.max(p.maxX,f.maxX)-Math.min(p.minX,f.minX))*(Math.max(p.maxY,f.maxY)-Math.min(p.minY,f.minY))-l);d<a?(a=d,i=l<i?l:i,o=c):d===a&&l<i&&(i=l,o=c)}t=o||t.children[0]}var f,p;return t},r.prototype._insert=function(e,t,n){var r=n?e:this.toBBox(e),i=[],a=this._chooseSubtree(r,this.data,t,i);for(a.children.push(e),s(a,r);t>=0&&i[t].children.length>this._maxEntries;)this._split(i,t),t--;this._adjustParentBBoxes(r,i,t)},r.prototype._split=function(e,t){var n=e[t],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);var o=this._chooseSplitIndex(n,i,r),s=m(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,a(n,this.toBBox),a(s,this.toBBox),t?e[t-1].children.push(s):this._splitRoot(n,s)},r.prototype._splitRoot=function(e,t){this.data=m([e,t]),this.data.height=e.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(e,t,n){for(var r,i,a,s,c,l,d,f=1/0,p=1/0,m=t;m<=n-t;m++){var h=o(e,0,m,this.toBBox),g=o(e,m,n,this.toBBox),_=(i=h,a=g,s=void 0,c=void 0,l=void 0,d=void 0,s=Math.max(i.minX,a.minX),c=Math.max(i.minY,a.minY),l=Math.min(i.maxX,a.maxX),d=Math.min(i.maxY,a.maxY),Math.max(0,l-s)*Math.max(0,d-c)),v=u(h)+u(g);_<f?(f=_,r=m,p=v<p?v:p):_===f&&v<p&&(p=v,r=m)}return r||n-t},r.prototype._chooseSplitAxis=function(e,t,n){var r=e.leaf?this.compareMinX:c,i=e.leaf?this.compareMinY:l;this._allDistMargin(e,t,n,r)<this._allDistMargin(e,t,n,i)&&e.children.sort(r)},r.prototype._allDistMargin=function(e,t,n,r){e.children.sort(r);for(var i=this.toBBox,a=o(e,0,t,i),c=o(e,n-t,n,i),l=d(a)+d(c),u=t;u<n-t;u++){var f=e.children[u];s(a,e.leaf?i(f):f),l+=d(a)}for(var p=n-t-1;p>=t;p--){var m=e.children[p];s(c,e.leaf?i(m):m),l+=d(c)}return l},r.prototype._adjustParentBBoxes=function(e,t,n){for(var r=n;r>=0;r--)s(t[r],e)},r.prototype._condense=function(e){for(var t=e.length-1,n=void 0;t>=0;t--)e[t].children.length===0?t>0?(n=e[t-1].children).splice(n.indexOf(e[t]),1):this.clear():a(e[t],this.toBBox)},r})})),St=c({default:()=>wt});function Ct(e,t){return e<t?-1:e>t?1:0}var wt,Tt=o((()=>{wt=class{constructor(e=[],t=Ct){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;let e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:t,compare:n}=this,r=t[e];for(;e>0;){let i=e-1>>1,a=t[i];if(n(r,a)>=0)break;t[e]=a,e=i}t[e]=r}_down(e){let{data:t,compare:n}=this,r=this.length>>1,i=t[e];for(;e<r;){let r=(e<<1)+1,a=t[r],o=r+1;if(o<this.length&&n(t[o],a)<0&&(r=o,a=t[o]),n(a,i)>=0)break;t[e]=a,e=r}t[e]=i}}})),Et=s(((e,t)=>{t.exports=function(e,t,n,r){var i=e[0],a=e[1],o=!1;n===void 0&&(n=0),r===void 0&&(r=t.length);for(var s=(r-n)/2,c=0,l=s-1;c<s;l=c++){var u=t[n+c*2+0],d=t[n+c*2+1],f=t[n+l*2+0],p=t[n+l*2+1];d>a!=p>a&&i<(f-u)*(a-d)/(p-d)+u&&(o=!o)}return o}})),Dt=s(((e,t)=>{t.exports=function(e,t,n,r){var i=e[0],a=e[1],o=!1;n===void 0&&(n=0),r===void 0&&(r=t.length);for(var s=r-n,c=0,l=s-1;c<s;l=c++){var u=t[c+n][0],d=t[c+n][1],f=t[l+n][0],p=t[l+n][1];d>a!=p>a&&i<(f-u)*(a-d)/(p-d)+u&&(o=!o)}return o}})),Ot=s(((e,t)=>{var n=Et(),r=Dt();t.exports=function(e,t,i,a){return t.length>0&&Array.isArray(t[0])?r(e,t,i,a):n(e,t,i,a)},t.exports.nested=r,t.exports.flat=n})),kt=s(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):r((n||=self).predicates={})})(e,function(e){"use strict";let t=134217729;function n(e,t,n,r,i){let a,o,s,c,l=t[0],u=r[0],d=0,f=0;u>l==u>-l?(a=l,l=t[++d]):(a=u,u=r[++f]);let p=0;if(d<e&&f<n)for(u>l==u>-l?(s=a-((o=l+a)-l),l=t[++d]):(s=a-((o=u+a)-u),u=r[++f]),a=o,s!==0&&(i[p++]=s);d<e&&f<n;)u>l==u>-l?(s=a-((o=a+l)-(c=o-a))+(l-c),l=t[++d]):(s=a-((o=a+u)-(c=o-a))+(u-c),u=r[++f]),a=o,s!==0&&(i[p++]=s);for(;d<e;)s=a-((o=a+l)-(c=o-a))+(l-c),l=t[++d],a=o,s!==0&&(i[p++]=s);for(;f<n;)s=a-((o=a+u)-(c=o-a))+(u-c),u=r[++f],a=o,s!==0&&(i[p++]=s);return a===0&&p!==0||(i[p++]=a),p}function r(e){return new Float64Array(e)}let i=r(4),a=r(8),o=r(12),s=r(16),c=r(4);e.orient2d=function(e,r,l,u,d,f){let p=(r-f)*(l-d),m=(e-d)*(u-f),h=p-m;if(p===0||m===0||p>0!=m>0)return h;let g=Math.abs(p+m);return Math.abs(h)>=33306690738754716e-32*g?h:-function(e,r,l,u,d,f,p){let m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M=e-d,N=l-d,P=r-f,F=u-f;v=(O=(x=M-(b=(y=t*M)-(y-M)))*(C=F-(S=(y=t*F)-(y-F)))-((D=M*F)-b*S-x*S-b*C))-(w=O-(A=(x=P-(b=(y=t*P)-(y-P)))*(C=N-(S=(y=t*N)-(y-N)))-((k=P*N)-b*S-x*S-b*C))),i[0]=O-(w+v)+(v-A),v=(E=D-((T=D+w)-(v=T-D))+(w-v))-(w=E-k),i[1]=E-(w+v)+(v-k),v=(j=T+w)-T,i[2]=T-(j-v)+(w-v),i[3]=j;let I=function(e,t){let n=t[0];for(let r=1;r<e;r++)n+=t[r];return n}(4,i),ee=22204460492503146e-32*p;if(I>=ee||-I>=ee||(m=e-(M+(v=e-M))+(v-d),g=l-(N+(v=l-N))+(v-d),h=r-(P+(v=r-P))+(v-f),_=u-(F+(v=u-F))+(v-f),m===0&&h===0&&g===0&&_===0)||(ee=11093356479670487e-47*p+33306690738754706e-32*Math.abs(I),(I+=M*_+F*m-(P*g+N*h))>=ee||-I>=ee))return I;v=(O=(x=m-(b=(y=t*m)-(y-m)))*(C=F-(S=(y=t*F)-(y-F)))-((D=m*F)-b*S-x*S-b*C))-(w=O-(A=(x=h-(b=(y=t*h)-(y-h)))*(C=N-(S=(y=t*N)-(y-N)))-((k=h*N)-b*S-x*S-b*C))),c[0]=O-(w+v)+(v-A),v=(E=D-((T=D+w)-(v=T-D))+(w-v))-(w=E-k),c[1]=E-(w+v)+(v-k),v=(j=T+w)-T,c[2]=T-(j-v)+(w-v),c[3]=j;let L=n(4,i,4,c,a);v=(O=(x=M-(b=(y=t*M)-(y-M)))*(C=_-(S=(y=t*_)-(y-_)))-((D=M*_)-b*S-x*S-b*C))-(w=O-(A=(x=P-(b=(y=t*P)-(y-P)))*(C=g-(S=(y=t*g)-(y-g)))-((k=P*g)-b*S-x*S-b*C))),c[0]=O-(w+v)+(v-A),v=(E=D-((T=D+w)-(v=T-D))+(w-v))-(w=E-k),c[1]=E-(w+v)+(v-k),v=(j=T+w)-T,c[2]=T-(j-v)+(w-v),c[3]=j;let R=n(L,a,4,c,o);return v=(O=(x=m-(b=(y=t*m)-(y-m)))*(C=_-(S=(y=t*_)-(y-_)))-((D=m*_)-b*S-x*S-b*C))-(w=O-(A=(x=h-(b=(y=t*h)-(y-h)))*(C=g-(S=(y=t*g)-(y-g)))-((k=h*g)-b*S-x*S-b*C))),c[0]=O-(w+v)+(v-A),v=(E=D-((T=D+w)-(v=T-D))+(w-v))-(w=E-k),c[1]=E-(w+v)+(v-k),v=(j=T+w)-T,c[2]=T-(j-v)+(w-v),c[3]=j,s[n(R,o,4,c,s)-1]}(e,r,l,u,d,f,g)},e.orient2dfast=function(e,t,n,r,i,a){return(t-a)*(n-i)-(e-i)*(r-a)},Object.defineProperty(e,`__esModule`,{value:!0})})})),At=u(s(((e,t)=>{var n=xt(),r=(Tt(),d(St)),i=Ot(),a=kt().orient2d;r.default&&(r=r.default),t.exports=o,t.exports.default=o;function o(e,t,r){t=Math.max(0,t===void 0?2:t),r||=0;var i=g(e),a=new n(16);a.toBBox=function(e){return{minX:e[0],minY:e[1],maxX:e[0],maxY:e[1]}},a.compareMinX=function(e,t){return e[0]-t[0]},a.compareMinY=function(e,t){return e[1]-t[1]},a.load(e);for(var o=[],c=0,l;c<i.length;c++){var u=i[c];a.remove(u),l=_(u,l),o.push(l)}var d=new n(16);for(c=0;c<o.length;c++)d.insert(h(o[c]));for(var f=t*t,p=r*r;o.length;){var m=o.shift(),y=m.p,b=m.next.p,x=v(y,b);if(!(x<p)){var S=x/f;u=s(a,m.prev.p,y,b,m.next.next.p,S,d),u&&Math.min(v(u,y),v(u,b))<=S&&(o.push(m),o.push(_(u,m)),a.remove(u),d.remove(m),d.insert(h(m)),d.insert(h(m.next)))}}m=l;var C=[];do C.push(m.p),m=m.next;while(m!==l);return C.push(m.p),C}function s(e,t,n,i,a,o,s){for(var u=new r([],c),d=e.data;d;){for(var p=0;p<d.children.length;p++){var m=d.children[p],h=d.leaf?y(m,n,i):l(n,i,m);h>o||u.push({node:m,dist:h})}for(;u.length&&!u.peek().node.children;){var g=u.pop(),_=g.node,v=y(_,t,n),b=y(_,i,a);if(g.dist<v&&g.dist<b&&f(n,_,s)&&f(i,_,s))return _}d=u.pop(),d&&=d.node}return null}function c(e,t){return e.dist-t.dist}function l(e,t,n){if(u(e,n)||u(t,n))return 0;var r=b(e[0],e[1],t[0],t[1],n.minX,n.minY,n.maxX,n.minY);if(r===0)return 0;var i=b(e[0],e[1],t[0],t[1],n.minX,n.minY,n.minX,n.maxY);if(i===0)return 0;var a=b(e[0],e[1],t[0],t[1],n.maxX,n.minY,n.maxX,n.maxY);if(a===0)return 0;var o=b(e[0],e[1],t[0],t[1],n.minX,n.maxY,n.maxX,n.maxY);return o===0?0:Math.min(r,i,a,o)}function u(e,t){return e[0]>=t.minX&&e[0]<=t.maxX&&e[1]>=t.minY&&e[1]<=t.maxY}function f(e,t,n){for(var r=Math.min(e[0],t[0]),i=Math.min(e[1],t[1]),a=Math.max(e[0],t[0]),o=Math.max(e[1],t[1]),s=n.search({minX:r,minY:i,maxX:a,maxY:o}),c=0;c<s.length;c++)if(m(s[c].p,s[c].next.p,e,t))return!1;return!0}function p(e,t,n){return a(e[0],e[1],t[0],t[1],n[0],n[1])}function m(e,t,n,r){return e!==r&&t!==n&&p(e,t,n)>0!=p(e,t,r)>0&&p(n,r,e)>0!=p(n,r,t)>0}function h(e){var t=e.p,n=e.next.p;return e.minX=Math.min(t[0],n[0]),e.minY=Math.min(t[1],n[1]),e.maxX=Math.max(t[0],n[0]),e.maxY=Math.max(t[1],n[1]),e}function g(e){for(var t=e[0],n=e[0],r=e[0],a=e[0],o=0;o<e.length;o++){var s=e[o];s[0]<t[0]&&(t=s),s[0]>r[0]&&(r=s),s[1]<n[1]&&(n=s),s[1]>a[1]&&(a=s)}var c=[t,n,r,a],l=c.slice();for(o=0;o<e.length;o++)i(e[o],c)||l.push(e[o]);return S(l)}function _(e,t){var n={p:e,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return t?(n.next=t.next,n.prev=t,t.next.prev=n,t.next=n):(n.prev=n,n.next=n),n}function v(e,t){var n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r}function y(e,t,n){var r=t[0],i=t[1],a=n[0]-r,o=n[1]-i;if(a!==0||o!==0){var s=((e[0]-r)*a+(e[1]-i)*o)/(a*a+o*o);s>1?(r=n[0],i=n[1]):s>0&&(r+=a*s,i+=o*s)}return a=e[0]-r,o=e[1]-i,a*a+o*o}function b(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=e-i,p=t-a,m=c*c+l*l,h=c*u+l*d,g=u*u+d*d,_=c*f+l*p,v=u*f+d*p,y=m*g-h*h,b,x,S,C,w=y,T=y;y===0?(x=0,w=1,C=v,T=g):(x=h*v-g*_,C=m*v-h*_,x<0?(x=0,C=v,T=g):x>w&&(x=w,C=v+h,T=g)),C<0?(C=0,-_<0?x=0:-_>m?x=w:(x=-_,w=m)):C>T&&(C=T,-_+h<0?x=0:-_+h>m?x=w:(x=-_+h,w=m)),b=x===0?0:x/w,S=C===0?0:C/T;var E=(1-b)*e+b*n,D=(1-b)*t+b*r,O=(1-S)*i+S*o,k=(1-S)*a+S*s,A=O-E,j=k-D;return A*A+j*j}function x(e,t){return e[0]===t[0]?e[1]-t[1]:e[0]-t[0]}function S(e){e.sort(x);for(var t=[],n=0;n<e.length;n++){for(;t.length>=2&&p(t[t.length-2],t[t.length-1],e[n])<=0;)t.pop();t.push(e[n])}for(var r=[],i=e.length-1;i>=0;i--){for(;r.length>=2&&p(r[r.length-2],r[r.length-1],e[i])<=0;)r.pop();r.push(e[i])}return r.pop(),t.pop(),t.concat(r)}}))(),1);function jt(e,t={}){t.concavity=t.concavity||1/0;let n=[];if(_t(e,e=>{n.push([e[0],e[1]])}),!n.length)return null;let r=(0,At.default)(n,t.concavity);return r.length>3?lt([r]):null}function Mt(e,t={}){let n=0,r=0,i=0;return _t(e,function(e){n+=e[0],r+=e[1],i++},!0),ct([n/i,r/i],t.properties)}function Nt(e){if(!e)throw Error(`coord is required`);if(!Array.isArray(e)){if(e.type===`Feature`&&e.geometry!==null&&e.geometry.type===`Point`)return[...e.geometry.coordinates];if(e.type===`Point`)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw Error(`coord must be GeoJSON Point or an Array of numbers`)}function Pt(e){if(Array.isArray(e))return e;if(e.type===`Feature`){if(e.geometry!==null)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw Error(`coords must be GeoJSON Feature, Geometry Object or an Array`)}function Ft(e,t,n={}){let r;return r=n.final?It(Nt(t),Nt(e)):It(Nt(e),Nt(t)),r>180?-(360-r):r}function It(e,t){let n=pt(e[1]),r=pt(t[1]),i=pt(t[0]-e[0]);i>Math.PI&&(i-=2*Math.PI),i<-Math.PI&&(i+=2*Math.PI);let a=Math.log(Math.tan(r/2+Math.PI/4)/Math.tan(n/2+Math.PI/4));return(ft(Math.atan2(i,a))+360)%360}function Lt(e,t,n={}){let r=Nt(e),i=Nt(t);return i[0]+=i[0]-r[0]>180?-360:r[0]-i[0]>180?360:0,mt(Rt(r,i),`meters`,n.units)}function Rt(e,t,n){n=n===void 0?$:Number(n);let r=n,i=e[1]*Math.PI/180,a=t[1]*Math.PI/180,o=a-i,s=Math.abs(t[0]-e[0])*Math.PI/180;s>Math.PI&&(s-=2*Math.PI);let c=Math.log(Math.tan(a/2+Math.PI/4)/Math.tan(i/2+Math.PI/4)),l=Math.abs(c)>1e-11?o/c:Math.cos(i);return Math.sqrt(o*o+l*l*s*s)*r}function zt(e,t,n,r={}){let i=t<0,a=mt(Math.abs(t),r.units,`meters`);i&&(a=-Math.abs(a));let o=Nt(e),s=Bt(o,a,n);return s[0]+=s[0]-o[0]>180?-360:o[0]-s[0]>180?360:0,ct(s,r.properties)}function Bt(e,t,n,r){r=r===void 0?$:Number(r);let i=t/r,a=e[0]*Math.PI/180,o=pt(e[1]),s=pt(n),c=i*Math.cos(s),l=o+c;Math.abs(l)>Math.PI/2&&(l=l>0?Math.PI-l:-Math.PI-l);let u=Math.log(Math.tan(l/2+Math.PI/4)/Math.tan(o/2+Math.PI/4)),d=Math.abs(u)>1e-11?c/u:Math.cos(o);return[((a+i*Math.sin(s)/d)*180/Math.PI+540)%360-180,l*180/Math.PI]}function Vt(e){if(!e)throw Error(`geojson is required`);switch(e.type){case`Feature`:return Ht(e);case`FeatureCollection`:return Wt(e);case`Point`:case`LineString`:case`Polygon`:case`MultiPoint`:case`MultiLineString`:case`MultiPolygon`:case`GeometryCollection`:return Gt(e);default:throw Error(`unknown GeoJSON type`)}}function Ht(e){let t={type:`Feature`};return Object.keys(e).forEach(n=>{switch(n){case`type`:case`properties`:case`geometry`:return;default:t[n]=e[n]}}),t.properties=Ut(e.properties),e.geometry==null?t.geometry=null:t.geometry=Gt(e.geometry),t}function Ut(e){let t={};return e&&Object.keys(e).forEach(n=>{let r=e[n];typeof r==`object`?r===null?t[n]=null:Array.isArray(r)?t[n]=r.map(e=>e):t[n]=Ut(r):t[n]=r}),t}function Wt(e){let t={type:`FeatureCollection`};return Object.keys(e).forEach(n=>{switch(n){case`type`:case`features`:return;default:t[n]=e[n]}}),t.features=e.features.map(e=>Ht(e)),t}function Gt(e){let t={type:e.type};return e.bbox&&(t.bbox=e.bbox),e.type===`GeometryCollection`?(t.geometries=e.geometries.map(e=>Gt(e)),t):(t.coordinates=Kt(e.coordinates),t)}function Kt(e){let t=e;return typeof t[0]==`object`?t.map(e=>Kt(e)):t.slice()}function qt(e,t,n){if(n||={},!gt(n))throw Error(`options is invalid`);let r=n.pivot,i=n.mutate;if(!e)throw Error(`geojson is required`);if(t==null||isNaN(t))throw Error(`angle is required`);if(t===0)return e;let a=r??Mt(e);return(i===!1||i===void 0)&&(e=Vt(e)),_t(e,function(e){let n=Ft(a,e)+t,r=Pt(zt(a,Lt(a,e),n));e[0]=r[0],e[1]=r[1]}),e}function Jt(e,t,n={}){if(n.final===!0)return Yt(e,t);let r=Nt(e),i=Nt(t),a=pt(r[0]),o=pt(i[0]),s=pt(r[1]),c=pt(i[1]),l=Math.sin(o-a)*Math.cos(c),u=Math.cos(s)*Math.sin(c)-Math.sin(s)*Math.cos(c)*Math.cos(o-a);return ft(Math.atan2(l,u))}function Yt(e,t){let n=Jt(t,e);return n=(n+180)%360,n}function Xt(e,t={}){if(e.bbox!=null&&!0!==t.recompute)return e.bbox;let n=[1/0,1/0,-1/0,-1/0];return _t(e,e=>{n[0]>e[0]&&(n[0]=e[0]),n[1]>e[1]&&(n[1]=e[1]),n[2]<e[0]&&(n[2]=e[0]),n[3]<e[1]&&(n[3]=e[1])}),n}function Zt(e,t={}){let n=Number(e[0]),r=Number(e[1]),i=Number(e[2]),a=Number(e[3]);if(e.length===6)throw Error(`@turf/bbox-polygon does not support BBox with 6 positions`);let o=[n,r];return lt([[o,[i,r],[i,a],[n,a],o]],t.properties,{bbox:e,id:t.id})}function Qt(e){return Zt(Xt(e))}function $t(e){return bt(e,(e,t)=>e+en(t),0)}function en(e){let t=0,n;switch(e.type){case`Polygon`:return tn(e.coordinates);case`MultiPolygon`:for(n=0;n<e.coordinates.length;n++)t+=tn(e.coordinates[n]);return t;case`Point`:case`MultiPoint`:case`LineString`:case`MultiLineString`:return 0}return 0}function tn(e){let t=0;if(e&&e.length>0){t+=Math.abs(an(e[0]));for(let n=1;n<e.length;n++)t-=Math.abs(an(e[n]))}return t}var nn=$*$/2,rn=Math.PI/180;function an(e){let t=e.length-1;if(t<=2)return 0;let n=0,r=0;for(;r<t;){let i=e[r],a=e[r+1===t?0:r+1],o=e[r+2>=t?(r+2)%t:r+2],s=i[0]*rn,c=a[1]*rn,l=o[0]*rn;n+=(l-s)*Math.sin(c),r++}return n*nn}function on(e){let t=jt(e);if(!t)throw Error(`Can't calculate smallestSurroundingRectangleByArea for given geometry`);let n=Mt(t),r=vt(t),i=2**53-1,a=null;for(let e=0;e<r.length-1;e++){let o=Jt(r[e],r[e+1]),s=Qt(qt(t,-1*o,{pivot:n})),c=$t(s);c<i&&(i=c,a=qt(s,o,{pivot:n}))}return a}function sn(e,t){let n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)}function cn(e){let t=1/0,n=-1/0,r=1/0,i=-1/0;for(let[a,o]of e)a<t&&(t=a),a>n&&(n=a),o<r&&(r=o),o>i&&(i=o);return[(n+t)*.5,(i+r)*.5]}var ln=class e extends it{getBoxMesh(){un.identity(),un.setFromMatrix3(this.rotation),un.decompose(mn,dn,new f.Vector3);let e=this.halfSize.clone().multiplyScalar(2),t=new f.Mesh(new f.BoxGeometry(e.x,e.y,e.z));return t.position.copy(this.center),t.rotation.setFromQuaternion(dn),t}getBoxEdge(e=16776960){let t=this.getBoxMesh();hn.setFromObject(t);let n=new f.EdgesGeometry(t.geometry.clone().applyMatrix4(t.matrixWorld));return new f.LineSegments(n,new f.LineBasicMaterial({color:e,toneMapped:!1}))}toJson(){return un.identity(),un.setFromMatrix3(this.rotation),un.decompose(mn,dn,new f.Vector3),{size:this.halfSize.toArray(),center:this.center.toArray(),quaternion:dn.toArray()}}static from(t,n,r,i=new e){if(r instanceof f.Euler)dn.setFromEuler(r);else if(r instanceof f.Quaternion)dn.copy(r);else throw Error(`传入的旋转不是欧拉角或者四元数`);return un.compose(n,dn,pn),i.center.copy(n),i.halfSize.copy(t.multiplyScalar(.5)),i.rotation.setFromMatrix4(un),i}static fromByPath2D(t,n,r,i=new e){let a=on({type:`Polygon`,coordinates:[t.map(e=>[e.x,e.y])]});if(!a)throw Error(`2d obb 获取失败`);let o=a.geometry.coordinates[0],s=sn(o[0],o[1]),c=sn(o[1],o[2]),l=Math.atan2(o[1][1]-o[0][1],o[1][0]-o[0][0]);mn.set(s,c,r),fn.set(0,0,l);let[u,d]=cn(o);return n.x=u,n.y=d,this.from(mn,n,fn,i)}},un=new f.Matrix4,dn=new f.Quaternion,fn=new f.Euler,pn=new f.Vector3(1,1,1),mn=new f.Vector3,hn=new f.Box3;function gn(e,t,n=.005,r=.2){if(!e.length||!t.length)return 0;let i=Math.max(n*3,.05),a=n*n,o=new Map,s=(e,t,n)=>`${Math.floor(e/i)},${Math.floor(t/i)},${Math.floor(n/i)}`;for(let e of t){let t=s(e.x,e.y,e.z);o.has(t)||o.set(t,[]),o.get(t).push(e)}let c=0,l=Math.ceil(n/i)+1,u=[];for(let e=-l;e<=l;e++)for(let t=-l;t<=l;t++)for(let n=-l;n<=l;n++)e*e+t*t+n*n<=l*l&&u.push([e,t,n]);for(let t of e){let n=Math.floor(t.x/i),s=Math.floor(t.y/i),l=Math.floor(t.z/i),d=!1;for(let[e,r,i]of u){let c=`${n+e},${s+r},${l+i}`;if(o.has(c)){for(let e of o.get(c))if(t.distanceToSquared(e)<a){d=!0;break}if(d)break}}if(d&&(c++,c/e.length>r))return c/e.length}return c/e.length}function _n(e,t,n=.5){let r=0,i=0;for(let a of e)if(t.containsPoint(a)&&(r++,i=r/e.length,i>n))break;return i}function vn(e,t,n,r){if(e.intersectsOBB(t))return!0;{let i=bn(e,r),a=bn(t,n);if(i||a)return!0}return!1}function yn(e,t){let n=new f.Vector3,r=new f.Vector3;e.getSize(n),t.getSize(r);let i=n.x*n.y*n.z,a=r.x*r.y*r.z;return i>a?1:i<a?-1:0}function bn(e,t){let n=!0;for(let r=0;r<t.length;r++)if(!e.containsPoint(t[r])){n=!1;break}return n}function xn(e){if(e.length===0)return{x:0,y:0,z:0,h:0};let t=0,n=0,r=-1/0,i=1/0;for(let a of e)t+=a.x,n+=a.y,r=Math.max(r,a.z),i=Math.min(i,a.z);return{x:t/e.length,y:n/e.length,z:0,maxz:r,minz:i,h:r-i}}function Sn(e,t,n,r){let i=[];for(let t=0;t<e.length;t++)i.push(new f.Vector3(e[t][0],e[t][1],0));if(i.length==0)return null;let a=ln.fromByPath2D(i,t,n);return a.center.z=r,a}var Cn=e=>{if(e.length==0)return[];let t=[];for(let n=0;n<e.length;n++){let r=e[n].points.map(e=>[e.x,e.y]),i=xn(e[n].points),a=e[n].obj_id;a=a.replace(/calcony railing/g,`balcony railing`).replace(/glass balcony railing/g,`balcony railing`).replace(/metal balcony railing/g,`balcony railing`).replace(/temporary construction guardrail/g,`balcony railing`),a.split(`_`).slice(1,3).join(`_`).split(`.`)[0].split(`_`)[0];let o=a.indexOf(`_`)+1,s=a.lastIndexOf(`_`),c=a.substring(o,s);if(c===`wall`||c===`floor`||c===`roof`)continue;let l=[];for(let t=0;t<e[n].points.length;t++)l.push(new f.Vector3(e[n].points[t].x,e[n].points[t].y,e[n].points[t].z));let u={points:l,path:Je(r),h:i.h,minz:i.minz,maxz:i.maxz,center:{x:i.x,y:i.y,z:i.z},obj_id:e[n].obj_id,type:c,averagePz:e[n].averagePz,obb:null,isDel:!1,obj_id:a,positionArr:[e[n].position]};if(u.obb=Sn(u.path,u.center,u.h,(u.maxz+u.minz)/2),u.obb==null)continue;let d=-1;for(let e=0;e<t.length;e++)if(t[e].type==c){d=e;break}d==-1?t.push({type:c,array:[u]}):t[d].array.push(u)}for(let e=0;e<t.length;e++){let n=t[e].array,r=[],i=[];for(let e=0;e<n.length;e++){if(n[e].obb==null||r.includes(e))continue;let t={...n[e],obb:n[e].obb.clone()};for(let i=e+1;i<n.length;i++)if(!(n[i].obb==null||r.includes(i))&&t.obb.intersectsOBB(n[i].obb)){r.push(i),t.points.push(...n[i].points),t.path=Je(t.points.map(e=>[e.x,e.y]));let a=xn(t.points);t.h=a.h,t.minz=a.minz,t.maxz=a.maxz,t.center={x:a.x,y:a.y,z:a.z},t.obb=Sn(t.path,t.center,t.h,(t.maxz+t.minz)/2),t.positionArr.push(...n[i].positionArr),i=e}t.path.length>n[e].path.length&&(r.push(e),i.push(t))}let a=[];for(let e=0;e<n.length;e++)r.includes(e)||a.push(n[e]);a.push(...i),t[e].array=a}for(let e=0;e<t.length;e++){let n=t[e].type,r=t[e].array;for(let i=0;i<r.length;i++){let a=r[i].obb,o=r[i].minz;r[i].maxz;let s=r[i].averagePz;if(n===`window`||n===`door`||n===`tv`||n===`chair`||n===`cabinet`||n===`table`){let e=new f.Vector3;a.getSize(e);let t=[e.x,e.y,e.z],n=0;for(let e of t)if(e<.2&&(n++,n===2)){r[i].isDel=!0;break}}if(!r[i].isDel)for(let c=e+1;c<t.length;c++){let e=t[c].type,l=t[c].array;for(let t=0;t<l.length;t++){if(l[t].isDel)continue;let c=l[t].obb,u=l[t].minz;if(l[t].maxz,a.intersectsOBB(c)){_n(l[t].points,a);let d=_n(r[i].points,c),f=yn(a,c);if(d>=.3&&f==-1){r[i].isDel=!0;break}if(n!==`wall`&&n!==`floor`&&n!==`roof`){if(n===`window`){if(e===`balcony railing`&&containsObb(a,l[t].points)){l[t].isDel=!0;continue}if(e===`balcony railing`&&containsObb(c,r[i].points)){r[i].isDel=!0;break}if(e===`balcony railing`&&vn(a,c,r[i].points,l[t].points)&&(Math.abs(o-u)<.1||Math.abs(u-s)>.3)){l[t].isDel=!0;continue}}else if(n===`balcony railing`){if(e===`window`&&containsObb(a,l[t].points)){l[t].isDel=!0;continue}if(e===`window`&&containsObb(c,r[i].points)){r[i].isDel=!0;break}if(e===`window`&&vn(a,c,r[i].points,l[t].points)&&(Math.abs(o-u)<.1||Math.abs(o-s)>.3)){r[i].isDel=!0;break}}let d=!1,f=[],p=[],m=r[i].points,h=l[t].points;if(m.length>h.length?(d=!0,f=m,p=h):(f=h,p=m),gn(p,f,.03,.5)>.5){if(e===`people`){l[t].isDel=!0;continue}else if(n===`people`){r[i].isDel=!0;break}if(d)l[t].isDel=!0;else{r[i].isDel=!0;break}}else if(vn(a,c)){if(e===`people`){l[t].isDel=!0;continue}else if(n===`people`){r[i].isDel=!0;break}let o=yn(a,c);if(o===1||o===0){if(e===`switch`)continue;_n(p,a)>=.5&&(l[t].isDel=!0)}else{if(n===`switch`)continue;if(_n(p,c)>=.5){r[i].isDel=!0;break}}}}}}if(r[i].isDel)break}}}for(let e=0;e<t.length;e++){let n=t[e].type,r=t[e].array;for(let e=0;e<r.length;e++){let t=r[e].maxz,i=r[e].minz,a=n===`switch`?.1:.3,o=r[e].averagePz;if(Math.abs(t-o)<a){r[e].isDel=!0;continue}if(n===`window`||n===`door`||n===`tv`){let i=Math.abs(t-o);n!==`window`&&i<1.6&&(r[e].isDel=!0),n===`window`&&i<1&&(r[e].isDel=!0)}if(n===`chair`){let t=new f.Vector3;r[e].obb.getSize(t),(t.x<.1||t.y<.1)&&(r[e].isDel=!0)}n===`balcony railing`&&(Math.abs(t-i)<.4&&(r[e].isDel=!0),(i<o&&Math.abs(i-o)>1||i>o&&Math.abs(i-o)>1)&&(r[e].isDel=!0),t<o&&(r[e].isDel=!0))}}for(let e=0;e<t.length;e++)t[e].array=t[e].array.filter(e=>!e.isDel);let n=[];for(let e=0;e<t.length;e++){let r=t[e].array;for(let e=0;e<r.length;e++)n.push({obbBox:r[e].obb,box:new f.Box3().setFromPoints(r[e].points),category:r[e].type,center:{x:r[e].center.x,y:r[e].center.y,z:(r[e].minz+r[e].maxz)/2},name:r[e].obj_id,obj_id:r[e].obj_id,pcdPoints:r[e].points,positionArr:r[e].positionArr})}return n};exports.classifySegments=D,exports.getAllGeometry=ie,exports.getBeamLine=oe,exports.getColLine=ce,exports.getMainBeamLine=se,exports.getMergeMeaning=Cn,exports.getParallelism=w,exports.getPointCloudMinMax=M,exports.getPointCoverageOnQuad=A,exports.isParallel=y,exports.perpendicularInfo=T,exports.removeNoisePoints=P,exports.segmentsIntersect2D=g,exports.usegetBeamLine=ae;
|
package/dist/index.js
CHANGED
|
@@ -1103,28 +1103,28 @@ var fe = class {
|
|
|
1103
1103
|
}
|
|
1104
1104
|
i.add(m), console.time();
|
|
1105
1105
|
let { beamGroup: x } = await _e(o, _, y, i);
|
|
1106
|
-
console.timeEnd(), console.log("beamGroup", x)
|
|
1107
|
-
let S = new e.MeshBasicMaterial({
|
|
1106
|
+
console.timeEnd(), console.log("beamGroup", x), new e.MeshBasicMaterial({
|
|
1108
1107
|
color: "#cffd00",
|
|
1109
1108
|
transparent: !0,
|
|
1110
1109
|
opacity: .4,
|
|
1111
1110
|
side: e.DoubleSide
|
|
1112
|
-
})
|
|
1111
|
+
});
|
|
1112
|
+
let S = new e.MeshBasicMaterial({
|
|
1113
1113
|
color: "#ff0000",
|
|
1114
1114
|
transparent: !0,
|
|
1115
1115
|
opacity: .4,
|
|
1116
1116
|
side: e.DoubleSide
|
|
1117
|
-
}),
|
|
1117
|
+
}), C = new e.MeshBasicMaterial({
|
|
1118
1118
|
color: "#e100ff",
|
|
1119
1119
|
transparent: !0,
|
|
1120
1120
|
opacity: .4,
|
|
1121
1121
|
side: e.DoubleSide
|
|
1122
|
-
}),
|
|
1122
|
+
}), T = new e.MeshBasicMaterial({
|
|
1123
1123
|
color: "#0400ff",
|
|
1124
1124
|
transparent: !0,
|
|
1125
1125
|
opacity: .4,
|
|
1126
1126
|
side: e.DoubleSide
|
|
1127
|
-
}),
|
|
1127
|
+
}), E = new e.LineBasicMaterial({ color: "#cffd00" }), D = [];
|
|
1128
1128
|
for (let t = 0; t < o.length; t++) {
|
|
1129
1129
|
let n = o[t];
|
|
1130
1130
|
if (n.checkResults) for (let t of n.checkResults) for (let n of t.originalVertices) {
|
|
@@ -1151,12 +1151,12 @@ var fe = class {
|
|
|
1151
1151
|
3
|
|
1152
1152
|
]), o.computeVertexNormals();
|
|
1153
1153
|
let c = new e.EdgesGeometry(o, 1);
|
|
1154
|
-
|
|
1154
|
+
D.push(c);
|
|
1155
1155
|
}
|
|
1156
1156
|
}
|
|
1157
|
-
if (
|
|
1158
|
-
let t = w(
|
|
1159
|
-
t.rotateX(-Math.PI / 2), s.add(new e.LineSegments(t,
|
|
1157
|
+
if (D.length > 0) {
|
|
1158
|
+
let t = w(D, !1);
|
|
1159
|
+
t.rotateX(-Math.PI / 2), s.add(new e.LineSegments(t, E)), s.visible = !1, i.add(s), D.forEach((e) => e.dispose());
|
|
1160
1160
|
}
|
|
1161
1161
|
new e.PointsMaterial({
|
|
1162
1162
|
color: 65535,
|
|
@@ -1176,29 +1176,29 @@ var fe = class {
|
|
|
1176
1176
|
let i = [];
|
|
1177
1177
|
i.push(new e.Vector3(t.start.x, t.start.y, t.start.z)), i.push(new e.Vector3(t.end.x, t.end.y, t.end.z));
|
|
1178
1178
|
let a = new e.BufferGeometry();
|
|
1179
|
-
a.setFromPoints(i), a.rotateX(-Math.PI / 2), f.add(new e.Line(a,
|
|
1179
|
+
a.setFromPoints(i), a.rotateX(-Math.PI / 2), f.add(new e.Line(a, E));
|
|
1180
1180
|
}
|
|
1181
1181
|
f.visible = !1, i.add(c), i.add(f);
|
|
1182
|
-
let
|
|
1182
|
+
let k = [], A = [], j = new e.LineBasicMaterial({ color: "#f30606" }), M = new e.MeshBasicMaterial({ color: "#071ac4" });
|
|
1183
1183
|
for (let t = 0; t < _.length; t++) {
|
|
1184
1184
|
let n = new e.SphereGeometry(.05);
|
|
1185
1185
|
n.translate(_[t].x, _[t].y, _[t].z);
|
|
1186
1186
|
let r = [], i = new e.Vector3(_[t].x, _[t].y, _[t].z), a = new e.Quaternion(_[t].qx, _[t].qy, _[t].qz, _[t].qw), o = new e.Vector3(0, 0, -1).applyQuaternion(a), s = i.clone().addScaledVector(o, .001);
|
|
1187
1187
|
r.push(i), r.push(s);
|
|
1188
1188
|
let c = new e.BufferGeometry();
|
|
1189
|
-
c.setFromPoints(r),
|
|
1189
|
+
c.setFromPoints(r), A.push(c), k.push(n);
|
|
1190
|
+
}
|
|
1191
|
+
if (k.length > 0) {
|
|
1192
|
+
let t = w(k, !1);
|
|
1193
|
+
t.rotateX(-Math.PI / 2), l.add(new e.Mesh(t, M)), k.forEach((e) => e.dispose());
|
|
1190
1194
|
}
|
|
1191
1195
|
if (A.length > 0) {
|
|
1192
1196
|
let t = w(A, !1);
|
|
1193
|
-
t.rotateX(-Math.PI / 2), l.add(new e.
|
|
1194
|
-
}
|
|
1195
|
-
if (j.length > 0) {
|
|
1196
|
-
let t = w(j, !1);
|
|
1197
|
-
t.rotateX(-Math.PI / 2), l.add(new e.Line(t, M)), j.forEach((e) => e.dispose());
|
|
1197
|
+
t.rotateX(-Math.PI / 2), l.add(new e.Line(t, j)), A.forEach((e) => e.dispose());
|
|
1198
1198
|
}
|
|
1199
1199
|
i.add(l);
|
|
1200
|
-
let { AiProjectionGroup:
|
|
1201
|
-
return u.add(
|
|
1200
|
+
let { AiProjectionGroup: P, AiProjectionGroup2: F } = N(y);
|
|
1201
|
+
return u.add(P), u.rotateX(-Math.PI / 2), i.add(u), d.add(F), d.visible = !1, d.rotateX(-Math.PI / 2), i.add(d), console.log("jsonpcdData", y), o.forEach((t) => {
|
|
1202
1202
|
t.doorAndBeamData && t.doorAndBeamData.length > 0 && (t.doorAndBeamData.forEach((t) => {
|
|
1203
1203
|
if (t.beamStart) {
|
|
1204
1204
|
let n = new e.BufferGeometry(), r = new Float32Array([
|
|
@@ -1222,7 +1222,7 @@ var fe = class {
|
|
|
1222
1222
|
0,
|
|
1223
1223
|
2,
|
|
1224
1224
|
3
|
|
1225
|
-
]), n.computeVertexNormals(), n.rotateX(-Math.PI / 2)
|
|
1225
|
+
]), n.computeVertexNormals(), n.rotateX(-Math.PI / 2);
|
|
1226
1226
|
}
|
|
1227
1227
|
let n = new e.BufferGeometry(), r = new Float32Array([
|
|
1228
1228
|
t.doorStart.x,
|
|
@@ -1245,9 +1245,7 @@ var fe = class {
|
|
|
1245
1245
|
0,
|
|
1246
1246
|
2,
|
|
1247
1247
|
3
|
|
1248
|
-
]), n.computeVertexNormals(), n.rotateX(-Math.PI / 2), t.isDoor ? p.add(new e.Mesh(n,
|
|
1249
|
-
let i = `id:${t.id},Nid:${t.nearId}`, a = new e.Vector3((t.doorStart.x + t.doorEnd.x) / 2, (t.doorStart.y + t.doorEnd.y) / 2, t.doorStart.z + t.doorHeight);
|
|
1250
|
-
a.applyEuler(new e.Euler(-Math.PI / 2, 0, 0)), p.add(O(i, a));
|
|
1248
|
+
]), n.computeVertexNormals(), n.rotateX(-Math.PI / 2), t.isDoor ? p.add(new e.Mesh(n, T)) : t.type == "beam" ? p.add(new e.Mesh(n, C)) : p.add(new e.Mesh(n, S)), `${t.id}${t.nearId}`, new e.Vector3((t.doorStart.x + t.doorEnd.x) / 2, (t.doorStart.y + t.doorEnd.y) / 2, t.doorStart.z + t.doorHeight).applyEuler(new e.Euler(-Math.PI / 2, 0, 0));
|
|
1251
1249
|
}), i.add(p));
|
|
1252
1250
|
}), {
|
|
1253
1251
|
checkResultGroup: s,
|
|
@@ -1610,9 +1608,12 @@ var fe = class {
|
|
|
1610
1608
|
end: P
|
|
1611
1609
|
});
|
|
1612
1610
|
{
|
|
1613
|
-
let t = new e.Vector3().subVectors(N, P), n = new e.Vector3().subVectors(P, N), r = Infinity, i = Infinity, o = N.clone(), s = P.clone(), c = [];
|
|
1614
|
-
if (a.originalPoints.forEach((
|
|
1615
|
-
|
|
1611
|
+
let t = new e.Vector3().subVectors(N, P), n = new e.Vector3().subVectors(P, N), r = Infinity, i = Infinity, o = N.clone(), s = P.clone(), c = [], l = [], u = new e.Line3(j, M), d = new e.Vector3(), f = 999999;
|
|
1612
|
+
if (a.originalPoints.forEach((r) => {
|
|
1613
|
+
if (r.z - N.z < S / 2 + .1 && r.z - N.z > S / 2 - .1 && c.push(r), r.z > j.z) {
|
|
1614
|
+
let i = u.closestPointToPoint(r, !0, d), a = i.distanceTo(r), o = new e.Vector3().subVectors(i, j), s = A(t, new e.Vector3().subVectors(i, M)), c = A(n, o);
|
|
1615
|
+
s && s.parallel && !s.sameDirection && c && c.parallel && !c.sameDirection && a < .1 && a > .02 && (f > a && (f = a), l.push(r));
|
|
1616
|
+
}
|
|
1616
1617
|
}), c.length > 0) {
|
|
1617
1618
|
let { newProjectPoints: a } = ie(N, P, c);
|
|
1618
1619
|
for (let e of a) e.z = N.z;
|
|
@@ -1627,7 +1628,7 @@ var fe = class {
|
|
|
1627
1628
|
}
|
|
1628
1629
|
});
|
|
1629
1630
|
}
|
|
1630
|
-
o.equals(N) || (N = o, M = new e.Vector3(N.x, N.y, M.z)), s.equals(P) || (P = s, j = new e.Vector3(P.x, P.y, j.z));
|
|
1631
|
+
o.equals(N) || (N = o, M = new e.Vector3(N.x, N.y, M.z)), s.equals(P) || (P = s, j = new e.Vector3(P.x, P.y, j.z)), l.length > 10 && (j.z = M.z + f, S += f);
|
|
1631
1632
|
}
|
|
1632
1633
|
let s = P.distanceTo(N);
|
|
1633
1634
|
if (s < .4 && !E || s < .3 && E) continue;
|
|
@@ -1636,7 +1637,7 @@ var fe = class {
|
|
|
1636
1637
|
id: l,
|
|
1637
1638
|
beamStart: j,
|
|
1638
1639
|
beamEnd: M,
|
|
1639
|
-
beamHeight: a.rooftopPz -
|
|
1640
|
+
beamHeight: a.rooftopPz - j.z,
|
|
1640
1641
|
doorStart: N,
|
|
1641
1642
|
doorEnd: P,
|
|
1642
1643
|
doorHeight: S,
|
|
@@ -1667,7 +1668,7 @@ var fe = class {
|
|
|
1667
1668
|
}
|
|
1668
1669
|
}
|
|
1669
1670
|
}
|
|
1670
|
-
let
|
|
1671
|
+
let b = !1;
|
|
1671
1672
|
if (!g) {
|
|
1672
1673
|
let a = new e.Line3(N.clone(), P.clone());
|
|
1673
1674
|
for (let o = 0; o < t.length; o++) {
|
|
@@ -1696,27 +1697,27 @@ var fe = class {
|
|
|
1696
1697
|
}
|
|
1697
1698
|
}
|
|
1698
1699
|
if (n) break;
|
|
1699
|
-
} else s && s.type == "collinear_overlap" && s.maxPerpendicularDistance > .3 && s.maxPerpendicularDistance < .7 && (
|
|
1700
|
+
} else s && s.type == "collinear_overlap" && s.maxPerpendicularDistance > .3 && s.maxPerpendicularDistance < .7 && (b = !0);
|
|
1700
1701
|
}
|
|
1701
1702
|
if (n) continue;
|
|
1702
1703
|
}
|
|
1703
|
-
let
|
|
1704
|
+
let C = !1;
|
|
1704
1705
|
if (y != -1) for (let e = 0; e < p.length && !(p[e].length == 1 && (p[e][0].id == l ? (p[e].push({
|
|
1705
1706
|
id: y,
|
|
1706
1707
|
beamStart: _,
|
|
1707
1708
|
beamEnd: v
|
|
1708
|
-
}),
|
|
1709
|
+
}), C = !0) : p[e][0].id == y && (p[e].push({
|
|
1709
1710
|
id: l,
|
|
1710
1711
|
beamStart: j,
|
|
1711
1712
|
beamEnd: M
|
|
1712
|
-
}),
|
|
1713
|
-
|
|
1713
|
+
}), C = !0), C)); e++);
|
|
1714
|
+
C || p.push([{
|
|
1714
1715
|
id: l,
|
|
1715
1716
|
beamStart: j,
|
|
1716
1717
|
beamEnd: M
|
|
1717
1718
|
}]);
|
|
1718
|
-
let
|
|
1719
|
-
if (m = E ? "door" :
|
|
1719
|
+
let w = h.doorStart.distanceTo(h.doorEnd);
|
|
1720
|
+
if (m = E ? "door" : w > 1.8 || b && w > 1 ? "beam" : "hole", h.type = m, h.nearId != -1 && m == "hole") {
|
|
1720
1721
|
let e = !1;
|
|
1721
1722
|
for (let n = 0; n < t.length; n++) if (t[n].doorAndBeamData) {
|
|
1722
1723
|
for (let r = 0; r < t[n].doorAndBeamData.length; r++) if (t[n].doorAndBeamData[r].nearId == l && t[n].doorAndBeamData[r].type == "beam") {
|
|
@@ -3876,7 +3877,9 @@ var Pn = (t) => {
|
|
|
3876
3877
|
for (let r = 0; r < t.length; r++) {
|
|
3877
3878
|
let i = t[r].points.map((e) => [e.x, e.y]), a = Mn(t[r].points), o = t[r].obj_id;
|
|
3878
3879
|
o = o.replace(/calcony railing/g, "balcony railing").replace(/glass balcony railing/g, "balcony railing").replace(/metal balcony railing/g, "balcony railing").replace(/temporary construction guardrail/g, "balcony railing"), o.split("_").slice(1, 3).join("_").split(".")[0].split("_")[0];
|
|
3879
|
-
let s = o.indexOf("_") + 1, c = o.lastIndexOf("_"), l = o.substring(s, c)
|
|
3880
|
+
let s = o.indexOf("_") + 1, c = o.lastIndexOf("_"), l = o.substring(s, c);
|
|
3881
|
+
if (l === "wall" || l === "floor" || l === "roof") continue;
|
|
3882
|
+
let u = [];
|
|
3880
3883
|
for (let n = 0; n < t[r].points.length; n++) u.push(new e.Vector3(t[r].points[n].x, t[r].points[n].y, t[r].points[n].z));
|
|
3881
3884
|
let d = {
|
|
3882
3885
|
points: u,
|