markuno_lib 1.2.82 → 1.2.84

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/bin/markcad.js CHANGED
@@ -1,1121 +1 @@
1
- import*as THREE from"three";import{TrianglesDrawMode,TriangleFanDrawMode,TriangleStripDrawMode,Loader,LoaderUtils,FileLoader,MeshPhysicalMaterial,Vector2,Color,LinearSRGBColorSpace,SRGBColorSpace,SpotLight,PointLight,DirectionalLight,Matrix4,Vector3,Quaternion,InstancedMesh,InstancedBufferAttribute,Object3D,TextureLoader,ImageBitmapLoader,BufferAttribute,InterleavedBuffer,InterleavedBufferAttribute,LinearMipmapLinearFilter,NearestMipmapLinearFilter,LinearMipmapNearestFilter,NearestMipmapNearestFilter,LinearFilter,NearestFilter,RepeatWrapping,MirroredRepeatWrapping,ClampToEdgeWrapping,PointsMaterial,Material,LineBasicMaterial,MeshStandardMaterial,DoubleSide,MeshBasicMaterial,PropertyBinding,BufferGeometry,SkinnedMesh,Mesh,LineSegments,Line,LineLoop,Points,Group,PerspectiveCamera,MathUtils,OrthographicCamera,Skeleton,AnimationClip,Bone,InterpolateDiscrete,InterpolateLinear,Texture,VectorKeyframeTrack,NumberKeyframeTrack,QuaternionKeyframeTrack,ColorManagement,FrontSide,Interpolant,Box3,Sphere,CompressedCubeTexture,UnsignedByteType,CompressedArrayTexture,CompressedTexture,DisplayP3ColorSpace,LinearDisplayP3ColorSpace,NoColorSpace,RGBA_ASTC_6x6_Format,RedFormat,RGFormat,RGBAFormat,HalfFloatType,FloatType,DataTexture,Data3DTexture,RGBA_S3TC_DXT1_Format,RGB_PVRTC_4BPPV1_Format,RGB_ETC2_Format,RGB_ETC1_Format,RGBA_S3TC_DXT5_Format,RGBA_PVRTC_4BPPV1_Format,RGBA_ETC2_EAC_Format,RGBA_BPTC_Format,RGBA_ASTC_4x4_Format,MeshPhongMaterial,AdditiveBlending,Float32BufferAttribute}from"three";class Matrix3D{constructor(){this.m=new Float32Array(16),this.st=[],this.init()}init(){return this.m.fill(0),this.m[0]=this.m[5]=this.m[10]=this.m[15]=1,this}atranslate(x,y,z){return this.m[12]+=x,this.m[13]+=y,this.m[14]+=z,this}translate(x,y,z){return x??=0,y??=0,z??=0,this.m[12]+=x*this.m[0]+y*this.m[4]+z*this.m[8],this.m[13]+=x*this.m[1]+y*this.m[5]+z*this.m[9],this.m[14]+=x*this.m[2]+y*this.m[6]+z*this.m[10],this.m[15]+=x*this.m[3]+y*this.m[7]+z*this.m[11],this}rotateX(angolo){if(angolo){const rad=(angolo||0)*Math.PI/180,s=Math.sin(rad),c=Math.cos(rad),a=[...this.m];this.m[1]=a[1]*c+a[9]*s,this.m[2]=a[2]*c+a[10]*s,this.m[3]=a[3]*c+a[11]*s,this.m[9]=a[1]*-s+a[9]*c,this.m[10]=a[2]*-s+a[10]*c,this.m[11]=a[3]*-s+a[11]*c}return this}rotateY(angolo){if(angolo){const rad=(angolo||0)*Math.PI/180,s=Math.sin(rad),c=Math.cos(rad),a=[...this.m];this.m[0]=a[0]*c+a[8]*s,this.m[1]=a[1]*c+a[9]*s,this.m[2]=a[2]*c+a[10]*s,this.m[3]=a[3]*c+a[11]*s,this.m[8]=a[0]*-s+a[8]*c,this.m[9]=a[1]*-s+a[9]*c,this.m[10]=a[2]*-s+a[10]*c,this.m[11]=a[3]*-s+a[11]*c}return this}rotateZ(angolo){if(angolo){const rad=(angolo||0)*Math.PI/180,s=Math.sin(rad),c=Math.cos(rad),a=[...this.m];this.m[0]=a[0]*c+a[4]*s,this.m[1]=a[1]*c+a[5]*s,this.m[2]=a[2]*c+a[6]*s,this.m[3]=a[3]*c+a[7]*s,this.m[4]=a[0]*-s+a[4]*c,this.m[5]=a[1]*-s+a[5]*c,this.m[6]=a[2]*-s+a[6]*c,this.m[7]=a[3]*-s+a[7]*c}return this}getdati(){return Array.from(this.m)}setdati(d){if(d&&16===d.length){for(let i=0;i<16;i++)this.m[i]=Number(d[i])||0;return this}this.init()}push(){return this.st.push(new Float32Array(this.m)),this}pop(){return this.st.length>0&&(this.m=this.st.pop()),this}transform(x,y,z=0){return{x:x*this.m[0]+y*this.m[4]+z*this.m[8]+this.m[12],y:x*this.m[1]+y*this.m[5]+z*this.m[9]+this.m[13],z:x*this.m[2]+y*this.m[6]+z*this.m[10]+this.m[14]}}invert(){const m=this.m,inv=new Matrix3D,det=this.determinant();return Math.abs(det)<1e-8?null:(inv.m[0]=(m[5]*m[10]*m[15]+m[9]*m[14]*m[7]+m[13]*m[6]*m[11]-m[5]*m[14]*m[11]-m[9]*m[6]*m[15]-m[13]*m[10]*m[7])/det,inv.m[1]=(m[1]*m[14]*m[11]+m[9]*m[2]*m[15]+m[13]*m[10]*m[3]-m[1]*m[10]*m[15]-m[9]*m[14]*m[3]-m[13]*m[2]*m[11])/det,inv.m[2]=(m[1]*m[6]*m[15]+m[5]*m[14]*m[3]+m[13]*m[2]*m[7]-m[1]*m[14]*m[7]-m[5]*m[2]*m[15]-m[13]*m[6]*m[3])/det,inv.m[3]=(m[1]*m[10]*m[7]+m[5]*m[2]*m[11]+m[9]*m[6]*m[3]-m[1]*m[6]*m[11]-m[5]*m[10]*m[3]-m[9]*m[2]*m[7])/det,inv.m[4]=(m[4]*m[14]*m[11]+m[8]*m[6]*m[15]+m[12]*m[10]*m[7]-m[4]*m[10]*m[15]-m[8]*m[14]*m[7]-m[12]*m[6]*m[11])/det,inv.m[5]=(m[0]*m[10]*m[15]+m[8]*m[14]*m[3]+m[12]*m[2]*m[11]-m[0]*m[14]*m[11]-m[8]*m[2]*m[15]-m[12]*m[10]*m[3])/det,inv.m[6]=(m[0]*m[14]*m[7]+m[4]*m[2]*m[15]+m[12]*m[6]*m[3]-m[0]*m[6]*m[15]-m[4]*m[14]*m[3]-m[12]*m[2]*m[7])/det,inv.m[7]=(m[0]*m[6]*m[11]+m[4]*m[10]*m[3]+m[8]*m[2]*m[7]-m[0]*m[10]*m[7]-m[4]*m[2]*m[11]-m[8]*m[6]*m[3])/det,inv.m[8]=(m[4]*m[9]*m[15]+m[8]*m[13]*m[7]+m[12]*m[5]*m[11]-m[4]*m[13]*m[11]-m[8]*m[5]*m[15]-m[12]*m[9]*m[7])/det,inv.m[9]=(m[0]*m[13]*m[11]+m[8]*m[1]*m[15]+m[12]*m[9]*m[3]-m[0]*m[9]*m[15]-m[8]*m[13]*m[3]-m[12]*m[1]*m[11])/det,inv.m[10]=(m[0]*m[5]*m[15]+m[4]*m[13]*m[3]+m[12]*m[1]*m[7]-m[0]*m[13]*m[7]-m[4]*m[1]*m[15]-m[12]*m[5]*m[3])/det,inv.m[11]=(m[0]*m[9]*m[7]+m[4]*m[1]*m[11]+m[8]*m[5]*m[3]-m[0]*m[5]*m[11]-m[4]*m[9]*m[3]-m[8]*m[1]*m[7])/det,inv.m[12]=(m[4]*m[13]*m[10]+m[8]*m[5]*m[14]+m[12]*m[9]*m[6]-m[4]*m[9]*m[14]-m[8]*m[13]*m[6]-m[12]*m[5]*m[10])/det,inv.m[13]=(m[0]*m[9]*m[14]+m[8]*m[13]*m[2]+m[12]*m[1]*m[10]-m[0]*m[13]*m[10]-m[8]*m[1]*m[14]-m[12]*m[9]*m[2])/det,inv.m[14]=(m[0]*m[13]*m[6]+m[4]*m[1]*m[14]+m[12]*m[5]*m[2]-m[0]*m[5]*m[14]-m[4]*m[13]*m[2]-m[12]*m[1]*m[6])/det,inv.m[15]=(m[0]*m[5]*m[10]+m[4]*m[9]*m[2]+m[8]*m[1]*m[6]-m[0]*m[9]*m[6]-m[4]*m[1]*m[10]-m[8]*m[5]*m[2])/det,inv)}determinant(){const m=this.m;return m[0]*(m[5]*m[10]*m[15]+m[9]*m[14]*m[7]+m[13]*m[6]*m[11]-m[5]*m[14]*m[11]-m[9]*m[6]*m[15]-m[13]*m[10]*m[7])-m[4]*(m[1]*m[10]*m[15]+m[9]*m[14]*m[3]+m[13]*m[2]*m[11]-m[1]*m[14]*m[11]-m[9]*m[2]*m[15]-m[13]*m[10]*m[3])+m[8]*(m[1]*m[6]*m[15]+m[5]*m[14]*m[3]+m[13]*m[2]*m[7]-m[1]*m[14]*m[7]-m[5]*m[2]*m[15]-m[13]*m[6]*m[3])-m[12]*(m[1]*m[6]*m[11]+m[5]*m[10]*m[3]+m[9]*m[2]*m[7]-m[1]*m[10]*m[7]-m[5]*m[2]*m[11]-m[9]*m[6]*m[3])}multiply(matrix){const a=[...this.m],b=matrix.m;return this.m[0]=a[0]*b[0]+a[4]*b[1]+a[8]*b[2]+a[12]*b[3],this.m[1]=a[1]*b[0]+a[5]*b[1]+a[9]*b[2]+a[13]*b[3],this.m[2]=a[2]*b[0]+a[6]*b[1]+a[10]*b[2]+a[14]*b[3],this.m[3]=a[3]*b[0]+a[7]*b[1]+a[11]*b[2]+a[15]*b[3],this.m[4]=a[0]*b[4]+a[4]*b[5]+a[8]*b[6]+a[12]*b[7],this.m[5]=a[1]*b[4]+a[5]*b[5]+a[9]*b[6]+a[13]*b[7],this.m[6]=a[2]*b[4]+a[6]*b[5]+a[10]*b[6]+a[14]*b[7],this.m[7]=a[3]*b[4]+a[7]*b[5]+a[11]*b[6]+a[15]*b[7],this.m[8]=a[0]*b[8]+a[4]*b[9]+a[8]*b[10]+a[12]*b[11],this.m[9]=a[1]*b[8]+a[5]*b[9]+a[9]*b[10]+a[13]*b[11],this.m[10]=a[2]*b[8]+a[6]*b[9]+a[10]*b[10]+a[14]*b[11],this.m[11]=a[3]*b[8]+a[7]*b[9]+a[11]*b[10]+a[15]*b[11],this.m[12]=a[0]*b[12]+a[4]*b[13]+a[8]*b[14]+a[12]*b[15],this.m[13]=a[1]*b[12]+a[5]*b[13]+a[9]*b[14]+a[13]*b[15],this.m[14]=a[2]*b[12]+a[6]*b[13]+a[10]*b[14]+a[14]*b[15],this.m[15]=a[3]*b[12]+a[7]*b[13]+a[11]*b[14]+a[15]*b[15],this}}
2
- /** Tolleranza utilizzata per i confronti numerici */
3
- /**
4
- * Classe che rappresenta un punto 2D con coordinate x,y
5
- * @class
6
- */
7
- class Punto2{
8
- /**
9
- * Crea un nuovo punto 2D
10
- * @param {number|Array|Object} x - Coordinata x, array [x,y] o oggetto {x,y}
11
- * @param {number} [y] - Coordinata y se x è un numero
12
- */
13
- constructor(x,y){Array.isArray(x)?(this.x=x[0]||0,this.y=x[1]||0):x&&"object"==typeof x?(this.x=x.x||0,this.y=x.y||0):(this.x=x||0,this.y=y||0)}
14
- /**
15
- * Restituisce una rappresentazione testuale del punto
16
- * @returns {string} Stringa nel formato {x,y}
17
- */get dump(){return`{${this.x.toFixed(1)},${this.y.toFixed(1)}}`}
18
- /**
19
- * Calcola il quadrato della lunghezza del vettore dal punto all'origine
20
- * @returns {number} Lunghezza al quadrato
21
- */get len2(){return this.x*this.x+this.y*this.y}
22
- /**
23
- * Calcola la lunghezza del vettore dal punto all'origine
24
- * @returns {number} Lunghezza del vettore
25
- */get len(){return Math.sqrt(this.len2)}
26
- /**
27
- * Calcola l'angolo del vettore rispetto all'asse x
28
- * @returns {number} Angolo in radianti
29
- */get angle(){return Math.atan2(this.y,this.x)}
30
- /**
31
- * Restituisce il vettore normalizzato (lunghezza unitaria)
32
- * @returns {Punto2} Nuovo punto con le coordinate normalizzate
33
- */dir(){let l=this.len;return l?new Punto2(this.x/l,this.y/l):this}distanza(p1){return new Punto2(p1.x-this.x,p1.y-this.y).len}}
34
- /**
35
- * Classe che rappresenta una linea 2D definita da due punti
36
- */class Linea2{
37
- /**
38
- * Crea una nuova linea 2D
39
- * @param {number|Object} p1 - Coordinata x del primo punto o oggetto {x,y}
40
- * @param {number|Object} p2 - Coordinata y del primo punto o oggetto {x,y}
41
- * @param {number} [x2=null] - Coordinata x del secondo punto (opzionale)
42
- * @param {number} [y2=null] - Coordinata y del secondo punto (opzionale)
43
- */
44
- constructor(p1,p2,x2=null,y2=null){"number"==typeof p1&&"number"==typeof p2&&null!==x2&&null!==y2?(this.p1=new Punto2({x:p1,y:p2}),this.p2=new Punto2({x:x2,y:y2})):p1&&p2?(this.p1=new Punto2(p1),this.p2=new Punto2(p2)):(this.p1=new Punto2(0,0),this.p2=new Punto2(1,0))}
45
- /**
46
- * Restituisce una rappresentazione testuale della linea
47
- * @returns {string} Stringa nel formato "p1-p2"
48
- */get dump(){return`${this.p1.dump}-${this.p2.dump}`}
49
- /**
50
- * Calcola la differenza delle coordinate x dei punti
51
- * @returns {number} Differenza x
52
- */get dx(){return this.p2.x-this.p1.x}
53
- /**
54
- * Calcola la differenza delle coordinate y dei punti
55
- * @returns {number} Differenza y
56
- */get dy(){return this.p2.y-this.p1.y}
57
- /**
58
- * Calcola il quadrato della lunghezza della linea
59
- * @returns {number} Lunghezza al quadrato
60
- */get len2(){let{dx:dx,dy:dy}=this;return dx*dx+dy*dy}
61
- /**
62
- * Calcola la lunghezza della linea
63
- * @returns {number} Lunghezza
64
- */get len(){return Math.sqrt(this.len2)}get angle(){return this.angolo()}
65
- /**
66
- * Estende la linea di una certa lunghezza o fino all'intersezione con un'altra linea
67
- * @param {number|Linea2} l - Lunghezza di estensione o linea da intersecare
68
- * @returns {Linea2} Nuova linea estesa
69
- */estendi(l){if("number"==typeof l){if(!l)return this;let{p1:p1,p2:p2,dx:dx,dy:dy,len:len}=this;return len?(dx/=len,dy/=len,l>0?new Linea2(p1,new Punto2(p2.x+dx*l,p2.y+dy*l)):new Linea2(new Punto2(p1.x+dx*l,p1.y+dy*l),p2)):this}if(l instanceof Linea2){const intersectionPoint=this.interseca(l);if(!intersectionPoint)return this;return(intersectionPoint.x-this.p1.x)**2+(intersectionPoint.y-this.p1.y)**2<(intersectionPoint.x-this.p2.x)**2+(intersectionPoint.y-this.p2.y)**2?new Linea2(intersectionPoint,this.p2):new Linea2(this.p1,intersectionPoint)}}puntot(t){return new Punto2(this.p1.x+(this.p2.x-this.p1.x)*t,this.p1.y+(this.p2.y-this.p1.y)*t)}setlunghezza(l){let tm=this.len;if(tm&&l){let t=l/tm,p2=this.puntot(t);this.p2=p2}}proiezionet(p){const{p1:p1,dx:dx,dy:dy,len2:len2}=this;if(len2<.001)return;const t=((p.x-p1.x)*dx+(p.y-p1.y)*dy)/len2;return{p:new Punto2(p1.x+t*dx,p1.y+t*dy),t:t}}proiezione(p){const r=this.proiezionet(p);return r?r.p:void 0}
70
- /**
71
- * Calcola il vettore direzione normalizzato della linea
72
- * @returns {Punto2} Vettore direzione
73
- */get direzione(){let{dx:dx,dy:dy,len:len}=this;return len?new Punto2(dx/len,dy/len):new Punto2(0,0)}
74
- /**
75
- * Calcola il vettore normale normalizzato della linea
76
- * @returns {Punto2} Vettore normale
77
- */get normale(){let{dx:dx,dy:dy,len:len}=this;return len?new Punto2(-dy/len,dx/len):new Punto2(0,1)}perpendicolare(p=null,lunghezza=0){const{normale:normale,len:len,p1:p1}=this;if(len<1e-9)return;const l=lunghezza||len,q=p?new Punto2(p):this.p1;return new Linea2(q,new Punto2(q.x+normale.x*l,q.y+normale.y*l))}perpendicolaret(t,lunghezza=0){const{normale:normale,len:len,p1:p1,p2:p2}=this;if(len<1e-9)return;const l=lunghezza||len,q=new Punto2(p1.x+(p2.x-p1.x)*t,p1.y+(p2.y-p1.y)*t);return new Linea2(q,new Punto2(q.x+normale.x*l,q.y+normale.y*l))}
78
- /**
79
- * Crea una nuova linea ruotata di un certo angolo
80
- * @param {number} [angle=Math.PI/2] - Angolo di rotazione in radianti
81
- * @param {number} [length=0] - Lunghezza della nuova linea
82
- * @param {boolean/Punto2} [fine=false] - Se fine è un punto allora crea un segmento che passa per quel punto
83
- * Se true ruota attorno al primo punto, altrimenti al secondo
84
- * @returns {Linea2} Nuova linea ruotata
85
- */ruotata(angle=Math.PI/2,length=0,fine=!1){const{p1:p1,p2:p2,direzione:direzione,len:len}=this;if(length=length||len,len<1e-9)return;const a=Math.abs(angle%(2*Math.PI));if(!(a<1e-9||Math.abs(a-Math.PI)<1e-9)){if("boolean"==typeof fine){const sx=(direzione.x*Math.cos(angle)-direzione.y*Math.sin(angle))*length,sy=(direzione.x*Math.sin(angle)+direzione.y*Math.cos(angle))*length;return fine?new Linea2(p1,new Punto2(p1.x+sx,p1.y+sy)):new Linea2(p2,new Punto2(p2.x+sx,p2.y+sy))}{let p3=new Punto2(fine);const dx=direzione.x*Math.cos(angle)-direzione.y*Math.sin(angle),dy=direzione.x*Math.sin(angle)+direzione.y*Math.cos(angle);new Punto2(dx,dy);const rettaRuotata=new Linea2(p3,new Punto2(p3.x+dx,p3.y+dy)),puntoIntersezione=this.interseca(rettaRuotata);if(!puntoIntersezione)return;const pFine=new Punto2(puntoIntersezione.x+dx*length,puntoIntersezione.y+dy*length);return new Linea2(puntoIntersezione,pFine)}}}
86
- /**
87
- * Calcola un punto sulla direzione della linea a una certa distanza
88
- * @param {Punto2} p1 - Punto di partenza
89
- * @param {number} lunghezza - Distanza dal punto di partenza
90
- * @returns {Punto2} Nuovo punto
91
- */puntosudirezione(p1,lunghezza){let{direzione:direzione}=this;return new Punto2(p1.x+direzione.x*lunghezza,p1.y+direzione.y*lunghezza)}
92
- /**
93
- * Crea una nuova linea parallela a questa passante per un punto
94
- * @param {Punto2} p1 - Punto di passaggio
95
- * @param {number} lunghezza - Lunghezza della nuova linea
96
- * @returns {Linea2} Nuova linea parallela
97
- */parallela(p1,lunghezza){let{direzione:direzione}=this;return new Linea2(p1,this.puntosudirezione(p1,lunghezza))}
98
- /**
99
- * Calcola il punto di intersezione con un'altra linea
100
- * @param {Linea2} line2 - Seconda linea
101
- * @returns {Punto2|null} Punto di intersezione o null se parallele
102
- */intersezione(line2){return this.interseca(line2)}interseca(line2){const{p1:p1_1,p2:p2_1}=this,{p1:p1_2,p2:p2_2}=line2,det=(p2_1.x-p1_1.x)*(p2_2.y-p1_2.y)-(p2_1.y-p1_1.y)*(p2_2.x-p1_2.x);if(Math.abs(det)<.001)return null;const t=((p1_2.x-p1_1.x)*(p2_2.y-p1_2.y)-(p1_2.y-p1_1.y)*(p2_2.x-p1_2.x))/det;return new Punto2(p1_1.x+t*(p2_1.x-p1_1.x),p1_1.y+t*(p2_1.y-p1_1.y))}onsegment(p,eps=1e-9){const{p1:p1,p2:p2}=this,minX=Math.min(p1.x,p2.x)-eps,maxX=Math.max(p1.x,p2.x)+eps,minY=Math.min(p1.y,p2.y)-eps,maxY=Math.max(p1.y,p2.y)+eps;return p.x>=minX&&p.x<=maxX&&p.y>=minY&&p.y<=maxY}distanzaPunto(p){const q=this.proiezione(p);if(!q)return 1e9;const dx=p.x-q.x,dy=p.y-q.y;return Math.hypot(dx,dy)}
103
- /**
104
- * Verifica se la linea è parallela a un'altra
105
- * @param {Linea2} line2 - Seconda linea
106
- * @returns {boolean} True se parallele
107
- */isparallela(line2){const det=this.dx*line2.dy-this.dy*line2.dx;return Math.abs(det)<1}
108
- /**
109
- * Restituisce alcune info sul “quadrilatero” formato da questa linea e da line2,
110
- * assumendo che siano parallele e abbiano verso invertito.
111
- * @param {Linea2} line2
112
- * @returns {Object|undefined}
113
- * { angle, aini, afin, l, distanza } oppure undefined se non parallele o degenere
114
- */lunghezzatotale(l2){const dx=this.p2.x-this.p1.x,dy=this.p2.y-this.p1.y,n=Math.hypot(dx,dy);if(!n)return 0;const inv=1/n,proj=p=>(p.x*dx+p.y*dy)*inv,s1=proj(this.p1),s2=proj(this.p2),t1=proj(l2.p1),t2=proj(l2.p2),smin=s1<s2?s1:s2,smax=s1>s2?s1:s2,tmin=t1<t2?t1:t2,tmax=t1>t2?t1:t2;return Math.round(100*(Math.max(smax,tmax)-Math.min(smin,tmin)))/100}infoquad(line2){if(!this.isparallela(line2))return;const{p1:p1,p2:p2,normale:normale}=this;let{p1:p3,p2:p4}=line2;const distance2=(a,b)=>(a.x-b.x)**2+(a.y-b.y)**2;function wrapToPi(theta){return theta>Math.PI?theta-=2*Math.PI:theta<-Math.PI&&(theta+=2*Math.PI),theta}function getangle(a,b){return Math.atan2(b.y-a.y,b.x-a.x)}distance2(p1,p3)>distance2(p1,p4)&&([p3,p4]=[p4,p3]);const baseAng=getangle(p1,p2);function toDeg(x){return Math.round(18e4*x/Math.PI)/1e3}const aini=toDeg(wrapToPi(getangle(p1,p3)-baseAng)),afin=toDeg(wrapToPi(getangle(p2,p4)-baseAng)),l=Math.round(100*this.len)/100,dx=p3.x-p1.x,dy=p3.y-p1.y,distanza=Math.round(100*Math.abs(dx*normale.x+dy*normale.y))/100;let ltot=this.lunghezzatotale(line2);return{angle:toDeg(baseAng),aini:aini,afin:afin,l:l,ltot:ltot,distanza:distanza,sx:Math.round(100*p1.x)/100,sy:Math.round(100*p1.y)/100}}
115
- /**
116
- * Verifica se la linea è perpendicolare a un'altra
117
- * @param {Linea2} line2 - Seconda linea
118
- * @returns {boolean} True se perpendicolari
119
- */isperpendicolare(line2){const dotProduct=this.dx*line2.dx+this.dy*line2.dy;return Math.abs(dotProduct)<.001}
120
- /**
121
- * Crea una nuova linea parallela a questa a una certa distanza
122
- * @param {number} delta - Distanza di offset (positiva a sinistra, negativa a destra)
123
- * @returns {Linea2} Nuova linea parallela
124
- */offset(delta){const normale=this.normale,p1_offset=new Punto2(this.p1.x+normale.x*delta,this.p1.y+normale.y*delta),p2_offset=new Punto2(this.p2.x+normale.x*delta,this.p2.y+normale.y*delta);return new Linea2(p1_offset,p2_offset)}
125
- /**
126
- * Calcola l'angolo tra questa linea e un'altra o l'angolo assoluto d
127
- * @param {Linea2} line2 - Seconda linea
128
- * @returns {number} Angolo in radianti
129
- */angolo(line2){const{dx:dx1,dy:dy1}=this;let delta;if(line2){const{dx:dx2,dy:dy2}=line2,a1=Math.atan2(dy1,dx1);delta=Math.atan2(dy2,dx2)-a1}else delta=Math.atan2(dy1,dx1);return delta>Math.PI?delta-=2*Math.PI:delta<-Math.PI&&(delta+=2*Math.PI),delta}ortopt(l){let{p1:p1,dx:dx,dy:dy}=this;const len=Math.hypot(dx,dy);if(len<.001)return;const ux=-dy/len,uy=dx/len;return{x:p1.x+ux*l,y:p1.y+uy*l}}offsetline(l){let{p1:p1,p2:p2,dx:dx,dy:dy}=this;const len=Math.hypot(dx,dy);if(len<.001)return;const ux=-dy/len,uy=dx/len;return new Linea2({x:p1.x+ux*l,y:p1.y+uy*l},{x:p2.x+ux*l,y:p2.y+uy*l})}
130
- /**
131
- * Calcola la distanza tra due segmenti paralleli
132
- * @param {Linea2} line2 - Seconda linea
133
- * @returns {number} Distanza tra i segmenti o 1e9 se non paralleli
134
- */distanzaSegmentiParalleli(line2){if(!this.isparallela(line2))return 1e9;const{p1:p1,normale:normale}=this,dx=line2.p1.x-p1.x,dy=line2.p1.y-p1.y,distanza=Math.abs(dx*normale.x+dy*normale.y);return Math.abs(distanza)<.001?0:distanza}
135
- /**
136
- * Verifica se due linee sono collineari
137
- * @param {Linea2} line2 - Seconda linea
138
- * @param {boolean} [checkpunticomune=false] - Se true verifica anche la sovrapposizione
139
- * @returns {boolean} True se collineari
140
- */isCollineare(line2,checkpunticomune=!1){if(!this.isparallela(line2))return!1;const distanza=this.distanzaSegmentiParalleli(line2);if(Math.abs(distanza)>.001)return!1;if(checkpunticomune){function isPointBetween(p,a,b,toll=.001){const cross=(b.x-a.x)*(p.y-a.y)-(b.y-a.y)*(p.x-a.x);return!(Math.abs(cross)>toll)&&(Math.min(a.x,b.x)-toll<=p.x&&p.x<=Math.max(a.x,b.x)+toll&&Math.min(a.y,b.y)-toll<=p.y&&p.y<=Math.max(a.y,b.y)+toll)}const{p1:p1,p2:p2}=this,{p1:p1_2,p2:p2_2}=line2;return isPointBetween(p1_2,p1,p2)||isPointBetween(p2_2,p1,p2)||isPointBetween(p1,p1_2,p2_2)||isPointBetween(p2,p1_2,p2_2)}return!0}clone(){return new Linea2(this.p1.x,this.p1.y,this.p2.x,this.p2.y)}rotate(deg){if(!deg)return this;const r=deg*Math.PI/180,cosTheta=Math.cos(r),sinTheta=Math.sin(r);function rotate(p){return new Punto2(p.x*cosTheta-p.y*sinTheta,p.x*sinTheta+p.y*cosTheta)}return this.p1=rotate(this.p1),this.p2=rotate(this.p2),this}move(x=0,y=0){return"object"==typeof x&&x.x&&(y=x.y||0,x=x.x),this.p1.x+=x,this.p1.y+=y,this.p2.x+=x,this.p2.y+=y,this}}
141
- /**
142
- * Calcola i punti di offset tra due percorsi
143
- * Trova i punti del secondo percorso che corrispondono all'offset del primo
144
- * @param {Array<{x:number,y:number}>} pt - Array di punti del primo percorso
145
- * @param {Array<{x:number,y:number}>} pt2 - Array di punti del secondo percorso
146
- * @param {number} delta - Distanza di offset
147
- * @returns {Array<{x:number,y:number}>} Array di punti del percorso offset
148
- */function getptsoffset(pt,pt2,delta){let k1,k2,a1,a2,i1=-1,i2=-1,n=pt.length,np=pt2.length,offpt=[],l1a=new Linea2(pt[0],pt[1]),l2a=new Linea2(pt[n-2],pt[n-1]),l1=l1a.offset(delta),l2=l2a.offset(delta);for(let i=0;i<np;i++){let l=new Linea2(pt2[i%np],pt2[(i+1)%np]);l1.isparallela(l)&&l1.isCollineare(l,!0)&&(i1=i),l2.isparallela(l)&&l2.isCollineare(l,!0)&&(i2=i)}if(i1>=0&&i2>=0){i1>i2?(k1=i1-i2+2,k2=i2+np-i1+2,k1<k2?(a1=i2,a2=i1+1):(a1=i1,a2=i2+np+1)):(k1=i2-i1+2,k2=i1+np-i2+2,k1<k2?(a1=i1,a2=i2+1):(a1=i2,a2=i1+np+1));for(let i=a1;i<=a2;i++)offpt.push(pt2[i%np])}return offpt}async function errorescript(code,error){let line,col,tm,match=(error.stack||"").match(/user-script\.js:(\d+):(\d+)/);if(match||(match=(error.toString()||"").match(/user-script\.js:(\d+):(\d+)/)),match&&([,line,col]=match.map(Number),line-=2),(!line||!col)&&error instanceof SyntaxError){window.acorn||(await new Promise(((resolve,reject)=>{const s=document.createElement("script");s.src="https://cdn.jsdelivr.net/npm/acorn@8.15.0/dist/acorn.js",s.onload=resolve,s.onerror=reject,document.head.appendChild(s)})),console.log("caricato acorn"));try{window.acorn.parse(code,{ecmaVersion:"latest"})}catch(parseErr){parseErr.loc&&(line=parseErr.loc.line,col=parseErr.loc.column+1)}}return tm=line&&col?`ERRORE: ${error.message}\n`+function extractContext(code,line,col,context=1){const lines=code.split(/\r?\n/),idx=line-1,start=Math.max(0,idx-context),end=Math.min(lines.length,idx+context+1);return lines.slice(start,end).map(((txt,i)=>start+i+1===line?txt+"\n"+" ".repeat(col-1)+"^":txt)).join("\n")}(code,line,col):error.message,tm}const PIF=Math.PI/180;function clean(k,locase=!1){return locase?(k||"").trim().toLowerCase():(k||"").trim()}
149
- /**
150
- * Rimuove i commenti dal codice sorgente mantenendo la struttura del codice
151
- * @param {string} codice - Il codice sorgente da processare
152
- * @param {boolean} tienivuoti - Se true mantiene le righe vuote
153
- * @returns {string[]} Array di righe di codice senza commenti
154
- */function seedarray(arr,seed){if(arr&&arr.length){let cl=[];for(let i=0;i<arr.length;i++){let a=arr[i];if(a.p)for(let j=0;j<a.p;j++)cl.push(i);else cl.push(i)}return arr[cl[seeder(cl.length,seed)]]}}function seeder(n,seed="seed42"){const rand=function mulberry32(a){return function(){a=(a|=0)+1831565813|0;let t=Math.imul(a^a>>>15,1|a);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}(function xmur3(str){let h=1779033703^str.length;for(let i=0;i<str.length;i++)h=Math.imul(h^str.charCodeAt(i),3432918353),h=h<<13|h>>>19;return function(){return h=Math.imul(h^h>>>16,2246822507),h=Math.imul(h^h>>>13,3266489909),(h^=h>>>16)>>>0}}(String(seed))());return Math.floor(rand()*n)}function getcolonne(value,keepquote=!1){value=String(value||"");const pp=/^(\d+)\.\.(\d+)$/.exec(value);if(pp){let n1=parseInt(pp[1]),n2=parseInt(pp[2]),cl=[];n1>n2&&([n1,n2]=[n2,n1]);for(let i=n1;i<=n2;i++)cl.push(i+"");return cl}if(!/["({[]/.test(value))return value.split(/[,;]/).map((e=>e.trim()));const risultato=[];let buffer="",livelloParentesi=0,inVirgolette=!1;for(let i=0;i<value.length;i++){const char=value[i];if(0===livelloParentesi&&'"'===char&&(0!==i&&"\\"===value[i-1]||(inVirgolette=!inVirgolette)),inVirgolette||("("===char||"["===char||"{"===char?livelloParentesi++:")"!==char&&"]"!==char&&"}"!==char||(livelloParentesi=Math.max(0,livelloParentesi-1))),","!==char&&";"!==char||0!==livelloParentesi||inVirgolette)buffer+=char;else{const trimmed=buffer.trim();risultato.push(trimmed),buffer=""}}const trimmed=buffer.trim();return trimmed&&risultato.push(trimmed),risultato.map((e=>(e=e.trim(),!keepquote&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("(")&&e.endsWith(")"))?e.slice(1,-1):e)))}function hash(obj){let str="";if("string"==typeof obj||"number"==typeof obj)str=obj+"";else if("object"==typeof obj&&obj){const chiaviOrdinati=Object.keys(obj).sort(),separatore="\0";str=chiaviOrdinati.map((key=>`${key}${separatore}${String(obj[key])}`)).join(separatore)}let h1=2166136261,h2=2218511855;for(let i=0;i<str.length;i++){const char=str.charCodeAt(i);h1^=char,h1+=h1<<5^2779096485,h2^=h1,h2=((h2<<3)+char^2134516169)>>>0}return h1>>>=0,h1.toString(16)+h2.toString(16)}function clamp(n,min=-1/0,max=1/0){return(n=Number(n)||0)<min&&(n=min),n>max&&(n=max),n}function getSqDist(p1,p2){let dx=p1.x-p2.x,dy=p1.y-p2.y;return dx*dx+dy*dy}function getSqSegDist(p,p1,p2){let x=p1.x,y=p1.y,dx=p2.x-x,dy=p2.y-y;if(0!==dx||0!==dy){let t=((p.x-x)*dx+(p.y-y)*dy)/(dx*dx+dy*dy);t>1?(x=p2.x,y=p2.y):t>0&&(x+=dx*t,y+=dy*t)}return dx=p.x-x,dy=p.y-y,dx*dx+dy*dy}function simplifyDPStep(points,first,last,sqTolerance,simplified){let index,maxSqDist=sqTolerance;for(let i=first+1;i<last;i++){let sqDist=getSqSegDist(points[i],points[first],points[last]);sqDist>maxSqDist&&(index=i,maxSqDist=sqDist)}maxSqDist>sqTolerance&&(index-first>1&&simplifyDPStep(points,first,index,sqTolerance,simplified),simplified.push(points[index]),last-index>1&&simplifyDPStep(points,index,last,sqTolerance,simplified))}function simplifyDouglasPeucker(points,sqTolerance){let last=points.length-1,simplified=[points[0]];return simplifyDPStep(points,0,last,sqTolerance,simplified),simplified.push(points[last]),simplified}
155
- /**
156
- * Esegue la semplificazione di un poligono (array di punti) combinando
157
- * l’algoritmo di distanza radiale e l’algoritmo di Ramer–Douglas–Peucker.
158
- *
159
- * @param {Array<{x:number,y:number}>} points - Array di punti {x,y} da semplificare.
160
- * @param {number} [tolerance=1] - Tolleranza di semplificazione: distanza minima consentita
161
- * (in unità lineari) tra i punti; internamente usata al quadrato per il calcolo
162
- * (`sqTolerance = tolerance * tolerance`). Valori più grandi rimuovono più punti.
163
- * @param {boolean} [highestQuality=false] - Se `true`, salta il passaggio di
164
- * semplificazione radiale e usa solo Douglas–Peucker per massima qualità.
165
- * @returns {Array<{x:number,y:number}>} Nuovo array di punti semplificato.
166
- */function simplify(points,tolerance,highestQuality){if(points.length<=2)return points;let sqTolerance=void 0!==tolerance?tolerance*tolerance:1;return points=highestQuality?points:function simplifyRadialDist(points,sqTolerance){let point,prevPoint=points[0],newPoints=[prevPoint];for(let i=1,len=points.length;i<len;i++)point=points[i],getSqDist(point,prevPoint)>sqTolerance&&(newPoints.push(point),prevPoint=point);return prevPoint!==point&&newPoints.push(point),newPoints}(points,sqTolerance),points=simplifyDouglasPeucker(points,sqTolerance)}function mapvertices(pat1,pat2){const dist2=(a,b)=>(a.x-b.x)**2+(a.y-b.y)**2;let n1=pat1.length,n2=pat2.length;if(n1<2||n2<2)return[];let map=[[0,0]];if(n1===n2){for(let i=1;i<n1;i++)map.push([i,i]);return map}if(n1>n2)for(let i=1,j=0;i<n1-1;i++){if(j+1<n2){const p=pat1[i],d1=dist2(p,pat2[j]);dist2(p,pat2[j+1])<=d1&&j++}map.push([i,j])}else for(let i=1,j=0;i<n2-1;i++){if(j+1<n1){const p=pat2[i],d1=dist2(p,pat1[j]);dist2(p,pat1[j+1])<=d1&&j++}map.push([j,i])}return map.push([n1-1,n2-1]),map}
167
- /**
168
- * Calcola i punti di un arco DXF dato p1, p2, bulge e n punti intermedi.
169
- * p1, p2: oggetti {x, y}
170
- * bulge: valore DXF tra p1 e p2
171
- * n: numero di punti INTERMEDI da inserire tra p1 e p2 (n=0 -> solo estremi)
172
- * Return: array di punti [{x, y}, ..., {x, y}]
173
- */function dxfbulge(p1,p2,bulge,n=0){const points=[];if(!bulge||Math.abs(bulge)<1e-10||0===n)return points;const theta=4*Math.atan(bulge);if(theta<0)return dxfbulge(p2,p1,-bulge,n).reverse();const dx=p2.x-p1.x,dy=p2.y-p1.y,chord=Math.hypot(dx,dy),r=chord/(2*Math.sin(theta/2)),mx=(p1.x+p2.x)/2,my=(p1.y+p2.y)/2,nx=-dy/chord,ny=dx/chord,d=r*Math.cos(theta/2),sign=bulge>=0?1:-1,cx=mx+sign*nx*d,cy=my+sign*ny*d;let a1=Math.atan2(p1.y-cy,p1.x-cx);for(let i=1;i<=n;i++){const a=a1+i/(n+1)*theta,x=cx+r*Math.cos(a),y=cy+r*Math.sin(a);points.push({x:x,y:y})}return points}
174
- /**
175
- * Crea una curva di Bézier quadratica tra due segmenti di linea.
176
- * @param {Object} a1 - Punto iniziale del primo segmento {x,y}
177
- * @param {Object} a2 - Punto finale del primo segmento {x,y}
178
- * @param {Object} b1 - Punto iniziale del secondo segmento {x,y}
179
- * @param {Object} b2 - Punto finale del secondo segmento {x,y}
180
- * @param {number} [subdivisions=10] - Numero di suddivisioni della curva
181
- * @returns {Array<Object>} Array di punti {x,y} che formano la curva
182
- */
183
- function raccordabezier(a1,a2,b1,b2,subdivisions=10){const intersection=function getIntersection(p1,p2,p3,p4){const denom=(p1.x-p2.x)*(p3.y-p4.y)-(p1.y-p2.y)*(p3.x-p4.x);return 0===denom?null:{x:((p1.x*p2.y-p1.y*p2.x)*(p3.x-p4.x)-(p1.x-p2.x)*(p3.x*p4.y-p3.y*p4.x))/denom,y:((p1.x*p2.y-p1.y*p2.x)*(p3.y-p4.y)-(p1.y-p2.y)*(p3.x*p4.y-p3.y*p4.x))/denom}}(a1,a2,b1,b2);if(!intersection)return[{x:a2.x,y:a2.y},{x:b1.x,y:b1.y}];const control=intersection;if(0===subdivisions)return[{x:a2.x,y:a2.y},{x:b1.x,y:b1.y}];const curvePoints=[];for(let i=0;i<=subdivisions;i++){const t=i/subdivisions,oneMinusT=1-t,x=oneMinusT*oneMinusT*a2.x+2*oneMinusT*t*control.x+t*t*b1.x,y=oneMinusT*oneMinusT*a2.y+2*oneMinusT*t*control.y+t*t*b1.y;curvePoints.push({x:x,y:y})}return curvePoints}
184
- /**
185
- * Crea una curva di Bézier quadratica tra due segmenti usando 3 punti e una distanza
186
- * @param {Object} a1 - Punto iniziale del primo segmento {x,y}
187
- * @param {Object} a2 - Punto comune ai due segmenti {x,y}
188
- * @param {Object} a3 - Punto finale del secondo segmento {x,y}
189
- * @param {number} d - Distanza di raccordo
190
- * @param {number} [subdivisions=10] - Numero di suddivisioni della curva
191
- * @returns {Array<Object>} Array di punti {x,y} che formano la curva
192
- */function raccordabezier3(a1,a2,a3,d,subdivisions=10){const v1_x=a2.x-a1.x,v1_y=a2.y-a1.y,v2_x=a3.x-a2.x,v2_y=a3.y-a2.y,len1=Math.sqrt(v1_x*v1_x+v1_y*v1_y),len2=Math.sqrt(v2_x*v2_x+v2_y*v2_y);if(d>len1||d>len2)return[a1,a2,a3];d!=len1&&d!=len2||(d-=.01);const t1=(len1-d)/len1,t2=d/len2;return raccordabezier(a1,{x:a1.x+v1_x*t1,y:a1.y+v1_y*t1},{x:a2.x+v2_x*t2,y:a2.y+v2_y*t2},a3,subdivisions)}
193
- /**
194
- * Calcola il vettore normale unitario di un segmento di linea.
195
- * @param {Object} p1 - Punto iniziale {x,y}
196
- * @param {Object} p2 - Punto finale {x,y}
197
- * @returns {Object} Vettore normale unitario {nx,ny}
198
- */function normal2(p1,p2){const dx=p2.x-p1.x;let nx=-(p2.y-p1.y),ny=dx;const length=Math.sqrt(nx*nx+ny*ny);return 0===length?{nx:0,ny:0}:{nx:nx/length,ny:ny/length}}
199
- /**
200
- * Calcola l'angolo tra tre punti in radianti.
201
- * @param {Object} p1 - Primo punto {x,y}
202
- * @param {Object} p2 - Punto centrale {x,y}
203
- * @param {Object} p3 - Terzo punto {x,y}
204
- * @returns {number} Angolo in radianti
205
- */function angle3point(p1,p2,p3){const u_x=p2.x-p1.x,u_y=p2.y-p1.y,v_x=p3.x-p2.x,v_y=p3.y-p2.y,dot=u_x*v_x+u_y*v_y,cross=u_x*v_y-u_y*v_x,magU=Math.sqrt(u_x**2+u_y**2),magV=Math.sqrt(v_x**2+v_y**2);return magU&&magV?Math.atan2(cross,dot):0}
206
- /**
207
- * Calcola l'angolo tra due vettori in gradi.
208
- * @param {Object} v1 - Primo vettore {x,y}
209
- * @param {Object} v2 - Secondo vettore {x,y}
210
- * @returns {number} Angolo in gradi
211
- */function angle2vec(v1,v2){const dot=v1.x*v2.x+v1.y*v2.y,mag1=Math.sqrt(v1.x*v1.x+v1.y*v1.y),mag2=Math.sqrt(v2.x*v2.x+v2.y*v2.y);if(0===mag1||0===mag2)return 0;let cosTheta=dot/(mag1*mag2);cosTheta=Math.max(-1,Math.min(1,cosTheta));return Math.acos(cosTheta)/PIF}
212
- /**
213
- * Rimuove i punti duplicati da un percorso chiuso.
214
- * @param {Array<Object>} path - Array di punti {x,y}
215
- * @param {number} [delta=0.005] - Soglia di distanza per considerare i punti duplicati
216
- * @returns {Array<Object>} Nuovo array di punti senza duplicati
217
- */function removeduplicate(path,delta=.005){if(!Array.isArray(path)||0===path.length)return[];const cleanedPath=[],n=path.length;for(let i=0;i<n;i++){const current=path[i],next=path[(i+1)%n];cleanedPath.push({x:current.x,y:current.y}),next.x,current.x,next.y,current.y}const first=cleanedPath[0],last=cleanedPath[cleanedPath.length-1];return first.x,last.x,first.y,last.y,cleanedPath}
218
- /**
219
- * Calcola le normali e i valori UV per un percorso chiuso.
220
- * @param {Array<Object>} path - Array di punti {x,y}
221
- * @param {number} [c=0] - Coefficiente c per il calcolo di z
222
- * @param {number} [a=0] - Coefficiente a per il calcolo di z
223
- * @param {number} [b=0] - Coefficiente b per il calcolo di z
224
- * @param {number} [anglemin=30] - Angolo minimo in gradi per la suddivisione dei punti
225
- * @param {sh} [null] - Shape da raccordare
226
- * @param {invert} [false] - inverti direzione del raccordo
227
-
228
- * @returns {Array<Object>} Array di punti con normali e coordinate UV
229
- */
230
- /*
231
- * Crea un oggetto shape per manipolare forme 2D
232
- * @returns {Object} Oggetto con metodi per manipolare la forma
233
- * @property {string} key - Hash univoco della forma
234
- * @property {Array<{x:number,y:number}>} pt - Array dei punti della forma
235
- * @property {Array<number>} vec - Array dei punti come vettore [x1,y1,x2,y2,...]
236
- * @property {number} orient - Orientamento della forma (1 orario, -1 antiorario, 0 degenere)
237
- * @method clone() - Crea una copia della forma
238
- * @method rotate(deg) - Ruota la forma di deg gradi
239
- * @method move(x,y) - Sposta la forma di x,y
240
- * @method fromclip(vv) - Inizializza da punti in formato clipper
241
- * @method fromvec(aa) - Inizializza da array di coordinate [x1,y1,x2,y2,...]
242
- * @method frompt(pts) - Inizializza da array di punti [{x,y},...]
243
- * @method fromdxfvec(verts) - vertici nel formato DXF LWPOLYLINE con bulge per i raccordi:
244
- * @method fromstr(str) - Inizializza da stringa con sintassi speciale
245
- * @method addpt(pts) - Aggiunge punti alla forma
246
- * @method addracc(v1,v2,suddivisioni,addv1v2) - Aggiunge raccordo tra punti
247
- * @method setorient(mode) - Imposta l'orientamento della forma
248
- * @method reverse() - Inverte l'ordine dei punti
249
- * @method pointinshape(p) - Verifica se un punto è interno alla forma
250
- * @method azzera() - Rimuove tutti i punti
251
- * @method removeduplicate(delta) - Rimuove punti duplicati
252
- * @method to3d(u0,c,a,b,shape,invert) - Converte in forma 3D con normali
253
- */
254
- function getshape(){let pt=[];
255
- /**
256
- * Calcola l'orientamento della forma usando la formula dell'area segnata
257
- * @returns {number} 1 se orario, -1 se antiorario, 0 se degenere
258
- */function orientation(){if(!pt.length)return 0;let area=0;const n=pt.length;for(let i=0;i<n;i++){const current=pt[i],next=pt[(i+1)%n];area+=current.x*next.y-next.x*current.y}return area>0?1:area<0?-1:0}
259
- /**
260
- * Converte i punti in array di coordinate
261
- * @returns {Array<number>} Array [x1,y1,x2,y2,...]
262
- */
263
- function tovec(){return pt.flatMap((p=>[p.x,p.y]))}function move(x=0,y=0){"object"==typeof x&&x.x&&(y=x.y||0,x=x.x);for(let p of pt)p.x+=x,p.y+=y;return this}
264
- /**
265
- * Verifica se un punto è interno al poligono usando ray casting
266
- * @param {Object} P - Punto da verificare {x,y}
267
- * @returns {boolean} true se il punto è interno
268
- */function selezionaprimo(idprimopunto){return(idprimopunto%=pt.length)>0&&(pt=[...pt.slice(idprimopunto),...pt.slice(0,idprimopunto)]),this}
269
- /**
270
- * Aggiunge punti da array di coordinate
271
- * @param {Array<number>} aa - Array [x1,y1,x2,y2,...]
272
- */
273
- function _addvec(aa){for(let i=0;i<aa.length;i+=2)pt.push({x:aa[i],y:aa[i+1]})}function fromstr(str){return pt=removeduplicate(function processTokens(tokens){const points=[];for(let i=0;i<tokens.length;i++){const token=tokens[i];if("point"===token.type)points.push(token.point);else if("command"===token.type)switch(token.cmd){case"x":{const p1=points[points.length-1],p2="point"===tokens[i+1]?.type?tokens[i+1].point:points[0],bulge=parseFloat(token.params[0])||5;{const STEP=1;let dx=p2.x-p1.x,dy=p2.y-p1.y,dist=Math.hypot(dx,dy);dist>1&&points.push(...dxfbulge(p1,p2,bulge,Math.floor((dist-STEP)/(STEP+2))+1))}break}case"b":{if(points.length<2)continue;const npt=parseInt(token.params[0])||5,p1=points[points.length-2],p2=points[points.length-1];let p3="point"===tokens[i+1]?.type?tokens[i+1].point:void 0,p4="point"===tokens[i+2]?.type?tokens[i+2].point:void 0;p3?p4||(p4=points[0]):(p3=points[0],p4=points[1]);const raccordo=raccordabezier(p1,p2,p3,p4,npt);points.push(...raccordo),i+=1;break}case"r":{if(points.length<1)continue;const dist=parseFloat(token.params[0])||0;if(dist>0){const npt=parseInt(token.params[1])||Math.min(dist,10),p1=points[points.length-1];let p2="point"===tokens[i+1]?.type?tokens[i+1].point:void 0,p3="point"===tokens[i+2]?.type?tokens[i+2].point:"point"===tokens[i+3]?.type?tokens[i+3].point:void 0;p2?p3||(p3=points[0]):(p2=points[0],p3=points[1],points.splice(0,1));const raccordo=raccordabezier3(p1,p2,p3,dist,npt);points.push(...raccordo),i+=1}break}case"c":{const radius=parseFloat(token.params[0])||50,segments=parseInt(token.params[1])||12,center="point"===tokens[i+1]?.type?tokens[i+1].point:new Punto2(0,0);for(let j=0;j<segments;j++)points.push(new Punto2(center.x+radius*Math.cos(j/segments*Math.PI*2),center.y+radius*Math.sin(j/segments*Math.PI*2)));i+=1;break}case"a":{let npt,p1="point"===tokens[i+1]?.type?tokens[i+1].point:void 0,p2="point"===tokens[i+2]?.type?tokens[i+2].point:void 0,p3="point"===tokens[i+3]?.type?tokens[i+3].point:void 0;if(!p1||!p3)continue;if(p2)if(token.params[0])npt=clamp(parseInt(token.params[0]),1,24);else{const chord=Math.hypot(p3.x-p1.x,p3.y-p1.y),sagitta=Math.abs((p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y))/(2*chord);npt=Math.round(chord*Math.sqrt(sagitta/(chord+.1))*10),npt=clamp(npt,1,24),npt=1}else p2=p3,npt=0;const arcoPoints=arcfrom3point(npt,p1,p2,p3);points.push(...arcoPoints),i+=3;break}}}return points}(function tokenize(str){const tokens=[],values=str.replace(/[\n\r,;]/g," ").replace(/\s+/g," ").toLowerCase().trim().split(" ").filter((s=>s.length>0));let i=0;for(;i<values.length;){const val=values[i];/^[brcax]/.test(val)?(tokens.push({type:"command",cmd:val[0],params:val.slice(1).split(":")}),i++):i<values.length-1&&/^-?\d+(\.\d+)?$/.test(values[i])&&/^-?\d+(\.\d+)?$/.test(values[i+1])?(tokens.push({type:"point",point:new Punto2(parseFloat(values[i]),parseFloat(values[i+1]))}),i+=2):i++}return tokens}(str))),this}function dims(pts){let{p1:p1,p2:p2}=pts.reduce(((m,p)=>(m.p1.x=Math.min(m.p1.x,p.x),m.p2.x=Math.max(m.p2.x,p.x),m.p1.y=Math.min(m.p1.y,p.y),m.p2.y=Math.max(m.p2.y,p.y),m)),{p1:new Punto2(1/0,1/0),p2:new Punto2(-1/0,-1/0)}),isrect=!1;if(4==pts.length){const TOLL=.001;function findpunto(x,y){let f=pts.find((p=>Math.abs(p.x-x)<TOLL&&Math.abs(p.y-y)<TOLL));return!!f}findpunto(p1.x,p1.y)&&findpunto(p1.x,p2.y)&&findpunto(p2.x,p1.y)&&findpunto(p2.x,p2.y)&&(isrect=!0)}return{p1:p1,p2:p2,isrect:isrect,width:p2.x-p1.x,height:p2.y-p1.y}}return{get key(){return hash(tovec().join("\t"))},orienta:function orienta(p0,p1){if(!p0||!p1)return null;const dx=p1.x-p0.x,dy=p1.y-p0.y,angolo=180*Math.atan2(dy,dx)/Math.PI,matrix=new Matrix3D;matrix.rotateZ(-angolo),matrix.translate(-p0.x,-p0.y,0);const ptTrasformati=pt.map((p=>matrix.transform(p.x,p.y)));let mm=ptTrasformati.reduce(((m,p)=>(m.p1.x=Math.min(m.p1.x,p.x),m.p2.x=Math.max(m.p2.x,p.x),m.p1.y=Math.min(m.p1.y,p.y),m.p2.y=Math.max(m.p2.y,p.y),m)),{p1:new Punto2(1/0,1/0),p2:new Punto2(-1/0,-1/0)});return{shape:getshape().frompt(ptTrasformati),origine:new Punto2(p0.x,p0.y),angolo:angolo,mm:mm,width:mm.p2.x-mm.p1.x,height:mm.p2.y-mm.p1.y}},rebase:function rebase(angolo,forceorigin=!1,ox=0,oy=0){const matrix=new Matrix3D;matrix.rotateZ(-angolo);let ptTrasformati=pt.map((p=>matrix.transform(p.x,p.y))),{p1:p1,p2:p2,width:width,height:height}=dims(ptTrasformati);return forceorigin||(ox=p1.x,oy=p1.y),ptTrasformati=ptTrasformati.map((p=>new Punto2(p.x-ox,p.y-oy))),{shape:getshape().frompt(ptTrasformati),origine:new Punto2(ox,oy),angolo:angolo,width:width,height:height}},fromstr:fromstr,move:move,get pt(){return pt},set pt(val){Array.isArray(val)&&(pt=val)},get npt(){return pt?.length||0},get vec(){return tovec()},toJSON:()=>({vec:tovec(),orient:orientation()}),get orient(){return orientation()},corners:(angolo=45)=>
274
- /**
275
- * Trova i punti in cui l’angolo interno è maggiore di `thresholdDeg`.
276
- *
277
- * @param {Array<{x:number,y:number}>} path - Array di punti chiuso.
278
- * @param {number} thresholdDeg - Angolo in gradi.
279
- * @returns {Array<{ index: number, point: {x:number,y:number}, angle: number }>}
280
- */
281
- function sharpCorners(path,thresholdDeg=45){const result=[],n=path.length;if(n<3)return result;for(let i=0;i<n;i++){const prev=path[(i-1+n)%n],curr=path[i],next=path[(i+1)%n],ux=curr.x-prev.x,uy=curr.y-prev.y,vx=next.x-curr.x,vy=next.y-curr.y,magU=Math.hypot(ux,uy),magV=Math.hypot(vx,vy);if(0===magU||0===magV)continue;let cosTheta=(ux*vx+uy*vy)/(magU*magV);cosTheta=Math.max(-1,Math.min(1,cosTheta));const angleDeg=180*Math.acos(cosTheta)/Math.PI;angleDeg>thresholdDeg&&result.push({i:i,x:curr.x,y:curr.y,a:angleDeg})}return result}(pt,45),clone:()=>getshape().frompt(pt),dims:()=>dims(pt),get area(){return Math.abs(pt.reduce(((acc,curr,i)=>{const next=pt[(i+1)%pt.length];return acc+(curr.x*next.y-next.x*curr.y)}),0)/2)},pointslink(sh2){let map=mapvertices(pt,sh2.pt),plink=[];for(let m of map)plink[m[0]]=sh2.pt[m[1]];return plink},alignline(p1,p2){return pt=function stretchShapeToLine(shapePts,p1,p2){if(!shapePts?.length||!p1||!p2)return[];const first=shapePts[0],last=shapePts[shapePts.length-1],dx=last.x-first.x,dy=last.y-first.y,ang=Math.atan2(dy,dx);let pts0=shapePts.map((p=>({x:p.x-first.x,y:p.y-first.y}))),pts1=pts0.map((p=>({x:p.x*Math.cos(-ang)-p.y*Math.sin(-ang),y:p.x*Math.sin(-ang)+p.y*Math.cos(-ang)})));const linea={dx:p2.x-p1.x,dy:p2.y-p1.y},scaleX=Math.sqrt(linea.dx*linea.dx+linea.dy*linea.dy)/(pts1[pts1.length-1].x||1e-8);let pts2=pts1.map((p=>({x:p.x*scaleX,y:p.y})));const angDest=Math.atan2(linea.dy,linea.dx);let pts3=pts2.map((p=>({x:p.x*Math.cos(angDest)-p.y*Math.sin(angDest),y:p.x*Math.sin(angDest)+p.y*Math.cos(angDest)}))),ptsFinal=pts3.map((p=>({x:p.x+p1.x,y:p.y+p1.y})));return ptsFinal}(pt,p1,p2),this},rotate(deg){if(!deg)return this;const r=deg*Math.PI/180,cosTheta=Math.cos(r),sinTheta=Math.sin(r);for(let p of pt){const xNew=p.x*cosTheta-p.y*sinTheta,yNew=p.x*sinTheta+p.y*cosTheta;p.x=xNew,p.y=yNew}return this},selezionaprimo:selezionaprimo,
282
- /**
283
- * Trova i punti in cui l’angolo interno è maggiore di `thresholdDeg`.
284
- *
285
- * @param {Array<{x:number,y:number}>} path - Array di punti chiuso.
286
- * @param {number} thresholdDeg - Angolo in gradi.
287
- * @returns {Array<{ index: number, point: {x:number,y:number}, angle: number }>}
288
- */
289
- segment(i,inverse=!1){let n=pt.length;return i<0&&(i+=n),new Linea2(pt[i%n],pt[(i+(inverse?-1:1))%n])},lineoffset(i1,i2,offset){if((i1=(i1||0)%pt.length)!=(i2=(i2||0)%pt.length)){let l2=new Linea2(pt[i1],pt[i2]);if(l2){return l2=l2.offsetline(-offset),this.intersectline(l2)}}},orientasplitter(){-1!=orientation()&&pt.reverse();let np=pt.length;for(let i=0;i<np;i++){let lt=new Linea2(pt[(np+i-1)%np],pt[i]);if(Math.abs(Math.abs(lt.angle)-Math.PI)<.001){i&&selezionaprimo(i);break}}return this},mirrorx(value=0){for(let p of pt)p.x=2*value-p.x;return this},mirrory(value=0){for(let p of pt)p.y=2*value-p.y;return this},simplify(tolerance,hq){return pt=simplify(pt,tolerance,hq),this},fromclip(vv){pt=[];for(let p of vv)pt.push({x:p.x/1e3,y:p.y/1e3});return this},infosegmento(i,open=!1){const n=pt.length;function clampIndex(idx){return(idx+n)%n}function angle(p1,p2){return Math.atan2(p2.y-p1.y,p2.x-p1.x)}function angleDiff(a,b){let diff=a-b;for(;diff>Math.PI;)diff-=2*Math.PI;for(;diff<-Math.PI;)diff+=2*Math.PI;return diff}const p1=pt[i];let p0,p2,p3;if(open)if(0===i){const dx=pt[1].x-pt[0].x,dy=pt[1].y-pt[0].y;p0={x:pt[0].x-dx,y:pt[0].y-dy},p2=pt[1],p3=2==n?{x:pt[1].x+dx,y:pt[1].y+dy}:pt[2]}else if(i===n-1){const dx=pt[n-1].x-pt[n-2].x,dy=pt[n-1].y-pt[n-2].y;p0=pt[n-2],p2={x:pt[n-1].x+dx,y:pt[n-1].y+dy},p3={x:p2.x+dx,y:p2.y+dy}}else p0=pt[i-1],p2=pt[i+1],p3=i+2<n?pt[i+2]:{x:pt[i+1].x+(pt[i+1].x-pt[i].x),y:pt[i+1].y+(pt[i+1].y-pt[i].y)};else{const i0=clampIndex(i-1),i2=clampIndex(i+1),i3=clampIndex(i+2);p0=pt[i0],p2=pt[i2],p3=pt[i3]}const ang12=angle(p1,p2),ang01=angle(p0,p1),ang23=angle(p2,p3);return{x:p1.x,y:p1.y,l:function length(p1,p2){const dx=p2.x-p1.x,dy=p2.y-p1.y;return Math.sqrt(dx*dx+dy*dy)}(p1,p2),ang:ang12/PIF,a1:angleDiff(ang12,ang01)/PIF,a2:angleDiff(ang23,ang12)/PIF}},swapxy(){for(let i=0;i<pt.length;i++){let q=pt[i].x;pt[i].x=-pt[i].y,pt[i].y=-q}return this},fromvec(aa){return pt=[],_addvec(aa),this},addvec(vec){return _addvec(vec),this},frompt(pts){return pt=[...pts],pt=removeduplicate(pt),this},fromdxfvec(verts){let points=[];if(verts&&verts.length)for(let i=0;i<verts.length;i++){let{x:x,y:y,bulge:bulge}=verts[i];if(points.push({x:x,y:y}),bulge){const step=1;let p1={x:x,y:y},p2=verts[(i+1)%verts.length],dx=p2.x-p1.x,dy=p2.y-p1.y,dist=Math.hypot(dx,dy);dist>step&&points.push(...dxfbulge(p1,p2,bulge,Math.floor((dist-step)/step)+1))}}return pt=points.map((e=>({x:Math.round(10*e.x)/10,y:Math.round(10*e.y)/10}))),pt=removeduplicate(pt),this},monotona(){let dxd=dims(pt),pp=pt.map((e=>({x:e.x-dxd.p2.x,y:e.y}))),xp=[];xp.push(pp[0]);let lastv=pp[0].y;for(let i=1;i<pp.length;i++)if(pp[i].y>lastv+1e-4||i==pp.length-1)xp.push(pp[i]),lastv=pp[i].y;else{const newv=lastv+1e-4;xp.push({x:pp[i].x,y:newv}),lastv=newv}return{sh:getshape().frompt(xp),...dxd}},offsetshape(delta){let sg=[],sh=this;for(let i=0;i<sh.npt-1;i++){let l=sh.segment(i).offset(delta);sg.push(l)}let l1=sh.segment(0).perpendicolare(),s2=sh.segment(sh.npt-2),l2=s2.perpendicolare(s2.p2),pts=[l1.interseca(sg[0])];for(let i=0;i<sg.length-1;i++){let p=sg[i].interseca(sg[i+1]);p&&pts.push(p)}return pts.push(sg[sg.length-1].interseca(l2)),getshape().frompt(pts)},sliceony(stag){let yvalues=stag.pt.map((e=>e.y)).slice(1,-1);const res=[],n=pt.length;let imin=0,yMin=pt[0].y;for(let i=1;i<n;i++)pt[i].y<yMin&&(yMin=pt[i].y,imin=i);const pts=[...pt.slice(imin),...pt.slice(0,imin)],m=pts.length,ymap=new Map;for(let i=0;i<m;i++)for(let y of yvalues)Math.abs(pts[i].y-y)<1e-5&&(ymap.has(y)?ymap.get(y).i2=i:ymap.set(y,{i1:i,i2:i}));const pairs=yvalues.map((y=>ymap.get(y))).filter((p=>p&&p.i1>=0&&p.i2>=0));pairs.length>0&&pairs[0].i1>0&&res.push([...pts.slice(0,pairs[0].i1+1),...pts.slice(pairs[0].i2,pairs[0].length)]);for(let i=0;i<pairs.length-1;i++){const a=pairs[i],b=pairs[i+1];res.push([...pts.slice(a.i1,b.i1+1),...pts.slice(b.i2,a.i2+1)])}const last=pairs[pairs.length-1];last.i2>last.i1&&res.push(pts.slice(last.i1,last.i2+1));return res.filter((arr=>arr.length>0))},splitshape(p,verticale=!0){const p1=verticale?{x:p.x,y:p.y-100}:{x:p.x-100,y:p.y},p2=verticale?{x:p.x,y:p.y+100}:{x:p.x+100,y:p.y},linea=this.intersectline(new Linea2(p1,p2));if(!linea)return null;const pstart=linea.p1,pend=linea.p2,findIndex=pt=>this.pt.findIndex(((v,i)=>new Linea2(v,this.pt[(i+1)%this.pt.length]).onsegment(pt))),i1=findIndex(pstart),i2=findIndex(pend);if(i1<0||i2<0)return null;const n=this.pt.length,loop=(a,b,p0,p1)=>{const res=[];for(let i=a;i!==b;i=(i+1)%n)res.push(this.pt[(i+1)%n]);return res},dx=getshape().frompt(loop(i1,i2));return{sx:getshape().frompt(loop(i2,i1)),dx:dx,linea:linea}},xfromy(y,valore0=0,maggiore=!0){const res=[],n=this.pt.length;for(let i=0;i<n-1;i++){const p1=this.pt[i],p2=this.pt[i+1];if(p1.y<=y&&p2.y>=y||p2.y<=y&&p1.y>=y){const dy=p2.y-p1.y,t=dy?(y-p1.y)/dy:0,x=p1.x+t*(p2.x-p1.x);res.push(x)}else p1.y===y&&p2.y===y&&res.push(maggiore?Math.max(p1.x,p2.x):Math.min(p1.x,p2.x))}return res.length?maggiore?Math.max(...res):Math.min(...res):valore0},yfromx(x,valore0=0,maggiore=!0){const res=[],n=this.pt.length;for(let i=0;i<n-1;i++){const p1=this.pt[i],p2=this.pt[i+1];if(p1.x<=x&&p2.x>=x||p2.x<=x&&p1.x>=x){const dx=p2.x-p1.x,t=dx?(x-p1.x)/dx:0,y=p1.y+t*(p2.y-p1.y);res.push(y)}else p1.x===x&&p2.x===x&&res.push(maggiore?Math.max(p1.y,p2.y):Math.min(p1.y,p2.y))}return res.length?maggiore?Math.max(...res):Math.min(...res):valore0},forcevalues(shape,verticale=!0,delta=1e-6){const sorted=[...new Set(shape.pt.map((e=>verticale?e.y:e.x)))].sort(((a,b)=>a-b)),newpt=[],n=pt.length;for(let i=0;i<n;i++){const p1=pt[i],p2=pt[(i+1)%n];newpt.push({...p1});let v1=verticale?p1.y:p1.x,v2=verticale?p2.y:p2.x;if(v1===v2)continue;const range=v2>v1?sorted.filter((v=>v>v1+delta&&v<v2-delta)):sorted.filter((v=>v<v1-delta&&v>v2+delta)).reverse();for(const v of range){const t=(v-v1)/(v2-v1),q={x:p1.x+t*(p2.x-p1.x),y:p1.y+t*(p2.y-p1.y)};newpt.push(q)}}return pt=newpt,this},fromrrect(w,h,r=10,sx=0,sy=0){return(r>=w/2||r>=h/2&&r<=0)&&(r=Math.round(Math.min(w/3,h/3))),fromstr(`0,0,r${r},${w},0,r${r},${w},${h},r${r},0,${h},r${r}`),(sx||sy)&&move(sx,sy),this},fromrect(w,h,sx,sy,bordo){w||(w=10),h||(h=10),bordo||(bordo=0),bordo=Math.min(Math.abs(bordo),Math.abs(.4*w),Math.abs(.4*h));let b1=w>0?bordo:-bordo,b2=h>0?bordo:-bordo;return pt=bordo?[{x:b1,y:0},{x:w-b1,y:0},{x:w,y:b2},{x:w,y:h-b2},{x:w-b1,y:h},{x:b1,y:h},{x:0,y:h-b2},{x:0,y:b2}]:[{x:0,y:0},{x:w,y:0},{x:w,y:h},{x:0,y:h}],this},intersectline:l=>function _intersectline(shape,p3,p4){let n=shape.length,l=new Linea2(p3,p4);const intersezioni=[];for(let i=0;i<shape.length;i++){let l2=new Linea2(shape[i],shape[(i+1)%n]),p=l2.interseca(l);p&&l2.onsegment(p)&&intersezioni.push(p)}if(intersezioni.length<2)return null;const{dx:dx,dy:dy}=l;intersezioni.sort(((a,b)=>(a.x-p3.x)*dx+(a.y-p3.y)*dy-((b.x-p3.x)*dx+(b.y-p3.y)*dy)));let pstart=new Punto2(intersezioni[0].x,intersezioni[0].y),pend=new Punto2(intersezioni[intersezioni.length-1].x,intersezioni[intersezioni.length-1].y);const vx1=pend.x-pstart.x,vy1=pend.y-pstart.y;return vx1*dx+vy1*dy<0&&([pstart,pend]=[pend,pstart]),new Linea2(pstart,pend)}(pt,l.p1,l.p2),tostr(dec=2){let dd=10**dec,pstr=x=>String(Math.round(x*dd)/dd),cl=pt.map((e=>`${pstr(e.x)};${pstr(e.y)};`)).join("");return cl&&cl.length?cl.slice(0,-1).match(/.{1,80}(;|$)/g).map((s=>s.trim())).join("\n"):""},addpt(pts){return pts?(Array.isArray(pts)||(pts=[pts]),pt=removeduplicate([...pt,...pts]),this):this},addracc(v1,v2,suddivisioni=2,addv1v2=!0){if(Array.isArray(v1)&&(v2={x:v1[2]||0,y:v1[3]||0},v1={x:v1[0]||0,y:v1[1]||0}),pt.length>=2){let tm=raccordabezier(pt[pt.length-2],pt[pt.length-1],v1,v2,suddivisioni);pt=[...pt,...tm],addv1v2&&(pt.push(v1),pt.push(v2))}return pt=removeduplicate(pt),this},setorient(mode){let p=orientation();return(1==p&&-1==mode||-1==p&&1==mode)&&pt.reverse(),this},reverse(){return pt.reverse(),this},pointinshape:p=>function isPointInPolygon(P){let x=P.x,y=P.y,inside=!1;for(let i=0,j=pt.length-1;i<pt.length;j=i++){let xi=pt[i].x,yi=pt[i].y,xj=pt[j].x,yj=pt[j].y;yi>y!=yj>y&&x<(xj-xi)*(y-yi)/(yj-yi)+xi&&(inside=!inside)}return inside}(p),azzera(){return pt=[],this},truncatebefore:function truncatebefore(linea){let s=new Linea2(pt[0],pt[1]),p=linea.interseca(s);if(p){let a=pt[0],b=pt[1],dx=b.x-a.x,dy=b.y-a.y,den=dx*dx+dy*dy;if(den){if(((p.x-a.x)*dx+(p.y-a.y)*dy)/den<=1)return pt[0]=p,this}}for(let i=1;i<pt.length-1;i++){let s=new Linea2(pt[i],pt[i+1]),p=linea.interseca(s);if(p&&s.onsegment(p))return pt=pt.slice(i),pt[0]=p,this}return this},truncateafter:function truncateafter(linea){let np=pt.length,s=new Linea2(pt[np-2],pt[np-1]),p=linea.interseca(s);if(p){let a=pt[np-2],b=pt[np-1],dx=b.x-a.x,dy=b.y-a.y,den=dx*dx+dy*dy;if(den){if(((p.x-a.x)*dx+(p.y-a.y)*dy)/den>=0)return pt[np-1]=p,this}}for(let i=np-3;i>=0;i--){let s=new Linea2(pt[i],pt[i+1]),p=linea.interseca(s);if(p&&s.onsegment(p))return pt=pt.slice(0,i+1),pt.push(p),this}return this},removeduplicate(delta=.005){return pt=removeduplicate(pt,delta),this},to3d(u0,alt=0,coeffa=0,coeffb=0,open=!1,sh=null,invert=!1){let tm=function to3dcoor(path,options){let{currentU:currentU=0,c:c=0,a:a=0,b:b=0,anglemin:anglemin=30,open:open=!1,sh:sh=null,invert:invert=!1}=options;const pointsWithNormals=[],n=path.length;for(let i=0;i<n;i++){const prev=path[(i-1+n)%n],current=path[i],next=path[(i+1)%n],vPrev={x:current.x-prev.x,y:current.y-prev.y},vNext={x:next.x-current.x,y:next.y-current.y},normalPrev=normal2(prev,current),normalNext=normal2(current,next),angle=angle2vec(vPrev,vNext);let z=a*current.x+b*current.y+c;if(sh){let t=sh.xfromy(current.y,0,!0);invert?z+=t:z-=t}Math.abs(angle-180)<=anglemin?(normalPrev.nx,normalNext.nx,normalPrev.ny,normalNext.ny,pointsWithNormals.push({x:current.x,y:-current.y,z:z,u:currentU,v:z})):(pointsWithNormals.push({x:current.x,y:-current.y,z:z,u:currentU,v:z}),pointsWithNormals.push({x:current.x,y:-current.y,z:z,u:currentU,v:z}));const dx=next.x-current.x,dy=next.y-current.y;currentU+=Math.sqrt(dx*dx+dy*dy)}if(!open){let p=pointsWithNormals[0],pf=pointsWithNormals[pointsWithNormals.length-1];p.x==pf.x&&p.y==pf.y||pointsWithNormals.push({x:p.x,y:p.y,z:p.z,nx:p.nx,ny:p.ny,nz:p.nz,u:currentU,v:p.z})}return pointsWithNormals}(pt,{open:open,currentU:u0,c:alt,a:coeffa,b:coeffb,anglemin:30,sh:sh,invert:invert});return tm},getboundbox:()=>pt.length?pt.reduce(((box,p)=>(box.p1.x=Math.min(box.p1.x,p.x),box.p1.y=Math.min(box.p1.y,p.y),box.p2.x=Math.max(box.p2.x,p.x),box.p2.y=Math.max(box.p2.y,p.y),box)),{p1:new Punto2(1/0,1/0),p2:new Punto2(-1/0,-1/0)}):{p1:new Punto2(0,0),p2:new Punto2(0,0)},fittobox(p1,p2){if(!pt.length)return this;const currentBox=this.getboundbox(),currentWidth=currentBox.p2.x-currentBox.p1.x,currentHeight=currentBox.p2.y-currentBox.p1.y,targetWidth=p2.x-p1.x,targetHeight=p2.y-p1.y,scale=Math.min(targetWidth/(currentWidth||1),targetHeight/(currentHeight||1));for(let p of pt)p.x=(p.x-currentBox.p1.x)*scale,p.y=(p.y-currentBox.p1.y)*scale,p.x+=p1.x,p.y+=p1.y;return this}}}
290
- /**
291
- * Calcola i punti di un arco passante per tre punti
292
- * @param {number} segments - Numero di segmenti (punti-1)
293
- * @param {Punto2} p1 - Punto iniziale
294
- * @param {Punto2} p2 - Punto intermedio
295
- * @param {Punto2} p3 - Punto finale
296
- * @returns {Array<Punto2>} Array di punti che formano l'arco
297
- */function arcfrom3point(segments,p1,p2,p3){if(segments<=0)return[p1,p3];if(1===segments)return[p1,p2,p3];const center=function findCircleCenter(p1,p2,p3){const t=p2.x*p2.x+p2.y*p2.y,bc=(p1.x*p1.x+p1.y*p1.y-t)/2,cd=(t-p3.x*p3.x-p3.y*p3.y)/2,det=(p1.x-p2.x)*(p2.y-p3.y)-(p2.x-p3.x)*(p1.y-p2.y);return Math.abs(det)<1e-10?null:new Punto2((bc*(p2.y-p3.y)-cd*(p1.y-p2.y))/det,((p1.x-p2.x)*cd-(p2.x-p3.x)*bc)/det)}(p1,p2,p3);if(!center){const pts=[];for(let i=0;i<=segments;i++){const t=i/segments;pts.push(new Punto2(p1.x+(p3.x-p1.x)*t,p1.y+(p3.y-p1.y)*t))}return pts}let start=Math.atan2(p1.y-center.y,p1.x-center.x);Math.atan2(p2.y-center.y,p2.x-center.x);let end=Math.atan2(p3.y-center.y,p3.x-center.x);const cross=(p2.x-p1.x)*(p3.y-p1.y)-(p2.y-p1.y)*(p3.x-p1.x),norm=a=>(a+2*Math.PI)%(2*Math.PI);start=norm(start),end=norm(end),cross>0?end<start&&(end+=2*Math.PI):end>start&&(end-=2*Math.PI);const radius=Math.hypot(p1.x-center.x,p1.y-center.y),delta=(end-start)/segments,points=[];for(let i=0;i<=segments;i++){const angle=start+delta*i;points.push(new Punto2(center.x+radius*Math.cos(angle),center.y+radius*Math.sin(angle)))}return points}function getDefaultExportFromCjs(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}var module,clipper={exports:{}};
298
- /*******************************************************************************
299
- * *
300
- * Author : Angus Johnson *
301
- * Version : 6.4.2 *
302
- * Date : 27 February 2017 *
303
- * Website : http://www.angusj.com *
304
- * Copyright : Angus Johnson 2010-2017 *
305
- * *
306
- * License: *
307
- * Use, modification & distribution is subject to Boost Software License Ver 1. *
308
- * http://www.boost.org/LICENSE_1_0.txt *
309
- * *
310
- * Attributions: *
311
- * The code in this library is an extension of Bala Vatti's clipping algorithm: *
312
- * "A generic solution to polygon clipping" *
313
- * Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63. *
314
- * http://portal.acm.org/citation.cfm?id=129906 *
315
- * *
316
- * Computer graphics and geometric modeling: implementation and algorithms *
317
- * By Max K. Agoston *
318
- * Springer; 1 edition (January 4, 2005) *
319
- * http://books.google.com/books?q=vatti+clipping+agoston *
320
- * *
321
- * See also: *
322
- * "Polygon Offsetting by Computing Winding Numbers" *
323
- * Paper no. DETC2005-85513 pp. 565-575 *
324
- * ASME 2005 International Design Engineering Technical Conferences *
325
- * and Computers and Information in Engineering Conference (IDETC/CIE2005) *
326
- * September 24-28, 2005 , Long Beach, California, USA *
327
- * http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf *
328
- * *
329
- *******************************************************************************/module=clipper,
330
- /*******************************************************************************
331
- * *
332
- * Author : Timo *
333
- * Version : 6.4.2.2 *
334
- * Date : 8 September 2017 *
335
- * *
336
- * This is a translation of the C# Clipper library to Javascript. *
337
- * Int128 struct of C# is implemented using JSBN of Tom Wu. *
338
- * Because Javascript lacks support for 64-bit integers, the space *
339
- * is a little more restricted than in C# version. *
340
- * *
341
- * C# version has support for coordinate space: *
342
- * +-4611686018427387903 ( sqrt(2^127 -1)/2 ) *
343
- * while Javascript version has support for space: *
344
- * +-4503599627370495 ( sqrt(2^106 -1)/2 ) *
345
- * *
346
- * Tom Wu's JSBN proved to be the fastest big integer library: *
347
- * http://jsperf.com/big-integer-library-test *
348
- * *
349
- * This class can be made simpler when (if ever) 64-bit integer support comes *
350
- * or floating point Clipper is released. *
351
- * *
352
- *******************************************************************************/
353
- /*******************************************************************************
354
- * *
355
- * Basic JavaScript BN library - subset useful for RSA encryption. *
356
- * http://www-cs-students.stanford.edu/~tjw/jsbn/ *
357
- * Copyright (c) 2005 Tom Wu *
358
- * All Rights Reserved. *
359
- * See "LICENSE" for details: *
360
- * http://www-cs-students.stanford.edu/~tjw/jsbn/LICENSE *
361
- * *
362
- *******************************************************************************/
363
- function(){var navigator_appName,ClipperLib={version:"6.4.2.2",use_lines:!0,use_xyz:!1},isNode=!1;if(module.exports?(module.exports=ClipperLib,isNode=!0):"undefined"!=typeof document?window.ClipperLib=ClipperLib:self.ClipperLib=ClipperLib,isNode)nav="chrome",navigator_appName="Netscape";else{var nav=navigator.userAgent.toString().toLowerCase();navigator_appName=navigator.appName}var dbits,browser={};
364
- /**
365
- * @constructor
366
- */
367
- function BigInteger(a,b,c){ClipperLib.biginteger_used=1,null!=a&&("number"==typeof a&&void 0===b?this.fromInt(a):"number"==typeof a?this.fromNumber(a,b,c):null==b&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,b))}function nbi(){return new BigInteger(null,void 0,void 0)}-1!=nav.indexOf("chrome")&&-1==nav.indexOf("chromium")?browser.chrome=1:browser.chrome=0,-1!=nav.indexOf("chromium")?browser.chromium=1:browser.chromium=0,-1!=nav.indexOf("safari")&&-1==nav.indexOf("chrome")&&-1==nav.indexOf("chromium")?browser.safari=1:browser.safari=0,-1!=nav.indexOf("firefox")?browser.firefox=1:browser.firefox=0,-1!=nav.indexOf("firefox/17")?browser.firefox17=1:browser.firefox17=0,-1!=nav.indexOf("firefox/15")?browser.firefox15=1:browser.firefox15=0,-1!=nav.indexOf("firefox/3")?browser.firefox3=1:browser.firefox3=0,-1!=nav.indexOf("opera")?browser.opera=1:browser.opera=0,-1!=nav.indexOf("msie 10")?browser.msie10=1:browser.msie10=0,-1!=nav.indexOf("msie 9")?browser.msie9=1:browser.msie9=0,-1!=nav.indexOf("msie 8")?browser.msie8=1:browser.msie8=0,-1!=nav.indexOf("msie 7")?browser.msie7=1:browser.msie7=0,-1!=nav.indexOf("msie ")?browser.msie=1:browser.msie=0,ClipperLib.biginteger_used=null,"Microsoft Internet Explorer"==navigator_appName?(BigInteger.prototype.am=function am2(i,x,w,j,c,n){for(var xl=32767&x,xh=x>>15;--n>=0;){var l=32767&this[i],h=this[i++]>>15,m=xh*l+h*xl;c=((l=xl*l+((32767&m)<<15)+w[j]+(1073741823&c))>>>30)+(m>>>15)+xh*h+(c>>>30),w[j++]=1073741823&l}return c},dbits=30):"Netscape"!=navigator_appName?(BigInteger.prototype.am=function am1(i,x,w,j,c,n){for(;--n>=0;){var v=x*this[i++]+w[j]+c;c=Math.floor(v/67108864),w[j++]=67108863&v}return c},dbits=26):(BigInteger.prototype.am=function am3(i,x,w,j,c,n){for(var xl=16383&x,xh=x>>14;--n>=0;){var l=16383&this[i],h=this[i++]>>14,m=xh*l+h*xl;c=((l=xl*l+((16383&m)<<14)+w[j]+c)>>28)+(m>>14)+xh*h,w[j++]=268435455&l}return c},dbits=28),BigInteger.prototype.DB=dbits,BigInteger.prototype.DM=(1<<dbits)-1,BigInteger.prototype.DV=1<<dbits,BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=52-dbits,BigInteger.prototype.F2=2*dbits-52;var rr,vv,BI_RC=new Array;for(rr="0".charCodeAt(0),vv=0;vv<=9;++vv)BI_RC[rr++]=vv;for(rr="a".charCodeAt(0),vv=10;vv<36;++vv)BI_RC[rr++]=vv;for(rr="A".charCodeAt(0),vv=10;vv<36;++vv)BI_RC[rr++]=vv;function int2char(n){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(n)}function intAt(s,i){var c=BI_RC[s.charCodeAt(i)];return null==c?-1:c}function nbv(i){var r=nbi();return r.fromInt(i),r}function nbits(x){var t,r=1;return 0!=(t=x>>>16)&&(x=t,r+=16),0!=(t=x>>8)&&(x=t,r+=8),0!=(t=x>>4)&&(x=t,r+=4),0!=(t=x>>2)&&(x=t,r+=2),0!=(t=x>>1)&&(x=t,r+=1),r}
368
- /**
369
- * @constructor
370
- */
371
- function Classic(m){this.m=m}
372
- /**
373
- * @constructor
374
- */
375
- function Montgomery(m){this.m=m,this.mp=m.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<m.DB-15)-1,this.mt2=2*m.t}function op_and(x,y){return x&y}function op_or(x,y){return x|y}function op_xor(x,y){return x^y}function op_andnot(x,y){return x&~y}function lbit(x){if(0==x)return-1;var r=0;return 65535&x||(x>>=16,r+=16),255&x||(x>>=8,r+=8),15&x||(x>>=4,r+=4),3&x||(x>>=2,r+=2),1&x||++r,r}function cbit(x){for(var r=0;0!=x;)x&=x-1,++r;return r}
376
- /**
377
- * @constructor
378
- */
379
- function NullExp(){}function nNop(x){return x}
380
- /**
381
- * @constructor
382
- */
383
- function Barrett(m){this.r2=nbi(),this.q3=nbi(),BigInteger.ONE.dlShiftTo(2*m.t,this.r2),this.mu=this.r2.divide(m),this.m=m}Classic.prototype.convert=function cConvert(x){return x.s<0||x.compareTo(this.m)>=0?x.mod(this.m):x},Classic.prototype.revert=function cRevert(x){return x},Classic.prototype.reduce=function cReduce(x){x.divRemTo(this.m,null,x)},Classic.prototype.mulTo=function cMulTo(x,y,r){x.multiplyTo(y,r),this.reduce(r)},Classic.prototype.sqrTo=function cSqrTo(x,r){x.squareTo(r),this.reduce(r)},Montgomery.prototype.convert=function montConvert(x){var r=nbi();return x.abs().dlShiftTo(this.m.t,r),r.divRemTo(this.m,null,r),x.s<0&&r.compareTo(BigInteger.ZERO)>0&&this.m.subTo(r,r),r},Montgomery.prototype.revert=function montRevert(x){var r=nbi();return x.copyTo(r),this.reduce(r),r},Montgomery.prototype.reduce=function montReduce(x){for(;x.t<=this.mt2;)x[x.t++]=0;for(var i=0;i<this.m.t;++i){var j=32767&x[i],u0=j*this.mpl+((j*this.mph+(x[i]>>15)*this.mpl&this.um)<<15)&x.DM;for(x[j=i+this.m.t]+=this.m.am(0,u0,x,i,0,this.m.t);x[j]>=x.DV;)x[j]-=x.DV,x[++j]++}x.clamp(),x.drShiftTo(this.m.t,x),x.compareTo(this.m)>=0&&x.subTo(this.m,x)},Montgomery.prototype.mulTo=function montMulTo(x,y,r){x.multiplyTo(y,r),this.reduce(r)},Montgomery.prototype.sqrTo=function montSqrTo(x,r){x.squareTo(r),this.reduce(r)},BigInteger.prototype.copyTo=function bnpCopyTo(r){for(var i=this.t-1;i>=0;--i)r[i]=this[i];r.t=this.t,r.s=this.s},BigInteger.prototype.fromInt=function bnpFromInt(x){this.t=1,this.s=x<0?-1:0,x>0?this[0]=x:x<-1?this[0]=x+this.DV:this.t=0},BigInteger.prototype.fromString=function bnpFromString(s,b){var k;if(16==b)k=4;else if(8==b)k=3;else if(256==b)k=8;else if(2==b)k=1;else if(32==b)k=5;else{if(4!=b)return void this.fromRadix(s,b);k=2}this.t=0,this.s=0;for(var i=s.length,mi=!1,sh=0;--i>=0;){var x=8==k?255&s[i]:intAt(s,i);x<0?"-"==s.charAt(i)&&(mi=!0):(mi=!1,0==sh?this[this.t++]=x:sh+k>this.DB?(this[this.t-1]|=(x&(1<<this.DB-sh)-1)<<sh,this[this.t++]=x>>this.DB-sh):this[this.t-1]|=x<<sh,(sh+=k)>=this.DB&&(sh-=this.DB))}8==k&&128&s[0]&&(this.s=-1,sh>0&&(this[this.t-1]|=(1<<this.DB-sh)-1<<sh)),this.clamp(),mi&&BigInteger.ZERO.subTo(this,this)},BigInteger.prototype.clamp=function bnpClamp(){for(var c=this.s&this.DM;this.t>0&&this[this.t-1]==c;)--this.t},BigInteger.prototype.dlShiftTo=function bnpDLShiftTo(n,r){var i;for(i=this.t-1;i>=0;--i)r[i+n]=this[i];for(i=n-1;i>=0;--i)r[i]=0;r.t=this.t+n,r.s=this.s},BigInteger.prototype.drShiftTo=function bnpDRShiftTo(n,r){for(var i=n;i<this.t;++i)r[i-n]=this[i];r.t=Math.max(this.t-n,0),r.s=this.s},BigInteger.prototype.lShiftTo=function bnpLShiftTo(n,r){var i,bs=n%this.DB,cbs=this.DB-bs,bm=(1<<cbs)-1,ds=Math.floor(n/this.DB),c=this.s<<bs&this.DM;for(i=this.t-1;i>=0;--i)r[i+ds+1]=this[i]>>cbs|c,c=(this[i]&bm)<<bs;for(i=ds-1;i>=0;--i)r[i]=0;r[ds]=c,r.t=this.t+ds+1,r.s=this.s,r.clamp()},BigInteger.prototype.rShiftTo=function bnpRShiftTo(n,r){r.s=this.s;var ds=Math.floor(n/this.DB);if(ds>=this.t)r.t=0;else{var bs=n%this.DB,cbs=this.DB-bs,bm=(1<<bs)-1;r[0]=this[ds]>>bs;for(var i=ds+1;i<this.t;++i)r[i-ds-1]|=(this[i]&bm)<<cbs,r[i-ds]=this[i]>>bs;bs>0&&(r[this.t-ds-1]|=(this.s&bm)<<cbs),r.t=this.t-ds,r.clamp()}},BigInteger.prototype.subTo=function bnpSubTo(a,r){for(var i=0,c=0,m=Math.min(a.t,this.t);i<m;)c+=this[i]-a[i],r[i++]=c&this.DM,c>>=this.DB;if(a.t<this.t){for(c-=a.s;i<this.t;)c+=this[i],r[i++]=c&this.DM,c>>=this.DB;c+=this.s}else{for(c+=this.s;i<a.t;)c-=a[i],r[i++]=c&this.DM,c>>=this.DB;c-=a.s}r.s=c<0?-1:0,c<-1?r[i++]=this.DV+c:c>0&&(r[i++]=c),r.t=i,r.clamp()},BigInteger.prototype.multiplyTo=function bnpMultiplyTo(a,r){var x=this.abs(),y=a.abs(),i=x.t;for(r.t=i+y.t;--i>=0;)r[i]=0;for(i=0;i<y.t;++i)r[i+x.t]=x.am(0,y[i],r,i,0,x.t);r.s=0,r.clamp(),this.s!=a.s&&BigInteger.ZERO.subTo(r,r)},BigInteger.prototype.squareTo=function bnpSquareTo(r){for(var x=this.abs(),i=r.t=2*x.t;--i>=0;)r[i]=0;for(i=0;i<x.t-1;++i){var c=x.am(i,x[i],r,2*i,0,1);(r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1))>=x.DV&&(r[i+x.t]-=x.DV,r[i+x.t+1]=1)}r.t>0&&(r[r.t-1]+=x.am(i,x[i],r,2*i,0,1)),r.s=0,r.clamp()},BigInteger.prototype.divRemTo=function bnpDivRemTo(m,q,r){var pm=m.abs();if(!(pm.t<=0)){var pt=this.abs();if(pt.t<pm.t)return null!=q&&q.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=nbi());var y=nbi(),ts=this.s,ms=m.s,nsh=this.DB-nbits(pm[pm.t-1]);nsh>0?(pm.lShiftTo(nsh,y),pt.lShiftTo(nsh,r)):(pm.copyTo(y),pt.copyTo(r));var ys=y.t,y0=y[ys-1];if(0!=y0){var yt=y0*(1<<this.F1)+(ys>1?y[ys-2]>>this.F2:0),d1=this.FV/yt,d2=(1<<this.F1)/yt,e=1<<this.F2,i=r.t,j=i-ys,t=null==q?nbi():q;for(y.dlShiftTo(j,t),r.compareTo(t)>=0&&(r[r.t++]=1,r.subTo(t,r)),BigInteger.ONE.dlShiftTo(ys,t),t.subTo(y,y);y.t<ys;)y[y.t++]=0;for(;--j>=0;){var qd=r[--i]==y0?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);if((r[i]+=y.am(0,qd,r,j,0,ys))<qd)for(y.dlShiftTo(j,t),r.subTo(t,r);r[i]<--qd;)r.subTo(t,r)}null!=q&&(r.drShiftTo(ys,q),ts!=ms&&BigInteger.ZERO.subTo(q,q)),r.t=ys,r.clamp(),nsh>0&&r.rShiftTo(nsh,r),ts<0&&BigInteger.ZERO.subTo(r,r)}}},BigInteger.prototype.invDigit=function bnpInvDigit(){if(this.t<1)return 0;var x=this[0];if(!(1&x))return 0;var y=3&x;return(y=(y=(y=(y=y*(2-(15&x)*y)&15)*(2-(255&x)*y)&255)*(2-((65535&x)*y&65535))&65535)*(2-x*y%this.DV)%this.DV)>0?this.DV-y:-y},BigInteger.prototype.isEven=function bnpIsEven(){return 0==(this.t>0?1&this[0]:this.s)},BigInteger.prototype.exp=function bnpExp(e,z){if(e>4294967295||e<1)return BigInteger.ONE;var r=nbi(),r2=nbi(),g=z.convert(this),i=nbits(e)-1;for(g.copyTo(r);--i>=0;)if(z.sqrTo(r,r2),(e&1<<i)>0)z.mulTo(r2,g,r);else{var t=r;r=r2,r2=t}return z.revert(r)},BigInteger.prototype.toString=function bnToString(b){if(this.s<0)return"-"+this.negate().toString(b);var k;if(16==b)k=4;else if(8==b)k=3;else if(2==b)k=1;else if(32==b)k=5;else{if(4!=b)return this.toRadix(b);k=2}var d,km=(1<<k)-1,m=!1,r="",i=this.t,p=this.DB-i*this.DB%k;if(i-- >0)for(p<this.DB&&(d=this[i]>>p)>0&&(m=!0,r=int2char(d));i>=0;)p<k?(d=(this[i]&(1<<p)-1)<<k-p,d|=this[--i]>>(p+=this.DB-k)):(d=this[i]>>(p-=k)&km,p<=0&&(p+=this.DB,--i)),d>0&&(m=!0),m&&(r+=int2char(d));return m?r:"0"},BigInteger.prototype.negate=function bnNegate(){var r=nbi();return BigInteger.ZERO.subTo(this,r),r},BigInteger.prototype.abs=function bnAbs(){return this.s<0?this.negate():this},BigInteger.prototype.compareTo=function bnCompareTo(a){var r=this.s-a.s;if(0!=r)return r;var i=this.t;if(0!=(r=i-a.t))return this.s<0?-r:r;for(;--i>=0;)if(0!=(r=this[i]-a[i]))return r;return 0},BigInteger.prototype.bitLength=function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)},BigInteger.prototype.mod=function bnMod(a){var r=nbi();return this.abs().divRemTo(a,null,r),this.s<0&&r.compareTo(BigInteger.ZERO)>0&&a.subTo(r,r),r},BigInteger.prototype.modPowInt=function bnModPowInt(e,m){var z;return z=e<256||m.isEven()?new Classic(m):new Montgomery(m),this.exp(e,z)},BigInteger.ZERO=nbv(0),BigInteger.ONE=nbv(1),NullExp.prototype.convert=nNop,NullExp.prototype.revert=nNop,NullExp.prototype.mulTo=function nMulTo(x,y,r){x.multiplyTo(y,r)},NullExp.prototype.sqrTo=function nSqrTo(x,r){x.squareTo(r)},Barrett.prototype.convert=function barrettConvert(x){if(x.s<0||x.t>2*this.m.t)return x.mod(this.m);if(x.compareTo(this.m)<0)return x;var r=nbi();return x.copyTo(r),this.reduce(r),r},Barrett.prototype.revert=function barrettRevert(x){return x},Barrett.prototype.reduce=function barrettReduce(x){for(x.drShiftTo(this.m.t-1,this.r2),x.t>this.m.t+1&&(x.t=this.m.t+1,x.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);x.compareTo(this.r2)<0;)x.dAddOffset(1,this.m.t+1);for(x.subTo(this.r2,x);x.compareTo(this.m)>=0;)x.subTo(this.m,x)},Barrett.prototype.mulTo=function barrettMulTo(x,y,r){x.multiplyTo(y,r),this.reduce(r)},Barrett.prototype.sqrTo=function barrettSqrTo(x,r){x.squareTo(r),this.reduce(r)};var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],lplim=(1<<26)/lowprimes[lowprimes.length-1];BigInteger.prototype.chunkSize=function bnpChunkSize(r){return Math.floor(Math.LN2*this.DB/Math.log(r))},BigInteger.prototype.toRadix=function bnpToRadix(b){if(null==b&&(b=10),0==this.signum()||b<2||b>36)return"0";var cs=this.chunkSize(b),a=Math.pow(b,cs),d=nbv(a),y=nbi(),z=nbi(),r="";for(this.divRemTo(d,y,z);y.signum()>0;)r=(a+z.intValue()).toString(b).substr(1)+r,y.divRemTo(d,y,z);return z.intValue().toString(b)+r},BigInteger.prototype.fromRadix=function bnpFromRadix(s,b){this.fromInt(0),null==b&&(b=10);for(var cs=this.chunkSize(b),d=Math.pow(b,cs),mi=!1,j=0,w=0,i=0;i<s.length;++i){var x=intAt(s,i);x<0?"-"==s.charAt(i)&&0==this.signum()&&(mi=!0):(w=b*w+x,++j>=cs&&(this.dMultiply(d),this.dAddOffset(w,0),j=0,w=0))}j>0&&(this.dMultiply(Math.pow(b,j)),this.dAddOffset(w,0)),mi&&BigInteger.ZERO.subTo(this,this)},BigInteger.prototype.fromNumber=function bnpFromNumber(a,b,c){if("number"==typeof b)if(a<2)this.fromInt(1);else for(this.fromNumber(a,c),this.testBit(a-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(b);)this.dAddOffset(2,0),this.bitLength()>a&&this.subTo(BigInteger.ONE.shiftLeft(a-1),this);else{var x=new Array,t=7&a;x.length=1+(a>>3),b.nextBytes(x),t>0?x[0]&=(1<<t)-1:x[0]=0,this.fromString(x,256)}},BigInteger.prototype.bitwiseTo=function bnpBitwiseTo(a,op,r){var i,f,m=Math.min(a.t,this.t);for(i=0;i<m;++i)r[i]=op(this[i],a[i]);if(a.t<this.t){for(f=a.s&this.DM,i=m;i<this.t;++i)r[i]=op(this[i],f);r.t=this.t}else{for(f=this.s&this.DM,i=m;i<a.t;++i)r[i]=op(f,a[i]);r.t=a.t}r.s=op(this.s,a.s),r.clamp()},BigInteger.prototype.changeBit=function bnpChangeBit(n,op){var r=BigInteger.ONE.shiftLeft(n);return this.bitwiseTo(r,op,r),r},BigInteger.prototype.addTo=function bnpAddTo(a,r){for(var i=0,c=0,m=Math.min(a.t,this.t);i<m;)c+=this[i]+a[i],r[i++]=c&this.DM,c>>=this.DB;if(a.t<this.t){for(c+=a.s;i<this.t;)c+=this[i],r[i++]=c&this.DM,c>>=this.DB;c+=this.s}else{for(c+=this.s;i<a.t;)c+=a[i],r[i++]=c&this.DM,c>>=this.DB;c+=a.s}r.s=c<0?-1:0,c>0?r[i++]=c:c<-1&&(r[i++]=this.DV+c),r.t=i,r.clamp()},BigInteger.prototype.dMultiply=function bnpDMultiply(n){this[this.t]=this.am(0,n-1,this,0,0,this.t),++this.t,this.clamp()},BigInteger.prototype.dAddOffset=function bnpDAddOffset(n,w){if(0!=n){for(;this.t<=w;)this[this.t++]=0;for(this[w]+=n;this[w]>=this.DV;)this[w]-=this.DV,++w>=this.t&&(this[this.t++]=0),++this[w]}},BigInteger.prototype.multiplyLowerTo=function bnpMultiplyLowerTo(a,n,r){var j,i=Math.min(this.t+a.t,n);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(j=r.t-this.t;i<j;++i)r[i+this.t]=this.am(0,a[i],r,i,0,this.t);for(j=Math.min(a.t,n);i<j;++i)this.am(0,a[i],r,i,0,n-i);r.clamp()},BigInteger.prototype.multiplyUpperTo=function bnpMultiplyUpperTo(a,n,r){--n;var i=r.t=this.t+a.t-n;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(n-this.t,0);i<a.t;++i)r[this.t+i-n]=this.am(n-i,a[i],r,0,0,this.t+i-n);r.clamp(),r.drShiftTo(1,r)},BigInteger.prototype.modInt=function bnpModInt(n){if(n<=0)return 0;var d=this.DV%n,r=this.s<0?n-1:0;if(this.t>0)if(0==d)r=this[0]%n;else for(var i=this.t-1;i>=0;--i)r=(d*r+this[i])%n;return r},BigInteger.prototype.millerRabin=function bnpMillerRabin(t){var n1=this.subtract(BigInteger.ONE),k=n1.getLowestSetBit();if(k<=0)return!1;var r=n1.shiftRight(k);(t=t+1>>1)>lowprimes.length&&(t=lowprimes.length);for(var a=nbi(),i=0;i<t;++i){a.fromInt(lowprimes[Math.floor(Math.random()*lowprimes.length)]);var y=a.modPow(r,this);if(0!=y.compareTo(BigInteger.ONE)&&0!=y.compareTo(n1)){for(var j=1;j++<k&&0!=y.compareTo(n1);)if(0==(y=y.modPowInt(2,this)).compareTo(BigInteger.ONE))return!1;if(0!=y.compareTo(n1))return!1}}return!0},BigInteger.prototype.clone=function bnClone(){var r=nbi();return this.copyTo(r),r},BigInteger.prototype.intValue=function bnIntValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},BigInteger.prototype.byteValue=function bnByteValue(){return 0==this.t?this.s:this[0]<<24>>24},BigInteger.prototype.shortValue=function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16},BigInteger.prototype.signum=function bnSigNum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},BigInteger.prototype.toByteArray=function bnToByteArray(){var i=this.t,r=new Array;r[0]=this.s;var d,p=this.DB-i*this.DB%8,k=0;if(i-- >0)for(p<this.DB&&(d=this[i]>>p)!=(this.s&this.DM)>>p&&(r[k++]=d|this.s<<this.DB-p);i>=0;)p<8?(d=(this[i]&(1<<p)-1)<<8-p,d|=this[--i]>>(p+=this.DB-8)):(d=this[i]>>(p-=8)&255,p<=0&&(p+=this.DB,--i)),128&d&&(d|=-256),0==k&&(128&this.s)!=(128&d)&&++k,(k>0||d!=this.s)&&(r[k++]=d);return r},BigInteger.prototype.equals=function bnEquals(a){return 0==this.compareTo(a)},BigInteger.prototype.min=function bnMin(a){return this.compareTo(a)<0?this:a},BigInteger.prototype.max=function bnMax(a){return this.compareTo(a)>0?this:a},BigInteger.prototype.and=function bnAnd(a){var r=nbi();return this.bitwiseTo(a,op_and,r),r},BigInteger.prototype.or=function bnOr(a){var r=nbi();return this.bitwiseTo(a,op_or,r),r},BigInteger.prototype.xor=function bnXor(a){var r=nbi();return this.bitwiseTo(a,op_xor,r),r},BigInteger.prototype.andNot=function bnAndNot(a){var r=nbi();return this.bitwiseTo(a,op_andnot,r),r},BigInteger.prototype.not=function bnNot(){for(var r=nbi(),i=0;i<this.t;++i)r[i]=this.DM&~this[i];return r.t=this.t,r.s=~this.s,r},BigInteger.prototype.shiftLeft=function bnShiftLeft(n){var r=nbi();return n<0?this.rShiftTo(-n,r):this.lShiftTo(n,r),r},BigInteger.prototype.shiftRight=function bnShiftRight(n){var r=nbi();return n<0?this.lShiftTo(-n,r):this.rShiftTo(n,r),r},BigInteger.prototype.getLowestSetBit=function bnGetLowestSetBit(){for(var i=0;i<this.t;++i)if(0!=this[i])return i*this.DB+lbit(this[i]);return this.s<0?this.t*this.DB:-1},BigInteger.prototype.bitCount=function bnBitCount(){for(var r=0,x=this.s&this.DM,i=0;i<this.t;++i)r+=cbit(this[i]^x);return r},BigInteger.prototype.testBit=function bnTestBit(n){var j=Math.floor(n/this.DB);return j>=this.t?0!=this.s:!!(this[j]&1<<n%this.DB)},BigInteger.prototype.setBit=function bnSetBit(n){return this.changeBit(n,op_or)},BigInteger.prototype.clearBit=function bnClearBit(n){return this.changeBit(n,op_andnot)},BigInteger.prototype.flipBit=function bnFlipBit(n){return this.changeBit(n,op_xor)},BigInteger.prototype.add=function bnAdd(a){var r=nbi();return this.addTo(a,r),r},BigInteger.prototype.subtract=function bnSubtract(a){var r=nbi();return this.subTo(a,r),r},BigInteger.prototype.multiply=function bnMultiply(a){var r=nbi();return this.multiplyTo(a,r),r},BigInteger.prototype.divide=function bnDivide(a){var r=nbi();return this.divRemTo(a,r,null),r},BigInteger.prototype.remainder=function bnRemainder(a){var r=nbi();return this.divRemTo(a,null,r),r},BigInteger.prototype.divideAndRemainder=function bnDivideAndRemainder(a){var q=nbi(),r=nbi();return this.divRemTo(a,q,r),new Array(q,r)},BigInteger.prototype.modPow=function bnModPow(e,m){var k,z,i=e.bitLength(),r=nbv(1);if(i<=0)return r;k=i<18?1:i<48?3:i<144?4:i<768?5:6,z=i<8?new Classic(m):m.isEven()?new Barrett(m):new Montgomery(m);var g=new Array,n=3,k1=k-1,km=(1<<k)-1;if(g[1]=z.convert(this),k>1){var g2=nbi();for(z.sqrTo(g[1],g2);n<=km;)g[n]=nbi(),z.mulTo(g2,g[n-2],g[n]),n+=2}var w,t,j=e.t-1,is1=!0,r2=nbi();for(i=nbits(e[j])-1;j>=0;){for(i>=k1?w=e[j]>>i-k1&km:(w=(e[j]&(1<<i+1)-1)<<k1-i,j>0&&(w|=e[j-1]>>this.DB+i-k1)),n=k;!(1&w);)w>>=1,--n;if((i-=n)<0&&(i+=this.DB,--j),is1)g[w].copyTo(r),is1=!1;else{for(;n>1;)z.sqrTo(r,r2),z.sqrTo(r2,r),n-=2;n>0?z.sqrTo(r,r2):(t=r,r=r2,r2=t),z.mulTo(r2,g[w],r)}for(;j>=0&&!(e[j]&1<<i);)z.sqrTo(r,r2),t=r,r=r2,r2=t,--i<0&&(i=this.DB-1,--j)}return z.revert(r)},BigInteger.prototype.modInverse=function bnModInverse(m){var ac=m.isEven();if(this.isEven()&&ac||0==m.signum())return BigInteger.ZERO;for(var u=m.clone(),v=this.clone(),a=nbv(1),b=nbv(0),c=nbv(0),d=nbv(1);0!=u.signum();){for(;u.isEven();)u.rShiftTo(1,u),ac?(a.isEven()&&b.isEven()||(a.addTo(this,a),b.subTo(m,b)),a.rShiftTo(1,a)):b.isEven()||b.subTo(m,b),b.rShiftTo(1,b);for(;v.isEven();)v.rShiftTo(1,v),ac?(c.isEven()&&d.isEven()||(c.addTo(this,c),d.subTo(m,d)),c.rShiftTo(1,c)):d.isEven()||d.subTo(m,d),d.rShiftTo(1,d);u.compareTo(v)>=0?(u.subTo(v,u),ac&&a.subTo(c,a),b.subTo(d,b)):(v.subTo(u,v),ac&&c.subTo(a,c),d.subTo(b,d))}return 0!=v.compareTo(BigInteger.ONE)?BigInteger.ZERO:d.compareTo(m)>=0?d.subtract(m):d.signum()<0?(d.addTo(m,d),d.signum()<0?d.add(m):d):d},BigInteger.prototype.pow=function bnPow(e){return this.exp(e,new NullExp)},BigInteger.prototype.gcd=function bnGCD(a){var x=this.s<0?this.negate():this.clone(),y=a.s<0?a.negate():a.clone();if(x.compareTo(y)<0){var t=x;x=y,y=t}var i=x.getLowestSetBit(),g=y.getLowestSetBit();if(g<0)return x;for(i<g&&(g=i),g>0&&(x.rShiftTo(g,x),y.rShiftTo(g,y));x.signum()>0;)(i=x.getLowestSetBit())>0&&x.rShiftTo(i,x),(i=y.getLowestSetBit())>0&&y.rShiftTo(i,y),x.compareTo(y)>=0?(x.subTo(y,x),x.rShiftTo(1,x)):(y.subTo(x,y),y.rShiftTo(1,y));return g>0&&y.lShiftTo(g,y),y},BigInteger.prototype.isProbablePrime=function bnIsProbablePrime(t){var i,x=this.abs();if(1==x.t&&x[0]<=lowprimes[lowprimes.length-1]){for(i=0;i<lowprimes.length;++i)if(x[0]==lowprimes[i])return!0;return!1}if(x.isEven())return!1;for(i=1;i<lowprimes.length;){for(var m=lowprimes[i],j=i+1;j<lowprimes.length&&m<lplim;)m*=lowprimes[j++];for(m=x.modInt(m);i<j;)if(m%lowprimes[i++]==0)return!1}return x.millerRabin(t)},BigInteger.prototype.square=function bnSquare(){var r=nbi();return this.squareTo(r),r};var Int128=BigInteger;Int128.prototype.IsNegative=function(){return-1==this.compareTo(Int128.ZERO)},Int128.op_Equality=function(val1,val2){return 0==val1.compareTo(val2)},Int128.op_Inequality=function(val1,val2){return 0!=val1.compareTo(val2)},Int128.op_GreaterThan=function(val1,val2){return val1.compareTo(val2)>0},Int128.op_LessThan=function(val1,val2){return val1.compareTo(val2)<0},Int128.op_Addition=function(lhs,rhs){return new Int128(lhs,void 0,void 0).add(new Int128(rhs,void 0,void 0))},Int128.op_Subtraction=function(lhs,rhs){return new Int128(lhs,void 0,void 0).subtract(new Int128(rhs,void 0,void 0))},Int128.Int128Mul=function(lhs,rhs){return new Int128(lhs,void 0,void 0).multiply(new Int128(rhs,void 0,void 0))},Int128.op_Division=function(lhs,rhs){return lhs.divide(rhs)},Int128.prototype.ToDouble=function(){return parseFloat(this.toString())};var Inherit=function(ce,ce2){var p;if(void 0===Object.getOwnPropertyNames){for(p in ce2.prototype)void 0!==ce.prototype[p]&&ce.prototype[p]!==Object.prototype[p]||(ce.prototype[p]=ce2.prototype[p]);for(p in ce2)void 0===ce[p]&&(ce[p]=ce2[p]);ce.$baseCtor=ce2}else{for(var props=Object.getOwnPropertyNames(ce2.prototype),i=0;i<props.length;i++)void 0===Object.getOwnPropertyDescriptor(ce.prototype,props[i])&&Object.defineProperty(ce.prototype,props[i],Object.getOwnPropertyDescriptor(ce2.prototype,props[i]));for(p in ce2)void 0===ce[p]&&(ce[p]=ce2[p]);ce.$baseCtor=ce2}};
384
- /**
385
- * @constructor
386
- */ClipperLib.Path=function(){return[]},ClipperLib.Path.prototype.push=Array.prototype.push,
387
- /**
388
- * @constructor
389
- */
390
- ClipperLib.Paths=function(){return[]},ClipperLib.Paths.prototype.push=Array.prototype.push,
391
- /**
392
- * @constructor
393
- */
394
- ClipperLib.DoublePoint=function(){var a=arguments;this.X=0,this.Y=0,1===a.length?(this.X=a[0].X,this.Y=a[0].Y):2===a.length&&(this.X=a[0],this.Y=a[1])},
395
- /**
396
- * @constructor
397
- */
398
- ClipperLib.DoublePoint0=function(){this.X=0,this.Y=0},ClipperLib.DoublePoint0.prototype=ClipperLib.DoublePoint.prototype,
399
- /**
400
- * @constructor
401
- */
402
- ClipperLib.DoublePoint1=function(dp){this.X=dp.X,this.Y=dp.Y},ClipperLib.DoublePoint1.prototype=ClipperLib.DoublePoint.prototype,
403
- /**
404
- * @constructor
405
- */
406
- ClipperLib.DoublePoint2=function(x,y){this.X=x,this.Y=y},ClipperLib.DoublePoint2.prototype=ClipperLib.DoublePoint.prototype,
407
- /**
408
- * @suppress {missingProperties}
409
- */
410
- ClipperLib.PolyNode=function(){this.m_Parent=null,this.m_polygon=new ClipperLib.Path,this.m_Index=0,this.m_jointype=0,this.m_endtype=0,this.m_Childs=[],this.IsOpen=!1},ClipperLib.PolyNode.prototype.IsHoleNode=function(){for(var result=!0,node=this.m_Parent;null!==node;)result=!result,node=node.m_Parent;return result},ClipperLib.PolyNode.prototype.ChildCount=function(){return this.m_Childs.length},ClipperLib.PolyNode.prototype.Contour=function(){return this.m_polygon},ClipperLib.PolyNode.prototype.AddChild=function(Child){var cnt=this.m_Childs.length;this.m_Childs.push(Child),Child.m_Parent=this,Child.m_Index=cnt},ClipperLib.PolyNode.prototype.GetNext=function(){return this.m_Childs.length>0?this.m_Childs[0]:this.GetNextSiblingUp()},ClipperLib.PolyNode.prototype.GetNextSiblingUp=function(){return null===this.m_Parent?null:this.m_Index===this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+1]},ClipperLib.PolyNode.prototype.Childs=function(){return this.m_Childs},ClipperLib.PolyNode.prototype.Parent=function(){return this.m_Parent},ClipperLib.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()},
411
- /**
412
- * @suppress {missingProperties}
413
- * @constructor
414
- */
415
- ClipperLib.PolyTree=function(){this.m_AllPolys=[],ClipperLib.PolyNode.call(this)},ClipperLib.PolyTree.prototype.Clear=function(){for(var i=0,ilen=this.m_AllPolys.length;i<ilen;i++)this.m_AllPolys[i]=null;this.m_AllPolys.length=0,this.m_Childs.length=0},ClipperLib.PolyTree.prototype.GetFirst=function(){return this.m_Childs.length>0?this.m_Childs[0]:null},ClipperLib.PolyTree.prototype.Total=function(){var result=this.m_AllPolys.length;return result>0&&this.m_Childs[0]!==this.m_AllPolys[0]&&result--,result},Inherit(ClipperLib.PolyTree,ClipperLib.PolyNode),ClipperLib.Math_Abs_Int64=ClipperLib.Math_Abs_Int32=ClipperLib.Math_Abs_Double=function(a){return Math.abs(a)},ClipperLib.Math_Max_Int32_Int32=function(a,b){return Math.max(a,b)},browser.msie||browser.opera||browser.safari?ClipperLib.Cast_Int32=function(a){return 0|a}:ClipperLib.Cast_Int32=function(a){return~~a},void 0===Number.toInteger&&(Number.toInteger=null),browser.chrome?ClipperLib.Cast_Int64=function(a){return a<-2147483648||a>2147483647?a<0?Math.ceil(a):Math.floor(a):~~a}:browser.firefox&&"function"==typeof Number.toInteger?ClipperLib.Cast_Int64=function(a){return Number.toInteger(a)}:browser.msie7||browser.msie8?ClipperLib.Cast_Int64=function(a){return parseInt(a,10)}:browser.msie?ClipperLib.Cast_Int64=function(a){return a<-2147483648||a>2147483647?a<0?Math.ceil(a):Math.floor(a):0|a}:ClipperLib.Cast_Int64=function(a){return a<0?Math.ceil(a):Math.floor(a)},ClipperLib.Clear=function(a){a.length=0},ClipperLib.PI=3.141592653589793,ClipperLib.PI2=6.283185307179586,
416
- /**
417
- * @constructor
418
- */
419
- ClipperLib.IntPoint=function(){var a=arguments,alen=a.length;if(this.X=0,this.Y=0,ClipperLib.use_xyz)if(this.Z=0,3===alen)this.X=a[0],this.Y=a[1],this.Z=a[2];else if(2===alen)this.X=a[0],this.Y=a[1],this.Z=0;else if(1===alen)if(a[0]instanceof ClipperLib.DoublePoint){var dp=a[0];this.X=ClipperLib.Clipper.Round(dp.X),this.Y=ClipperLib.Clipper.Round(dp.Y),this.Z=0}else void 0===(pt=a[0]).Z&&(pt.Z=0),this.X=pt.X,this.Y=pt.Y,this.Z=pt.Z;else this.X=0,this.Y=0,this.Z=0;else if(2===alen)this.X=a[0],this.Y=a[1];else if(1===alen)if(a[0]instanceof ClipperLib.DoublePoint)dp=a[0],this.X=ClipperLib.Clipper.Round(dp.X),this.Y=ClipperLib.Clipper.Round(dp.Y);else{var pt=a[0];this.X=pt.X,this.Y=pt.Y}else this.X=0,this.Y=0},ClipperLib.IntPoint.op_Equality=function(a,b){return a.X===b.X&&a.Y===b.Y},ClipperLib.IntPoint.op_Inequality=function(a,b){return a.X!==b.X||a.Y!==b.Y},
420
- /**
421
- * @constructor
422
- */
423
- ClipperLib.IntPoint0=function(){this.X=0,this.Y=0,ClipperLib.use_xyz&&(this.Z=0)},ClipperLib.IntPoint0.prototype=ClipperLib.IntPoint.prototype,
424
- /**
425
- * @constructor
426
- */
427
- ClipperLib.IntPoint1=function(pt){this.X=pt.X,this.Y=pt.Y,ClipperLib.use_xyz&&(void 0===pt.Z?this.Z=0:this.Z=pt.Z)},ClipperLib.IntPoint1.prototype=ClipperLib.IntPoint.prototype,
428
- /**
429
- * @constructor
430
- */
431
- ClipperLib.IntPoint1dp=function(dp){this.X=ClipperLib.Clipper.Round(dp.X),this.Y=ClipperLib.Clipper.Round(dp.Y),ClipperLib.use_xyz&&(this.Z=0)},ClipperLib.IntPoint1dp.prototype=ClipperLib.IntPoint.prototype,
432
- /**
433
- * @constructor
434
- */
435
- ClipperLib.IntPoint2=function(x,y,z){this.X=x,this.Y=y,ClipperLib.use_xyz&&(this.Z=void 0===z?0:z)},ClipperLib.IntPoint2.prototype=ClipperLib.IntPoint.prototype,
436
- /**
437
- * @constructor
438
- */
439
- ClipperLib.IntRect=function(){var a=arguments,alen=a.length;if(4===alen)this.left=a[0],this.top=a[1],this.right=a[2],this.bottom=a[3];else if(1===alen){var ir=a[0];this.left=ir.left,this.top=ir.top,this.right=ir.right,this.bottom=ir.bottom}else this.left=0,this.top=0,this.right=0,this.bottom=0},
440
- /**
441
- * @constructor
442
- */
443
- ClipperLib.IntRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0},ClipperLib.IntRect0.prototype=ClipperLib.IntRect.prototype,
444
- /**
445
- * @constructor
446
- */
447
- ClipperLib.IntRect1=function(ir){this.left=ir.left,this.top=ir.top,this.right=ir.right,this.bottom=ir.bottom},ClipperLib.IntRect1.prototype=ClipperLib.IntRect.prototype,
448
- /**
449
- * @constructor
450
- */
451
- ClipperLib.IntRect4=function(l,t,r,b){this.left=l,this.top=t,this.right=r,this.bottom=b},ClipperLib.IntRect4.prototype=ClipperLib.IntRect.prototype,ClipperLib.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},ClipperLib.PolyType={ptSubject:0,ptClip:1},ClipperLib.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},ClipperLib.JoinType={jtSquare:0,jtRound:1,jtMiter:2},ClipperLib.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},ClipperLib.EdgeSide={esLeft:0,esRight:1},ClipperLib.Direction={dRightToLeft:0,dLeftToRight:1},
452
- /**
453
- * @constructor
454
- */
455
- ClipperLib.TEdge=function(){this.Bot=new ClipperLib.IntPoint0,this.Curr=new ClipperLib.IntPoint0,this.Top=new ClipperLib.IntPoint0,this.Delta=new ClipperLib.IntPoint0,this.Dx=0,this.PolyTyp=ClipperLib.PolyType.ptSubject,this.Side=ClipperLib.EdgeSide.esLeft,this.WindDelta=0,this.WindCnt=0,this.WindCnt2=0,this.OutIdx=0,this.Next=null,this.Prev=null,this.NextInLML=null,this.NextInAEL=null,this.PrevInAEL=null,this.NextInSEL=null,this.PrevInSEL=null},
456
- /**
457
- * @constructor
458
- */
459
- ClipperLib.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new ClipperLib.IntPoint0},ClipperLib.MyIntersectNodeSort=function(){},ClipperLib.MyIntersectNodeSort.Compare=function(node1,node2){var i=node2.Pt.Y-node1.Pt.Y;return i>0?1:i<0?-1:0},
460
- /**
461
- * @constructor
462
- */
463
- ClipperLib.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null},
464
- /**
465
- * @constructor
466
- */
467
- ClipperLib.Scanbeam=function(){this.Y=0,this.Next=null},
468
- /**
469
- * @constructor
470
- */
471
- ClipperLib.Maxima=function(){this.X=0,this.Next=null,this.Prev=null},
472
- /**
473
- * @constructor
474
- */
475
- ClipperLib.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null},
476
- /**
477
- * @constructor
478
- */
479
- ClipperLib.OutPt=function(){this.Idx=0,this.Pt=new ClipperLib.IntPoint0,this.Next=null,this.Prev=null},
480
- /**
481
- * @constructor
482
- */
483
- ClipperLib.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new ClipperLib.IntPoint0},ClipperLib.ClipperBase=function(){this.m_MinimaList=null,this.m_CurrentLM=null,this.m_edges=new Array,this.m_UseFullRange=!1,this.m_HasOpenPaths=!1,this.PreserveCollinear=!1,this.m_Scanbeam=null,this.m_PolyOuts=null,this.m_ActiveEdges=null},ClipperLib.ClipperBase.horizontal=-9007199254740992,ClipperLib.ClipperBase.Skip=-2,ClipperLib.ClipperBase.Unassigned=-1,ClipperLib.ClipperBase.tolerance=1e-20,ClipperLib.ClipperBase.loRange=47453132,ClipperLib.ClipperBase.hiRange=0xfffffffffffff,ClipperLib.ClipperBase.near_zero=function(val){return val>-ClipperLib.ClipperBase.tolerance&&val<ClipperLib.ClipperBase.tolerance},ClipperLib.ClipperBase.IsHorizontal=function(e){return 0===e.Delta.Y},ClipperLib.ClipperBase.prototype.PointIsVertex=function(pt,pp){var pp2=pp;do{if(ClipperLib.IntPoint.op_Equality(pp2.Pt,pt))return!0;pp2=pp2.Next}while(pp2!==pp);return!1},ClipperLib.ClipperBase.prototype.PointOnLineSegment=function(pt,linePt1,linePt2,UseFullRange){return UseFullRange?pt.X===linePt1.X&&pt.Y===linePt1.Y||pt.X===linePt2.X&&pt.Y===linePt2.Y||pt.X>linePt1.X==pt.X<linePt2.X&&pt.Y>linePt1.Y==pt.Y<linePt2.Y&&Int128.op_Equality(Int128.Int128Mul(pt.X-linePt1.X,linePt2.Y-linePt1.Y),Int128.Int128Mul(linePt2.X-linePt1.X,pt.Y-linePt1.Y)):pt.X===linePt1.X&&pt.Y===linePt1.Y||pt.X===linePt2.X&&pt.Y===linePt2.Y||pt.X>linePt1.X==pt.X<linePt2.X&&pt.Y>linePt1.Y==pt.Y<linePt2.Y&&(pt.X-linePt1.X)*(linePt2.Y-linePt1.Y)==(linePt2.X-linePt1.X)*(pt.Y-linePt1.Y)},ClipperLib.ClipperBase.prototype.PointOnPolygon=function(pt,pp,UseFullRange){for(var pp2=pp;;){if(this.PointOnLineSegment(pt,pp2.Pt,pp2.Next.Pt,UseFullRange))return!0;if((pp2=pp2.Next)===pp)break}return!1},ClipperLib.ClipperBase.prototype.SlopesEqual=ClipperLib.ClipperBase.SlopesEqual=function(){var e1,e2,pt1,pt2,pt3,pt4,a=arguments,alen=a.length;return 3===alen?(e1=a[0],e2=a[1],a[2]?Int128.op_Equality(Int128.Int128Mul(e1.Delta.Y,e2.Delta.X),Int128.Int128Mul(e1.Delta.X,e2.Delta.Y)):ClipperLib.Cast_Int64(e1.Delta.Y*e2.Delta.X)===ClipperLib.Cast_Int64(e1.Delta.X*e2.Delta.Y)):4===alen?(pt1=a[0],pt2=a[1],pt3=a[2],a[3]?Int128.op_Equality(Int128.Int128Mul(pt1.Y-pt2.Y,pt2.X-pt3.X),Int128.Int128Mul(pt1.X-pt2.X,pt2.Y-pt3.Y)):ClipperLib.Cast_Int64((pt1.Y-pt2.Y)*(pt2.X-pt3.X))-ClipperLib.Cast_Int64((pt1.X-pt2.X)*(pt2.Y-pt3.Y))==0):(pt1=a[0],pt2=a[1],pt3=a[2],pt4=a[3],a[4]?Int128.op_Equality(Int128.Int128Mul(pt1.Y-pt2.Y,pt3.X-pt4.X),Int128.Int128Mul(pt1.X-pt2.X,pt3.Y-pt4.Y)):ClipperLib.Cast_Int64((pt1.Y-pt2.Y)*(pt3.X-pt4.X))-ClipperLib.Cast_Int64((pt1.X-pt2.X)*(pt3.Y-pt4.Y))==0)},ClipperLib.ClipperBase.SlopesEqual3=function(e1,e2,UseFullRange){return UseFullRange?Int128.op_Equality(Int128.Int128Mul(e1.Delta.Y,e2.Delta.X),Int128.Int128Mul(e1.Delta.X,e2.Delta.Y)):ClipperLib.Cast_Int64(e1.Delta.Y*e2.Delta.X)===ClipperLib.Cast_Int64(e1.Delta.X*e2.Delta.Y)},ClipperLib.ClipperBase.SlopesEqual4=function(pt1,pt2,pt3,UseFullRange){return UseFullRange?Int128.op_Equality(Int128.Int128Mul(pt1.Y-pt2.Y,pt2.X-pt3.X),Int128.Int128Mul(pt1.X-pt2.X,pt2.Y-pt3.Y)):ClipperLib.Cast_Int64((pt1.Y-pt2.Y)*(pt2.X-pt3.X))-ClipperLib.Cast_Int64((pt1.X-pt2.X)*(pt2.Y-pt3.Y))==0},ClipperLib.ClipperBase.SlopesEqual5=function(pt1,pt2,pt3,pt4,UseFullRange){return UseFullRange?Int128.op_Equality(Int128.Int128Mul(pt1.Y-pt2.Y,pt3.X-pt4.X),Int128.Int128Mul(pt1.X-pt2.X,pt3.Y-pt4.Y)):ClipperLib.Cast_Int64((pt1.Y-pt2.Y)*(pt3.X-pt4.X))-ClipperLib.Cast_Int64((pt1.X-pt2.X)*(pt3.Y-pt4.Y))==0},ClipperLib.ClipperBase.prototype.Clear=function(){this.DisposeLocalMinimaList();for(var i=0,ilen=this.m_edges.length;i<ilen;++i){for(var j=0,jlen=this.m_edges[i].length;j<jlen;++j)this.m_edges[i][j]=null;ClipperLib.Clear(this.m_edges[i])}ClipperLib.Clear(this.m_edges),this.m_UseFullRange=!1,this.m_HasOpenPaths=!1},ClipperLib.ClipperBase.prototype.DisposeLocalMinimaList=function(){for(;null!==this.m_MinimaList;){var tmpLm=this.m_MinimaList.Next;this.m_MinimaList=null,this.m_MinimaList=tmpLm}this.m_CurrentLM=null},ClipperLib.ClipperBase.prototype.RangeTest=function(Pt,useFullRange){useFullRange.Value?(Pt.X>ClipperLib.ClipperBase.hiRange||Pt.Y>ClipperLib.ClipperBase.hiRange||-Pt.X>ClipperLib.ClipperBase.hiRange||-Pt.Y>ClipperLib.ClipperBase.hiRange)&&ClipperLib.Error("Coordinate outside allowed range in RangeTest()."):(Pt.X>ClipperLib.ClipperBase.loRange||Pt.Y>ClipperLib.ClipperBase.loRange||-Pt.X>ClipperLib.ClipperBase.loRange||-Pt.Y>ClipperLib.ClipperBase.loRange)&&(useFullRange.Value=!0,this.RangeTest(Pt,useFullRange))},ClipperLib.ClipperBase.prototype.InitEdge=function(e,eNext,ePrev,pt){e.Next=eNext,e.Prev=ePrev,e.Curr.X=pt.X,e.Curr.Y=pt.Y,ClipperLib.use_xyz&&(e.Curr.Z=pt.Z),e.OutIdx=-1},ClipperLib.ClipperBase.prototype.InitEdge2=function(e,polyType){e.Curr.Y>=e.Next.Curr.Y?(e.Bot.X=e.Curr.X,e.Bot.Y=e.Curr.Y,ClipperLib.use_xyz&&(e.Bot.Z=e.Curr.Z),e.Top.X=e.Next.Curr.X,e.Top.Y=e.Next.Curr.Y,ClipperLib.use_xyz&&(e.Top.Z=e.Next.Curr.Z)):(e.Top.X=e.Curr.X,e.Top.Y=e.Curr.Y,ClipperLib.use_xyz&&(e.Top.Z=e.Curr.Z),e.Bot.X=e.Next.Curr.X,e.Bot.Y=e.Next.Curr.Y,ClipperLib.use_xyz&&(e.Bot.Z=e.Next.Curr.Z)),this.SetDx(e),e.PolyTyp=polyType},ClipperLib.ClipperBase.prototype.FindNextLocMin=function(E){for(var E2;;){for(;ClipperLib.IntPoint.op_Inequality(E.Bot,E.Prev.Bot)||ClipperLib.IntPoint.op_Equality(E.Curr,E.Top);)E=E.Next;if(E.Dx!==ClipperLib.ClipperBase.horizontal&&E.Prev.Dx!==ClipperLib.ClipperBase.horizontal)break;for(;E.Prev.Dx===ClipperLib.ClipperBase.horizontal;)E=E.Prev;for(E2=E;E.Dx===ClipperLib.ClipperBase.horizontal;)E=E.Next;if(E.Top.Y!==E.Prev.Bot.Y){E2.Prev.Bot.X<E.Bot.X&&(E=E2);break}}return E},ClipperLib.ClipperBase.prototype.ProcessBound=function(E,LeftBoundIsForward){var EStart,Horz,Result=E;if(Result.OutIdx===ClipperLib.ClipperBase.Skip){if(E=Result,LeftBoundIsForward){for(;E.Top.Y===E.Next.Bot.Y;)E=E.Next;for(;E!==Result&&E.Dx===ClipperLib.ClipperBase.horizontal;)E=E.Prev}else{for(;E.Top.Y===E.Prev.Bot.Y;)E=E.Prev;for(;E!==Result&&E.Dx===ClipperLib.ClipperBase.horizontal;)E=E.Next}if(E===Result)Result=LeftBoundIsForward?E.Next:E.Prev;else{E=LeftBoundIsForward?Result.Next:Result.Prev;var locMin=new ClipperLib.LocalMinima;locMin.Next=null,locMin.Y=E.Bot.Y,locMin.LeftBound=null,locMin.RightBound=E,E.WindDelta=0,Result=this.ProcessBound(E,LeftBoundIsForward),this.InsertLocalMinima(locMin)}return Result}if(E.Dx===ClipperLib.ClipperBase.horizontal&&((EStart=LeftBoundIsForward?E.Prev:E.Next).Dx===ClipperLib.ClipperBase.horizontal?EStart.Bot.X!==E.Bot.X&&EStart.Top.X!==E.Bot.X&&this.ReverseHorizontal(E):EStart.Bot.X!==E.Bot.X&&this.ReverseHorizontal(E)),EStart=E,LeftBoundIsForward){for(;Result.Top.Y===Result.Next.Bot.Y&&Result.Next.OutIdx!==ClipperLib.ClipperBase.Skip;)Result=Result.Next;if(Result.Dx===ClipperLib.ClipperBase.horizontal&&Result.Next.OutIdx!==ClipperLib.ClipperBase.Skip){for(Horz=Result;Horz.Prev.Dx===ClipperLib.ClipperBase.horizontal;)Horz=Horz.Prev;Horz.Prev.Top.X>Result.Next.Top.X&&(Result=Horz.Prev)}for(;E!==Result;)E.NextInLML=E.Next,E.Dx===ClipperLib.ClipperBase.horizontal&&E!==EStart&&E.Bot.X!==E.Prev.Top.X&&this.ReverseHorizontal(E),E=E.Next;E.Dx===ClipperLib.ClipperBase.horizontal&&E!==EStart&&E.Bot.X!==E.Prev.Top.X&&this.ReverseHorizontal(E),Result=Result.Next}else{for(;Result.Top.Y===Result.Prev.Bot.Y&&Result.Prev.OutIdx!==ClipperLib.ClipperBase.Skip;)Result=Result.Prev;if(Result.Dx===ClipperLib.ClipperBase.horizontal&&Result.Prev.OutIdx!==ClipperLib.ClipperBase.Skip){for(Horz=Result;Horz.Next.Dx===ClipperLib.ClipperBase.horizontal;)Horz=Horz.Next;(Horz.Next.Top.X===Result.Prev.Top.X||Horz.Next.Top.X>Result.Prev.Top.X)&&(Result=Horz.Next)}for(;E!==Result;)E.NextInLML=E.Prev,E.Dx===ClipperLib.ClipperBase.horizontal&&E!==EStart&&E.Bot.X!==E.Next.Top.X&&this.ReverseHorizontal(E),E=E.Prev;E.Dx===ClipperLib.ClipperBase.horizontal&&E!==EStart&&E.Bot.X!==E.Next.Top.X&&this.ReverseHorizontal(E),Result=Result.Prev}return Result},ClipperLib.ClipperBase.prototype.AddPath=function(pg,polyType,Closed){ClipperLib.use_lines?Closed||polyType!==ClipperLib.PolyType.ptClip||ClipperLib.Error("AddPath: Open paths must be subject."):Closed||ClipperLib.Error("AddPath: Open paths have been disabled.");var highI=pg.length-1;if(Closed)for(;highI>0&&ClipperLib.IntPoint.op_Equality(pg[highI],pg[0]);)--highI;for(;highI>0&&ClipperLib.IntPoint.op_Equality(pg[highI],pg[highI-1]);)--highI;if(Closed&&highI<2||!Closed&&highI<1)return!1;for(var edges=new Array,i=0;i<=highI;i++)edges.push(new ClipperLib.TEdge);var IsFlat=!0;edges[1].Curr.X=pg[1].X,edges[1].Curr.Y=pg[1].Y,ClipperLib.use_xyz&&(edges[1].Curr.Z=pg[1].Z);var $1={Value:this.m_UseFullRange};for(this.RangeTest(pg[0],$1),this.m_UseFullRange=$1.Value,$1.Value=this.m_UseFullRange,this.RangeTest(pg[highI],$1),this.m_UseFullRange=$1.Value,this.InitEdge(edges[0],edges[1],edges[highI],pg[0]),this.InitEdge(edges[highI],edges[0],edges[highI-1],pg[highI]),i=highI-1;i>=1;--i)$1.Value=this.m_UseFullRange,this.RangeTest(pg[i],$1),this.m_UseFullRange=$1.Value,this.InitEdge(edges[i],edges[i+1],edges[i-1],pg[i]);for(var leftBoundIsForward,eStart=edges[0],E=eStart,eLoopStop=eStart;;)if(E.Curr!==E.Next.Curr||!Closed&&E.Next===eStart){if(E.Prev===E.Next)break;if(!Closed||!ClipperLib.ClipperBase.SlopesEqual4(E.Prev.Curr,E.Curr,E.Next.Curr,this.m_UseFullRange)||this.PreserveCollinear&&this.Pt2IsBetweenPt1AndPt3(E.Prev.Curr,E.Curr,E.Next.Curr)){if((E=E.Next)===eLoopStop||!Closed&&E.Next===eStart)break}else E===eStart&&(eStart=E.Next),eLoopStop=E=(E=this.RemoveEdge(E)).Prev}else{if(E===E.Next)break;E===eStart&&(eStart=E.Next),eLoopStop=E=this.RemoveEdge(E)}if(!Closed&&E===E.Next||Closed&&E.Prev===E.Next)return!1;Closed||(this.m_HasOpenPaths=!0,eStart.Prev.OutIdx=ClipperLib.ClipperBase.Skip),E=eStart;do{this.InitEdge2(E,polyType),E=E.Next,IsFlat&&E.Curr.Y!==eStart.Curr.Y&&(IsFlat=!1)}while(E!==eStart);if(IsFlat){if(Closed)return!1;for(E.Prev.OutIdx=ClipperLib.ClipperBase.Skip,(locMin=new ClipperLib.LocalMinima).Next=null,locMin.Y=E.Bot.Y,locMin.LeftBound=null,locMin.RightBound=E,locMin.RightBound.Side=ClipperLib.EdgeSide.esRight,locMin.RightBound.WindDelta=0;E.Bot.X!==E.Prev.Top.X&&this.ReverseHorizontal(E),E.Next.OutIdx!==ClipperLib.ClipperBase.Skip;)E.NextInLML=E.Next,E=E.Next;return this.InsertLocalMinima(locMin),this.m_edges.push(edges),!0}this.m_edges.push(edges);var EMin=null;for(ClipperLib.IntPoint.op_Equality(E.Prev.Bot,E.Prev.Top)&&(E=E.Next);(E=this.FindNextLocMin(E))!==EMin;){var locMin;null===EMin&&(EMin=E),(locMin=new ClipperLib.LocalMinima).Next=null,locMin.Y=E.Bot.Y,E.Dx<E.Prev.Dx?(locMin.LeftBound=E.Prev,locMin.RightBound=E,leftBoundIsForward=!1):(locMin.LeftBound=E,locMin.RightBound=E.Prev,leftBoundIsForward=!0),locMin.LeftBound.Side=ClipperLib.EdgeSide.esLeft,locMin.RightBound.Side=ClipperLib.EdgeSide.esRight,Closed?locMin.LeftBound.Next===locMin.RightBound?locMin.LeftBound.WindDelta=-1:locMin.LeftBound.WindDelta=1:locMin.LeftBound.WindDelta=0,locMin.RightBound.WindDelta=-locMin.LeftBound.WindDelta,(E=this.ProcessBound(locMin.LeftBound,leftBoundIsForward)).OutIdx===ClipperLib.ClipperBase.Skip&&(E=this.ProcessBound(E,leftBoundIsForward));var E2=this.ProcessBound(locMin.RightBound,!leftBoundIsForward);E2.OutIdx===ClipperLib.ClipperBase.Skip&&(E2=this.ProcessBound(E2,!leftBoundIsForward)),locMin.LeftBound.OutIdx===ClipperLib.ClipperBase.Skip?locMin.LeftBound=null:locMin.RightBound.OutIdx===ClipperLib.ClipperBase.Skip&&(locMin.RightBound=null),this.InsertLocalMinima(locMin),leftBoundIsForward||(E=E2)}return!0},ClipperLib.ClipperBase.prototype.AddPaths=function(ppg,polyType,closed){for(var result=!1,i=0,ilen=ppg.length;i<ilen;++i)this.AddPath(ppg[i],polyType,closed)&&(result=!0);return result},ClipperLib.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(pt1,pt2,pt3){return!(ClipperLib.IntPoint.op_Equality(pt1,pt3)||ClipperLib.IntPoint.op_Equality(pt1,pt2)||ClipperLib.IntPoint.op_Equality(pt3,pt2))&&(pt1.X!==pt3.X?pt2.X>pt1.X==pt2.X<pt3.X:pt2.Y>pt1.Y==pt2.Y<pt3.Y)},ClipperLib.ClipperBase.prototype.RemoveEdge=function(e){e.Prev.Next=e.Next,e.Next.Prev=e.Prev;var result=e.Next;return e.Prev=null,result},ClipperLib.ClipperBase.prototype.SetDx=function(e){e.Delta.X=e.Top.X-e.Bot.X,e.Delta.Y=e.Top.Y-e.Bot.Y,0===e.Delta.Y?e.Dx=ClipperLib.ClipperBase.horizontal:e.Dx=e.Delta.X/e.Delta.Y},ClipperLib.ClipperBase.prototype.InsertLocalMinima=function(newLm){if(null===this.m_MinimaList)this.m_MinimaList=newLm;else if(newLm.Y>=this.m_MinimaList.Y)newLm.Next=this.m_MinimaList,this.m_MinimaList=newLm;else{for(var tmpLm=this.m_MinimaList;null!==tmpLm.Next&&newLm.Y<tmpLm.Next.Y;)tmpLm=tmpLm.Next;newLm.Next=tmpLm.Next,tmpLm.Next=newLm}},ClipperLib.ClipperBase.prototype.PopLocalMinima=function(Y,current){return current.v=this.m_CurrentLM,null!==this.m_CurrentLM&&this.m_CurrentLM.Y===Y&&(this.m_CurrentLM=this.m_CurrentLM.Next,!0)},ClipperLib.ClipperBase.prototype.ReverseHorizontal=function(e){var tmp=e.Top.X;e.Top.X=e.Bot.X,e.Bot.X=tmp,ClipperLib.use_xyz&&(tmp=e.Top.Z,e.Top.Z=e.Bot.Z,e.Bot.Z=tmp)},ClipperLib.ClipperBase.prototype.Reset=function(){if(this.m_CurrentLM=this.m_MinimaList,null!==this.m_CurrentLM){this.m_Scanbeam=null;for(var lm=this.m_MinimaList;null!==lm;){this.InsertScanbeam(lm.Y);var e=lm.LeftBound;null!==e&&(e.Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,ClipperLib.use_xyz&&(e.Curr.Z=e.Bot.Z),e.OutIdx=ClipperLib.ClipperBase.Unassigned),null!==(e=lm.RightBound)&&(e.Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,ClipperLib.use_xyz&&(e.Curr.Z=e.Bot.Z),e.OutIdx=ClipperLib.ClipperBase.Unassigned),lm=lm.Next}this.m_ActiveEdges=null}},ClipperLib.ClipperBase.prototype.InsertScanbeam=function(Y){if(null===this.m_Scanbeam)this.m_Scanbeam=new ClipperLib.Scanbeam,this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=Y;else if(Y>this.m_Scanbeam.Y){var newSb=new ClipperLib.Scanbeam;newSb.Y=Y,newSb.Next=this.m_Scanbeam,this.m_Scanbeam=newSb}else{for(var sb2=this.m_Scanbeam;null!==sb2.Next&&Y<=sb2.Next.Y;)sb2=sb2.Next;if(Y===sb2.Y)return;var newSb1=new ClipperLib.Scanbeam;newSb1.Y=Y,newSb1.Next=sb2.Next,sb2.Next=newSb1}},ClipperLib.ClipperBase.prototype.PopScanbeam=function(Y){return null===this.m_Scanbeam?(Y.v=0,!1):(Y.v=this.m_Scanbeam.Y,this.m_Scanbeam=this.m_Scanbeam.Next,!0)},ClipperLib.ClipperBase.prototype.LocalMinimaPending=function(){return null!==this.m_CurrentLM},ClipperLib.ClipperBase.prototype.CreateOutRec=function(){var result=new ClipperLib.OutRec;return result.Idx=ClipperLib.ClipperBase.Unassigned,result.IsHole=!1,result.IsOpen=!1,result.FirstLeft=null,result.Pts=null,result.BottomPt=null,result.PolyNode=null,this.m_PolyOuts.push(result),result.Idx=this.m_PolyOuts.length-1,result},ClipperLib.ClipperBase.prototype.DisposeOutRec=function(index){var outRec=this.m_PolyOuts[index];outRec.Pts=null,outRec=null,this.m_PolyOuts[index]=null},ClipperLib.ClipperBase.prototype.UpdateEdgeIntoAEL=function(e){null===e.NextInLML&&ClipperLib.Error("UpdateEdgeIntoAEL: invalid call");var AelPrev=e.PrevInAEL,AelNext=e.NextInAEL;return e.NextInLML.OutIdx=e.OutIdx,null!==AelPrev?AelPrev.NextInAEL=e.NextInLML:this.m_ActiveEdges=e.NextInLML,null!==AelNext&&(AelNext.PrevInAEL=e.NextInLML),e.NextInLML.Side=e.Side,e.NextInLML.WindDelta=e.WindDelta,e.NextInLML.WindCnt=e.WindCnt,e.NextInLML.WindCnt2=e.WindCnt2,(e=e.NextInLML).Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,e.PrevInAEL=AelPrev,e.NextInAEL=AelNext,ClipperLib.ClipperBase.IsHorizontal(e)||this.InsertScanbeam(e.Top.Y),e},ClipperLib.ClipperBase.prototype.SwapPositionsInAEL=function(edge1,edge2){if(edge1.NextInAEL!==edge1.PrevInAEL&&edge2.NextInAEL!==edge2.PrevInAEL){if(edge1.NextInAEL===edge2){var next=edge2.NextInAEL;null!==next&&(next.PrevInAEL=edge1);var prev=edge1.PrevInAEL;null!==prev&&(prev.NextInAEL=edge2),edge2.PrevInAEL=prev,edge2.NextInAEL=edge1,edge1.PrevInAEL=edge2,edge1.NextInAEL=next}else if(edge2.NextInAEL===edge1){var next1=edge1.NextInAEL;null!==next1&&(next1.PrevInAEL=edge2);var prev1=edge2.PrevInAEL;null!==prev1&&(prev1.NextInAEL=edge1),edge1.PrevInAEL=prev1,edge1.NextInAEL=edge2,edge2.PrevInAEL=edge1,edge2.NextInAEL=next1}else{var next2=edge1.NextInAEL,prev2=edge1.PrevInAEL;edge1.NextInAEL=edge2.NextInAEL,null!==edge1.NextInAEL&&(edge1.NextInAEL.PrevInAEL=edge1),edge1.PrevInAEL=edge2.PrevInAEL,null!==edge1.PrevInAEL&&(edge1.PrevInAEL.NextInAEL=edge1),edge2.NextInAEL=next2,null!==edge2.NextInAEL&&(edge2.NextInAEL.PrevInAEL=edge2),edge2.PrevInAEL=prev2,null!==edge2.PrevInAEL&&(edge2.PrevInAEL.NextInAEL=edge2)}null===edge1.PrevInAEL?this.m_ActiveEdges=edge1:null===edge2.PrevInAEL&&(this.m_ActiveEdges=edge2)}},ClipperLib.ClipperBase.prototype.DeleteFromAEL=function(e){var AelPrev=e.PrevInAEL,AelNext=e.NextInAEL;null===AelPrev&&null===AelNext&&e!==this.m_ActiveEdges||(null!==AelPrev?AelPrev.NextInAEL=AelNext:this.m_ActiveEdges=AelNext,null!==AelNext&&(AelNext.PrevInAEL=AelPrev),e.NextInAEL=null,e.PrevInAEL=null)},
484
- /**
485
- * @suppress {missingProperties}
486
- */
487
- ClipperLib.Clipper=function(InitOptions){void 0===InitOptions&&(InitOptions=0),this.m_PolyOuts=null,this.m_ClipType=ClipperLib.ClipType.ctIntersection,this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=null,this.m_IntersectNodeComparer=null,this.m_ExecuteLocked=!1,this.m_ClipFillType=ClipperLib.PolyFillType.pftEvenOdd,this.m_SubjFillType=ClipperLib.PolyFillType.pftEvenOdd,this.m_Joins=null,this.m_GhostJoins=null,this.m_UsingPolyTree=!1,this.ReverseSolution=!1,this.StrictlySimple=!1,ClipperLib.ClipperBase.call(this),this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=new Array,this.m_IntersectNodeComparer=ClipperLib.MyIntersectNodeSort.Compare,this.m_ExecuteLocked=!1,this.m_UsingPolyTree=!1,this.m_PolyOuts=new Array,this.m_Joins=new Array,this.m_GhostJoins=new Array,this.ReverseSolution=!!(1&InitOptions),this.StrictlySimple=!!(2&InitOptions),this.PreserveCollinear=!!(4&InitOptions),ClipperLib.use_xyz&&(this.ZFillFunction=null)},ClipperLib.Clipper.ioReverseSolution=1,ClipperLib.Clipper.ioStrictlySimple=2,ClipperLib.Clipper.ioPreserveCollinear=4,ClipperLib.Clipper.prototype.Clear=function(){0!==this.m_edges.length&&(this.DisposeAllPolyPts(),ClipperLib.ClipperBase.prototype.Clear.call(this))},ClipperLib.Clipper.prototype.InsertMaxima=function(X){var newMax=new ClipperLib.Maxima;if(newMax.X=X,null===this.m_Maxima)this.m_Maxima=newMax,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(X<this.m_Maxima.X)newMax.Next=this.m_Maxima,newMax.Prev=null,this.m_Maxima=newMax;else{for(var m=this.m_Maxima;null!==m.Next&&X>=m.Next.X;)m=m.Next;if(X===m.X)return;newMax.Next=m.Next,newMax.Prev=m,null!==m.Next&&(m.Next.Prev=newMax),m.Next=newMax}},ClipperLib.Clipper.prototype.Execute=function(){var a=arguments,alen=a.length,ispolytree=a[1]instanceof ClipperLib.PolyTree;if(4===alen&&!ispolytree){var clipType=a[0],solution=a[1],subjFillType=a[2],clipFillType=a[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&ClipperLib.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,ClipperLib.Clear(solution),this.m_SubjFillType=subjFillType,this.m_ClipFillType=clipFillType,this.m_ClipType=clipType,this.m_UsingPolyTree=!1;try{(succeeded=this.ExecuteInternal())&&this.BuildResult(solution)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return succeeded}if(4===alen&&ispolytree){clipType=a[0];var polytree=a[1];if(subjFillType=a[2],clipFillType=a[3],this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=subjFillType,this.m_ClipFillType=clipFillType,this.m_ClipType=clipType,this.m_UsingPolyTree=!0;try{var succeeded;(succeeded=this.ExecuteInternal())&&this.BuildResult2(polytree)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return succeeded}return 2!==alen||ispolytree?2===alen&&ispolytree?(clipType=a[0],polytree=a[1],this.Execute(clipType,polytree,ClipperLib.PolyFillType.pftEvenOdd,ClipperLib.PolyFillType.pftEvenOdd)):void 0:(clipType=a[0],solution=a[1],this.Execute(clipType,solution,ClipperLib.PolyFillType.pftEvenOdd,ClipperLib.PolyFillType.pftEvenOdd))},ClipperLib.Clipper.prototype.FixHoleLinkage=function(outRec){if(null!==outRec.FirstLeft&&(outRec.IsHole===outRec.FirstLeft.IsHole||null===outRec.FirstLeft.Pts)){for(var orfl=outRec.FirstLeft;null!==orfl&&(orfl.IsHole===outRec.IsHole||null===orfl.Pts);)orfl=orfl.FirstLeft;outRec.FirstLeft=orfl}},ClipperLib.Clipper.prototype.ExecuteInternal=function(){try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var outRec,i,ilen,botY={},topY={};if(!this.PopScanbeam(botY))return!1;for(this.InsertLocalMinimaIntoAEL(botY.v);this.PopScanbeam(topY)||this.LocalMinimaPending();){if(this.ProcessHorizontals(),this.m_GhostJoins.length=0,!this.ProcessIntersections(topY.v))return!1;this.ProcessEdgesAtTopOfScanbeam(topY.v),botY.v=topY.v,this.InsertLocalMinimaIntoAEL(botY.v)}for(i=0,ilen=this.m_PolyOuts.length;i<ilen;i++)null===(outRec=this.m_PolyOuts[i]).Pts||outRec.IsOpen||(outRec.IsHole^this.ReverseSolution)==this.Area$1(outRec)>0&&this.ReversePolyPtLinks(outRec.Pts);for(this.JoinCommonEdges(),i=0,ilen=this.m_PolyOuts.length;i<ilen;i++)null!==(outRec=this.m_PolyOuts[i]).Pts&&(outRec.IsOpen?this.FixupOutPolyline(outRec):this.FixupOutPolygon(outRec));return this.StrictlySimple&&this.DoSimplePolygons(),!0}finally{this.m_Joins.length=0,this.m_GhostJoins.length=0}},ClipperLib.Clipper.prototype.DisposeAllPolyPts=function(){for(var i=0,ilen=this.m_PolyOuts.length;i<ilen;++i)this.DisposeOutRec(i);ClipperLib.Clear(this.m_PolyOuts)},ClipperLib.Clipper.prototype.AddJoin=function(Op1,Op2,OffPt){var j=new ClipperLib.Join;j.OutPt1=Op1,j.OutPt2=Op2,j.OffPt.X=OffPt.X,j.OffPt.Y=OffPt.Y,ClipperLib.use_xyz&&(j.OffPt.Z=OffPt.Z),this.m_Joins.push(j)},ClipperLib.Clipper.prototype.AddGhostJoin=function(Op,OffPt){var j=new ClipperLib.Join;j.OutPt1=Op,j.OffPt.X=OffPt.X,j.OffPt.Y=OffPt.Y,ClipperLib.use_xyz&&(j.OffPt.Z=OffPt.Z),this.m_GhostJoins.push(j)},ClipperLib.Clipper.prototype.SetZ=function(pt,e1,e2){if(null!==this.ZFillFunction){if(0!==pt.Z||null===this.ZFillFunction)return;ClipperLib.IntPoint.op_Equality(pt,e1.Bot)?pt.Z=e1.Bot.Z:ClipperLib.IntPoint.op_Equality(pt,e1.Top)?pt.Z=e1.Top.Z:ClipperLib.IntPoint.op_Equality(pt,e2.Bot)?pt.Z=e2.Bot.Z:ClipperLib.IntPoint.op_Equality(pt,e2.Top)?pt.Z=e2.Top.Z:this.ZFillFunction(e1.Bot,e1.Top,e2.Bot,e2.Top,pt)}},ClipperLib.Clipper.prototype.InsertLocalMinimaIntoAEL=function(botY){for(var lb,rb,lm={};this.PopLocalMinima(botY,lm);){lb=lm.v.LeftBound,rb=lm.v.RightBound;var Op1=null;if(null===lb?(this.InsertEdgeIntoAEL(rb,null),this.SetWindingCount(rb),this.IsContributing(rb)&&(Op1=this.AddOutPt(rb,rb.Bot))):null===rb?(this.InsertEdgeIntoAEL(lb,null),this.SetWindingCount(lb),this.IsContributing(lb)&&(Op1=this.AddOutPt(lb,lb.Bot)),this.InsertScanbeam(lb.Top.Y)):(this.InsertEdgeIntoAEL(lb,null),this.InsertEdgeIntoAEL(rb,lb),this.SetWindingCount(lb),rb.WindCnt=lb.WindCnt,rb.WindCnt2=lb.WindCnt2,this.IsContributing(lb)&&(Op1=this.AddLocalMinPoly(lb,rb,lb.Bot)),this.InsertScanbeam(lb.Top.Y)),null!==rb&&(ClipperLib.ClipperBase.IsHorizontal(rb)?(null!==rb.NextInLML&&this.InsertScanbeam(rb.NextInLML.Top.Y),this.AddEdgeToSEL(rb)):this.InsertScanbeam(rb.Top.Y)),null!==lb&&null!==rb){if(null!==Op1&&ClipperLib.ClipperBase.IsHorizontal(rb)&&this.m_GhostJoins.length>0&&0!==rb.WindDelta)for(var i=0,ilen=this.m_GhostJoins.length;i<ilen;i++){var j=this.m_GhostJoins[i];this.HorzSegmentsOverlap(j.OutPt1.Pt.X,j.OffPt.X,rb.Bot.X,rb.Top.X)&&this.AddJoin(j.OutPt1,Op1,j.OffPt)}if(lb.OutIdx>=0&&null!==lb.PrevInAEL&&lb.PrevInAEL.Curr.X===lb.Bot.X&&lb.PrevInAEL.OutIdx>=0&&ClipperLib.ClipperBase.SlopesEqual5(lb.PrevInAEL.Curr,lb.PrevInAEL.Top,lb.Curr,lb.Top,this.m_UseFullRange)&&0!==lb.WindDelta&&0!==lb.PrevInAEL.WindDelta){var Op2=this.AddOutPt(lb.PrevInAEL,lb.Bot);this.AddJoin(Op1,Op2,lb.Top)}if(lb.NextInAEL!==rb){rb.OutIdx>=0&&rb.PrevInAEL.OutIdx>=0&&ClipperLib.ClipperBase.SlopesEqual5(rb.PrevInAEL.Curr,rb.PrevInAEL.Top,rb.Curr,rb.Top,this.m_UseFullRange)&&0!==rb.WindDelta&&0!==rb.PrevInAEL.WindDelta&&(Op2=this.AddOutPt(rb.PrevInAEL,rb.Bot),this.AddJoin(Op1,Op2,rb.Top));var e=lb.NextInAEL;if(null!==e)for(;e!==rb;)this.IntersectEdges(rb,e,lb.Curr),e=e.NextInAEL}}}},ClipperLib.Clipper.prototype.InsertEdgeIntoAEL=function(edge,startEdge){if(null===this.m_ActiveEdges)edge.PrevInAEL=null,edge.NextInAEL=null,this.m_ActiveEdges=edge;else if(null===startEdge&&this.E2InsertsBeforeE1(this.m_ActiveEdges,edge))edge.PrevInAEL=null,edge.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=edge,this.m_ActiveEdges=edge;else{for(null===startEdge&&(startEdge=this.m_ActiveEdges);null!==startEdge.NextInAEL&&!this.E2InsertsBeforeE1(startEdge.NextInAEL,edge);)startEdge=startEdge.NextInAEL;edge.NextInAEL=startEdge.NextInAEL,null!==startEdge.NextInAEL&&(startEdge.NextInAEL.PrevInAEL=edge),edge.PrevInAEL=startEdge,startEdge.NextInAEL=edge}},ClipperLib.Clipper.prototype.E2InsertsBeforeE1=function(e1,e2){return e2.Curr.X===e1.Curr.X?e2.Top.Y>e1.Top.Y?e2.Top.X<ClipperLib.Clipper.TopX(e1,e2.Top.Y):e1.Top.X>ClipperLib.Clipper.TopX(e2,e1.Top.Y):e2.Curr.X<e1.Curr.X},ClipperLib.Clipper.prototype.IsEvenOddFillType=function(edge){return edge.PolyTyp===ClipperLib.PolyType.ptSubject?this.m_SubjFillType===ClipperLib.PolyFillType.pftEvenOdd:this.m_ClipFillType===ClipperLib.PolyFillType.pftEvenOdd},ClipperLib.Clipper.prototype.IsEvenOddAltFillType=function(edge){return edge.PolyTyp===ClipperLib.PolyType.ptSubject?this.m_ClipFillType===ClipperLib.PolyFillType.pftEvenOdd:this.m_SubjFillType===ClipperLib.PolyFillType.pftEvenOdd},ClipperLib.Clipper.prototype.IsContributing=function(edge){var pft,pft2;switch(edge.PolyTyp===ClipperLib.PolyType.ptSubject?(pft=this.m_SubjFillType,pft2=this.m_ClipFillType):(pft=this.m_ClipFillType,pft2=this.m_SubjFillType),pft){case ClipperLib.PolyFillType.pftEvenOdd:if(0===edge.WindDelta&&1!==edge.WindCnt)return!1;break;case ClipperLib.PolyFillType.pftNonZero:if(1!==Math.abs(edge.WindCnt))return!1;break;case ClipperLib.PolyFillType.pftPositive:if(1!==edge.WindCnt)return!1;break;default:if(-1!==edge.WindCnt)return!1}switch(this.m_ClipType){case ClipperLib.ClipType.ctIntersection:switch(pft2){case ClipperLib.PolyFillType.pftEvenOdd:case ClipperLib.PolyFillType.pftNonZero:return 0!==edge.WindCnt2;case ClipperLib.PolyFillType.pftPositive:return edge.WindCnt2>0;default:return edge.WindCnt2<0}case ClipperLib.ClipType.ctUnion:switch(pft2){case ClipperLib.PolyFillType.pftEvenOdd:case ClipperLib.PolyFillType.pftNonZero:return 0===edge.WindCnt2;case ClipperLib.PolyFillType.pftPositive:return edge.WindCnt2<=0;default:return edge.WindCnt2>=0}case ClipperLib.ClipType.ctDifference:if(edge.PolyTyp===ClipperLib.PolyType.ptSubject)switch(pft2){case ClipperLib.PolyFillType.pftEvenOdd:case ClipperLib.PolyFillType.pftNonZero:return 0===edge.WindCnt2;case ClipperLib.PolyFillType.pftPositive:return edge.WindCnt2<=0;default:return edge.WindCnt2>=0}else switch(pft2){case ClipperLib.PolyFillType.pftEvenOdd:case ClipperLib.PolyFillType.pftNonZero:return 0!==edge.WindCnt2;case ClipperLib.PolyFillType.pftPositive:return edge.WindCnt2>0;default:return edge.WindCnt2<0}case ClipperLib.ClipType.ctXor:if(0!==edge.WindDelta)return!0;switch(pft2){case ClipperLib.PolyFillType.pftEvenOdd:case ClipperLib.PolyFillType.pftNonZero:return 0===edge.WindCnt2;case ClipperLib.PolyFillType.pftPositive:return edge.WindCnt2<=0;default:return edge.WindCnt2>=0}}return!0},ClipperLib.Clipper.prototype.SetWindingCount=function(edge){for(var e=edge.PrevInAEL;null!==e&&(e.PolyTyp!==edge.PolyTyp||0===e.WindDelta);)e=e.PrevInAEL;if(null===e){var pft=edge.PolyTyp===ClipperLib.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;0===edge.WindDelta?edge.WindCnt=pft===ClipperLib.PolyFillType.pftNegative?-1:1:edge.WindCnt=edge.WindDelta,edge.WindCnt2=0,e=this.m_ActiveEdges}else if(0===edge.WindDelta&&this.m_ClipType!==ClipperLib.ClipType.ctUnion)edge.WindCnt=1,edge.WindCnt2=e.WindCnt2,e=e.NextInAEL;else if(this.IsEvenOddFillType(edge)){if(0===edge.WindDelta){for(var Inside=!0,e2=e.PrevInAEL;null!==e2;)e2.PolyTyp===e.PolyTyp&&0!==e2.WindDelta&&(Inside=!Inside),e2=e2.PrevInAEL;edge.WindCnt=Inside?0:1}else edge.WindCnt=edge.WindDelta;edge.WindCnt2=e.WindCnt2,e=e.NextInAEL}else e.WindCnt*e.WindDelta<0?Math.abs(e.WindCnt)>1?e.WindDelta*edge.WindDelta<0?edge.WindCnt=e.WindCnt:edge.WindCnt=e.WindCnt+edge.WindDelta:edge.WindCnt=0===edge.WindDelta?1:edge.WindDelta:0===edge.WindDelta?edge.WindCnt=e.WindCnt<0?e.WindCnt-1:e.WindCnt+1:e.WindDelta*edge.WindDelta<0?edge.WindCnt=e.WindCnt:edge.WindCnt=e.WindCnt+edge.WindDelta,edge.WindCnt2=e.WindCnt2,e=e.NextInAEL;if(this.IsEvenOddAltFillType(edge))for(;e!==edge;)0!==e.WindDelta&&(edge.WindCnt2=0===edge.WindCnt2?1:0),e=e.NextInAEL;else for(;e!==edge;)edge.WindCnt2+=e.WindDelta,e=e.NextInAEL},ClipperLib.Clipper.prototype.AddEdgeToSEL=function(edge){null===this.m_SortedEdges?(this.m_SortedEdges=edge,edge.PrevInSEL=null,edge.NextInSEL=null):(edge.NextInSEL=this.m_SortedEdges,edge.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=edge,this.m_SortedEdges=edge)},ClipperLib.Clipper.prototype.PopEdgeFromSEL=function(e){if(e.v=this.m_SortedEdges,null===e.v)return!1;var oldE=e.v;return this.m_SortedEdges=e.v.NextInSEL,null!==this.m_SortedEdges&&(this.m_SortedEdges.PrevInSEL=null),oldE.NextInSEL=null,oldE.PrevInSEL=null,!0},ClipperLib.Clipper.prototype.CopyAELToSEL=function(){var e=this.m_ActiveEdges;for(this.m_SortedEdges=e;null!==e;)e.PrevInSEL=e.PrevInAEL,e.NextInSEL=e.NextInAEL,e=e.NextInAEL},ClipperLib.Clipper.prototype.SwapPositionsInSEL=function(edge1,edge2){if(!(null===edge1.NextInSEL&&null===edge1.PrevInSEL||null===edge2.NextInSEL&&null===edge2.PrevInSEL)){if(edge1.NextInSEL===edge2)null!==(next=edge2.NextInSEL)&&(next.PrevInSEL=edge1),null!==(prev=edge1.PrevInSEL)&&(prev.NextInSEL=edge2),edge2.PrevInSEL=prev,edge2.NextInSEL=edge1,edge1.PrevInSEL=edge2,edge1.NextInSEL=next;else if(edge2.NextInSEL===edge1)null!==(next=edge1.NextInSEL)&&(next.PrevInSEL=edge2),null!==(prev=edge2.PrevInSEL)&&(prev.NextInSEL=edge1),edge1.PrevInSEL=prev,edge1.NextInSEL=edge2,edge2.PrevInSEL=edge1,edge2.NextInSEL=next;else{var next=edge1.NextInSEL,prev=edge1.PrevInSEL;edge1.NextInSEL=edge2.NextInSEL,null!==edge1.NextInSEL&&(edge1.NextInSEL.PrevInSEL=edge1),edge1.PrevInSEL=edge2.PrevInSEL,null!==edge1.PrevInSEL&&(edge1.PrevInSEL.NextInSEL=edge1),edge2.NextInSEL=next,null!==edge2.NextInSEL&&(edge2.NextInSEL.PrevInSEL=edge2),edge2.PrevInSEL=prev,null!==edge2.PrevInSEL&&(edge2.PrevInSEL.NextInSEL=edge2)}null===edge1.PrevInSEL?this.m_SortedEdges=edge1:null===edge2.PrevInSEL&&(this.m_SortedEdges=edge2)}},ClipperLib.Clipper.prototype.AddLocalMaxPoly=function(e1,e2,pt){this.AddOutPt(e1,pt),0===e2.WindDelta&&this.AddOutPt(e2,pt),e1.OutIdx===e2.OutIdx?(e1.OutIdx=-1,e2.OutIdx=-1):e1.OutIdx<e2.OutIdx?this.AppendPolygon(e1,e2):this.AppendPolygon(e2,e1)},ClipperLib.Clipper.prototype.AddLocalMinPoly=function(e1,e2,pt){var result,e,prevE;if(ClipperLib.ClipperBase.IsHorizontal(e2)||e1.Dx>e2.Dx?(result=this.AddOutPt(e1,pt),e2.OutIdx=e1.OutIdx,e1.Side=ClipperLib.EdgeSide.esLeft,e2.Side=ClipperLib.EdgeSide.esRight,prevE=(e=e1).PrevInAEL===e2?e2.PrevInAEL:e.PrevInAEL):(result=this.AddOutPt(e2,pt),e1.OutIdx=e2.OutIdx,e1.Side=ClipperLib.EdgeSide.esRight,e2.Side=ClipperLib.EdgeSide.esLeft,prevE=(e=e2).PrevInAEL===e1?e1.PrevInAEL:e.PrevInAEL),null!==prevE&&prevE.OutIdx>=0&&prevE.Top.Y<pt.Y&&e.Top.Y<pt.Y){var xPrev=ClipperLib.Clipper.TopX(prevE,pt.Y),xE=ClipperLib.Clipper.TopX(e,pt.Y);if(xPrev===xE&&0!==e.WindDelta&&0!==prevE.WindDelta&&ClipperLib.ClipperBase.SlopesEqual5(new ClipperLib.IntPoint2(xPrev,pt.Y),prevE.Top,new ClipperLib.IntPoint2(xE,pt.Y),e.Top,this.m_UseFullRange)){var outPt=this.AddOutPt(prevE,pt);this.AddJoin(result,outPt,e.Top)}}return result},ClipperLib.Clipper.prototype.AddOutPt=function(e,pt){if(e.OutIdx<0){(outRec=this.CreateOutRec()).IsOpen=0===e.WindDelta;var newOp=new ClipperLib.OutPt;return outRec.Pts=newOp,newOp.Idx=outRec.Idx,newOp.Pt.X=pt.X,newOp.Pt.Y=pt.Y,ClipperLib.use_xyz&&(newOp.Pt.Z=pt.Z),newOp.Next=newOp,newOp.Prev=newOp,outRec.IsOpen||this.SetHoleState(e,outRec),e.OutIdx=outRec.Idx,newOp}var outRec,op=(outRec=this.m_PolyOuts[e.OutIdx]).Pts,ToFront=e.Side===ClipperLib.EdgeSide.esLeft;return ToFront&&ClipperLib.IntPoint.op_Equality(pt,op.Pt)?op:!ToFront&&ClipperLib.IntPoint.op_Equality(pt,op.Prev.Pt)?op.Prev:((newOp=new ClipperLib.OutPt).Idx=outRec.Idx,newOp.Pt.X=pt.X,newOp.Pt.Y=pt.Y,ClipperLib.use_xyz&&(newOp.Pt.Z=pt.Z),newOp.Next=op,newOp.Prev=op.Prev,newOp.Prev.Next=newOp,op.Prev=newOp,ToFront&&(outRec.Pts=newOp),newOp)},ClipperLib.Clipper.prototype.GetLastOutPt=function(e){var outRec=this.m_PolyOuts[e.OutIdx];return e.Side===ClipperLib.EdgeSide.esLeft?outRec.Pts:outRec.Pts.Prev},ClipperLib.Clipper.prototype.SwapPoints=function(pt1,pt2){var tmp=new ClipperLib.IntPoint1(pt1.Value);pt1.Value.X=pt2.Value.X,pt1.Value.Y=pt2.Value.Y,ClipperLib.use_xyz&&(pt1.Value.Z=pt2.Value.Z),pt2.Value.X=tmp.X,pt2.Value.Y=tmp.Y,ClipperLib.use_xyz&&(pt2.Value.Z=tmp.Z)},ClipperLib.Clipper.prototype.HorzSegmentsOverlap=function(seg1a,seg1b,seg2a,seg2b){var tmp;return seg1a>seg1b&&(tmp=seg1a,seg1a=seg1b,seg1b=tmp),seg2a>seg2b&&(tmp=seg2a,seg2a=seg2b,seg2b=tmp),seg1a<seg2b&&seg2a<seg1b},ClipperLib.Clipper.prototype.SetHoleState=function(e,outRec){for(var e2=e.PrevInAEL,eTmp=null;null!==e2;)e2.OutIdx>=0&&0!==e2.WindDelta&&(null===eTmp?eTmp=e2:eTmp.OutIdx===e2.OutIdx&&(eTmp=null)),e2=e2.PrevInAEL;null===eTmp?(outRec.FirstLeft=null,outRec.IsHole=!1):(outRec.FirstLeft=this.m_PolyOuts[eTmp.OutIdx],outRec.IsHole=!outRec.FirstLeft.IsHole)},ClipperLib.Clipper.prototype.GetDx=function(pt1,pt2){return pt1.Y===pt2.Y?ClipperLib.ClipperBase.horizontal:(pt2.X-pt1.X)/(pt2.Y-pt1.Y)},ClipperLib.Clipper.prototype.FirstIsBottomPt=function(btmPt1,btmPt2){for(var p=btmPt1.Prev;ClipperLib.IntPoint.op_Equality(p.Pt,btmPt1.Pt)&&p!==btmPt1;)p=p.Prev;var dx1p=Math.abs(this.GetDx(btmPt1.Pt,p.Pt));for(p=btmPt1.Next;ClipperLib.IntPoint.op_Equality(p.Pt,btmPt1.Pt)&&p!==btmPt1;)p=p.Next;var dx1n=Math.abs(this.GetDx(btmPt1.Pt,p.Pt));for(p=btmPt2.Prev;ClipperLib.IntPoint.op_Equality(p.Pt,btmPt2.Pt)&&p!==btmPt2;)p=p.Prev;var dx2p=Math.abs(this.GetDx(btmPt2.Pt,p.Pt));for(p=btmPt2.Next;ClipperLib.IntPoint.op_Equality(p.Pt,btmPt2.Pt)&&p!==btmPt2;)p=p.Next;var dx2n=Math.abs(this.GetDx(btmPt2.Pt,p.Pt));return Math.max(dx1p,dx1n)===Math.max(dx2p,dx2n)&&Math.min(dx1p,dx1n)===Math.min(dx2p,dx2n)?this.Area(btmPt1)>0:dx1p>=dx2p&&dx1p>=dx2n||dx1n>=dx2p&&dx1n>=dx2n},ClipperLib.Clipper.prototype.GetBottomPt=function(pp){for(var dups=null,p=pp.Next;p!==pp;)p.Pt.Y>pp.Pt.Y?(pp=p,dups=null):p.Pt.Y===pp.Pt.Y&&p.Pt.X<=pp.Pt.X&&(p.Pt.X<pp.Pt.X?(dups=null,pp=p):p.Next!==pp&&p.Prev!==pp&&(dups=p)),p=p.Next;if(null!==dups)for(;dups!==p;)for(this.FirstIsBottomPt(p,dups)||(pp=dups),dups=dups.Next;ClipperLib.IntPoint.op_Inequality(dups.Pt,pp.Pt);)dups=dups.Next;return pp},ClipperLib.Clipper.prototype.GetLowermostRec=function(outRec1,outRec2){null===outRec1.BottomPt&&(outRec1.BottomPt=this.GetBottomPt(outRec1.Pts)),null===outRec2.BottomPt&&(outRec2.BottomPt=this.GetBottomPt(outRec2.Pts));var bPt1=outRec1.BottomPt,bPt2=outRec2.BottomPt;return bPt1.Pt.Y>bPt2.Pt.Y?outRec1:bPt1.Pt.Y<bPt2.Pt.Y?outRec2:bPt1.Pt.X<bPt2.Pt.X?outRec1:bPt1.Pt.X>bPt2.Pt.X||bPt1.Next===bPt1?outRec2:bPt2.Next===bPt2||this.FirstIsBottomPt(bPt1,bPt2)?outRec1:outRec2},ClipperLib.Clipper.prototype.OutRec1RightOfOutRec2=function(outRec1,outRec2){do{if((outRec1=outRec1.FirstLeft)===outRec2)return!0}while(null!==outRec1);return!1},ClipperLib.Clipper.prototype.GetOutRec=function(idx){for(var outrec=this.m_PolyOuts[idx];outrec!==this.m_PolyOuts[outrec.Idx];)outrec=this.m_PolyOuts[outrec.Idx];return outrec},ClipperLib.Clipper.prototype.AppendPolygon=function(e1,e2){var holeStateRec,outRec1=this.m_PolyOuts[e1.OutIdx],outRec2=this.m_PolyOuts[e2.OutIdx];holeStateRec=this.OutRec1RightOfOutRec2(outRec1,outRec2)?outRec2:this.OutRec1RightOfOutRec2(outRec2,outRec1)?outRec1:this.GetLowermostRec(outRec1,outRec2);var p1_lft=outRec1.Pts,p1_rt=p1_lft.Prev,p2_lft=outRec2.Pts,p2_rt=p2_lft.Prev;e1.Side===ClipperLib.EdgeSide.esLeft?e2.Side===ClipperLib.EdgeSide.esLeft?(this.ReversePolyPtLinks(p2_lft),p2_lft.Next=p1_lft,p1_lft.Prev=p2_lft,p1_rt.Next=p2_rt,p2_rt.Prev=p1_rt,outRec1.Pts=p2_rt):(p2_rt.Next=p1_lft,p1_lft.Prev=p2_rt,p2_lft.Prev=p1_rt,p1_rt.Next=p2_lft,outRec1.Pts=p2_lft):e2.Side===ClipperLib.EdgeSide.esRight?(this.ReversePolyPtLinks(p2_lft),p1_rt.Next=p2_rt,p2_rt.Prev=p1_rt,p2_lft.Next=p1_lft,p1_lft.Prev=p2_lft):(p1_rt.Next=p2_lft,p2_lft.Prev=p1_rt,p1_lft.Prev=p2_rt,p2_rt.Next=p1_lft),outRec1.BottomPt=null,holeStateRec===outRec2&&(outRec2.FirstLeft!==outRec1&&(outRec1.FirstLeft=outRec2.FirstLeft),outRec1.IsHole=outRec2.IsHole),outRec2.Pts=null,outRec2.BottomPt=null,outRec2.FirstLeft=outRec1;var OKIdx=e1.OutIdx,ObsoleteIdx=e2.OutIdx;e1.OutIdx=-1,e2.OutIdx=-1;for(var e=this.m_ActiveEdges;null!==e;){if(e.OutIdx===ObsoleteIdx){e.OutIdx=OKIdx,e.Side=e1.Side;break}e=e.NextInAEL}outRec2.Idx=outRec1.Idx},ClipperLib.Clipper.prototype.ReversePolyPtLinks=function(pp){if(null!==pp){var pp1,pp2;pp1=pp;do{pp2=pp1.Next,pp1.Next=pp1.Prev,pp1.Prev=pp2,pp1=pp2}while(pp1!==pp)}},ClipperLib.Clipper.SwapSides=function(edge1,edge2){var side=edge1.Side;edge1.Side=edge2.Side,edge2.Side=side},ClipperLib.Clipper.SwapPolyIndexes=function(edge1,edge2){var outIdx=edge1.OutIdx;edge1.OutIdx=edge2.OutIdx,edge2.OutIdx=outIdx},ClipperLib.Clipper.prototype.IntersectEdges=function(e1,e2,pt){var e1Contributing=e1.OutIdx>=0,e2Contributing=e2.OutIdx>=0;if(ClipperLib.use_xyz&&this.SetZ(pt,e1,e2),!ClipperLib.use_lines||0!==e1.WindDelta&&0!==e2.WindDelta){if(e1.PolyTyp===e2.PolyTyp)if(this.IsEvenOddFillType(e1)){var oldE1WindCnt=e1.WindCnt;e1.WindCnt=e2.WindCnt,e2.WindCnt=oldE1WindCnt}else e1.WindCnt+e2.WindDelta===0?e1.WindCnt=-e1.WindCnt:e1.WindCnt+=e2.WindDelta,e2.WindCnt-e1.WindDelta==0?e2.WindCnt=-e2.WindCnt:e2.WindCnt-=e1.WindDelta;else this.IsEvenOddFillType(e2)?e1.WindCnt2=0===e1.WindCnt2?1:0:e1.WindCnt2+=e2.WindDelta,this.IsEvenOddFillType(e1)?e2.WindCnt2=0===e2.WindCnt2?1:0:e2.WindCnt2-=e1.WindDelta;var e1FillType,e2FillType,e1FillType2,e2FillType2,e1Wc,e2Wc;switch(e1.PolyTyp===ClipperLib.PolyType.ptSubject?(e1FillType=this.m_SubjFillType,e1FillType2=this.m_ClipFillType):(e1FillType=this.m_ClipFillType,e1FillType2=this.m_SubjFillType),e2.PolyTyp===ClipperLib.PolyType.ptSubject?(e2FillType=this.m_SubjFillType,e2FillType2=this.m_ClipFillType):(e2FillType=this.m_ClipFillType,e2FillType2=this.m_SubjFillType),e1FillType){case ClipperLib.PolyFillType.pftPositive:e1Wc=e1.WindCnt;break;case ClipperLib.PolyFillType.pftNegative:e1Wc=-e1.WindCnt;break;default:e1Wc=Math.abs(e1.WindCnt)}switch(e2FillType){case ClipperLib.PolyFillType.pftPositive:e2Wc=e2.WindCnt;break;case ClipperLib.PolyFillType.pftNegative:e2Wc=-e2.WindCnt;break;default:e2Wc=Math.abs(e2.WindCnt)}if(e1Contributing&&e2Contributing)0!==e1Wc&&1!==e1Wc||0!==e2Wc&&1!==e2Wc||e1.PolyTyp!==e2.PolyTyp&&this.m_ClipType!==ClipperLib.ClipType.ctXor?this.AddLocalMaxPoly(e1,e2,pt):(this.AddOutPt(e1,pt),this.AddOutPt(e2,pt),ClipperLib.Clipper.SwapSides(e1,e2),ClipperLib.Clipper.SwapPolyIndexes(e1,e2));else if(e1Contributing)0!==e2Wc&&1!==e2Wc||(this.AddOutPt(e1,pt),ClipperLib.Clipper.SwapSides(e1,e2),ClipperLib.Clipper.SwapPolyIndexes(e1,e2));else if(e2Contributing)0!==e1Wc&&1!==e1Wc||(this.AddOutPt(e2,pt),ClipperLib.Clipper.SwapSides(e1,e2),ClipperLib.Clipper.SwapPolyIndexes(e1,e2));else if(!(0!==e1Wc&&1!==e1Wc||0!==e2Wc&&1!==e2Wc)){var e1Wc2,e2Wc2;switch(e1FillType2){case ClipperLib.PolyFillType.pftPositive:e1Wc2=e1.WindCnt2;break;case ClipperLib.PolyFillType.pftNegative:e1Wc2=-e1.WindCnt2;break;default:e1Wc2=Math.abs(e1.WindCnt2)}switch(e2FillType2){case ClipperLib.PolyFillType.pftPositive:e2Wc2=e2.WindCnt2;break;case ClipperLib.PolyFillType.pftNegative:e2Wc2=-e2.WindCnt2;break;default:e2Wc2=Math.abs(e2.WindCnt2)}if(e1.PolyTyp!==e2.PolyTyp)this.AddLocalMinPoly(e1,e2,pt);else if(1===e1Wc&&1===e2Wc)switch(this.m_ClipType){case ClipperLib.ClipType.ctIntersection:e1Wc2>0&&e2Wc2>0&&this.AddLocalMinPoly(e1,e2,pt);break;case ClipperLib.ClipType.ctUnion:e1Wc2<=0&&e2Wc2<=0&&this.AddLocalMinPoly(e1,e2,pt);break;case ClipperLib.ClipType.ctDifference:(e1.PolyTyp===ClipperLib.PolyType.ptClip&&e1Wc2>0&&e2Wc2>0||e1.PolyTyp===ClipperLib.PolyType.ptSubject&&e1Wc2<=0&&e2Wc2<=0)&&this.AddLocalMinPoly(e1,e2,pt);break;case ClipperLib.ClipType.ctXor:this.AddLocalMinPoly(e1,e2,pt)}else ClipperLib.Clipper.SwapSides(e1,e2)}}else{if(0===e1.WindDelta&&0===e2.WindDelta)return;e1.PolyTyp===e2.PolyTyp&&e1.WindDelta!==e2.WindDelta&&this.m_ClipType===ClipperLib.ClipType.ctUnion?0===e1.WindDelta?e2Contributing&&(this.AddOutPt(e1,pt),e1Contributing&&(e1.OutIdx=-1)):e1Contributing&&(this.AddOutPt(e2,pt),e2Contributing&&(e2.OutIdx=-1)):e1.PolyTyp!==e2.PolyTyp&&(0!==e1.WindDelta||1!==Math.abs(e2.WindCnt)||this.m_ClipType===ClipperLib.ClipType.ctUnion&&0!==e2.WindCnt2?0!==e2.WindDelta||1!==Math.abs(e1.WindCnt)||this.m_ClipType===ClipperLib.ClipType.ctUnion&&0!==e1.WindCnt2||(this.AddOutPt(e2,pt),e2Contributing&&(e2.OutIdx=-1)):(this.AddOutPt(e1,pt),e1Contributing&&(e1.OutIdx=-1)))}},ClipperLib.Clipper.prototype.DeleteFromSEL=function(e){var SelPrev=e.PrevInSEL,SelNext=e.NextInSEL;null===SelPrev&&null===SelNext&&e!==this.m_SortedEdges||(null!==SelPrev?SelPrev.NextInSEL=SelNext:this.m_SortedEdges=SelNext,null!==SelNext&&(SelNext.PrevInSEL=SelPrev),e.NextInSEL=null,e.PrevInSEL=null)},ClipperLib.Clipper.prototype.ProcessHorizontals=function(){for(var horzEdge={};this.PopEdgeFromSEL(horzEdge);)this.ProcessHorizontal(horzEdge.v)},ClipperLib.Clipper.prototype.GetHorzDirection=function(HorzEdge,$var){HorzEdge.Bot.X<HorzEdge.Top.X?($var.Left=HorzEdge.Bot.X,$var.Right=HorzEdge.Top.X,$var.Dir=ClipperLib.Direction.dLeftToRight):($var.Left=HorzEdge.Top.X,$var.Right=HorzEdge.Bot.X,$var.Dir=ClipperLib.Direction.dRightToLeft)},ClipperLib.Clipper.prototype.ProcessHorizontal=function(horzEdge){var $var={Dir:null,Left:null,Right:null};this.GetHorzDirection(horzEdge,$var);for(var dir=$var.Dir,horzLeft=$var.Left,horzRight=$var.Right,IsOpen=0===horzEdge.WindDelta,eLastHorz=horzEdge,eMaxPair=null;null!==eLastHorz.NextInLML&&ClipperLib.ClipperBase.IsHorizontal(eLastHorz.NextInLML);)eLastHorz=eLastHorz.NextInLML;null===eLastHorz.NextInLML&&(eMaxPair=this.GetMaximaPair(eLastHorz));var currMax=this.m_Maxima;if(null!==currMax)if(dir===ClipperLib.Direction.dLeftToRight){for(;null!==currMax&&currMax.X<=horzEdge.Bot.X;)currMax=currMax.Next;null!==currMax&&currMax.X>=eLastHorz.Top.X&&(currMax=null)}else{for(;null!==currMax.Next&&currMax.Next.X<horzEdge.Bot.X;)currMax=currMax.Next;currMax.X<=eLastHorz.Top.X&&(currMax=null)}for(var op1=null;;){for(var IsLastHorz=horzEdge===eLastHorz,e=this.GetNextInAEL(horzEdge,dir);null!==e;){if(null!==currMax)if(dir===ClipperLib.Direction.dLeftToRight)for(;null!==currMax&&currMax.X<e.Curr.X;)horzEdge.OutIdx>=0&&!IsOpen&&this.AddOutPt(horzEdge,new ClipperLib.IntPoint2(currMax.X,horzEdge.Bot.Y)),currMax=currMax.Next;else for(;null!==currMax&&currMax.X>e.Curr.X;)horzEdge.OutIdx>=0&&!IsOpen&&this.AddOutPt(horzEdge,new ClipperLib.IntPoint2(currMax.X,horzEdge.Bot.Y)),currMax=currMax.Prev;if(dir===ClipperLib.Direction.dLeftToRight&&e.Curr.X>horzRight||dir===ClipperLib.Direction.dRightToLeft&&e.Curr.X<horzLeft)break;if(e.Curr.X===horzEdge.Top.X&&null!==horzEdge.NextInLML&&e.Dx<horzEdge.NextInLML.Dx)break;if(horzEdge.OutIdx>=0&&!IsOpen){ClipperLib.use_xyz&&(dir===ClipperLib.Direction.dLeftToRight?this.SetZ(e.Curr,horzEdge,e):this.SetZ(e.Curr,e,horzEdge)),op1=this.AddOutPt(horzEdge,e.Curr);for(var eNextHorz=this.m_SortedEdges;null!==eNextHorz;){if(eNextHorz.OutIdx>=0&&this.HorzSegmentsOverlap(horzEdge.Bot.X,horzEdge.Top.X,eNextHorz.Bot.X,eNextHorz.Top.X)){var op2=this.GetLastOutPt(eNextHorz);this.AddJoin(op2,op1,eNextHorz.Top)}eNextHorz=eNextHorz.NextInSEL}this.AddGhostJoin(op1,horzEdge.Bot)}if(e===eMaxPair&&IsLastHorz)return horzEdge.OutIdx>=0&&this.AddLocalMaxPoly(horzEdge,eMaxPair,horzEdge.Top),this.DeleteFromAEL(horzEdge),void this.DeleteFromAEL(eMaxPair);if(dir===ClipperLib.Direction.dLeftToRight){var Pt=new ClipperLib.IntPoint2(e.Curr.X,horzEdge.Curr.Y);this.IntersectEdges(horzEdge,e,Pt)}else Pt=new ClipperLib.IntPoint2(e.Curr.X,horzEdge.Curr.Y),this.IntersectEdges(e,horzEdge,Pt);var eNext=this.GetNextInAEL(e,dir);this.SwapPositionsInAEL(horzEdge,e),e=eNext}if(null===horzEdge.NextInLML||!ClipperLib.ClipperBase.IsHorizontal(horzEdge.NextInLML))break;(horzEdge=this.UpdateEdgeIntoAEL(horzEdge)).OutIdx>=0&&this.AddOutPt(horzEdge,horzEdge.Bot),$var={Dir:dir,Left:horzLeft,Right:horzRight},this.GetHorzDirection(horzEdge,$var),dir=$var.Dir,horzLeft=$var.Left,horzRight=$var.Right}if(horzEdge.OutIdx>=0&&null===op1){for(op1=this.GetLastOutPt(horzEdge),eNextHorz=this.m_SortedEdges;null!==eNextHorz;)eNextHorz.OutIdx>=0&&this.HorzSegmentsOverlap(horzEdge.Bot.X,horzEdge.Top.X,eNextHorz.Bot.X,eNextHorz.Top.X)&&(op2=this.GetLastOutPt(eNextHorz),this.AddJoin(op2,op1,eNextHorz.Top)),eNextHorz=eNextHorz.NextInSEL;this.AddGhostJoin(op1,horzEdge.Top)}if(null!==horzEdge.NextInLML)if(horzEdge.OutIdx>=0){if(op1=this.AddOutPt(horzEdge,horzEdge.Top),0===(horzEdge=this.UpdateEdgeIntoAEL(horzEdge)).WindDelta)return;var ePrev=horzEdge.PrevInAEL;eNext=horzEdge.NextInAEL,null!==ePrev&&ePrev.Curr.X===horzEdge.Bot.X&&ePrev.Curr.Y===horzEdge.Bot.Y&&0===ePrev.WindDelta&&ePrev.OutIdx>=0&&ePrev.Curr.Y>ePrev.Top.Y&&ClipperLib.ClipperBase.SlopesEqual3(horzEdge,ePrev,this.m_UseFullRange)?(op2=this.AddOutPt(ePrev,horzEdge.Bot),this.AddJoin(op1,op2,horzEdge.Top)):null!==eNext&&eNext.Curr.X===horzEdge.Bot.X&&eNext.Curr.Y===horzEdge.Bot.Y&&0!==eNext.WindDelta&&eNext.OutIdx>=0&&eNext.Curr.Y>eNext.Top.Y&&ClipperLib.ClipperBase.SlopesEqual3(horzEdge,eNext,this.m_UseFullRange)&&(op2=this.AddOutPt(eNext,horzEdge.Bot),this.AddJoin(op1,op2,horzEdge.Top))}else horzEdge=this.UpdateEdgeIntoAEL(horzEdge);else horzEdge.OutIdx>=0&&this.AddOutPt(horzEdge,horzEdge.Top),this.DeleteFromAEL(horzEdge)},ClipperLib.Clipper.prototype.GetNextInAEL=function(e,Direction){return Direction===ClipperLib.Direction.dLeftToRight?e.NextInAEL:e.PrevInAEL},ClipperLib.Clipper.prototype.IsMinima=function(e){return null!==e&&e.Prev.NextInLML!==e&&e.Next.NextInLML!==e},ClipperLib.Clipper.prototype.IsMaxima=function(e,Y){return null!==e&&e.Top.Y===Y&&null===e.NextInLML},ClipperLib.Clipper.prototype.IsIntermediate=function(e,Y){return e.Top.Y===Y&&null!==e.NextInLML},ClipperLib.Clipper.prototype.GetMaximaPair=function(e){return ClipperLib.IntPoint.op_Equality(e.Next.Top,e.Top)&&null===e.Next.NextInLML?e.Next:ClipperLib.IntPoint.op_Equality(e.Prev.Top,e.Top)&&null===e.Prev.NextInLML?e.Prev:null},ClipperLib.Clipper.prototype.GetMaximaPairEx=function(e){var result=this.GetMaximaPair(e);return null===result||result.OutIdx===ClipperLib.ClipperBase.Skip||result.NextInAEL===result.PrevInAEL&&!ClipperLib.ClipperBase.IsHorizontal(result)?null:result},ClipperLib.Clipper.prototype.ProcessIntersections=function(topY){if(null===this.m_ActiveEdges)return!0;try{if(this.BuildIntersectList(topY),0===this.m_IntersectList.length)return!0;if(1!==this.m_IntersectList.length&&!this.FixupIntersectionOrder())return!1;this.ProcessIntersectList()}catch($$e2){this.m_SortedEdges=null,this.m_IntersectList.length=0,ClipperLib.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0},ClipperLib.Clipper.prototype.BuildIntersectList=function(topY){if(null!==this.m_ActiveEdges){var e=this.m_ActiveEdges;for(this.m_SortedEdges=e;null!==e;)e.PrevInSEL=e.PrevInAEL,e.NextInSEL=e.NextInAEL,e.Curr.X=ClipperLib.Clipper.TopX(e,topY),e=e.NextInAEL;for(var isModified=!0;isModified&&null!==this.m_SortedEdges;){for(isModified=!1,e=this.m_SortedEdges;null!==e.NextInSEL;){var eNext=e.NextInSEL,pt=new ClipperLib.IntPoint0;if(e.Curr.X>eNext.Curr.X){this.IntersectPoint(e,eNext,pt),pt.Y<topY&&(pt=new ClipperLib.IntPoint2(ClipperLib.Clipper.TopX(e,topY),topY));var newNode=new ClipperLib.IntersectNode;newNode.Edge1=e,newNode.Edge2=eNext,newNode.Pt.X=pt.X,newNode.Pt.Y=pt.Y,ClipperLib.use_xyz&&(newNode.Pt.Z=pt.Z),this.m_IntersectList.push(newNode),this.SwapPositionsInSEL(e,eNext),isModified=!0}else e=eNext}if(null===e.PrevInSEL)break;e.PrevInSEL.NextInSEL=null}this.m_SortedEdges=null}},ClipperLib.Clipper.prototype.EdgesAdjacent=function(inode){return inode.Edge1.NextInSEL===inode.Edge2||inode.Edge1.PrevInSEL===inode.Edge2},ClipperLib.Clipper.IntersectNodeSort=function(node1,node2){return node2.Pt.Y-node1.Pt.Y},ClipperLib.Clipper.prototype.FixupIntersectionOrder=function(){this.m_IntersectList.sort(this.m_IntersectNodeComparer),this.CopyAELToSEL();for(var cnt=this.m_IntersectList.length,i=0;i<cnt;i++){if(!this.EdgesAdjacent(this.m_IntersectList[i])){for(var j=i+1;j<cnt&&!this.EdgesAdjacent(this.m_IntersectList[j]);)j++;if(j===cnt)return!1;var tmp=this.m_IntersectList[i];this.m_IntersectList[i]=this.m_IntersectList[j],this.m_IntersectList[j]=tmp}this.SwapPositionsInSEL(this.m_IntersectList[i].Edge1,this.m_IntersectList[i].Edge2)}return!0},ClipperLib.Clipper.prototype.ProcessIntersectList=function(){for(var i=0,ilen=this.m_IntersectList.length;i<ilen;i++){var iNode=this.m_IntersectList[i];this.IntersectEdges(iNode.Edge1,iNode.Edge2,iNode.Pt),this.SwapPositionsInAEL(iNode.Edge1,iNode.Edge2)}this.m_IntersectList.length=0},browser.msie?ClipperLib.Clipper.Round=function(a){return a<0?Math.ceil(a-.5):Math.round(a)}:browser.chromium?ClipperLib.Clipper.Round=function(a){return a<0?-Math.round(Math.abs(a)):Math.round(a)}:browser.safari?ClipperLib.Clipper.Round=function(a){return a<0?(a-=.5)<-2147483648?Math.ceil(a):0|a:(a+=.5)>2147483647?Math.floor(a):0|a}:ClipperLib.Clipper.Round=function(a){return a<0?Math.ceil(a-.5):Math.floor(a+.5)},ClipperLib.Clipper.TopX=function(edge,currentY){return currentY===edge.Top.Y?edge.Top.X:edge.Bot.X+ClipperLib.Clipper.Round(edge.Dx*(currentY-edge.Bot.Y))},ClipperLib.Clipper.prototype.IntersectPoint=function(edge1,edge2,ip){var b1,b2;if(ip.X=0,ip.Y=0,edge1.Dx===edge2.Dx)return ip.Y=edge1.Curr.Y,void(ip.X=ClipperLib.Clipper.TopX(edge1,ip.Y));if(0===edge1.Delta.X)ip.X=edge1.Bot.X,ClipperLib.ClipperBase.IsHorizontal(edge2)?ip.Y=edge2.Bot.Y:(b2=edge2.Bot.Y-edge2.Bot.X/edge2.Dx,ip.Y=ClipperLib.Clipper.Round(ip.X/edge2.Dx+b2));else if(0===edge2.Delta.X)ip.X=edge2.Bot.X,ClipperLib.ClipperBase.IsHorizontal(edge1)?ip.Y=edge1.Bot.Y:(b1=edge1.Bot.Y-edge1.Bot.X/edge1.Dx,ip.Y=ClipperLib.Clipper.Round(ip.X/edge1.Dx+b1));else{b1=edge1.Bot.X-edge1.Bot.Y*edge1.Dx;var q=((b2=edge2.Bot.X-edge2.Bot.Y*edge2.Dx)-b1)/(edge1.Dx-edge2.Dx);ip.Y=ClipperLib.Clipper.Round(q),Math.abs(edge1.Dx)<Math.abs(edge2.Dx)?ip.X=ClipperLib.Clipper.Round(edge1.Dx*q+b1):ip.X=ClipperLib.Clipper.Round(edge2.Dx*q+b2)}if(ip.Y<edge1.Top.Y||ip.Y<edge2.Top.Y){if(edge1.Top.Y>edge2.Top.Y)return ip.Y=edge1.Top.Y,ip.X=ClipperLib.Clipper.TopX(edge2,edge1.Top.Y),ip.X<edge1.Top.X;ip.Y=edge2.Top.Y,Math.abs(edge1.Dx)<Math.abs(edge2.Dx)?ip.X=ClipperLib.Clipper.TopX(edge1,ip.Y):ip.X=ClipperLib.Clipper.TopX(edge2,ip.Y)}ip.Y>edge1.Curr.Y&&(ip.Y=edge1.Curr.Y,Math.abs(edge1.Dx)>Math.abs(edge2.Dx)?ip.X=ClipperLib.Clipper.TopX(edge2,ip.Y):ip.X=ClipperLib.Clipper.TopX(edge1,ip.Y))},ClipperLib.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(topY){for(var e=this.m_ActiveEdges;null!==e;){var IsMaximaEdge=this.IsMaxima(e,topY);if(IsMaximaEdge){var eMaxPair=this.GetMaximaPairEx(e);IsMaximaEdge=null===eMaxPair||!ClipperLib.ClipperBase.IsHorizontal(eMaxPair)}if(IsMaximaEdge){this.StrictlySimple&&this.InsertMaxima(e.Top.X);var ePrev=e.PrevInAEL;this.DoMaxima(e),e=null===ePrev?this.m_ActiveEdges:ePrev.NextInAEL}else{if(this.IsIntermediate(e,topY)&&ClipperLib.ClipperBase.IsHorizontal(e.NextInLML)?((e=this.UpdateEdgeIntoAEL(e)).OutIdx>=0&&this.AddOutPt(e,e.Bot),this.AddEdgeToSEL(e)):(e.Curr.X=ClipperLib.Clipper.TopX(e,topY),e.Curr.Y=topY),ClipperLib.use_xyz&&(e.Top.Y===topY?e.Curr.Z=e.Top.Z:e.Bot.Y===topY?e.Curr.Z=e.Bot.Z:e.Curr.Z=0),this.StrictlySimple&&(ePrev=e.PrevInAEL,e.OutIdx>=0&&0!==e.WindDelta&&null!==ePrev&&ePrev.OutIdx>=0&&ePrev.Curr.X===e.Curr.X&&0!==ePrev.WindDelta)){var ip=new ClipperLib.IntPoint1(e.Curr);ClipperLib.use_xyz&&this.SetZ(ip,ePrev,e);var op=this.AddOutPt(ePrev,ip),op2=this.AddOutPt(e,ip);this.AddJoin(op,op2,ip)}e=e.NextInAEL}}for(this.ProcessHorizontals(),this.m_Maxima=null,e=this.m_ActiveEdges;null!==e;){if(this.IsIntermediate(e,topY)){op=null,e.OutIdx>=0&&(op=this.AddOutPt(e,e.Top)),ePrev=(e=this.UpdateEdgeIntoAEL(e)).PrevInAEL;var eNext=e.NextInAEL;null!==ePrev&&ePrev.Curr.X===e.Bot.X&&ePrev.Curr.Y===e.Bot.Y&&null!==op&&ePrev.OutIdx>=0&&ePrev.Curr.Y===ePrev.Top.Y&&ClipperLib.ClipperBase.SlopesEqual5(e.Curr,e.Top,ePrev.Curr,ePrev.Top,this.m_UseFullRange)&&0!==e.WindDelta&&0!==ePrev.WindDelta?(op2=this.AddOutPt(ePrev2,e.Bot),this.AddJoin(op,op2,e.Top)):null!==eNext&&eNext.Curr.X===e.Bot.X&&eNext.Curr.Y===e.Bot.Y&&null!==op&&eNext.OutIdx>=0&&eNext.Curr.Y===eNext.Top.Y&&ClipperLib.ClipperBase.SlopesEqual5(e.Curr,e.Top,eNext.Curr,eNext.Top,this.m_UseFullRange)&&0!==e.WindDelta&&0!==eNext.WindDelta&&(op2=this.AddOutPt(eNext,e.Bot),this.AddJoin(op,op2,e.Top))}e=e.NextInAEL}},ClipperLib.Clipper.prototype.DoMaxima=function(e){var eMaxPair=this.GetMaximaPairEx(e);if(null===eMaxPair)return e.OutIdx>=0&&this.AddOutPt(e,e.Top),void this.DeleteFromAEL(e);for(var eNext=e.NextInAEL;null!==eNext&&eNext!==eMaxPair;)this.IntersectEdges(e,eNext,e.Top),this.SwapPositionsInAEL(e,eNext),eNext=e.NextInAEL;-1===e.OutIdx&&-1===eMaxPair.OutIdx?(this.DeleteFromAEL(e),this.DeleteFromAEL(eMaxPair)):e.OutIdx>=0&&eMaxPair.OutIdx>=0?(e.OutIdx>=0&&this.AddLocalMaxPoly(e,eMaxPair,e.Top),this.DeleteFromAEL(e),this.DeleteFromAEL(eMaxPair)):ClipperLib.use_lines&&0===e.WindDelta?(e.OutIdx>=0&&(this.AddOutPt(e,e.Top),e.OutIdx=ClipperLib.ClipperBase.Unassigned),this.DeleteFromAEL(e),eMaxPair.OutIdx>=0&&(this.AddOutPt(eMaxPair,e.Top),eMaxPair.OutIdx=ClipperLib.ClipperBase.Unassigned),this.DeleteFromAEL(eMaxPair)):ClipperLib.Error("DoMaxima error")},ClipperLib.Clipper.ReversePaths=function(polys){for(var i=0,len=polys.length;i<len;i++)polys[i].reverse()},ClipperLib.Clipper.Orientation=function(poly){return ClipperLib.Clipper.Area(poly)>=0},ClipperLib.Clipper.prototype.PointCount=function(pts){if(null===pts)return 0;var result=0,p=pts;do{result++,p=p.Next}while(p!==pts);return result},ClipperLib.Clipper.prototype.BuildResult=function(polyg){ClipperLib.Clear(polyg);for(var i=0,ilen=this.m_PolyOuts.length;i<ilen;i++){var outRec=this.m_PolyOuts[i];if(null!==outRec.Pts){var p=outRec.Pts.Prev,cnt=this.PointCount(p);if(!(cnt<2)){for(var pg=new Array(cnt),j=0;j<cnt;j++)pg[j]=p.Pt,p=p.Prev;polyg.push(pg)}}}},ClipperLib.Clipper.prototype.BuildResult2=function(polytree){polytree.Clear();for(var i=0,ilen=this.m_PolyOuts.length;i<ilen;i++){var outRec=this.m_PolyOuts[i],cnt=this.PointCount(outRec.Pts);if(!(outRec.IsOpen&&cnt<2||!outRec.IsOpen&&cnt<3)){this.FixHoleLinkage(outRec);var pn=new ClipperLib.PolyNode;polytree.m_AllPolys.push(pn),outRec.PolyNode=pn,pn.m_polygon.length=cnt;for(var op=outRec.Pts.Prev,j=0;j<cnt;j++)pn.m_polygon[j]=op.Pt,op=op.Prev}}for(i=0,ilen=this.m_PolyOuts.length;i<ilen;i++)null!==(outRec=this.m_PolyOuts[i]).PolyNode&&(outRec.IsOpen?(outRec.PolyNode.IsOpen=!0,polytree.AddChild(outRec.PolyNode)):null!==outRec.FirstLeft&&null!==outRec.FirstLeft.PolyNode?outRec.FirstLeft.PolyNode.AddChild(outRec.PolyNode):polytree.AddChild(outRec.PolyNode))},ClipperLib.Clipper.prototype.FixupOutPolyline=function(outRec){for(var pp=outRec.Pts,lastPP=pp.Prev;pp!==lastPP;)if(pp=pp.Next,ClipperLib.IntPoint.op_Equality(pp.Pt,pp.Prev.Pt)){pp===lastPP&&(lastPP=pp.Prev);var tmpPP=pp.Prev;tmpPP.Next=pp.Next,pp.Next.Prev=tmpPP,pp=tmpPP}pp===pp.Prev&&(outRec.Pts=null)},ClipperLib.Clipper.prototype.FixupOutPolygon=function(outRec){var lastOK=null;outRec.BottomPt=null;for(var pp=outRec.Pts,preserveCol=this.PreserveCollinear||this.StrictlySimple;;){if(pp.Prev===pp||pp.Prev===pp.Next)return void(outRec.Pts=null);if(ClipperLib.IntPoint.op_Equality(pp.Pt,pp.Next.Pt)||ClipperLib.IntPoint.op_Equality(pp.Pt,pp.Prev.Pt)||ClipperLib.ClipperBase.SlopesEqual4(pp.Prev.Pt,pp.Pt,pp.Next.Pt,this.m_UseFullRange)&&(!preserveCol||!this.Pt2IsBetweenPt1AndPt3(pp.Prev.Pt,pp.Pt,pp.Next.Pt)))lastOK=null,pp.Prev.Next=pp.Next,pp.Next.Prev=pp.Prev,pp=pp.Prev;else{if(pp===lastOK)break;null===lastOK&&(lastOK=pp),pp=pp.Next}}outRec.Pts=pp},ClipperLib.Clipper.prototype.DupOutPt=function(outPt,InsertAfter){var result=new ClipperLib.OutPt;return result.Pt.X=outPt.Pt.X,result.Pt.Y=outPt.Pt.Y,ClipperLib.use_xyz&&(result.Pt.Z=outPt.Pt.Z),result.Idx=outPt.Idx,InsertAfter?(result.Next=outPt.Next,result.Prev=outPt,outPt.Next.Prev=result,outPt.Next=result):(result.Prev=outPt.Prev,result.Next=outPt,outPt.Prev.Next=result,outPt.Prev=result),result},ClipperLib.Clipper.prototype.GetOverlap=function(a1,a2,b1,b2,$val){return a1<a2?b1<b2?($val.Left=Math.max(a1,b1),$val.Right=Math.min(a2,b2)):($val.Left=Math.max(a1,b2),$val.Right=Math.min(a2,b1)):b1<b2?($val.Left=Math.max(a2,b1),$val.Right=Math.min(a1,b2)):($val.Left=Math.max(a2,b2),$val.Right=Math.min(a1,b1)),$val.Left<$val.Right},ClipperLib.Clipper.prototype.JoinHorz=function(op1,op1b,op2,op2b,Pt,DiscardLeft){var Dir1=op1.Pt.X>op1b.Pt.X?ClipperLib.Direction.dRightToLeft:ClipperLib.Direction.dLeftToRight,Dir2=op2.Pt.X>op2b.Pt.X?ClipperLib.Direction.dRightToLeft:ClipperLib.Direction.dLeftToRight;if(Dir1===Dir2)return!1;if(Dir1===ClipperLib.Direction.dLeftToRight){for(;op1.Next.Pt.X<=Pt.X&&op1.Next.Pt.X>=op1.Pt.X&&op1.Next.Pt.Y===Pt.Y;)op1=op1.Next;DiscardLeft&&op1.Pt.X!==Pt.X&&(op1=op1.Next),op1b=this.DupOutPt(op1,!DiscardLeft),ClipperLib.IntPoint.op_Inequality(op1b.Pt,Pt)&&((op1=op1b).Pt.X=Pt.X,op1.Pt.Y=Pt.Y,ClipperLib.use_xyz&&(op1.Pt.Z=Pt.Z),op1b=this.DupOutPt(op1,!DiscardLeft))}else{for(;op1.Next.Pt.X>=Pt.X&&op1.Next.Pt.X<=op1.Pt.X&&op1.Next.Pt.Y===Pt.Y;)op1=op1.Next;DiscardLeft||op1.Pt.X===Pt.X||(op1=op1.Next),op1b=this.DupOutPt(op1,DiscardLeft),ClipperLib.IntPoint.op_Inequality(op1b.Pt,Pt)&&((op1=op1b).Pt.X=Pt.X,op1.Pt.Y=Pt.Y,ClipperLib.use_xyz&&(op1.Pt.Z=Pt.Z),op1b=this.DupOutPt(op1,DiscardLeft))}if(Dir2===ClipperLib.Direction.dLeftToRight){for(;op2.Next.Pt.X<=Pt.X&&op2.Next.Pt.X>=op2.Pt.X&&op2.Next.Pt.Y===Pt.Y;)op2=op2.Next;DiscardLeft&&op2.Pt.X!==Pt.X&&(op2=op2.Next),op2b=this.DupOutPt(op2,!DiscardLeft),ClipperLib.IntPoint.op_Inequality(op2b.Pt,Pt)&&((op2=op2b).Pt.X=Pt.X,op2.Pt.Y=Pt.Y,ClipperLib.use_xyz&&(op2.Pt.Z=Pt.Z),op2b=this.DupOutPt(op2,!DiscardLeft))}else{for(;op2.Next.Pt.X>=Pt.X&&op2.Next.Pt.X<=op2.Pt.X&&op2.Next.Pt.Y===Pt.Y;)op2=op2.Next;DiscardLeft||op2.Pt.X===Pt.X||(op2=op2.Next),op2b=this.DupOutPt(op2,DiscardLeft),ClipperLib.IntPoint.op_Inequality(op2b.Pt,Pt)&&((op2=op2b).Pt.X=Pt.X,op2.Pt.Y=Pt.Y,ClipperLib.use_xyz&&(op2.Pt.Z=Pt.Z),op2b=this.DupOutPt(op2,DiscardLeft))}return Dir1===ClipperLib.Direction.dLeftToRight===DiscardLeft?(op1.Prev=op2,op2.Next=op1,op1b.Next=op2b,op2b.Prev=op1b):(op1.Next=op2,op2.Prev=op1,op1b.Prev=op2b,op2b.Next=op1b),!0},ClipperLib.Clipper.prototype.JoinPoints=function(j,outRec1,outRec2){var op1=j.OutPt1,op1b=new ClipperLib.OutPt,op2=j.OutPt2,op2b=new ClipperLib.OutPt,isHorizontal=j.OutPt1.Pt.Y===j.OffPt.Y;if(isHorizontal&&ClipperLib.IntPoint.op_Equality(j.OffPt,j.OutPt1.Pt)&&ClipperLib.IntPoint.op_Equality(j.OffPt,j.OutPt2.Pt)){if(outRec1!==outRec2)return!1;for(op1b=j.OutPt1.Next;op1b!==op1&&ClipperLib.IntPoint.op_Equality(op1b.Pt,j.OffPt);)op1b=op1b.Next;var reverse1=op1b.Pt.Y>j.OffPt.Y;for(op2b=j.OutPt2.Next;op2b!==op2&&ClipperLib.IntPoint.op_Equality(op2b.Pt,j.OffPt);)op2b=op2b.Next;return reverse1!==op2b.Pt.Y>j.OffPt.Y&&(reverse1?(op1b=this.DupOutPt(op1,!1),op2b=this.DupOutPt(op2,!0),op1.Prev=op2,op2.Next=op1,op1b.Next=op2b,op2b.Prev=op1b,j.OutPt1=op1,j.OutPt2=op1b,!0):(op1b=this.DupOutPt(op1,!0),op2b=this.DupOutPt(op2,!1),op1.Next=op2,op2.Prev=op1,op1b.Prev=op2b,op2b.Next=op1b,j.OutPt1=op1,j.OutPt2=op1b,!0))}if(isHorizontal){for(op1b=op1;op1.Prev.Pt.Y===op1.Pt.Y&&op1.Prev!==op1b&&op1.Prev!==op2;)op1=op1.Prev;for(;op1b.Next.Pt.Y===op1b.Pt.Y&&op1b.Next!==op1&&op1b.Next!==op2;)op1b=op1b.Next;if(op1b.Next===op1||op1b.Next===op2)return!1;for(op2b=op2;op2.Prev.Pt.Y===op2.Pt.Y&&op2.Prev!==op2b&&op2.Prev!==op1b;)op2=op2.Prev;for(;op2b.Next.Pt.Y===op2b.Pt.Y&&op2b.Next!==op2&&op2b.Next!==op1;)op2b=op2b.Next;if(op2b.Next===op2||op2b.Next===op1)return!1;var $val={Left:null,Right:null};if(!this.GetOverlap(op1.Pt.X,op1b.Pt.X,op2.Pt.X,op2b.Pt.X,$val))return!1;var DiscardLeftSide,Left=$val.Left,Right=$val.Right,Pt=new ClipperLib.IntPoint0;return op1.Pt.X>=Left&&op1.Pt.X<=Right?(Pt.X=op1.Pt.X,Pt.Y=op1.Pt.Y,ClipperLib.use_xyz&&(Pt.Z=op1.Pt.Z),DiscardLeftSide=op1.Pt.X>op1b.Pt.X):op2.Pt.X>=Left&&op2.Pt.X<=Right?(Pt.X=op2.Pt.X,Pt.Y=op2.Pt.Y,ClipperLib.use_xyz&&(Pt.Z=op2.Pt.Z),DiscardLeftSide=op2.Pt.X>op2b.Pt.X):op1b.Pt.X>=Left&&op1b.Pt.X<=Right?(Pt.X=op1b.Pt.X,Pt.Y=op1b.Pt.Y,ClipperLib.use_xyz&&(Pt.Z=op1b.Pt.Z),DiscardLeftSide=op1b.Pt.X>op1.Pt.X):(Pt.X=op2b.Pt.X,Pt.Y=op2b.Pt.Y,ClipperLib.use_xyz&&(Pt.Z=op2b.Pt.Z),DiscardLeftSide=op2b.Pt.X>op2.Pt.X),j.OutPt1=op1,j.OutPt2=op2,this.JoinHorz(op1,op1b,op2,op2b,Pt,DiscardLeftSide)}for(op1b=op1.Next;ClipperLib.IntPoint.op_Equality(op1b.Pt,op1.Pt)&&op1b!==op1;)op1b=op1b.Next;var Reverse1=op1b.Pt.Y>op1.Pt.Y||!ClipperLib.ClipperBase.SlopesEqual4(op1.Pt,op1b.Pt,j.OffPt,this.m_UseFullRange);if(Reverse1){for(op1b=op1.Prev;ClipperLib.IntPoint.op_Equality(op1b.Pt,op1.Pt)&&op1b!==op1;)op1b=op1b.Prev;if(op1b.Pt.Y>op1.Pt.Y||!ClipperLib.ClipperBase.SlopesEqual4(op1.Pt,op1b.Pt,j.OffPt,this.m_UseFullRange))return!1}for(op2b=op2.Next;ClipperLib.IntPoint.op_Equality(op2b.Pt,op2.Pt)&&op2b!==op2;)op2b=op2b.Next;var Reverse2=op2b.Pt.Y>op2.Pt.Y||!ClipperLib.ClipperBase.SlopesEqual4(op2.Pt,op2b.Pt,j.OffPt,this.m_UseFullRange);if(Reverse2){for(op2b=op2.Prev;ClipperLib.IntPoint.op_Equality(op2b.Pt,op2.Pt)&&op2b!==op2;)op2b=op2b.Prev;if(op2b.Pt.Y>op2.Pt.Y||!ClipperLib.ClipperBase.SlopesEqual4(op2.Pt,op2b.Pt,j.OffPt,this.m_UseFullRange))return!1}return!(op1b===op1||op2b===op2||op1b===op2b||outRec1===outRec2&&Reverse1===Reverse2||(Reverse1?(op1b=this.DupOutPt(op1,!1),op2b=this.DupOutPt(op2,!0),op1.Prev=op2,op2.Next=op1,op1b.Next=op2b,op2b.Prev=op1b,j.OutPt1=op1,j.OutPt2=op1b,0):(op1b=this.DupOutPt(op1,!0),op2b=this.DupOutPt(op2,!1),op1.Next=op2,op2.Prev=op1,op1b.Prev=op2b,op2b.Next=op1b,j.OutPt1=op1,j.OutPt2=op1b,0)))},ClipperLib.Clipper.GetBounds=function(paths){for(var i=0,cnt=paths.length;i<cnt&&0===paths[i].length;)i++;if(i===cnt)return new ClipperLib.IntRect(0,0,0,0);var result=new ClipperLib.IntRect;for(result.left=paths[i][0].X,result.right=result.left,result.top=paths[i][0].Y,result.bottom=result.top;i<cnt;i++)for(var j=0,jlen=paths[i].length;j<jlen;j++)paths[i][j].X<result.left?result.left=paths[i][j].X:paths[i][j].X>result.right&&(result.right=paths[i][j].X),paths[i][j].Y<result.top?result.top=paths[i][j].Y:paths[i][j].Y>result.bottom&&(result.bottom=paths[i][j].Y);return result},ClipperLib.Clipper.prototype.GetBounds2=function(ops){var opStart=ops,result=new ClipperLib.IntRect;for(result.left=ops.Pt.X,result.right=ops.Pt.X,result.top=ops.Pt.Y,result.bottom=ops.Pt.Y,ops=ops.Next;ops!==opStart;)ops.Pt.X<result.left&&(result.left=ops.Pt.X),ops.Pt.X>result.right&&(result.right=ops.Pt.X),ops.Pt.Y<result.top&&(result.top=ops.Pt.Y),ops.Pt.Y>result.bottom&&(result.bottom=ops.Pt.Y),ops=ops.Next;return result},ClipperLib.Clipper.PointInPolygon=function(pt,path){var result=0,cnt=path.length;if(cnt<3)return 0;for(var ip=path[0],i=1;i<=cnt;++i){var ipNext=i===cnt?path[0]:path[i];if(ipNext.Y===pt.Y&&(ipNext.X===pt.X||ip.Y===pt.Y&&ipNext.X>pt.X==ip.X<pt.X))return-1;if(ip.Y<pt.Y!=ipNext.Y<pt.Y)if(ip.X>=pt.X)if(ipNext.X>pt.X)result=1-result;else{if(0==(d=(ip.X-pt.X)*(ipNext.Y-pt.Y)-(ipNext.X-pt.X)*(ip.Y-pt.Y)))return-1;d>0==ipNext.Y>ip.Y&&(result=1-result)}else if(ipNext.X>pt.X){var d;if(0==(d=(ip.X-pt.X)*(ipNext.Y-pt.Y)-(ipNext.X-pt.X)*(ip.Y-pt.Y)))return-1;d>0==ipNext.Y>ip.Y&&(result=1-result)}ip=ipNext}return result},ClipperLib.Clipper.prototype.PointInPolygon=function(pt,op){var result=0,startOp=op,ptx=pt.X,pty=pt.Y,poly0x=op.Pt.X,poly0y=op.Pt.Y;do{var poly1x=(op=op.Next).Pt.X,poly1y=op.Pt.Y;if(poly1y===pty&&(poly1x===ptx||poly0y===pty&&poly1x>ptx==poly0x<ptx))return-1;if(poly0y<pty!=poly1y<pty)if(poly0x>=ptx)if(poly1x>ptx)result=1-result;else{if(0==(d=(poly0x-ptx)*(poly1y-pty)-(poly1x-ptx)*(poly0y-pty)))return-1;d>0==poly1y>poly0y&&(result=1-result)}else if(poly1x>ptx){var d;if(0==(d=(poly0x-ptx)*(poly1y-pty)-(poly1x-ptx)*(poly0y-pty)))return-1;d>0==poly1y>poly0y&&(result=1-result)}poly0x=poly1x,poly0y=poly1y}while(startOp!==op);return result},ClipperLib.Clipper.prototype.Poly2ContainsPoly1=function(outPt1,outPt2){var op=outPt1;do{var res=this.PointInPolygon(op.Pt,outPt2);if(res>=0)return res>0;op=op.Next}while(op!==outPt1);return!0},ClipperLib.Clipper.prototype.FixupFirstLefts1=function(OldOutRec,NewOutRec){for(var outRec,firstLeft,i=0,ilen=this.m_PolyOuts.length;i<ilen;i++)outRec=this.m_PolyOuts[i],firstLeft=ClipperLib.Clipper.ParseFirstLeft(outRec.FirstLeft),null!==outRec.Pts&&firstLeft===OldOutRec&&this.Poly2ContainsPoly1(outRec.Pts,NewOutRec.Pts)&&(outRec.FirstLeft=NewOutRec)},ClipperLib.Clipper.prototype.FixupFirstLefts2=function(innerOutRec,outerOutRec){for(var outRec,firstLeft,orfl=outerOutRec.FirstLeft,i=0,ilen=this.m_PolyOuts.length;i<ilen;i++)null!==(outRec=this.m_PolyOuts[i]).Pts&&outRec!==outerOutRec&&outRec!==innerOutRec&&((firstLeft=ClipperLib.Clipper.ParseFirstLeft(outRec.FirstLeft))!==orfl&&firstLeft!==innerOutRec&&firstLeft!==outerOutRec||(this.Poly2ContainsPoly1(outRec.Pts,innerOutRec.Pts)?outRec.FirstLeft=innerOutRec:this.Poly2ContainsPoly1(outRec.Pts,outerOutRec.Pts)?outRec.FirstLeft=outerOutRec:outRec.FirstLeft!==innerOutRec&&outRec.FirstLeft!==outerOutRec||(outRec.FirstLeft=orfl)))},ClipperLib.Clipper.prototype.FixupFirstLefts3=function(OldOutRec,NewOutRec){for(var outRec,firstLeft,i=0,ilen=this.m_PolyOuts.length;i<ilen;i++)outRec=this.m_PolyOuts[i],firstLeft=ClipperLib.Clipper.ParseFirstLeft(outRec.FirstLeft),null!==outRec.Pts&&firstLeft===OldOutRec&&(outRec.FirstLeft=NewOutRec)},ClipperLib.Clipper.ParseFirstLeft=function(FirstLeft){for(;null!==FirstLeft&&null===FirstLeft.Pts;)FirstLeft=FirstLeft.FirstLeft;return FirstLeft},ClipperLib.Clipper.prototype.JoinCommonEdges=function(){for(var i=0,ilen=this.m_Joins.length;i<ilen;i++){var holeStateRec,join=this.m_Joins[i],outRec1=this.GetOutRec(join.OutPt1.Idx),outRec2=this.GetOutRec(join.OutPt2.Idx);null!==outRec1.Pts&&null!==outRec2.Pts&&(outRec1.IsOpen||outRec2.IsOpen||(holeStateRec=outRec1===outRec2?outRec1:this.OutRec1RightOfOutRec2(outRec1,outRec2)?outRec2:this.OutRec1RightOfOutRec2(outRec2,outRec1)?outRec1:this.GetLowermostRec(outRec1,outRec2),this.JoinPoints(join,outRec1,outRec2)&&(outRec1===outRec2?(outRec1.Pts=join.OutPt1,outRec1.BottomPt=null,(outRec2=this.CreateOutRec()).Pts=join.OutPt2,this.UpdateOutPtIdxs(outRec2),this.Poly2ContainsPoly1(outRec2.Pts,outRec1.Pts)?(outRec2.IsHole=!outRec1.IsHole,outRec2.FirstLeft=outRec1,this.m_UsingPolyTree&&this.FixupFirstLefts2(outRec2,outRec1),(outRec2.IsHole^this.ReverseSolution)==this.Area$1(outRec2)>0&&this.ReversePolyPtLinks(outRec2.Pts)):this.Poly2ContainsPoly1(outRec1.Pts,outRec2.Pts)?(outRec2.IsHole=outRec1.IsHole,outRec1.IsHole=!outRec2.IsHole,outRec2.FirstLeft=outRec1.FirstLeft,outRec1.FirstLeft=outRec2,this.m_UsingPolyTree&&this.FixupFirstLefts2(outRec1,outRec2),(outRec1.IsHole^this.ReverseSolution)==this.Area$1(outRec1)>0&&this.ReversePolyPtLinks(outRec1.Pts)):(outRec2.IsHole=outRec1.IsHole,outRec2.FirstLeft=outRec1.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(outRec1,outRec2))):(outRec2.Pts=null,outRec2.BottomPt=null,outRec2.Idx=outRec1.Idx,outRec1.IsHole=holeStateRec.IsHole,holeStateRec===outRec2&&(outRec1.FirstLeft=outRec2.FirstLeft),outRec2.FirstLeft=outRec1,this.m_UsingPolyTree&&this.FixupFirstLefts3(outRec2,outRec1)))))}},ClipperLib.Clipper.prototype.UpdateOutPtIdxs=function(outrec){var op=outrec.Pts;do{op.Idx=outrec.Idx,op=op.Prev}while(op!==outrec.Pts)},ClipperLib.Clipper.prototype.DoSimplePolygons=function(){for(var i=0;i<this.m_PolyOuts.length;){var outrec=this.m_PolyOuts[i++],op=outrec.Pts;if(null!==op&&!outrec.IsOpen)do{for(var op2=op.Next;op2!==outrec.Pts;){if(ClipperLib.IntPoint.op_Equality(op.Pt,op2.Pt)&&op2.Next!==op&&op2.Prev!==op){var op3=op.Prev,op4=op2.Prev;op.Prev=op4,op4.Next=op,op2.Prev=op3,op3.Next=op2,outrec.Pts=op;var outrec2=this.CreateOutRec();outrec2.Pts=op2,this.UpdateOutPtIdxs(outrec2),this.Poly2ContainsPoly1(outrec2.Pts,outrec.Pts)?(outrec2.IsHole=!outrec.IsHole,outrec2.FirstLeft=outrec,this.m_UsingPolyTree&&this.FixupFirstLefts2(outrec2,outrec)):this.Poly2ContainsPoly1(outrec.Pts,outrec2.Pts)?(outrec2.IsHole=outrec.IsHole,outrec.IsHole=!outrec2.IsHole,outrec2.FirstLeft=outrec.FirstLeft,outrec.FirstLeft=outrec2,this.m_UsingPolyTree&&this.FixupFirstLefts2(outrec,outrec2)):(outrec2.IsHole=outrec.IsHole,outrec2.FirstLeft=outrec.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(outrec,outrec2)),op2=op}op2=op2.Next}op=op.Next}while(op!==outrec.Pts)}},ClipperLib.Clipper.Area=function(poly){if(!Array.isArray(poly))return 0;var cnt=poly.length;if(cnt<3)return 0;for(var a=0,i=0,j=cnt-1;i<cnt;++i)a+=(poly[j].X+poly[i].X)*(poly[j].Y-poly[i].Y),j=i;return.5*-a},ClipperLib.Clipper.prototype.Area=function(op){var opFirst=op;if(null===op)return 0;var a=0;do{a+=(op.Prev.Pt.X+op.Pt.X)*(op.Prev.Pt.Y-op.Pt.Y),op=op.Next}while(op!==opFirst);return.5*a},ClipperLib.Clipper.prototype.Area$1=function(outRec){return this.Area(outRec.Pts)},ClipperLib.Clipper.SimplifyPolygon=function(poly,fillType){var result=new Array,c=new ClipperLib.Clipper(0);return c.StrictlySimple=!0,c.AddPath(poly,ClipperLib.PolyType.ptSubject,!0),c.Execute(ClipperLib.ClipType.ctUnion,result,fillType,fillType),result},ClipperLib.Clipper.SimplifyPolygons=function(polys,fillType){void 0===fillType&&(fillType=ClipperLib.PolyFillType.pftEvenOdd);var result=new Array,c=new ClipperLib.Clipper(0);return c.StrictlySimple=!0,c.AddPaths(polys,ClipperLib.PolyType.ptSubject,!0),c.Execute(ClipperLib.ClipType.ctUnion,result,fillType,fillType),result},ClipperLib.Clipper.DistanceSqrd=function(pt1,pt2){var dx=pt1.X-pt2.X,dy=pt1.Y-pt2.Y;return dx*dx+dy*dy},ClipperLib.Clipper.DistanceFromLineSqrd=function(pt,ln1,ln2){var A=ln1.Y-ln2.Y,B=ln2.X-ln1.X,C=A*ln1.X+B*ln1.Y;return(C=A*pt.X+B*pt.Y-C)*C/(A*A+B*B)},ClipperLib.Clipper.SlopesNearCollinear=function(pt1,pt2,pt3,distSqrd){return Math.abs(pt1.X-pt2.X)>Math.abs(pt1.Y-pt2.Y)?pt1.X>pt2.X==pt1.X<pt3.X?ClipperLib.Clipper.DistanceFromLineSqrd(pt1,pt2,pt3)<distSqrd:pt2.X>pt1.X==pt2.X<pt3.X?ClipperLib.Clipper.DistanceFromLineSqrd(pt2,pt1,pt3)<distSqrd:ClipperLib.Clipper.DistanceFromLineSqrd(pt3,pt1,pt2)<distSqrd:pt1.Y>pt2.Y==pt1.Y<pt3.Y?ClipperLib.Clipper.DistanceFromLineSqrd(pt1,pt2,pt3)<distSqrd:pt2.Y>pt1.Y==pt2.Y<pt3.Y?ClipperLib.Clipper.DistanceFromLineSqrd(pt2,pt1,pt3)<distSqrd:ClipperLib.Clipper.DistanceFromLineSqrd(pt3,pt1,pt2)<distSqrd},ClipperLib.Clipper.PointsAreClose=function(pt1,pt2,distSqrd){var dx=pt1.X-pt2.X,dy=pt1.Y-pt2.Y;return dx*dx+dy*dy<=distSqrd},ClipperLib.Clipper.ExcludeOp=function(op){var result=op.Prev;return result.Next=op.Next,op.Next.Prev=result,result.Idx=0,result},ClipperLib.Clipper.CleanPolygon=function(path,distance){void 0===distance&&(distance=1.415);var cnt=path.length;if(0===cnt)return new Array;for(var outPts=new Array(cnt),i=0;i<cnt;++i)outPts[i]=new ClipperLib.OutPt;for(i=0;i<cnt;++i)outPts[i].Pt=path[i],outPts[i].Next=outPts[(i+1)%cnt],outPts[i].Next.Prev=outPts[i],outPts[i].Idx=0;for(var distSqrd=distance*distance,op=outPts[0];0===op.Idx&&op.Next!==op.Prev;)ClipperLib.Clipper.PointsAreClose(op.Pt,op.Prev.Pt,distSqrd)?(op=ClipperLib.Clipper.ExcludeOp(op),cnt--):ClipperLib.Clipper.PointsAreClose(op.Prev.Pt,op.Next.Pt,distSqrd)?(ClipperLib.Clipper.ExcludeOp(op.Next),op=ClipperLib.Clipper.ExcludeOp(op),cnt-=2):ClipperLib.Clipper.SlopesNearCollinear(op.Prev.Pt,op.Pt,op.Next.Pt,distSqrd)?(op=ClipperLib.Clipper.ExcludeOp(op),cnt--):(op.Idx=1,op=op.Next);cnt<3&&(cnt=0);var result=new Array(cnt);for(i=0;i<cnt;++i)result[i]=new ClipperLib.IntPoint1(op.Pt),op=op.Next;return outPts=null,result},ClipperLib.Clipper.CleanPolygons=function(polys,distance){for(var result=new Array(polys.length),i=0,ilen=polys.length;i<ilen;i++)result[i]=ClipperLib.Clipper.CleanPolygon(polys[i],distance);return result},ClipperLib.Clipper.Minkowski=function(pattern,path,IsSum,IsClosed){var delta=IsClosed?1:0,polyCnt=pattern.length,pathCnt=path.length,result=new Array;if(IsSum)for(var i=0;i<pathCnt;i++){for(var p=new Array(polyCnt),j=0,jlen=pattern.length,ip=pattern[j];j<jlen;ip=pattern[++j])p[j]=new ClipperLib.IntPoint2(path[i].X+ip.X,path[i].Y+ip.Y);result.push(p)}else for(i=0;i<pathCnt;i++){for(p=new Array(polyCnt),j=0,jlen=pattern.length,ip=pattern[j];j<jlen;ip=pattern[++j])p[j]=new ClipperLib.IntPoint2(path[i].X-ip.X,path[i].Y-ip.Y);result.push(p)}var quads=new Array;for(i=0;i<pathCnt-1+delta;i++)for(j=0;j<polyCnt;j++){var quad=new Array;quad.push(result[i%pathCnt][j%polyCnt]),quad.push(result[(i+1)%pathCnt][j%polyCnt]),quad.push(result[(i+1)%pathCnt][(j+1)%polyCnt]),quad.push(result[i%pathCnt][(j+1)%polyCnt]),ClipperLib.Clipper.Orientation(quad)||quad.reverse(),quads.push(quad)}return quads},ClipperLib.Clipper.MinkowskiSum=function(pattern,path_or_paths,pathIsClosed){if(path_or_paths[0]instanceof Array){paths=path_or_paths;for(var solution=new ClipperLib.Paths,i=(c=new ClipperLib.Clipper,0);i<paths.length;++i){var tmp=ClipperLib.Clipper.Minkowski(pattern,paths[i],!0,pathIsClosed);c.AddPaths(tmp,ClipperLib.PolyType.ptSubject,!0),pathIsClosed&&(path=ClipperLib.Clipper.TranslatePath(paths[i],pattern[0]),c.AddPath(path,ClipperLib.PolyType.ptClip,!0))}return c.Execute(ClipperLib.ClipType.ctUnion,solution,ClipperLib.PolyFillType.pftNonZero,ClipperLib.PolyFillType.pftNonZero),solution}var c,path=path_or_paths,paths=ClipperLib.Clipper.Minkowski(pattern,path,!0,pathIsClosed);return(c=new ClipperLib.Clipper).AddPaths(paths,ClipperLib.PolyType.ptSubject,!0),c.Execute(ClipperLib.ClipType.ctUnion,paths,ClipperLib.PolyFillType.pftNonZero,ClipperLib.PolyFillType.pftNonZero),paths},ClipperLib.Clipper.TranslatePath=function(path,delta){for(var outPath=new ClipperLib.Path,i=0;i<path.length;i++)outPath.push(new ClipperLib.IntPoint2(path[i].X+delta.X,path[i].Y+delta.Y));return outPath},ClipperLib.Clipper.MinkowskiDiff=function(poly1,poly2){var paths=ClipperLib.Clipper.Minkowski(poly1,poly2,!1,!0),c=new ClipperLib.Clipper;return c.AddPaths(paths,ClipperLib.PolyType.ptSubject,!0),c.Execute(ClipperLib.ClipType.ctUnion,paths,ClipperLib.PolyFillType.pftNonZero,ClipperLib.PolyFillType.pftNonZero),paths},ClipperLib.Clipper.PolyTreeToPaths=function(polytree){var result=new Array;return ClipperLib.Clipper.AddPolyNodeToPaths(polytree,ClipperLib.Clipper.NodeType.ntAny,result),result},ClipperLib.Clipper.AddPolyNodeToPaths=function(polynode,nt,paths){var match=!0;switch(nt){case ClipperLib.Clipper.NodeType.ntOpen:return;case ClipperLib.Clipper.NodeType.ntClosed:match=!polynode.IsOpen}polynode.m_polygon.length>0&&match&&paths.push(polynode.m_polygon);for(var $i3=0,$t3=polynode.Childs(),$l3=$t3.length,pn=$t3[$i3];$i3<$l3;pn=$t3[++$i3])ClipperLib.Clipper.AddPolyNodeToPaths(pn,nt,paths)},ClipperLib.Clipper.OpenPathsFromPolyTree=function(polytree){for(var result=new ClipperLib.Paths,i=0,ilen=polytree.ChildCount();i<ilen;i++)polytree.Childs()[i].IsOpen&&result.push(polytree.Childs()[i].m_polygon);return result},ClipperLib.Clipper.ClosedPathsFromPolyTree=function(polytree){var result=new ClipperLib.Paths;return ClipperLib.Clipper.AddPolyNodeToPaths(polytree,ClipperLib.Clipper.NodeType.ntClosed,result),result},Inherit(ClipperLib.Clipper,ClipperLib.ClipperBase),ClipperLib.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2},
488
- /**
489
- * @constructor
490
- */
491
- ClipperLib.ClipperOffset=function(miterLimit,arcTolerance){void 0===miterLimit&&(miterLimit=2),void 0===arcTolerance&&(arcTolerance=ClipperLib.ClipperOffset.def_arc_tolerance),this.m_destPolys=new ClipperLib.Paths,this.m_srcPoly=new ClipperLib.Path,this.m_destPoly=new ClipperLib.Path,this.m_normals=new Array,this.m_delta=0,this.m_sinA=0,this.m_sin=0,this.m_cos=0,this.m_miterLim=0,this.m_StepsPerRad=0,this.m_lowest=new ClipperLib.IntPoint0,this.m_polyNodes=new ClipperLib.PolyNode,this.MiterLimit=miterLimit,this.ArcTolerance=arcTolerance,this.m_lowest.X=-1},ClipperLib.ClipperOffset.two_pi=6.28318530717959,ClipperLib.ClipperOffset.def_arc_tolerance=.25,ClipperLib.ClipperOffset.prototype.Clear=function(){ClipperLib.Clear(this.m_polyNodes.Childs()),this.m_lowest.X=-1},ClipperLib.ClipperOffset.Round=ClipperLib.Clipper.Round,ClipperLib.ClipperOffset.prototype.AddPath=function(path,joinType,endType){var highI=path.length-1;if(!(highI<0)){var newNode=new ClipperLib.PolyNode;if(newNode.m_jointype=joinType,newNode.m_endtype=endType,endType===ClipperLib.EndType.etClosedLine||endType===ClipperLib.EndType.etClosedPolygon)for(;highI>0&&ClipperLib.IntPoint.op_Equality(path[0],path[highI]);)highI--;newNode.m_polygon.push(path[0]);for(var j=0,k=0,i=1;i<=highI;i++)ClipperLib.IntPoint.op_Inequality(newNode.m_polygon[j],path[i])&&(j++,newNode.m_polygon.push(path[i]),(path[i].Y>newNode.m_polygon[k].Y||path[i].Y===newNode.m_polygon[k].Y&&path[i].X<newNode.m_polygon[k].X)&&(k=j));if(!(endType===ClipperLib.EndType.etClosedPolygon&&j<2)&&(this.m_polyNodes.AddChild(newNode),endType===ClipperLib.EndType.etClosedPolygon))if(this.m_lowest.X<0)this.m_lowest=new ClipperLib.IntPoint2(this.m_polyNodes.ChildCount()-1,k);else{var ip=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(newNode.m_polygon[k].Y>ip.Y||newNode.m_polygon[k].Y===ip.Y&&newNode.m_polygon[k].X<ip.X)&&(this.m_lowest=new ClipperLib.IntPoint2(this.m_polyNodes.ChildCount()-1,k))}}},ClipperLib.ClipperOffset.prototype.AddPaths=function(paths,joinType,endType){for(var i=0,ilen=paths.length;i<ilen;i++)this.AddPath(paths[i],joinType,endType)},ClipperLib.ClipperOffset.prototype.FixOrientations=function(){if(this.m_lowest.X>=0&&!ClipperLib.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var i=0;i<this.m_polyNodes.ChildCount();i++)((node=this.m_polyNodes.Childs()[i]).m_endtype===ClipperLib.EndType.etClosedPolygon||node.m_endtype===ClipperLib.EndType.etClosedLine&&ClipperLib.Clipper.Orientation(node.m_polygon))&&node.m_polygon.reverse();else for(i=0;i<this.m_polyNodes.ChildCount();i++){var node;(node=this.m_polyNodes.Childs()[i]).m_endtype!==ClipperLib.EndType.etClosedLine||ClipperLib.Clipper.Orientation(node.m_polygon)||node.m_polygon.reverse()}},ClipperLib.ClipperOffset.GetUnitNormal=function(pt1,pt2){var dx=pt2.X-pt1.X,dy=pt2.Y-pt1.Y;if(0===dx&&0===dy)return new ClipperLib.DoublePoint2(0,0);var f=1/Math.sqrt(dx*dx+dy*dy);return dx*=f,dy*=f,new ClipperLib.DoublePoint2(dy,-dx)},ClipperLib.ClipperOffset.prototype.DoOffset=function(delta){if(this.m_destPolys=new Array,this.m_delta=delta,ClipperLib.ClipperBase.near_zero(delta))for(var i=0;i<this.m_polyNodes.ChildCount();i++)(node=this.m_polyNodes.Childs()[i]).m_endtype===ClipperLib.EndType.etClosedPolygon&&this.m_destPolys.push(node.m_polygon);else{var y;this.MiterLimit>2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5,y=this.ArcTolerance<=0?ClipperLib.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(delta)*ClipperLib.ClipperOffset.def_arc_tolerance?Math.abs(delta)*ClipperLib.ClipperOffset.def_arc_tolerance:this.ArcTolerance;var steps=3.14159265358979/Math.acos(1-y/Math.abs(delta));for(this.m_sin=Math.sin(ClipperLib.ClipperOffset.two_pi/steps),this.m_cos=Math.cos(ClipperLib.ClipperOffset.two_pi/steps),this.m_StepsPerRad=steps/ClipperLib.ClipperOffset.two_pi,delta<0&&(this.m_sin=-this.m_sin),i=0;i<this.m_polyNodes.ChildCount();i++){var node=this.m_polyNodes.Childs()[i];this.m_srcPoly=node.m_polygon;var len=this.m_srcPoly.length;if(!(0===len||delta<=0&&(len<3||node.m_endtype!==ClipperLib.EndType.etClosedPolygon)))if(this.m_destPoly=new Array,1!==len){for(this.m_normals.length=0,j=0;j<len-1;j++)this.m_normals.push(ClipperLib.ClipperOffset.GetUnitNormal(this.m_srcPoly[j],this.m_srcPoly[j+1]));if(node.m_endtype===ClipperLib.EndType.etClosedLine||node.m_endtype===ClipperLib.EndType.etClosedPolygon?this.m_normals.push(ClipperLib.ClipperOffset.GetUnitNormal(this.m_srcPoly[len-1],this.m_srcPoly[0])):this.m_normals.push(new ClipperLib.DoublePoint1(this.m_normals[len-2])),node.m_endtype===ClipperLib.EndType.etClosedPolygon){var k=len-1;for(j=0;j<len;j++)k=this.OffsetPoint(j,k,node.m_jointype);this.m_destPolys.push(this.m_destPoly)}else if(node.m_endtype===ClipperLib.EndType.etClosedLine){for(k=len-1,j=0;j<len;j++)k=this.OffsetPoint(j,k,node.m_jointype);this.m_destPolys.push(this.m_destPoly),this.m_destPoly=new Array;var n=this.m_normals[len-1];for(j=len-1;j>0;j--)this.m_normals[j]=new ClipperLib.DoublePoint2(-this.m_normals[j-1].X,-this.m_normals[j-1].Y);for(this.m_normals[0]=new ClipperLib.DoublePoint2(-n.X,-n.Y),k=0,j=len-1;j>=0;j--)k=this.OffsetPoint(j,k,node.m_jointype);this.m_destPolys.push(this.m_destPoly)}else{var pt1;for(k=0,j=1;j<len-1;++j)k=this.OffsetPoint(j,k,node.m_jointype);for(node.m_endtype===ClipperLib.EndType.etOpenButt?(j=len-1,pt1=new ClipperLib.IntPoint2(ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].X+this.m_normals[j].X*delta),ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].Y+this.m_normals[j].Y*delta)),this.m_destPoly.push(pt1),pt1=new ClipperLib.IntPoint2(ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].X-this.m_normals[j].X*delta),ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].Y-this.m_normals[j].Y*delta)),this.m_destPoly.push(pt1)):(j=len-1,k=len-2,this.m_sinA=0,this.m_normals[j]=new ClipperLib.DoublePoint2(-this.m_normals[j].X,-this.m_normals[j].Y),node.m_endtype===ClipperLib.EndType.etOpenSquare?this.DoSquare(j,k):this.DoRound(j,k)),j=len-1;j>0;j--)this.m_normals[j]=new ClipperLib.DoublePoint2(-this.m_normals[j-1].X,-this.m_normals[j-1].Y);for(this.m_normals[0]=new ClipperLib.DoublePoint2(-this.m_normals[1].X,-this.m_normals[1].Y),j=(k=len-1)-1;j>0;--j)k=this.OffsetPoint(j,k,node.m_jointype);node.m_endtype===ClipperLib.EndType.etOpenButt?(pt1=new ClipperLib.IntPoint2(ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].X-this.m_normals[0].X*delta),ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].Y-this.m_normals[0].Y*delta)),this.m_destPoly.push(pt1),pt1=new ClipperLib.IntPoint2(ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].X+this.m_normals[0].X*delta),ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].Y+this.m_normals[0].Y*delta)),this.m_destPoly.push(pt1)):(k=1,this.m_sinA=0,node.m_endtype===ClipperLib.EndType.etOpenSquare?this.DoSquare(0,1):this.DoRound(0,1)),this.m_destPolys.push(this.m_destPoly)}}else{if(node.m_jointype===ClipperLib.JoinType.jtRound)for(var X=1,Y=0,j=1;j<=steps;j++){this.m_destPoly.push(new ClipperLib.IntPoint2(ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].X+X*delta),ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].Y+Y*delta)));var X2=X;X=X*this.m_cos-this.m_sin*Y,Y=X2*this.m_sin+Y*this.m_cos}else{X=-1,Y=-1;for(var j=0;j<4;++j)this.m_destPoly.push(new ClipperLib.IntPoint2(ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].X+X*delta),ClipperLib.ClipperOffset.Round(this.m_srcPoly[0].Y+Y*delta))),X<0?X=1:Y<0?Y=1:X=-1}this.m_destPolys.push(this.m_destPoly)}}}},ClipperLib.ClipperOffset.prototype.Execute=function(){var a=arguments;if(a[0]instanceof ClipperLib.PolyTree)if(delta=a[1],(solution=a[0]).Clear(),this.FixOrientations(),this.DoOffset(delta),(clpr=new ClipperLib.Clipper(0)).AddPaths(this.m_destPolys,ClipperLib.PolyType.ptSubject,!0),delta>0)clpr.Execute(ClipperLib.ClipType.ctUnion,solution,ClipperLib.PolyFillType.pftPositive,ClipperLib.PolyFillType.pftPositive);else if(r=ClipperLib.Clipper.GetBounds(this.m_destPolys),(outer=new ClipperLib.Path).push(new ClipperLib.IntPoint2(r.left-10,r.bottom+10)),outer.push(new ClipperLib.IntPoint2(r.right+10,r.bottom+10)),outer.push(new ClipperLib.IntPoint2(r.right+10,r.top-10)),outer.push(new ClipperLib.IntPoint2(r.left-10,r.top-10)),clpr.AddPath(outer,ClipperLib.PolyType.ptSubject,!0),clpr.ReverseSolution=!0,clpr.Execute(ClipperLib.ClipType.ctUnion,solution,ClipperLib.PolyFillType.pftNegative,ClipperLib.PolyFillType.pftNegative),1===solution.ChildCount()&&solution.Childs()[0].ChildCount()>0){var outerNode=solution.Childs()[0];solution.Childs()[0]=outerNode.Childs()[0],solution.Childs()[0].m_Parent=solution;for(var i=1;i<outerNode.ChildCount();i++)solution.AddChild(outerNode.Childs()[i])}else solution.Clear();else{var clpr,solution=a[0],delta=a[1];if(ClipperLib.Clear(solution),this.FixOrientations(),this.DoOffset(delta),(clpr=new ClipperLib.Clipper(0)).AddPaths(this.m_destPolys,ClipperLib.PolyType.ptSubject,!0),delta>0)clpr.Execute(ClipperLib.ClipType.ctUnion,solution,ClipperLib.PolyFillType.pftPositive,ClipperLib.PolyFillType.pftPositive);else{var outer,r=ClipperLib.Clipper.GetBounds(this.m_destPolys);(outer=new ClipperLib.Path).push(new ClipperLib.IntPoint2(r.left-10,r.bottom+10)),outer.push(new ClipperLib.IntPoint2(r.right+10,r.bottom+10)),outer.push(new ClipperLib.IntPoint2(r.right+10,r.top-10)),outer.push(new ClipperLib.IntPoint2(r.left-10,r.top-10)),clpr.AddPath(outer,ClipperLib.PolyType.ptSubject,!0),clpr.ReverseSolution=!0,clpr.Execute(ClipperLib.ClipType.ctUnion,solution,ClipperLib.PolyFillType.pftNegative,ClipperLib.PolyFillType.pftNegative),solution.length>0&&solution.splice(0,1)}}},ClipperLib.ClipperOffset.prototype.OffsetPoint=function(j,k,jointype){if(this.m_sinA=this.m_normals[k].X*this.m_normals[j].Y-this.m_normals[j].X*this.m_normals[k].Y,Math.abs(this.m_sinA*this.m_delta)<1){if(this.m_normals[k].X*this.m_normals[j].X+this.m_normals[j].Y*this.m_normals[k].Y>0)return this.m_destPoly.push(new ClipperLib.IntPoint2(ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].X+this.m_normals[k].X*this.m_delta),ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].Y+this.m_normals[k].Y*this.m_delta))),k}else this.m_sinA>1?this.m_sinA=1:this.m_sinA<-1&&(this.m_sinA=-1);if(this.m_sinA*this.m_delta<0)this.m_destPoly.push(new ClipperLib.IntPoint2(ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].X+this.m_normals[k].X*this.m_delta),ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].Y+this.m_normals[k].Y*this.m_delta))),this.m_destPoly.push(new ClipperLib.IntPoint1(this.m_srcPoly[j])),this.m_destPoly.push(new ClipperLib.IntPoint2(ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].X+this.m_normals[j].X*this.m_delta),ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].Y+this.m_normals[j].Y*this.m_delta)));else switch(jointype){case ClipperLib.JoinType.jtMiter:var r=this.m_normals[j].X*this.m_normals[k].X+this.m_normals[j].Y*this.m_normals[k].Y+1;r>=this.m_miterLim?this.DoMiter(j,k,r):this.DoSquare(j,k);break;case ClipperLib.JoinType.jtSquare:this.DoSquare(j,k);break;case ClipperLib.JoinType.jtRound:this.DoRound(j,k)}return k=j},ClipperLib.ClipperOffset.prototype.DoSquare=function(j,k){var dx=Math.tan(Math.atan2(this.m_sinA,this.m_normals[k].X*this.m_normals[j].X+this.m_normals[k].Y*this.m_normals[j].Y)/4);this.m_destPoly.push(new ClipperLib.IntPoint2(ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].X+this.m_delta*(this.m_normals[k].X-this.m_normals[k].Y*dx)),ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].Y+this.m_delta*(this.m_normals[k].Y+this.m_normals[k].X*dx)))),this.m_destPoly.push(new ClipperLib.IntPoint2(ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].X+this.m_delta*(this.m_normals[j].X+this.m_normals[j].Y*dx)),ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].Y+this.m_delta*(this.m_normals[j].Y-this.m_normals[j].X*dx))))},ClipperLib.ClipperOffset.prototype.DoMiter=function(j,k,r){var q=this.m_delta/r;this.m_destPoly.push(new ClipperLib.IntPoint2(ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].X+(this.m_normals[k].X+this.m_normals[j].X)*q),ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].Y+(this.m_normals[k].Y+this.m_normals[j].Y)*q)))},ClipperLib.ClipperOffset.prototype.DoRound=function(j,k){for(var X2,a=Math.atan2(this.m_sinA,this.m_normals[k].X*this.m_normals[j].X+this.m_normals[k].Y*this.m_normals[j].Y),steps=Math.max(ClipperLib.Cast_Int32(ClipperLib.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(a))),1),X=this.m_normals[k].X,Y=this.m_normals[k].Y,i=0;i<steps;++i)this.m_destPoly.push(new ClipperLib.IntPoint2(ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].X+X*this.m_delta),ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].Y+Y*this.m_delta))),X2=X,X=X*this.m_cos-this.m_sin*Y,Y=X2*this.m_sin+Y*this.m_cos;this.m_destPoly.push(new ClipperLib.IntPoint2(ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].X+this.m_normals[j].X*this.m_delta),ClipperLib.ClipperOffset.Round(this.m_srcPoly[j].Y+this.m_normals[j].Y*this.m_delta)))},ClipperLib.Error=function(message){try{throw new Error(message)}catch(err){alert(err.message)}},ClipperLib.JS={},ClipperLib.JS.AreaOfPolygon=function(poly,scale){return scale||(scale=1),ClipperLib.Clipper.Area(poly)/(scale*scale)},ClipperLib.JS.AreaOfPolygons=function(poly,scale){scale||(scale=1);for(var area=0,i=0;i<poly.length;i++)area+=ClipperLib.Clipper.Area(poly[i]);return area/(scale*scale)},ClipperLib.JS.BoundsOfPath=function(path,scale){return ClipperLib.JS.BoundsOfPaths([path],scale)},ClipperLib.JS.BoundsOfPaths=function(paths,scale){scale||(scale=1);var bounds=ClipperLib.Clipper.GetBounds(paths);return bounds.left/=scale,bounds.bottom/=scale,bounds.right/=scale,bounds.top/=scale,bounds},ClipperLib.JS.Clean=function(polygon,delta){if(!(polygon instanceof Array))return[];var isPolygons=polygon[0]instanceof Array;if(polygon=ClipperLib.JS.Clone(polygon),"number"!=typeof delta||null===delta)return ClipperLib.Error("Delta is not a number in Clean()."),polygon;if(0===polygon.length||1===polygon.length&&0===polygon[0].length||delta<0)return polygon;isPolygons||(polygon=[polygon]);for(var len,poly,result,d,p,j,i,k_length=polygon.length,results=[],k=0;k<k_length;k++)if(0!==(len=(poly=polygon[k]).length))if(len<3)result=poly,results.push(result);else{for(result=poly,d=delta*delta,p=poly[0],j=1,i=1;i<len;i++)(poly[i].X-p.X)*(poly[i].X-p.X)+(poly[i].Y-p.Y)*(poly[i].Y-p.Y)<=d||(result[j]=poly[i],p=poly[i],j++);p=poly[j-1],(poly[0].X-p.X)*(poly[0].X-p.X)+(poly[0].Y-p.Y)*(poly[0].Y-p.Y)<=d&&j--,j<len&&result.splice(j,len-j),result.length&&results.push(result)}return!isPolygons&&results.length?results=results[0]:isPolygons||0!==results.length?isPolygons&&0===results.length&&(results=[[]]):results=[],results},ClipperLib.JS.Clone=function(polygon){if(!(polygon instanceof Array))return[];if(0===polygon.length)return[];if(1===polygon.length&&0===polygon[0].length)return[[]];var isPolygons=polygon[0]instanceof Array;isPolygons||(polygon=[polygon]);var plen,i,j,result,len=polygon.length,results=new Array(len);for(i=0;i<len;i++){for(plen=polygon[i].length,result=new Array(plen),j=0;j<plen;j++)result[j]={X:polygon[i][j].X,Y:polygon[i][j].Y};results[i]=result}return isPolygons||(results=results[0]),results},ClipperLib.JS.Lighten=function(polygon,tolerance){if(!(polygon instanceof Array))return[];if("number"!=typeof tolerance||null===tolerance)return ClipperLib.Error("Tolerance is not a number in Lighten()."),ClipperLib.JS.Clone(polygon);if(0===polygon.length||1===polygon.length&&0===polygon[0].length||tolerance<0)return ClipperLib.JS.Clone(polygon);var i,j,poly,k,poly2,plen,A,B,P,rem,addlast,bxax,byay,l,ax,ay,isPolygons=polygon[0]instanceof Array;isPolygons||(polygon=[polygon]);var len=polygon.length,toleranceSq=tolerance*tolerance,results=[];for(i=0;i<len;i++)if(0!==(plen=(poly=polygon[i]).length)){for(k=0;k<1e6;k++){for(poly2=[],poly[(plen=poly.length)-1].X!==poly[0].X||poly[plen-1].Y!==poly[0].Y?(addlast=1,poly.push({X:poly[0].X,Y:poly[0].Y}),plen=poly.length):addlast=0,rem=[],j=0;j<plen-2;j++)A=poly[j],P=poly[j+1],B=poly[j+2],ax=A.X,ay=A.Y,bxax=B.X-ax,byay=B.Y-ay,0===bxax&&0===byay||((l=((P.X-ax)*bxax+(P.Y-ay)*byay)/(bxax*bxax+byay*byay))>1?(ax=B.X,ay=B.Y):l>0&&(ax+=bxax*l,ay+=byay*l)),(bxax=P.X-ax)*bxax+(byay=P.Y-ay)*byay<=toleranceSq&&(rem[j+1]=1,j++);for(poly2.push({X:poly[0].X,Y:poly[0].Y}),j=1;j<plen-1;j++)rem[j]||poly2.push({X:poly[j].X,Y:poly[j].Y});if(poly2.push({X:poly[plen-1].X,Y:poly[plen-1].Y}),addlast&&poly.pop(),!rem.length)break;poly=poly2}poly2[(plen=poly2.length)-1].X===poly2[0].X&&poly2[plen-1].Y===poly2[0].Y&&poly2.pop(),poly2.length>2&&results.push(poly2)}return isPolygons||(results=results[0]),void 0===results&&(results=[]),results},ClipperLib.JS.PerimeterOfPath=function(path,closed,scale){if(void 0===path)return 0;var p1,p2,sqrt=Math.sqrt,perimeter=0,p1x=0,p1y=0,p2x=0,p2y=0,j=path.length;if(j<2)return 0;for(closed&&(path[j]=path[0],j++);--j;)p1x=(p1=path[j]).X,p1y=p1.Y,perimeter+=sqrt((p1x-(p2x=(p2=path[j-1]).X))*(p1x-p2x)+(p1y-(p2y=p2.Y))*(p1y-p2y));return closed&&path.pop(),perimeter/scale},ClipperLib.JS.PerimeterOfPaths=function(paths,closed,scale){scale||(scale=1);for(var perimeter=0,i=0;i<paths.length;i++)perimeter+=ClipperLib.JS.PerimeterOfPath(paths[i],closed,scale);return perimeter},ClipperLib.JS.ScaleDownPath=function(path,scale){var i,p;for(scale||(scale=1),i=path.length;i--;)(p=path[i]).X=p.X/scale,p.Y=p.Y/scale},ClipperLib.JS.ScaleDownPaths=function(paths,scale){var i,j,p;for(scale||(scale=1),i=paths.length;i--;)for(j=paths[i].length;j--;)(p=paths[i][j]).X=p.X/scale,p.Y=p.Y/scale},ClipperLib.JS.ScaleUpPath=function(path,scale){var i,p,round=Math.round;for(scale||(scale=1),i=path.length;i--;)(p=path[i]).X=round(p.X*scale),p.Y=round(p.Y*scale)},ClipperLib.JS.ScaleUpPaths=function(paths,scale){var i,j,p,round=Math.round;for(scale||(scale=1),i=paths.length;i--;)for(j=paths[i].length;j--;)(p=paths[i][j]).X=round(p.X*scale),p.Y=round(p.Y*scale)},
492
- /**
493
- * @constructor
494
- */
495
- ClipperLib.ExPolygons=function(){return[]},
496
- /**
497
- * @constructor
498
- */
499
- ClipperLib.ExPolygon=function(){this.outer=null,this.holes=null},ClipperLib.JS.AddOuterPolyNodeToExPolygons=function(polynode,expolygons){var ep=new ClipperLib.ExPolygon;ep.outer=polynode.Contour();var node,n,i,j,childs2,jlen,childs=polynode.Childs(),ilen=childs.length;for(ep.holes=new Array(ilen),i=0;i<ilen;i++)for(node=childs[i],ep.holes[i]=node.Contour(),j=0,jlen=(childs2=node.Childs()).length;j<jlen;j++)n=childs2[j],ClipperLib.JS.AddOuterPolyNodeToExPolygons(n,expolygons);expolygons.push(ep)},ClipperLib.JS.ExPolygonsToPaths=function(expolygons){var a,i,alen,ilen,paths=new ClipperLib.Paths;for(a=0,alen=expolygons.length;a<alen;a++)for(paths.push(expolygons[a].outer),i=0,ilen=expolygons[a].holes.length;i<ilen;i++)paths.push(expolygons[a].holes[i]);return paths},ClipperLib.JS.PolyTreeToExPolygons=function(polytree){var node,i,childs,ilen,expolygons=new ClipperLib.ExPolygons;for(i=0,ilen=(childs=polytree.Childs()).length;i<ilen;i++)node=childs[i],ClipperLib.JS.AddOuterPolyNodeToExPolygons(node,expolygons);return expolygons}}();var ClipperLib=getDefaultExportFromCjs(clipper.exports);
500
- /**
501
- * Crea un oggetto per operazioni booleane e manipolazione di forme 2D usando la libreria Clipper
502
- * @returns {Object} Oggetto con metodi per operazioni su forme
503
- * @property {Function} offset - Crea un offset della forma
504
- * @property {Function} inflate - Espande o contrae una forma
505
- * @property {Function} unisci - Unisce più forme con gestione di fori e tagli
506
- */
507
- function alignByMinDist(sag1,sag2,isopen){const n1=sag1.length,n2=sag2.length;if(n1<1||n2<1)return sag2.slice();let bestOffset=0,minSum=1/0;for(let k=0;k<n2;k++){const p0=sag1[0],q0=sag2[k%n2],dx0=p0.x-q0.x,dy0=p0.y-q0.y,p1=sag1[n1-1],q1=sag2[isopen?Math.min(k+n1-1,n2-1):(k+n1-1)%n2],dx1=p1.x-q1.x,dy1=p1.y-q1.y,sum=dx0*dx0+dy0*dy0+dx1*dx1+dy1*dy1;sum<minSum&&(minSum=sum,bestOffset=k)}return[...sag2.slice(bestOffset),...sag2.slice(0,bestOffset)]}function shapeclip(){function toclipformat(pts){let tm=pts.map((e=>({X:Math.round(1e4*e.x),Y:Math.round(1e4*e.y)})));return ensureOrientation(tm)}function fromclipformat(pts){return pts.map((e=>({x:e.X/1e4,y:e.Y/1e4})))}const ensureOrientation=poly=>ClipperLib.Clipper.Orientation(poly)?poly:poly.slice().reverse();function orientation(pt){if(!pt.length)return 0;let area=0;const n=pt.length;for(let i=0;i<n;i++){const current=pt[i],next=pt[(i+1)%n];area+=current.X*next.Y-next.X*current.Y}return area>0?1:area<0?-1:0}const _inflate=(pt,delta,cut=!1)=>{const co=new ClipperLib.ClipperOffset;co.MiterLimit=4,co.AddPath(pt,ClipperLib.JoinType.jtMiter,cut||2==pt.length?ClipperLib.EndType.etOpenButt:ClipperLib.EndType.etClosedPolygon);const solution=new ClipperLib.Paths;return co.Execute(solution,delta),solution};function _inflateopen(pts,delta){const co=new ClipperLib.ClipperOffset;co.MiterLimit=4,co.ArcTolerance=.25;const DD=1e4*delta,pshape=toclipformat(pts);co.AddPath(pshape,ClipperLib.JoinType.jtMiter,ClipperLib.EndType.etClosedPolygon);const solution=new ClipperLib.Paths;co.Execute(solution,DD);let tm=fromclipformat(solution[0]);return getshape().frompt(tm)}return{offset(shape,delta){const co=new ClipperLib.ClipperOffset;co.MiterLimit=4,co.ArcTolerance=.25;const DD=1e4*Math.abs(delta),pshape=toclipformat(shape.pt);co.AddPath(pshape,ClipperLib.JoinType.jtMiter,ClipperLib.EndType.etOpenButt);const solution=new ClipperLib.Paths;co.Execute(solution,DD);let tm=fromclipformat(solution[0]);return getshape().frompt(tm)},inflate:function inflate(shape,delta=2,mantainorder=!1,isopen=0){let pshape=toclipformat(shape.pt),tm=_inflate(pshape,1e4*delta);if(!tm||!tm.length)return getshape().frompt([]);let p2=getshape().frompt(fromclipformat(tm[0]));if(mantainorder){p2.orient!=shape.orient&&p2.reverse();let p3=alignByMinDist(shape.pt,p2.pt,isopen);if(p2.frompt(p3),isopen>0&&shape.pt.length>=3){function estendi1(sh1,sh2){let l1=sh1.segment(0).ruotata(-Math.PI/2,200,!0),l2=sh1.segment(-2).ruotata(-Math.PI/2,200),q2=sh2.segment(-2).interseca(l2),q1=sh2.segment(0).interseca(l1);q1&&(sh2.pt[0]=q1),q2&&(sh2.pt[sh2.pt.length-1]=q2)}function estendi2(sh1,sh2){let lfin=sh1.segment(-1),l2=sh2.segment(0),q1=lfin.interseca(l2);q1&&(sh2.pt[0]=q1),l2=sh2.segment(-2);let q2=lfin.interseca(l2);q2&&(sh2.pt[sh2.pt.length-1]=q2)}1==isopen?estendi1(shape,p2):estendi2(shape,p2)}}return p2},inflateopen:_inflateopen,inflateclose(shape,delta){let p2=_inflateopen(shape.pt,delta);p2.orient!=shape.orient&&p2.reverse();let p3=alignByMinDist(shape.pt,p2.pt,0);return p2.frompt(p3),p2},inflatecornici(shape,delta=2,linetruncateini,linetruncateend){let p2,n=shape.npt;if(2==n){let l2=shape.segment(0).offset(delta);p2=getshape().frompt([l2.p1,l2.p2])}else if(3==n){let l1=shape.segment(0).offset(delta),l2=shape.segment(1).offset(delta);if(l1.isparallela(l2))p2=getshape().frompt([l1.p1,l2.p2]);else{let p=l1.interseca(l2);p2=getshape().frompt([l1.p1,p,l2.p2])}}else{let l1=new Linea2(shape.pt[0],shape.pt[shape.npt-1]),len1=l1.len,l2=l1.perpendicolare(l1.p1,len1),l3=l1.perpendicolare(l1.p2,len1);l2.isparallela(shape.segment(0))&&(l2=l1.perpendicolare(l1.puntot(.1),len1)),l3.isparallela(shape.segment(shape.npt-2))&&(l3=l1.perpendicolare(l1.puntot(.9),len1));let n2=Math.floor(shape.npt/2),{t:t}=l2.proiezionet(shape.pt[n2]),t2=2*(t>0?-1:1),px2=l2.puntot(t2),px3=l3.puntot(t2);p2=_inflateopen([...shape.pt,px3,px2],delta);let idx=p2.pt.reduce(((imin,p,i)=>(p.x-px2.x)**2+(p.y-px2.y)**2<(p2.pt[imin].x-px2.x)**2+(p2.pt[imin].y-px2.y)**2?i:imin),0);p2.pt=p2.pt.slice(idx+2).concat(p2.pt.slice(0,idx)),p2.orient!=shape.orient&&p2.reverse(),linetruncateini&&(shape.truncatebefore(linetruncateini),p2.truncatebefore(linetruncateini)),linetruncateend&&(p2.truncateafter(linetruncateend),shape.truncateafter(linetruncateend))}return p2},intersecasplitter(areabase,forma1){const clipper=new ClipperLib.Clipper,pt1=[toclipformat(forma1.pt)],pt2=[toclipformat(areabase.pt)];clipper.AddPaths(pt1,ClipperLib.PolyType.ptSubject,!0),clipper.AddPaths(pt2,ClipperLib.PolyType.ptClip,!0);const solution=new ClipperLib.Paths;let res;if(clipper.Execute(ClipperLib.ClipType.ctIntersection,solution,ClipperLib.PolyFillType.pftNonZero,ClipperLib.PolyFillType.pftNonZero)&&solution.length>0){const path=solution[0];if(1===orientation(path)){res=getshape().frompt(fromclipformat(path)),res.orient!=forma1.orient&&res.reverse();for(let iu=0;iu<forma1.pt.length;iu++){let p2=forma1.pt[iu],id=res.pt.findIndex((p=>Math.abs(p.x-p2.x)<.01&&Math.abs(p.y-p2.y)<.01));if(id>0){id-=iu,0!=id&&res.selezionaprimo(id);break}}}}return res},offsetpts(pts,delta=.01){const DELTA=1e4*delta;let tm=_inflate(toclipformat(pts),DELTA);if(tm&&tm.length)return fromclipformat(tm[0])},areesplitter(shapept,clipspt,useInflatedClipping=!0){if(!Array.isArray(shapept)||shapept.length<3)return;if(!clipspt||0==clipspt.length)return[shapept];const subj=new ClipperLib.Paths,clip=new ClipperLib.Paths;let shape_in=useInflatedClipping?_inflate(toclipformat(shapept),-100):[toclipformat(shapept)],clips_in=useInflatedClipping?clipspt.flatMap((c=>_inflate(toclipformat(c),100))):clipspt.map((c=>toclipformat(c)));for(let s of shape_in)subj.push(s);for(let c of clips_in)clip.push(c);const clipper=new ClipperLib.Clipper;clipper.AddPaths(subj,ClipperLib.PolyType.ptSubject,!0),clipper.AddPaths(clip,ClipperLib.PolyType.ptClip,!0);const solution=new ClipperLib.Paths;if(!clipper.Execute(ClipperLib.ClipType.ctDifference,solution,ClipperLib.PolyFillType.pftNonZero,ClipperLib.PolyFillType.pftNonZero))return;let res=[];for(let x of solution)if(useInflatedClipping){const restored=_inflate(x,100);for(const r of restored)1===orientation(r)&&res.push(fromclipformat(r))}else if(x.length>4&&1==orientation(x)){const cleaned=_inflate(x,-100);if(cleaned.length>0)for(let cc of cleaned){const restored=_inflate(cc,100);for(const rr of restored)1===orientation(rr)&&res.push(fromclipformat(rr))}}else 1==orientation(x)&&res.push(fromclipformat(x));return res},unisci(shapes,holes,cuts){const subj=new ClipperLib.Paths,clip=new ClipperLib.Paths;for(let hh of shapes){let h2=[toclipformat(hh.pt)];for(let h of h2)subj.push(h)}if(holes&&holes.length)for(let hh of holes){let h1=toclipformat(hh.pt);clip.push(h1)}if(cuts&&cuts.length)for(let hh of cuts){let h1=toclipformat(hh.pt),h2=_inflate(h1,1,!0);for(let h of h2)clip.push(h)}const clipper=new ClipperLib.Clipper;clipper.AddPaths(subj,ClipperLib.PolyType.ptSubject,!0),clipper.AddPaths(clip,ClipperLib.PolyType.ptClip,!0);const solution=new ClipperLib.Paths;if(clipper.Execute(ClipperLib.ClipType.ctDifference,solution,ClipperLib.PolyFillType.pftNonZero,ClipperLib.PolyFillType.pftNonZero)){let res=[],holes=[];for(let x of solution)if(1==orientation(x)){let yy=[x];for(let y of yy)res.push({shape:getshape().frompt(fromclipformat(y)),holes:[]})}else holes.push(getshape().frompt(fromclipformat(x)));for(let h of holes)for(let s of res)if(s.shape.pointinshape(h.pt[0])){s.holes.push(h);break}return res}return[]}}}class Vscene{constructor(x,y,info={}){this.x=x,this.y=y,this.info=info,this.clear()}addrow(o){o||(o={}),o.id=function newid(rows){let max=0;for(let x of rows)+x.id>max&&(max=+x.id);return max+1}(this.rows);let tm=new Vobject(o);return this.rows.push(tm),tm}clear(){this.curlayer=0,this.rows=[],this.clines=[]}fromjson(o){let ll,l2;o||(o={info:{}}),this.clear(),this.x=o.x||4e3,this.y=o.y||3e3,this.info=o.info||{},this.curlayer=o.curlayer,o.clines&&(ll=o.clines.map((e=>new Linea2(e.p1,e.p2))));let x=this.x,y=this.y;l2=[new Linea2(0,0,100,0),new Linea2(x,0,x,100),new Linea2(x,y,x-100,y),new Linea2(0,y,0,y-100)],this.clines=[...l2,...ll],o.rows&&(this.rows=o.rows.map((e=>new Vobject(e))))}tojson(){let{x:x,y:y,info:info,curlayer:curlayer,xrows:xrows,xclines:xclines}=this,rows=xrows.map((e=>e.tojson())),clines=xclines.map((e=>({p1:e.p1,p2:e.p2})));return clines=clines.slice(4),{x:x,y:y,curlayer:curlayer,rows:rows,clines:clines}}}class Vobject{constructor(o){o||(o={}),this.fromjson(o)}get lines(){if(this._lines&&this._lines.length)return this._lines;{let{x:x,y:y}=this;return x||(x=100),y||(y=100),[new Linea2(0,0,0,y),new Linea2(x,0,x,y)]}}fromjson(o){let ll;this.id=o.id??1,this.layer=o.layer||0,this.hidden=!!o.hidden,this.x=o.x||100,this.y=o.y||100,this.pc=o.pc||{x:0,y:0},o.shape?this.shape=getshape().frompt(o.shape):this.shape=void 0,o.lines&&o.lines.length&&(ll=o.lines.map((e=>new Linea2(e.p1,e.p2)))),this._lines=ll,this.draw=new Vis2d(`d:${o.id}`),o.draw&&this.draw.fromjson(o.draw),this.info=o.info||{},this.pos=o.pos||{x:0,y:0,rot:0}}tojson(){let{id:id,layer:layer,x:x,y:y,pc:pc,shape:shape,hidden:hidden,_lines:lines,info:info,pos:pos}=this;return lines=lines&&lines.length?lines.map((e=>({p1:e.p1,p2:e.p2}))):void 0,shape=shape?shape.pt:void 0,{id:id,layer:layer,x:x,y:y,pc:pc,shape:shape,lines:lines,hidden:hidden,info:info,pos:pos,draw:this.draw.tojson()}}}class Vis2d{constructor(name){this.name=name,this.clear()}clear(){return this.vec=[],this.gr={},this}tojson(){let tm={};for(let x in this.gr)tm[x]=this.gr[x].tojson();return{name:this.name,rows:this.vec,groups:tm}}fromjson(n){if(!(n&&n.name&&n.rows&&n.groups))throw new Error("wrong data JSON");this.clear(),this.name=n.name,this.vec=n.rows;for(let x in n.groups)this.gr[x]=new Vis2d(x).fromjson(n.groups[x])}creategr(name="grp"){return this.gr[name]||(this.gr[name]=new Vis2d(name)),this.gr[name]}push(x=0,y=0,op={}){"number"==typeof op&&(op={rot:op}),op||(op={}),this.vec.push({type:"push",x:x,y:y,op:op})}pop(){this.vec.push({type:"pop"})}randomcolor(transp="100%"){return`hsl(${Math.floor(360*Math.random())}, 50%, 40%,${transp})`}addgr(gr){let name=gr;gr?.name&&(name=gr.name),this.gr[name]?this.vec.push({type:"group",name:name}):this.vec.push({type:"err",err:`addgroup: ${name} => missing`})}addquota(x1,y1,x2,y2,d=0,text="",scalafont=1,spessore=.25){this.vec.push({type:"quota",x1:x1,y1:y1,x2:x2,y2:y2,d:d,text:text,spessore:spessore,color:"black",scalafont:scalafont})}addqpunto(x1,y1,x2,y2,d=0,text="",scalafont=1,spessore=.25){this.vec.push({type:"qpunto",x1:x1,y1:y1,x2:x2,y2:y2,d:d,text:text,spessore:spessore,color:"black",scalafont:scalafont})}addpoint(p,id=-1,color="red",spessore=8){return p&&this.vec.push({type:"point",p:p,id:id,color:color,spessore:1*spessore}),this}addline(l,id=-1,color=void 0,spessore=1){return l&&this.vec.push({type:"line",l:l,id:id,color:color,spessore:1*spessore}),this}addrect(l,id=-1,color=void 0,spessore=1){return l&&this.vec.push({type:"rect",l:l,id:id,color:color,spessore:1*spessore}),this}addimg(l,img){return l&&this.vec.push({type:"img",l:l,img:img}),this}addrecta(l,id=-1,color=void 0){return l&&this.vec.push({type:"recta",l:l,id:id,color:color,spessore:0}),this}addshape(s,color=void 0,spessore=1){return s&&this.vec.push({type:"shape",s:s,color:color||this.randomcolor(),spessore:1*spessore}),this}addshapelin(s,color=void 0,spessore=1){return s&&this.vec.push({type:"shapelin",s:s,color:color||this.randomcolor(),spessore:1*spessore}),this}addarea(s,color=void 0){return s&&this.vec.push({type:"area",s:s,color:color||this.randomcolor()}),this}addoffset(x,y){return this.vec.push({type:"offset",x:x||0,y:y||0}),this}}function checkoggetto(oggetti,tipo,cod,isrect){if("h"==tipo&&(tipo="o"),oggetti||(oggetti=[]),"number"==typeof cod&&!["a","as"].includes(tipo))return{cod:"__",macro:"",sps:cod};let bb=oggetti.find((e=>e.tipo.includes(tipo)&&e.cod==cod&&(e.isshape||isrect||"a"!=tipo)));return bb||(bb=oggetti.find((e=>e.tipo.includes(tipo)&&(e.isshape||isrect||"a"!=tipo)))),bb||(bb={cod:"__",macro:"",sps:0}),"a"!=tipo&&"as"!=tipo||"__"==bb.cod||bb.color||(bb.color=`hsl(${function stringToHue(str){let hash=0;for(let i=0;i<str.length;i++)hash=31*hash+str.charCodeAt(i)>>>0;return Math.floor(.6180339887*hash%1*360)}(bb.cod)}, 95%, 97%`),bb}function getbordi(oggetti,bordo){let bordi,uguali=!1;if(Array.isArray(bordo)){bordo.length=4;let b0=bordo[0]||"";bordi=bordo.map((b=>checkoggetto(oggetti,"b",b||b0))),uguali=bordi.every((b=>b.sps===bordi[0].sps))}else{let tm=checkoggetto(oggetti,"b",bordo);bordi=[tm,tm,tm,tm],uguali=!0}return{bordi:bordi,uguali:uguali,senza:!(bordi[0].sps||bordi[1].sps||bordi[2].sps||bordi[3].sps),bl:bordi[0].sps,bt:bordi[1].sps,br:bordi[2].sps,bb:bordi[3].sps}}function elaborapercorso(sh1,bordo,taglio,oggetti,countid=0){let sh2,sh3,p1h,p2h,p3h,p4h,p1v,p2v,p3v,p4v,p1s,p2s,line1,line2,i1,i2,dati=[],draws=[];function eseguipezzo(l1,l2,bordo,shape){let info=l1.infoquad(l2);if(info&&info.distanza){let s0=getshape().frompt(shape||[l1.p1,l1.p2,l2.p2,l2.p1]),s1=s0.clone();(info.sx||info.sy)&&s1.move(-info.sx||0,-info.sy||0),info.angle&&s1.rotate(-info.angle||0);let tm={id:++countid,type:`b${bordo}`,info:info};shape&&(tm.shape=s1.pt),draws.push({type:`b${bordo}`,pt:s0.pt}),dati.push(tm)}}countid=countid||0;let np=sh1.pt.length,idr=np-1;oggetti||(oggetti=[]);let{bordi:bordi,uguali:uguali,senza:senza}=getbordi(oggetti,bordo);if(uguali)if(senza||!bordi[0].sps)sh2=sh1.clone();else{let b=bordi[0].sps;sh2=shapeclip().inflate(sh1,-b,!0)}else{let b,ll=[],pp=[];for(let i=0;i<np;i++){b=0==i?bordi[0].sps:i==idr-1?bordi[2].sps:i==idr?bordi[3].sps:bordi[1].sps,"number"!=typeof b&&(b=0);let l=sh1.segment(i).offset(-b);ll.push(l)}for(let i=0;i<np;i++){let p=ll[i].interseca(ll[(i-1+np)%np]);pp.push(p)}sh2=getshape().frompt(pp)}if(!senza){p1h=sh2.segment(idr).interseca(sh1.segment(0)),p2h=sh2.segment(1).interseca(sh1.segment(0)),p3h=sh1.segment(idr-1).interseca(sh2.segment(idr-2)),p4h=sh1.segment(idr-1).interseca(sh2.segment(idr)),p1v=sh1.segment(idr).interseca(sh2.segment(0)),p2v=sh1.segment(1).interseca(sh2.segment(0)),p3v=sh1.segment(idr-2).interseca(sh2.segment(idr-1)),p4v=sh1.segment(idr).interseca(sh2.segment(idr-1)),i1=1,i2=idr-2,line1=sh2.segment(0),line2=sh2.segment(idr-1);for(let i=1;i<idr-1;i++){let l=sh1.segment(i),p=l.interseca(line1);p&&l.onsegment(p)&&(i1=i,p2v=p),p=l.interseca(line2),p&&l.onsegment(p)&&(i2=i,p3v=p)}i1-=1,i2=idr-2-i2;let p1=sh1.pt[0],p2=sh2.pt[0],p3=sh2.pt[idr],p4=sh1.pt[idr];switch(taglio[0]){case"v":eseguipezzo(new Linea2(p4v,p1v),sh2.segment(idr),3),p2=p1v,p3=p4v;break;case"o":eseguipezzo(sh1.segment(idr),new Linea2(p4h,p1h),3),p1=p1h,p4=p4h;break;default:eseguipezzo(sh1.segment(idr),sh2.segment(idr),3)}switch(p1s=sh1.pt.slice(1,idr),p2s=sh2.pt.slice(1,idr),taglio[1]){case"v":eseguipezzo(new Linea2(p1,sh1.pt[1]),new Linea2(p2,p2v),0),eseguipezzo(new Linea2(sh1.pt[idr-1],p4),new Linea2(p3v,p3),2),i1&&(p1s=p1s.slice(i1)),i2&&(p1s=p1s.slice(0,-i2)),p1s[0]=p2v,p1s[p1s.length-1]=p3v;break;case"o":eseguipezzo(new Linea2(p1,p2h),new Linea2(p2,sh2.pt[1]),0),eseguipezzo(new Linea2(p3h,p4),new Linea2(sh2.pt[idr-1],p3),2),p2s[0]=p2h,p2s[p2s.length-1]=p3h;break;default:eseguipezzo(new Linea2(p1,sh1.pt[1]),new Linea2(p2,sh2.pt[1]),0),eseguipezzo(new Linea2(sh1.pt[idr-1],p4),new Linea2(sh2.pt[idr-1],p3),2)}if(sh3=getshape().frompt(p2s),p1s.length<8&&p1s.length==p2s.length)for(let i=0;i<p1s.length-1;i++)eseguipezzo(new Linea2(p1s[i],p1s[i+1]),new Linea2(p2s[i],p2s[i+1]),1);else{let sh3=getshape().frompt([...p1s,...p2s.reverse()]),l3=new Linea2(p1s[0],p1s[p1s.length-1]),l4=l3.offset(-bordo[1]);eseguipezzo(l3,l4,1,sh3.pt)}}return{countid:countid,shape2:sh2,shapetop:sh3,bordi:bordi,dati:dati,draws:draws}}function creaprofiloesterno(ff,oggetti){let sh1,{x:x,y:y,tipo:tipo,bordo:bordo,taglio:taglio,h1:h1,h2:h2,l1:l1,l2:l2,forma:forma}=ff;x=x<50?50:x,y=y<50?50:y,l1=l1||0,l2=l2||0,h1=h1||0,h2=h2||0;let pts=[0,0];switch(tipo){case"i":case"d":pts.push(l1>0&&l1<x?l1:0,h1>0&&h1<y?y-h1:y),pts.push(l2>0&&l2<x-l1?x-l2:x,h2>0&&h2<y&&h2!=h1?y-h2:y);break;case"a":if(forma){let tm=getshape().fromstr(forma);tm.alignline({x:l1,y:y-h1},{x:x-l2,y:y-h2}),pts.push(...tm.vec)}else if((h1||h2)&&h1>=0&&h1<Math.min(y,x/2)&&h2>=0&&h2<Math.min(y,x/2)){let tm=getshape().fromstr(`a30;${l1||0};${y-h1};${x/2};${y};${x-l2};${y-h2}`);pts.push(...tm.vec)}else pts.push(0,y,x,y);break;case"s":l1>0&&h1>0?pts.push(0,y-h1,l1,y):pts.push(0,y),l2&&l2<x-l1&&h2>0&&h2<y?pts.push(x-l2,y,x,y-h2):pts.push(x,y);break;default:pts.push(0,y,x,y)}pts.push(x,0),ff.countid=0,sh1=getshape().fromvec(pts);let{countid:countid,shape2:shape2,shapetop:shapetop,bordi:bordi,dati:dati,draws:draws}=elaborapercorso(sh1,bordo,taglio,oggetti,ff.countid);return ff.countid=countid,{shape:sh1,internalshape:shape2,shape2:shape2,shapetop:shapetop,bordi:bordi,dati:dati,draws:draws}}
508
- /**
509
- * Genera segmenti basati su intervalli e punti di interruzione
510
- * @param {Array<{a: number, b: number}>} t1 - Array di oggetti che rappresentano intervalli con coordinate a e b
511
- * @param {Array<number>} [t2] - Array opzionale di punti di interruzione
512
- * @param {boolean} [interna=false] - Se true, usa i bordi interni degli intervalli
513
- * @param {boolean} [allbreak=false] - Se true, considera ogni punto degli intervalli come una rottura
514
- * @returns {Array<{a: number, b: number}>} Array di segmenti generati
515
- */const tipi={x:"normale",s:"smussato",i:"inclinato",a:"arco/sagomato",d:"diagonali"},tagli={dd:"diagonale",vv:"verticale",oo:"orizzontale",vo:"verticale+orizzontale",vd:"verticale+diagonale",ov:"orizzontale+verticale",od:"orizzontale+diagonale"},tipocut={d:"dist. positiva","d-":"dist. negativa",p:"perc. positiva","p-":"perc negativa"},tipoalign={l:"sinistra",c:"centro",r:"destra"};function findareacod(areacodes,x,y){let mindist=1/0,minkey="";for(let k of areacodes){let dist=(k.x-x)**2+(k.y-y)**2;dist<mindist&&(mindist=dist,minkey=k.k)}return minkey}function generatesegments(t1,t2,interna=!1,allbreak=!1){let t3=[];if(t1?.length>=2){if(allbreak){let tm=[];for(let t of t1)tm.push({a:t.a,b:t.a}),t.a!=t.b&&tm.push({a:t.b,b:t.b});t1=tm}if(t1=t1.sort(((a,b)=>a.a-b.a)),t2?.length){let j=0;for(let i=1;i<t1.length;i++){const ε=1e-6;if(t2.find((e=>e>t1[i-1].b+ε&&e<t1[i].a-ε))){if(i-1>j){let result;result=interna?{a:t1[j].b,b:t1[i-1].a}:{a:t1[j].a,b:t1[i-1].b},t3.push(result)}j=i}}j<t1.length-1&&(interna?t3.push({a:t1[j].b,b:t1[t1.length-1].a}):t3.push({a:t1[j].a,b:t1[t1.length-1].b}))}else t3.push({a:t1[0].b,b:t1[t1.length-1].a})}return t3}function makedivisions(ff,shape2,oggetti){delete ff.arre;let draws=[],areas=[],dati=[],lines=[],{x:dx,y:dy,oriz:oriz,vert:vert,tipo:tipo,minvano:minvano,minvanox:minvanox,minvanoy:minvanoy}=ff,{bb:bb,bt:bt,bl:bl,br:br}=getbordi(oggetti,ff.bordo);minvanox=minvanox||minvano||50,minvanoy=minvanoy||minvano||50;let{dati:h1,punti:ph}=ordinabase(oggetti,"o",oriz,dy,minvanoy,bb,bt,tipo),{dati:v1,punti:pv}=ordinabase(oggetti,"v",vert,dx,minvanox,bl,br),shapecontorno=shape2.clone();function adddatilin(type,cod,l0,l1,sp,id){if("l"==type)areas.push([l0.p1,l0.p2]),lines.push([l0.p1.x,l0.p1.y,l0.p2.x,l0.p2.y]);else{let ptx=[l0.p1,l0.p2,l1.p2,l1.p1];areas.push(ptx);let s1=getshape().frompt(ptx);if(shapecontorno?.pt&&(s1.orient!=shapecontorno.orient&&s1.reverse(),s1=shapeclip().intersecasplitter(shapecontorno,s1)),s1){s1.pt.length>=4&&(l0.p1=s1.pt[0],l0.p2=s1.pt[1],l1.p1=s1.pt[s1.pt.length-1],l1.p2=s1.pt[s1.pt.length-2]),lines.push([l0.p1.x+("v"==type?sp:0),l0.p1.y+("v"!=type?sp:0),l0.p2.x+("v"==type?sp:0),l0.p2.y+("v"!=type?sp:0)]);let info=l0.infoquad(l1);if(info&&info.distanza){let s2=s1.clone(),c2=checkoggetto(oggetti,type,cod);(info.sx||info.sy)&&s2.move(-info.sx||0,-info.sy||0),info.angle&&s2.rotate(-info.angle||0);let tm={id:id,type:type,cod:cod,c2:c2,shape:s2.pt,info:info};dati.push(tm),tm?.shape&&draws.push({type:type,sx:tm.info.sx,sy:tm.info.sy,rot:tm.info.angle,pt:tm.shape})}}}}function isinseg(segs,v){return!!segs.find((e=>e.a<=v&&e.b>=v))}v1.forEach(((v,i)=>{v.segs=generatesegments(ph,v.cuts,!0),v.segs.forEach(((s,j)=>{let l0=new Linea2({x:v.x,y:s.a},{x:v.x,y:s.b}),l1=new Linea2({x:v.x+v.sp,y:s.a},{x:v.x+v.sp,y:s.b});adddatilin(v.sp?"v":"l",v.cod,l0,l1,v.sp/2,v.id)}))}));for(let h of h1){let cuts=[...h.cuts],pv1=[...pv];for(let v of v1)pv1.push({a:v.x,b:v.x+v.sp}),isinseg(v.segs,h.x+h.sp/2)&&cuts.push(v.x+v.sp/2);h.segs=generatesegments(pv1,cuts,!0,!0),h.segs=h.segs.filter((e=>Math.abs(e.a-e.b)>40));for(let s of h.segs){let l1=new Linea2({x:s.b,y:h.x+h.sp},{x:s.a,y:h.x+h.sp}),l0=new Linea2({x:s.b,y:h.x},{x:s.a,y:h.x});adddatilin(h.sp?"o":"l",h.cod,l0,l1,h.sp,h.id)}}let res=shapeclip().areesplitter(shape2.pt,areas),areacodes=function getareacodes(ff){let k1,x1,k2,x2,out=[];for(let i=0;i<=ff.vert.length;i++){if(0==i)k1="v0",x1=0;else{let t=ff.vert[i-1];k1=`${t.dir}${t.id}`,x1=t._v}for(let j=0;j<=ff.oriz.length;j++){if(0==j)k2="o0",x2=0;else{let t=ff.oriz[j-1];k2=`${t.dir}${t.id}`,x2=t._v}out.push({k:k1+k2,x:x1,y:x2})}}return out}(ff);for(let d of res){let s=getshape().frompt(d),{p1:p1,width:width,height:height,isrect:isrect}=s.dims(),k=findareacod(areacodes,p1.x,p1.y),cod=ff.aree[k]||ff.area||"",c2=checkoggetto(oggetti,"a",cod,isrect),ix=s.pt.findIndex((p=>Math.abs(p.x-p1.x)<.001&&Math.abs(p.y-p1.y)<.001));ix>0&&s.selezionaprimo(ix),s.pt.length&&(s.move(-p1.x,-p1.y),1==s.orient&&s.reverse()),dati.push({id:k,cod:cod,c2:c2,type:"a",shape:isrect?null:s.pt,info:{isrect:isrect?1:0,sx:p1.x,sy:p1.y,rot:0,width:width,height:height}}),draws.push({type:isrect?"a":"as",sx:p1.x,sy:p1.y,dx:width,dy:height,id:k,cod:cod,rot:0,pt:s.pt,color:c2.color})}return{ff:ff,h1:h1,ph:ph,v1:v1,pv:pv,draws:draws,lines:lines,dati:dati}}function ordinabase(oggetti,dir,hh,dd,minvano,b1,b2,tipo){let d1=[];if(hh){for(let h of hh){let sp=checkoggetto(oggetti,dir,h.cod).sps||0,x=0;switch(h.tipo){case"d-":x=dd-h.v;break;case"p":x=dd*h.v/100;break;case"p-":x=dd*(100-h.v)/100;break;default:x=h.v}if(sp&&"c"==h.align?x-=sp/2:sp&&"r"==h.align&&(x-=sp),x=Math.round(10*x)/10,h._x0=x,h._x1=x+sp,h._v=x+sp/2,h._valid=x>0&&x<dd,x>b1&&x<dd-b2){let cuts=[];h.cuts&&h.cuts.length&&h.cuts.forEach((c=>{cuts.push(c<0?dd+c:c)})),d1.push({id:h.id,x:x,sp:sp,cuts:cuts,cod:h.cod})}}d1.sort(((a,b)=>a.x-b.x))}let d2=[],p0=b1;"a"==tipo&&(dd*=1.3);for(let i=0;i<d1.length;i++){let d=d1[i];d.x>=p0+minvano&&d.x+d.sp<=dd-b2-minvano&&(d.min=p0+minvano,d.max=dd-b2-minvano,d2.length>0&&(d2[d2.length-1].max=d.x-minvano),d2.push(d),p0=d.x+d.sp)}let d3=[];d3.push({a:b1,b:b1});for(let d of d2)d3.push({a:d.x,b:d.x+d.sp});return d3.push({a:dd-b2,b:dd-b2}),{dati:d2,punti:d3}}function check(ff){let{x:x,y:y,area:area,bordo:bordo,gvert:gvert,goriz:goriz,priority:priority,minvano:minvano,taglio:taglio,tipo:tipo,h1:h1,h2:h2,l1:l1,l2:l2,d1:d1,x1:x1,y1:y1,d2:d2,x2:x2,y2:y2,vert:vert,oriz:oriz,aree:aree,forma:forma,countid:countid}=ff;return x=x||1e3,x<200&&(x=200),y=y||1e3,y<200&&(y=200),h1=h1||y1||0,h2=h2||y2||0,l1=l1||d1||x1||0,l2=l2||d2||x2||0,h1<0&&h1>y-100&&(h1=0),h2<0&&h2>y-100&&(h2=0),(l2<0||l2>x-l1)&&(l2=0),(l1<0||l1>x-l2)&&(l1=0),minvano=minvano||50,forma&&(tipo="a"),area=area||"__",bordo=bordo||"__",priority=priority||"v",taglio=tagli[taglio]?taglio:"dd",tipo=tipi[tipo]?tipo:"x",vert=vert||[],oriz=oriz||[],aree=aree||{},goriz=goriz||void 0,gvert=gvert||void 0,countid=countid||1,{x:x,y:y,area:area,bordo:bordo,gvert:gvert,goriz:goriz,priority:priority,minvano:minvano,taglio:taglio,tipo:tipo,h1:h1,h2:h2,l1:l1,l2:l2,vert:vert,oriz:oriz,aree:aree,countid:countid}}function addtaglio(ff,dir,tipodim,dim,cod,align="c",cuts=[],id){return id||(console.log("manca id a addtaglio"),id=0),{dir:dir,id:id,tipo:tipocut[tipodim]?tipodim:"d",align:tipoalign[align]?align:"c",v:dim,cod:cod,cuts:cuts||[]}}function addoriz(ff,tipodim,dim,cod,align,cuts){let x=Array.isArray(ff.bordo)?ff.bordo[0]:ff.bordo;cod||(cod=ff.goriz||x||"__"),Array.isArray(align)&&(cuts=align,align="c"),ff.oriz||(ff.oriz=[]);let tm=addtaglio(0,"o",tipodim,dim,cod,align,cuts,(ff.oriz.length?Math.max(...ff.oriz.map((e=>e.id))):0)+1);return ff.oriz.push(tm),ff}var SP=Object.freeze({__proto__:null,addhoriz:function addhoriz(ff,tipodim,dim,cod,align,cuts){return addoriz(ff,tipodim,dim,cod,align,cuts)},addoriz:addoriz,addvert:function addvert(ff,tipodim,dim,cod,align,cuts){let x=Array.isArray(ff.bordo)?ff.bordo[0]:ff.bordo;cod||(cod=ff.gvert||x||"__"),Array.isArray(align)&&(cuts=align,align="c"),ff.vert||(ff.vert=[]);let tm=addtaglio(0,"v",tipodim,dim,cod,align,cuts,(ff.vert.length?Math.max(...ff.vert.map((e=>e.id))):0)+1);return ff.vert.push(tm),ff},calcoladivisioni:
516
- /**
517
- * Ordina e calcola le posizioni di taglio lungo una dimensione, gestendo bordi e spazi minimi
518
- * @param {Array<Object>} hh - Array di oggetti che definiscono i tagli
519
- * @param {number} dd - Dimensione totale disponibile
520
- * @param {number} bordo - Dimensione del bordo da mantenere
521
- * @param {number} minvano - Spazio minimo da mantenere tra i tagli
522
- * @returns {Object} Oggetto contenente:
523
- * - dati: Array di oggetti con le posizioni elaborate dei tagli
524
- * - punti: Array di oggetti {a,b} che definiscono inizio e fine di ogni segmento
525
- */
526
- function calcoladivisioni(ff,notused,shape2,oggetti){return makedivisions(ff,shape2,oggetti)},check:check,checkoggetto:checkoggetto,creaprofiloesterno:creaprofiloesterno,create:function create(x,y,bordo,options){options||(options={});let{minvano:minvano,priority:priority,taglio:taglio,tipo:tipo,h1:h1,h2:h2,d1:d1,d2:d2,l1:l1,l2:l2,x1:x1,x2:x2,y1:y1,y2:y2,gvert:gvert,goriz:goriz,forma:forma,area:area}=options,ff=check({x:x,y:y,area:area,bordo:bordo,gvert:gvert,goriz:goriz,priority:priority,minvano:minvano,taglio:taglio,tipo:tipo,h1:h1,h2:h2,l1:l1,l2:l2,d1:d1,x1:x1,y1:y1,d2:d2,x2:x2,y2:y2});return ff.forma=forma,ff},elaborapercorso:elaborapercorso,getbordi:getbordi,makedivisions:makedivisions,makeshape:function makeshape(ff,oggetti){return creaprofiloesterno(ff,oggetti)},priorita:{v:"verticale",h:"orizzontale"},tagli:tagli,tipi:tipi,tipilocks:[{cod:"diml",des:"Larghezza"},{cod:"dima",des:"Altezza"},{cod:"etipo",des:"Modifica Tipo"},{cod:"etaglio",des:"Modifica Taglio"},{cod:"ebordi",des:"Modifica Bordi"},{cod:"esag",des:"Shape"},{cod:"vcrea",des:"Crea Div. Verticale"},{cod:"ocrea",des:"Crea Div. Orizzontale"},{cod:"vmov",des:"Sposta Div. Verticale"},{cod:"omov",des:"Sposta Div. Orizzontale"},{cod:"vedit",des:"Modifica Div. Verticale"},{cod:"oedit",des:"Modifica Div. Orizzontale"},{cod:"emods",des:"Modificatori Orizzontali/Verticali"},{cod:"ecuts",des:"Modifica/Aggiungi Cuts"},{cod:"earee",des:"Modifica Aree"}],tipoalign:tipoalign,tipocut:tipocut});function joinlinestoshapes(lk){let out=[];for(let ll of lk)for(let l1 of ll.lines){let l=new Linea2(l1.p1,l1.p2);l.rotate(-ll.ang),l.move(ll.pos.x,ll.pos.z),l.valid=!0,out.push(l)}function samepoint(p1,p2){return Math.abs(p1.x-p2.x)+Math.abs(p1.y-p2.y)<.1}for(let i=0;i<out.length;i++){if(!out[i].valid)continue;if(out[i].len<.1){out[i].valid=!1;continue}const a=out[i];for(let j=i+1;j<out.length;j++){const b=out[j];if(!b.valid)continue;if(!a.isparallela(b))continue;if(!a.isCollineare(b))continue;a.a1b=b.onsegment(a.p1,.1),a.a2b=b.onsegment(a.p2,.1),a.b1a=a.onsegment(b.p1,.1),a.b2a=a.onsegment(b.p2,.1);const{x:ax,y:ay}=a.direzione,{x:bx,y:by}=b.direzione;if(ax*bx+ay*by>0)if(a.b1a&&a.b2a)b.valid=!1;else{if(a.a1b&&a.a2b){a.valid=!1;break}if(a.a1b&&a.b2a){let l=new Linea2(b.p1,a.p2);l.valid=!0,out.push(l),a.valid=!1,b.valid=!1;break}if(a.a2b&&a.b1a){let l=new Linea2(a.p1,b.p2);l.valid=!0,out.push(l),a.valid=!1,b.valid=!1;break}}else{const ta1=a.proiezionet(a.p1).t,ta2=a.proiezionet(a.p2).t,tb1=a.proiezionet(b.p1).t,tb2=a.proiezionet(b.p2).t,minA=Math.min(ta1,ta2),maxA=Math.max(ta1,ta2),minB=Math.min(tb1,tb2),maxB=Math.max(tb1,tb2),ovMin=Math.max(minA,minB),ovMax=Math.min(maxA,maxB);if(ovMax>ovMin+.1){if(minA<ovMin){let l=new Linea2(a.puntot(minA),a.puntot(ovMin));l.valid=!0,out.push(l)}if(maxA>ovMax){let l=new Linea2(a.puntot(maxA),a.puntot(ovMax));l.valid=!0,out.push(l)}if(minB<ovMin){let l=new Linea2(a.puntot(minB),a.puntot(ovMin));l.valid=!0,out.push(l)}if(maxB>ovMax){let l=new Linea2(a.puntot(maxB),a.puntot(ovMax));l.valid=!0,out.push(l)}a.valid=!1,b.valid=!1;break}}}}out=out.filter((e=>e.valid)).map((e=>getshape().frompt([e.p1,e.p2])));for(let i1=0;i1<out.length;i1++){let s1=out[i1],changed=!0;for(;changed;){changed=!1;for(let i2=i1+1;i2<out.length;){let s2=out[i2];samepoint(s1.pt[0],s2.pt[0])?(s2.pt.reverse(),s1.pt.unshift(...s2.pt.slice(0,-1)),out.splice(i2,1),changed=!0):samepoint(s1.pt[s1.pt.length-1],s2.pt[s2.pt.length-1])?(s2.pt.reverse(),s1.pt.push(...s2.pt.slice(1)),out.splice(i2,1),changed=!0):samepoint(s1.pt[0],s2.pt[s2.pt.length-1])?(s1.pt.unshift(...s2.pt.slice(0,-1)),out.splice(i2,1),changed=!0):samepoint(s1.pt[s1.pt.length-1],s2.pt[0])?(s1.pt.push(...s2.pt.slice(1)),out.splice(i2,1),changed=!0):i2++}}}return out}async function valutagrafica(amb,startmacro,rulespec,progetto,fnreload){let{getcolonne:getcolonne,muCalc:muCalc,muEval:muEval,tipifree:tipifree}=amb.muvalutatore;rulespec||(rulespec={});for(let x of["l","a","p"]){!amb.vari.var(x)&&startmacro.dims&&amb.vari.add(x,String(startmacro.dims[x].val||100))}let fnlist=new Set;const PARSGLOBAL=["sl","sa","sp","ul","ua","up","ax","ay","az","scx","scy","scz","scale"];let isdimreload,isfnreload=!1,oo=await muEval(amb,startmacro,startmacro.codice,{leveleval:0,checkheader:op=>{let{variante:variante}=op;if(Array.isArray(startmacro.head)){let ff=startmacro.head.find((e=>e.cod==variante));isfnreload=!!ff}},grafica:async _op=>{let p2,cadv,iscad,des,fatti,{id:id,pars:pars,parametri:parametri,macro:macro,options:options,vari:vari}=_op,isheader=!!(macro&&macro.head&&macro.head.length),sv={l:amb.vari.var("l"),a:amb.vari.var("a"),p:amb.vari.var("p")};const varcad=["l","a","p","#d",...PARSGLOBAL];for(let x of varcad){let tm=amb.vari.dictionary[x];tm&&(sv[x]=tm)}async function _parsepars(x,head){let k,v,r9=/^#(d|des|descrizione)\s*=\s*(.*)\s*$/im.exec(x);if(r9)k="#d",v=await amb.vari.valuta(r9[2]);else{let result=await vari.parametrokeyval(x);k=result.k,v=result.v}k&&!fatti[k]&&(fatti[k]=!0,varcad.includes(k)?"#d"==k?des=v:("string"==typeof v&&(v=muCalc(v)),["l","a","p"].includes(k)&&amb.vari.add(k,String(v)),cadv[k]=v,iscad=!0):"string"==typeof v?p2.push(`${k}=${v}`):amb.vari.add(k,v))}let px;if(p2=[],cadv={},iscad=!1,des="",fatti={},progetto&&progetto.keys&&progetto.keys[id]&&(px=progetto.keys[id].pars,px))for(let t in px){let t1=amb.vari.dictionary[t];t1&&(sv[t]=t1),await _parsepars(`${t}=${px[t]}`)}if(pars&&pars.length)for(const par of pars)await _parsepars(par);if(parametri&&parametri.length)for(const param of parametri)await _parsepars(param);if(macro&&macro.head&&macro.head.length){let tm=macro.head.filter((e=>!["g","p"].includes(e.t)));for(const h of tm)await _parsepars(h.cod)}let out={iscad:iscad,isheader:isheader,name:macro.name,des:des,leveleval:options.leveleval};isheader&&id&&(out.id=id),iscad&&(cadv.l?amb.vari.add("l",String(cadv.l)):cadv.l=muCalc(amb.vari.var("l")),cadv.a?amb.vari.add("a",String(cadv.a)):cadv.a=muCalc(amb.vari.var("a")),cadv.p?amb.vari.add("p",String(cadv.p)):cadv.p=muCalc(amb.vari.var("p")),out.cadv=cadv),await macro.impostaparametri(parametri,p2,!0,px);let ruleid=rulespec[id];id&&isheader&&ruleid&&ruleid.pars&&(out.pars=ruleid.pars,options.leveleval++,await macro.setparametri(ruleid.pars));let tm=amb.vari.var("_rootnode");if(amb.vari.add("_rootnode","0"),out.rows=await muEval(amb,macro,macro.codice,options),amb.vari.add("_rootnode",tm),id&&isheader&&(out.spars=macro.getparametri()),iscad)for(let x in sv)amb.vari.dictionary[x]=sv[x];return out},parsefnpunto:async _op=>{let{dati:dati,vari:vari,id:id,output:output}=_op;dati=dati.trim();let q=dati.indexOf(" "),q2=dati.indexOf(",");q2>0&&q>0&&q2<q&&(q=q2);let fn,pp,pars={},p2={};q>1?(fn=dati.slice(1,q),pp=getcolonne(dati.slice(q+1))):(fn=dati.slice(1),pp=[]),fnlist.has(fn)||fnlist.add(fn);for(let p of pp){let{k:k,v:v}=await vari.parametrokeyval(p);k&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(k)&&(pars[k]=v||"")}for(let l of["l","a","p"])pars[l]||(pars[l]=vari.var(l));let tm=Object.keys(pars);for(let l of PARSGLOBAL)tm.includes(l)&&(p2[l]=muCalc(pars[l]),p2[l]&&(pars[l]=p2[l]));output.push({t:"fn",fn:fn,id:id,pars:pars,p2:p2})}});for(let x of["l","a","p"])if(startmacro.dims&&startmacro.dims[x].val!=parseFloat(amb.vari.var(x))){isdimreload=!0;break}return(isfnreload||isdimreload&&"function"==typeof fnreload)&&await fnreload(isdimreload,isfnreload),{oo:oo,vari:amb.vari.dump(!0),fnlist:[...fnlist]}}function ismacro(row){return"object"==typeof row&&row?.name&&row.rows}function isfn(row){return"object"==typeof row&&"fn"==row?.t}function getnodebyid(id,nodocorrente){let res;return nodocorrente&&nodocorrente.rows&&function _getnode(rows){for(let x of rows){if(ismacro(x)){if(x.id==id)return void(res=x);x.rows&&_getnode(x.rows)}if(res)return}}(nodocorrente.rows),res}function getsubrules(nodocorrente){let res=[];return res.push({id:"",level:0,name:"home"}),function _xfiltrati(rr,level){if(rr.rows&&rr.rows.length)for(let x of rr.rows)ismacro(x)&&(x.id&&x.isheader?(res.push({id:x.id,name:x.name,des:x.des||"",spec:x.pars?1:0,level:level}),_xfiltrati(x,level+1)):_xfiltrati(x,level))}(nodocorrente,1),res}function getdumpmacro(nodo){let cl=[];return function _dumpnodo(node){if(node.rows&&node.rows.length)for(let x of node.rows)if(ismacro(x)){x.name;let c=[];if(x.iscad&&x.cadv)for(let k in x.cadv){let t=x.cadv[k];"number"==typeof t&&t&&c.push(`${k}=${t}`)}if(x.pars)for(let k in x.pars){let t=x.pars[k];c.push(`${k}=${t}`)}c.length&&cl.push(`--\x3e ${x.name} ${c.join(",")}`),_dumpnodo(x),c.length&&cl.push("<--")}else isfn(x)?cl.push(`FN: ${x.fn} ${JSON.stringify(x.pars)}`):"string"==typeof x&&x.length&&cl.push(x)}(nodo),cl.join("\n")}const mgreen$1=new THREE.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:THREE.DoubleSide});function getorientate(ori,x,y,z){switch(x=x||0,y=y||0,z=z||0,ori.trim().toLowerCase()){case"alp":return{x:y,y:x,z:z};case"apl":return{x:y,y:z,z:x};case"pla":return{x:z,y:x,z:y};case"pal":return{x:z,y:y,z:x};case"lpa":return{x:x,y:z,z:y};default:return{x:x,y:y,z:z}}}function parselavs(ori,id,x=0,y=0,z=0,lavorazioni="",facce="",def=""){let lavcods=function muClComments(codice,tienivuoti){const righe=(code=codice,code.replace(/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')|\/\*[\s\S]*?\*\//g,((match,quoted)=>quoted||""))).split(/\r?\n/);var code;const tm=[];let rigaContinua="";for(const riga of righe){let rigaTrim=riga.trim();if(rigaTrim.includes("//")&&(rigaTrim=rigaTrim.split("//")[0].trim()),0!==rigaTrim.length)if(rigaContinua.length>0&&(rigaTrim=rigaContinua+" "+rigaTrim,rigaContinua=""),rigaTrim.endsWith("\\")){rigaTrim=rigaTrim.slice(0,-1);const indiceCommento=rigaTrim.lastIndexOf("//");-1!==indiceCommento&&(rigaTrim=rigaTrim.slice(0,indiceCommento).trim()),rigaContinua=rigaTrim}else tm.push(rigaTrim)}return tm}(lavorazioni),rets=[];for(let lavcod of lavcods){let rr=/^([({}):$\w.\\/]+)[\s;,]*(.*)?$/im.exec(lavcod);if(rr&&rr[1]){let lav={name:rr[1].trim().toLowerCase(),...getorientate(ori,x,y,z),id:id,facce:facce};if(rr[2]){let aa=getcolonne(rr[2]);for(let a of aa){let i=a.indexOf("=");i>0&&(lav[a.slice(0,i).trim()]=a.slice(i+1).trim())}}rets.push(lav)}}return!rets.length&&def&&rets.push({name:def,...getorientate(ori,x,y,z),id:id,facce:facce}),rets}function getemitter(data){let{d:d,name:name,x:x,y:y,z:z,lavs:lavs="",ids:ids="",faces:faces=null,size:size=5}=data;ids=getcolonne(clean(ids,!0));const emitter=new THREE.Object3D;if(emitter.position.set(x,y,z),emitter.userData={emitter:!0,lavs:lavs,ids:ids,faces:faces,size:size,name:name},d){const geometry=new THREE.SphereGeometry(size||5,8,8),material=new THREE.MeshBasicMaterial({color:16711680}),mesh=new THREE.Mesh(geometry,material);emitter.add(mesh)}return emitter}function getreceiver(gcad,data){gcad.gmats.__istask=1;let{d:d,ori:ori="LAP",x:x=0,y:y=0,z:z=0,tipo:tipo="",start:start="",end:end=""}=data;tipo=clean(tipo,!0);const receiver=new THREE.Object3D;if(receiver.position.set(x/2,y/2,z/2),receiver.userData={receiver:!0,ori:(ori||"").trim().toLowerCase(),x:x,y:y,z:z,tipo:tipo,start:start,end:end},d){const geometry=new THREE.BoxGeometry(x,y,z),mesh=new THREE.Mesh(geometry,mgreen$1);mesh.position.set(0,0,0),receiver.add(mesh)}return receiver}function calcolatasks(scena){const emitterWorldPosition=new WeakMap,receiverWorldMatrixInverse=new WeakMap;function boxBoxIntersects(pos,l,x,y,z){return pos.x+l>0&&pos.x-l<x&&pos.y+l>0&&pos.y-l<y&&pos.z+l>0&&pos.z-l<z}function getFacceToccate(pos,sogliafaccia,x,y,z,filtra){const facce=[];function addfaccia(f){filtra&&!filtra.includes(f)||facce.push(f)}return Math.abs(pos.x-0)<sogliafaccia&&addfaccia("s"),Math.abs(pos.x-x)<sogliafaccia&&addfaccia("d"),Math.abs(pos.y-0)<sogliafaccia&&addfaccia("b"),Math.abs(pos.y-y)<sogliafaccia&&addfaccia("a"),Math.abs(pos.z-0)<sogliafaccia&&addfaccia("z"),Math.abs(pos.z-z)<sogliafaccia&&addfaccia("f"),facce.join("")}function getEmitterWorldPosition(emitter){if(!emitterWorldPosition.has(emitter)){const pos=new THREE.Vector3;emitter.getWorldPosition(pos),emitterWorldPosition.set(emitter,pos)}return emitterWorldPosition.get(emitter)}function getReceiverWorldMatrixInverse(receiver){if(!receiverWorldMatrixInverse.has(receiver)){const inv=receiver.matrixWorld.clone().invert();receiverWorldMatrixInverse.set(receiver,inv)}return receiverWorldMatrixInverse.get(receiver)}scena.updateMatrixWorld(!0);const receivers=[],emitters=[];!function scan(obj){obj.userData?.receiver&&receivers.push(obj),obj.userData?.emitter&&emitters.push(obj),obj.children&&obj.children.forEach(scan)}(scena);let tasks=[];for(const receiver of receivers){const{mat:mat,ori:ori,x:x,y:y,z:z,start:start,end:end,tipo:tipo,size:size}=receiver.userData;let singletask={id:mat,...getorientate(ori,x,y,z),tipo:tipo,ori:ori,lavs:[]};start&&singletask.lavs.push(...parselavs(ori,"_start",0,0,0,start,"",""));const matrixInverse=getReceiverWorldMatrixInverse(receiver);for(const emitter of emitters){if("string"==typeof tipo&&""!==tipo){const idx=emitter.userData.ids;if(Array.isArray(idx)&&idx.length>0&&!idx.includes("*")&&!idx.includes(tipo))continue}const posLocalAdj=getEmitterWorldPosition(emitter).clone().applyMatrix4(matrixInverse).clone().add(new THREE.Vector3(x/2,y/2,z/2));if(!boxBoxIntersects(posLocalAdj,emitter.userData.size??0,x,y,z))continue;const facceToccate=getFacceToccate(posLocalAdj,emitter.userData.soglia??2,x,y,z,emitter.userData.faces);facceToccate&&facceToccate.length&&singletask.lavs.push(...parselavs(ori,emitter.userData.name,posLocalAdj.x,posLocalAdj.y,posLocalAdj.z,emitter.userData.lavs,facceToccate,"nd"))}end&&singletask.lavs.push(...parselavs(ori,"_end",0,0,0,end,"","")),singletask.lavs.length&&tasks.push(singletask)}return tasks}function getbb(obj,force=!1){if(!force&&obj.userData.bb)return obj.userData._boundingbox;const box=(new THREE.Box3).setFromObject(obj);return obj.userData._boundingbox=box,box}function setorigine(obj,x=0,y=0,z=0){const min=getbb(obj).min,wrapper=new THREE.Group;return wrapper.add(obj),obj.position.sub(new THREE.Vector3(min.x+x,min.y+y,min.z+z)),wrapper}function scalaoggetto(gcad,originale,scale={}){const box=getbb(originale),size=new THREE.Vector3;box.getSize(size);const min=box.min,axes=["x","y","z","u","v"],norm={};for(let ax of axes){let sc=scale[ax];if(void 0===sc)norm[ax]={s:1};else if("number"==typeof sc)norm[ax]={s:sc};else if("object"==typeof sc){let s=sc.s??1,dim="x"===ax?size.x:"y"===ax?size.y:size.z,minv="x"===ax?min.x:"y"===ax?min.y:min.z;void 0!==sc.distperc&&(sc.dist=dim*sc.distperc),void 0!==sc.dist&&(s=(dim+sc.dist)/dim);let p1=sc.p1?sc.p1+minv:void 0,p2=sc.p2?sc.p2+minv:void 0;void 0!==sc.p1perc&&(p1=minv+dim*sc.p1perc),void 0!==sc.p2perc&&(p2=minv+dim*sc.p2perc),norm[ax]={s:s,p1:p1,p2:p2}}}if(axes.every((ax=>void 0===norm[ax].p1||void 0===norm[ax].p2))){if(1===norm.x.s&&1===norm.y.s&&1===norm.z.s)return originale;const wrapper=new THREE.Group;return wrapper.scale.set(norm.x.s,norm.y.s,norm.z.s),wrapper.add(originale),wrapper}const key=hash(`${originale.uuid}|${JSON.stringify(norm)}`);if(gcad.meshes[key])return gcad.meshes[key];const needAxis={};axes.forEach((ax=>{const{s:s,p1:p1,p2:p2}=norm[ax];needAxis[ax]=!(1===s&&void 0===p1&&void 0===p2)}));const clone=originale.clone(!0);return delete clone?.userData._boundingbox,clone.traverse((n=>{if(n.isMesh){const sOld=n.scale.clone();n.geometry=n.geometry.clone();const posAttr=n.geometry.attributes.position,uvAttr=n.geometry.attributes.uv,trasf=(val,ax)=>{if(!needAxis[ax])return val;const{s:s,p1:p1,p2:p2}=norm[ax];if(void 0===p1||void 0===p2)return val*s;const delta=p2*s-p2;if(val<p1)return val;if(val>=p2)return val+delta;return p1+(val-p1)*((p2-p1+delta)/(p2-p1))};if(posAttr&&(needAxis.x||needAxis.y||needAxis.z)){const arr=posAttr.array;for(let i=0;i<arr.length;i+=3)needAxis.x&&(arr[i]=trasf(arr[i],"x")),needAxis.y&&(arr[i+1]=trasf(arr[i+1],"y")),needAxis.z&&(arr[i+2]=trasf(arr[i+2],"z"));posAttr.needsUpdate=!0,n.geometry.computeVertexNormals()}if(uvAttr&&(needAxis.u||needAxis.v)){const arr=uvAttr.array;for(let i=0;i<arr.length;i+=2)needAxis.u&&(arr[i]=trasf(arr[i],"u")),needAxis.v&&(arr[i+1]=trasf(arr[i+1],"v"));uvAttr.needsUpdate=!0}n.scale.set(sOld.x*norm.x.s,sOld.y*norm.y.s,sOld.z*norm.z.s)}})),gcad.meshes[key]=clone,clone}function posiziona(grp,pos={}){let tm=new THREE.Group;if(grp){let g2=grp.clone(),tm2=g2,{marker:marker="",sl:sl=0,sa:sa=0,sp:sp=0,ax:ax=0,ay:ay=0,az:az=0,ul:ul=0,ua:ua=0,up:up=0,scale:scale=1,scx:scx=scale,scy:scy=scale,scz:scz=scale,emitters:emitters,emittersname:emittersname,order:order,ignoreTraverse:ignoreTraverse}=pos;if("number"==typeof order&&g2.traverse((child=>{child.isMesh&&(child.renderOrder=order)})),tm.position.set(sl,sa,sp),tm.rotation.set(ax*PIF,ay*PIF,az*PIF),(ul||ua||up)&&(tm2=new THREE.Group,tm2.add(g2),tm2.position.set(ul,ua,up)),tm.scale.set(scx,scy,scz),tm.add(tm2),marker&&(tm.layers.set(11),tm.userData.marker=marker),ignoreTraverse&&(tm.userData.ignoreTraverse=!0),emitters&&emitters.length)for(let e of emitters)e.name=e.name||emittersname,tm.add(getemitter(e))}return tm}const SIDE=THREE.DoubleSide;let materialline1=new THREE.LineBasicMaterial({color:16711680,transparent:!1,opacity:1}),materialline2=new THREE.LineBasicMaterial({color:11579568,transparent:!1,opacity:1});const mwhite=new THREE.MeshStandardMaterial({color:16777215,roughness:.5,metalness:.4,side:SIDE}),mgray1=new THREE.MeshStandardMaterial({color:8421504,roughness:.5,metalness:.4,side:SIDE}),mgray2=new THREE.MeshStandardMaterial({color:11579568,roughness:.5,metalness:.4,side:SIDE}),mred=new THREE.MeshStandardMaterial({color:16711680,roughness:.5,metalness:.4,side:SIDE}),mblue=new THREE.MeshStandardMaterial({color:1982639,roughness:.5,metalness:.4,side:SIDE}),mgreen=new THREE.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:SIDE}),mblack=new THREE.MeshStandardMaterial({color:0,roughness:.5,metalness:.4,side:SIDE}),scaleunit=.001;function groupfromgeometry(geometry,material,x,y,z,name,layer){let child=new THREE.Group;child.position.set(x,y,z),child.name=name;const mesh=new THREE.Mesh(geometry,material);mesh.name=name,mesh.castShadow=!0,mesh.receiveShadow=!0,mesh.layers.set(layer);const edges=new THREE.EdgesGeometry(geometry),lineSegments=new THREE.LineSegments(edges,materialline1);return lineSegments.layers.set(30),child.add(mesh),child.add(lineSegments),child}function edgesfromgeometry(g1,layer=30){return getlinesgeom(new THREE.EdgesGeometry(g1,40),layer)}function getlinesgeom(edges,layer=30){const lineSegments=new THREE.LineSegments(edges,materialline1);return lineSegments.layers.set(layer),lineSegments}function getmesh(geom,material,layer=1,clone=!1){let m=new THREE.Mesh(geom,clone?material.clone():material);return m.castShadow=!0,m.receiveShadow=!0,m.layers.set(layer),m}function get3dshape(punti,material,layer){if(!punti||punti.length<3)return new THREE.BufferGeometry;const vertices=[];for(let i=0;i<punti.length;i++){const p1=punti[i],p2=punti[(i+1)%punti.length];vertices.push(p1.x,0,p1.y),vertices.push(p2.x,0,p2.y)}const geometry=new THREE.BufferGeometry;geometry.setAttribute("position",new THREE.Float32BufferAttribute(vertices,3));let m=new THREE.LineSegments(geometry,material);return m.layers.set(layer),m}function creategroup(name,op={}){let{ignoreTraverse:ignoreTraverse}=op,g=new THREE.Group;return g.name=name||"$$",ignoreTraverse&&(g.userData.ignoreTraverse=!0),g}function svuotanodo(n){!function _dispose(node){if(node.children.length){[...node.children].forEach((child=>{_dispose(child),node.remove(child)}))}node.geometry&&node.geometry.dispose(),node.material&&(Array.isArray(node.material)?node.material.forEach((m=>m.dispose())):node.material.dispose())}(n)}function deletegroup(grpbase,name){if(!grpbase?.children)return;let gr=grpbase.children.find((e=>e.name==name));if(gr){for(;gr.children.length>0;){const child=gr.children[0];gr.remove(child)}gr.parent&&gr.parent.remove(gr),gr=null}}function randombasemat(){const material=new THREE.LineBasicMaterial,color=new THREE.Color;return color.setHSL(Math.random(),.7,.4),material.color=color,material}
527
- /**
528
- * Crea una linea 3D
529
- * @param {Object} l - Oggetto contenente punti p1 e p2
530
- * @param {string} id - Identificatore
531
- * @param {THREE.Material} [mat=null] - Materiale da applicare
532
- * @returns {THREE.Line} Linea 3D
533
- */function getspriteid(id,size=5,color="#000"){const cnv=document.createElement("canvas"),ctx=cnv.getContext("2d");ctx.font="48px sans-serif";const w=Math.ceil(ctx.measureText(id).width)+16;cnv.width=w,cnv.height=64,ctx.font="48px sans-serif",ctx.textBaseline="middle",ctx.fillStyle="rgba(0,0,0,0)",ctx.fillRect(0,0,w,64),ctx.fillStyle=color,ctx.fillText(id,8,32);const map=new THREE.CanvasTexture(cnv);map.needsUpdate=!0,map.minFilter=THREE.LinearFilter;const sm=new THREE.SpriteMaterial({map:map,transparent:!0}),sp=new THREE.Sprite(sm),k=size/20;return sp.scale.set(w*k,64*k,1),sp}function getline(l,id,mat=null){const lineGeometry=(new THREE.BufferGeometry).setFromPoints([new THREE.Vector3(l.p1.x,0,l.p1.y),new THREE.Vector3(l.p2.x,0,l.p2.y)]);let tm=new THREE.Line(lineGeometry,mat||randombasemat());if(id){let sp=getspriteid(id||"",8,"#F00");sp.position.set((l.p1.x+l.p2.x)/2,0,(l.p1.y+l.p2.y)/2),tm.add(sp)}return tm}
534
- /**
535
- * Crea un punto 3D rappresentato da una sfera
536
- * @param {Object} p - Coordinate del punto
537
- * @param {string} id - Identificatore
538
- * @param {THREE.Material} [mat=null] - Materiale da applicare
539
- * @param {number} [size=5] - Dimensione della sfera
540
- * @returns {THREE.Mesh} Punto 3D
541
- */function getpoint(p,id,mat=null,size=5){let tm;const pointgeom=new THREE.SphereGeometry(size,8,8);if(tm=new THREE.Mesh(pointgeom,mat||randombasemat()),id){let sp=getspriteid(id||"",size);sp.position.set(1.2*size,0,1.2*size),tm.add(sp)}return tm.position.set(p.x,0,p.y),tm}async function smat(gcad,file,op={}){op||(op={});let ky=hash(file+JSON.stringify(op));return gcad.smats[ky]||(gcad.smats[ky]=await async function smat0(gcad,file,op={}){let fileini=file,paramstr="",isColore=!1;file.startsWith("#")&&(isColore=!0,/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})(?=$|[[(])/.test(file)||(file=file.slice(1)));let basefile=file;const paramMatch=file.match(/^(.*)\[([^\]]+)\]$/);paramMatch&&(basefile=paramMatch[1],paramstr=paramMatch[2]);const p={};paramstr&&paramstr.split(/[,;]/).forEach((kv=>{let[k,v]=kv.split("=").map((x=>x.trim()));void 0!==v&&(["e"].includes(k)?p[k]=v.startsWith("0x")?parseInt(v):parseFloat(v):isNaN(parseFloat(v))?p[k]=v:p[k]=parseFloat(v))}));const mappaParam={s:["sx","sy"],sx:["sx"],sy:["sy"],rot:["rot"],br:["brightness"],r:["roughness"],m:["metalness"],h:["bumpScale"],n:["normalScale"],d:["bumpScale"],b:["bumpScale"],e:["emissiveIntensity"],ec:["emissive"],env:["envMapIntensity"],o:["opacity"],t:["transparent"],at:["alphaTest"]};let rot0=op.rot,scale0=parseFloat(op.s)||1;delete op.s;let optot={...op};for(let k in p)if(mappaParam[k])for(let t of mappaParam[k])optot[t]=p[k];let transparent=!!optot?.transparent,sx=(optot.sx??optot.s??p.sx??p.s??1)*scale0,sy=(optot.sy??optot.s??p.sy??p.s??1)*scale0,rot=Number((p.rot??0)+(rot0??0))*PIF;try{let tm={roughness:optot.roughness??.5,metalness:optot.metalness??0,side:THREE.DoubleSide,envMapIntensity:optot.env??.6};if(void 0!==optot.normalScale){let ns=Number(optot.normalScale);isNaN(ns)||0===ns||(tm.normalScale=new THREE.Vector2(ns,ns))}let hasNormal=!1,hasBump=!1;if(file.includes("(")||isColore){let{base:base,files:files,transparent:t2}=function getFilesToLoad(isColore,basefile){let files=[],m=basefile.match(/^([^(]+)\((([a-zA-Z0-9_\-/]+)_([a-z]+)|([a-z]+))\)$/);if(!m)return{base:basefile,files:files};let base=m[1],transparent=!1,mapalias=m[3]||base,suffstr=m[4]||m[5]||"";isColore||files.push({suff:"",file:`${base}.webp`,cs:!0});for(let s of suffstr)"t"==s?(transparent=!0,m[3]&&suffissoMap[s]&&files.push({suff:s,file:`${mapalias}_${s}.webp`,cs:!1})):suffissoMap[s]&&files.push({suff:s,file:`${mapalias}_${s}.webp`,cs:!!["","n","e"].includes(s)});return{base:base,files:files,transparent:transparent}}(isColore,basefile);if(transparent=t2,files.some((f=>"n"===f.suff))&&(files=files.filter((f=>"h"!==f.suff))),0===optot.roughness&&(files=files.filter((f=>"r"!==f.suff))),0===optot.metalness&&(files=files.filter((f=>"m"!==f.suff))),0===optot.emissiveIntensity&&(files=files.filter((f=>"e"!==f.suff))),files&&files.length){let textures=await Promise.all(files.map((f=>gcad.tex(f.file,sx,sy,rot).catch((()=>null)))));for(let i=0;i<files.length;i++){let t=textures[i];if(!t)continue;t&&t.isTexture&&(t.colorSpace=files[i].cs?THREE.SRGBColorSpace:THREE.LinearSRGBColorSpace);let suff=files[i].suff,{prop:prop,extra:extra}=suffissoMap[suff];tm[prop]=t,"normalMap"===extra?(hasNormal=!0,tm.normalMap=t,tm.normalScale=tm.normalScale??new THREE.Vector2(1,1)):"bumpScale"===extra?(hasBump=!0,tm.bumpMap=t):Array.isArray(extra)&&extra.includes("emissive")&&void 0!==optot.emissiveIntensity&&0!==optot.emissiveIntensity&&(tm.emissive=optot.emissive||16777215,tm.emissiveIntensity=optot.emissiveIntensity??1)}}isColore&&(tm.color=new THREE.Color(base))}else if(basefile.includes(".")){let tx=await gcad.tex(basefile,sx,sy,rot);if(!tx)return mwhite;tm.map=tx}if(hasNormal&&hasBump?delete tm.bumpMap:hasBump&&(tm.bumpScale=optot.bumpScale??.03),tm.transparent=!!transparent,tm.transparent&&(tm.depthWrite=!1,tm.opacity=optot?.opacity??1),void 0!==optot.brightness){let bf=Number(optot.brightness);!isNaN(bf)&&bf>0&&1!==bf&&(tm.color||(tm.color=new THREE.Color(1,1,1)),tm.color.multiplyScalar(bf))}return new THREE.MeshStandardMaterial(tm)}catch(error){return console.log("errore mat:",error.message,fileini),mwhite}}
542
- /**
543
- * Estrae tutte le texture usate nella scena glb e le converte in file WEBP.
544
- * @param {THREE.Object3D} root - nodo root (es: gltf.scene)
545
- * @param {string} baseName - prefisso del nome file
546
- * @returns {Promise<File[]>} array di File webp
547
- */(gcad,file,op)),gcad.smats[ky]}
548
- /**
549
- * Crea un materiale PBR partendo da una stringa parametri
550
- * @param {object} gcad - contesto CAD con funzione tex()
551
- * @param {string} file - nome file o codice colore/parametri
552
- * @param {object} op - opzioni aggiuntive
553
- */const suffissoMap={"":{prop:"map",extra:null},n:{prop:"normalMap",extra:null},a:{prop:"aoMap",extra:"aoMapIntensity"},r:{prop:"roughnessMap",extra:null},h:{prop:"bumpMap",extra:"bumpScale"},t:{prop:"alphaMap",extra:null},m:{prop:"metalnessMap",extra:null},e:{prop:"emissiveMap",extra:["emissive","emissiveIntensity"]}};async function extractTextures(root,baseName){const counters={},out=[];function getName(suffix){counters[suffix]=(counters[suffix]||0)+1;let base=baseName;return suffix&&(base+=`_${suffix}`),counters[suffix]>1&&(base+=counters[suffix]),`${base}.webp`}return root.traverse((obj=>{if(obj.material){const materials=Array.isArray(obj.material)?obj.material:[obj.material];for(const mat of materials)for(const[suffix,{prop:prop}]of Object.entries(suffissoMap)){const tex=mat[prop];if(tex&&tex.image&&!tex._extracted){tex._extracted=!0;let promise,img=tex.image;if(img.toBlob)promise=new Promise((res=>img.toBlob(res,"image/webp")));else if(img instanceof ImageBitmap){const canvas=document.createElement("canvas");canvas.width=img.width,canvas.height=img.height;canvas.getContext("2d").drawImage(img,0,0),promise=new Promise((res=>canvas.toBlob(res,"image/webp")))}else{if(!(img instanceof HTMLImageElement))continue;{const canvas=document.createElement("canvas");canvas.width=img.naturalWidth||img.width,canvas.height=img.naturalHeight||img.height;canvas.getContext("2d").drawImage(img,0,0),promise=new Promise((res=>canvas.toBlob(res,"image/webp")))}}out.push(promise.then((blob=>new File([blob],getName(suffix),{type:"image/webp"}))))}}}})),root.traverse((obj=>{if(obj.material){const materials=Array.isArray(obj.material)?obj.material:[obj.material];for(const mat of materials)for(const{prop:prop}of Object.values(suffissoMap)){const tex=mat[prop];tex&&tex._extracted&&delete tex._extracted}}})),Promise.all(out)}function uvswap(geom){if(geom&&geom.attributes){const uv=geom.attributes.uv;if(uv){const a=uv.array;for(let i=0,n=a.length;i<n;i+=2){const t=a[i];a[i]=a[i+1],a[i+1]=t}uv.needsUpdate=!0}const uv2=geom.attributes.uv2;if(uv2){const b=uv2.array;for(let i=0,n=b.length;i<n;i+=2){const t=b[i];b[i]=b[i+1],b[i+1]=t}uv2.needsUpdate=!0}}}function getfakeshadow2(w,h,map){const shape=(new THREE.Shape).moveTo(0,0).lineTo(w,0).lineTo(w,h).lineTo(0,h).lineTo(0,0),geometry=new THREE.ShapeGeometry(shape),pos=geometry.attributes.position,uv=new Float32Array(2*pos.count);for(let i=0;i<pos.count;i++)uv[2*i]=pos.getX(i)/w,uv[2*i+1]=pos.getY(i)/h;geometry.setAttribute("uv",new THREE.BufferAttribute(uv,2));const material=new THREE.MeshBasicMaterial({map:map,transparent:!0,alphaTest:.01,depthWrite:!1,side:THREE.DoubleSide}),mesh=new THREE.Mesh(geometry,material);return mesh.layers.set(9),mesh.rotation.x=Math.PI/2,mesh}function getfakeshadow(gcad,shape,alfa){let ky=`fk${shape.key}${alfa}`,{p1:p1,width:width,height:height}=shape.dims();gcad.texture||(gcad.texture={});let tm=gcad.texture[ky];tm||(tm=function createBlurredShadowTextureFromPoints(mshape,size=256,blurPx=32,alpha=.2,p1,width,height){if(!width||!height||!mshape.pt||mshape.pt.length<2)return;const minX=p1.x,minY=p1.y,shapeWidth=width,shapeHeight=height,points=mshape.pt,extra=2*blurPx,canvas=document.createElement("canvas");canvas.width=size+2*extra,canvas.height=size+2*extra;const ctx=canvas.getContext("2d");ctx.save(),ctx.translate(extra,extra),ctx.scale(size/shapeWidth,size/shapeHeight),ctx.translate(-minX,-minY),ctx.filter=`blur(${blurPx}px)`,ctx.beginPath(),ctx.moveTo(points[0].x,points[0].y);for(let i=1;i<points.length;i++)ctx.lineTo(points[i].x,points[i].y);ctx.closePath(),ctx.fillStyle=`rgba(0,0,0,${alpha})`,ctx.fill(),ctx.restore();const texture=new THREE.CanvasTexture(canvas);return texture.needsUpdate=!0,texture}(shape,256,32,alfa,p1,width,height),gcad.texture[ky]=tm);const fakeShape=function pointsToShape(points){const fakeShape=new THREE.Shape;fakeShape.moveTo(points[0].x,points[0].y);for(let i=1;i<points.length;i++)fakeShape.lineTo(points[i].x,points[i].y);return fakeShape}(shape.pt),shadowGeometry=new THREE.ShapeGeometry(fakeShape);!function applyUVtoShapeGeometry(geometry,minX,minY,width,height){const pos=geometry.attributes.position,uv=[];for(let i=0;i<pos.count;i++){const x=pos.getX(i),y=pos.getY(i);uv.push((x-minX)/width,(y-minY)/height)}geometry.setAttribute("uv",new THREE.Float32BufferAttribute(uv,2))}(shadowGeometry,p1.x,p1.y,width,height);const shadowMaterial=new THREE.MeshBasicMaterial({map:tm,transparent:!0,depthWrite:!1,side:THREE.DoubleSide});let ms=new THREE.Mesh(shadowGeometry,shadowMaterial);return ms.layers.set(9),ms.rotation.x=Math.PI/2,ms}function addmovpivot(gcad,grp,movimento,op={},x=0,y=0,z=0){if(movimento=clean(movimento,!0),!gcad.movs[movimento])return grp;gcad.movs[movimento];const pivotLocal=new THREE.Vector3(x,y,z),isZeroPivot=0===pivotLocal.lengthSq(),pivotGroup=new THREE.Group;pivotGroup.name=`pivot_${movimento}`;const movimentoGroup=new THREE.Group;if(movimentoGroup.name=`mov_${movimento}`,isZeroPivot)pivotGroup.position.copy(grp.position),pivotGroup.quaternion.copy(grp.quaternion),grp.position.set(0,0,0),grp.rotation.set(0,0,0);else{const pivotWorld=pivotLocal.clone().applyMatrix4(grp.matrixWorld);pivotGroup.position.copy(pivotWorld);const offset=pivotLocal.clone().negate();grp.position.add(offset),pivotGroup.quaternion.copy(grp.getWorldQuaternion(new THREE.Quaternion)),grp.rotation.set(0,0,0)}return movimentoGroup.add(grp),pivotGroup.add(movimentoGroup),op||(op={}),op.inmov=!1,op.key=movimento,op.dt=0,op.dtstart=!1,movimentoGroup.userData.mov={...op},pivotGroup}
554
- /**
555
- * Crea un gestore di movimento per animare oggetti 3D.
556
- * @param {string} key - Chiave identificativa del movimento
557
- * @param {Array<Object>} gtimeline - Timeline di passi di animazione. Ogni passo può contenere:
558
- * @param {number} time - Durata del passo in millisecondi
559
- * @param {(number|function)} [x] - Traslazione X (unità o funzione che restituisce unità)
560
- * @param {(number|function)} [y] - Traslazione Y
561
- * @param {(number|function)} [z] - Traslazione Z
562
- * @param {(number|function)} [s] - Scala uniforme (moltiplicatore)
563
- * @param {(number|function)} [sx] - Scala X
564
- * @param {(number|function)} [sy] - Scala Y
565
- * @param {(number|function)} [sz] - Scala Z
566
- * @param {(number|function)} [ax] - Rotazione X (in giri)
567
- * @param {(number|function)} [ay] - Rotazione Y
568
- * @param {(number|function)} [az] - Rotazione Z
569
- * @param {(number|function)} [t] - Trasparenza (0-1)
570
- * @returns {Object} Oggetto gestore del movimento con metodi:
571
- * @property {number} tline - Durata totale della timeline
572
- * @property {function} clear - Pulisce la timeline
573
- * @property {function} add - Aggiunge un passo alla timeline
574
- * @property {string} key - Chiave del movimento
575
- * @property {function} step - Esegue un passo dell'animazione
576
- * @property {function} reset - Resetta l'oggetto alla posizione iniziale
577
- */function getmovimento(key,gtimeline=[]){let totale=0,timeline=[];const _cleartimeline=()=>{timeline=[],totale=0},_add=(t,op={})=>{t&&timeline.push({...op,time:t}),totale=timeline.reduce(((t,e)=>t+(e.time||0)),0)};_cleartimeline(),gtimeline&&gtimeline.length&&gtimeline.forEach((e=>_add(e.time,e)));const _resetmov=grp=>{const{mov:mov}=grp?.userData||{};mov&&(mov.inmov=!1,grp.position.set(0,0,0),grp.scale.set(1,1,1),grp.rotation.set(0,0,0))};return{get tline(){return totale},clear:_cleartimeline,add:_add,key:key,step:(grp,callback)=>{if(!grp||!grp.userData?.mov||!totale)return;const{mov:mov}=grp.userData;if(!mov.inmov)return;let dt=mov.dt-mov.dtstart;if(mov.ripeti)dt%=totale;else if(dt>totale)return void _resetmov(grp);let x=0,y=0,z=0,ax=0,ay=0,az=0,sx=1,sy=1,sz=1,t=null,accumTime=0;for(let step of timeline){if(accumTime+=step.time,dt<accumTime){const c=step.time>0?(dt-(accumTime-step.time))/step.time:1,_calc=(f,def=0)=>"function"==typeof f?f(mov)*c:(f||def)*c;x+=_calc(step.x),y+=_calc(step.y),z+=_calc(step.z),sx*=1+_calc(step.sx??step.s,0),sy*=1+_calc(step.sy??step.s,0),sz*=1+_calc(step.sz??step.s,0),ax+=_calc(step.ax)*PIF,ay+=_calc(step.ay)*PIF,az+=_calc(step.az)*PIF,void 0!==step.t&&(t="function"==typeof step.t?step.t(mov)*c:step.t*c);break}{const _calc=(f,def=0)=>"function"==typeof f?f(mov):f||def;x+=_calc(step.x),y+=_calc(step.y),z+=_calc(step.z),sx*=1+_calc(step.sx??step.s,0),sy*=1+_calc(step.sy??step.s,0),sz*=1+_calc(step.sz??step.s,0),ax+=_calc(step.ax)*PIF,ay+=_calc(step.ay)*PIF,az+=_calc(step.az)*PIF,void 0!==step.t&&(t="function"==typeof step.t?step.t(mov):step.t)}}grp.position.set(x,y,z),grp.scale.set(sx,sy,sz),grp.rotation.set(ax,ay,az),null!==t&&grp.traverse((obj=>{if(obj.material){(Array.isArray(obj.material)?obj.material:[obj.material]).forEach((mat=>{mat.transparent&&(mat.opacity=1-t)}))}})),callback&&callback(grp,dt)},reset:_resetmov}}let globalLabelCanvas=null,globalLabelContext=null;
578
- /**
579
- * Crea un punto di riferimento invisibile nell'albero 3D
580
- * @param {number} x - Coordinata X
581
- * @param {number} y - Coordinata Y
582
- * @param {number} z - Coordinata Z
583
- * @param {Object} dati - Dati da archiviare nell'oggetto
584
- * @param {string} [id=null] - Identificatore opzionale
585
- * @returns {THREE.Object3D} Oggetto di riferimento invisibile
586
- */
587
- function getriferimento(dati,x=0,y=0,z=0,id="rif"){"string"==typeof dati&&(dati={testo:dati});let riferimento=new THREE.Object3D;return riferimento.position.set(x,y,z),id&&(riferimento.name=id),riferimento.userData={tipo:"rif",...dati},riferimento}
588
- /**
589
- * Crea una targhetta rettangolare con testo
590
- * @param {Array|string} testo - Array di oggetti {testo, size, colore} o stringa
591
- * @param {number} dim - Larghezza/altezza della targhetta
592
- * @param {Object} options - Opzioni aggiuntive
593
- * @returns {THREE.Mesh} Mesh con la targhetta
594
- */function gettarghetta(gcad,testo,dim=100,options={}){const{noSfondo:noSfondo=!1,forcey:forcey=!1,coloreSfondo:coloreSfondo="white",coloreBordo:coloreBordo="gray",spessoreBordo:spessoreBordo=2,padding:padding=8,layer:layer=21,size:size=24,fontFamily:fontFamily="Arial",raggioAngoli:raggioAngoli=10,order:order=0}=options;testo=(testo||"").replaceAll("\\n","\n");let tt=hash(`T:${coloreSfondo}|${coloreBordo}|${fontFamily}|${padding}|${spessoreBordo}|${raggioAngoli}|${noSfondo}|${testo}`);const sizebase=size??24;testo=testo.split("\n").map((e=>{let size=sizebase,bold=!1,italic=!1,color="black";e=e.trim();let rr=/^\s*#(\w)([bi]?)([\d.]*)[,;](.*)$/.exec(e);if(rr)switch(size=parseFloat(rr[3]||1)*sizebase,"b"===rr[2]&&(bold=!0),"i"===rr[2]&&(italic=!0),e=rr[4],rr[1].toLowerCase()){case"r":color="red";break;case"g":color="green";break;case"b":color="blue";break;case"c":color="cyan"}return{testo:e,size:size,color:color,bold:bold,italic:italic}})).filter((e=>e.testo));const{canvas:canvas,context:context}=function getGlobalCanvas(){return globalLabelCanvas||(globalLabelCanvas=document.createElement("canvas"),globalLabelContext=globalLabelCanvas.getContext("2d",{willReadFrequently:!0})),{canvas:globalLabelCanvas,context:globalLabelContext}}();let maxWidth=0,totalHeight=2*padding;testo.forEach(((riga,i)=>{const{testo:testoRiga,size:size=12}=riga,fontSize=2*size;context.font=`${fontSize}px ${fontFamily}`;const textWidth=context.measureText(testoRiga).width,textHeight=fontSize*(i==testo.length-1?1:1.2);maxWidth=Math.max(maxWidth,textWidth),totalHeight+=textHeight})),maxWidth+=2*padding;const aspectRatio=totalHeight/maxWidth||1;let dimx,dimy;if(forcey?(dimy=dim,dimx=Math.ceil(dimy/aspectRatio)):(dimx=dim,dimy=Math.ceil(dimx*aspectRatio)),!gcad.textures[tt]){const canvasWidth=Math.floor(maxWidth+2*spessoreBordo),canvasHeight=Math.floor(totalHeight+2*spessoreBordo);(canvas.width<canvasWidth||canvas.height<canvasHeight)&&(canvas.width=Math.max(canvas.width,canvasWidth),canvas.height=Math.max(canvas.height,canvasHeight)),context.clearRect(0,0,canvasWidth,canvasHeight);const bgColor=new THREE.Color(coloreSfondo),bgColorStyle=`rgb(${Math.floor(255*bgColor.r)}, ${Math.floor(255*bgColor.g)}, ${Math.floor(255*bgColor.b)})`,borderColor=new THREE.Color(coloreBordo),borderColorStyle=`rgb(${Math.floor(255*borderColor.r)}, ${Math.floor(255*borderColor.g)}, ${Math.floor(255*borderColor.b)})`,radius=raggioAngoli;context.beginPath(),noSfondo||(drawRoundedRect(context,0,0,canvasWidth,canvasHeight,radius+spessoreBordo/2),context.fillStyle=borderColorStyle,context.fill(),context.beginPath(),drawRoundedRect(context,spessoreBordo,spessoreBordo,canvasWidth-2*spessoreBordo,canvasHeight-2*spessoreBordo,radius-spessoreBordo/2),context.fillStyle=bgColorStyle,context.fill());let yPosition=padding+spessoreBordo;testo.forEach((riga=>{const{testo:testoRiga,size:size=12,color:color="black",bold:bold,italic:italic}=riga,fontSize=2*size;context.font=`${bold?"bold ":italic?"italic ":""}${fontSize}px ${fontFamily}`,context.fillStyle=color,context.textAlign="center",context.textBaseline="top",context.fillText(testoRiga,canvasWidth/2,yPosition),yPosition+=1.2*fontSize}));const imageData=context.getImageData(0,0,canvasWidth,canvasHeight),texture=new THREE.DataTexture(imageData.data,imageData.width,imageData.height,THREE.RGBAFormat);texture.needsUpdate=!0,texture.flipY=!0,texture.minFilter=THREE.LinearFilter,texture.magFilter=THREE.LinearFilter,gcad.textures[tt]=texture}const materialeTesto=new THREE.MeshBasicMaterial({map:gcad.textures[tt],transparent:!0,alphaTest:.5,side:SIDE}),geometriaTesto=new THREE.PlaneGeometry(dimx,dimy),meshTesto=new THREE.Mesh(geometriaTesto,materialeTesto);return meshTesto.layers.set(layer),meshTesto.renderOrder=order,meshTesto.userData={dimx:dimx,dimy:dimy},meshTesto}function drawRoundedRect(ctx,x,y,width,height,radius){radius=Math.min(radius,Math.min(width/2,height/2)),ctx.moveTo(x+radius,y),ctx.lineTo(x+width-radius,y),ctx.quadraticCurveTo(x+width,y,x+width,y+radius),ctx.lineTo(x+width,y+height-radius),ctx.quadraticCurveTo(x+width,y+height,x+width-radius,y+height),ctx.lineTo(x+radius,y+height),ctx.quadraticCurveTo(x,y+height,x,y+height-radius),ctx.lineTo(x,y+radius),ctx.quadraticCurveTo(x,y,x+radius,y),ctx.closePath()}
595
- /**
596
- * Crea una quota tra due punti in 3D sul piano XY
597
- * @param {string} testo - Testo da visualizzare nella quota
598
- * @param {number} x1 - Coordinata X del primo punto
599
- * @param {number} y1 - Coordinata Y del primo punto
600
- * @param {number} x2 - Coordinata X del secondo punto
601
- * @param {number} y2 - Coordinata Y del secondo punto
602
- * @param {number} sizetesto - Dimensione del testo
603
- * @param {Object} options - Opzioni aggiuntive
604
- * @returns {THREE.Group} Gruppo contenente la quota
605
- */function getquota(gcad,testo,x1,y1,x2,y2,options={}){const{altezza:altezza=30,offset:offset=0,piano:piano="xy",layer:layer=22,delta:delta=5,spessoreLinea:spessoreLinea=3}=options,pp=(x,y)=>"xz"===piano?[x,0,y]:"yz"===piano?[0,x,y]:[x,y,0],quotaGroup=new THREE.Group;quotaGroup.name="quota";const dx=x2-x1,dy=y2-y1,distanza=Math.sqrt(dx*dx+dy*dy),angolo=Math.atan2(dy,dx);testo||(testo="$$"),testo.includes("$$")&&(testo=testo.replace("$$",`${distanza.toFixed(1)}`));let linee=testo.split("\n").length;const offsetX=-Math.sin(angolo)*offset,offsetY=Math.cos(angolo)*offset,targhetta=gettarghetta(gcad,testo,2*altezza*linee,{noSfondo:!0,layer:layer,forcey:!0}),{dimx:dimx,dimy:dimy}=targhetta.userData;function getCilindro(puntoInizio,puntoFine,spessore){const direzione=(new THREE.Vector3).subVectors(puntoFine,puntoInizio),lunghezza=direzione.length();let geometria,ky=hash(`c:${spessore}|${lunghezza}`);gcad.geo[ky]?geometria=gcad.geo[ky]:(geometria=new THREE.CylinderGeometry(spessore/2,spessore/2,lunghezza,3,1,!0),gcad.geo[ky]=geometria);const cilindro=new THREE.Mesh(geometria,mblack);cilindro.position.copy(puntoInizio).add(direzione.multiplyScalar(.5));const punto=(new THREE.Vector3).copy(puntoFine);return cilindro.lookAt(punto),cilindro.rotateX(Math.PI/2),cilindro}if(dimx>distanza-delta){targhetta.position.set(distanza/2,altezza,0);const lineaOrizzontale=getCilindro(new THREE.Vector3(...pp(0,0)),new THREE.Vector3(...pp(distanza,0)),spessoreLinea);quotaGroup.add(lineaOrizzontale)}else{const spazioTarghetta=dimx+delta,inizioTarghetta=(distanza-spazioTarghetta)/2,fineTarghetta=inizioTarghetta+spazioTarghetta,lineaOrizzontale1=getCilindro(new THREE.Vector3(...pp(0,0)),new THREE.Vector3(...pp(inizioTarghetta,0)),spessoreLinea);quotaGroup.add(lineaOrizzontale1);const lineaOrizzontale2=getCilindro(new THREE.Vector3(...pp(fineTarghetta,0)),new THREE.Vector3(...pp(distanza,0)),spessoreLinea);quotaGroup.add(lineaOrizzontale2),targhetta.position.set(...pp(distanza/2,0))}const h1=offset>altezza/2?-offset:-altezza/2,h2=-offset>altezza/2?-offset:altezza/2,puntoInizioV1=new THREE.Vector3(...pp(0,h1)),puntoFineV1=new THREE.Vector3(...pp(0,h2)),puntoInizioV2=new THREE.Vector3(...pp(distanza,h1)),puntoFineV2=new THREE.Vector3(...pp(distanza,h2)),lineaVerticale1=getCilindro(puntoInizioV1,puntoFineV1,spessoreLinea);quotaGroup.add(lineaVerticale1);const lineaVerticale2=getCilindro(puntoInizioV2,puntoFineV2,spessoreLinea);return quotaGroup.add(lineaVerticale2),targhetta.userData.updateOrientation=function(camera){camera&&this.quaternion.copy(camera.quaternion)},quotaGroup.add(targhetta),"xy"===piano?(quotaGroup.position.set(x1+offsetX,y1+offsetY,0),quotaGroup.rotation.z=angolo):"xz"===piano?(quotaGroup.position.set(x1+offsetX,0,y1+offsetY),quotaGroup.rotation.y=-angolo):"yz"===piano&&(quotaGroup.position.set(0,x1+offsetX,y1+offsetY),quotaGroup.rotation.x=angolo),quotaGroup.traverse((function(object){object.layers.set(layer)})),quotaGroup}
606
- /**
607
- * Perlin noise 2D tileable, RGBA interpolato, con supporto scale e octaves
608
- */function fillNoise(data,size,op={}){let{scale:scale=8,octaves:octaves=3,persistence:persistence=.5,seed:seed=0,contrast:contrast=1,color1:color1="#000000",color2:color2="#ffffff",alpha1:alpha1=1,alpha2:alpha2=1}=op;const c1=new THREE.Color(color1),c2=new THREE.Color(color2),fade=t=>t*t*t*(t*(6*t-15)+10),lerp=(a,b,t)=>a+(b-a)*t,period=size,perm=new Uint16Array(2*period);let seedval=0|Math.floor(65536*seed);for(let i=0;i<period;i++)perm[i]=i;for(let i=0;i<period;i++){const j=Math.floor((seedval^=seedval<<13,seedval^=seedval>>17,seedval^=seedval<<5,(seedval<0?1+~seedval:seedval)%65536/65536*period));[perm[i],perm[j]]=[perm[j],perm[i]]}for(let i=0;i<period;i++)perm[period+i]=perm[i];const grad2=[[1,1],[-1,1],[1,-1],[-1,-1],[1,0],[-1,0],[0,1],[0,-1]];function grad(ix,iy){const idx=perm[(perm[ix%period]+iy)%period]%8;return grad2[idx]}function perlin(x,y,periodx,periody){const X=Math.floor(x)%periodx,Y=Math.floor(y)%periody,xf=x-Math.floor(x),yf=y-Math.floor(y),g00=grad(X,Y),g10=grad(X+1,Y),g01=grad(X,Y+1),g11=grad(X+1,Y+1),n00=g00[0]*xf+g00[1]*yf,n10=g10[0]*(xf-1)+g10[1]*yf,n01=g01[0]*xf+g01[1]*(yf-1),n11=g11[0]*(xf-1)+g11[1]*(yf-1),u=fade(xf),v=fade(yf);return lerp(lerp(n00,n10,u),lerp(n01,n11,u),v)}let minv=1/0,maxv=-1/0;const values=new Float32Array(size*size);for(let y=0;y<size;y++)for(let x=0;x<size;x++){let nx=x/size*scale,ny=y/size*scale,amp=1,freq=1,sum=0,norm=0;for(let o=0;o<octaves;o++){sum+=perlin(nx*freq,ny*freq,period/freq,period/freq)*amp,norm+=amp,amp*=persistence,freq*=2}let v=sum/norm;values[y*size+x]=v,v<minv&&(minv=v),v>maxv&&(maxv=v)}const scalev=1/(maxv-minv);for(let y=0;y<size;y++)for(let x=0;x<size;x++){let v=(values[y*size+x]-minv)*scalev;v=Math.pow(v,contrast);const r=c1.r+(c2.r-c1.r)*v,g=c1.g+(c2.g-c1.g)*v,b=c1.b+(c2.b-c1.b)*v,a=0,i=4*(y*size+x);data[i]=Math.floor(255*r),data[i+1]=Math.floor(255*g),data[i+2]=Math.floor(255*b),data[i+3]=Math.floor(255*a)}}function texgen(gcad,type,size=256,op={}){[16,32,64,128,256,512,1024].includes(size)||(size=256);let ky=hash(`gen|${type}|${size}|${JSON.stringify(op)}`);if(!gcad[ky]){const data=new Uint8Array(size*size*4);switch(type){case"wood":let op1={...op};op1.scale=6+seeder(40,op.seed+"a")/10,op1.octaves=op.octaves||3,op1.persistence=.5+seeder(50,op.seed+"b")/100,op1.rings=2+seeder(200,op.seed+"c")/100,op1.distortion=.3+seeder(100,op.seed+"d")/300,op1.color1=op.color1||"#442200",op1.color2=op.color2||"#ffe0a0",fillNoise(data,size,op1);break;case"marble":let op2={...op};op2.scale=op.scale||10,op2.octaves=op.octaves||3,op2.persistence=op.persistence||.6,op2.rings=op.rings||1+seeder(100,op.seed+"m3")/50,op2.distortion=op.distortion||.8+seeder(200,op.seed+"m4")/200,op2.contrast=op.contrast||1.2,op2.color1=op.color1||"#e0e0e0",op2.color2=op.color2||"#909090",fillNoise(data,size,op2);break;case"glass":let opg={...op};opg.scale=op.scale||32,opg.octaves=op.octaves||2,opg.persistence=op.persistence||.8,opg.contrast=op.contrast||1,opg.color1=op.color1||"rgba(255,255,255,0.2)",opg.color2=op.color2||"rgba(255,255,255,0.6)",fillNoise(data,size,opg);break;case"gradient":case"pattern":break;default:fillNoise(data,size,op)}const tex=new THREE.DataTexture(data,size,size,THREE.RGBAFormat);tex.needsUpdate=!0,tex.wrapS=tex.wrapT=THREE.RepeatWrapping,tex.repeat.set(.002,.002),tex.center.set(.5,.5),gcad[ky]=tex}return gcad[ky]}
609
- /**
610
- * Crea un cilindro 3D con orientamento personalizzabile
611
- * @param {string} ori - Orientamento (X/L, Y/A, Z/P)
612
- * @param {number} h - Altezza
613
- * @param {number} r1 - Raggio base
614
- * @param {number} r2 - Raggio top
615
- * @param {THREE.Material|Array} mats - Materiale/i da applicare
616
- * @param {Object} options - Opzioni di configurazione
617
- * @returns {Promise<THREE.Group>} Gruppo contenente il cilindro
618
- */
619
- function getcilindro(gcad,ori,h,r1,r2,mats=mwhite,options){options||(options={}),Array.isArray(mats)||(mats=[mats]);const cyl=function cylgeometry(gcad,h,r,rtop,segments=16){if(!r||!h)return null;let ky=hash(`cy${h}|${r}|${rtop||r}|${segments}`);if(!gcad.geo[ky]){const geometry=new THREE.CylinderGeometry(rtop||r,r,h,segments);gcad.geo[ky]=geometry}return gcad.geo[ky]}(gcad,h,r1,r2,options.sides||16);let grp=new THREE.Group;switch((ori||"").trim().toUpperCase()){case"X":case"L":grp.position.set(h/2,0,0),grp.rotation.z=Math.PI/2;break;case"Z":case"P":grp.position.set(0,0,h/2),grp.rotation.x=Math.PI/2;break;default:grp.position.set(0,h/2,0)}if(cyl){if(!options.nolines){let segments=edgesfromgeometry(cyl);grp.add(segments)}options.uvswap&&uvswap(cyl);const matTop=mats[0]||mwhite,matBottom=mats[1]||matTop,matSides=mats[2]||matTop;grp.add(getmesh(cyl,[matTop,matBottom,matSides]))}return grp}
620
- /**
621
- * Crea un box 3D con linee di bordo opzionali
622
- * @param {number} x - Larghezza
623
- * @param {number} y - Altezza
624
- * @param {number} z - Profondità
625
- * @param {THREE.Material} mat - Materiale da applicare
626
- * @param {Object} options - Opzioni di configurazione
627
- * @returns {Promise<THREE.Group>} Gruppo contenente il box
628
- */function scalauv(box){const uvAttr=box.attributes.uv;if(uvAttr){const arr=uvAttr.array;for(let i=0;i<arr.length;i++)arr[i]*=1e3;uvAttr.needsUpdate=!0}}function getface(gcad,x,y,mat,op={}){let{repeat:repeat,order:order,center:center=!1}=op;const key=hash(`f:${x}|${y}|${repeat?1:0}`);if(!gcad.geo[key]){const geometry=new THREE.PlaneGeometry(x,y),uvs=geometry.attributes.uv;if(repeat)for(let i=0;i<uvs.count;i++)uvs.setXY(i,uvs.getX(i)*x,uvs.getY(i)*y);else{const tm=[[0,1e3],[1e3,1e3],[0,0],[1e3,0]];for(let i=0;i<uvs.count;i++){const t=tm[i];uvs.setXY(i,t[0],t[1])}}uvs.needsUpdate=!0,gcad.geo[key]=geometry}const plane=new THREE.Mesh(gcad.geo[key],mat);return"number"==typeof order&&(plane.renderOrder=order),center||plane.position.set(x/2,y/2,0),mat?.transparent&&plane.layers.set(2),plane}function getbox(gcad,x,y,z,mat,options){mat&&mat.isMaterial||(options=mat,mat=void 0),options||(options={});let{center:center=!1,nolines:nolines,centerbase:centerbase=!1,px:px=0,py:py=0,pz:pz=0}=options;const box=new THREE.BoxGeometry(x,y,z);scalauv(box);const grp=new THREE.Group;if(centerbase?grp.position.set(0,y/2,0):px||py||pz?grp.position.set(px||0,py||0,pz||0):center||grp.position.set(x/2,y/2,z/2),!nolines||!mat){let segments=edgesfromgeometry(box);grp.add(segments)}return mat&&grp.add(getmesh(box,mat)),grp}function getcyl(gcad,height,radius,mat,options){options||(options={});let{center:center=!1,nolines:nolines=!1,segments:segments=16,top:top=-1,bottom:bottom=-1,heightSegments:heightSegments=1,openEnded:openEnded=!1,thetaStart:thetaStart=0,thetaLength:thetaLength=2*Math.PI}=options;top<0&&(top=radius),bottom<0&&(bottom=radius);const cylinder=new THREE.CylinderGeometry(top,bottom,height,segments,heightSegments,openEnded,thetaStart,thetaLength);scalauv(cylinder),options.uvswap&&uvswap(cylinder);const mesh=getmesh(cylinder,mat||mwhite),grp=new THREE.Group;if(grp.add(mesh),grp.position.set(0,center?0:height/2,0),!nolines){let segs=edgesfromgeometry(cylinder);grp.add(segs)}return grp}
629
- /**
630
- * Crea una sfera 3D come gruppo (mesh + edges opzionali).
631
- * @param {object} gcad - riferimento (non usato ma coerente con getbox)
632
- * @param {number} r - raggio della sfera
633
- * @param {THREE.Material} mat - materiale della mesh
634
- * @param {object} [options] - opzioni: {center: boolean, nolines: boolean}
635
- * @returns {THREE.Group}
636
- */function getsphere(gcad,r,mat,options){options||(options={});let{nolines:nolines,segmenti:segmenti=16}=options,grp=new THREE.Group;const sphere=new THREE.SphereGeometry(r,2*segmenti,segmenti);if(scalauv(sphere),!nolines){let segments=edgesfromgeometry(sphere);grp.add(segments)}return grp.add(getmesh(sphere,mat||mwhite)),grp}function makeShape(points){const shape=new THREE.Shape;shape.moveTo(points[0].x,points[0].y);for(let i=1;i<points.length;i++)shape.lineTo(points[i].x,points[i].y);return shape.closePath(),shape}function extrudelines(grp,pts,holes,h,sy=3){const addring=arr=>{const top=((arr,z)=>{if(!arr||arr.length<2)return null;const n=arr.length,pos=new Float32Array(3*(n+1));for(let i=0;i<=n;i++){const p=arr[i%n],o=3*i;pos[o]=p.x,pos[o+1]=p.y,pos[o+2]=z}const g=new THREE.BufferGeometry;return g.setAttribute("position",new THREE.BufferAttribute(pos,3)),new THREE.Line(g,materialline1)})(arr,-sy);top&&(top.layers.set(30),grp.add(top))};addring(pts);for(const hh of holes)addring(hh)}function getextrude(gcad,pts,h=10,holes=[],mat=void 0,op={}){mat&&mat.isMaterial||(op=mat,mat=void 0),op=op??{};let{stonda:stonda,sx:sx,sy:sy,round:round,nolines:nolines}=op,ky=hash(`${JSON.stringify(pts)}|${h}|${JSON.stringify(op)}|${JSON.stringify(holes)}`);sx=sx??stonda??0,sy=sy??stonda??0;let geom=gcad.geo[ky];if(!geom){const sh=makeShape(pts);holes.forEach((hh=>sh.holes.push(function makePath(points){const path=new THREE.Path;path.moveTo(points[0].x,points[0].y);for(let i=1;i<points.length;i++)path.lineTo(points[i].x,points[i].y);return path.closePath(),path}(hh))));const benabled=sx>0&&sy>0;geom=new THREE.ExtrudeGeometry(sh,{depth:h,bevelEnabled:benabled,bevelSize:sx,bevelThickness:sy,bevelSegments:benabled?round?3:1:0,curveSegments:benabled?10:1}),gcad.geo[ky]=geom,op.uvswap&&uvswap(geom)}let tm=new THREE.Group;return tm.add(new THREE.Mesh(geom,mat||mwhite)),nolines||extrudelines(tm,pts,holes,0,sy),tm}function getthorus(gcad,r,tuber=.2,mat,options){options||(options={});let{center:center,nolines:nolines,segmenti:segmenti=16,tubi:tubi=12}=options,grp=new THREE.Group;const thorus=new THREE.TorusGeometry(r,tuber,tubi,2*segmenti);if(scalauv(thorus),grp.position.set(0,center?0:r,0),!nolines){let segments=edgesfromgeometry(thorus);grp.add(segments)}return grp.add(getmesh(thorus,mat||mwhite)),grp}function getluce(gcad,shape,color="#ffffff",intensity=1){const pt=shape.pt;if(!pt||!pt.length)return null;const ky=hash(`${shape.key}|${color}|${intensity}`);if(!gcad.meshes[ky]){const sh=makeShape(pt),geom=new THREE.ShapeGeometry(sh),mat=new THREE.MeshStandardMaterial({color:new THREE.Color(color),emissive:new THREE.Color(color),emissiveIntensity:intensity,toneMapped:!1,transparent:!0,depthWrite:!1,side:THREE.DoubleSide,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:1}),mesh=new THREE.Mesh(geom,mat);mesh.layers.set(8),mesh.userData.isBloom=!0,gcad.meshes[ky]=mesh,gcad.mustlight=!0}return gcad.meshes[ky]}
637
- /**
638
- * @param {BufferGeometry} geometry
639
- * @param {number} tolerance
640
- * @return {BufferGeometry}
641
- */
642
- /**
643
- * @param {BufferGeometry} geometry
644
- * @param {number} drawMode
645
- * @return {BufferGeometry}
646
- */
647
- function toTrianglesDrawMode(geometry,drawMode){if(drawMode===TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),geometry;if(drawMode===TriangleFanDrawMode||drawMode===TriangleStripDrawMode){let index=geometry.getIndex();if(null===index){const indices=[],position=geometry.getAttribute("position");if(void 0===position)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),geometry;for(let i=0;i<position.count;i++)indices.push(i);geometry.setIndex(indices),index=geometry.getIndex()}const numberOfTriangles=index.count-2,newIndices=[];if(drawMode===TriangleFanDrawMode)for(let i=1;i<=numberOfTriangles;i++)newIndices.push(index.getX(0)),newIndices.push(index.getX(i)),newIndices.push(index.getX(i+1));else for(let i=0;i<numberOfTriangles;i++)i%2==0?(newIndices.push(index.getX(i)),newIndices.push(index.getX(i+1)),newIndices.push(index.getX(i+2))):(newIndices.push(index.getX(i+2)),newIndices.push(index.getX(i+1)),newIndices.push(index.getX(i)));newIndices.length/3!==numberOfTriangles&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const newGeometry=geometry.clone();return newGeometry.setIndex(newIndices),newGeometry.clearGroups(),newGeometry}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",drawMode),geometry}function pannellogeometry(gcad,l,a,p,r1=0,r2=0,r3=0,r4=0,b=0,npt=2,fluvswap=!1){let ky=hash(`pg--${l}|${a}|${p}|${r1}|${r2}|${r3}|${r4}|${b}|${npt}|${fluvswap?1:0}`);if(l-=.01,a-=.01,p-=.01,!gcad.geo[ky]){l-=2*b,a-=2*b,p-=2*b;let tm=getshape();const vv=[{x:r4,y:0},{x:a-r1,y:0},{x:a,y:r1},{x:a,y:p-r2},{x:a-r2,y:p},{x:r3,y:p},{x:0,y:p-r3},{x:0,y:r4}];tm.addpt(vv[0]),tm.addpt(vv[1]),r1&&tm.addpt(raccordabezier(vv[0],vv[1],vv[2],vv[3],npt)),tm.addpt(vv[2]),tm.addpt(vv[3]),r2&&tm.addpt(raccordabezier(vv[2],vv[3],vv[4],vv[5],npt)),tm.addpt(vv[4]),tm.addpt(vv[5]),r3&&tm.addpt(raccordabezier(vv[4],vv[5],vv[6],vv[7],npt)),tm.addpt(vv[6]),tm.addpt(vv[7]),r2&&tm.addpt(raccordabezier(vv[6],vv[7],vv[0],vv[1],npt)),tm.removeduplicate(.01);let pts=tm.pt;const shape=new THREE.Shape;shape.moveTo(pts[0].x,pts[0].y);for(let i=1;i<pts.length;i++)shape.lineTo(pts[i].x,pts[i].y);shape.lineTo(pts[0].x,pts[0].y);const extrudeSettings={depth:l,bevelEnabled:b>0,bevelThickness:b,bevelSize:b,bevelSegments:1};let xgeo=new THREE.ExtrudeGeometry(shape,extrudeSettings);xgeo=function mergeVertices(geometry,tolerance=1e-4){tolerance=Math.max(tolerance,Number.EPSILON);const hashToIndex={},indices=geometry.getIndex(),positions=geometry.getAttribute("position"),vertexCount=indices?indices.count:positions.count;let nextIndex=0;const attributeNames=Object.keys(geometry.attributes),tmpAttributes={},tmpMorphAttributes={},newIndices=[],getters=["getX","getY","getZ","getW"],setters=["setX","setY","setZ","setW"];for(let i=0,l=attributeNames.length;i<l;i++){const name=attributeNames[i],attr=geometry.attributes[name];tmpAttributes[name]=new attr.constructor(new attr.array.constructor(attr.count*attr.itemSize),attr.itemSize,attr.normalized);const morphAttributes=geometry.morphAttributes[name];morphAttributes&&(tmpMorphAttributes[name]||(tmpMorphAttributes[name]=[]),morphAttributes.forEach(((morphAttr,i)=>{const array=new morphAttr.array.constructor(morphAttr.count*morphAttr.itemSize);tmpMorphAttributes[name][i]=new morphAttr.constructor(array,morphAttr.itemSize,morphAttr.normalized)})))}const halfTolerance=.5*tolerance,exponent=Math.log10(1/tolerance),hashMultiplier=Math.pow(10,exponent),hashAdditive=halfTolerance*hashMultiplier;for(let i=0;i<vertexCount;i++){const index=indices?indices.getX(i):i;let hash="";for(let j=0,l=attributeNames.length;j<l;j++){const name=attributeNames[j],attribute=geometry.getAttribute(name),itemSize=attribute.itemSize;for(let k=0;k<itemSize;k++)hash+=~~(attribute[getters[k]](index)*hashMultiplier+hashAdditive)+","}if(hash in hashToIndex)newIndices.push(hashToIndex[hash]);else{for(let j=0,l=attributeNames.length;j<l;j++){const name=attributeNames[j],attribute=geometry.getAttribute(name),morphAttributes=geometry.morphAttributes[name],itemSize=attribute.itemSize,newArray=tmpAttributes[name],newMorphArrays=tmpMorphAttributes[name];for(let k=0;k<itemSize;k++){const getterFunc=getters[k],setterFunc=setters[k];if(newArray[setterFunc](nextIndex,attribute[getterFunc](index)),morphAttributes)for(let m=0,ml=morphAttributes.length;m<ml;m++)newMorphArrays[m][setterFunc](nextIndex,morphAttributes[m][getterFunc](index))}}hashToIndex[hash]=nextIndex,newIndices.push(nextIndex),nextIndex++}}const result=geometry.clone();for(const name in geometry.attributes){const tmpAttribute=tmpAttributes[name];if(result.setAttribute(name,new tmpAttribute.constructor(tmpAttribute.array.slice(0,nextIndex*tmpAttribute.itemSize),tmpAttribute.itemSize,tmpAttribute.normalized)),name in tmpMorphAttributes)for(let j=0;j<tmpMorphAttributes[name].length;j++){const tmpMorphAttribute=tmpMorphAttributes[name][j];result.morphAttributes[name][j]=new tmpMorphAttribute.constructor(tmpMorphAttribute.array.slice(0,nextIndex*tmpMorphAttribute.itemSize),tmpMorphAttribute.itemSize,tmpMorphAttribute.normalized)}}return result.setIndex(newIndices),result}(xgeo),xgeo.computeVertexNormals();const uv=xgeo.attributes.uv;let x1=Math.random()*l,y1=Math.random()*(a+p);fluvswap&&uvswap(xgeo);for(let i=0;i<uv.count;i++)uv.setXY(i,uv.getY(i)+y1,uv.getX(i)+x1);uv.needsUpdate=!0,gcad.geo[ky]=xgeo}return gcad.geo[ky]}function getpannello(gcad,orientamento,x,y,z,mat1,mat2,options){options||(options={});let l,a,p,{r:r,r1:r1,r2:r2,r3:r3,r4:r4,b:b,npt:npt}=options;r1=r1||r||0,r2=r2||r||0,r3=r3||r||0,r4=r4||r||0,npt=npt||2,b=b||0,(b>=x/2||b>=y/2||b>=z/2)&&(b=0),l="L"==(orientamento=orientamento.trim().toUpperCase())[0]?x:"A"==orientamento[0]?y:z,a="L"==orientamento[1]?x:"A"==orientamento[1]?y:z,p="L"==orientamento[2]?x:"A"==orientamento[2]?y:z;let grp=new THREE.Group;if(!options.nolines){let segments=edgesfromgeometry(new THREE.BoxGeometry(x,y,z));segments.position.set(x/2,y/2,z/2),grp.add(segments)}let mesh=getmesh(pannellogeometry(gcad,l,a,p,r1,r2,r3,r4,b,npt,options.uvswap),[mat2||mat1||mgreen,mat1||mred]);mesh.name="pannello",mesh.layers.set(1);let m2=mesh;return b&&(mesh.position.set(b,b,b),m2=new THREE.Group,m2.add(mesh)),mesh=function meshrotate(orientamento,mesh,x=0,y=0,z=0){switch(orientamento.trim().toUpperCase()){case"LPA":mesh.rotation.y=Math.PI/2,mesh.rotation.x=Math.PI,mesh.position.set(0,z,0);break;case"ALP":mesh.rotation.x=Math.PI/2,mesh.position.set(0,x,0);break;case"APL":mesh.rotation.x=-Math.PI/2,mesh.rotation.z=-Math.PI/2;break;case"PLA":break;case"PAL":mesh.rotation.z=Math.PI/2,mesh.position.set(z,0,0);break;case"LAP":mesh.rotation.y=Math.PI/2,mesh.rotation.z=Math.PI/2}return mesh}(orientamento,m2,l,a,p),grp.add(mesh),grp}async function getpannello2(gcad,orientamento,l,a,p,mat,round=0){let bb;switch((round<0||round>Math.max(l,a,p)/3)&&(round=0),orientamento){case"lap":bb=getextrude(gcad,getshape().fromrect(l-2*round,a-2*round).pt,p-2*round,[],mat,{round:round,stonda:round}),bb.position.x=round,bb.position.z=p-round,bb.position.y=a-round,bb.rotation.x=Math.PI;break;case"alp":bb=getextrude(gcad,getshape().fromrect(a-2*round,l-2*round).pt,p-2*round,[],mat,{round:round,stonda:round}),bb.position.x=round,bb.position.z=round,bb.position.y=a-round,bb.rotation.z=-Math.PI/2;break;case"apl":bb=getextrude(gcad,getshape().fromrect(a-2*round,p-2*round).pt,l-2*round,[],mat,{round:round,stonda:round}),bb.position.x=round,bb.position.z=round,bb.position.y=round,bb.rotation.y=Math.PI/2,bb.rotation.z=Math.PI/2;break;case"pal":bb=getextrude(gcad,getshape().fromrect(p-2*round,a-2*round).pt,l-2*round,[],mat,{round:round,stonda:round}),bb.position.x=round,bb.position.z=p-round,bb.position.y=round,bb.rotation.y=Math.PI/2;break;case"pla":bb=getextrude(gcad,getshape().fromrect(p-2*round,l-2*round).pt,a-2*round,[],mat,{round:round,stonda:round}),bb.rotation.z=-Math.PI/2,bb.rotation.x=-Math.PI/2,bb.position.x=round,bb.position.z=round,bb.position.y=round;break;default:bb=getextrude(gcad,getshape().fromrect(l-2*round,p-2*round).pt,a-2*round,[],mat,{round:round,stonda:round}),bb.position.x=round,bb.position.z=round,bb.rotation.x=Math.PI/2,bb.position.y=a-round}return bb}function earcut(data,holeIndices,dim=2){const hasHoles=holeIndices&&holeIndices.length,outerLen=hasHoles?holeIndices[0]*dim:data.length;let outerNode=linkedList(data,0,outerLen,dim,!0);const triangles=[];if(!outerNode||outerNode.next===outerNode.prev)return triangles;let minX,minY,invSize;if(hasHoles&&(outerNode=function eliminateHoles(data,holeIndices,outerNode,dim){const queue=[];for(let i=0,len=holeIndices.length;i<len;i++){const list=linkedList(data,holeIndices[i]*dim,i<len-1?holeIndices[i+1]*dim:data.length,dim,!1);list===list.next&&(list.steiner=!0),queue.push(getLeftmost(list))}queue.sort(compareXYSlope);for(let i=0;i<queue.length;i++)outerNode=eliminateHole(queue[i],outerNode);return outerNode}(data,holeIndices,outerNode,dim)),data.length>80*dim){minX=1/0,minY=1/0;let maxX=-1/0,maxY=-1/0;for(let i=dim;i<outerLen;i+=dim){const x=data[i],y=data[i+1];x<minX&&(minX=x),y<minY&&(minY=y),x>maxX&&(maxX=x),y>maxY&&(maxY=y)}invSize=Math.max(maxX-minX,maxY-minY),invSize=0!==invSize?32767/invSize:0}return earcutLinked(outerNode,triangles,dim,minX,minY,invSize,0),triangles}function linkedList(data,start,end,dim,clockwise){let last;if(clockwise===function signedArea(data,start,end,dim){let sum=0;for(let i=start,j=end-dim;i<end;i+=dim)sum+=(data[j]-data[i])*(data[i+1]+data[j+1]),j=i;return sum}(data,start,end,dim)>0)for(let i=start;i<end;i+=dim)last=insertNode(i/dim|0,data[i],data[i+1],last);else for(let i=end-dim;i>=start;i-=dim)last=insertNode(i/dim|0,data[i],data[i+1],last);return last&&equals(last,last.next)&&(removeNode(last),last=last.next),last}function filterPoints(start,end){if(!start)return start;end||(end=start);let again,p=start;do{if(again=!1,p.steiner||!equals(p,p.next)&&0!==area(p.prev,p,p.next))p=p.next;else{if(removeNode(p),p=end=p.prev,p===p.next)break;again=!0}}while(again||p!==end);return end}function earcutLinked(ear,triangles,dim,minX,minY,invSize,pass){if(!ear)return;!pass&&invSize&&function indexCurve(start,minX,minY,invSize){let p=start;do{0===p.z&&(p.z=zOrder(p.x,p.y,minX,minY,invSize)),p.prevZ=p.prev,p.nextZ=p.next,p=p.next}while(p!==start);p.prevZ.nextZ=null,p.prevZ=null,function sortLinked(list){let numMerges,inSize=1;do{let e,p=list;list=null;let tail=null;for(numMerges=0;p;){numMerges++;let q=p,pSize=0;for(let i=0;i<inSize&&(pSize++,q=q.nextZ,q);i++);let qSize=inSize;for(;pSize>0||qSize>0&&q;)0!==pSize&&(0===qSize||!q||p.z<=q.z)?(e=p,p=p.nextZ,pSize--):(e=q,q=q.nextZ,qSize--),tail?tail.nextZ=e:list=e,e.prevZ=tail,tail=e;p=q}tail.nextZ=null,inSize*=2}while(numMerges>1);return list}(p)}(ear,minX,minY,invSize);let stop=ear;for(;ear.prev!==ear.next;){const prev=ear.prev,next=ear.next;if(invSize?isEarHashed(ear,minX,minY,invSize):isEar(ear))triangles.push(prev.i,ear.i,next.i),removeNode(ear),ear=next.next,stop=next.next;else if((ear=next)===stop){pass?1===pass?earcutLinked(ear=cureLocalIntersections(filterPoints(ear),triangles),triangles,dim,minX,minY,invSize,2):2===pass&&splitEarcut(ear,triangles,dim,minX,minY,invSize):earcutLinked(filterPoints(ear),triangles,dim,minX,minY,invSize,1);break}}}function isEar(ear){const a=ear.prev,b=ear,c=ear.next;if(area(a,b,c)>=0)return!1;const ax=a.x,bx=b.x,cx=c.x,ay=a.y,by=b.y,cy=c.y,x0=Math.min(ax,bx,cx),y0=Math.min(ay,by,cy),x1=Math.max(ax,bx,cx),y1=Math.max(ay,by,cy);let p=c.next;for(;p!==a;){if(p.x>=x0&&p.x<=x1&&p.y>=y0&&p.y<=y1&&pointInTriangleExceptFirst(ax,ay,bx,by,cx,cy,p.x,p.y)&&area(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function isEarHashed(ear,minX,minY,invSize){const a=ear.prev,b=ear,c=ear.next;if(area(a,b,c)>=0)return!1;const ax=a.x,bx=b.x,cx=c.x,ay=a.y,by=b.y,cy=c.y,x0=Math.min(ax,bx,cx),y0=Math.min(ay,by,cy),x1=Math.max(ax,bx,cx),y1=Math.max(ay,by,cy),minZ=zOrder(x0,y0,minX,minY,invSize),maxZ=zOrder(x1,y1,minX,minY,invSize);let p=ear.prevZ,n=ear.nextZ;for(;p&&p.z>=minZ&&n&&n.z<=maxZ;){if(p.x>=x0&&p.x<=x1&&p.y>=y0&&p.y<=y1&&p!==a&&p!==c&&pointInTriangleExceptFirst(ax,ay,bx,by,cx,cy,p.x,p.y)&&area(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,n.x>=x0&&n.x<=x1&&n.y>=y0&&n.y<=y1&&n!==a&&n!==c&&pointInTriangleExceptFirst(ax,ay,bx,by,cx,cy,n.x,n.y)&&area(n.prev,n,n.next)>=0)return!1;n=n.nextZ}for(;p&&p.z>=minZ;){if(p.x>=x0&&p.x<=x1&&p.y>=y0&&p.y<=y1&&p!==a&&p!==c&&pointInTriangleExceptFirst(ax,ay,bx,by,cx,cy,p.x,p.y)&&area(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;n&&n.z<=maxZ;){if(n.x>=x0&&n.x<=x1&&n.y>=y0&&n.y<=y1&&n!==a&&n!==c&&pointInTriangleExceptFirst(ax,ay,bx,by,cx,cy,n.x,n.y)&&area(n.prev,n,n.next)>=0)return!1;n=n.nextZ}return!0}function cureLocalIntersections(start,triangles){let p=start;do{const a=p.prev,b=p.next.next;!equals(a,b)&&intersects(a,p,p.next,b)&&locallyInside(a,b)&&locallyInside(b,a)&&(triangles.push(a.i,p.i,b.i),removeNode(p),removeNode(p.next),p=start=b),p=p.next}while(p!==start);return filterPoints(p)}function splitEarcut(start,triangles,dim,minX,minY,invSize){let a=start;do{let b=a.next.next;for(;b!==a.prev;){if(a.i!==b.i&&isValidDiagonal(a,b)){let c=splitPolygon(a,b);return a=filterPoints(a,a.next),c=filterPoints(c,c.next),earcutLinked(a,triangles,dim,minX,minY,invSize,0),void earcutLinked(c,triangles,dim,minX,minY,invSize,0)}b=b.next}a=a.next}while(a!==start)}function compareXYSlope(a,b){let result=a.x-b.x;if(0===result&&(result=a.y-b.y,0===result)){result=(a.next.y-a.y)/(a.next.x-a.x)-(b.next.y-b.y)/(b.next.x-b.x)}return result}function eliminateHole(hole,outerNode){const bridge=function findHoleBridge(hole,outerNode){let p=outerNode;const hx=hole.x,hy=hole.y;let m,qx=-1/0;if(equals(hole,p))return p;do{if(equals(hole,p.next))return p.next;if(hy<=p.y&&hy>=p.next.y&&p.next.y!==p.y){const x=p.x+(hy-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(x<=hx&&x>qx&&(qx=x,m=p.x<p.next.x?p:p.next,x===hx))return m}p=p.next}while(p!==outerNode);if(!m)return null;const stop=m,mx=m.x,my=m.y;let tanMin=1/0;p=m;do{if(hx>=p.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hy<my?hx:qx,hy,mx,my,hy<my?qx:hx,hy,p.x,p.y)){const tan=Math.abs(hy-p.y)/(hx-p.x);locallyInside(p,hole)&&(tan<tanMin||tan===tanMin&&(p.x>m.x||p.x===m.x&&sectorContainsSector(m,p)))&&(m=p,tanMin=tan)}p=p.next}while(p!==stop);return m}(hole,outerNode);if(!bridge)return outerNode;const bridgeReverse=splitPolygon(bridge,hole);return filterPoints(bridgeReverse,bridgeReverse.next),filterPoints(bridge,bridge.next)}function sectorContainsSector(m,p){return area(m.prev,m,p.prev)<0&&area(p.next,m,m.next)<0}function zOrder(x,y,minX,minY,invSize){return(x=1431655765&((x=858993459&((x=252645135&((x=16711935&((x=(x-minX)*invSize|0)|x<<8))|x<<4))|x<<2))|x<<1))|(y=1431655765&((y=858993459&((y=252645135&((y=16711935&((y=(y-minY)*invSize|0)|y<<8))|y<<4))|y<<2))|y<<1))<<1}function getLeftmost(start){let p=start,leftmost=start;do{(p.x<leftmost.x||p.x===leftmost.x&&p.y<leftmost.y)&&(leftmost=p),p=p.next}while(p!==start);return leftmost}function pointInTriangle(ax,ay,bx,by,cx,cy,px,py){return(cx-px)*(ay-py)>=(ax-px)*(cy-py)&&(ax-px)*(by-py)>=(bx-px)*(ay-py)&&(bx-px)*(cy-py)>=(cx-px)*(by-py)}function pointInTriangleExceptFirst(ax,ay,bx,by,cx,cy,px,py){return!(ax===px&&ay===py)&&pointInTriangle(ax,ay,bx,by,cx,cy,px,py)}function isValidDiagonal(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!function intersectsPolygon(a,b){let p=a;do{if(p.i!==a.i&&p.next.i!==a.i&&p.i!==b.i&&p.next.i!==b.i&&intersects(p,p.next,a,b))return!0;p=p.next}while(p!==a);return!1}(a,b)&&(locallyInside(a,b)&&locallyInside(b,a)&&function middleInside(a,b){let p=a,inside=!1;const px=(a.x+b.x)/2,py=(a.y+b.y)/2;do{p.y>py!=p.next.y>py&&p.next.y!==p.y&&px<(p.next.x-p.x)*(py-p.y)/(p.next.y-p.y)+p.x&&(inside=!inside),p=p.next}while(p!==a);return inside}(a,b)&&(area(a.prev,a,b.prev)||area(a,b.prev,b))||equals(a,b)&&area(a.prev,a,a.next)>0&&area(b.prev,b,b.next)>0)}function area(p,q,r){return(q.y-p.y)*(r.x-q.x)-(q.x-p.x)*(r.y-q.y)}function equals(p1,p2){return p1.x===p2.x&&p1.y===p2.y}function intersects(p1,q1,p2,q2){const o1=sign(area(p1,q1,p2)),o2=sign(area(p1,q1,q2)),o3=sign(area(p2,q2,p1)),o4=sign(area(p2,q2,q1));return o1!==o2&&o3!==o4||(!(0!==o1||!onSegment(p1,p2,q1))||(!(0!==o2||!onSegment(p1,q2,q1))||(!(0!==o3||!onSegment(p2,p1,q2))||!(0!==o4||!onSegment(p2,q1,q2)))))}function onSegment(p,q,r){return q.x<=Math.max(p.x,r.x)&&q.x>=Math.min(p.x,r.x)&&q.y<=Math.max(p.y,r.y)&&q.y>=Math.min(p.y,r.y)}function sign(num){return num>0?1:num<0?-1:0}function locallyInside(a,b){return area(a.prev,a,a.next)<0?area(a,b,a.next)>=0&&area(a,a.prev,b)>=0:area(a,b,a.prev)<0||area(a,a.next,b)<0}function splitPolygon(a,b){const a2=createNode(a.i,a.x,a.y),b2=createNode(b.i,b.x,b.y),an=a.next,bp=b.prev;return a.next=b,b.prev=a,a2.next=an,an.prev=a2,b2.next=a2,a2.prev=b2,bp.next=b2,b2.prev=bp,b2}function insertNode(i,x,y,last){const p=createNode(i,x,y);return last?(p.next=last.next,p.prev=last,last.next.prev=p,last.next=p):(p.prev=p,p.next=p),p}function removeNode(p){p.next.prev=p.prev,p.prev.next=p.next,p.prevZ&&(p.prevZ.nextZ=p.nextZ),p.nextZ&&(p.nextZ.prevZ=p.prevZ)}function createNode(i,x,y){return{i:i,x:x,y:y,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function unifyVertices(vertices,uvs,indices){const vertMap=new Map,verticesOut=[],uvsOut=[],indicesOut=[];for(let i=0;i<indices.length;i++){const idx=indices[i],vx=vertices[3*idx+0],vy=vertices[3*idx+1],vz=vertices[3*idx+2],ux=uvs[2*idx+0],uy=uvs[2*idx+1],key=`${vx},${vy},${vz}|${ux},${uy}`;if(vertMap.has(key))indicesOut.push(vertMap.get(key));else{const newIndex=verticesOut.length/3;vertMap.set(key,newIndex),verticesOut.push(vx,vy,vz),uvsOut.push(ux,uy),indicesOut.push(newIndex)}}return{vertices:verticesOut,uvs:uvsOut,indices:indicesOut}}function infoestrudi(shape,hshape,pts,options,sh){options||(options={}),pts||(pts=[]);let p0=options.p0||0,coeffbase1=Math.tan(options.coeffbase1*PIF||0),coeffbase2=Math.tan(options.coeffbase2*PIF||0),p1=hshape||options.p1||20,coefftop1=Math.tan(options.coefftop1*PIF||0),coefftop2=Math.tan(options.coefftop2*PIF||0),{mi:mi,ma:ma}=shape.pt.reduce(((t,e)=>(t.mi.x=Math.min(t.mi.x,e.x),t.mi.y=Math.min(t.mi.y,e.y),t.ma.x=Math.max(t.ma.x,e.x),t.ma.y=Math.max(t.ma.y,e.y),t)),{mi:{x:1e9,y:1e9},ma:{x:-1e9,y:-1e9}}),lmax=0,lmin=1e9;function getpars(p){p.z1=getzeta(p.x,p.y,p0,coeffbase1,coeffbase2,sh),p.z2=getzeta(p.x,p.y,p1,coefftop1,coefftop2,sh),p.l=Math.abs(p.z2-p.z1)}for(let p of pts)getpars(p);getpars(mi),getpars(ma);let rect=[{x:mi.x,y:mi.y},{x:ma.x,y:mi.y},{x:ma.x,y:ma.y},{x:mi.x,y:ma.y}];for(let r of rect)getpars(r),r.l>lmax&&(lmax=r.l),r.l<lmin&&(lmin=r.l);return{aini:options.coeffbase1||0,aini2:options.coeffbase2||0,afin:options.coefftop1||0,afin2:options.coefftop2||0,pts:pts,mi:mi,ma:ma,rect:rect,dimx:ma.x-mi.x,dimy:ma.y-mi.y,lnom:p1-p0,lmax:lmax,lmin:lmin,lmed:(lmax+lmin)/2}}function getzeta(x,y,zbase,cx,cy,sh,invert=!1){let z=x*cx+y*cy+zbase;if(sh){let t=sh.xfromy(-y,0,!0);invert?z-=t:z=t}return z}function sidegeomfromshapes(gcad,ky,s1,s2,invert=!1,stonda=!1,fuvswap=!1){if(s1&&s2){if(s1.length!==s2.length)throw new Error("shapes with different length");if(s1.length<2)throw new Error("I percorsi devono contenere almeno due punti ciascuno.");if(!gcad.geo[ky]){const vertices=[],uvs=[],indices=[],np=s1.length,addpts=ss=>{for(const s of ss)vertices.push(s.x,s.y,s.z),fuvswap?uvs.push(s.v,s.u):uvs.push(s.u,s.v)},equalpos=(p1,p2)=>p1.x===p2.x&&p1.y===p2.y&&p1.z===p2.z,addindexquad=(i1,i2,i3,i4)=>{invert?indices.push(i1,i3,i2,i3,i4,i2):indices.push(i1,i2,i3,i3,i2,i4)};addpts(s1),addpts(s2);for(let i=0;i<np-1;i++){const j=i+1;equalpos(s1[i],s1[j])||addindexquad(i,j,i+np,j+np)}const geometry=new THREE.BufferGeometry;if(stonda){let tm=unifyVertices(vertices,uvs,indices);geometry.setAttribute("position",new THREE.Float32BufferAttribute(tm.vertices,3)),geometry.setAttribute("uv",new THREE.Float32BufferAttribute(tm.uvs,2)),geometry.setIndex(tm.indices)}else geometry.setAttribute("position",new THREE.Float32BufferAttribute(vertices,3)),geometry.setAttribute("uv",new THREE.Float32BufferAttribute(uvs,2)),geometry.setIndex(indices);geometry.computeVertexNormals(),gcad.geo[ky]=geometry}return gcad.geo[ky]}}function bottomgeomfromshape(gcad,inverti,outer,holes,c=0,a=0,b=0,shape=null,stonda=!1,fuvswap=!1){let ky=`bg:${c}|${a}${b}|${outer.key}|${inverti}|${shape?.key||""}|${fuvswap?1:0}`;for(let h of holes)ky=`${ky}|${h.key}`;if(ky=hash(ky),!gcad.geo[ky]){let triangles,pos=[],hl=[],cc=outer.pt.length;pos=outer.vec;const geometry=new THREE.BufferGeometry,vertices=[],uvs=[],indices=[];function addvertexes(triangles,pos){let i0=vertices.length/3;for(let i=0;i<triangles.length;i++){const index=triangles[i],x=pos[2*index],y=-pos[2*index+1],z=getzeta(x,y,c,a,b,shape,inverti);vertices.push(x,y,z),fuvswap?uvs.push(x,y):uvs.push(y,x)}for(let i=0;i<triangles.length;i+=3)inverti?indices.push(i+i0,i+i0+2,i+i0+1):indices.push(i+i0,i+i0+1,i+i0+2)}if(shape){let cl2=outer.sliceony(shape);for(let c of cl2){let x=c.flatMap((p=>[p.x,p.y]));addvertexes(earcut(x,[]),x)}}else if(Array.isArray(holes)&&holes.length){for(let h of holes)hl.push(cc),cc+=h.pt.length,pos=[...pos,...h.vec];triangles=earcut(pos,hl),addvertexes(triangles,pos)}else triangles=earcut(pos),addvertexes(triangles,pos);if(stonda){let tm=unifyVertices(vertices,uvs,indices);geometry.setAttribute("position",new THREE.Float32BufferAttribute(tm.vertices,3)),geometry.setAttribute("uv",new THREE.Float32BufferAttribute(tm.uvs,2)),geometry.setIndex(tm.indices)}else geometry.setAttribute("position",new THREE.Float32BufferAttribute(vertices,3)),geometry.setAttribute("uv",new THREE.Float32BufferAttribute(uvs,2)),geometry.setIndex(indices);geometry.computeVertexNormals(),gcad.geo[ky]=geometry}return gcad.geo[ky]}function estrusorotate(orientamento,mesh,z=0){switch(orientamento.trim().toUpperCase().slice(0,1)){case"A":mesh.rotation.x=-Math.PI/2;break;case"L":mesh.rotation.y=Math.PI/2,mesh.rotation.z=Math.PI;break;case"P":mesh.rotation.z=Math.PI/2}return mesh}
648
- /**
649
- * Crea una geometria estrusa con opzioni avanzate
650
- * @param {string} orient - Orientamento dell'estrusione
651
- * @param {number} hshape - Altezza dell'estrusione
652
- * @param {Object} shape - Forma base
653
- * @param {Array} holes - Array di fori
654
- * @param {Array} mats - Array di materiali
655
- * @param {Object} options - Opzioni di configurazione
656
- * @returns {THREE.Group} Gruppo contenente la geometria estrusa
657
- */function estruso(gcad,orient,hshape,shape,holes,mats,options){options||(options={}),mats||(mats=[]),Array.isArray(mats)||(mats=[mats,mats,mats]);let p0=options.p0||0,coeffbase1=Math.tan(options.coeffbase1*PIF||0),coeffbase2=Math.tan(options.coeffbase2*PIF||0),p1=hshape||options.p1||20,coefftop1=Math.tan(options.coefftop1*PIF||0),coefftop2=Math.tan(options.coefftop2*PIF||0),shapetop=options.shapetop,shapebase=options.shapebase||options.shapebottom;shapetop&&(coefftop2=0),shapebase&&(coefftop2=0);let shb=shapebase?shapebase.key:"",sht=shapetop?shapetop.key:"",notopholes=options.notopholes||!1,nobottomholes=options.nobottomholes||options.nobaseholes||!1,opinvert=options.invert||!1,open=options.open||!1,grp=new THREE.Group;if(shape){if(!options.nobase){let h1=holes;nobottomholes&&(h1=Array.isArray(nobottomholes)?h1.filter(((_,i)=>!nobottomholes[i])):[]);let g1=bottomgeomfromshape(gcad,!0,shape,open?[]:h1,p0,coeffbase1,coeffbase2,shapebase,!1,options.uvswap);options.nolines||grp.add(edgesfromgeometry(g1)),grp.add(getmesh(g1,mats[0]||mwhite))}if(!options.notop){let h1=holes;notopholes&&(h1=Array.isArray(notopholes)?h1.filter(((_,i)=>!notopholes[i])):[]);let g3=bottomgeomfromshape(gcad,!1,shape,open?[]:h1,p1,coefftop1,coefftop2,shapetop,!1,options.uvswap);grp.add(getmesh(g3,mats[1]||mats[0]||mwhite)),options.nolines||grp.add(edgesfromgeometry(g3))}if(!options.nosides){let pat1=shape.to3d(0,p0,coeffbase1,-coeffbase2,open,shapebase,!opinvert),pat2=shape.to3d(1,p1,coefftop1,-coefftop2,open,shapetop,opinvert),ky=`${shape.key}${opinvert?1:0}|${p0}|${p1}|${coeffbase1}|${coeffbase2||shb}|${coefftop1}|${coefftop2||sht}|${open}|${options.wvswap?1:0}`,geo1=sidegeomfromshapes(gcad,ky,pat1,pat2,!1,!1,options.uvswap);if(options.nolines||options.nosidelines||grp.add(edgesfromgeometry(geo1)),grp.add(getmesh(geo1,mats[2]||mats[0]||mwhite)),holes&&!open)for(let i=0;i<holes.length;i++){let h=holes[i];if(Array.isArray(notopholes)){if(notopholes[i])continue}else if(notopholes)continue;if(Array.isArray(nobottomholes)){if(nobottomholes[i])continue}else if(nobottomholes)continue;pat1=h.to3d(0,p0,coeffbase1,coeffbase2),pat2=h.to3d(0,p1,coefftop1,coefftop2),ky=`${h.key}|${p0}|${p1}|${coeffbase1}|${coeffbase2}|${coefftop1}|${coefftop2}`;let geo2=sidegeomfromshapes(gcad,ky,pat1,pat2,!0);options.nolines||options.nosidelines||grp.add(edgesfromgeometry(geo2)),grp.add(getmesh(geo2,mats[3]||mats[0]||mwhite))}}return estrusorotate(orient,grp,hshape)}return grp}function revolve(gcad,shape,orient,mat,options){options||(options={});let segmenti=options.segmenti??12,ky=hash(`rev|${shape.key}|${orient}|${segmenti}`),geometria=gcad.geo[ky],grp=new THREE.Group;if(!geometria){const punti3D=shape.pt.map((p=>new THREE.Vector3(p.x,p.y,0)));geometria=new THREE.LatheGeometry(punti3D,segmenti,0,2*Math.PI),gcad.geo[ky]=geometria}options.uvswap&&uvswap(geometria);const mesh=new THREE.Mesh(geometria,mat);return grp.add(mesh),options.nolines||options.nosidelines||grp.add(edgesfromgeometry(geometria)),grp}function estrusopat(gcad,orient,pat,plink,shape,mats,options){options||(options={});let invert=options.invert;mats||(mats=[]);let open=options.open,closepat=options.closepat;if(!pat.pt?.length)return;let pbase=shape.to3d(0,0,0,0,open),grp=new THREE.Group;if(!options.nobase&&!options.open&&!closepat){let gb=new THREE.Group,angolo=angle3point(plink[0],pat.pt[0],pat.pt[1])+Math.PI/2,g1=bottomgeomfromshape(gcad,!1,shape,[],0,-Math.tan(angolo),0,null,!1,options.uvswap);gb.add(getmesh(g1,mats[0]||mwhite)),gb.add(edgesfromgeometry(g1));let seg1=pat.infosegmento(0,!0);grp.add(posiziona(gb,{sl:seg1.x,sp:seg1.y,sa:0,ay:90-seg1.ang}))}if(!options.notop&&!options.open&&!closepat){let gt=new THREE.Group,angolo=-(angle3point(pat.pt[pat.npt-2],pat.pt[pat.npt-1],plink[pat.npt-1])+Math.PI/2),g2=bottomgeomfromshape(gcad,!0,shape,[],0,-Math.tan(angolo),0,null,!1,options.uvswap);gt.add(getmesh(g2,mats[1]||mats[0]||mwhite)),gt.add(edgesfromgeometry(g2));let seg1=pat.infosegmento(pat.pt.length-1,!0);grp.add(posiziona(gt,{sl:seg1.x,sp:seg1.y,sa:0,ay:90-seg1.ang}))}const geo1=function sidegeomfrompat(gcad,pbase,pat,plink,closepat,invert){let ky=`bsg:${pbase.key}|${pat.key}|${closepat}|${invert}`;if(pat.npt==plink.length){if(ky=hash(ky),!gcad.geo[ky]){const vertices=[],uvs=[],indices=[],np=pbase.length,equalpos=(p1,p2)=>p1.x===p2.x&&p1.y===p2.y&&p1.z===p2.z;let l0=0,pt=pat.pt,ptl=pat.npt;const addpts=(ss,mat,deltav,coeffz)=>{for(const s of ss){let p=new THREE.Vector3(s.x,s.y,s.x*coeffz);p.applyMatrix4(mat),vertices.push(p.x,p.y,p.z),uvs.push(s.u,s.v+deltav)}};let lp=ptl;for(let ii=0;ii<ptl;ii++){let angolo;angolo=ii<ptl-1?angle3point(plink[ii],pt[ii],pt[ii+1])+Math.PI/2:-(angle3point(pt[ii-1],pt[ii],plink[ii])+Math.PI/2);let coefficente=-Math.tan(angolo),seg1=pat.infosegmento(ii,!0),obj=new THREE.Object3D;obj.position.set(seg1.x,0,seg1.y),obj.rotation.set(0,(90-seg1.ang)*PIF,0),obj.updateMatrix(),addpts(pbase,obj.matrix,l0,coefficente),l0+=seg1.l}if(closepat){let seg1=pat.infosegmento(0,!0),obj=new THREE.Object3D;obj.position.set(seg1.x,0,seg1.y),obj.rotation.set(0,(90-seg1.ang)*PIF,0);let angolo=angle3point(pt[ptl-1],pt[0],plink[0])+Math.PI/2,coefficente=-Math.tan(angolo);obj.updateMatrix(),addpts(pbase,obj.matrix,l0,coefficente),l0+=seg1.l,lp++}for(let li=0;li<lp-1;li++)for(let i=0;i<np-1;i++){const addindexquad=(i1,i2,i3,i4)=>{invert?indices.push(i1,i3,i2,i3,i4,i2):indices.push(i1,i2,i3,i3,i2,i4)},j=i+1;equalpos(pbase[i],pbase[j])||addindexquad(i+li*np,j+li*np,i+(li+1)*np,j+(li+1)*np)}const geometry=new THREE.BufferGeometry;geometry.setAttribute("position",new THREE.Float32BufferAttribute(vertices,3)),geometry.setAttribute("uv",new THREE.Float32BufferAttribute(uvs,2)),geometry.setIndex(indices),geometry.computeVertexNormals(),gcad[ky]=geometry}return gcad[ky]}}(gcad,pbase,pat,plink,closepat?1:0,invert?1:0,options.uvswap);return geo1&&(options.nolines||options.nosidelines||grp.add(edgesfromgeometry(geo1)),grp.add(getmesh(geo1,mats[2]||mats[0]||mwhite))),estrusorotate(orient,grp,0)}async function spritemat(gcad,file){try{let tm={transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1};if(file.startsWith("#"))tm.color=file;else{let tx=await gcad.tex(file,1e3,1e3);tx?tm.map=tx:tm.color="black"}return new THREE.SpriteMaterial(tm)}catch(error){return mwhite}}function getsprite0(ispunto,x,y,z,mat,options={}){options||(options={});let{size:size=50,pick:pick=!1,screen:screen=!1,sizex:sizex,sizey:sizey}=options;const sprite=new THREE.Sprite(mat);sprite.position.set(0,0,0),sprite.userData.issprite=!0,sprite.userData.ispunto=ispunto,sprite.userData.ispick=pick,sprite.userData.isScreen=screen,sprite.renderOrder=999,sprite.layers.set(29),sprite.name=ispunto?"_punto":"_sprite";let gr=new THREE.Group;return gr.position.set(x,y,z),gr.scale.set(sizex||size,sizey||sizex||size,1),gr.add(sprite),gr.traverse((obj=>{obj.material&&(obj.material.depthTest=!1,obj.material.depthWrite=!1)})),gr.renderOrder=999,gr}async function getpunto(gcad,x,y,z,color="yellow",options){options||(options={size:20}),options.screen=!0;const texture=await function createCircleTexture(gcad,size=64,color="rgba(255,0,0,1)"){const ky=`ct|${size}|${color}`;if(!gcad.textures[ky]){const canvas=document.createElement("canvas");canvas.width=canvas.height=size;const ctx=canvas.getContext("2d"),radius=size/2;ctx.clearRect(0,0,size,size),ctx.fillStyle=color,ctx.beginPath(),ctx.arc(radius,radius,radius,0,2*Math.PI),ctx.fill();const texture=new THREE.CanvasTexture(canvas);texture.needsUpdate=!0,gcad.textures[ky]=texture}return gcad.textures[ky]}(gcad,64,color);return getsprite0(!0,x,y,z,new THREE.SpriteMaterial({map:texture,transparent:!0,fog:!1,toneMapped:!1}),options)}function getsprite(gcad,x,y,z,mat,options={}){return getsprite0(!1,x,y,z,mat,options)}class GLTFLoader extends Loader{constructor(manager){super(manager),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(parser){return new GLTFMaterialsClearcoatExtension(parser)})),this.register((function(parser){return new GLTFMaterialsDispersionExtension(parser)})),this.register((function(parser){return new GLTFTextureBasisUExtension(parser)})),this.register((function(parser){return new GLTFTextureWebPExtension(parser)})),this.register((function(parser){return new GLTFTextureAVIFExtension(parser)})),this.register((function(parser){return new GLTFMaterialsSheenExtension(parser)})),this.register((function(parser){return new GLTFMaterialsTransmissionExtension(parser)})),this.register((function(parser){return new GLTFMaterialsVolumeExtension(parser)})),this.register((function(parser){return new GLTFMaterialsIorExtension(parser)})),this.register((function(parser){return new GLTFMaterialsEmissiveStrengthExtension(parser)})),this.register((function(parser){return new GLTFMaterialsSpecularExtension(parser)})),this.register((function(parser){return new GLTFMaterialsIridescenceExtension(parser)})),this.register((function(parser){return new GLTFMaterialsAnisotropyExtension(parser)})),this.register((function(parser){return new GLTFMaterialsBumpExtension(parser)})),this.register((function(parser){return new GLTFLightsExtension(parser)})),this.register((function(parser){return new GLTFMeshoptCompression(parser)})),this.register((function(parser){return new GLTFMeshGpuInstancing(parser)}))}load(url,onLoad,onProgress,onError){const scope=this;let resourcePath;if(""!==this.resourcePath)resourcePath=this.resourcePath;else if(""!==this.path){const relativeUrl=LoaderUtils.extractUrlBase(url);resourcePath=LoaderUtils.resolveURL(relativeUrl,this.path)}else resourcePath=LoaderUtils.extractUrlBase(url);this.manager.itemStart(url);const _onError=function(e){onError?onError(e):console.error(e),scope.manager.itemError(url),scope.manager.itemEnd(url)},loader=new FileLoader(this.manager);loader.setPath(this.path),loader.setResponseType("arraybuffer"),loader.setRequestHeader(this.requestHeader),loader.setWithCredentials(this.withCredentials),loader.load(url,(function(data){try{scope.parse(data,resourcePath,(function(gltf){onLoad(gltf),scope.manager.itemEnd(url)}),_onError)}catch(e){_onError(e)}}),onProgress,_onError)}setDRACOLoader(dracoLoader){return this.dracoLoader=dracoLoader,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(ktx2Loader){return this.ktx2Loader=ktx2Loader,this}setMeshoptDecoder(meshoptDecoder){return this.meshoptDecoder=meshoptDecoder,this}register(callback){return-1===this.pluginCallbacks.indexOf(callback)&&this.pluginCallbacks.push(callback),this}unregister(callback){return-1!==this.pluginCallbacks.indexOf(callback)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(callback),1),this}parse(data,path,onLoad,onError){let json;const extensions={},plugins={},textDecoder=new TextDecoder;if("string"==typeof data)json=JSON.parse(data);else if(data instanceof ArrayBuffer){if(textDecoder.decode(new Uint8Array(data,0,4))===BINARY_EXTENSION_HEADER_MAGIC){try{extensions[EXTENSIONS.KHR_BINARY_GLTF]=new GLTFBinaryExtension(data)}catch(error){return void(onError&&onError(error))}json=JSON.parse(extensions[EXTENSIONS.KHR_BINARY_GLTF].content)}else json=JSON.parse(textDecoder.decode(data))}else json=data;if(void 0===json.asset||json.asset.version[0]<2)return void(onError&&onError(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const parser=new GLTFParser(json,{path:path||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});parser.fileLoader.setRequestHeader(this.requestHeader);for(let i=0;i<this.pluginCallbacks.length;i++){const plugin=this.pluginCallbacks[i](parser);plugin.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),plugins[plugin.name]=plugin,extensions[plugin.name]=!0}if(json.extensionsUsed)for(let i=0;i<json.extensionsUsed.length;++i){const extensionName=json.extensionsUsed[i],extensionsRequired=json.extensionsRequired||[];switch(extensionName){case EXTENSIONS.KHR_MATERIALS_UNLIT:extensions[extensionName]=new GLTFMaterialsUnlitExtension;break;case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:extensions[extensionName]=new GLTFDracoMeshCompressionExtension(json,this.dracoLoader);break;case EXTENSIONS.KHR_TEXTURE_TRANSFORM:extensions[extensionName]=new GLTFTextureTransformExtension;break;case EXTENSIONS.KHR_MESH_QUANTIZATION:extensions[extensionName]=new GLTFMeshQuantizationExtension;break;default:extensionsRequired.indexOf(extensionName)>=0&&void 0===plugins[extensionName]&&console.warn('THREE.GLTFLoader: Unknown extension "'+extensionName+'".')}}parser.setExtensions(extensions),parser.setPlugins(plugins),parser.parse(onLoad,onError)}parseAsync(data,path){const scope=this;return new Promise((function(resolve,reject){scope.parse(data,path,resolve,reject)}))}}function GLTFRegistry(){let objects={};return{get:function(key){return objects[key]},add:function(key,object){objects[key]=object},remove:function(key){delete objects[key]},removeAll:function(){objects={}}}}
658
- /*********************************/
659
- /********** EXTENSIONS ***********/
660
- /*********************************/const EXTENSIONS={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};
661
- /**
662
- * Punctual Lights Extension
663
- *
664
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual
665
- */class GLTFLightsExtension{constructor(parser){this.parser=parser,this.name=EXTENSIONS.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const parser=this.parser,nodeDefs=this.parser.json.nodes||[];for(let nodeIndex=0,nodeLength=nodeDefs.length;nodeIndex<nodeLength;nodeIndex++){const nodeDef=nodeDefs[nodeIndex];nodeDef.extensions&&nodeDef.extensions[this.name]&&void 0!==nodeDef.extensions[this.name].light&&parser._addNodeRef(this.cache,nodeDef.extensions[this.name].light)}}_loadLight(lightIndex){const parser=this.parser,cacheKey="light:"+lightIndex;let dependency=parser.cache.get(cacheKey);if(dependency)return dependency;const json=parser.json,lightDef=((json.extensions&&json.extensions[this.name]||{}).lights||[])[lightIndex];let lightNode;const color=new Color(16777215);void 0!==lightDef.color&&color.setRGB(lightDef.color[0],lightDef.color[1],lightDef.color[2],LinearSRGBColorSpace);const range=void 0!==lightDef.range?lightDef.range:0;switch(lightDef.type){case"directional":lightNode=new DirectionalLight(color),lightNode.target.position.set(0,0,-1),lightNode.add(lightNode.target);break;case"point":lightNode=new PointLight(color),lightNode.distance=range;break;case"spot":lightNode=new SpotLight(color),lightNode.distance=range,lightDef.spot=lightDef.spot||{},lightDef.spot.innerConeAngle=void 0!==lightDef.spot.innerConeAngle?lightDef.spot.innerConeAngle:0,lightDef.spot.outerConeAngle=void 0!==lightDef.spot.outerConeAngle?lightDef.spot.outerConeAngle:Math.PI/4,lightNode.angle=lightDef.spot.outerConeAngle,lightNode.penumbra=1-lightDef.spot.innerConeAngle/lightDef.spot.outerConeAngle,lightNode.target.position.set(0,0,-1),lightNode.add(lightNode.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+lightDef.type)}return lightNode.position.set(0,0,0),lightNode.decay=2,assignExtrasToUserData(lightNode,lightDef),void 0!==lightDef.intensity&&(lightNode.intensity=lightDef.intensity),lightNode.name=parser.createUniqueName(lightDef.name||"light_"+lightIndex),dependency=Promise.resolve(lightNode),parser.cache.add(cacheKey,dependency),dependency}getDependency(type,index){if("light"===type)return this._loadLight(index)}createNodeAttachment(nodeIndex){const self=this,parser=this.parser,nodeDef=parser.json.nodes[nodeIndex],lightIndex=(nodeDef.extensions&&nodeDef.extensions[this.name]||{}).light;return void 0===lightIndex?null:this._loadLight(lightIndex).then((function(light){return parser._getNodeRef(self.cache,lightIndex,light)}))}}
666
- /**
667
- * Unlit Materials Extension
668
- *
669
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit
670
- */class GLTFMaterialsUnlitExtension{constructor(){this.name=EXTENSIONS.KHR_MATERIALS_UNLIT}getMaterialType(){return MeshBasicMaterial}extendParams(materialParams,materialDef,parser){const pending=[];materialParams.color=new Color(1,1,1),materialParams.opacity=1;const metallicRoughness=materialDef.pbrMetallicRoughness;if(metallicRoughness){if(Array.isArray(metallicRoughness.baseColorFactor)){const array=metallicRoughness.baseColorFactor;materialParams.color.setRGB(array[0],array[1],array[2],LinearSRGBColorSpace),materialParams.opacity=array[3]}void 0!==metallicRoughness.baseColorTexture&&pending.push(parser.assignTexture(materialParams,"map",metallicRoughness.baseColorTexture,SRGBColorSpace))}return Promise.all(pending)}}
671
- /**
672
- * Materials Emissive Strength Extension
673
- *
674
- * Specification: https://github.com/KhronosGroup/glTF/blob/5768b3ce0ef32bc39cdf1bef10b948586635ead3/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md
675
- */class GLTFMaterialsEmissiveStrengthExtension{constructor(parser){this.parser=parser,this.name=EXTENSIONS.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(materialIndex,materialParams){const materialDef=this.parser.json.materials[materialIndex];if(!materialDef.extensions||!materialDef.extensions[this.name])return Promise.resolve();const emissiveStrength=materialDef.extensions[this.name].emissiveStrength;return void 0!==emissiveStrength&&(materialParams.emissiveIntensity=emissiveStrength),Promise.resolve()}}
676
- /**
677
- * Clearcoat Materials Extension
678
- *
679
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat
680
- */class GLTFMaterialsClearcoatExtension{constructor(parser){this.parser=parser,this.name=EXTENSIONS.KHR_MATERIALS_CLEARCOAT}getMaterialType(materialIndex){const materialDef=this.parser.json.materials[materialIndex];return materialDef.extensions&&materialDef.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(materialIndex,materialParams){const parser=this.parser,materialDef=parser.json.materials[materialIndex];if(!materialDef.extensions||!materialDef.extensions[this.name])return Promise.resolve();const pending=[],extension=materialDef.extensions[this.name];if(void 0!==extension.clearcoatFactor&&(materialParams.clearcoat=extension.clearcoatFactor),void 0!==extension.clearcoatTexture&&pending.push(parser.assignTexture(materialParams,"clearcoatMap",extension.clearcoatTexture)),void 0!==extension.clearcoatRoughnessFactor&&(materialParams.clearcoatRoughness=extension.clearcoatRoughnessFactor),void 0!==extension.clearcoatRoughnessTexture&&pending.push(parser.assignTexture(materialParams,"clearcoatRoughnessMap",extension.clearcoatRoughnessTexture)),void 0!==extension.clearcoatNormalTexture&&(pending.push(parser.assignTexture(materialParams,"clearcoatNormalMap",extension.clearcoatNormalTexture)),void 0!==extension.clearcoatNormalTexture.scale)){const scale=extension.clearcoatNormalTexture.scale;materialParams.clearcoatNormalScale=new Vector2(scale,scale)}return Promise.all(pending)}}
681
- /**
682
- * Materials dispersion Extension
683
- *
684
- * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_dispersion
685
- */class GLTFMaterialsDispersionExtension{constructor(parser){this.parser=parser,this.name=EXTENSIONS.KHR_MATERIALS_DISPERSION}getMaterialType(materialIndex){const materialDef=this.parser.json.materials[materialIndex];return materialDef.extensions&&materialDef.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(materialIndex,materialParams){const materialDef=this.parser.json.materials[materialIndex];if(!materialDef.extensions||!materialDef.extensions[this.name])return Promise.resolve();const extension=materialDef.extensions[this.name];return materialParams.dispersion=void 0!==extension.dispersion?extension.dispersion:0,Promise.resolve()}}
686
- /**
687
- * Iridescence Materials Extension
688
- *
689
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_iridescence
690
- */class GLTFMaterialsIridescenceExtension{constructor(parser){this.parser=parser,this.name=EXTENSIONS.KHR_MATERIALS_IRIDESCENCE}getMaterialType(materialIndex){const materialDef=this.parser.json.materials[materialIndex];return materialDef.extensions&&materialDef.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(materialIndex,materialParams){const parser=this.parser,materialDef=parser.json.materials[materialIndex];if(!materialDef.extensions||!materialDef.extensions[this.name])return Promise.resolve();const pending=[],extension=materialDef.extensions[this.name];return void 0!==extension.iridescenceFactor&&(materialParams.iridescence=extension.iridescenceFactor),void 0!==extension.iridescenceTexture&&pending.push(parser.assignTexture(materialParams,"iridescenceMap",extension.iridescenceTexture)),void 0!==extension.iridescenceIor&&(materialParams.iridescenceIOR=extension.iridescenceIor),void 0===materialParams.iridescenceThicknessRange&&(materialParams.iridescenceThicknessRange=[100,400]),void 0!==extension.iridescenceThicknessMinimum&&(materialParams.iridescenceThicknessRange[0]=extension.iridescenceThicknessMinimum),void 0!==extension.iridescenceThicknessMaximum&&(materialParams.iridescenceThicknessRange[1]=extension.iridescenceThicknessMaximum),void 0!==extension.iridescenceThicknessTexture&&pending.push(parser.assignTexture(materialParams,"iridescenceThicknessMap",extension.iridescenceThicknessTexture)),Promise.all(pending)}}
691
- /**
692
- * Sheen Materials Extension
693
- *
694
- * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_sheen
695
- */class GLTFMaterialsSheenExtension{constructor(parser){this.parser=parser,this.name=EXTENSIONS.KHR_MATERIALS_SHEEN}getMaterialType(materialIndex){const materialDef=this.parser.json.materials[materialIndex];return materialDef.extensions&&materialDef.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(materialIndex,materialParams){const parser=this.parser,materialDef=parser.json.materials[materialIndex];if(!materialDef.extensions||!materialDef.extensions[this.name])return Promise.resolve();const pending=[];materialParams.sheenColor=new Color(0,0,0),materialParams.sheenRoughness=0,materialParams.sheen=1;const extension=materialDef.extensions[this.name];if(void 0!==extension.sheenColorFactor){const colorFactor=extension.sheenColorFactor;materialParams.sheenColor.setRGB(colorFactor[0],colorFactor[1],colorFactor[2],LinearSRGBColorSpace)}return void 0!==extension.sheenRoughnessFactor&&(materialParams.sheenRoughness=extension.sheenRoughnessFactor),void 0!==extension.sheenColorTexture&&pending.push(parser.assignTexture(materialParams,"sheenColorMap",extension.sheenColorTexture,SRGBColorSpace)),void 0!==extension.sheenRoughnessTexture&&pending.push(parser.assignTexture(materialParams,"sheenRoughnessMap",extension.sheenRoughnessTexture)),Promise.all(pending)}}
696
- /**
697
- * Transmission Materials Extension
698
- *
699
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_transmission
700
- * Draft: https://github.com/KhronosGroup/glTF/pull/1698
701
- */class GLTFMaterialsTransmissionExtension{constructor(parser){this.parser=parser,this.name=EXTENSIONS.KHR_MATERIALS_TRANSMISSION}getMaterialType(materialIndex){const materialDef=this.parser.json.materials[materialIndex];return materialDef.extensions&&materialDef.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(materialIndex,materialParams){const parser=this.parser,materialDef=parser.json.materials[materialIndex];if(!materialDef.extensions||!materialDef.extensions[this.name])return Promise.resolve();const pending=[],extension=materialDef.extensions[this.name];return void 0!==extension.transmissionFactor&&(materialParams.transmission=extension.transmissionFactor),void 0!==extension.transmissionTexture&&pending.push(parser.assignTexture(materialParams,"transmissionMap",extension.transmissionTexture)),Promise.all(pending)}}
702
- /**
703
- * Materials Volume Extension
704
- *
705
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_volume
706
- */class GLTFMaterialsVolumeExtension{constructor(parser){this.parser=parser,this.name=EXTENSIONS.KHR_MATERIALS_VOLUME}getMaterialType(materialIndex){const materialDef=this.parser.json.materials[materialIndex];return materialDef.extensions&&materialDef.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(materialIndex,materialParams){const parser=this.parser,materialDef=parser.json.materials[materialIndex];if(!materialDef.extensions||!materialDef.extensions[this.name])return Promise.resolve();const pending=[],extension=materialDef.extensions[this.name];materialParams.thickness=void 0!==extension.thicknessFactor?extension.thicknessFactor:0,void 0!==extension.thicknessTexture&&pending.push(parser.assignTexture(materialParams,"thicknessMap",extension.thicknessTexture)),materialParams.attenuationDistance=extension.attenuationDistance||1/0;const colorArray=extension.attenuationColor||[1,1,1];return materialParams.attenuationColor=(new Color).setRGB(colorArray[0],colorArray[1],colorArray[2],LinearSRGBColorSpace),Promise.all(pending)}}
707
- /**
708
- * Materials ior Extension
709
- *
710
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_ior
711
- */class GLTFMaterialsIorExtension{constructor(parser){this.parser=parser,this.name=EXTENSIONS.KHR_MATERIALS_IOR}getMaterialType(materialIndex){const materialDef=this.parser.json.materials[materialIndex];return materialDef.extensions&&materialDef.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(materialIndex,materialParams){const materialDef=this.parser.json.materials[materialIndex];if(!materialDef.extensions||!materialDef.extensions[this.name])return Promise.resolve();const extension=materialDef.extensions[this.name];return materialParams.ior=void 0!==extension.ior?extension.ior:1.5,Promise.resolve()}}
712
- /**
713
- * Materials specular Extension
714
- *
715
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular
716
- */class GLTFMaterialsSpecularExtension{constructor(parser){this.parser=parser,this.name=EXTENSIONS.KHR_MATERIALS_SPECULAR}getMaterialType(materialIndex){const materialDef=this.parser.json.materials[materialIndex];return materialDef.extensions&&materialDef.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(materialIndex,materialParams){const parser=this.parser,materialDef=parser.json.materials[materialIndex];if(!materialDef.extensions||!materialDef.extensions[this.name])return Promise.resolve();const pending=[],extension=materialDef.extensions[this.name];materialParams.specularIntensity=void 0!==extension.specularFactor?extension.specularFactor:1,void 0!==extension.specularTexture&&pending.push(parser.assignTexture(materialParams,"specularIntensityMap",extension.specularTexture));const colorArray=extension.specularColorFactor||[1,1,1];return materialParams.specularColor=(new Color).setRGB(colorArray[0],colorArray[1],colorArray[2],LinearSRGBColorSpace),void 0!==extension.specularColorTexture&&pending.push(parser.assignTexture(materialParams,"specularColorMap",extension.specularColorTexture,SRGBColorSpace)),Promise.all(pending)}}
717
- /**
718
- * Materials bump Extension
719
- *
720
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/EXT_materials_bump
721
- */class GLTFMaterialsBumpExtension{constructor(parser){this.parser=parser,this.name=EXTENSIONS.EXT_MATERIALS_BUMP}getMaterialType(materialIndex){const materialDef=this.parser.json.materials[materialIndex];return materialDef.extensions&&materialDef.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(materialIndex,materialParams){const parser=this.parser,materialDef=parser.json.materials[materialIndex];if(!materialDef.extensions||!materialDef.extensions[this.name])return Promise.resolve();const pending=[],extension=materialDef.extensions[this.name];return materialParams.bumpScale=void 0!==extension.bumpFactor?extension.bumpFactor:1,void 0!==extension.bumpTexture&&pending.push(parser.assignTexture(materialParams,"bumpMap",extension.bumpTexture)),Promise.all(pending)}}
722
- /**
723
- * Materials anisotropy Extension
724
- *
725
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_anisotropy
726
- */class GLTFMaterialsAnisotropyExtension{constructor(parser){this.parser=parser,this.name=EXTENSIONS.KHR_MATERIALS_ANISOTROPY}getMaterialType(materialIndex){const materialDef=this.parser.json.materials[materialIndex];return materialDef.extensions&&materialDef.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(materialIndex,materialParams){const parser=this.parser,materialDef=parser.json.materials[materialIndex];if(!materialDef.extensions||!materialDef.extensions[this.name])return Promise.resolve();const pending=[],extension=materialDef.extensions[this.name];return void 0!==extension.anisotropyStrength&&(materialParams.anisotropy=extension.anisotropyStrength),void 0!==extension.anisotropyRotation&&(materialParams.anisotropyRotation=extension.anisotropyRotation),void 0!==extension.anisotropyTexture&&pending.push(parser.assignTexture(materialParams,"anisotropyMap",extension.anisotropyTexture)),Promise.all(pending)}}
727
- /**
728
- * BasisU Texture Extension
729
- *
730
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_basisu
731
- */class GLTFTextureBasisUExtension{constructor(parser){this.parser=parser,this.name=EXTENSIONS.KHR_TEXTURE_BASISU}loadTexture(textureIndex){const parser=this.parser,json=parser.json,textureDef=json.textures[textureIndex];if(!textureDef.extensions||!textureDef.extensions[this.name])return null;const extension=textureDef.extensions[this.name],loader=parser.options.ktx2Loader;if(!loader){if(json.extensionsRequired&&json.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return parser.loadTextureImage(textureIndex,extension.source,loader)}}
732
- /**
733
- * WebP Texture Extension
734
- *
735
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_webp
736
- */class GLTFTextureWebPExtension{constructor(parser){this.parser=parser,this.name=EXTENSIONS.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(textureIndex){const name=this.name,parser=this.parser,json=parser.json,textureDef=json.textures[textureIndex];if(!textureDef.extensions||!textureDef.extensions[name])return null;const extension=textureDef.extensions[name],source=json.images[extension.source];let loader=parser.textureLoader;if(source.uri){const handler=parser.options.manager.getHandler(source.uri);null!==handler&&(loader=handler)}return this.detectSupport().then((function(isSupported){if(isSupported)return parser.loadTextureImage(textureIndex,extension.source,loader);if(json.extensionsRequired&&json.extensionsRequired.indexOf(name)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return parser.loadTexture(textureIndex)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(resolve){const image=new Image;image.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",image.onload=image.onerror=function(){resolve(1===image.height)}}))),this.isSupported}}
737
- /**
738
- * AVIF Texture Extension
739
- *
740
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_avif
741
- */class GLTFTextureAVIFExtension{constructor(parser){this.parser=parser,this.name=EXTENSIONS.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(textureIndex){const name=this.name,parser=this.parser,json=parser.json,textureDef=json.textures[textureIndex];if(!textureDef.extensions||!textureDef.extensions[name])return null;const extension=textureDef.extensions[name],source=json.images[extension.source];let loader=parser.textureLoader;if(source.uri){const handler=parser.options.manager.getHandler(source.uri);null!==handler&&(loader=handler)}return this.detectSupport().then((function(isSupported){if(isSupported)return parser.loadTextureImage(textureIndex,extension.source,loader);if(json.extensionsRequired&&json.extensionsRequired.indexOf(name)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return parser.loadTexture(textureIndex)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(resolve){const image=new Image;image.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",image.onload=image.onerror=function(){resolve(1===image.height)}}))),this.isSupported}}
742
- /**
743
- * meshopt BufferView Compression Extension
744
- *
745
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression
746
- */class GLTFMeshoptCompression{constructor(parser){this.name=EXTENSIONS.EXT_MESHOPT_COMPRESSION,this.parser=parser}loadBufferView(index){const json=this.parser.json,bufferView=json.bufferViews[index];if(bufferView.extensions&&bufferView.extensions[this.name]){const extensionDef=bufferView.extensions[this.name],buffer=this.parser.getDependency("buffer",extensionDef.buffer),decoder=this.parser.options.meshoptDecoder;if(!decoder||!decoder.supported){if(json.extensionsRequired&&json.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return buffer.then((function(res){const byteOffset=extensionDef.byteOffset||0,byteLength=extensionDef.byteLength||0,count=extensionDef.count,stride=extensionDef.byteStride,source=new Uint8Array(res,byteOffset,byteLength);return decoder.decodeGltfBufferAsync?decoder.decodeGltfBufferAsync(count,stride,source,extensionDef.mode,extensionDef.filter).then((function(res){return res.buffer})):decoder.ready.then((function(){const result=new ArrayBuffer(count*stride);return decoder.decodeGltfBuffer(new Uint8Array(result),count,stride,source,extensionDef.mode,extensionDef.filter),result}))}))}return null}}
747
- /**
748
- * GPU Instancing Extension
749
- *
750
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_mesh_gpu_instancing
751
- *
752
- */class GLTFMeshGpuInstancing{constructor(parser){this.name=EXTENSIONS.EXT_MESH_GPU_INSTANCING,this.parser=parser}createNodeMesh(nodeIndex){const json=this.parser.json,nodeDef=json.nodes[nodeIndex];if(!nodeDef.extensions||!nodeDef.extensions[this.name]||void 0===nodeDef.mesh)return null;const meshDef=json.meshes[nodeDef.mesh];for(const primitive of meshDef.primitives)if(primitive.mode!==WEBGL_CONSTANTS.TRIANGLES&&primitive.mode!==WEBGL_CONSTANTS.TRIANGLE_STRIP&&primitive.mode!==WEBGL_CONSTANTS.TRIANGLE_FAN&&void 0!==primitive.mode)return null;const attributesDef=nodeDef.extensions[this.name].attributes,pending=[],attributes={};for(const key in attributesDef)pending.push(this.parser.getDependency("accessor",attributesDef[key]).then((accessor=>(attributes[key]=accessor,attributes[key]))));return pending.length<1?null:(pending.push(this.parser.createNodeMesh(nodeIndex)),Promise.all(pending).then((results=>{const nodeObject=results.pop(),meshes=nodeObject.isGroup?nodeObject.children:[nodeObject],count=results[0].count,instancedMeshes=[];for(const mesh of meshes){const m=new Matrix4,p=new Vector3,q=new Quaternion,s=new Vector3(1,1,1),instancedMesh=new InstancedMesh(mesh.geometry,mesh.material,count);for(let i=0;i<count;i++)attributes.TRANSLATION&&p.fromBufferAttribute(attributes.TRANSLATION,i),attributes.ROTATION&&q.fromBufferAttribute(attributes.ROTATION,i),attributes.SCALE&&s.fromBufferAttribute(attributes.SCALE,i),instancedMesh.setMatrixAt(i,m.compose(p,q,s));for(const attributeName in attributes)if("_COLOR_0"===attributeName){const attr=attributes[attributeName];instancedMesh.instanceColor=new InstancedBufferAttribute(attr.array,attr.itemSize,attr.normalized)}else"TRANSLATION"!==attributeName&&"ROTATION"!==attributeName&&"SCALE"!==attributeName&&mesh.geometry.setAttribute(attributeName,attributes[attributeName]);Object3D.prototype.copy.call(instancedMesh,mesh),this.parser.assignFinalMaterial(instancedMesh),instancedMeshes.push(instancedMesh)}return nodeObject.isGroup?(nodeObject.clear(),nodeObject.add(...instancedMeshes),nodeObject):instancedMeshes[0]})))}}const BINARY_EXTENSION_HEADER_MAGIC="glTF",BINARY_EXTENSION_CHUNK_TYPES_JSON=1313821514,BINARY_EXTENSION_CHUNK_TYPES_BIN=5130562;class GLTFBinaryExtension{constructor(data){this.name=EXTENSIONS.KHR_BINARY_GLTF,this.content=null,this.body=null;const headerView=new DataView(data,0,12),textDecoder=new TextDecoder;if(this.header={magic:textDecoder.decode(new Uint8Array(data.slice(0,4))),version:headerView.getUint32(4,!0),length:headerView.getUint32(8,!0)},this.header.magic!==BINARY_EXTENSION_HEADER_MAGIC)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const chunkContentsLength=this.header.length-12,chunkView=new DataView(data,12);let chunkIndex=0;for(;chunkIndex<chunkContentsLength;){const chunkLength=chunkView.getUint32(chunkIndex,!0);chunkIndex+=4;const chunkType=chunkView.getUint32(chunkIndex,!0);if(chunkIndex+=4,chunkType===BINARY_EXTENSION_CHUNK_TYPES_JSON){const contentArray=new Uint8Array(data,12+chunkIndex,chunkLength);this.content=textDecoder.decode(contentArray)}else if(chunkType===BINARY_EXTENSION_CHUNK_TYPES_BIN){const byteOffset=12+chunkIndex;this.body=data.slice(byteOffset,byteOffset+chunkLength)}chunkIndex+=chunkLength}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}
753
- /**
754
- * DRACO Mesh Compression Extension
755
- *
756
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression
757
- */class GLTFDracoMeshCompressionExtension{constructor(json,dracoLoader){if(!dracoLoader)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=EXTENSIONS.KHR_DRACO_MESH_COMPRESSION,this.json=json,this.dracoLoader=dracoLoader,this.dracoLoader.preload()}decodePrimitive(primitive,parser){const json=this.json,dracoLoader=this.dracoLoader,bufferViewIndex=primitive.extensions[this.name].bufferView,gltfAttributeMap=primitive.extensions[this.name].attributes,threeAttributeMap={},attributeNormalizedMap={},attributeTypeMap={};for(const attributeName in gltfAttributeMap){const threeAttributeName=ATTRIBUTES[attributeName]||attributeName.toLowerCase();threeAttributeMap[threeAttributeName]=gltfAttributeMap[attributeName]}for(const attributeName in primitive.attributes){const threeAttributeName=ATTRIBUTES[attributeName]||attributeName.toLowerCase();if(void 0!==gltfAttributeMap[attributeName]){const accessorDef=json.accessors[primitive.attributes[attributeName]],componentType=WEBGL_COMPONENT_TYPES[accessorDef.componentType];attributeTypeMap[threeAttributeName]=componentType.name,attributeNormalizedMap[threeAttributeName]=!0===accessorDef.normalized}}return parser.getDependency("bufferView",bufferViewIndex).then((function(bufferView){return new Promise((function(resolve,reject){dracoLoader.decodeDracoFile(bufferView,(function(geometry){for(const attributeName in geometry.attributes){const attribute=geometry.attributes[attributeName],normalized=attributeNormalizedMap[attributeName];void 0!==normalized&&(attribute.normalized=normalized)}resolve(geometry)}),threeAttributeMap,attributeTypeMap,LinearSRGBColorSpace,reject)}))}))}}
758
- /**
759
- * Texture Transform Extension
760
- *
761
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform
762
- */class GLTFTextureTransformExtension{constructor(){this.name=EXTENSIONS.KHR_TEXTURE_TRANSFORM}extendTexture(texture,transform){return void 0!==transform.texCoord&&transform.texCoord!==texture.channel||void 0!==transform.offset||void 0!==transform.rotation||void 0!==transform.scale?(texture=texture.clone(),void 0!==transform.texCoord&&(texture.channel=transform.texCoord),void 0!==transform.offset&&texture.offset.fromArray(transform.offset),void 0!==transform.rotation&&(texture.rotation=transform.rotation),void 0!==transform.scale&&texture.repeat.fromArray(transform.scale),texture.needsUpdate=!0,texture):texture}}
763
- /**
764
- * Mesh Quantization Extension
765
- *
766
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization
767
- */class GLTFMeshQuantizationExtension{constructor(){this.name=EXTENSIONS.KHR_MESH_QUANTIZATION}}
768
- /*********************************/
769
- /********** INTERPOLATION ********/
770
- /*********************************/class GLTFCubicSplineInterpolant extends Interpolant{constructor(parameterPositions,sampleValues,sampleSize,resultBuffer){super(parameterPositions,sampleValues,sampleSize,resultBuffer)}copySampleValue_(index){const result=this.resultBuffer,values=this.sampleValues,valueSize=this.valueSize,offset=index*valueSize*3+valueSize;for(let i=0;i!==valueSize;i++)result[i]=values[offset+i];return result}interpolate_(i1,t0,t,t1){const result=this.resultBuffer,values=this.sampleValues,stride=this.valueSize,stride2=2*stride,stride3=3*stride,td=t1-t0,p=(t-t0)/td,pp=p*p,ppp=pp*p,offset1=i1*stride3,offset0=offset1-stride3,s2=-2*ppp+3*pp,s3=ppp-pp,s0=1-s2,s1=s3-pp+p;for(let i=0;i!==stride;i++){const p0=values[offset0+i+stride],m0=values[offset0+i+stride2]*td,p1=values[offset1+i+stride],m1=values[offset1+i]*td;result[i]=s0*p0+s1*m0+s2*p1+s3*m1}return result}}const _q=new Quaternion;class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant{interpolate_(i1,t0,t,t1){const result=super.interpolate_(i1,t0,t,t1);return _q.fromArray(result).normalize().toArray(result),result}}
771
- /*********************************/
772
- /********** INTERNALS ************/
773
- /*********************************/const WEBGL_CONSTANTS={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},WEBGL_COMPONENT_TYPES={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},WEBGL_FILTERS={9728:NearestFilter,9729:LinearFilter,9984:NearestMipmapNearestFilter,9985:LinearMipmapNearestFilter,9986:NearestMipmapLinearFilter,9987:LinearMipmapLinearFilter},WEBGL_WRAPPINGS={33071:ClampToEdgeWrapping,33648:MirroredRepeatWrapping,10497:RepeatWrapping},WEBGL_TYPE_SIZES={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ATTRIBUTES={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},PATH_PROPERTIES={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},INTERPOLATION={CUBICSPLINE:void 0,LINEAR:InterpolateLinear,STEP:InterpolateDiscrete},ALPHA_MODES_OPAQUE="OPAQUE",ALPHA_MODES_MASK="MASK",ALPHA_MODES_BLEND="BLEND";function addUnknownExtensionsToUserData(knownExtensions,object,objectDef){for(const name in objectDef.extensions)void 0===knownExtensions[name]&&(object.userData.gltfExtensions=object.userData.gltfExtensions||{},object.userData.gltfExtensions[name]=objectDef.extensions[name])}
774
- /**
775
- * @param {Object3D|Material|BufferGeometry} object
776
- * @param {GLTF.definition} gltfDef
777
- */function assignExtrasToUserData(object,gltfDef){void 0!==gltfDef.extras&&("object"==typeof gltfDef.extras?Object.assign(object.userData,gltfDef.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+gltfDef.extras))}
778
- /**
779
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets
780
- *
781
- * @param {BufferGeometry} geometry
782
- * @param {Array<GLTF.Target>} targets
783
- * @param {GLTFParser} parser
784
- * @return {Promise<BufferGeometry>}
785
- */
786
- /**
787
- * @param {Mesh} mesh
788
- * @param {GLTF.Mesh} meshDef
789
- */
790
- function updateMorphTargets(mesh,meshDef){if(mesh.updateMorphTargets(),void 0!==meshDef.weights)for(let i=0,il=meshDef.weights.length;i<il;i++)mesh.morphTargetInfluences[i]=meshDef.weights[i];if(meshDef.extras&&Array.isArray(meshDef.extras.targetNames)){const targetNames=meshDef.extras.targetNames;if(mesh.morphTargetInfluences.length===targetNames.length){mesh.morphTargetDictionary={};for(let i=0,il=targetNames.length;i<il;i++)mesh.morphTargetDictionary[targetNames[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function createPrimitiveKey(primitiveDef){let geometryKey;const dracoExtension=primitiveDef.extensions&&primitiveDef.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION];if(geometryKey=dracoExtension?"draco:"+dracoExtension.bufferView+":"+dracoExtension.indices+":"+createAttributesKey(dracoExtension.attributes):primitiveDef.indices+":"+createAttributesKey(primitiveDef.attributes)+":"+primitiveDef.mode,void 0!==primitiveDef.targets)for(let i=0,il=primitiveDef.targets.length;i<il;i++)geometryKey+=":"+createAttributesKey(primitiveDef.targets[i]);return geometryKey}function createAttributesKey(attributes){let attributesKey="";const keys=Object.keys(attributes).sort();for(let i=0,il=keys.length;i<il;i++)attributesKey+=keys[i]+":"+attributes[keys[i]]+";";return attributesKey}function getNormalizedComponentScale(constructor){switch(constructor){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const _identityMatrix=new Matrix4;class GLTFParser{constructor(json={},options={}){this.json=json,this.extensions={},this.plugins={},this.options=options,this.cache=new GLTFRegistry,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let isSafari=!1,safariVersion=-1,isFirefox=!1,firefoxVersion=-1;if("undefined"!=typeof navigator){const userAgent=navigator.userAgent;isSafari=!0===/^((?!chrome|android).)*safari/i.test(userAgent);const safariMatch=userAgent.match(/Version\/(\d+)/);safariVersion=isSafari&&safariMatch?parseInt(safariMatch[1],10):-1,isFirefox=userAgent.indexOf("Firefox")>-1,firefoxVersion=isFirefox?userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||isSafari&&safariVersion<17||isFirefox&&firefoxVersion<98?this.textureLoader=new TextureLoader(this.options.manager):this.textureLoader=new ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(extensions){this.extensions=extensions}setPlugins(plugins){this.plugins=plugins}parse(onLoad,onError){const parser=this,json=this.json,extensions=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(ext){return ext._markDefs&&ext._markDefs()})),Promise.all(this._invokeAll((function(ext){return ext.beforeRoot&&ext.beforeRoot()}))).then((function(){return Promise.all([parser.getDependencies("scene"),parser.getDependencies("animation"),parser.getDependencies("camera")])})).then((function(dependencies){const result={scene:dependencies[0][json.scene||0],scenes:dependencies[0],animations:dependencies[1],cameras:dependencies[2],asset:json.asset,parser:parser,userData:{}};return addUnknownExtensionsToUserData(extensions,result,json),assignExtrasToUserData(result,json),Promise.all(parser._invokeAll((function(ext){return ext.afterRoot&&ext.afterRoot(result)}))).then((function(){for(const scene of result.scenes)scene.updateMatrixWorld();onLoad(result)}))})).catch(onError)}
791
- /**
792
- * Marks the special nodes/meshes in json for efficient parse.
793
- */_markDefs(){const nodeDefs=this.json.nodes||[],skinDefs=this.json.skins||[],meshDefs=this.json.meshes||[];for(let skinIndex=0,skinLength=skinDefs.length;skinIndex<skinLength;skinIndex++){const joints=skinDefs[skinIndex].joints;for(let i=0,il=joints.length;i<il;i++)nodeDefs[joints[i]].isBone=!0}for(let nodeIndex=0,nodeLength=nodeDefs.length;nodeIndex<nodeLength;nodeIndex++){const nodeDef=nodeDefs[nodeIndex];void 0!==nodeDef.mesh&&(this._addNodeRef(this.meshCache,nodeDef.mesh),void 0!==nodeDef.skin&&(meshDefs[nodeDef.mesh].isSkinnedMesh=!0)),void 0!==nodeDef.camera&&this._addNodeRef(this.cameraCache,nodeDef.camera)}}
794
- /**
795
- * Counts references to shared node / Object3D resources. These resources
796
- * can be reused, or "instantiated", at multiple nodes in the scene
797
- * hierarchy. Mesh, Camera, and Light instances are instantiated and must
798
- * be marked. Non-scenegraph resources (like Materials, Geometries, and
799
- * Textures) can be reused directly and are not marked here.
800
- *
801
- * Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
802
- */_addNodeRef(cache,index){void 0!==index&&(void 0===cache.refs[index]&&(cache.refs[index]=cache.uses[index]=0),cache.refs[index]++)}
803
- /** Returns a reference to a shared resource, cloning it if necessary. */_getNodeRef(cache,index,object){if(cache.refs[index]<=1)return object;const ref=object.clone(),updateMappings=(original,clone)=>{const mappings=this.associations.get(original);null!=mappings&&this.associations.set(clone,mappings);for(const[i,child]of original.children.entries())updateMappings(child,clone.children[i])};return updateMappings(object,ref),ref.name+="_instance_"+cache.uses[index]++,ref}_invokeOne(func){const extensions=Object.values(this.plugins);extensions.push(this);for(let i=0;i<extensions.length;i++){const result=func(extensions[i]);if(result)return result}return null}_invokeAll(func){const extensions=Object.values(this.plugins);extensions.unshift(this);const pending=[];for(let i=0;i<extensions.length;i++){const result=func(extensions[i]);result&&pending.push(result)}return pending}
804
- /**
805
- * Requests the specified dependency asynchronously, with caching.
806
- * @param {string} type
807
- * @param {number} index
808
- * @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
809
- */getDependency(type,index){const cacheKey=type+":"+index;let dependency=this.cache.get(cacheKey);if(!dependency){switch(type){case"scene":dependency=this.loadScene(index);break;case"node":dependency=this._invokeOne((function(ext){return ext.loadNode&&ext.loadNode(index)}));break;case"mesh":dependency=this._invokeOne((function(ext){return ext.loadMesh&&ext.loadMesh(index)}));break;case"accessor":dependency=this.loadAccessor(index);break;case"bufferView":dependency=this._invokeOne((function(ext){return ext.loadBufferView&&ext.loadBufferView(index)}));break;case"buffer":dependency=this.loadBuffer(index);break;case"material":dependency=this._invokeOne((function(ext){return ext.loadMaterial&&ext.loadMaterial(index)}));break;case"texture":dependency=this._invokeOne((function(ext){return ext.loadTexture&&ext.loadTexture(index)}));break;case"skin":dependency=this.loadSkin(index);break;case"animation":dependency=this._invokeOne((function(ext){return ext.loadAnimation&&ext.loadAnimation(index)}));break;case"camera":dependency=this.loadCamera(index);break;default:if(dependency=this._invokeOne((function(ext){return ext!=this&&ext.getDependency&&ext.getDependency(type,index)})),!dependency)throw new Error("Unknown type: "+type)}this.cache.add(cacheKey,dependency)}return dependency}
810
- /**
811
- * Requests all dependencies of the specified type asynchronously, with caching.
812
- * @param {string} type
813
- * @return {Promise<Array<Object>>}
814
- */getDependencies(type){let dependencies=this.cache.get(type);if(!dependencies){const parser=this,defs=this.json[type+("mesh"===type?"es":"s")]||[];dependencies=Promise.all(defs.map((function(def,index){return parser.getDependency(type,index)}))),this.cache.add(type,dependencies)}return dependencies}
815
- /**
816
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
817
- * @param {number} bufferIndex
818
- * @return {Promise<ArrayBuffer>}
819
- */loadBuffer(bufferIndex){const bufferDef=this.json.buffers[bufferIndex],loader=this.fileLoader;if(bufferDef.type&&"arraybuffer"!==bufferDef.type)throw new Error("THREE.GLTFLoader: "+bufferDef.type+" buffer type is not supported.");if(void 0===bufferDef.uri&&0===bufferIndex)return Promise.resolve(this.extensions[EXTENSIONS.KHR_BINARY_GLTF].body);const options=this.options;return new Promise((function(resolve,reject){loader.load(LoaderUtils.resolveURL(bufferDef.uri,options.path),resolve,void 0,(function(){reject(new Error('THREE.GLTFLoader: Failed to load buffer "'+bufferDef.uri+'".'))}))}))}
820
- /**
821
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
822
- * @param {number} bufferViewIndex
823
- * @return {Promise<ArrayBuffer>}
824
- */loadBufferView(bufferViewIndex){const bufferViewDef=this.json.bufferViews[bufferViewIndex];return this.getDependency("buffer",bufferViewDef.buffer).then((function(buffer){const byteLength=bufferViewDef.byteLength||0,byteOffset=bufferViewDef.byteOffset||0;return buffer.slice(byteOffset,byteOffset+byteLength)}))}
825
- /**
826
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
827
- * @param {number} accessorIndex
828
- * @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
829
- */loadAccessor(accessorIndex){const parser=this,json=this.json,accessorDef=this.json.accessors[accessorIndex];if(void 0===accessorDef.bufferView&&void 0===accessorDef.sparse){const itemSize=WEBGL_TYPE_SIZES[accessorDef.type],TypedArray=WEBGL_COMPONENT_TYPES[accessorDef.componentType],normalized=!0===accessorDef.normalized,array=new TypedArray(accessorDef.count*itemSize);return Promise.resolve(new BufferAttribute(array,itemSize,normalized))}const pendingBufferViews=[];return void 0!==accessorDef.bufferView?pendingBufferViews.push(this.getDependency("bufferView",accessorDef.bufferView)):pendingBufferViews.push(null),void 0!==accessorDef.sparse&&(pendingBufferViews.push(this.getDependency("bufferView",accessorDef.sparse.indices.bufferView)),pendingBufferViews.push(this.getDependency("bufferView",accessorDef.sparse.values.bufferView))),Promise.all(pendingBufferViews).then((function(bufferViews){const bufferView=bufferViews[0],itemSize=WEBGL_TYPE_SIZES[accessorDef.type],TypedArray=WEBGL_COMPONENT_TYPES[accessorDef.componentType],elementBytes=TypedArray.BYTES_PER_ELEMENT,itemBytes=elementBytes*itemSize,byteOffset=accessorDef.byteOffset||0,byteStride=void 0!==accessorDef.bufferView?json.bufferViews[accessorDef.bufferView].byteStride:void 0,normalized=!0===accessorDef.normalized;let array,bufferAttribute;if(byteStride&&byteStride!==itemBytes){const ibSlice=Math.floor(byteOffset/byteStride),ibCacheKey="InterleavedBuffer:"+accessorDef.bufferView+":"+accessorDef.componentType+":"+ibSlice+":"+accessorDef.count;let ib=parser.cache.get(ibCacheKey);ib||(array=new TypedArray(bufferView,ibSlice*byteStride,accessorDef.count*byteStride/elementBytes),ib=new InterleavedBuffer(array,byteStride/elementBytes),parser.cache.add(ibCacheKey,ib)),bufferAttribute=new InterleavedBufferAttribute(ib,itemSize,byteOffset%byteStride/elementBytes,normalized)}else array=null===bufferView?new TypedArray(accessorDef.count*itemSize):new TypedArray(bufferView,byteOffset,accessorDef.count*itemSize),bufferAttribute=new BufferAttribute(array,itemSize,normalized);if(void 0!==accessorDef.sparse){const itemSizeIndices=WEBGL_TYPE_SIZES.SCALAR,TypedArrayIndices=WEBGL_COMPONENT_TYPES[accessorDef.sparse.indices.componentType],byteOffsetIndices=accessorDef.sparse.indices.byteOffset||0,byteOffsetValues=accessorDef.sparse.values.byteOffset||0,sparseIndices=new TypedArrayIndices(bufferViews[1],byteOffsetIndices,accessorDef.sparse.count*itemSizeIndices),sparseValues=new TypedArray(bufferViews[2],byteOffsetValues,accessorDef.sparse.count*itemSize);null!==bufferView&&(bufferAttribute=new BufferAttribute(bufferAttribute.array.slice(),bufferAttribute.itemSize,bufferAttribute.normalized));for(let i=0,il=sparseIndices.length;i<il;i++){const index=sparseIndices[i];if(bufferAttribute.setX(index,sparseValues[i*itemSize]),itemSize>=2&&bufferAttribute.setY(index,sparseValues[i*itemSize+1]),itemSize>=3&&bufferAttribute.setZ(index,sparseValues[i*itemSize+2]),itemSize>=4&&bufferAttribute.setW(index,sparseValues[i*itemSize+3]),itemSize>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return bufferAttribute}))}
830
- /**
831
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
832
- * @param {number} textureIndex
833
- * @return {Promise<THREE.Texture|null>}
834
- */loadTexture(textureIndex){const json=this.json,options=this.options,sourceIndex=json.textures[textureIndex].source,sourceDef=json.images[sourceIndex];let loader=this.textureLoader;if(sourceDef.uri){const handler=options.manager.getHandler(sourceDef.uri);null!==handler&&(loader=handler)}return this.loadTextureImage(textureIndex,sourceIndex,loader)}loadTextureImage(textureIndex,sourceIndex,loader){const parser=this,json=this.json,textureDef=json.textures[textureIndex],sourceDef=json.images[sourceIndex],cacheKey=(sourceDef.uri||sourceDef.bufferView)+":"+textureDef.sampler;if(this.textureCache[cacheKey])return this.textureCache[cacheKey];const promise=this.loadImageSource(sourceIndex,loader).then((function(texture){texture.flipY=!1,texture.name=textureDef.name||sourceDef.name||"",""===texture.name&&"string"==typeof sourceDef.uri&&!1===sourceDef.uri.startsWith("data:image/")&&(texture.name=sourceDef.uri);const sampler=(json.samplers||{})[textureDef.sampler]||{};return texture.magFilter=WEBGL_FILTERS[sampler.magFilter]||LinearFilter,texture.minFilter=WEBGL_FILTERS[sampler.minFilter]||LinearMipmapLinearFilter,texture.wrapS=WEBGL_WRAPPINGS[sampler.wrapS]||RepeatWrapping,texture.wrapT=WEBGL_WRAPPINGS[sampler.wrapT]||RepeatWrapping,parser.associations.set(texture,{textures:textureIndex}),texture})).catch((function(){return null}));return this.textureCache[cacheKey]=promise,promise}loadImageSource(sourceIndex,loader){const parser=this,json=this.json,options=this.options;if(void 0!==this.sourceCache[sourceIndex])return this.sourceCache[sourceIndex].then((texture=>texture.clone()));const sourceDef=json.images[sourceIndex],URL=self.URL||self.webkitURL;let sourceURI=sourceDef.uri||"",isObjectURL=!1;if(void 0!==sourceDef.bufferView)sourceURI=parser.getDependency("bufferView",sourceDef.bufferView).then((function(bufferView){isObjectURL=!0;const blob=new Blob([bufferView],{type:sourceDef.mimeType});return sourceURI=URL.createObjectURL(blob),sourceURI}));else if(void 0===sourceDef.uri)throw new Error("THREE.GLTFLoader: Image "+sourceIndex+" is missing URI and bufferView");const promise=Promise.resolve(sourceURI).then((function(sourceURI){return new Promise((function(resolve,reject){let onLoad=resolve;!0===loader.isImageBitmapLoader&&(onLoad=function(imageBitmap){const texture=new Texture(imageBitmap);texture.needsUpdate=!0,resolve(texture)}),loader.load(LoaderUtils.resolveURL(sourceURI,options.path),onLoad,void 0,reject)}))})).then((function(texture){return!0===isObjectURL&&URL.revokeObjectURL(sourceURI),assignExtrasToUserData(texture,sourceDef),texture.userData.mimeType=sourceDef.mimeType||function getImageURIMimeType(uri){return uri.search(/\.jpe?g($|\?)/i)>0||0===uri.search(/^data\:image\/jpeg/)?"image/jpeg":uri.search(/\.webp($|\?)/i)>0||0===uri.search(/^data\:image\/webp/)?"image/webp":"image/png"}(sourceDef.uri),texture})).catch((function(error){throw console.error("THREE.GLTFLoader: Couldn't load texture",sourceURI),error}));return this.sourceCache[sourceIndex]=promise,promise}
835
- /**
836
- * Asynchronously assigns a texture to the given material parameters.
837
- * @param {Object} materialParams
838
- * @param {string} mapName
839
- * @param {Object} mapDef
840
- * @return {Promise<Texture>}
841
- */assignTexture(materialParams,mapName,mapDef,colorSpace){const parser=this;return this.getDependency("texture",mapDef.index).then((function(texture){if(!texture)return null;if(void 0!==mapDef.texCoord&&mapDef.texCoord>0&&((texture=texture.clone()).channel=mapDef.texCoord),parser.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]){const transform=void 0!==mapDef.extensions?mapDef.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]:void 0;if(transform){const gltfReference=parser.associations.get(texture);texture=parser.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM].extendTexture(texture,transform),parser.associations.set(texture,gltfReference)}}return void 0!==colorSpace&&(texture.colorSpace=colorSpace),materialParams[mapName]=texture,texture}))}
842
- /**
843
- * Assigns final material to a Mesh, Line, or Points instance. The instance
844
- * already has a material (generated from the glTF material options alone)
845
- * but reuse of the same glTF material may require multiple threejs materials
846
- * to accommodate different primitive types, defines, etc. New materials will
847
- * be created if necessary, and reused from a cache.
848
- * @param {Object3D} mesh Mesh, Line, or Points instance.
849
- */assignFinalMaterial(mesh){const geometry=mesh.geometry;let material=mesh.material;const useDerivativeTangents=void 0===geometry.attributes.tangent,useVertexColors=void 0!==geometry.attributes.color,useFlatShading=void 0===geometry.attributes.normal;if(mesh.isPoints){const cacheKey="PointsMaterial:"+material.uuid;let pointsMaterial=this.cache.get(cacheKey);pointsMaterial||(pointsMaterial=new PointsMaterial,Material.prototype.copy.call(pointsMaterial,material),pointsMaterial.color.copy(material.color),pointsMaterial.map=material.map,pointsMaterial.sizeAttenuation=!1,this.cache.add(cacheKey,pointsMaterial)),material=pointsMaterial}else if(mesh.isLine){const cacheKey="LineBasicMaterial:"+material.uuid;let lineMaterial=this.cache.get(cacheKey);lineMaterial||(lineMaterial=new LineBasicMaterial,Material.prototype.copy.call(lineMaterial,material),lineMaterial.color.copy(material.color),lineMaterial.map=material.map,this.cache.add(cacheKey,lineMaterial)),material=lineMaterial}if(useDerivativeTangents||useVertexColors||useFlatShading){let cacheKey="ClonedMaterial:"+material.uuid+":";useDerivativeTangents&&(cacheKey+="derivative-tangents:"),useVertexColors&&(cacheKey+="vertex-colors:"),useFlatShading&&(cacheKey+="flat-shading:");let cachedMaterial=this.cache.get(cacheKey);cachedMaterial||(cachedMaterial=material.clone(),useVertexColors&&(cachedMaterial.vertexColors=!0),useFlatShading&&(cachedMaterial.flatShading=!0),useDerivativeTangents&&(cachedMaterial.normalScale&&(cachedMaterial.normalScale.y*=-1),cachedMaterial.clearcoatNormalScale&&(cachedMaterial.clearcoatNormalScale.y*=-1)),this.cache.add(cacheKey,cachedMaterial),this.associations.set(cachedMaterial,this.associations.get(material))),material=cachedMaterial}mesh.material=material}getMaterialType(){return MeshStandardMaterial}
850
- /**
851
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
852
- * @param {number} materialIndex
853
- * @return {Promise<Material>}
854
- */loadMaterial(materialIndex){const parser=this,json=this.json,extensions=this.extensions,materialDef=json.materials[materialIndex];let materialType;const materialParams={},pending=[];if((materialDef.extensions||{})[EXTENSIONS.KHR_MATERIALS_UNLIT]){const kmuExtension=extensions[EXTENSIONS.KHR_MATERIALS_UNLIT];materialType=kmuExtension.getMaterialType(),pending.push(kmuExtension.extendParams(materialParams,materialDef,parser))}else{const metallicRoughness=materialDef.pbrMetallicRoughness||{};if(materialParams.color=new Color(1,1,1),materialParams.opacity=1,Array.isArray(metallicRoughness.baseColorFactor)){const array=metallicRoughness.baseColorFactor;materialParams.color.setRGB(array[0],array[1],array[2],LinearSRGBColorSpace),materialParams.opacity=array[3]}void 0!==metallicRoughness.baseColorTexture&&pending.push(parser.assignTexture(materialParams,"map",metallicRoughness.baseColorTexture,SRGBColorSpace)),materialParams.metalness=void 0!==metallicRoughness.metallicFactor?metallicRoughness.metallicFactor:1,materialParams.roughness=void 0!==metallicRoughness.roughnessFactor?metallicRoughness.roughnessFactor:1,void 0!==metallicRoughness.metallicRoughnessTexture&&(pending.push(parser.assignTexture(materialParams,"metalnessMap",metallicRoughness.metallicRoughnessTexture)),pending.push(parser.assignTexture(materialParams,"roughnessMap",metallicRoughness.metallicRoughnessTexture))),materialType=this._invokeOne((function(ext){return ext.getMaterialType&&ext.getMaterialType(materialIndex)})),pending.push(Promise.all(this._invokeAll((function(ext){return ext.extendMaterialParams&&ext.extendMaterialParams(materialIndex,materialParams)}))))}!0===materialDef.doubleSided&&(materialParams.side=DoubleSide);const alphaMode=materialDef.alphaMode||ALPHA_MODES_OPAQUE;if(alphaMode===ALPHA_MODES_BLEND?(materialParams.transparent=!0,materialParams.depthWrite=!1):(materialParams.transparent=!1,alphaMode===ALPHA_MODES_MASK&&(materialParams.alphaTest=void 0!==materialDef.alphaCutoff?materialDef.alphaCutoff:.5)),void 0!==materialDef.normalTexture&&materialType!==MeshBasicMaterial&&(pending.push(parser.assignTexture(materialParams,"normalMap",materialDef.normalTexture)),materialParams.normalScale=new Vector2(1,1),void 0!==materialDef.normalTexture.scale)){const scale=materialDef.normalTexture.scale;materialParams.normalScale.set(scale,scale)}if(void 0!==materialDef.occlusionTexture&&materialType!==MeshBasicMaterial&&(pending.push(parser.assignTexture(materialParams,"aoMap",materialDef.occlusionTexture)),void 0!==materialDef.occlusionTexture.strength&&(materialParams.aoMapIntensity=materialDef.occlusionTexture.strength)),void 0!==materialDef.emissiveFactor&&materialType!==MeshBasicMaterial){const emissiveFactor=materialDef.emissiveFactor;materialParams.emissive=(new Color).setRGB(emissiveFactor[0],emissiveFactor[1],emissiveFactor[2],LinearSRGBColorSpace)}return void 0!==materialDef.emissiveTexture&&materialType!==MeshBasicMaterial&&pending.push(parser.assignTexture(materialParams,"emissiveMap",materialDef.emissiveTexture,SRGBColorSpace)),Promise.all(pending).then((function(){const material=new materialType(materialParams);return materialDef.name&&(material.name=materialDef.name),assignExtrasToUserData(material,materialDef),parser.associations.set(material,{materials:materialIndex}),materialDef.extensions&&addUnknownExtensionsToUserData(extensions,material,materialDef),material}))}
855
- /** When Object3D instances are targeted by animation, they need unique names. */createUniqueName(originalName){const sanitizedName=PropertyBinding.sanitizeNodeName(originalName||"");return sanitizedName in this.nodeNamesUsed?sanitizedName+"_"+ ++this.nodeNamesUsed[sanitizedName]:(this.nodeNamesUsed[sanitizedName]=0,sanitizedName)}
856
- /**
857
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
858
- *
859
- * Creates BufferGeometries from primitives.
860
- *
861
- * @param {Array<GLTF.Primitive>} primitives
862
- * @return {Promise<Array<BufferGeometry>>}
863
- */loadGeometries(primitives){const parser=this,extensions=this.extensions,cache=this.primitiveCache;function createDracoPrimitive(primitive){return extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(primitive,parser).then((function(geometry){return addPrimitiveAttributes(geometry,primitive,parser)}))}const pending=[];for(let i=0,il=primitives.length;i<il;i++){const primitive=primitives[i],cacheKey=createPrimitiveKey(primitive),cached=cache[cacheKey];if(cached)pending.push(cached.promise);else{let geometryPromise;geometryPromise=primitive.extensions&&primitive.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]?createDracoPrimitive(primitive):addPrimitiveAttributes(new BufferGeometry,primitive,parser),cache[cacheKey]={primitive:primitive,promise:geometryPromise},pending.push(geometryPromise)}}return Promise.all(pending)}
864
- /**
865
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
866
- * @param {number} meshIndex
867
- * @return {Promise<Group|Mesh|SkinnedMesh>}
868
- */loadMesh(meshIndex){const parser=this,json=this.json,extensions=this.extensions,meshDef=json.meshes[meshIndex],primitives=meshDef.primitives,pending=[];for(let i=0,il=primitives.length;i<il;i++){const material=void 0===primitives[i].material?(void 0===(cache=this.cache).DefaultMaterial&&(cache.DefaultMaterial=new MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:FrontSide})),cache.DefaultMaterial):this.getDependency("material",primitives[i].material);pending.push(material)}
869
- /**
870
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material
871
- */
872
- var cache;return pending.push(parser.loadGeometries(primitives)),Promise.all(pending).then((function(results){const materials=results.slice(0,results.length-1),geometries=results[results.length-1],meshes=[];for(let i=0,il=geometries.length;i<il;i++){const geometry=geometries[i],primitive=primitives[i];let mesh;const material=materials[i];if(primitive.mode===WEBGL_CONSTANTS.TRIANGLES||primitive.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP||primitive.mode===WEBGL_CONSTANTS.TRIANGLE_FAN||void 0===primitive.mode)mesh=!0===meshDef.isSkinnedMesh?new SkinnedMesh(geometry,material):new Mesh(geometry,material),!0===mesh.isSkinnedMesh&&mesh.normalizeSkinWeights(),primitive.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP?mesh.geometry=toTrianglesDrawMode(mesh.geometry,TriangleStripDrawMode):primitive.mode===WEBGL_CONSTANTS.TRIANGLE_FAN&&(mesh.geometry=toTrianglesDrawMode(mesh.geometry,TriangleFanDrawMode));else if(primitive.mode===WEBGL_CONSTANTS.LINES)mesh=new LineSegments(geometry,material);else if(primitive.mode===WEBGL_CONSTANTS.LINE_STRIP)mesh=new Line(geometry,material);else if(primitive.mode===WEBGL_CONSTANTS.LINE_LOOP)mesh=new LineLoop(geometry,material);else{if(primitive.mode!==WEBGL_CONSTANTS.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+primitive.mode);mesh=new Points(geometry,material)}Object.keys(mesh.geometry.morphAttributes).length>0&&updateMorphTargets(mesh,meshDef),mesh.name=parser.createUniqueName(meshDef.name||"mesh_"+meshIndex),assignExtrasToUserData(mesh,meshDef),primitive.extensions&&addUnknownExtensionsToUserData(extensions,mesh,primitive),parser.assignFinalMaterial(mesh),meshes.push(mesh)}for(let i=0,il=meshes.length;i<il;i++)parser.associations.set(meshes[i],{meshes:meshIndex,primitives:i});if(1===meshes.length)return meshDef.extensions&&addUnknownExtensionsToUserData(extensions,meshes[0],meshDef),meshes[0];const group=new Group;meshDef.extensions&&addUnknownExtensionsToUserData(extensions,group,meshDef),parser.associations.set(group,{meshes:meshIndex});for(let i=0,il=meshes.length;i<il;i++)group.add(meshes[i]);return group}))}
873
- /**
874
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
875
- * @param {number} cameraIndex
876
- * @return {Promise<THREE.Camera>}
877
- */loadCamera(cameraIndex){let camera;const cameraDef=this.json.cameras[cameraIndex],params=cameraDef[cameraDef.type];if(params)return"perspective"===cameraDef.type?camera=new PerspectiveCamera(MathUtils.radToDeg(params.yfov),params.aspectRatio||1,params.znear||1,params.zfar||2e6):"orthographic"===cameraDef.type&&(camera=new OrthographicCamera(-params.xmag,params.xmag,params.ymag,-params.ymag,params.znear,params.zfar)),cameraDef.name&&(camera.name=this.createUniqueName(cameraDef.name)),assignExtrasToUserData(camera,cameraDef),Promise.resolve(camera);console.warn("THREE.GLTFLoader: Missing camera parameters.")}
878
- /**
879
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
880
- * @param {number} skinIndex
881
- * @return {Promise<Skeleton>}
882
- */loadSkin(skinIndex){const skinDef=this.json.skins[skinIndex],pending=[];for(let i=0,il=skinDef.joints.length;i<il;i++)pending.push(this._loadNodeShallow(skinDef.joints[i]));return void 0!==skinDef.inverseBindMatrices?pending.push(this.getDependency("accessor",skinDef.inverseBindMatrices)):pending.push(null),Promise.all(pending).then((function(results){const inverseBindMatrices=results.pop(),jointNodes=results,bones=[],boneInverses=[];for(let i=0,il=jointNodes.length;i<il;i++){const jointNode=jointNodes[i];if(jointNode){bones.push(jointNode);const mat=new Matrix4;null!==inverseBindMatrices&&mat.fromArray(inverseBindMatrices.array,16*i),boneInverses.push(mat)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',skinDef.joints[i])}return new Skeleton(bones,boneInverses)}))}
883
- /**
884
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
885
- * @param {number} animationIndex
886
- * @return {Promise<AnimationClip>}
887
- */loadAnimation(animationIndex){const json=this.json,parser=this,animationDef=json.animations[animationIndex],animationName=animationDef.name?animationDef.name:"animation_"+animationIndex,pendingNodes=[],pendingInputAccessors=[],pendingOutputAccessors=[],pendingSamplers=[],pendingTargets=[];for(let i=0,il=animationDef.channels.length;i<il;i++){const channel=animationDef.channels[i],sampler=animationDef.samplers[channel.sampler],target=channel.target,name=target.node,input=void 0!==animationDef.parameters?animationDef.parameters[sampler.input]:sampler.input,output=void 0!==animationDef.parameters?animationDef.parameters[sampler.output]:sampler.output;void 0!==target.node&&(pendingNodes.push(this.getDependency("node",name)),pendingInputAccessors.push(this.getDependency("accessor",input)),pendingOutputAccessors.push(this.getDependency("accessor",output)),pendingSamplers.push(sampler),pendingTargets.push(target))}return Promise.all([Promise.all(pendingNodes),Promise.all(pendingInputAccessors),Promise.all(pendingOutputAccessors),Promise.all(pendingSamplers),Promise.all(pendingTargets)]).then((function(dependencies){const nodes=dependencies[0],inputAccessors=dependencies[1],outputAccessors=dependencies[2],samplers=dependencies[3],targets=dependencies[4],tracks=[];for(let i=0,il=nodes.length;i<il;i++){const node=nodes[i],inputAccessor=inputAccessors[i],outputAccessor=outputAccessors[i],sampler=samplers[i],target=targets[i];if(void 0===node)continue;node.updateMatrix&&node.updateMatrix();const createdTracks=parser._createAnimationTracks(node,inputAccessor,outputAccessor,sampler,target);if(createdTracks)for(let k=0;k<createdTracks.length;k++)tracks.push(createdTracks[k])}return new AnimationClip(animationName,void 0,tracks)}))}createNodeMesh(nodeIndex){const json=this.json,parser=this,nodeDef=json.nodes[nodeIndex];return void 0===nodeDef.mesh?null:parser.getDependency("mesh",nodeDef.mesh).then((function(mesh){const node=parser._getNodeRef(parser.meshCache,nodeDef.mesh,mesh);return void 0!==nodeDef.weights&&node.traverse((function(o){if(o.isMesh)for(let i=0,il=nodeDef.weights.length;i<il;i++)o.morphTargetInfluences[i]=nodeDef.weights[i]})),node}))}
888
- /**
889
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
890
- * @param {number} nodeIndex
891
- * @return {Promise<Object3D>}
892
- */loadNode(nodeIndex){const parser=this,nodeDef=this.json.nodes[nodeIndex],nodePending=parser._loadNodeShallow(nodeIndex),childPending=[],childrenDef=nodeDef.children||[];for(let i=0,il=childrenDef.length;i<il;i++)childPending.push(parser.getDependency("node",childrenDef[i]));const skeletonPending=void 0===nodeDef.skin?Promise.resolve(null):parser.getDependency("skin",nodeDef.skin);return Promise.all([nodePending,Promise.all(childPending),skeletonPending]).then((function(results){const node=results[0],children=results[1],skeleton=results[2];null!==skeleton&&node.traverse((function(mesh){mesh.isSkinnedMesh&&mesh.bind(skeleton,_identityMatrix)}));for(let i=0,il=children.length;i<il;i++)node.add(children[i]);return node}))}_loadNodeShallow(nodeIndex){const json=this.json,extensions=this.extensions,parser=this;if(void 0!==this.nodeCache[nodeIndex])return this.nodeCache[nodeIndex];const nodeDef=json.nodes[nodeIndex],nodeName=nodeDef.name?parser.createUniqueName(nodeDef.name):"",pending=[],meshPromise=parser._invokeOne((function(ext){return ext.createNodeMesh&&ext.createNodeMesh(nodeIndex)}));return meshPromise&&pending.push(meshPromise),void 0!==nodeDef.camera&&pending.push(parser.getDependency("camera",nodeDef.camera).then((function(camera){return parser._getNodeRef(parser.cameraCache,nodeDef.camera,camera)}))),parser._invokeAll((function(ext){return ext.createNodeAttachment&&ext.createNodeAttachment(nodeIndex)})).forEach((function(promise){pending.push(promise)})),this.nodeCache[nodeIndex]=Promise.all(pending).then((function(objects){let node;if(node=!0===nodeDef.isBone?new Bone:objects.length>1?new Group:1===objects.length?objects[0]:new Object3D,node!==objects[0])for(let i=0,il=objects.length;i<il;i++)node.add(objects[i]);if(nodeDef.name&&(node.userData.name=nodeDef.name,node.name=nodeName),assignExtrasToUserData(node,nodeDef),nodeDef.extensions&&addUnknownExtensionsToUserData(extensions,node,nodeDef),void 0!==nodeDef.matrix){const matrix=new Matrix4;matrix.fromArray(nodeDef.matrix),node.applyMatrix4(matrix)}else void 0!==nodeDef.translation&&node.position.fromArray(nodeDef.translation),void 0!==nodeDef.rotation&&node.quaternion.fromArray(nodeDef.rotation),void 0!==nodeDef.scale&&node.scale.fromArray(nodeDef.scale);return parser.associations.has(node)||parser.associations.set(node,{}),parser.associations.get(node).nodes=nodeIndex,node})),this.nodeCache[nodeIndex]}
893
- /**
894
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
895
- * @param {number} sceneIndex
896
- * @return {Promise<Group>}
897
- */loadScene(sceneIndex){const extensions=this.extensions,sceneDef=this.json.scenes[sceneIndex],parser=this,scene=new Group;sceneDef.name&&(scene.name=parser.createUniqueName(sceneDef.name)),assignExtrasToUserData(scene,sceneDef),sceneDef.extensions&&addUnknownExtensionsToUserData(extensions,scene,sceneDef);const nodeIds=sceneDef.nodes||[],pending=[];for(let i=0,il=nodeIds.length;i<il;i++)pending.push(parser.getDependency("node",nodeIds[i]));return Promise.all(pending).then((function(nodes){for(let i=0,il=nodes.length;i<il;i++)scene.add(nodes[i]);return parser.associations=(node=>{const reducedAssociations=new Map;for(const[key,value]of parser.associations)(key instanceof Material||key instanceof Texture)&&reducedAssociations.set(key,value);return node.traverse((node=>{const mappings=parser.associations.get(node);null!=mappings&&reducedAssociations.set(node,mappings)})),reducedAssociations})(scene),scene}))}_createAnimationTracks(node,inputAccessor,outputAccessor,sampler,target){const tracks=[],targetName=node.name?node.name:node.uuid,targetNames=[];let TypedKeyframeTrack;switch(PATH_PROPERTIES[target.path]===PATH_PROPERTIES.weights?node.traverse((function(object){object.morphTargetInfluences&&targetNames.push(object.name?object.name:object.uuid)})):targetNames.push(targetName),PATH_PROPERTIES[target.path]){case PATH_PROPERTIES.weights:TypedKeyframeTrack=NumberKeyframeTrack;break;case PATH_PROPERTIES.rotation:TypedKeyframeTrack=QuaternionKeyframeTrack;break;case PATH_PROPERTIES.position:case PATH_PROPERTIES.scale:TypedKeyframeTrack=VectorKeyframeTrack;break;default:if(1===outputAccessor.itemSize)TypedKeyframeTrack=NumberKeyframeTrack;else TypedKeyframeTrack=VectorKeyframeTrack}const interpolation=void 0!==sampler.interpolation?INTERPOLATION[sampler.interpolation]:InterpolateLinear,outputArray=this._getArrayFromAccessor(outputAccessor);for(let j=0,jl=targetNames.length;j<jl;j++){const track=new TypedKeyframeTrack(targetNames[j]+"."+PATH_PROPERTIES[target.path],inputAccessor.array,outputArray,interpolation);"CUBICSPLINE"===sampler.interpolation&&this._createCubicSplineTrackInterpolant(track),tracks.push(track)}return tracks}_getArrayFromAccessor(accessor){let outputArray=accessor.array;if(accessor.normalized){const scale=getNormalizedComponentScale(outputArray.constructor),scaled=new Float32Array(outputArray.length);for(let j=0,jl=outputArray.length;j<jl;j++)scaled[j]=outputArray[j]*scale;outputArray=scaled}return outputArray}_createCubicSplineTrackInterpolant(track){track.createInterpolant=function InterpolantFactoryMethodGLTFCubicSpline(result){return new(this instanceof QuaternionKeyframeTrack?GLTFCubicSplineQuaternionInterpolant:GLTFCubicSplineInterpolant)(this.times,this.values,this.getValueSize()/3,result)},track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}
898
- /**
899
- * @param {BufferGeometry} geometry
900
- * @param {GLTF.Primitive} primitiveDef
901
- * @param {GLTFParser} parser
902
- */
903
- /**
904
- * @param {BufferGeometry} geometry
905
- * @param {GLTF.Primitive} primitiveDef
906
- * @param {GLTFParser} parser
907
- * @return {Promise<BufferGeometry>}
908
- */
909
- function addPrimitiveAttributes(geometry,primitiveDef,parser){const attributes=primitiveDef.attributes,pending=[];function assignAttributeAccessor(accessorIndex,attributeName){return parser.getDependency("accessor",accessorIndex).then((function(accessor){geometry.setAttribute(attributeName,accessor)}))}for(const gltfAttributeName in attributes){const threeAttributeName=ATTRIBUTES[gltfAttributeName]||gltfAttributeName.toLowerCase();threeAttributeName in geometry.attributes||pending.push(assignAttributeAccessor(attributes[gltfAttributeName],threeAttributeName))}if(void 0!==primitiveDef.indices&&!geometry.index){const accessor=parser.getDependency("accessor",primitiveDef.indices).then((function(accessor){geometry.setIndex(accessor)}));pending.push(accessor)}return ColorManagement.workingColorSpace!==LinearSRGBColorSpace&&"COLOR_0"in attributes&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ColorManagement.workingColorSpace}" not supported.`),assignExtrasToUserData(geometry,primitiveDef),function computeBounds(geometry,primitiveDef,parser){const attributes=primitiveDef.attributes,box=new Box3;if(void 0===attributes.POSITION)return;{const accessor=parser.json.accessors[attributes.POSITION],min=accessor.min,max=accessor.max;if(void 0===min||void 0===max)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(box.set(new Vector3(min[0],min[1],min[2]),new Vector3(max[0],max[1],max[2])),accessor.normalized){const boxScale=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[accessor.componentType]);box.min.multiplyScalar(boxScale),box.max.multiplyScalar(boxScale)}}const targets=primitiveDef.targets;if(void 0!==targets){const maxDisplacement=new Vector3,vector=new Vector3;for(let i=0,il=targets.length;i<il;i++){const target=targets[i];if(void 0!==target.POSITION){const accessor=parser.json.accessors[target.POSITION],min=accessor.min,max=accessor.max;if(void 0!==min&&void 0!==max){if(vector.setX(Math.max(Math.abs(min[0]),Math.abs(max[0]))),vector.setY(Math.max(Math.abs(min[1]),Math.abs(max[1]))),vector.setZ(Math.max(Math.abs(min[2]),Math.abs(max[2]))),accessor.normalized){const boxScale=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[accessor.componentType]);vector.multiplyScalar(boxScale)}maxDisplacement.max(vector)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}box.expandByVector(maxDisplacement)}geometry.boundingBox=box;const sphere=new Sphere;box.getCenter(sphere.center),sphere.radius=box.min.distanceTo(box.max)/2,geometry.boundingSphere=sphere}(geometry,primitiveDef,parser),Promise.all(pending).then((function(){return void 0!==primitiveDef.targets?function addMorphTargets(geometry,targets,parser){let hasMorphPosition=!1,hasMorphNormal=!1,hasMorphColor=!1;for(let i=0,il=targets.length;i<il;i++){const target=targets[i];if(void 0!==target.POSITION&&(hasMorphPosition=!0),void 0!==target.NORMAL&&(hasMorphNormal=!0),void 0!==target.COLOR_0&&(hasMorphColor=!0),hasMorphPosition&&hasMorphNormal&&hasMorphColor)break}if(!hasMorphPosition&&!hasMorphNormal&&!hasMorphColor)return Promise.resolve(geometry);const pendingPositionAccessors=[],pendingNormalAccessors=[],pendingColorAccessors=[];for(let i=0,il=targets.length;i<il;i++){const target=targets[i];if(hasMorphPosition){const pendingAccessor=void 0!==target.POSITION?parser.getDependency("accessor",target.POSITION):geometry.attributes.position;pendingPositionAccessors.push(pendingAccessor)}if(hasMorphNormal){const pendingAccessor=void 0!==target.NORMAL?parser.getDependency("accessor",target.NORMAL):geometry.attributes.normal;pendingNormalAccessors.push(pendingAccessor)}if(hasMorphColor){const pendingAccessor=void 0!==target.COLOR_0?parser.getDependency("accessor",target.COLOR_0):geometry.attributes.color;pendingColorAccessors.push(pendingAccessor)}}return Promise.all([Promise.all(pendingPositionAccessors),Promise.all(pendingNormalAccessors),Promise.all(pendingColorAccessors)]).then((function(accessors){const morphPositions=accessors[0],morphNormals=accessors[1],morphColors=accessors[2];return hasMorphPosition&&(geometry.morphAttributes.position=morphPositions),hasMorphNormal&&(geometry.morphAttributes.normal=morphNormals),hasMorphColor&&(geometry.morphAttributes.color=morphColors),geometry.morphTargetsRelative=!0,geometry}))}(geometry,primitiveDef.targets,parser):geometry}))}const _taskCache$1=new WeakMap;class DRACOLoader extends Loader{constructor(manager){super(manager),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(path){return this.decoderPath=path,this}setDecoderConfig(config){return this.decoderConfig=config,this}setWorkerLimit(workerLimit){return this.workerLimit=workerLimit,this}load(url,onLoad,onProgress,onError){const loader=new FileLoader(this.manager);loader.setPath(this.path),loader.setResponseType("arraybuffer"),loader.setRequestHeader(this.requestHeader),loader.setWithCredentials(this.withCredentials),loader.load(url,(buffer=>{this.parse(buffer,onLoad,onError)}),onProgress,onError)}parse(buffer,onLoad,onError=()=>{}){this.decodeDracoFile(buffer,onLoad,null,null,SRGBColorSpace,onError).catch(onError)}decodeDracoFile(buffer,callback,attributeIDs,attributeTypes,vertexColorSpace=LinearSRGBColorSpace,onError=()=>{}){const taskConfig={attributeIDs:attributeIDs||this.defaultAttributeIDs,attributeTypes:attributeTypes||this.defaultAttributeTypes,useUniqueIDs:!!attributeIDs,vertexColorSpace:vertexColorSpace};return this.decodeGeometry(buffer,taskConfig).then(callback).catch(onError)}decodeGeometry(buffer,taskConfig){const taskKey=JSON.stringify(taskConfig);if(_taskCache$1.has(buffer)){const cachedTask=_taskCache$1.get(buffer);if(cachedTask.key===taskKey)return cachedTask.promise;if(0===buffer.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let worker;const taskID=this.workerNextTaskID++,taskCost=buffer.byteLength,geometryPending=this._getWorker(taskID,taskCost).then((_worker=>(worker=_worker,new Promise(((resolve,reject)=>{worker._callbacks[taskID]={resolve:resolve,reject:reject},worker.postMessage({type:"decode",id:taskID,taskConfig:taskConfig,buffer:buffer},[buffer])}))))).then((message=>this._createGeometry(message.geometry)));return geometryPending.catch((()=>!0)).then((()=>{worker&&taskID&&this._releaseTask(worker,taskID)})),_taskCache$1.set(buffer,{key:taskKey,promise:geometryPending}),geometryPending}_createGeometry(geometryData){const geometry=new BufferGeometry;geometryData.index&&geometry.setIndex(new BufferAttribute(geometryData.index.array,1));for(let i=0;i<geometryData.attributes.length;i++){const result=geometryData.attributes[i],name=result.name,array=result.array,itemSize=result.itemSize,attribute=new BufferAttribute(array,itemSize);"color"===name&&(this._assignVertexColorSpace(attribute,result.vertexColorSpace),attribute.normalized=array instanceof Float32Array==!1),geometry.setAttribute(name,attribute)}return geometry}_assignVertexColorSpace(attribute,inputColorSpace){if(inputColorSpace!==SRGBColorSpace)return;const _color=new Color;for(let i=0,il=attribute.count;i<il;i++)_color.fromBufferAttribute(attribute,i).convertSRGBToLinear(),attribute.setXYZ(i,_color.r,_color.g,_color.b)}_loadLibrary(url,responseType){const loader=new FileLoader(this.manager);return loader.setPath(this.decoderPath),loader.setResponseType(responseType),loader.setWithCredentials(this.withCredentials),new Promise(((resolve,reject)=>{loader.load(url,resolve,void 0,reject)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const useJS="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,librariesPending=[];return useJS?librariesPending.push(this._loadLibrary("draco_decoder.js","text")):(librariesPending.push(this._loadLibrary("draco_wasm_wrapper.js","text")),librariesPending.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(librariesPending).then((libraries=>{const jsContent=libraries[0];useJS||(this.decoderConfig.wasmBinary=libraries[1]);const fn=DRACOWorker.toString(),body=["/* draco decoder */",jsContent,"","/* worker */",fn.substring(fn.indexOf("{")+1,fn.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([body]))})),this.decoderPending}_getWorker(taskID,taskCost){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const worker=new Worker(this.workerSourceURL);worker._callbacks={},worker._taskCosts={},worker._taskLoad=0,worker.postMessage({type:"init",decoderConfig:this.decoderConfig}),worker.onmessage=function(e){const message=e.data;switch(message.type){case"decode":worker._callbacks[message.id].resolve(message);break;case"error":worker._callbacks[message.id].reject(message);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+message.type+'"')}},this.workerPool.push(worker)}else this.workerPool.sort((function(a,b){return a._taskLoad>b._taskLoad?-1:1}));const worker=this.workerPool[this.workerPool.length-1];return worker._taskCosts[taskID]=taskCost,worker._taskLoad+=taskCost,worker}))}_releaseTask(worker,taskID){worker._taskLoad-=worker._taskCosts[taskID],delete worker._callbacks[taskID],delete worker._taskCosts[taskID]}debug(){console.log("Task load: ",this.workerPool.map((worker=>worker._taskLoad)))}dispose(){for(let i=0;i<this.workerPool.length;++i)this.workerPool[i].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}function DRACOWorker(){let decoderConfig,decoderPending;function decodeAttribute(draco,decoder,dracoGeometry,attributeName,attributeType,attribute){const numComponents=attribute.num_components(),numValues=dracoGeometry.num_points()*numComponents,byteLength=numValues*attributeType.BYTES_PER_ELEMENT,dataType=function getDracoDataType(draco,attributeType){switch(attributeType){case Float32Array:return draco.DT_FLOAT32;case Int8Array:return draco.DT_INT8;case Int16Array:return draco.DT_INT16;case Int32Array:return draco.DT_INT32;case Uint8Array:return draco.DT_UINT8;case Uint16Array:return draco.DT_UINT16;case Uint32Array:return draco.DT_UINT32}}(draco,attributeType),ptr=draco._malloc(byteLength);decoder.GetAttributeDataArrayForAllPoints(dracoGeometry,attribute,dataType,byteLength,ptr);const array=new attributeType(draco.HEAPF32.buffer,ptr,numValues).slice();return draco._free(ptr),{name:attributeName,array:array,itemSize:numComponents}}onmessage=function(e){const message=e.data;switch(message.type){case"init":decoderConfig=message.decoderConfig,decoderPending=new Promise((function(resolve){decoderConfig.onModuleLoaded=function(draco){resolve({draco:draco})},DracoDecoderModule(decoderConfig)}));break;case"decode":const buffer=message.buffer,taskConfig=message.taskConfig;decoderPending.then((module=>{const draco=module.draco,decoder=new draco.Decoder;try{const geometry=function decodeGeometry(draco,decoder,array,taskConfig){const attributeIDs=taskConfig.attributeIDs,attributeTypes=taskConfig.attributeTypes;let dracoGeometry,decodingStatus;const geometryType=decoder.GetEncodedGeometryType(array);if(geometryType===draco.TRIANGULAR_MESH)dracoGeometry=new draco.Mesh,decodingStatus=decoder.DecodeArrayToMesh(array,array.byteLength,dracoGeometry);else{if(geometryType!==draco.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");dracoGeometry=new draco.PointCloud,decodingStatus=decoder.DecodeArrayToPointCloud(array,array.byteLength,dracoGeometry)}if(!decodingStatus.ok()||0===dracoGeometry.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+decodingStatus.error_msg());const geometry={index:null,attributes:[]};for(const attributeName in attributeIDs){const attributeType=self[attributeTypes[attributeName]];let attribute,attributeID;if(taskConfig.useUniqueIDs)attributeID=attributeIDs[attributeName],attribute=decoder.GetAttributeByUniqueId(dracoGeometry,attributeID);else{if(attributeID=decoder.GetAttributeId(dracoGeometry,draco[attributeIDs[attributeName]]),-1===attributeID)continue;attribute=decoder.GetAttribute(dracoGeometry,attributeID)}const attributeResult=decodeAttribute(draco,decoder,dracoGeometry,attributeName,attributeType,attribute);"color"===attributeName&&(attributeResult.vertexColorSpace=taskConfig.vertexColorSpace),geometry.attributes.push(attributeResult)}geometryType===draco.TRIANGULAR_MESH&&(geometry.index=function decodeIndex(draco,decoder,dracoGeometry){const numFaces=dracoGeometry.num_faces(),numIndices=3*numFaces,byteLength=4*numIndices,ptr=draco._malloc(byteLength);decoder.GetTrianglesUInt32Array(dracoGeometry,byteLength,ptr);const index=new Uint32Array(draco.HEAPF32.buffer,ptr,numIndices).slice();return draco._free(ptr),{array:index,itemSize:1}}(draco,decoder,dracoGeometry));return draco.destroy(dracoGeometry),geometry}(draco,decoder,new Int8Array(buffer),taskConfig),buffers=geometry.attributes.map((attr=>attr.array.buffer));geometry.index&&buffers.push(geometry.index.array.buffer),self.postMessage({type:"decode",id:message.id,geometry:geometry},buffers)}catch(error){console.error(error),self.postMessage({type:"error",id:message.id,error:error.message})}finally{draco.destroy(decoder)}}))}}}
910
- /**
911
- * @author Deepkolos / https://github.com/deepkolos
912
- */class WorkerPool{constructor(pool=4){this.pool=pool,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(workerId){if(!this.workers[workerId]){const worker=this.workerCreator();worker.addEventListener("message",this._onMessage.bind(this,workerId)),this.workers[workerId]=worker}}_getIdleWorker(){for(let i=0;i<this.pool;i++)if(!(this.workerStatus&1<<i))return i;return-1}_onMessage(workerId,msg){const resolve=this.workersResolve[workerId];if(resolve&&resolve(msg),this.queue.length){const{resolve:resolve,msg:msg,transfer:transfer}=this.queue.shift();this.workersResolve[workerId]=resolve,this.workers[workerId].postMessage(msg,transfer)}else this.workerStatus^=1<<workerId}setWorkerCreator(workerCreator){this.workerCreator=workerCreator}setWorkerLimit(pool){this.pool=pool}postMessage(msg,transfer){return new Promise((resolve=>{const workerId=this._getIdleWorker();-1!==workerId?(this._initWorker(workerId),this.workerStatus|=1<<workerId,this.workersResolve[workerId]=resolve,this.workers[workerId].postMessage(msg,transfer)):this.queue.push({resolve:resolve,msg:msg,transfer:transfer})}))}dispose(){this.workers.forEach((worker=>worker.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const ct=9,gt=15,yt=16,dt=22,Ot=37,Ft=43,$t=76,se=83,pe=97,xe=100,de=103,Ae=109,Sn=165,In=166;class Si{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class Ii{constructor(t,e,n,i){this._dataView=new DataView(t.buffer,t.byteOffset+e,n),this._littleEndian=i,this._offset=0}_nextUint8(){const t=this._dataView.getUint8(this._offset);return this._offset+=1,t}_nextUint16(){const t=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,t}_nextUint32(){const t=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,t}_nextUint64(){const t=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,t}_nextInt32(){const t=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,t}_skip(t){return this._offset+=t,this}_scan(t,e=0){const n=this._offset;let i=0;for(;this._dataView.getUint8(this._offset)!==e&&i<t;)i++,this._offset++;return i<t&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,i)}}const Ti=[171,75,84,88,32,50,48,187,13,10,26,10];function Ei(t){return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(t):Buffer.from(t).toString("utf8")}let A,I,B;const g={env:{emscripten_notify_memory_growth:function(A){B=new Uint8Array(I.exports.memory.buffer)}}};class Q{init(){return A||(A="undefined"!=typeof fetch?fetch("data:application/wasm;base64,"+C).then((A=>A.arrayBuffer())).then((A=>WebAssembly.instantiate(A,g))).then(this._init):WebAssembly.instantiate(Buffer.from(C,"base64"),g).then(this._init),A)}_init(A){I=A.instance,g.env.emscripten_notify_memory_growth(0)}decode(A,g=0){if(!I)throw new Error("ZSTDDecoder: Await .init() before decoding.");const Q=A.byteLength,C=I.exports.malloc(Q);B.set(A,C),g=g||Number(I.exports.ZSTD_findDecompressedSize(C,Q));const E=I.exports.malloc(g),i=I.exports.ZSTD_decompress(E,g,C,Q),D=B.slice(E,E+i);return I.exports.free(C),I.exports.free(E),D}}const C="AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21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gA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQhBSAGQQR2IQRBICAAdCIAQQFyIQkgASgCACE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UG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEEdCAAbiECCyAAQQh2IgEgAkEYbCIAQYwIaigCAGwgAEGICGooAgBqIgJBA3YgAmogAEGACGooAgAgAEGECGooAgAgAWxqSQs3ACAAIAMgBCAFQY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AAAAYTAAAAAAAABhYAAAAAAAAGGQAAAAAAAAYcAAAAAAAABh8AAAAAAAAGIgAAAAAAAQYlAAAAAAABBikAAAAAAAIGLwAAAAAAAwY7AAAAAAAEBlMAAAAAAAcGgwAAAAAACQYDAgAAEAAABAQAAAAAAAAEBQAAACAAAAUGAAAAAAAABQcAAAAgAAAFCQAAAAAAAAUKAAAAAAAABgwAAAAAAAAGDwAAAAAAAAYSAAAAAAAABhUAAAAAAAAGGAAAAAAAAAYbAAAAAAAABh4AAAAAAAAGIQAAAAAAAQYjAAAAAAABBicAAAAAAAIGKwAAAAAAAwYzAAAAAAAEBkMAAAAAAAUGYwAAAAAACAYDAQAAIAAABAQAAAAwAAAEBAAAABAAAAQFAAAAIAAABQcAAAAgAAAFCAAAACAAAAUKAAAAIAAABQsAAAAAAAAGDgAAAAAAAAYRAAAAAAAABhQAAAAAAAAGFwAAAAAAAAYaAAAAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ",_taskCache=new WeakMap;
913
- /**
914
- * Loader for KTX 2.0 GPU Texture containers.
915
- *
916
- * KTX 2.0 is a container format for various GPU texture formats. The loader
917
- * supports Basis Universal GPU textures, which can be quickly transcoded to
918
- * a wide variety of GPU texture compression formats, as well as some
919
- * uncompressed DataTexture and Data3DTexture formats.
920
- *
921
- * References:
922
- * - KTX: http://github.khronos.org/KTX-Specification/
923
- * - DFD: https://www.khronos.org/registry/DataFormat/specs/1.3/dataformat.1.3.html#basicdescriptor
924
- */let _zstd,_activeLoaders=0;class KTX2Loader extends Loader{constructor(manager){super(manager),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new WorkerPool,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(path){return this.transcoderPath=path,this}setWorkerLimit(num){return this.workerPool.setWorkerLimit(num),this}async detectSupportAsync(renderer){return this.workerConfig={astcSupported:await renderer.hasFeatureAsync("texture-compression-astc"),etc1Supported:await renderer.hasFeatureAsync("texture-compression-etc1"),etc2Supported:await renderer.hasFeatureAsync("texture-compression-etc2"),dxtSupported:await renderer.hasFeatureAsync("texture-compression-bc"),bptcSupported:await renderer.hasFeatureAsync("texture-compression-bptc"),pvrtcSupported:await renderer.hasFeatureAsync("texture-compression-pvrtc")},this}detectSupport(renderer){return!0===renderer.isWebGPURenderer?this.workerConfig={astcSupported:renderer.hasFeature("texture-compression-astc"),etc1Supported:renderer.hasFeature("texture-compression-etc1"),etc2Supported:renderer.hasFeature("texture-compression-etc2"),dxtSupported:renderer.hasFeature("texture-compression-bc"),bptcSupported:renderer.hasFeature("texture-compression-bptc"),pvrtcSupported:renderer.hasFeature("texture-compression-pvrtc")}:this.workerConfig={astcSupported:renderer.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:renderer.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:renderer.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:renderer.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:renderer.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:renderer.extensions.has("WEBGL_compressed_texture_pvrtc")||renderer.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},this}init(){if(!this.transcoderPending){const jsLoader=new FileLoader(this.manager);jsLoader.setPath(this.transcoderPath),jsLoader.setWithCredentials(this.withCredentials);const jsContent=jsLoader.loadAsync("basis_transcoder.js"),binaryLoader=new FileLoader(this.manager);binaryLoader.setPath(this.transcoderPath),binaryLoader.setResponseType("arraybuffer"),binaryLoader.setWithCredentials(this.withCredentials);const binaryContent=binaryLoader.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([jsContent,binaryContent]).then((([jsContent,binaryContent])=>{const fn=KTX2Loader.BasisWorker.toString(),body=["/* constants */","let _EngineFormat = "+JSON.stringify(KTX2Loader.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(KTX2Loader.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(KTX2Loader.BasisFormat),"/* basis_transcoder.js */",jsContent,"/* worker */",fn.substring(fn.indexOf("{")+1,fn.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([body])),this.transcoderBinary=binaryContent,this.workerPool.setWorkerCreator((()=>{const worker=new Worker(this.workerSourceURL),transcoderBinary=this.transcoderBinary.slice(0);return worker.postMessage({type:"init",config:this.workerConfig,transcoderBinary:transcoderBinary},[transcoderBinary]),worker}))})),_activeLoaders>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),_activeLoaders++}return this.transcoderPending}load(url,onLoad,onProgress,onError){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const loader=new FileLoader(this.manager);loader.setResponseType("arraybuffer"),loader.setWithCredentials(this.withCredentials),loader.load(url,(buffer=>{this.parse(buffer,onLoad,onError)}),onProgress,onError)}parse(buffer,onLoad,onError){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(_taskCache.has(buffer)){return _taskCache.get(buffer).promise.then(onLoad).catch(onError)}this._createTexture(buffer).then((texture=>onLoad?onLoad(texture):null)).catch(onError)}_createTextureFrom(transcodeResult,container){const{faces:faces,width:width,height:height,format:format,type:type,error:error,dfdFlags:dfdFlags}=transcodeResult;if("error"===type)return Promise.reject(error);let texture;if(6===container.faceCount)texture=new CompressedCubeTexture(faces,format,UnsignedByteType);else{const mipmaps=faces[0].mipmaps;texture=container.layerCount>1?new CompressedArrayTexture(mipmaps,width,height,container.layerCount,format,UnsignedByteType):new CompressedTexture(mipmaps,width,height,format,UnsignedByteType)}return texture.minFilter=1===faces[0].mipmaps.length?LinearFilter:LinearMipmapLinearFilter,texture.magFilter=LinearFilter,texture.generateMipmaps=!1,texture.needsUpdate=!0,texture.colorSpace=parseColorSpace(container),texture.premultiplyAlpha=!!(1&dfdFlags),texture}
925
- /**
926
- * @param {ArrayBuffer} buffer
927
- * @param {object?} config
928
- * @return {Promise<CompressedTexture|CompressedArrayTexture|DataTexture|Data3DTexture>}
929
- */async _createTexture(buffer,config={}){const container=function Pi(t){const e=new Uint8Array(t.buffer,t.byteOffset,Ti.length);if(e[0]!==Ti[0]||e[1]!==Ti[1]||e[2]!==Ti[2]||e[3]!==Ti[3]||e[4]!==Ti[4]||e[5]!==Ti[5]||e[6]!==Ti[6]||e[7]!==Ti[7]||e[8]!==Ti[8]||e[9]!==Ti[9]||e[10]!==Ti[10]||e[11]!==Ti[11])throw new Error("Missing KTX 2.0 identifier.");const n=new Si,i=17*Uint32Array.BYTES_PER_ELEMENT,s=new Ii(t,Ti.length,i,!0);n.vkFormat=s._nextUint32(),n.typeSize=s._nextUint32(),n.pixelWidth=s._nextUint32(),n.pixelHeight=s._nextUint32(),n.pixelDepth=s._nextUint32(),n.layerCount=s._nextUint32(),n.faceCount=s._nextUint32();const a=s._nextUint32();n.supercompressionScheme=s._nextUint32();const r=s._nextUint32(),o=s._nextUint32(),l=s._nextUint32(),f=s._nextUint32(),U=s._nextUint64(),c=s._nextUint64(),h=new Ii(t,Ti.length+i,3*a*8,!0);for(let e=0;e<a;e++)n.levels.push({levelData:new Uint8Array(t.buffer,t.byteOffset+h._nextUint64(),h._nextUint64()),uncompressedByteLength:h._nextUint64()});const _=new Ii(t,r,o,!0),p={vendorId:_._skip(4)._nextUint16(),descriptorType:_._nextUint16(),versionNumber:_._nextUint16(),descriptorBlockSize:_._nextUint16(),colorModel:_._nextUint8(),colorPrimaries:_._nextUint8(),transferFunction:_._nextUint8(),flags:_._nextUint8(),texelBlockDimension:[_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8()],bytesPlane:[_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8()],samples:[]},g=(p.descriptorBlockSize/4-6)/4;for(let t=0;t<g;t++){const e={bitOffset:_._nextUint16(),bitLength:_._nextUint8(),channelType:_._nextUint8(),samplePosition:[_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&e.channelType?(e.sampleLower=_._nextInt32(),e.sampleUpper=_._nextInt32()):(e.sampleLower=_._nextUint32(),e.sampleUpper=_._nextUint32()),p.samples[t]=e}n.dataFormatDescriptor.length=0,n.dataFormatDescriptor.push(p);const y=new Ii(t,l,f,!0);for(;y._offset<f;){const t=y._nextUint32(),e=y._scan(t),i=Ei(e),s=y._scan(t-e.byteLength);n.keyValue[i]=i.match(/^ktx/i)?Ei(s):s,y._offset%4&&y._skip(4-y._offset%4)}if(c<=0)return n;const x=new Ii(t,U,c,!0),u=x._nextUint16(),b=x._nextUint16(),d=x._nextUint32(),m=x._nextUint32(),w=x._nextUint32(),D=x._nextUint32(),B=[];for(let t=0;t<a;t++)B.push({imageFlags:x._nextUint32(),rgbSliceByteOffset:x._nextUint32(),rgbSliceByteLength:x._nextUint32(),alphaSliceByteOffset:x._nextUint32(),alphaSliceByteLength:x._nextUint32()});const L=U+x._offset,A=L+d,k=A+m,v=k+w,S=new Uint8Array(t.buffer,t.byteOffset+L,d),I=new Uint8Array(t.buffer,t.byteOffset+A,m),O=new Uint8Array(t.buffer,t.byteOffset+k,w),T=new Uint8Array(t.buffer,t.byteOffset+v,D);return n.globalData={endpointCount:u,selectorCount:b,imageDescs:B,endpointsData:S,selectorsData:I,tablesData:O,extendedData:T},n}(new Uint8Array(buffer));if(0!==container.vkFormat)return async function createRawTexture(container){const{vkFormat:vkFormat}=container;if(void 0===FORMAT_MAP[vkFormat])throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");let zstd;2===container.supercompressionScheme&&(_zstd||(_zstd=new Promise((async resolve=>{const zstd=new Q;await zstd.init(),resolve(zstd)}))),zstd=await _zstd);const mipmaps=[];for(let levelIndex=0;levelIndex<container.levels.length;levelIndex++){const levelWidth=Math.max(1,container.pixelWidth>>levelIndex),levelHeight=Math.max(1,container.pixelHeight>>levelIndex),levelDepth=container.pixelDepth?Math.max(1,container.pixelDepth>>levelIndex):0,level=container.levels[levelIndex];let levelData,data;if(0===container.supercompressionScheme)levelData=level.levelData;else{if(2!==container.supercompressionScheme)throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");levelData=zstd.decode(level.levelData,level.uncompressedByteLength)}data=TYPE_MAP[vkFormat]===FloatType?new Float32Array(levelData.buffer,levelData.byteOffset,levelData.byteLength/Float32Array.BYTES_PER_ELEMENT):TYPE_MAP[vkFormat]===HalfFloatType?new Uint16Array(levelData.buffer,levelData.byteOffset,levelData.byteLength/Uint16Array.BYTES_PER_ELEMENT):levelData,mipmaps.push({data:data,width:levelWidth,height:levelHeight,depth:levelDepth})}let texture;if(UNCOMPRESSED_FORMATS.has(FORMAT_MAP[vkFormat]))texture=0===container.pixelDepth?new DataTexture(mipmaps[0].data,container.pixelWidth,container.pixelHeight):new Data3DTexture(mipmaps[0].data,container.pixelWidth,container.pixelHeight,container.pixelDepth);else{if(container.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");texture=new CompressedTexture(mipmaps,container.pixelWidth,container.pixelHeight)}return texture.mipmaps=mipmaps,texture.type=TYPE_MAP[vkFormat],texture.format=FORMAT_MAP[vkFormat],texture.colorSpace=parseColorSpace(container),texture.needsUpdate=!0,Promise.resolve(texture)}(container);const taskConfig=config,texturePending=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffer:buffer,taskConfig:taskConfig},[buffer]))).then((e=>this._createTextureFrom(e.data,container)));return _taskCache.set(buffer,{promise:texturePending}),texturePending}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),_activeLoaders--,this}}KTX2Loader.BasisFormat={ETC1S:0,UASTC_4x4:1},KTX2Loader.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},KTX2Loader.EngineFormat={RGBAFormat:RGBAFormat,RGBA_ASTC_4x4_Format:RGBA_ASTC_4x4_Format,RGBA_BPTC_Format:RGBA_BPTC_Format,RGBA_ETC2_EAC_Format:RGBA_ETC2_EAC_Format,RGBA_PVRTC_4BPPV1_Format:RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT5_Format:RGBA_S3TC_DXT5_Format,RGB_ETC1_Format:RGB_ETC1_Format,RGB_ETC2_Format:RGB_ETC2_Format,RGB_PVRTC_4BPPV1_Format:RGB_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT1_Format:RGBA_S3TC_DXT1_Format},KTX2Loader.BasisWorker=function(){let config,transcoderPending,BasisModule;const EngineFormat=_EngineFormat,TranscoderFormat=_TranscoderFormat,BasisFormat=_BasisFormat;self.addEventListener("message",(function(e){const message=e.data;switch(message.type){case"init":config=message.config,function init(wasmBinary){transcoderPending=new Promise((resolve=>{BasisModule={wasmBinary:wasmBinary,onRuntimeInitialized:resolve},BASIS(BasisModule)})).then((()=>{BasisModule.initializeBasis(),void 0===BasisModule.KTX2File&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")}))}(message.transcoderBinary);break;case"transcode":transcoderPending.then((()=>{try{const{faces:faces,buffers:buffers,width:width,height:height,hasAlpha:hasAlpha,format:format,dfdFlags:dfdFlags}=function transcode(buffer){const ktx2File=new BasisModule.KTX2File(new Uint8Array(buffer));function cleanup(){ktx2File.close(),ktx2File.delete()}if(!ktx2File.isValid())throw cleanup(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");const basisFormat=ktx2File.isUASTC()?BasisFormat.UASTC_4x4:BasisFormat.ETC1S,width=ktx2File.getWidth(),height=ktx2File.getHeight(),layerCount=ktx2File.getLayers()||1,levelCount=ktx2File.getLevels(),faceCount=ktx2File.getFaces(),hasAlpha=ktx2File.getHasAlpha(),dfdFlags=ktx2File.getDFDFlags(),{transcoderFormat:transcoderFormat,engineFormat:engineFormat}=function getTranscoderFormat(basisFormat,width,height,hasAlpha){let transcoderFormat,engineFormat;const options=basisFormat===BasisFormat.ETC1S?ETC1S_OPTIONS:UASTC_OPTIONS;for(let i=0;i<options.length;i++){const opt=options[i];if(config[opt.if]&&(opt.basisFormat.includes(basisFormat)&&!(hasAlpha&&opt.transcoderFormat.length<2)&&(!opt.needsPowerOfTwo||isPowerOfTwo(width)&&isPowerOfTwo(height))))return transcoderFormat=opt.transcoderFormat[hasAlpha?1:0],engineFormat=opt.engineFormat[hasAlpha?1:0],{transcoderFormat:transcoderFormat,engineFormat:engineFormat}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),transcoderFormat=TranscoderFormat.RGBA32,engineFormat=EngineFormat.RGBAFormat,{transcoderFormat:transcoderFormat,engineFormat:engineFormat}}(basisFormat,width,height,hasAlpha);if(!width||!height||!levelCount)throw cleanup(),new Error("THREE.KTX2Loader:\tInvalid texture");if(!ktx2File.startTranscoding())throw cleanup(),new Error("THREE.KTX2Loader: .startTranscoding failed");const faces=[],buffers=[];for(let face=0;face<faceCount;face++){const mipmaps=[];for(let mip=0;mip<levelCount;mip++){const layerMips=[];let mipWidth,mipHeight;for(let layer=0;layer<layerCount;layer++){const levelInfo=ktx2File.getImageLevelInfo(mip,layer,face);0!==face||0!==mip||0!==layer||levelInfo.origWidth%4==0&&levelInfo.origHeight%4==0||console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),levelCount>1?(mipWidth=levelInfo.origWidth,mipHeight=levelInfo.origHeight):(mipWidth=levelInfo.width,mipHeight=levelInfo.height);const dst=new Uint8Array(ktx2File.getImageTranscodedSizeInBytes(mip,layer,0,transcoderFormat));if(!ktx2File.transcodeImage(dst,mip,layer,face,transcoderFormat,0,-1,-1))throw cleanup(),new Error("THREE.KTX2Loader: .transcodeImage failed.");layerMips.push(dst)}const mipData=concat(layerMips);mipmaps.push({data:mipData,width:mipWidth,height:mipHeight}),buffers.push(mipData.buffer)}faces.push({mipmaps:mipmaps,width:width,height:height,format:engineFormat})}return cleanup(),{faces:faces,buffers:buffers,width:width,height:height,hasAlpha:hasAlpha,format:engineFormat,dfdFlags:dfdFlags}}(message.buffer);self.postMessage({type:"transcode",id:message.id,faces:faces,width:width,height:height,hasAlpha:hasAlpha,format:format,dfdFlags:dfdFlags},buffers)}catch(error){console.error(error),self.postMessage({type:"error",id:message.id,error:error.message})}}))}}));const FORMAT_OPTIONS=[{if:"astcSupported",basisFormat:[BasisFormat.UASTC_4x4],transcoderFormat:[TranscoderFormat.ASTC_4x4,TranscoderFormat.ASTC_4x4],engineFormat:[EngineFormat.RGBA_ASTC_4x4_Format,EngineFormat.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[BasisFormat.ETC1S,BasisFormat.UASTC_4x4],transcoderFormat:[TranscoderFormat.BC7_M5,TranscoderFormat.BC7_M5],engineFormat:[EngineFormat.RGBA_BPTC_Format,EngineFormat.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[BasisFormat.ETC1S,BasisFormat.UASTC_4x4],transcoderFormat:[TranscoderFormat.BC1,TranscoderFormat.BC3],engineFormat:[EngineFormat.RGBA_S3TC_DXT1_Format,EngineFormat.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[BasisFormat.ETC1S,BasisFormat.UASTC_4x4],transcoderFormat:[TranscoderFormat.ETC1,TranscoderFormat.ETC2],engineFormat:[EngineFormat.RGB_ETC2_Format,EngineFormat.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[BasisFormat.ETC1S,BasisFormat.UASTC_4x4],transcoderFormat:[TranscoderFormat.ETC1],engineFormat:[EngineFormat.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[BasisFormat.ETC1S,BasisFormat.UASTC_4x4],transcoderFormat:[TranscoderFormat.PVRTC1_4_RGB,TranscoderFormat.PVRTC1_4_RGBA],engineFormat:[EngineFormat.RGB_PVRTC_4BPPV1_Format,EngineFormat.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],ETC1S_OPTIONS=FORMAT_OPTIONS.sort((function(a,b){return a.priorityETC1S-b.priorityETC1S})),UASTC_OPTIONS=FORMAT_OPTIONS.sort((function(a,b){return a.priorityUASTC-b.priorityUASTC}));function isPowerOfTwo(value){return value<=2||!(value&value-1)&&0!==value}
930
- /** Concatenates N byte arrays. */function concat(arrays){if(1===arrays.length)return arrays[0];let totalByteLength=0;for(let i=0;i<arrays.length;i++){totalByteLength+=arrays[i].byteLength}const result=new Uint8Array(totalByteLength);let byteOffset=0;for(let i=0;i<arrays.length;i++){const array=arrays[i];result.set(array,byteOffset),byteOffset+=array.byteLength}return result}};const UNCOMPRESSED_FORMATS=new Set([RGBAFormat,RGFormat,RedFormat]),FORMAT_MAP={[Ae]:RGBAFormat,[pe]:RGBAFormat,[Ot]:RGBAFormat,[Ft]:RGBAFormat,[de]:RGFormat,[se]:RGFormat,[yt]:RGFormat,[dt]:RGFormat,[xe]:RedFormat,[$t]:RedFormat,[gt]:RedFormat,[ct]:RedFormat,[In]:RGBA_ASTC_6x6_Format,[Sn]:RGBA_ASTC_6x6_Format},TYPE_MAP={[Ae]:FloatType,[pe]:HalfFloatType,[Ot]:UnsignedByteType,[Ft]:UnsignedByteType,[de]:FloatType,[se]:HalfFloatType,[yt]:UnsignedByteType,[dt]:UnsignedByteType,[xe]:FloatType,[$t]:HalfFloatType,[gt]:UnsignedByteType,[ct]:UnsignedByteType,[In]:UnsignedByteType,[Sn]:UnsignedByteType};function parseColorSpace(container){const dfd=container.dataFormatDescriptor[0];return 1===dfd.colorPrimaries?2===dfd.transferFunction?SRGBColorSpace:LinearSRGBColorSpace:10===dfd.colorPrimaries?2===dfd.transferFunction?DisplayP3ColorSpace:LinearDisplayP3ColorSpace:(0===dfd.colorPrimaries||console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${dfd.colorPrimaries}"`),NoColorSpace)}var MeshoptDecoder=function(){var detector=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),wasmpack=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if("object"!=typeof WebAssembly)return{supported:!1};var instance,wasm=WebAssembly.validate(detector)?"b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb":"b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb",ready=WebAssembly.instantiate(unpack(wasm),{}).then((function(result){(instance=result.instance).exports.__wasm_call_ctors()}));function unpack(data){for(var result=new Uint8Array(data.length),i=0;i<data.length;++i){var ch=data.charCodeAt(i);result[i]=ch>96?ch-97:ch>64?ch-39:ch+4}var write=0;for(i=0;i<data.length;++i)result[write++]=result[i]<60?wasmpack[result[i]]:64*(result[i]-60)+result[++i];return result.buffer.slice(0,write)}function decode(fun,target,count,size,source,filter){var sbrk=instance.exports.sbrk,count4=count+3&-4,tp=sbrk(count4*size),sp=sbrk(source.length),heap=new Uint8Array(instance.exports.memory.buffer);heap.set(source,sp);var res=fun(tp,count,size,sp,source.length);if(0==res&&filter&&filter(tp,count4,size),target.set(heap.subarray(tp,tp+count*size)),sbrk(tp-sbrk(0)),0!=res)throw new Error("Malformed buffer data: "+res)}var filters={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},decoders={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},workers=[],requestId=0;function createWorker(url){var worker={object:new Worker(url),pending:0,requests:{}};return worker.object.onmessage=function(event){var data=event.data;worker.pending-=data.count,worker.requests[data.id][data.action](data.value),delete worker.requests[data.id]},worker}function initWorkers(count){for(var source="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(unpack(wasm))+"]), {}).then(function(result) { instance = result.instance; instance.exports.__wasm_call_ctors(); });self.onmessage = workerProcess;"+decode.toString()+workerProcess.toString(),blob=new Blob([source],{type:"text/javascript"}),url=URL.createObjectURL(blob),i=0;i<count;++i)workers[i]=createWorker(url);URL.revokeObjectURL(url)}function workerProcess(event){ready.then((function(){var data=event.data;try{var target=new Uint8Array(data.count*data.size);decode(instance.exports[data.mode],target,data.count,data.size,data.source,instance.exports[data.filter]),self.postMessage({id:data.id,count:data.count,action:"resolve",value:target},[target.buffer])}catch(error){self.postMessage({id:data.id,count:data.count,action:"reject",value:error})}}))}return{ready:ready,supported:!0,useWorkers:function(count){initWorkers(count)},decodeVertexBuffer:function(target,count,size,source,filter){decode(instance.exports.meshopt_decodeVertexBuffer,target,count,size,source,instance.exports[filters[filter]])},decodeIndexBuffer:function(target,count,size,source){decode(instance.exports.meshopt_decodeIndexBuffer,target,count,size,source)},decodeIndexSequence:function(target,count,size,source){decode(instance.exports.meshopt_decodeIndexSequence,target,count,size,source)},decodeGltfBuffer:function(target,count,size,source,mode,filter){decode(instance.exports[decoders[mode]],target,count,size,source,instance.exports[filters[filter]])},decodeGltfBufferAsync:function(count,size,source,mode,filter){return workers.length>0?function decodeWorker(count,size,source,mode,filter){for(var worker=workers[0],i=1;i<workers.length;++i)workers[i].pending<worker.pending&&(worker=workers[i]);return new Promise((function(resolve,reject){var data=new Uint8Array(source),id=requestId++;worker.pending+=count,worker.requests[id]={resolve:resolve,reject:reject},worker.object.postMessage({id:id,count:count,size:size,source:data,mode:mode,filter:filter},[data.buffer])}))}(count,size,source,decoders[mode],filters[filter]):ready.then((function(){var target=new Uint8Array(count*size);return decode(instance.exports[decoders[mode]],target,count,size,source,instance.exports[filters[filter]]),target}))}}}();
931
- /**
932
- * Autodesk 3DS three.js file loader, based on lib3ds.
933
- *
934
- * Loads geometry with uv and materials basic properties with texture support.
935
- *
936
- * @class TDSLoader
937
- * @constructor
938
- */class TDSLoader extends Loader{constructor(manager){super(manager),this.debug=!1,this.group=null,this.materials=[],this.meshes=[]}
939
- /**
940
- * Load 3ds file from url.
941
- *
942
- * @method load
943
- * @param {[type]} url URL for the file.
944
- * @param {Function} onLoad onLoad callback, receives group Object3D as argument.
945
- * @param {Function} onProgress onProgress callback.
946
- * @param {Function} onError onError callback.
947
- */load(url,onLoad,onProgress,onError){const scope=this,path=""===this.path?LoaderUtils.extractUrlBase(url):this.path,loader=new FileLoader(this.manager);loader.setPath(this.path),loader.setResponseType("arraybuffer"),loader.setRequestHeader(this.requestHeader),loader.setWithCredentials(this.withCredentials),loader.load(url,(function(data){try{onLoad(scope.parse(data,path))}catch(e){onError?onError(e):console.error(e),scope.manager.itemError(url)}}),onProgress,onError)}
948
- /**
949
- * Parse arraybuffer data and load 3ds file.
950
- *
951
- * @method parse
952
- * @param {ArrayBuffer} arraybuffer Arraybuffer data to be loaded.
953
- * @param {String} path Path for external resources.
954
- * @return {Group} Group loaded from 3ds file.
955
- */parse(arraybuffer,path){this.group=new Group,this.materials=[],this.meshes=[],this.readFile(arraybuffer,path);for(let i=0;i<this.meshes.length;i++)this.group.add(this.meshes[i]);return this.group}
956
- /**
957
- * Decode file content to read 3ds data.
958
- *
959
- * @method readFile
960
- * @param {ArrayBuffer} arraybuffer Arraybuffer data to be loaded.
961
- * @param {String} path Path for external resources.
962
- */readFile(arraybuffer,path){const data=new DataView(arraybuffer),chunk=new Chunk(data,0,this.debugMessage);if(chunk.id===MLIBMAGIC||chunk.id===CMAGIC||chunk.id===M3DMAGIC){let next=chunk.readChunk();for(;next;){if(next.id===M3D_VERSION){const version=next.readDWord();this.debugMessage("3DS file version: "+version)}else next.id===MDATA?this.readMeshData(next,path):this.debugMessage("Unknown main chunk: "+next.hexId);next=chunk.readChunk()}}this.debugMessage("Parsed "+this.meshes.length+" meshes")}
963
- /**
964
- * Read mesh data chunk.
965
- *
966
- * @method readMeshData
967
- * @param {Chunk} chunk to read mesh from
968
- * @param {String} path Path for external resources.
969
- */readMeshData(chunk,path){let next=chunk.readChunk();for(;next;){if(next.id===MESH_VERSION){const version=+next.readDWord();this.debugMessage("Mesh Version: "+version)}else if(next.id===MASTER_SCALE){const scale=next.readFloat();this.debugMessage("Master scale: "+scale),this.group.scale.set(scale,scale,scale)}else next.id===NAMED_OBJECT?(this.debugMessage("Named Object"),this.readNamedObject(next)):next.id===MAT_ENTRY?(this.debugMessage("Material"),this.readMaterialEntry(next,path)):this.debugMessage("Unknown MDATA chunk: "+next.hexId);next=chunk.readChunk()}}
970
- /**
971
- * Read named object chunk.
972
- *
973
- * @method readNamedObject
974
- * @param {Chunk} chunk Chunk in use.
975
- */readNamedObject(chunk){const name=chunk.readString();let next=chunk.readChunk();for(;next;){if(next.id===N_TRI_OBJECT){const mesh=this.readMesh(next);mesh.name=name,this.meshes.push(mesh)}else this.debugMessage("Unknown named object chunk: "+next.hexId);next=chunk.readChunk()}}
976
- /**
977
- * Read material data chunk and add it to the material list.
978
- *
979
- * @method readMaterialEntry
980
- * @param {Chunk} chunk Chunk in use.
981
- * @param {String} path Path for external resources.
982
- */readMaterialEntry(chunk,path){let next=chunk.readChunk();const material=new MeshPhongMaterial;for(;next;){if(next.id===MAT_NAME)material.name=next.readString(),this.debugMessage(" Name: "+material.name);else if(next.id===MAT_WIRE)this.debugMessage(" Wireframe"),material.wireframe=!0;else if(next.id===MAT_WIRE_SIZE){const value=next.readByte();material.wireframeLinewidth=value,this.debugMessage(" Wireframe Thickness: "+value)}else if(next.id===MAT_TWO_SIDE)material.side=DoubleSide,this.debugMessage(" DoubleSided");else if(next.id===MAT_ADDITIVE)this.debugMessage(" Additive Blending"),material.blending=AdditiveBlending;else if(next.id===MAT_DIFFUSE)this.debugMessage(" Diffuse Color"),material.color=this.readColor(next);else if(next.id===MAT_SPECULAR)this.debugMessage(" Specular Color"),material.specular=this.readColor(next);else if(next.id===MAT_AMBIENT)this.debugMessage(" Ambient color"),material.color=this.readColor(next);else if(next.id===MAT_SHININESS){const shininess=this.readPercentage(next);material.shininess=100*shininess,this.debugMessage(" Shininess : "+shininess)}else if(next.id===MAT_TRANSPARENCY){const transparency=this.readPercentage(next);material.opacity=1-transparency,this.debugMessage(" Transparency : "+transparency),material.transparent=material.opacity<1}else next.id===MAT_TEXMAP?(this.debugMessage(" ColorMap"),material.map=this.readMap(next,path)):next.id===MAT_BUMPMAP?(this.debugMessage(" BumpMap"),material.bumpMap=this.readMap(next,path)):next.id===MAT_OPACMAP?(this.debugMessage(" OpacityMap"),material.alphaMap=this.readMap(next,path)):next.id===MAT_SPECMAP?(this.debugMessage(" SpecularMap"),material.specularMap=this.readMap(next,path)):this.debugMessage(" Unknown material chunk: "+next.hexId);next=chunk.readChunk()}this.materials[material.name]=material}
983
- /**
984
- * Read mesh data chunk.
985
- *
986
- * @method readMesh
987
- * @param {Chunk} chunk Chunk in use.
988
- * @return {Mesh} The parsed mesh.
989
- */readMesh(chunk){let next=chunk.readChunk();const geometry=new BufferGeometry,material=new MeshPhongMaterial,mesh=new Mesh(geometry,material);for(mesh.name="mesh";next;){if(next.id===POINT_ARRAY){const points=next.readWord();this.debugMessage(" Vertex: "+points);const vertices=[];for(let i=0;i<points;i++)vertices.push(next.readFloat()),vertices.push(next.readFloat()),vertices.push(next.readFloat());geometry.setAttribute("position",new Float32BufferAttribute(vertices,3))}else if(next.id===FACE_ARRAY)this.readFaceArray(next,mesh);else if(next.id===TEX_VERTS){const texels=next.readWord();this.debugMessage(" UV: "+texels);const uvs=[];for(let i=0;i<texels;i++)uvs.push(next.readFloat()),uvs.push(next.readFloat());geometry.setAttribute("uv",new Float32BufferAttribute(uvs,2))}else if(next.id===MESH_MATRIX){this.debugMessage(" Tranformation Matrix (TODO)");const values=[];for(let i=0;i<12;i++)values[i]=next.readFloat();const matrix=new Matrix4;matrix.elements[0]=values[0],matrix.elements[1]=values[6],matrix.elements[2]=values[3],matrix.elements[3]=values[9],matrix.elements[4]=values[2],matrix.elements[5]=values[8],matrix.elements[6]=values[5],matrix.elements[7]=values[11],matrix.elements[8]=values[1],matrix.elements[9]=values[7],matrix.elements[10]=values[4],matrix.elements[11]=values[10],matrix.elements[12]=0,matrix.elements[13]=0,matrix.elements[14]=0,matrix.elements[15]=1,matrix.transpose();const inverse=new Matrix4;inverse.copy(matrix).invert(),geometry.applyMatrix4(inverse),matrix.decompose(mesh.position,mesh.quaternion,mesh.scale)}else this.debugMessage(" Unknown mesh chunk: "+next.hexId);next=chunk.readChunk()}return geometry.computeVertexNormals(),mesh}
990
- /**
991
- * Read face array data chunk.
992
- *
993
- * @method readFaceArray
994
- * @param {Chunk} chunk Chunk in use.
995
- * @param {Mesh} mesh Mesh to be filled with the data read.
996
- */readFaceArray(chunk,mesh){const faces=chunk.readWord();this.debugMessage(" Faces: "+faces);const index=[];for(let i=0;i<faces;++i)index.push(chunk.readWord(),chunk.readWord(),chunk.readWord()),chunk.readWord();mesh.geometry.setIndex(index);let materialIndex=0,start=0;for(;!chunk.endOfChunk;){const subchunk=chunk.readChunk();if(subchunk.id===MSH_MAT_GROUP){this.debugMessage(" Material Group");const group=this.readMaterialGroup(subchunk),count=3*group.index.length;mesh.geometry.addGroup(start,count,materialIndex),start+=count,materialIndex++;const material=this.materials[group.name];!1===Array.isArray(mesh.material)&&(mesh.material=[]),void 0!==material&&mesh.material.push(material)}else this.debugMessage(" Unknown face array chunk: "+subchunk.hexId)}1===mesh.material.length&&(mesh.material=mesh.material[0])}
997
- /**
998
- * Read texture map data chunk.
999
- *
1000
- * @method readMap
1001
- * @param {Chunk} chunk Chunk in use.
1002
- * @param {String} path Path for external resources.
1003
- * @return {Texture} Texture read from this data chunk.
1004
- */readMap(chunk,path){let next=chunk.readChunk(),texture={};const loader=new TextureLoader(this.manager);for(loader.setPath(this.resourcePath||path).setCrossOrigin(this.crossOrigin);next;){if(next.id===MAT_MAPNAME){const name=next.readString();texture=loader.load(name),texture.userData.name=name.split(".").slice(0,-1).join("."),this.debugMessage(" File: "+path+name)}else next.id===MAT_MAP_UOFFSET?(texture.offset.x=next.readFloat(),this.debugMessage(" OffsetX: "+texture.offset.x)):next.id===MAT_MAP_VOFFSET?(texture.offset.y=next.readFloat(),this.debugMessage(" OffsetY: "+texture.offset.y)):next.id===MAT_MAP_USCALE?(texture.repeat.x=next.readFloat(),this.debugMessage(" RepeatX: "+texture.repeat.x)):next.id===MAT_MAP_VSCALE?(texture.repeat.y=next.readFloat(),this.debugMessage(" RepeatY: "+texture.repeat.y)):this.debugMessage(" Unknown map chunk: "+next.hexId);next=chunk.readChunk()}return texture}
1005
- /**
1006
- * Read material group data chunk.
1007
- *
1008
- * @method readMaterialGroup
1009
- * @param {Chunk} chunk Chunk in use.
1010
- * @return {Object} Object with name and index of the object.
1011
- */readMaterialGroup(chunk){const name=chunk.readString(),numFaces=chunk.readWord();this.debugMessage(" Name: "+name),this.debugMessage(" Faces: "+numFaces);const index=[];for(let i=0;i<numFaces;++i)index.push(chunk.readWord());return{name:name,index:index}}
1012
- /**
1013
- * Read a color value.
1014
- *
1015
- * @method readColor
1016
- * @param {Chunk} chunk Chunk.
1017
- * @return {Color} Color value read..
1018
- */readColor(chunk){const subChunk=chunk.readChunk(),color=new Color;if(subChunk.id===COLOR_24||subChunk.id===LIN_COLOR_24){const r=subChunk.readByte(),g=subChunk.readByte(),b=subChunk.readByte();color.setRGB(r/255,g/255,b/255),this.debugMessage(" Color: "+color.r+", "+color.g+", "+color.b)}else if(subChunk.id===COLOR_F||subChunk.id===LIN_COLOR_F){const r=subChunk.readFloat(),g=subChunk.readFloat(),b=subChunk.readFloat();color.setRGB(r,g,b),this.debugMessage(" Color: "+color.r+", "+color.g+", "+color.b)}else this.debugMessage(" Unknown color chunk: "+subChunk.hexId);return color}
1019
- /**
1020
- * Read percentage value.
1021
- *
1022
- * @method readPercentage
1023
- * @param {Chunk} chunk Chunk to read data from.
1024
- * @return {Number} Data read from the dataview.
1025
- */readPercentage(chunk){const subChunk=chunk.readChunk();switch(subChunk.id){case INT_PERCENTAGE:return subChunk.readShort()/100;case FLOAT_PERCENTAGE:return subChunk.readFloat();default:return this.debugMessage(" Unknown percentage chunk: "+subChunk.hexId),0}}
1026
- /**
1027
- * Print debug message to the console.
1028
- *
1029
- * Is controlled by a flag to show or hide debug messages.
1030
- *
1031
- * @method debugMessage
1032
- * @param {Object} message Debug message to print to the console.
1033
- */debugMessage(message){this.debug&&console.log(message)}}
1034
- /** Read data/sub-chunks from chunk */class Chunk{
1035
- /**
1036
- * Create a new chunk
1037
- *
1038
- * @class Chunk
1039
- * @param {DataView} data DataView to read from.
1040
- * @param {Number} position in data.
1041
- * @param {Function} debugMessage logging callback.
1042
- */
1043
- constructor(data,position,debugMessage){this.data=data,this.offset=position,this.position=position,this.debugMessage=debugMessage,this.debugMessage instanceof Function&&(this.debugMessage=function(){}),this.id=this.readWord(),this.size=this.readDWord(),this.end=this.offset+this.size,this.end>data.byteLength&&this.debugMessage("Bad chunk size for chunk at "+position)}
1044
- /**
1045
- * read a sub cchunk.
1046
- *
1047
- * @method readChunk
1048
- * @return {Chunk | null} next sub chunk
1049
- */readChunk(){if(this.endOfChunk)return null;try{const next=new Chunk(this.data,this.position,this.debugMessage);return this.position+=next.size,next}catch(e){return this.debugMessage("Unable to read chunk at "+this.position),null}}
1050
- /**
1051
- * return the ID of this chunk as Hex
1052
- *
1053
- * @method idToString
1054
- * @return {String} hex-string of id
1055
- */get hexId(){return this.id.toString(16)}get endOfChunk(){return this.position>=this.end}
1056
- /**
1057
- * Read byte value.
1058
- *
1059
- * @method readByte
1060
- * @return {Number} Data read from the dataview.
1061
- */readByte(){const v=this.data.getUint8(this.position,!0);return this.position+=1,v}
1062
- /**
1063
- * Read 32 bit float value.
1064
- *
1065
- * @method readFloat
1066
- * @return {Number} Data read from the dataview.
1067
- */readFloat(){try{const v=this.data.getFloat32(this.position,!0);return this.position+=4,v}catch(e){return this.debugMessage(e+" "+this.position+" "+this.data.byteLength),0}}
1068
- /**
1069
- * Read 32 bit signed integer value.
1070
- *
1071
- * @method readInt
1072
- * @return {Number} Data read from the dataview.
1073
- */readInt(){const v=this.data.getInt32(this.position,!0);return this.position+=4,v}
1074
- /**
1075
- * Read 16 bit signed integer value.
1076
- *
1077
- * @method readShort
1078
- * @return {Number} Data read from the dataview.
1079
- */readShort(){const v=this.data.getInt16(this.position,!0);return this.position+=2,v}
1080
- /**
1081
- * Read 64 bit unsigned integer value.
1082
- *
1083
- * @method readDWord
1084
- * @return {Number} Data read from the dataview.
1085
- */readDWord(){const v=this.data.getUint32(this.position,!0);return this.position+=4,v}
1086
- /**
1087
- * Read 32 bit unsigned integer value.
1088
- *
1089
- * @method readWord
1090
- * @return {Number} Data read from the dataview.
1091
- */readWord(){const v=this.data.getUint16(this.position,!0);return this.position+=2,v}
1092
- /**
1093
- * Read NULL terminated ASCII string value from chunk-pos.
1094
- *
1095
- * @method readString
1096
- * @return {String} Data read from the dataview.
1097
- */readString(){let s="",c=this.readByte();for(;c;)s+=String.fromCharCode(c),c=this.readByte();return s}}const M3DMAGIC=19789,MLIBMAGIC=15786,CMAGIC=49725,M3D_VERSION=2,COLOR_F=16,COLOR_24=17,LIN_COLOR_24=18,LIN_COLOR_F=19,INT_PERCENTAGE=48,FLOAT_PERCENTAGE=49,MDATA=15677,MESH_VERSION=15678,MASTER_SCALE=256,MAT_ENTRY=45055,MAT_NAME=40960,MAT_AMBIENT=40976,MAT_DIFFUSE=40992,MAT_SPECULAR=41008,MAT_SHININESS=41024,MAT_TRANSPARENCY=41040,MAT_TWO_SIDE=41089,MAT_ADDITIVE=41091,MAT_WIRE=41093,MAT_WIRE_SIZE=41095,MAT_TEXMAP=41472,MAT_OPACMAP=41488,MAT_BUMPMAP=41520,MAT_SPECMAP=41476,MAT_MAPNAME=41728,MAT_MAP_USCALE=41812,MAT_MAP_VSCALE=41814,MAT_MAP_UOFFSET=41816,MAT_MAP_VOFFSET=41818,NAMED_OBJECT=16384,N_TRI_OBJECT=16640,POINT_ARRAY=16656,FACE_ARRAY=16672,MSH_MAT_GROUP=16688,TEX_VERTS=16704,MESH_MATRIX=16736;const to_std=(mat,cache)=>{if(!mat||"MeshPhongMaterial"!==mat.type)return mat;if(cache){const c=cache.get(mat);if(c)return c}const rough=1-("number"==typeof mat.shininess?Math.min(Math.max(mat.shininess,0),100):30)/100,std=new THREE.MeshStandardMaterial({name:mat.name,color:mat.color,map:mat.map,normalMap:mat.normalMap,emissive:mat.emissive,emissiveMap:mat.emissiveMap,envMap:mat.envMap,envMapIntensity:mat.envMapIntensity??1,lightMap:mat.lightMap,lightMapIntensity:mat.lightMapIntensity,alphaTest:mat.alphaTest,depthWrite:mat.depthWrite,depthTest:mat.depthTest,wireframe:mat.wireframe,transparent:mat.transparent,opacity:mat.opacity,side:mat.side,roughness:rough,metalness:0});return cache&&cache.set(mat,std),"function"==typeof mat.dispose&&(mat.dispose(),mat.userData=mat.userData||{},mat.userData._replaced=!0),std.needsUpdate=!0,std};function newgcad(P,_cat,islog=!0){let _movs={},_textures={},_meshes={},_geometries={},_cachefn={};const textureCache=new Map;let _smats={},_scripts={},_loadertex=new THREE.TextureLoader,_loaderGLTF=new GLTFLoader,_loader3DS=new TDSLoader;const dracoLoader=new DRACOLoader;dracoLoader.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.6/"),_loaderGLTF.setDRACOLoader(dracoLoader);const ktx2Loader=new KTX2Loader;ktx2Loader.setTranscoderPath("https://unpkg.com/three@0.159.0/examples/jsm/libs/basis/"),_loaderGLTF.setKTX2Loader(ktx2Loader),_loaderGLTF.setMeshoptDecoder(MeshoptDecoder);let cats=[_cat],getcat=()=>cats[cats.length-1],_gmatricole={};
1098
- /**
1099
- * Libera tutte le risorse caricate
1100
- */
1101
- async function clearmat(){for(const key in _textures)if(_textures[key]){const texture=await _textures[key];texture?.dispose()}for(const key in _smats)_smats[key]&&_smats[key]?.dispose();for(const[key,texOrPromise]of textureCache.entries()){const texture=texOrPromise instanceof Promise?await texOrPromise:texOrPromise;texture?.dispose&&texture.dispose()}textureCache.clear(),_textures={},_smats={}}function getdims(obj){let box=(new THREE.Box3).setFromObject(obj),n2=n=>Math.round(100*n)/100;return{zero:{x:n2(-box.min.x),y:n2(-box.min.y),z:n2(-box.min.z)},dim:{x:n2(box.max.x-box.min.x),y:n2(box.max.y-box.min.y),z:n2(box.max.z-box.min.z)},position:obj.position,rotation:{x:obj.rotation.x,y:obj.rotation.y,z:obj.rotation.z},scale:obj.scale}}async function get3ds(file){file.endsWith(".3ds")&&(file=file.slice(0,-4));const key=hash(`${getcat()}|${file}.3ds`);return _meshes[key]||(_meshes[key]=await new Promise(((resolve,reject)=>{let url,urlt="";file.startsWith("https://")?(url=`${file}.3ds`,urlt=url):P._cdn?(url=`${P._cdn}${getcat()}/3d/${file}.3ds`,urlt=`${P._cdn}${getcat()}/3d/${file}/`):(url=P.fullget("mufiles/getfile",{id:getcat(),subfolder:"3d",name:file,ext:".3ds"}),urlt=url+"&tex="),_loader3DS.setResourcePath(urlt),_loader3DS.load(url,(object=>{const cache=new WeakMap;object.traverse((n=>{n.isMesh&&n.material&&(n.material=Array.isArray(n.material)?n.material.map((e=>to_std(e,cache))):to_std(n.material,cache))})),object.userData||(object.userData={}),object.userData._ky=key,resolve(object)}),void 0,(error=>{console.log(error),delete _meshes[key],resolve(void 0)}))}))),_meshes[key]}async function getglb(file){const ext=".glb";file.endsWith(ext)&&(file=file.slice(0,-4)),file.startsWith("https://")||(file=file.replace(/\//g,"+"));let elemento=(file=file.split("+"))[1];file=file[0];const key=hash(`${getcat()}|${file}${ext}`);_meshes[key]||(_meshes[key]=await new Promise(((resolve,reject)=>{let url;url=file.startsWith("https://")?`${file}.glb`:P._cdn?`${P._cdn}${getcat()}/3d/${file}.glb`:P.fullget("mufiles/getfile",{id:getcat(),subfolder:"3d",name:file,ext:ext}),_loaderGLTF.setPath(""),_loaderGLTF.setResourcePath((resource=>(console.log("risorsa",resource),`${url}&tex=${resource}`))),_loaderGLTF.load(url,(async gltf=>{const object=gltf.scene;object.userData||(object.userData={}),object.userData._ky=key,resolve(object)}),void 0,(error=>{console.log(error),delete _meshes[key],resolve(void 0)}))})));let tm=_meshes[key];if(elemento){let n=tm?.getObjectByName(elemento);n&&(tm=n)}return tm}return{clearmatricole:()=>{_gmatricole={}},tex:async function tex(file,sx=1,sy,rot){let key;return sy||(sy=sx),rot||(rot=0),"__alpha"==file?(key=file,_textures[key]||(_textures[key]=function getfortransparent(){const texture=new THREE.CanvasTexture(function generateTexture(){const canvas=document.createElement("canvas");canvas.width=2,canvas.height=2;const context=canvas.getContext("2d");return context.fillStyle="white",context.fillRect(0,1,2,1),canvas}());return texture.magFilter=THREE.NearestFilter,texture.wrapT=THREE.RepeatWrapping,texture.wrapS=THREE.RepeatWrapping,texture.repeat.set(1,3.5),texture}()),_textures[key]):(key=hash(`${getcat()}|${file}|${sx}|${sy}|${rot}`),_textures[key]||(_textures[key]=new Promise(((resolve,reject)=>{let url;if(file.startsWith("https://"))url=file;else if(P._cdn)if(file.includes("/")){let v=file.split("/");url=`${P._cdn}${v[0]}/textures/${v[1]}`}else url=`${P._cdn}${getcat()}/textures/${file}`;else url=P.fullget("mufiles/getfile",{id:getcat(),subfolder:"textures",name:file,force:1});if(textureCache.has(url)){const tex=textureCache.get(url).clone();return tex.wrapS=THREE.RepeatWrapping,tex.wrapT=THREE.RepeatWrapping,tex.center.set(.5,.5),tex.repeat.set(.001*sx,.001*sy),tex.rotation=rot,void resolve(tex)}_loadertex.load(url,(tex=>{textureCache.set(url,tex),tex.wrapS=THREE.RepeatWrapping,tex.wrapT=THREE.RepeatWrapping,tex.repeat.set(.001*sx,.001*sy),tex.center.set(.5,.5),tex.rotation=rot,resolve(tex)}),void 0,(error=>{console.log(`Manca Texture ${file}!. questo rallenta molto il processo`),delete _textures[key],resolve(void 0)}))}))),_textures[key])},getglb:getglb,get3ds:get3ds,replacemats:function replacemats(bb,mats,callback){if(!Array.isArray(mats)||0==mats.length)return bb;const leggi_slot=mat=>{if(!mat)return-1;let s=(mat?.map?.name||mat?.name||mat?.map?.userData?.name||"").toString().trim();if(callback){const s1=callback(s);void 0!==s1&&(s=s1)}if(s.includes("_")&&(s=s.split("_").pop()),!s)return-1;const n=parseInt(s,10);return n>=1&&n<=9?n:-1};let serve_clone=!1,ky=String(bb.userData?._ky||"");if(bb.traverse((n=>{if(!n.isMesh)return;const ms=Array.isArray(n.material)?n.material:[n.material];for(const m of ms){const k=leggi_slot(m);k>0&&mats[k-1]&&(serve_clone=!0,ky+="|"+(mats[k-1].name||mats[k-1].uuid))}})),serve_clone){if(ky=hash(ky),_meshes[ky])return _meshes[ky];const cc=bb.clone(!0);cc.traverse((n=>{if(n.isMesh)if(Array.isArray(n.material))n.material=n.material.map((m=>{if(!m)return m;const k=leggi_slot(m);if(k>0&&mats[k-1]){const t=mats[k-1];return t.needsUpdate=!0,t}return m}));else{const m=n.material,k=leggi_slot(m);n.material=k>0&&mats[k-1]?(mats[k-1].needsUpdate=!0,mats[k-1]):m}})),cc.userData=cc.userData||{},cc.userData._ky=ky,_meshes[ky]=cc,bb=cc}return bb},islog:islog,clear:async function clear(){function destroymesh(mesh){function disposeMaterial(material){material.map&&material.map.dispose(),material.lightMap&&material.lightMap.dispose(),material.bumpMap&&material.bumpMap.dispose(),material.normalMap&&material.normalMap.dispose(),material.specularMap&&material.specularMap.dispose(),material.dispose()}mesh&&mesh.traverse((child=>{child.isMesh&&(child.geometry.dispose(),child.material&&(Array.isArray(child.material)?child.material.forEach(disposeMaterial):disposeMaterial(child.material)))}))}_gmatricole={},_cachefn={},THREE.Cache.clear();for(const c in _geometries)_geometries[c]?.dispose();for(const key in _meshes)if(_meshes[key]){destroymesh(await _meshes[key])}await clearmat(),_movs={},_textures={},_meshes={},_geometries={},_smats={},_scripts={}},clearmat:clearmat,getdims:getdims,info3d:async function info3d(file,scale=1,scaley=0,scalez=0){let tm=(file||"").endsWith(".3ds")?await get3ds(file):await getglb(file);if(tm)return scale&&1!=scale&&(tm.scale.set(scale||1,scaley||scale||1,scalez||scale||1),tm.needsUpdate=!0),getdims(tm)},getScript:async function getScript(file){file.endsWith(".custom")?file=file.slice(0,-7):file.endsWith(".js")&&(file=file.slice(0,-3));let key=hash(`${getcat()}|${file}`);if(!_scripts[key]){let script;try{script=await P.fetch("mufiles/customfn",{id:getcat(),name:file,ispar:1})}catch(error){script=`log('undefined ${getcat()}/${file}: ${error.message}');`}_scripts[key]=script}return _scripts[key]},checkScripts:async function checkScripts(files){let cl=[];if(!files||!Array.isArray(files))return;let ct=getcat();files=[...files,"_ricalcolatop","_ricalcolaaltri","_ricalcolalinee"];for(let f of files){let key=hash(`${ct}|${f}`);_scripts[key]||cl.push(f)}if(cl?.length){let scripts=await P.fetch("mufiles/customfn",{id:ct,name:cl,ispar:1});if(scripts)for(let s of scripts){let key=hash(`${ct}|${s.n}`);_scripts[key]=s.v}}},get loaderGLTF(){return _loaderGLTF},get gmats(){return _gmatricole},scripts:()=>Object.keys(_scripts),get geo(){return _geometries},get movs(){return _movs},get textures(){return _textures},get smats(){return _smats},get meshes(){return _meshes},get cacheFns(){return _cachefn},dump(){console.log(`SMATS:\n${Object.keys(_smats).join(" - ")};\nGEOMS:\n${Object.keys(_geometries).join(" - ")};\nTEX:\n${Object.keys(_textures).join(" - ")};\nMESH:\n${Object.keys(_meshes).join(" - ")};\n`)},get cat(){return getcat()},pushcat(cat){cats.push(cat)},popcat:()=>(cats.length>1&&cats.length--,getcat())}}const originalMaterials=new Map;
1102
- /**
1103
- * Salva i materiali originali di tutti i mesh nel gruppo (solo layer <= 20)
1104
- * @param {THREE.Object3D} gruppo
1105
- */function salvaMaterialiOriginali(gruppo){gruppo.traverse((obj=>{if(!obj.isMesh||obj.layers.mask>1<<20)return;const mat=obj.material;if(!mat)return;const mats=Array.isArray(mat)?mat:[mat];originalMaterials.has(obj)||originalMaterials.set(obj,mats)}))}
1106
- /**
1107
- * Ripristina i materiali originali salvati
1108
- */function ripristinaMaterialiOriginali(){for(let[obj,mats]of originalMaterials.entries())obj.material=Array.isArray(mats)?[...mats]:mats;originalMaterials.clear()}
1109
- /**
1110
- * Applica materiali evidenziati a tutti i mesh del gruppo
1111
- * @param {THREE.Object3D} gruppo
1112
- * @param {string[]} target - lista di matricole da evidenziare
1113
- * @param {THREE.Material} matBianco
1114
- * @param {THREE.Material} matVerde
1115
- */function applicaEvidenziazione(gruppo,target,matBianco,matVerde){!function ricorsiva(nodo,isEvidenziato,usaMappa){const nuovoEvidenziato=!!isEvidenziato||!!target&&target.includes(nodo?.userData?.mat),nuovoMappa=usaMappa||nodo.userData?.evidenziaMap;if(nodo.isMesh&&nodo.layers.mask<=1<<20){const oldMat=originalMaterials.get(nodo);if(!oldMat)return;const newMats=oldMat.map((m=>{const base=(nuovoEvidenziato?matVerde:matBianco).clone();return nuovoMappa&&m.map&&(base.map=m.map),base.transparent=m.transparent,base.opacity=m.opacity,base}));nodo.material=Array.isArray(nodo.material)?newMats:newMats[0]}nodo.children.forEach((c=>ricorsiva(c,nuovoEvidenziato,nuovoMappa)))}(gruppo,!1,!1)}
1116
- /**
1117
- * Applica evidenziazione multipla e salva una lista di immagini
1118
- * @param {THREE.Object3D} gruppo - oggetto root
1119
- * @param {Array<{ mats: string[], name?: string }>} matricole - elenco da evidenziare
1120
- * @returns {Promise<File[]>}
1121
- */async function evidenziaColli(gruppo,matricole,callback){salvaMaterialiOriginali(gruppo);const SIDE=THREE.DoubleSide,mwhite=new THREE.MeshStandardMaterial({color:16777215,roughness:.5,metalness:.4,side:SIDE}),mgreen=new THREE.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:SIDE});let ii=0;try{for(let mts of matricole)ii++,mts.name||(mts.name=`collo_${ii}`),applicaEvidenziazione(gruppo,mts.mats,mwhite,mgreen),await callback(mts)}catch(err){console.error("Errore durante evidenzia:",err)}finally{ripristinaMaterialiOriginali()}}function TODEG(a,dec=1){let C=10**dec;return Math.round(180*a*C/Math.PI)/C}function TORAD(a,dec=3){let C=10**dec;return Math.round(a*PIF*C)/C}const blocked={window:void 0,self:void 0,globalThis:void 0,document:void 0,Function:void 0,eval:void 0,fetch:void 0,XMLHttpRequest:void 0};function getOggetto(obj,exclude=[]){if(Array.isArray(obj))return obj.map((item=>getOggetto(item,exclude)));if(obj&&"object"==typeof obj){const result={};for(const[key,value]of Object.entries(obj))"function"==typeof value||exclude&&exclude.includes(key)||(result[key]=getOggetto(value,exclude));return result}return obj}async function evalcustomfunction(amb,code,values,objects){try{values||(values={}),objects||(objects={});const params={GCAD:!1,...values,A:amb,V:amb.vari,amb:amb,info3d:async function info3d(file,scale=1,scaley=0,scalez=0){if(amb.gcad)return await amb.gcad.info3d(file,scale,scaley,scalez)},gcad:amb.gcad,log:function addlog(...pars){const sanitized=pars.map((p=>getOggetto(p)));console.log(...sanitized)},Math:Math,getcolonne:getcolonne,clean:clean,SP:SP,seeder:seeder,seedarray:seedarray,Punto2:Punto2,Linea2:Linea2,clamp:clamp,hash:hash,PIF:PIF,getshape:getshape,shapeclip:shapeclip,...objects},paramNames=[...Object.keys(params),...Object.keys(blocked)],paramValues=[...Object.values(params),...Object.values(blocked)],fn=new Function(...paramNames,`\n try {\n return (async () => {\n ${code}\n })();\n } catch (err) {\n err.stack = '[SCRIPT] ' + err.stack;\n throw err;\n }`);return await fn(...paramValues)}catch(error){throw console.error("Errore durante l'esecuzione:",error),error}}function setLineColorMode(white,isdark){white?(materialline1.color.set(16777215),materialline2.color.set(16777215)):isdark?(materialline1.color.set(7368816),materialline2.color.set(6316128)):(materialline1.color.set(3158064),materialline2.color.set(5263440)),materialline1.needsUpdate=!0,materialline2.needsUpdate=!0}export{Linea2,Matrix3D,PIF,Punto2,SIDE,SP,TODEG,TORAD,Vis2d,Vobject,Vscene,addmovpivot,angle2vec,angle3point,blocked,calcolatasks,clamp,clean,creategroup,deletegroup,dxfbulge,edgesfromgeometry,elaborapercorso,errorescript,estruso,estrusopat,evalcustomfunction,evidenziaColli,extractTextures,get3dshape,getOggetto,getbb,getbordi,getbox,getcilindro,getcyl,getdumpmacro,getemitter,getextrude,getface,getfakeshadow,getfakeshadow2,getline,getlinesgeom,getluce,getmesh,getmovimento,getnodebyid,getpannello,getpannello2,getpoint,getptsoffset,getpunto,getquota,getreceiver,getriferimento,getshape,getsphere,getsprite,getsubrules,gettarghetta,getthorus,groupfromgeometry,hash,infoestrudi,isfn,ismacro,joinlinestoshapes,mapvertices,materialline1,materialline2,mblack,mblue,mgray1,mgray2,mgreen,mred,mwhite,newgcad,normal2,posiziona,raccordabezier,randombasemat,revolve,ripristinaMaterialiOriginali,salvaMaterialiOriginali,scalaoggetto,scaleunit,seedarray,seeder,setLineColorMode,setorigine,shapeclip,smat,spritemat,svuotanodo,texgen,valutagrafica};
1
+ import*as e from"three";import{TrianglesDrawMode as t,TriangleFanDrawMode as i,TriangleStripDrawMode as n,Loader as r,LoaderUtils as o,FileLoader as s,MeshPhysicalMaterial as A,Vector2 as a,Color as l,LinearSRGBColorSpace as c,SRGBColorSpace as p,SpotLight as h,PointLight as g,DirectionalLight as u,Matrix4 as d,Vector3 as f,Quaternion as I,InstancedMesh as m,InstancedBufferAttribute as b,Object3D as C,TextureLoader as B,ImageBitmapLoader as y,BufferAttribute as E,InterleavedBuffer as x,InterleavedBufferAttribute as P,LinearMipmapLinearFilter as w,NearestMipmapLinearFilter as v,LinearMipmapNearestFilter as D,NearestMipmapNearestFilter as S,LinearFilter as L,NearestFilter as M,RepeatWrapping as T,MirroredRepeatWrapping as _,ClampToEdgeWrapping as F,PointsMaterial as k,Material as R,LineBasicMaterial as N,MeshStandardMaterial as G,DoubleSide as O,MeshBasicMaterial as Y,PropertyBinding as U,BufferGeometry as X,SkinnedMesh as q,Mesh as H,LineSegments as z,Line as j,LineLoop as J,Points as W,Group as K,PerspectiveCamera as V,MathUtils as Z,OrthographicCamera as $,Skeleton as ee,AnimationClip as te,Bone as ie,InterpolateDiscrete as ne,InterpolateLinear as re,Texture as oe,VectorKeyframeTrack as se,NumberKeyframeTrack as Ae,QuaternionKeyframeTrack as ae,ColorManagement as le,FrontSide as ce,Interpolant as pe,Box3 as he,Sphere as ge,CompressedCubeTexture as ue,UnsignedByteType as de,CompressedArrayTexture as fe,CompressedTexture as Ie,DisplayP3ColorSpace as me,LinearDisplayP3ColorSpace as be,NoColorSpace as Ce,RGBA_ASTC_6x6_Format as Be,RedFormat as ye,RGFormat as Ee,RGBAFormat as xe,HalfFloatType as Qe,FloatType as Pe,DataTexture as we,Data3DTexture as ve,RGBA_S3TC_DXT1_Format as De,RGB_PVRTC_4BPPV1_Format as Se,RGB_ETC2_Format as Le,RGB_ETC1_Format as Me,RGBA_S3TC_DXT5_Format as Te,RGBA_PVRTC_4BPPV1_Format as _e,RGBA_ETC2_EAC_Format as Fe,RGBA_BPTC_Format as ke,RGBA_ASTC_4x4_Format as Re,MeshPhongMaterial as Ne,AdditiveBlending as Ge,Float32BufferAttribute as Oe}from"three";class Matrix3D{constructor(){this.m=new Float32Array(16),this.st=[],this.init()}init(){return this.m.fill(0),this.m[0]=this.m[5]=this.m[10]=this.m[15]=1,this}atranslate(e,t,i){return this.m[12]+=e,this.m[13]+=t,this.m[14]+=i,this}translate(e,t,i){return e??=0,t??=0,i??=0,this.m[12]+=e*this.m[0]+t*this.m[4]+i*this.m[8],this.m[13]+=e*this.m[1]+t*this.m[5]+i*this.m[9],this.m[14]+=e*this.m[2]+t*this.m[6]+i*this.m[10],this.m[15]+=e*this.m[3]+t*this.m[7]+i*this.m[11],this}rotateX(e){if(e){const t=(e||0)*Math.PI/180,i=Math.sin(t),n=Math.cos(t),r=[...this.m];this.m[1]=r[1]*n+r[9]*i,this.m[2]=r[2]*n+r[10]*i,this.m[3]=r[3]*n+r[11]*i,this.m[9]=r[1]*-i+r[9]*n,this.m[10]=r[2]*-i+r[10]*n,this.m[11]=r[3]*-i+r[11]*n}return this}rotateY(e){if(e){const t=(e||0)*Math.PI/180,i=Math.sin(t),n=Math.cos(t),r=[...this.m];this.m[0]=r[0]*n+r[8]*i,this.m[1]=r[1]*n+r[9]*i,this.m[2]=r[2]*n+r[10]*i,this.m[3]=r[3]*n+r[11]*i,this.m[8]=r[0]*-i+r[8]*n,this.m[9]=r[1]*-i+r[9]*n,this.m[10]=r[2]*-i+r[10]*n,this.m[11]=r[3]*-i+r[11]*n}return this}rotateZ(e){if(e){const t=(e||0)*Math.PI/180,i=Math.sin(t),n=Math.cos(t),r=[...this.m];this.m[0]=r[0]*n+r[4]*i,this.m[1]=r[1]*n+r[5]*i,this.m[2]=r[2]*n+r[6]*i,this.m[3]=r[3]*n+r[7]*i,this.m[4]=r[0]*-i+r[4]*n,this.m[5]=r[1]*-i+r[5]*n,this.m[6]=r[2]*-i+r[6]*n,this.m[7]=r[3]*-i+r[7]*n}return this}getdati(){return Array.from(this.m)}setdati(e){if(e&&16===e.length){for(let t=0;t<16;t++)this.m[t]=Number(e[t])||0;return this}this.init()}push(){return this.st.push(new Float32Array(this.m)),this}pop(){return this.st.length>0&&(this.m=this.st.pop()),this}transform(e,t,i=0){return{x:e*this.m[0]+t*this.m[4]+i*this.m[8]+this.m[12],y:e*this.m[1]+t*this.m[5]+i*this.m[9]+this.m[13],z:e*this.m[2]+t*this.m[6]+i*this.m[10]+this.m[14]}}invert(){const e=this.m,t=new Matrix3D,i=this.determinant();return Math.abs(i)<1e-8?null:(t.m[0]=(e[5]*e[10]*e[15]+e[9]*e[14]*e[7]+e[13]*e[6]*e[11]-e[5]*e[14]*e[11]-e[9]*e[6]*e[15]-e[13]*e[10]*e[7])/i,t.m[1]=(e[1]*e[14]*e[11]+e[9]*e[2]*e[15]+e[13]*e[10]*e[3]-e[1]*e[10]*e[15]-e[9]*e[14]*e[3]-e[13]*e[2]*e[11])/i,t.m[2]=(e[1]*e[6]*e[15]+e[5]*e[14]*e[3]+e[13]*e[2]*e[7]-e[1]*e[14]*e[7]-e[5]*e[2]*e[15]-e[13]*e[6]*e[3])/i,t.m[3]=(e[1]*e[10]*e[7]+e[5]*e[2]*e[11]+e[9]*e[6]*e[3]-e[1]*e[6]*e[11]-e[5]*e[10]*e[3]-e[9]*e[2]*e[7])/i,t.m[4]=(e[4]*e[14]*e[11]+e[8]*e[6]*e[15]+e[12]*e[10]*e[7]-e[4]*e[10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12]*e[1]*e[6])/i,t.m[15]=(e[0]*e[5]*e[10]+e[4]*e[9]*e[2]+e[8]*e[1]*e[6]-e[0]*e[9]*e[6]-e[4]*e[1]*e[10]-e[8]*e[5]*e[2])/i,t)}determinant(){const e=this.m;return e[0]*(e[5]*e[10]*e[15]+e[9]*e[14]*e[7]+e[13]*e[6]*e[11]-e[5]*e[14]*e[11]-e[9]*e[6]*e[15]-e[13]*e[10]*e[7])-e[4]*(e[1]*e[10]*e[15]+e[9]*e[14]*e[3]+e[13]*e[2]*e[11]-e[1]*e[14]*e[11]-e[9]*e[2]*e[15]-e[13]*e[10]*e[3])+e[8]*(e[1]*e[6]*e[15]+e[5]*e[14]*e[3]+e[13]*e[2]*e[7]-e[1]*e[14]*e[7]-e[5]*e[2]*e[15]-e[13]*e[6]*e[3])-e[12]*(e[1]*e[6]*e[11]+e[5]*e[10]*e[3]+e[9]*e[2]*e[7]-e[1]*e[10]*e[7]-e[5]*e[2]*e[11]-e[9]*e[6]*e[3])}multiply(e){const t=[...this.m],i=e.m;return this.m[0]=t[0]*i[0]+t[4]*i[1]+t[8]*i[2]+t[12]*i[3],this.m[1]=t[1]*i[0]+t[5]*i[1]+t[9]*i[2]+t[13]*i[3],this.m[2]=t[2]*i[0]+t[6]*i[1]+t[10]*i[2]+t[14]*i[3],this.m[3]=t[3]*i[0]+t[7]*i[1]+t[11]*i[2]+t[15]*i[3],this.m[4]=t[0]*i[4]+t[4]*i[5]+t[8]*i[6]+t[12]*i[7],this.m[5]=t[1]*i[4]+t[5]*i[5]+t[9]*i[6]+t[13]*i[7],this.m[6]=t[2]*i[4]+t[6]*i[5]+t[10]*i[6]+t[14]*i[7],this.m[7]=t[3]*i[4]+t[7]*i[5]+t[11]*i[6]+t[15]*i[7],this.m[8]=t[0]*i[8]+t[4]*i[9]+t[8]*i[10]+t[12]*i[11],this.m[9]=t[1]*i[8]+t[5]*i[9]+t[9]*i[10]+t[13]*i[11],this.m[10]=t[2]*i[8]+t[6]*i[9]+t[10]*i[10]+t[14]*i[11],this.m[11]=t[3]*i[8]+t[7]*i[9]+t[11]*i[10]+t[15]*i[11],this.m[12]=t[0]*i[12]+t[4]*i[13]+t[8]*i[14]+t[12]*i[15],this.m[13]=t[1]*i[12]+t[5]*i[13]+t[9]*i[14]+t[13]*i[15],this.m[14]=t[2]*i[12]+t[6]*i[13]+t[10]*i[14]+t[14]*i[15],this.m[15]=t[3]*i[12]+t[7]*i[13]+t[11]*i[14]+t[15]*i[15],this}}const Ye=.001;class Punto2{constructor(e,t){Array.isArray(e)?(this.x=e[0]||0,this.y=e[1]||0):e&&"object"==typeof e?(this.x=e.x||0,this.y=e.y||0):(this.x=e||0,this.y=t||0)}get dump(){return`{${this.x.toFixed(1)},${this.y.toFixed(1)}}`}get len2(){return this.x*this.x+this.y*this.y}get len(){return Math.sqrt(this.len2)}get angle(){return Math.atan2(this.y,this.x)}dir(){let e=this.len;return e?new Punto2(this.x/e,this.y/e):this}distanza(e){return new Punto2(e.x-this.x,e.y-this.y).len}}class Linea2{constructor(e,t,i=null,n=null){"number"==typeof e&&"number"==typeof t&&null!==i&&null!==n?(this.p1=new Punto2({x:e,y:t}),this.p2=new Punto2({x:i,y:n})):e&&t?(this.p1=new Punto2(e),this.p2=new Punto2(t)):(this.p1=new Punto2(0,0),this.p2=new Punto2(1,0))}get dump(){return`${this.p1.dump}-${this.p2.dump}`}get dx(){return this.p2.x-this.p1.x}get dy(){return this.p2.y-this.p1.y}get len2(){let{dx:e,dy:t}=this;return e*e+t*t}get len(){return Math.sqrt(this.len2)}get angle(){return this.angolo()}estendi(e){if("number"==typeof e){if(!e)return this;let{p1:t,p2:i,dx:n,dy:r,len:o}=this;return o?(n/=o,r/=o,e>0?new Linea2(t,new Punto2(i.x+n*e,i.y+r*e)):new Linea2(new Punto2(t.x+n*e,t.y+r*e),i)):this}if(e instanceof Linea2){const t=this.interseca(e);if(!t)return this;return(t.x-this.p1.x)**2+(t.y-this.p1.y)**2<(t.x-this.p2.x)**2+(t.y-this.p2.y)**2?new Linea2(t,this.p2):new Linea2(this.p1,t)}}puntot(e){return new Punto2(this.p1.x+(this.p2.x-this.p1.x)*e,this.p1.y+(this.p2.y-this.p1.y)*e)}setlunghezza(e){let t=this.len;if(t&&e){let i=e/t,n=this.puntot(i);this.p2=n}}proiezionet(e){const{p1:t,dx:i,dy:n,len2:r}=this;if(r<Ye)return;const o=((e.x-t.x)*i+(e.y-t.y)*n)/r;return{p:new Punto2(t.x+o*i,t.y+o*n),t:o}}proiezione(e){const t=this.proiezionet(e);return t?t.p:void 0}get direzione(){let{dx:e,dy:t,len:i}=this;return i?new Punto2(e/i,t/i):new Punto2(0,0)}get normale(){let{dx:e,dy:t,len:i}=this;return i?new Punto2(-t/i,e/i):new Punto2(0,1)}perpendicolare(e=null,t=0){const{normale:i,len:n,p1:r}=this;if(n<1e-9)return;const o=t||n,s=e?new Punto2(e):this.p1;return new Linea2(s,new Punto2(s.x+i.x*o,s.y+i.y*o))}perpendicolaret(e,t=0){const{normale:i,len:n,p1:r,p2:o}=this;if(n<1e-9)return;const s=t||n,A=new Punto2(r.x+(o.x-r.x)*e,r.y+(o.y-r.y)*e);return new Linea2(A,new Punto2(A.x+i.x*s,A.y+i.y*s))}ruotata(e=Math.PI/2,t=0,i=!1){const{p1:n,p2:r,direzione:o,len:s}=this;if(t=t||s,s<1e-9)return;const A=Math.abs(e%(2*Math.PI));if(!(A<1e-9||Math.abs(A-Math.PI)<1e-9)){if("boolean"==typeof i){const s=(o.x*Math.cos(e)-o.y*Math.sin(e))*t,A=(o.x*Math.sin(e)+o.y*Math.cos(e))*t;return i?new Linea2(n,new Punto2(n.x+s,n.y+A)):new Linea2(r,new Punto2(r.x+s,r.y+A))}{let n=new Punto2(i);const r=o.x*Math.cos(e)-o.y*Math.sin(e),s=o.x*Math.sin(e)+o.y*Math.cos(e);new Punto2(r,s);const A=new Linea2(n,new Punto2(n.x+r,n.y+s)),a=this.interseca(A);if(!a)return;const l=new Punto2(a.x+r*t,a.y+s*t);return new Linea2(a,l)}}}puntosudirezione(e,t){let{direzione:i}=this;return new Punto2(e.x+i.x*t,e.y+i.y*t)}parallela(e,t){let{direzione:i}=this;return new Linea2(e,this.puntosudirezione(e,t))}intersezione(e){return this.interseca(e)}interseca(e){const{p1:t,p2:i}=this,{p1:n,p2:r}=e,o=(i.x-t.x)*(r.y-n.y)-(i.y-t.y)*(r.x-n.x);if(Math.abs(o)<Ye)return null;const s=((n.x-t.x)*(r.y-n.y)-(n.y-t.y)*(r.x-n.x))/o;return new Punto2(t.x+s*(i.x-t.x),t.y+s*(i.y-t.y))}onsegment(e,t=1e-9){const{p1:i,p2:n}=this,r=Math.min(i.x,n.x)-t,o=Math.max(i.x,n.x)+t,s=Math.min(i.y,n.y)-t,A=Math.max(i.y,n.y)+t;return e.x>=r&&e.x<=o&&e.y>=s&&e.y<=A}distanzaPunto(e){const t=this.proiezione(e);if(!t)return 1e9;const i=e.x-t.x,n=e.y-t.y;return Math.hypot(i,n)}isparallela(e){const t=this.dx*e.dy-this.dy*e.dx;return Math.abs(t)<1}lunghezzatotale(e){const t=this.p2.x-this.p1.x,i=this.p2.y-this.p1.y,n=Math.hypot(t,i);if(!n)return 0;const r=1/n,proj=e=>(e.x*t+e.y*i)*r,o=proj(this.p1),s=proj(this.p2),A=proj(e.p1),a=proj(e.p2),l=o<s?o:s,c=o>s?o:s,p=A<a?A:a,h=A>a?A:a;return Math.round(100*(Math.max(c,h)-Math.min(l,p)))/100}infoquad(e){if(!this.isparallela(e))return;const{p1:t,p2:i,normale:n}=this;let{p1:r,p2:o}=e;const distance2=(e,t)=>(e.x-t.x)**2+(e.y-t.y)**2;function wrapToPi(e){return e>Math.PI?e-=2*Math.PI:e<-Math.PI&&(e+=2*Math.PI),e}function getangle(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}distance2(t,r)>distance2(t,o)&&([r,o]=[o,r]);const s=getangle(t,i);function toDeg(e){return Math.round(18e4*e/Math.PI)/1e3}const A=toDeg(wrapToPi(getangle(t,r)-s)),a=toDeg(wrapToPi(getangle(i,o)-s)),l=Math.round(100*this.len)/100,c=r.x-t.x,p=r.y-t.y,h=Math.round(100*Math.abs(c*n.x+p*n.y))/100;let g=this.lunghezzatotale(e);return{angle:toDeg(s),aini:A,afin:a,l:l,ltot:g,distanza:h,sx:Math.round(100*t.x)/100,sy:Math.round(100*t.y)/100}}isperpendicolare(e){const t=this.dx*e.dx+this.dy*e.dy;return Math.abs(t)<Ye}offset(e){const t=this.normale,i=new Punto2(this.p1.x+t.x*e,this.p1.y+t.y*e),n=new Punto2(this.p2.x+t.x*e,this.p2.y+t.y*e);return new Linea2(i,n)}angolo(e){const{dx:t,dy:i}=this;let n;if(e){const{dx:r,dy:o}=e,s=Math.atan2(i,t);n=Math.atan2(o,r)-s}else n=Math.atan2(i,t);return n>Math.PI?n-=2*Math.PI:n<-Math.PI&&(n+=2*Math.PI),n}ortopt(e){let{p1:t,dx:i,dy:n}=this;const r=Math.hypot(i,n);if(r<Ye)return;const o=-n/r,s=i/r;return{x:t.x+o*e,y:t.y+s*e}}offsetline(e){let{p1:t,p2:i,dx:n,dy:r}=this;const o=Math.hypot(n,r);if(o<Ye)return;const s=-r/o,A=n/o;return new Linea2({x:t.x+s*e,y:t.y+A*e},{x:i.x+s*e,y:i.y+A*e})}distanzaSegmentiParalleli(e){if(!this.isparallela(e))return 1e9;const{p1:t,normale:i}=this,n=e.p1.x-t.x,r=e.p1.y-t.y,o=Math.abs(n*i.x+r*i.y);return Math.abs(o)<Ye?0:o}isCollineare(e,t=!1){if(!this.isparallela(e))return!1;const i=this.distanzaSegmentiParalleli(e);if(Math.abs(i)>Ye)return!1;if(t){function isPointBetween(e,t,i,n=Ye){const r=(i.x-t.x)*(e.y-t.y)-(i.y-t.y)*(e.x-t.x);return!(Math.abs(r)>n)&&(Math.min(t.x,i.x)-n<=e.x&&e.x<=Math.max(t.x,i.x)+n&&Math.min(t.y,i.y)-n<=e.y&&e.y<=Math.max(t.y,i.y)+n)}const{p1:n,p2:r}=this,{p1:o,p2:s}=e;return isPointBetween(o,n,r)||isPointBetween(s,n,r)||isPointBetween(n,o,s)||isPointBetween(r,o,s)}return!0}clone(){return new Linea2(this.p1.x,this.p1.y,this.p2.x,this.p2.y)}rotate(e){if(!e)return this;const t=e*Math.PI/180,i=Math.cos(t),n=Math.sin(t);function rotate(e){return new Punto2(e.x*i-e.y*n,e.x*n+e.y*i)}return this.p1=rotate(this.p1),this.p2=rotate(this.p2),this}move(e=0,t=0){return"object"==typeof e&&e.x&&(t=e.y||0,e=e.x),this.p1.x+=e,this.p1.y+=t,this.p2.x+=e,this.p2.y+=t,this}}function getptsoffset(e,t,i){let n,r,o,s,A=-1,a=-1,l=e.length,c=t.length,p=[],h=new Linea2(e[0],e[1]),g=new Linea2(e[l-2],e[l-1]),u=h.offset(i),d=g.offset(i);for(let e=0;e<c;e++){let i=new Linea2(t[e%c],t[(e+1)%c]);u.isparallela(i)&&u.isCollineare(i,!0)&&(A=e),d.isparallela(i)&&d.isCollineare(i,!0)&&(a=e)}if(A>=0&&a>=0){A>a?(n=A-a+2,r=a+c-A+2,n<r?(o=a,s=A+1):(o=A,s=a+c+1)):(n=a-A+2,r=A+c-a+2,n<r?(o=A,s=a+1):(o=a,s=A+c+1));for(let e=o;e<=s;e++)p.push(t[e%c])}return p}async function errorescript(e,t){let i,n,r,o=(t.stack||"").match(/user-script\.js:(\d+):(\d+)/);if(o||(o=(t.toString()||"").match(/user-script\.js:(\d+):(\d+)/)),o&&([,i,n]=o.map(Number),i-=2),(!i||!n)&&t instanceof SyntaxError){window.acorn||(await new Promise(((e,t)=>{const i=document.createElement("script");i.src="https://cdn.jsdelivr.net/npm/acorn@8.15.0/dist/acorn.js",i.onload=e,i.onerror=t,document.head.appendChild(i)})),console.log("caricato acorn"));try{window.acorn.parse(e,{ecmaVersion:"latest"})}catch(e){e.loc&&(i=e.loc.line,n=e.loc.column+1)}}return r=i&&n?`ERRORE: ${t.message}\n`+function extractContext(e,t,i,n=1){const r=e.split(/\r?\n/),o=t-1,s=Math.max(0,o-n),A=Math.min(r.length,o+n+1);return r.slice(s,A).map(((e,n)=>s+n+1===t?e+"\n"+" ".repeat(i-1)+"^":e)).join("\n")}(e,i,n):t.message,r}function seedarray(e,t){if(e&&e.length){let i=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.p)for(let e=0;e<n.p;e++)i.push(t);else i.push(t)}return e[i[seeder(i.length,t)]]}}function seeder(e,t="seed42"){const i=function mulberry32(e){return function(){e=(e|=0)+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}(function xmur3(e){let t=1779033703^e.length;for(let i=0;i<e.length;i++)t=Math.imul(t^e.charCodeAt(i),3432918353),t=t<<13|t>>>19;return function(){return t=Math.imul(t^t>>>16,2246822507),t=Math.imul(t^t>>>13,3266489909),(t^=t>>>16)>>>0}}(String(t))());return Math.floor(i()*e)}function hash(e){let t="";if("string"==typeof e||"number"==typeof e)t=e+"";else if("object"==typeof e&&e){const i=Object.keys(e).sort(),n="\0";t=i.map((t=>`${t}${n}${String(e[t])}`)).join(n)}let i=2166136261,n=2218511855;for(let e=0;e<t.length;e++){const r=t.charCodeAt(e);i^=r,i+=i<<5^2779096485,n^=i,n=((n<<3)+r^2134516169)>>>0}return i>>>=0,i.toString(16)+n.toString(16)}function clean(e,t=!1){return t?(e||"").trim().toLowerCase():(e||"").trim()}function getcouple(e,t="=",i=!0){const n=(e=e||"").indexOf(t);return n>=0?{v:clean(e.substring(0,n),i),o:e.substring(n+t.length).trim(),fl:!0}:{v:clean(e,i),o:"",fl:!1}}function clamp(e,t=-1/0,i=1/0){return(e=Number(e)||0)<t&&(e=t),e>i&&(e=i),e}function getcolonne(e,t=!1){e=String(e||"");const i=/^(\d*)\.\.(\d*)$/.exec(e);if(i){let e=parseInt(i[1])||0,t=parseInt(i[2])||0;const n=[];for(let i=e;i<=t;i++)n.push(i+"");return n}if(!/["({[]/.test(e))return e.split(/[,;]/).map((e=>e.trim()));const n=[];let r="",o=0,s=!1;for(let t=0;t<e.length;t++){const i=e[t];if(0===o&&'"'===i&&(0!==t&&"\\"===e[t-1]||(s=!s)),s||("("===i||"["===i||"{"===i?o++:")"!==i&&"]"!==i&&"}"!==i||(o=Math.max(0,o-1))),","!==i&&";"!==i||0!==o||s)r+=i;else{const e=r.trim();n.push(e),r=""}}const A=r.trim();return A&&n.push(A),n.map((e=>(e=e.trim(),!t&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("(")&&e.endsWith(")"))?e.slice(1,-1):e)))}function muClComments(e,t){const i=(n=e,n.replace(/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')|\/\*[\s\S]*?\*\//g,((e,t)=>t||""))).split(/\r?\n/);var n;const r=[];let o="";for(const e of i){let t=e;if(/(^|[^:])\/\/.*/.test(t)&&(t=t.replace(/(^|[^:])\/\/.*/,((e,t)=>t.trim()))),t=t.trim(),0!==t.length)if(o.length>0&&(t=o+" "+t,o=""),t.endsWith("\\")){t=t.slice(0,-1);const e=t.lastIndexOf("//");-1!==e&&(t=t.slice(0,e).trim()),o=t}else r.push(t)}return r}new class Errori{constructor(){this.azzera()}azzera(){this.err=[]}add(e,t){this.err.push({msg:e,row:t})}get(){return this.err}get length(){return this.err.length}toString(){const e=[];for(const t of this.err){const i="object"==typeof t.msg?JSON.stringify(t.msg):t.msg||"";e.push(`${t.row?t.row+":":""}${i}`)}return e.join("\n")}};const Ue=Math.PI/180;function TODEG(e,t=1){let i=10**t;return Math.round(180*e*i/Math.PI)/i}function TORAD(e,t=3){let i=10**t;return Math.round(e*Ue*i)/i}const Xe={window:void 0,self:void 0,globalThis:void 0,document:void 0,Function:void 0,eval:void 0,fetch:void 0,XMLHttpRequest:void 0};function getOggetto(e,t=[]){if(Array.isArray(e))return e.map((e=>getOggetto(e,t)));if(e&&"object"==typeof e){const i={};for(const[n,r]of Object.entries(e))"function"==typeof r||t&&t.includes(n)||(i[n]=getOggetto(r,t));return i}return e}function getSqDist(e,t){let i=e.x-t.x,n=e.y-t.y;return i*i+n*n}function getSqSegDist(e,t,i){let n=t.x,r=t.y,o=i.x-n,s=i.y-r;if(0!==o||0!==s){let t=((e.x-n)*o+(e.y-r)*s)/(o*o+s*s);t>1?(n=i.x,r=i.y):t>0&&(n+=o*t,r+=s*t)}return o=e.x-n,s=e.y-r,o*o+s*s}function simplifyDPStep(e,t,i,n,r){let o,s=n;for(let n=t+1;n<i;n++){let r=getSqSegDist(e[n],e[t],e[i]);r>s&&(o=n,s=r)}s>n&&(o-t>1&&simplifyDPStep(e,t,o,n,r),r.push(e[o]),i-o>1&&simplifyDPStep(e,o,i,n,r))}function simplifyDouglasPeucker(e,t){let i=e.length-1,n=[e[0]];return simplifyDPStep(e,0,i,t,n),n.push(e[i]),n}function simplify(e,t,i){if(e.length<=2)return e;let n=void 0!==t?t*t:1;return e=i?e:function simplifyRadialDist(e,t){let i,n=e[0],r=[n];for(let o=1,s=e.length;o<s;o++)i=e[o],getSqDist(i,n)>t&&(r.push(i),n=i);return n!==i&&r.push(i),r}(e,n),e=simplifyDouglasPeucker(e,n)}function mapvertices(e,t){const dist2=(e,t)=>(e.x-t.x)**2+(e.y-t.y)**2;let i=e.length,n=t.length;if(i<2||n<2)return[];let r=[[0,0]];if(i===n){for(let e=1;e<i;e++)r.push([e,e]);return r}if(i>n)for(let o=1,s=0;o<i-1;o++){if(s+1<n){const i=e[o],n=dist2(i,t[s]);dist2(i,t[s+1])<=n&&s++}r.push([o,s])}else for(let o=1,s=0;o<n-1;o++){if(s+1<i){const i=t[o],n=dist2(i,e[s]);dist2(i,e[s+1])<=n&&s++}r.push([s,o])}return r.push([i-1,n-1]),r}function dxfbulge(e,t,i,n=0){const r=[];if(!i||Math.abs(i)<1e-10||0===n)return r;const o=4*Math.atan(i);if(o<0)return dxfbulge(t,e,-i,n).reverse();const s=t.x-e.x,A=t.y-e.y,a=Math.hypot(s,A),l=a/(2*Math.sin(o/2)),c=(e.x+t.x)/2,p=(e.y+t.y)/2,h=-A/a,g=s/a,u=l*Math.cos(o/2),d=i>=0?1:-1,f=c+d*h*u,I=p+d*g*u;let m=Math.atan2(e.y-I,e.x-f);for(let e=1;e<=n;e++){const t=m+e/(n+1)*o,i=f+l*Math.cos(t),s=I+l*Math.sin(t);r.push({x:i,y:s})}return r}function raccordabezier(e,t,i,n,r=10){const o=function getIntersection(e,t,i,n){const r=(e.x-t.x)*(i.y-n.y)-(e.y-t.y)*(i.x-n.x);return 0===r?null:{x:((e.x*t.y-e.y*t.x)*(i.x-n.x)-(e.x-t.x)*(i.x*n.y-i.y*n.x))/r,y:((e.x*t.y-e.y*t.x)*(i.y-n.y)-(e.y-t.y)*(i.x*n.y-i.y*n.x))/r}}(e,t,i,n);if(!o)return[{x:t.x,y:t.y},{x:i.x,y:i.y}];const s=o;if(0===r)return[{x:t.x,y:t.y},{x:i.x,y:i.y}];const A=[];for(let e=0;e<=r;e++){const n=e/r,o=1-n,a=o*o*t.x+2*o*n*s.x+n*n*i.x,l=o*o*t.y+2*o*n*s.y+n*n*i.y;A.push({x:a,y:l})}return A}function raccordabezier3(e,t,i,n,r=10){const o=t.x-e.x,s=t.y-e.y,A=i.x-t.x,a=i.y-t.y,l=Math.sqrt(o*o+s*s),c=Math.sqrt(A*A+a*a);if(n>l||n>c)return[e,t,i];n!=l&&n!=c||(n-=.01);const p=(l-n)/l,h=n/c;return raccordabezier(e,{x:e.x+o*p,y:e.y+s*p},{x:t.x+A*h,y:t.y+a*h},i,r)}function normal2(e,t){const i=t.x-e.x;let n=-(t.y-e.y),r=i;const o=Math.sqrt(n*n+r*r);return 0===o?{nx:0,ny:0}:{nx:n/o,ny:r/o}}function angle3point(e,t,i){const n=t.x-e.x,r=t.y-e.y,o=i.x-t.x,s=i.y-t.y,A=n*o+r*s,a=n*s-r*o,l=Math.sqrt(n**2+r**2),c=Math.sqrt(o**2+s**2);return l&&c?Math.atan2(a,A):0}function angle2vec(e,t){const i=e.x*t.x+e.y*t.y,n=Math.sqrt(e.x*e.x+e.y*e.y),r=Math.sqrt(t.x*t.x+t.y*t.y);if(0===n||0===r)return 0;let o=i/(n*r);o=Math.max(-1,Math.min(1,o));return Math.acos(o)/Ue}function removeduplicate(e,t=.005){if(!Array.isArray(e)||0===e.length)return[];const i=[],n=e.length;for(let t=0;t<n;t++){const r=e[t],o=e[(t+1)%n];i.push({x:r.x,y:r.y}),o.x,r.x,o.y,r.y}const r=i[0],o=i[i.length-1];return r.x,o.x,r.y,o.y,i}function getshape(){let e=[];function orientation(){if(!e.length)return 0;let t=0;const i=e.length;for(let n=0;n<i;n++){const r=e[n],o=e[(n+1)%i];t+=r.x*o.y-o.x*r.y}return t>0?1:t<0?-1:0}function tovec(){return e.flatMap((e=>[e.x,e.y]))}function move(t=0,i=0){"object"==typeof t&&t.x&&(i=t.y||0,t=t.x);for(let n of e)n.x+=t,n.y+=i;return this}function selezionaprimo(t){return(t%=e.length)>0&&(e=[...e.slice(t),...e.slice(0,t)]),this}function _addvec(t){for(let i=0;i<t.length;i+=2)e.push({x:t[i],y:t[i+1]})}function fromstr(t){return e=removeduplicate(function processTokens(e){const t=[];for(let i=0;i<e.length;i++){const n=e[i];if("point"===n.type)t.push(n.point);else if("command"===n.type)switch(n.cmd){case"x":{const r=t[t.length-1],o="point"===e[i+1]?.type?e[i+1].point:t[0],s=parseFloat(n.params[0])||5;{const e=1;let i=o.x-r.x,n=o.y-r.y,A=Math.hypot(i,n);A>1&&t.push(...dxfbulge(r,o,s,Math.floor((A-e)/(e+2))+1))}break}case"b":{if(t.length<2)continue;const r=parseInt(n.params[0])||5,o=t[t.length-2],s=t[t.length-1];let A="point"===e[i+1]?.type?e[i+1].point:void 0,a="point"===e[i+2]?.type?e[i+2].point:void 0;A?a||(a=t[0]):(A=t[0],a=t[1]);const l=raccordabezier(o,s,A,a,r);t.push(...l),i+=1;break}case"r":{if(t.length<1)continue;const r=parseFloat(n.params[0])||0;if(r>0){const o=parseInt(n.params[1])||Math.min(r,10),s=t[t.length-1];let A="point"===e[i+1]?.type?e[i+1].point:void 0,a="point"===e[i+2]?.type?e[i+2].point:"point"===e[i+3]?.type?e[i+3].point:void 0;A?a||(a=t[0]):(A=t[0],a=t[1],t.splice(0,1));const l=raccordabezier3(s,A,a,r,o);t.push(...l),i+=1}break}case"c":{const r=parseFloat(n.params[0])||50,o=parseInt(n.params[1])||12,s="point"===e[i+1]?.type?e[i+1].point:new Punto2(0,0);for(let e=0;e<o;e++)t.push(new Punto2(s.x+r*Math.cos(e/o*Math.PI*2),s.y+r*Math.sin(e/o*Math.PI*2)));i+=1;break}case"a":{let r,o="point"===e[i+1]?.type?e[i+1].point:void 0,s="point"===e[i+2]?.type?e[i+2].point:void 0,A="point"===e[i+3]?.type?e[i+3].point:void 0;if(!o||!A)continue;if(s)if(n.params[0])r=clamp(parseInt(n.params[0]),1,24);else{const e=Math.hypot(A.x-o.x,A.y-o.y),t=Math.abs((s.x-o.x)*(A.y-o.y)-(A.x-o.x)*(s.y-o.y))/(2*e);r=Math.round(e*Math.sqrt(t/(e+.1))*10),r=clamp(r,1,24),r=1}else s=A,r=0;const a=arcfrom3point(r,o,s,A);t.push(...a),i+=3;break}}}return t}(function tokenize(e){const t=[],i=e.replace(/[\n\r,;]/g," ").replace(/\s+/g," ").toLowerCase().trim().split(" ").filter((e=>e.length>0));let n=0;for(;n<i.length;){const e=i[n];/^[brcax]/.test(e)?(t.push({type:"command",cmd:e[0],params:e.slice(1).split(":")}),n++):n<i.length-1&&/^-?\d+(\.\d+)?$/.test(i[n])&&/^-?\d+(\.\d+)?$/.test(i[n+1])?(t.push({type:"point",point:new Punto2(parseFloat(i[n]),parseFloat(i[n+1]))}),n+=2):n++}return t}(t))),this}function dims(e){let{p1:t,p2:i}=e.reduce(((e,t)=>(e.p1.x=Math.min(e.p1.x,t.x),e.p2.x=Math.max(e.p2.x,t.x),e.p1.y=Math.min(e.p1.y,t.y),e.p2.y=Math.max(e.p2.y,t.y),e)),{p1:new Punto2(1/0,1/0),p2:new Punto2(-1/0,-1/0)}),n=!1;if(4==e.length){const r=.001;function findpunto(t,i){let n=e.find((e=>Math.abs(e.x-t)<r&&Math.abs(e.y-i)<r));return!!n}findpunto(t.x,t.y)&&findpunto(t.x,i.y)&&findpunto(i.x,t.y)&&findpunto(i.x,i.y)&&(n=!0)}return{p1:t,p2:i,isrect:n,width:i.x-t.x,height:i.y-t.y}}return{get key(){return hash(tovec().join("\t"))},orienta:function orienta(t,i){if(!t||!i)return null;const n=i.x-t.x,r=i.y-t.y,o=180*Math.atan2(r,n)/Math.PI,s=new Matrix3D;s.rotateZ(-o),s.translate(-t.x,-t.y,0);const A=e.map((e=>s.transform(e.x,e.y)));let a=A.reduce(((e,t)=>(e.p1.x=Math.min(e.p1.x,t.x),e.p2.x=Math.max(e.p2.x,t.x),e.p1.y=Math.min(e.p1.y,t.y),e.p2.y=Math.max(e.p2.y,t.y),e)),{p1:new Punto2(1/0,1/0),p2:new Punto2(-1/0,-1/0)});return{shape:getshape().frompt(A),origine:new Punto2(t.x,t.y),angolo:o,mm:a,width:a.p2.x-a.p1.x,height:a.p2.y-a.p1.y}},rebase:function rebase(t,i=!1,n=0,r=0){const o=new Matrix3D;o.rotateZ(-t);let s=e.map((e=>o.transform(e.x,e.y))),{p1:A,p2:a,width:l,height:c}=dims(s);return i||(n=A.x,r=A.y),s=s.map((e=>new Punto2(e.x-n,e.y-r))),{shape:getshape().frompt(s),origine:new Punto2(n,r),angolo:t,width:l,height:c}},fromstr:fromstr,move:move,get pt(){return e},set pt(t){Array.isArray(t)&&(e=t)},get npt(){return e?.length||0},get vec(){return tovec()},toJSON:()=>({vec:tovec(),orient:orientation()}),get orient(){return orientation()},corners:(t=45)=>function sharpCorners(e,t=45){const i=[],n=e.length;if(n<3)return i;for(let r=0;r<n;r++){const o=e[(r-1+n)%n],s=e[r],A=e[(r+1)%n],a=s.x-o.x,l=s.y-o.y,c=A.x-s.x,p=A.y-s.y,h=Math.hypot(a,l),g=Math.hypot(c,p);if(0===h||0===g)continue;let u=(a*c+l*p)/(h*g);u=Math.max(-1,Math.min(1,u));const d=180*Math.acos(u)/Math.PI;d>t&&i.push({i:r,x:s.x,y:s.y,a:d})}return i}(e,45),clone:()=>getshape().frompt(e),dims:()=>dims(e),get area(){return Math.abs(e.reduce(((t,i,n)=>{const r=e[(n+1)%e.length];return t+(i.x*r.y-r.x*i.y)}),0)/2)},pointslink(t){let i=mapvertices(e,t.pt),n=[];for(let e of i)n[e[0]]=t.pt[e[1]];return n},alignline(t,i){return e=function stretchShapeToLine(e,t,i){if(!e?.length||!t||!i)return[];const n=e[0],r=e[e.length-1],o=r.x-n.x,s=r.y-n.y,A=Math.atan2(s,o);let a=e.map((e=>({x:e.x-n.x,y:e.y-n.y}))),l=a.map((e=>({x:e.x*Math.cos(-A)-e.y*Math.sin(-A),y:e.x*Math.sin(-A)+e.y*Math.cos(-A)})));const c={dx:i.x-t.x,dy:i.y-t.y},p=Math.sqrt(c.dx*c.dx+c.dy*c.dy)/(l[l.length-1].x||1e-8);let h=l.map((e=>({x:e.x*p,y:e.y})));const g=Math.atan2(c.dy,c.dx);let u=h.map((e=>({x:e.x*Math.cos(g)-e.y*Math.sin(g),y:e.x*Math.sin(g)+e.y*Math.cos(g)}))),d=u.map((e=>({x:e.x+t.x,y:e.y+t.y})));return d}(e,t,i),this},rotate(t){if(!t)return this;const i=t*Math.PI/180,n=Math.cos(i),r=Math.sin(i);for(let t of e){const e=t.x*n-t.y*r,i=t.x*r+t.y*n;t.x=e,t.y=i}return this},selezionaprimo:selezionaprimo,segment(t,i=!1){let n=e.length;return t<0&&(t+=n),new Linea2(e[t%n],e[(t+(i?-1:1))%n])},lineoffset(t,i,n){if((t=(t||0)%e.length)!=(i=(i||0)%e.length)){let r=new Linea2(e[t],e[i]);if(r){return r=r.offsetline(-n),this.intersectline(r)}}},orientasplitter(){-1!=orientation()&&e.reverse();let t=e.length;for(let i=0;i<t;i++){let n=new Linea2(e[(t+i-1)%t],e[i]);if(Math.abs(Math.abs(n.angle)-Math.PI)<.001){i&&selezionaprimo(i);break}}return this},mirrorx(t=0){for(let i of e)i.x=2*t-i.x;return this},mirrory(t=0){for(let i of e)i.y=2*t-i.y;return this},simplify(t,i){return e=simplify(e,t,i),this},fromclip(t){e=[];for(let i of t)e.push({x:i.x/1e3,y:i.y/1e3});return this},infosegmento(t,i=!1){const n=e.length;function clampIndex(e){return(e+n)%n}function angle(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}function angleDiff(e,t){let i=e-t;for(;i>Math.PI;)i-=2*Math.PI;for(;i<-Math.PI;)i+=2*Math.PI;return i}const r=e[t];let o,s,A;if(i)if(0===t){const t=e[1].x-e[0].x,i=e[1].y-e[0].y;o={x:e[0].x-t,y:e[0].y-i},s=e[1],A=2==n?{x:e[1].x+t,y:e[1].y+i}:e[2]}else if(t===n-1){const t=e[n-1].x-e[n-2].x,i=e[n-1].y-e[n-2].y;o=e[n-2],s={x:e[n-1].x+t,y:e[n-1].y+i},A={x:s.x+t,y:s.y+i}}else o=e[t-1],s=e[t+1],A=t+2<n?e[t+2]:{x:e[t+1].x+(e[t+1].x-e[t].x),y:e[t+1].y+(e[t+1].y-e[t].y)};else{const i=clampIndex(t-1),n=clampIndex(t+1),r=clampIndex(t+2);o=e[i],s=e[n],A=e[r]}const a=angle(r,s),l=angle(o,r),c=angle(s,A);return{x:r.x,y:r.y,l:function length(e,t){const i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)}(r,s),ang:a/Ue,a1:angleDiff(a,l)/Ue,a2:angleDiff(c,a)/Ue}},swapxy(){for(let t=0;t<e.length;t++){let i=e[t].x;e[t].x=-e[t].y,e[t].y=-i}return this},fromvec(t){return e=[],_addvec(t),this},addvec(e){return _addvec(e),this},frompt(t){return e=[...t],e=removeduplicate(e),this},fromdxfvec(t){let i=[];if(t&&t.length)for(let e=0;e<t.length;e++){let{x:n,y:r,bulge:o}=t[e];if(i.push({x:n,y:r}),o){const s=1;let A={x:n,y:r},a=t[(e+1)%t.length],l=a.x-A.x,c=a.y-A.y,p=Math.hypot(l,c);p>s&&i.push(...dxfbulge(A,a,o,Math.floor((p-s)/s)+1))}}return e=i.map((e=>({x:Math.round(10*e.x)/10,y:Math.round(10*e.y)/10}))),e=removeduplicate(e),this},monotona(){let t=dims(e),i=e.map((e=>({x:e.x-t.p2.x,y:e.y}))),n=[];n.push(i[0]);let r=i[0].y,o=1e-4;for(let e=1;e<i.length;e++)if(i[e].y>r+o||e==i.length-1)n.push(i[e]),r=i[e].y;else{const t=r+o;n.push({x:i[e].x,y:t}),r=t}return{sh:getshape().frompt(n),...t}},offsetshape(e){let t=[],i=this;for(let n=0;n<i.npt-1;n++){let r=i.segment(n).offset(e);t.push(r)}let n=i.segment(0).perpendicolare(),r=i.segment(i.npt-2),o=r.perpendicolare(r.p2),s=[n.interseca(t[0])];for(let e=0;e<t.length-1;e++){let i=t[e].interseca(t[e+1]);i&&s.push(i)}return s.push(t[t.length-1].interseca(o)),getshape().frompt(s)},sliceony(t){let i=t.pt.map((e=>e.y)).slice(1,-1);const n=[],r=e.length;let o=0,s=e[0].y;for(let t=1;t<r;t++)e[t].y<s&&(s=e[t].y,o=t);const A=[...e.slice(o),...e.slice(0,o)],a=A.length,l=new Map;for(let e=0;e<a;e++)for(let t of i)Math.abs(A[e].y-t)<1e-5&&(l.has(t)?l.get(t).i2=e:l.set(t,{i1:e,i2:e}));const c=i.map((e=>l.get(e))).filter((e=>e&&e.i1>=0&&e.i2>=0));c.length>0&&c[0].i1>0&&n.push([...A.slice(0,c[0].i1+1),...A.slice(c[0].i2,c[0].length)]);for(let e=0;e<c.length-1;e++){const t=c[e],i=c[e+1];n.push([...A.slice(t.i1,i.i1+1),...A.slice(i.i2,t.i2+1)])}const p=c[c.length-1];p.i2>p.i1&&n.push(A.slice(p.i1,p.i2+1));return n.filter((e=>e.length>0))},splitshape(e,t=!0){const i=100,n=t?{x:e.x,y:e.y-i}:{x:e.x-i,y:e.y},r=t?{x:e.x,y:e.y+i}:{x:e.x+i,y:e.y},o=this.intersectline(new Linea2(n,r));if(!o)return null;const s=o.p1,A=o.p2,findIndex=e=>this.pt.findIndex(((t,i)=>new Linea2(t,this.pt[(i+1)%this.pt.length]).onsegment(e))),a=findIndex(s),l=findIndex(A);if(a<0||l<0)return null;const c=this.pt.length,loop=(e,t,i,n)=>{const r=[];for(let i=e;i!==t;i=(i+1)%c)r.push(this.pt[(i+1)%c]);return r},p=getshape().frompt(loop(a,l));return{sx:getshape().frompt(loop(l,a)),dx:p,linea:o}},xfromy(e,t=0,i=!0){const n=[],r=this.pt.length;for(let t=0;t<r-1;t++){const r=this.pt[t],o=this.pt[t+1];if(r.y<=e&&o.y>=e||o.y<=e&&r.y>=e){const t=o.y-r.y,i=t?(e-r.y)/t:0,s=r.x+i*(o.x-r.x);n.push(s)}else r.y===e&&o.y===e&&n.push(i?Math.max(r.x,o.x):Math.min(r.x,o.x))}return n.length?i?Math.max(...n):Math.min(...n):t},yfromx(e,t=0,i=!0){const n=[],r=this.pt.length;for(let t=0;t<r-1;t++){const r=this.pt[t],o=this.pt[t+1];if(r.x<=e&&o.x>=e||o.x<=e&&r.x>=e){const t=o.x-r.x,i=t?(e-r.x)/t:0,s=r.y+i*(o.y-r.y);n.push(s)}else r.x===e&&o.x===e&&n.push(i?Math.max(r.y,o.y):Math.min(r.y,o.y))}return n.length?i?Math.max(...n):Math.min(...n):t},forcevalues(t,i=!0,n=1e-6){const r=[...new Set(t.pt.map((e=>i?e.y:e.x)))].sort(((e,t)=>e-t)),o=[],s=e.length;for(let t=0;t<s;t++){const A=e[t],a=e[(t+1)%s];o.push({...A});let l=i?A.y:A.x,c=i?a.y:a.x;if(l===c)continue;const p=c>l?r.filter((e=>e>l+n&&e<c-n)):r.filter((e=>e<l-n&&e>c+n)).reverse();for(const e of p){const t=(e-l)/(c-l),i={x:A.x+t*(a.x-A.x),y:A.y+t*(a.y-A.y)};o.push(i)}}return e=o,this},fromrrect(e,t,i=10,n=0,r=0){return(i>=e/2||i>=t/2&&i<=0)&&(i=Math.round(Math.min(e/3,t/3))),fromstr(`0,0,r${i},${e},0,r${i},${e},${t},r${i},0,${t},r${i}`),(n||r)&&move(n,r),this},fromrect(t,i,n,r,o){t||(t=10),i||(i=10),o||(o=0),o=Math.min(Math.abs(o),Math.abs(.4*t),Math.abs(.4*i));let s=t>0?o:-o,A=i>0?o:-o;return e=o?[{x:s,y:0},{x:t-s,y:0},{x:t,y:A},{x:t,y:i-A},{x:t-s,y:i},{x:s,y:i},{x:0,y:i-A},{x:0,y:A}]:[{x:0,y:0},{x:t,y:0},{x:t,y:i},{x:0,y:i}],this},intersectline:t=>function _intersectline(e,t,i){let n=e.length,r=new Linea2(t,i);const o=[];for(let t=0;t<e.length;t++){let i=new Linea2(e[t],e[(t+1)%n]),s=i.interseca(r);s&&i.onsegment(s)&&o.push(s)}if(o.length<2)return null;const{dx:s,dy:A}=r;o.sort(((e,i)=>(e.x-t.x)*s+(e.y-t.y)*A-((i.x-t.x)*s+(i.y-t.y)*A)));let a=new Punto2(o[0].x,o[0].y),l=new Punto2(o[o.length-1].x,o[o.length-1].y);const c=l.x-a.x,p=l.y-a.y;return c*s+p*A<0&&([a,l]=[l,a]),new Linea2(a,l)}(e,t.p1,t.p2),tostr(t=2){let i=10**t,pstr=e=>String(Math.round(e*i)/i),n=e.map((e=>`${pstr(e.x)};${pstr(e.y)};`)).join("");return n&&n.length?n.slice(0,-1).match(/.{1,80}(;|$)/g).map((e=>e.trim())).join("\n"):""},addpt(t){return t?(Array.isArray(t)||(t=[t]),e=removeduplicate([...e,...t]),this):this},addracc(t,i,n=2,r=!0){if(Array.isArray(t)&&(i={x:t[2]||0,y:t[3]||0},t={x:t[0]||0,y:t[1]||0}),e.length>=2){let o=raccordabezier(e[e.length-2],e[e.length-1],t,i,n);e=[...e,...o],r&&(e.push(t),e.push(i))}return e=removeduplicate(e),this},setorient(t){let i=orientation();return(1==i&&-1==t||-1==i&&1==t)&&e.reverse(),this},reverse(){return e.reverse(),this},pointinshape:t=>function isPointInPolygon(t){let i=t.x,n=t.y,r=!1;for(let t=0,o=e.length-1;t<e.length;o=t++){let s=e[t].x,A=e[t].y,a=e[o].x,l=e[o].y;A>n!=l>n&&i<(a-s)*(n-A)/(l-A)+s&&(r=!r)}return r}(t),azzera(){return e=[],this},truncatebefore:function truncatebefore(t){let i=new Linea2(e[0],e[1]),n=t.interseca(i);if(n){let t=e[0],i=e[1],r=i.x-t.x,o=i.y-t.y,s=r*r+o*o;if(s){if(((n.x-t.x)*r+(n.y-t.y)*o)/s<=1)return e[0]=n,this}}for(let i=1;i<e.length-1;i++){let n=new Linea2(e[i],e[i+1]),r=t.interseca(n);if(r&&n.onsegment(r))return e=e.slice(i),e[0]=r,this}return this},truncateafter:function truncateafter(t){let i=e.length,n=new Linea2(e[i-2],e[i-1]),r=t.interseca(n);if(r){let t=e[i-2],n=e[i-1],o=n.x-t.x,s=n.y-t.y,A=o*o+s*s;if(A){if(((r.x-t.x)*o+(r.y-t.y)*s)/A>=0)return e[i-1]=r,this}}for(let n=i-3;n>=0;n--){let i=new Linea2(e[n],e[n+1]),r=t.interseca(i);if(r&&i.onsegment(r))return e=e.slice(0,n+1),e.push(r),this}return this},removeduplicate(t=.005){return e=removeduplicate(e,t),this},to3d(t,i=0,n=0,r=0,o=!1,s=null,A=!1){let a=function to3dcoor(e,t){let{currentU:i=0,c:n=0,a:r=0,b:o=0,anglemin:s=30,open:A=!1,sh:a=null,invert:l=!1}=t;const c=[],p=e.length;for(let t=0;t<p;t++){const A=e[(t-1+p)%p],h=e[t],g=e[(t+1)%p],u={x:h.x-A.x,y:h.y-A.y},d={x:g.x-h.x,y:g.y-h.y},f=normal2(A,h),I=normal2(h,g),m=angle2vec(u,d);let b=r*h.x+o*h.y+n;if(a){let e=a.xfromy(h.y,0,!0);l?b+=e:b-=e}Math.abs(m-180)<=s?(f.nx,I.nx,f.ny,I.ny,c.push({x:h.x,y:-h.y,z:b,u:i,v:b})):(c.push({x:h.x,y:-h.y,z:b,u:i,v:b}),c.push({x:h.x,y:-h.y,z:b,u:i,v:b}));const C=g.x-h.x,B=g.y-h.y;i+=Math.sqrt(C*C+B*B)}if(!A){let e=c[0],t=c[c.length-1];e.x==t.x&&e.y==t.y||c.push({x:e.x,y:e.y,z:e.z,nx:e.nx,ny:e.ny,nz:e.nz,u:i,v:e.z})}return c}(e,{open:o,currentU:t,c:i,a:n,b:r,anglemin:30,sh:s,invert:A});return a},getboundbox:()=>e.length?e.reduce(((e,t)=>(e.p1.x=Math.min(e.p1.x,t.x),e.p1.y=Math.min(e.p1.y,t.y),e.p2.x=Math.max(e.p2.x,t.x),e.p2.y=Math.max(e.p2.y,t.y),e)),{p1:new Punto2(1/0,1/0),p2:new Punto2(-1/0,-1/0)}):{p1:new Punto2(0,0),p2:new Punto2(0,0)},fittobox(t,i){if(!e.length)return this;const n=this.getboundbox(),r=n.p2.x-n.p1.x,o=n.p2.y-n.p1.y,s=i.x-t.x,A=i.y-t.y,a=Math.min(s/(r||1),A/(o||1));for(let i of e)i.x=(i.x-n.p1.x)*a,i.y=(i.y-n.p1.y)*a,i.x+=t.x,i.y+=t.y;return this}}}function arcfrom3point(e,t,i,n){if(e<=0)return[t,n];if(1===e)return[t,i,n];const r=function findCircleCenter(e,t,i){const n=t.x*t.x+t.y*t.y,r=(e.x*e.x+e.y*e.y-n)/2,o=(n-i.x*i.x-i.y*i.y)/2,s=(e.x-t.x)*(t.y-i.y)-(t.x-i.x)*(e.y-t.y);return Math.abs(s)<1e-10?null:new Punto2((r*(t.y-i.y)-o*(e.y-t.y))/s,((e.x-t.x)*o-(t.x-i.x)*r)/s)}(t,i,n);if(!r){const i=[];for(let r=0;r<=e;r++){const o=r/e;i.push(new Punto2(t.x+(n.x-t.x)*o,t.y+(n.y-t.y)*o))}return i}let o=Math.atan2(t.y-r.y,t.x-r.x);Math.atan2(i.y-r.y,i.x-r.x);let s=Math.atan2(n.y-r.y,n.x-r.x);const A=(i.x-t.x)*(n.y-t.y)-(i.y-t.y)*(n.x-t.x),norm=e=>(e+2*Math.PI)%(2*Math.PI);o=norm(o),s=norm(s),A>0?s<o&&(s+=2*Math.PI):s>o&&(s-=2*Math.PI);const a=Math.hypot(t.x-r.x,t.y-r.y),l=(s-o)/e,c=[];for(let t=0;t<=e;t++){const e=o+l*t;c.push(new Punto2(r.x+a*Math.cos(e),r.y+a*Math.sin(e)))}return c}function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var qe,He={exports:{}};qe=He,function(){var e,t={version:"6.4.2.2",use_lines:!0,use_xyz:!1},i=!1;if(qe.exports?(qe.exports=t,i=!0):"undefined"!=typeof document?window.ClipperLib=t:self.ClipperLib=t,i)n="chrome",e="Netscape";else{var n=navigator.userAgent.toString().toLowerCase();e=navigator.appName}var r,o={};function BigInteger(e,i,n){t.biginteger_used=1,null!=e&&("number"==typeof e&&void 0===i?this.fromInt(e):"number"==typeof e?this.fromNumber(e,i,n):null==i&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,i))}function nbi(){return new BigInteger(null,void 0,void 0)}-1!=n.indexOf("chrome")&&-1==n.indexOf("chromium")?o.chrome=1:o.chrome=0,-1!=n.indexOf("chromium")?o.chromium=1:o.chromium=0,-1!=n.indexOf("safari")&&-1==n.indexOf("chrome")&&-1==n.indexOf("chromium")?o.safari=1:o.safari=0,-1!=n.indexOf("firefox")?o.firefox=1:o.firefox=0,-1!=n.indexOf("firefox/17")?o.firefox17=1:o.firefox17=0,-1!=n.indexOf("firefox/15")?o.firefox15=1:o.firefox15=0,-1!=n.indexOf("firefox/3")?o.firefox3=1:o.firefox3=0,-1!=n.indexOf("opera")?o.opera=1:o.opera=0,-1!=n.indexOf("msie 10")?o.msie10=1:o.msie10=0,-1!=n.indexOf("msie 9")?o.msie9=1:o.msie9=0,-1!=n.indexOf("msie 8")?o.msie8=1:o.msie8=0,-1!=n.indexOf("msie 7")?o.msie7=1:o.msie7=0,-1!=n.indexOf("msie ")?o.msie=1:o.msie=0,t.biginteger_used=null,"Microsoft Internet Explorer"==e?(BigInteger.prototype.am=function am2(e,t,i,n,r,o){for(var s=32767&t,A=t>>15;--o>=0;){var a=32767&this[e],l=this[e++]>>15,c=A*a+l*s;r=((a=s*a+((32767&c)<<15)+i[n]+(1073741823&r))>>>30)+(c>>>15)+A*l+(r>>>30),i[n++]=1073741823&a}return r},r=30):"Netscape"!=e?(BigInteger.prototype.am=function am1(e,t,i,n,r,o){for(;--o>=0;){var s=t*this[e++]+i[n]+r;r=Math.floor(s/67108864),i[n++]=67108863&s}return r},r=26):(BigInteger.prototype.am=function am3(e,t,i,n,r,o){for(var s=16383&t,A=t>>14;--o>=0;){var a=16383&this[e],l=this[e++]>>14,c=A*a+l*s;r=((a=s*a+((16383&c)<<14)+i[n]+r)>>28)+(c>>14)+A*l,i[n++]=268435455&a}return r},r=28),BigInteger.prototype.DB=r,BigInteger.prototype.DM=(1<<r)-1,BigInteger.prototype.DV=1<<r,BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=52-r,BigInteger.prototype.F2=2*r-52;var s,A,a=new Array;for(s="0".charCodeAt(0),A=0;A<=9;++A)a[s++]=A;for(s="a".charCodeAt(0),A=10;A<36;++A)a[s++]=A;for(s="A".charCodeAt(0),A=10;A<36;++A)a[s++]=A;function int2char(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function intAt(e,t){var i=a[e.charCodeAt(t)];return null==i?-1:i}function nbv(e){var t=nbi();return t.fromInt(e),t}function nbits(e){var t,i=1;return 0!=(t=e>>>16)&&(e=t,i+=16),0!=(t=e>>8)&&(e=t,i+=8),0!=(t=e>>4)&&(e=t,i+=4),0!=(t=e>>2)&&(e=t,i+=2),0!=(t=e>>1)&&(e=t,i+=1),i}function Classic(e){this.m=e}function Montgomery(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function op_and(e,t){return e&t}function op_or(e,t){return e|t}function op_xor(e,t){return e^t}function op_andnot(e,t){return e&~t}function lbit(e){if(0==e)return-1;var t=0;return 65535&e||(e>>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function cbit(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function NullExp(){}function nNop(e){return e}function Barrett(e){this.r2=nbi(),this.q3=nbi(),BigInteger.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}Classic.prototype.convert=function cConvert(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},Classic.prototype.revert=function cRevert(e){return e},Classic.prototype.reduce=function cReduce(e){e.divRemTo(this.m,null,e)},Classic.prototype.mulTo=function cMulTo(e,t,i){e.multiplyTo(t,i),this.reduce(i)},Classic.prototype.sqrTo=function cSqrTo(e,t){e.squareTo(t),this.reduce(t)},Montgomery.prototype.convert=function montConvert(e){var t=nbi();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(BigInteger.ZERO)>0&&this.m.subTo(t,t),t},Montgomery.prototype.revert=function montRevert(e){var t=nbi();return e.copyTo(t),this.reduce(t),t},Montgomery.prototype.reduce=function montReduce(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var i=32767&e[t],n=i*this.mpl+((i*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[i=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[i]>=e.DV;)e[i]-=e.DV,e[++i]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},Montgomery.prototype.mulTo=function montMulTo(e,t,i){e.multiplyTo(t,i),this.reduce(i)},Montgomery.prototype.sqrTo=function montSqrTo(e,t){e.squareTo(t),this.reduce(t)},BigInteger.prototype.copyTo=function bnpCopyTo(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},BigInteger.prototype.fromInt=function bnpFromInt(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0},BigInteger.prototype.fromString=function bnpFromString(e,t){var i;if(16==t)i=4;else if(8==t)i=3;else if(256==t)i=8;else if(2==t)i=1;else if(32==t)i=5;else{if(4!=t)return void this.fromRadix(e,t);i=2}this.t=0,this.s=0;for(var n=e.length,r=!1,o=0;--n>=0;){var s=8==i?255&e[n]:intAt(e,n);s<0?"-"==e.charAt(n)&&(r=!0):(r=!1,0==o?this[this.t++]=s:o+i>this.DB?(this[this.t-1]|=(s&(1<<this.DB-o)-1)<<o,this[this.t++]=s>>this.DB-o):this[this.t-1]|=s<<o,(o+=i)>=this.DB&&(o-=this.DB))}8==i&&128&e[0]&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),r&&BigInteger.ZERO.subTo(this,this)},BigInteger.prototype.clamp=function bnpClamp(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t},BigInteger.prototype.dlShiftTo=function bnpDLShiftTo(e,t){var i;for(i=this.t-1;i>=0;--i)t[i+e]=this[i];for(i=e-1;i>=0;--i)t[i]=0;t.t=this.t+e,t.s=this.s},BigInteger.prototype.drShiftTo=function bnpDRShiftTo(e,t){for(var i=e;i<this.t;++i)t[i-e]=this[i];t.t=Math.max(this.t-e,0),t.s=this.s},BigInteger.prototype.lShiftTo=function bnpLShiftTo(e,t){var i,n=e%this.DB,r=this.DB-n,o=(1<<r)-1,s=Math.floor(e/this.DB),A=this.s<<n&this.DM;for(i=this.t-1;i>=0;--i)t[i+s+1]=this[i]>>r|A,A=(this[i]&o)<<n;for(i=s-1;i>=0;--i)t[i]=0;t[s]=A,t.t=this.t+s+1,t.s=this.s,t.clamp()},BigInteger.prototype.rShiftTo=function bnpRShiftTo(e,t){t.s=this.s;var i=Math.floor(e/this.DB);if(i>=this.t)t.t=0;else{var n=e%this.DB,r=this.DB-n,o=(1<<n)-1;t[0]=this[i]>>n;for(var s=i+1;s<this.t;++s)t[s-i-1]|=(this[s]&o)<<r,t[s-i]=this[s]>>n;n>0&&(t[this.t-i-1]|=(this.s&o)<<r),t.t=this.t-i,t.clamp()}},BigInteger.prototype.subTo=function bnpSubTo(e,t){for(var i=0,n=0,r=Math.min(e.t,this.t);i<r;)n+=this[i]-e[i],t[i++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;i<this.t;)n+=this[i],t[i++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;i<e.t;)n-=e[i],t[i++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[i++]=this.DV+n:n>0&&(t[i++]=n),t.t=i,t.clamp()},BigInteger.prototype.multiplyTo=function bnpMultiplyTo(e,t){var i=this.abs(),n=e.abs(),r=i.t;for(t.t=r+n.t;--r>=0;)t[r]=0;for(r=0;r<n.t;++r)t[r+i.t]=i.am(0,n[r],t,r,0,i.t);t.s=0,t.clamp(),this.s!=e.s&&BigInteger.ZERO.subTo(t,t)},BigInteger.prototype.squareTo=function bnpSquareTo(e){for(var t=this.abs(),i=e.t=2*t.t;--i>=0;)e[i]=0;for(i=0;i<t.t-1;++i){var n=t.am(i,t[i],e,2*i,0,1);(e[i+t.t]+=t.am(i+1,2*t[i],e,2*i+1,n,t.t-i-1))>=t.DV&&(e[i+t.t]-=t.DV,e[i+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(i,t[i],e,2*i,0,1)),e.s=0,e.clamp()},BigInteger.prototype.divRemTo=function bnpDivRemTo(e,t,i){var n=e.abs();if(!(n.t<=0)){var r=this.abs();if(r.t<n.t)return null!=t&&t.fromInt(0),void(null!=i&&this.copyTo(i));null==i&&(i=nbi());var o=nbi(),s=this.s,A=e.s,a=this.DB-nbits(n[n.t-1]);a>0?(n.lShiftTo(a,o),r.lShiftTo(a,i)):(n.copyTo(o),r.copyTo(i));var l=o.t,c=o[l-1];if(0!=c){var p=c*(1<<this.F1)+(l>1?o[l-2]>>this.F2:0),h=this.FV/p,g=(1<<this.F1)/p,u=1<<this.F2,d=i.t,f=d-l,I=null==t?nbi():t;for(o.dlShiftTo(f,I),i.compareTo(I)>=0&&(i[i.t++]=1,i.subTo(I,i)),BigInteger.ONE.dlShiftTo(l,I),I.subTo(o,o);o.t<l;)o[o.t++]=0;for(;--f>=0;){var m=i[--d]==c?this.DM:Math.floor(i[d]*h+(i[d-1]+u)*g);if((i[d]+=o.am(0,m,i,f,0,l))<m)for(o.dlShiftTo(f,I),i.subTo(I,i);i[d]<--m;)i.subTo(I,i)}null!=t&&(i.drShiftTo(l,t),s!=A&&BigInteger.ZERO.subTo(t,t)),i.t=l,i.clamp(),a>0&&i.rShiftTo(a,i),s<0&&BigInteger.ZERO.subTo(i,i)}}},BigInteger.prototype.invDigit=function bnpInvDigit(){if(this.t<1)return 0;var e=this[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},BigInteger.prototype.isEven=function bnpIsEven(){return 0==(this.t>0?1&this[0]:this.s)},BigInteger.prototype.exp=function bnpExp(e,t){if(e>4294967295||e<1)return BigInteger.ONE;var i=nbi(),n=nbi(),r=t.convert(this),o=nbits(e)-1;for(r.copyTo(i);--o>=0;)if(t.sqrTo(i,n),(e&1<<o)>0)t.mulTo(n,r,i);else{var s=i;i=n,n=s}return t.revert(i)},BigInteger.prototype.toString=function bnToString(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var i,n=(1<<t)-1,r=!1,o="",s=this.t,A=this.DB-s*this.DB%t;if(s-- >0)for(A<this.DB&&(i=this[s]>>A)>0&&(r=!0,o=int2char(i));s>=0;)A<t?(i=(this[s]&(1<<A)-1)<<t-A,i|=this[--s]>>(A+=this.DB-t)):(i=this[s]>>(A-=t)&n,A<=0&&(A+=this.DB,--s)),i>0&&(r=!0),r&&(o+=int2char(i));return r?o:"0"},BigInteger.prototype.negate=function bnNegate(){var e=nbi();return BigInteger.ZERO.subTo(this,e),e},BigInteger.prototype.abs=function bnAbs(){return this.s<0?this.negate():this},BigInteger.prototype.compareTo=function bnCompareTo(e){var t=this.s-e.s;if(0!=t)return t;var i=this.t;if(0!=(t=i-e.t))return this.s<0?-t:t;for(;--i>=0;)if(0!=(t=this[i]-e[i]))return t;return 0},BigInteger.prototype.bitLength=function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)},BigInteger.prototype.mod=function bnMod(e){var t=nbi();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(BigInteger.ZERO)>0&&e.subTo(t,t),t},BigInteger.prototype.modPowInt=function bnModPowInt(e,t){var i;return i=e<256||t.isEven()?new Classic(t):new Montgomery(t),this.exp(e,i)},BigInteger.ZERO=nbv(0),BigInteger.ONE=nbv(1),NullExp.prototype.convert=nNop,NullExp.prototype.revert=nNop,NullExp.prototype.mulTo=function nMulTo(e,t,i){e.multiplyTo(t,i)},NullExp.prototype.sqrTo=function nSqrTo(e,t){e.squareTo(t)},Barrett.prototype.convert=function barrettConvert(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=nbi();return e.copyTo(t),this.reduce(t),t},Barrett.prototype.revert=function barrettRevert(e){return e},Barrett.prototype.reduce=function barrettReduce(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},Barrett.prototype.mulTo=function barrettMulTo(e,t,i){e.multiplyTo(t,i),this.reduce(i)},Barrett.prototype.sqrTo=function barrettSqrTo(e,t){e.squareTo(t),this.reduce(t)};var l=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],c=(1<<26)/l[l.length-1];BigInteger.prototype.chunkSize=function bnpChunkSize(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},BigInteger.prototype.toRadix=function bnpToRadix(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),i=Math.pow(e,t),n=nbv(i),r=nbi(),o=nbi(),s="";for(this.divRemTo(n,r,o);r.signum()>0;)s=(i+o.intValue()).toString(e).substr(1)+s,r.divRemTo(n,r,o);return o.intValue().toString(e)+s},BigInteger.prototype.fromRadix=function bnpFromRadix(e,t){this.fromInt(0),null==t&&(t=10);for(var i=this.chunkSize(t),n=Math.pow(t,i),r=!1,o=0,s=0,A=0;A<e.length;++A){var a=intAt(e,A);a<0?"-"==e.charAt(A)&&0==this.signum()&&(r=!0):(s=t*s+a,++o>=i&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(s,0)),r&&BigInteger.ZERO.subTo(this,this)},BigInteger.prototype.fromNumber=function bnpFromNumber(e,t,i){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,i),this.testBit(e-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(e-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(BigInteger.ONE.shiftLeft(e-1),this);else{var n=new Array,r=7&e;n.length=1+(e>>3),t.nextBytes(n),r>0?n[0]&=(1<<r)-1:n[0]=0,this.fromString(n,256)}},BigInteger.prototype.bitwiseTo=function bnpBitwiseTo(e,t,i){var n,r,o=Math.min(e.t,this.t);for(n=0;n<o;++n)i[n]=t(this[n],e[n]);if(e.t<this.t){for(r=e.s&this.DM,n=o;n<this.t;++n)i[n]=t(this[n],r);i.t=this.t}else{for(r=this.s&this.DM,n=o;n<e.t;++n)i[n]=t(r,e[n]);i.t=e.t}i.s=t(this.s,e.s),i.clamp()},BigInteger.prototype.changeBit=function bnpChangeBit(e,t){var i=BigInteger.ONE.shiftLeft(e);return this.bitwiseTo(i,t,i),i},BigInteger.prototype.addTo=function bnpAddTo(e,t){for(var i=0,n=0,r=Math.min(e.t,this.t);i<r;)n+=this[i]+e[i],t[i++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;i<this.t;)n+=this[i],t[i++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;i<e.t;)n+=e[i],t[i++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[i++]=n:n<-1&&(t[i++]=this.DV+n),t.t=i,t.clamp()},BigInteger.prototype.dMultiply=function bnpDMultiply(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},BigInteger.prototype.dAddOffset=function bnpDAddOffset(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},BigInteger.prototype.multiplyLowerTo=function bnpMultiplyLowerTo(e,t,i){var n,r=Math.min(this.t+e.t,t);for(i.s=0,i.t=r;r>0;)i[--r]=0;for(n=i.t-this.t;r<n;++r)i[r+this.t]=this.am(0,e[r],i,r,0,this.t);for(n=Math.min(e.t,t);r<n;++r)this.am(0,e[r],i,r,0,t-r);i.clamp()},BigInteger.prototype.multiplyUpperTo=function bnpMultiplyUpperTo(e,t,i){--t;var n=i.t=this.t+e.t-t;for(i.s=0;--n>=0;)i[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)i[this.t+n-t]=this.am(t-n,e[n],i,0,0,this.t+n-t);i.clamp(),i.drShiftTo(1,i)},BigInteger.prototype.modInt=function bnpModInt(e){if(e<=0)return 0;var t=this.DV%e,i=this.s<0?e-1:0;if(this.t>0)if(0==t)i=this[0]%e;else for(var n=this.t-1;n>=0;--n)i=(t*i+this[n])%e;return i},BigInteger.prototype.millerRabin=function bnpMillerRabin(e){var t=this.subtract(BigInteger.ONE),i=t.getLowestSetBit();if(i<=0)return!1;var n=t.shiftRight(i);(e=e+1>>1)>l.length&&(e=l.length);for(var r=nbi(),o=0;o<e;++o){r.fromInt(l[Math.floor(Math.random()*l.length)]);var s=r.modPow(n,this);if(0!=s.compareTo(BigInteger.ONE)&&0!=s.compareTo(t)){for(var A=1;A++<i&&0!=s.compareTo(t);)if(0==(s=s.modPowInt(2,this)).compareTo(BigInteger.ONE))return!1;if(0!=s.compareTo(t))return!1}}return!0},BigInteger.prototype.clone=function bnClone(){var e=nbi();return this.copyTo(e),e},BigInteger.prototype.intValue=function bnIntValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},BigInteger.prototype.byteValue=function bnByteValue(){return 0==this.t?this.s:this[0]<<24>>24},BigInteger.prototype.shortValue=function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16},BigInteger.prototype.signum=function bnSigNum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},BigInteger.prototype.toByteArray=function bnToByteArray(){var e=this.t,t=new Array;t[0]=this.s;var i,n=this.DB-e*this.DB%8,r=0;if(e-- >0)for(n<this.DB&&(i=this[e]>>n)!=(this.s&this.DM)>>n&&(t[r++]=i|this.s<<this.DB-n);e>=0;)n<8?(i=(this[e]&(1<<n)-1)<<8-n,i|=this[--e]>>(n+=this.DB-8)):(i=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),128&i&&(i|=-256),0==r&&(128&this.s)!=(128&i)&&++r,(r>0||i!=this.s)&&(t[r++]=i);return t},BigInteger.prototype.equals=function bnEquals(e){return 0==this.compareTo(e)},BigInteger.prototype.min=function bnMin(e){return this.compareTo(e)<0?this:e},BigInteger.prototype.max=function bnMax(e){return this.compareTo(e)>0?this:e},BigInteger.prototype.and=function bnAnd(e){var t=nbi();return this.bitwiseTo(e,op_and,t),t},BigInteger.prototype.or=function bnOr(e){var t=nbi();return this.bitwiseTo(e,op_or,t),t},BigInteger.prototype.xor=function bnXor(e){var t=nbi();return this.bitwiseTo(e,op_xor,t),t},BigInteger.prototype.andNot=function bnAndNot(e){var t=nbi();return this.bitwiseTo(e,op_andnot,t),t},BigInteger.prototype.not=function bnNot(){for(var e=nbi(),t=0;t<this.t;++t)e[t]=this.DM&~this[t];return e.t=this.t,e.s=~this.s,e},BigInteger.prototype.shiftLeft=function bnShiftLeft(e){var t=nbi();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t},BigInteger.prototype.shiftRight=function bnShiftRight(e){var t=nbi();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t},BigInteger.prototype.getLowestSetBit=function bnGetLowestSetBit(){for(var e=0;e<this.t;++e)if(0!=this[e])return e*this.DB+lbit(this[e]);return this.s<0?this.t*this.DB:-1},BigInteger.prototype.bitCount=function bnBitCount(){for(var e=0,t=this.s&this.DM,i=0;i<this.t;++i)e+=cbit(this[i]^t);return e},BigInteger.prototype.testBit=function bnTestBit(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:!!(this[t]&1<<e%this.DB)},BigInteger.prototype.setBit=function bnSetBit(e){return this.changeBit(e,op_or)},BigInteger.prototype.clearBit=function bnClearBit(e){return this.changeBit(e,op_andnot)},BigInteger.prototype.flipBit=function bnFlipBit(e){return this.changeBit(e,op_xor)},BigInteger.prototype.add=function bnAdd(e){var t=nbi();return this.addTo(e,t),t},BigInteger.prototype.subtract=function bnSubtract(e){var t=nbi();return this.subTo(e,t),t},BigInteger.prototype.multiply=function bnMultiply(e){var t=nbi();return this.multiplyTo(e,t),t},BigInteger.prototype.divide=function bnDivide(e){var t=nbi();return this.divRemTo(e,t,null),t},BigInteger.prototype.remainder=function bnRemainder(e){var t=nbi();return this.divRemTo(e,null,t),t},BigInteger.prototype.divideAndRemainder=function bnDivideAndRemainder(e){var t=nbi(),i=nbi();return this.divRemTo(e,t,i),new Array(t,i)},BigInteger.prototype.modPow=function bnModPow(e,t){var i,n,r=e.bitLength(),o=nbv(1);if(r<=0)return o;i=r<18?1:r<48?3:r<144?4:r<768?5:6,n=r<8?new Classic(t):t.isEven()?new Barrett(t):new Montgomery(t);var s=new Array,A=3,a=i-1,l=(1<<i)-1;if(s[1]=n.convert(this),i>1){var c=nbi();for(n.sqrTo(s[1],c);A<=l;)s[A]=nbi(),n.mulTo(c,s[A-2],s[A]),A+=2}var p,h,g=e.t-1,u=!0,d=nbi();for(r=nbits(e[g])-1;g>=0;){for(r>=a?p=e[g]>>r-a&l:(p=(e[g]&(1<<r+1)-1)<<a-r,g>0&&(p|=e[g-1]>>this.DB+r-a)),A=i;!(1&p);)p>>=1,--A;if((r-=A)<0&&(r+=this.DB,--g),u)s[p].copyTo(o),u=!1;else{for(;A>1;)n.sqrTo(o,d),n.sqrTo(d,o),A-=2;A>0?n.sqrTo(o,d):(h=o,o=d,d=h),n.mulTo(d,s[p],o)}for(;g>=0&&!(e[g]&1<<r);)n.sqrTo(o,d),h=o,o=d,d=h,--r<0&&(r=this.DB-1,--g)}return n.revert(o)},BigInteger.prototype.modInverse=function bnModInverse(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return BigInteger.ZERO;for(var i=e.clone(),n=this.clone(),r=nbv(1),o=nbv(0),s=nbv(0),A=nbv(1);0!=i.signum();){for(;i.isEven();)i.rShiftTo(1,i),t?(r.isEven()&&o.isEven()||(r.addTo(this,r),o.subTo(e,o)),r.rShiftTo(1,r)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);for(;n.isEven();)n.rShiftTo(1,n),t?(s.isEven()&&A.isEven()||(s.addTo(this,s),A.subTo(e,A)),s.rShiftTo(1,s)):A.isEven()||A.subTo(e,A),A.rShiftTo(1,A);i.compareTo(n)>=0?(i.subTo(n,i),t&&r.subTo(s,r),o.subTo(A,o)):(n.subTo(i,n),t&&s.subTo(r,s),A.subTo(o,A))}return 0!=n.compareTo(BigInteger.ONE)?BigInteger.ZERO:A.compareTo(e)>=0?A.subtract(e):A.signum()<0?(A.addTo(e,A),A.signum()<0?A.add(e):A):A},BigInteger.prototype.pow=function bnPow(e){return this.exp(e,new NullExp)},BigInteger.prototype.gcd=function bnGCD(e){var t=this.s<0?this.negate():this.clone(),i=e.s<0?e.negate():e.clone();if(t.compareTo(i)<0){var n=t;t=i,i=n}var r=t.getLowestSetBit(),o=i.getLowestSetBit();if(o<0)return t;for(r<o&&(o=r),o>0&&(t.rShiftTo(o,t),i.rShiftTo(o,i));t.signum()>0;)(r=t.getLowestSetBit())>0&&t.rShiftTo(r,t),(r=i.getLowestSetBit())>0&&i.rShiftTo(r,i),t.compareTo(i)>=0?(t.subTo(i,t),t.rShiftTo(1,t)):(i.subTo(t,i),i.rShiftTo(1,i));return o>0&&i.lShiftTo(o,i),i},BigInteger.prototype.isProbablePrime=function bnIsProbablePrime(e){var t,i=this.abs();if(1==i.t&&i[0]<=l[l.length-1]){for(t=0;t<l.length;++t)if(i[0]==l[t])return!0;return!1}if(i.isEven())return!1;for(t=1;t<l.length;){for(var n=l[t],r=t+1;r<l.length&&n<c;)n*=l[r++];for(n=i.modInt(n);t<r;)if(n%l[t++]==0)return!1}return i.millerRabin(e)},BigInteger.prototype.square=function bnSquare(){var e=nbi();return this.squareTo(e),e};var p=BigInteger;p.prototype.IsNegative=function(){return-1==this.compareTo(p.ZERO)},p.op_Equality=function(e,t){return 0==e.compareTo(t)},p.op_Inequality=function(e,t){return 0!=e.compareTo(t)},p.op_GreaterThan=function(e,t){return e.compareTo(t)>0},p.op_LessThan=function(e,t){return e.compareTo(t)<0},p.op_Addition=function(e,t){return new p(e,void 0,void 0).add(new p(t,void 0,void 0))},p.op_Subtraction=function(e,t){return new p(e,void 0,void 0).subtract(new p(t,void 0,void 0))},p.Int128Mul=function(e,t){return new p(e,void 0,void 0).multiply(new p(t,void 0,void 0))},p.op_Division=function(e,t){return e.divide(t)},p.prototype.ToDouble=function(){return parseFloat(this.toString())};var Inherit=function(e,t){var i;if(void 0===Object.getOwnPropertyNames){for(i in t.prototype)void 0!==e.prototype[i]&&e.prototype[i]!==Object.prototype[i]||(e.prototype[i]=t.prototype[i]);for(i in t)void 0===e[i]&&(e[i]=t[i]);e.$baseCtor=t}else{for(var n=Object.getOwnPropertyNames(t.prototype),r=0;r<n.length;r++)void 0===Object.getOwnPropertyDescriptor(e.prototype,n[r])&&Object.defineProperty(e.prototype,n[r],Object.getOwnPropertyDescriptor(t.prototype,n[r]));for(i in t)void 0===e[i]&&(e[i]=t[i]);e.$baseCtor=t}};t.Path=function(){return[]},t.Path.prototype.push=Array.prototype.push,t.Paths=function(){return[]},t.Paths.prototype.push=Array.prototype.push,t.DoublePoint=function(){var e=arguments;this.X=0,this.Y=0,1===e.length?(this.X=e[0].X,this.Y=e[0].Y):2===e.length&&(this.X=e[0],this.Y=e[1])},t.DoublePoint0=function(){this.X=0,this.Y=0},t.DoublePoint0.prototype=t.DoublePoint.prototype,t.DoublePoint1=function(e){this.X=e.X,this.Y=e.Y},t.DoublePoint1.prototype=t.DoublePoint.prototype,t.DoublePoint2=function(e,t){this.X=e,this.Y=t},t.DoublePoint2.prototype=t.DoublePoint.prototype,t.PolyNode=function(){this.m_Parent=null,this.m_polygon=new t.Path,this.m_Index=0,this.m_jointype=0,this.m_endtype=0,this.m_Childs=[],this.IsOpen=!1},t.PolyNode.prototype.IsHoleNode=function(){for(var e=!0,t=this.m_Parent;null!==t;)e=!e,t=t.m_Parent;return e},t.PolyNode.prototype.ChildCount=function(){return this.m_Childs.length},t.PolyNode.prototype.Contour=function(){return this.m_polygon},t.PolyNode.prototype.AddChild=function(e){var t=this.m_Childs.length;this.m_Childs.push(e),e.m_Parent=this,e.m_Index=t},t.PolyNode.prototype.GetNext=function(){return this.m_Childs.length>0?this.m_Childs[0]:this.GetNextSiblingUp()},t.PolyNode.prototype.GetNextSiblingUp=function(){return null===this.m_Parent?null:this.m_Index===this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+1]},t.PolyNode.prototype.Childs=function(){return this.m_Childs},t.PolyNode.prototype.Parent=function(){return this.m_Parent},t.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()},t.PolyTree=function(){this.m_AllPolys=[],t.PolyNode.call(this)},t.PolyTree.prototype.Clear=function(){for(var e=0,t=this.m_AllPolys.length;e<t;e++)this.m_AllPolys[e]=null;this.m_AllPolys.length=0,this.m_Childs.length=0},t.PolyTree.prototype.GetFirst=function(){return this.m_Childs.length>0?this.m_Childs[0]:null},t.PolyTree.prototype.Total=function(){var e=this.m_AllPolys.length;return e>0&&this.m_Childs[0]!==this.m_AllPolys[0]&&e--,e},Inherit(t.PolyTree,t.PolyNode),t.Math_Abs_Int64=t.Math_Abs_Int32=t.Math_Abs_Double=function(e){return Math.abs(e)},t.Math_Max_Int32_Int32=function(e,t){return Math.max(e,t)},o.msie||o.opera||o.safari?t.Cast_Int32=function(e){return 0|e}:t.Cast_Int32=function(e){return~~e},void 0===Number.toInteger&&(Number.toInteger=null),o.chrome?t.Cast_Int64=function(e){return e<-2147483648||e>2147483647?e<0?Math.ceil(e):Math.floor(e):~~e}:o.firefox&&"function"==typeof Number.toInteger?t.Cast_Int64=function(e){return Number.toInteger(e)}:o.msie7||o.msie8?t.Cast_Int64=function(e){return parseInt(e,10)}:o.msie?t.Cast_Int64=function(e){return e<-2147483648||e>2147483647?e<0?Math.ceil(e):Math.floor(e):0|e}:t.Cast_Int64=function(e){return e<0?Math.ceil(e):Math.floor(e)},t.Clear=function(e){e.length=0},t.PI=3.141592653589793,t.PI2=6.283185307179586,t.IntPoint=function(){var e=arguments,i=e.length;if(this.X=0,this.Y=0,t.use_xyz)if(this.Z=0,3===i)this.X=e[0],this.Y=e[1],this.Z=e[2];else if(2===i)this.X=e[0],this.Y=e[1],this.Z=0;else if(1===i)if(e[0]instanceof t.DoublePoint){var n=e[0];this.X=t.Clipper.Round(n.X),this.Y=t.Clipper.Round(n.Y),this.Z=0}else void 0===(r=e[0]).Z&&(r.Z=0),this.X=r.X,this.Y=r.Y,this.Z=r.Z;else this.X=0,this.Y=0,this.Z=0;else if(2===i)this.X=e[0],this.Y=e[1];else if(1===i)if(e[0]instanceof t.DoublePoint)n=e[0],this.X=t.Clipper.Round(n.X),this.Y=t.Clipper.Round(n.Y);else{var r=e[0];this.X=r.X,this.Y=r.Y}else this.X=0,this.Y=0},t.IntPoint.op_Equality=function(e,t){return e.X===t.X&&e.Y===t.Y},t.IntPoint.op_Inequality=function(e,t){return e.X!==t.X||e.Y!==t.Y},t.IntPoint0=function(){this.X=0,this.Y=0,t.use_xyz&&(this.Z=0)},t.IntPoint0.prototype=t.IntPoint.prototype,t.IntPoint1=function(e){this.X=e.X,this.Y=e.Y,t.use_xyz&&(void 0===e.Z?this.Z=0:this.Z=e.Z)},t.IntPoint1.prototype=t.IntPoint.prototype,t.IntPoint1dp=function(e){this.X=t.Clipper.Round(e.X),this.Y=t.Clipper.Round(e.Y),t.use_xyz&&(this.Z=0)},t.IntPoint1dp.prototype=t.IntPoint.prototype,t.IntPoint2=function(e,i,n){this.X=e,this.Y=i,t.use_xyz&&(this.Z=void 0===n?0:n)},t.IntPoint2.prototype=t.IntPoint.prototype,t.IntRect=function(){var e=arguments,t=e.length;if(4===t)this.left=e[0],this.top=e[1],this.right=e[2],this.bottom=e[3];else if(1===t){var i=e[0];this.left=i.left,this.top=i.top,this.right=i.right,this.bottom=i.bottom}else this.left=0,this.top=0,this.right=0,this.bottom=0},t.IntRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0},t.IntRect0.prototype=t.IntRect.prototype,t.IntRect1=function(e){this.left=e.left,this.top=e.top,this.right=e.right,this.bottom=e.bottom},t.IntRect1.prototype=t.IntRect.prototype,t.IntRect4=function(e,t,i,n){this.left=e,this.top=t,this.right=i,this.bottom=n},t.IntRect4.prototype=t.IntRect.prototype,t.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},t.PolyType={ptSubject:0,ptClip:1},t.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},t.JoinType={jtSquare:0,jtRound:1,jtMiter:2},t.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},t.EdgeSide={esLeft:0,esRight:1},t.Direction={dRightToLeft:0,dLeftToRight:1},t.TEdge=function(){this.Bot=new t.IntPoint0,this.Curr=new t.IntPoint0,this.Top=new t.IntPoint0,this.Delta=new t.IntPoint0,this.Dx=0,this.PolyTyp=t.PolyType.ptSubject,this.Side=t.EdgeSide.esLeft,this.WindDelta=0,this.WindCnt=0,this.WindCnt2=0,this.OutIdx=0,this.Next=null,this.Prev=null,this.NextInLML=null,this.NextInAEL=null,this.PrevInAEL=null,this.NextInSEL=null,this.PrevInSEL=null},t.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new t.IntPoint0},t.MyIntersectNodeSort=function(){},t.MyIntersectNodeSort.Compare=function(e,t){var i=t.Pt.Y-e.Pt.Y;return i>0?1:i<0?-1:0},t.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null},t.Scanbeam=function(){this.Y=0,this.Next=null},t.Maxima=function(){this.X=0,this.Next=null,this.Prev=null},t.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null},t.OutPt=function(){this.Idx=0,this.Pt=new t.IntPoint0,this.Next=null,this.Prev=null},t.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new t.IntPoint0},t.ClipperBase=function(){this.m_MinimaList=null,this.m_CurrentLM=null,this.m_edges=new Array,this.m_UseFullRange=!1,this.m_HasOpenPaths=!1,this.PreserveCollinear=!1,this.m_Scanbeam=null,this.m_PolyOuts=null,this.m_ActiveEdges=null},t.ClipperBase.horizontal=-9007199254740992,t.ClipperBase.Skip=-2,t.ClipperBase.Unassigned=-1,t.ClipperBase.tolerance=1e-20,t.ClipperBase.loRange=47453132,t.ClipperBase.hiRange=0xfffffffffffff,t.ClipperBase.near_zero=function(e){return e>-t.ClipperBase.tolerance&&e<t.ClipperBase.tolerance},t.ClipperBase.IsHorizontal=function(e){return 0===e.Delta.Y},t.ClipperBase.prototype.PointIsVertex=function(e,i){var n=i;do{if(t.IntPoint.op_Equality(n.Pt,e))return!0;n=n.Next}while(n!==i);return!1},t.ClipperBase.prototype.PointOnLineSegment=function(e,t,i,n){return n?e.X===t.X&&e.Y===t.Y||e.X===i.X&&e.Y===i.Y||e.X>t.X==e.X<i.X&&e.Y>t.Y==e.Y<i.Y&&p.op_Equality(p.Int128Mul(e.X-t.X,i.Y-t.Y),p.Int128Mul(i.X-t.X,e.Y-t.Y)):e.X===t.X&&e.Y===t.Y||e.X===i.X&&e.Y===i.Y||e.X>t.X==e.X<i.X&&e.Y>t.Y==e.Y<i.Y&&(e.X-t.X)*(i.Y-t.Y)==(i.X-t.X)*(e.Y-t.Y)},t.ClipperBase.prototype.PointOnPolygon=function(e,t,i){for(var n=t;;){if(this.PointOnLineSegment(e,n.Pt,n.Next.Pt,i))return!0;if((n=n.Next)===t)break}return!1},t.ClipperBase.prototype.SlopesEqual=t.ClipperBase.SlopesEqual=function(){var e,i,n,r,o,s,A=arguments,a=A.length;return 3===a?(e=A[0],i=A[1],A[2]?p.op_Equality(p.Int128Mul(e.Delta.Y,i.Delta.X),p.Int128Mul(e.Delta.X,i.Delta.Y)):t.Cast_Int64(e.Delta.Y*i.Delta.X)===t.Cast_Int64(e.Delta.X*i.Delta.Y)):4===a?(n=A[0],r=A[1],o=A[2],A[3]?p.op_Equality(p.Int128Mul(n.Y-r.Y,r.X-o.X),p.Int128Mul(n.X-r.X,r.Y-o.Y)):t.Cast_Int64((n.Y-r.Y)*(r.X-o.X))-t.Cast_Int64((n.X-r.X)*(r.Y-o.Y))==0):(n=A[0],r=A[1],o=A[2],s=A[3],A[4]?p.op_Equality(p.Int128Mul(n.Y-r.Y,o.X-s.X),p.Int128Mul(n.X-r.X,o.Y-s.Y)):t.Cast_Int64((n.Y-r.Y)*(o.X-s.X))-t.Cast_Int64((n.X-r.X)*(o.Y-s.Y))==0)},t.ClipperBase.SlopesEqual3=function(e,i,n){return n?p.op_Equality(p.Int128Mul(e.Delta.Y,i.Delta.X),p.Int128Mul(e.Delta.X,i.Delta.Y)):t.Cast_Int64(e.Delta.Y*i.Delta.X)===t.Cast_Int64(e.Delta.X*i.Delta.Y)},t.ClipperBase.SlopesEqual4=function(e,i,n,r){return r?p.op_Equality(p.Int128Mul(e.Y-i.Y,i.X-n.X),p.Int128Mul(e.X-i.X,i.Y-n.Y)):t.Cast_Int64((e.Y-i.Y)*(i.X-n.X))-t.Cast_Int64((e.X-i.X)*(i.Y-n.Y))==0},t.ClipperBase.SlopesEqual5=function(e,i,n,r,o){return o?p.op_Equality(p.Int128Mul(e.Y-i.Y,n.X-r.X),p.Int128Mul(e.X-i.X,n.Y-r.Y)):t.Cast_Int64((e.Y-i.Y)*(n.X-r.X))-t.Cast_Int64((e.X-i.X)*(n.Y-r.Y))==0},t.ClipperBase.prototype.Clear=function(){this.DisposeLocalMinimaList();for(var e=0,i=this.m_edges.length;e<i;++e){for(var n=0,r=this.m_edges[e].length;n<r;++n)this.m_edges[e][n]=null;t.Clear(this.m_edges[e])}t.Clear(this.m_edges),this.m_UseFullRange=!1,this.m_HasOpenPaths=!1},t.ClipperBase.prototype.DisposeLocalMinimaList=function(){for(;null!==this.m_MinimaList;){var e=this.m_MinimaList.Next;this.m_MinimaList=null,this.m_MinimaList=e}this.m_CurrentLM=null},t.ClipperBase.prototype.RangeTest=function(e,i){i.Value?(e.X>t.ClipperBase.hiRange||e.Y>t.ClipperBase.hiRange||-e.X>t.ClipperBase.hiRange||-e.Y>t.ClipperBase.hiRange)&&t.Error("Coordinate outside allowed range in RangeTest()."):(e.X>t.ClipperBase.loRange||e.Y>t.ClipperBase.loRange||-e.X>t.ClipperBase.loRange||-e.Y>t.ClipperBase.loRange)&&(i.Value=!0,this.RangeTest(e,i))},t.ClipperBase.prototype.InitEdge=function(e,i,n,r){e.Next=i,e.Prev=n,e.Curr.X=r.X,e.Curr.Y=r.Y,t.use_xyz&&(e.Curr.Z=r.Z),e.OutIdx=-1},t.ClipperBase.prototype.InitEdge2=function(e,i){e.Curr.Y>=e.Next.Curr.Y?(e.Bot.X=e.Curr.X,e.Bot.Y=e.Curr.Y,t.use_xyz&&(e.Bot.Z=e.Curr.Z),e.Top.X=e.Next.Curr.X,e.Top.Y=e.Next.Curr.Y,t.use_xyz&&(e.Top.Z=e.Next.Curr.Z)):(e.Top.X=e.Curr.X,e.Top.Y=e.Curr.Y,t.use_xyz&&(e.Top.Z=e.Curr.Z),e.Bot.X=e.Next.Curr.X,e.Bot.Y=e.Next.Curr.Y,t.use_xyz&&(e.Bot.Z=e.Next.Curr.Z)),this.SetDx(e),e.PolyTyp=i},t.ClipperBase.prototype.FindNextLocMin=function(e){for(var i;;){for(;t.IntPoint.op_Inequality(e.Bot,e.Prev.Bot)||t.IntPoint.op_Equality(e.Curr,e.Top);)e=e.Next;if(e.Dx!==t.ClipperBase.horizontal&&e.Prev.Dx!==t.ClipperBase.horizontal)break;for(;e.Prev.Dx===t.ClipperBase.horizontal;)e=e.Prev;for(i=e;e.Dx===t.ClipperBase.horizontal;)e=e.Next;if(e.Top.Y!==e.Prev.Bot.Y){i.Prev.Bot.X<e.Bot.X&&(e=i);break}}return e},t.ClipperBase.prototype.ProcessBound=function(e,i){var n,r,o=e;if(o.OutIdx===t.ClipperBase.Skip){if(e=o,i){for(;e.Top.Y===e.Next.Bot.Y;)e=e.Next;for(;e!==o&&e.Dx===t.ClipperBase.horizontal;)e=e.Prev}else{for(;e.Top.Y===e.Prev.Bot.Y;)e=e.Prev;for(;e!==o&&e.Dx===t.ClipperBase.horizontal;)e=e.Next}if(e===o)o=i?e.Next:e.Prev;else{e=i?o.Next:o.Prev;var s=new t.LocalMinima;s.Next=null,s.Y=e.Bot.Y,s.LeftBound=null,s.RightBound=e,e.WindDelta=0,o=this.ProcessBound(e,i),this.InsertLocalMinima(s)}return o}if(e.Dx===t.ClipperBase.horizontal&&((n=i?e.Prev:e.Next).Dx===t.ClipperBase.horizontal?n.Bot.X!==e.Bot.X&&n.Top.X!==e.Bot.X&&this.ReverseHorizontal(e):n.Bot.X!==e.Bot.X&&this.ReverseHorizontal(e)),n=e,i){for(;o.Top.Y===o.Next.Bot.Y&&o.Next.OutIdx!==t.ClipperBase.Skip;)o=o.Next;if(o.Dx===t.ClipperBase.horizontal&&o.Next.OutIdx!==t.ClipperBase.Skip){for(r=o;r.Prev.Dx===t.ClipperBase.horizontal;)r=r.Prev;r.Prev.Top.X>o.Next.Top.X&&(o=r.Prev)}for(;e!==o;)e.NextInLML=e.Next,e.Dx===t.ClipperBase.horizontal&&e!==n&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),e=e.Next;e.Dx===t.ClipperBase.horizontal&&e!==n&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),o=o.Next}else{for(;o.Top.Y===o.Prev.Bot.Y&&o.Prev.OutIdx!==t.ClipperBase.Skip;)o=o.Prev;if(o.Dx===t.ClipperBase.horizontal&&o.Prev.OutIdx!==t.ClipperBase.Skip){for(r=o;r.Next.Dx===t.ClipperBase.horizontal;)r=r.Next;(r.Next.Top.X===o.Prev.Top.X||r.Next.Top.X>o.Prev.Top.X)&&(o=r.Next)}for(;e!==o;)e.NextInLML=e.Prev,e.Dx===t.ClipperBase.horizontal&&e!==n&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),e=e.Prev;e.Dx===t.ClipperBase.horizontal&&e!==n&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),o=o.Prev}return o},t.ClipperBase.prototype.AddPath=function(e,i,n){t.use_lines?n||i!==t.PolyType.ptClip||t.Error("AddPath: Open paths must be subject."):n||t.Error("AddPath: Open paths have been disabled.");var r=e.length-1;if(n)for(;r>0&&t.IntPoint.op_Equality(e[r],e[0]);)--r;for(;r>0&&t.IntPoint.op_Equality(e[r],e[r-1]);)--r;if(n&&r<2||!n&&r<1)return!1;for(var o=new Array,s=0;s<=r;s++)o.push(new t.TEdge);var A=!0;o[1].Curr.X=e[1].X,o[1].Curr.Y=e[1].Y,t.use_xyz&&(o[1].Curr.Z=e[1].Z);var a={Value:this.m_UseFullRange};for(this.RangeTest(e[0],a),this.m_UseFullRange=a.Value,a.Value=this.m_UseFullRange,this.RangeTest(e[r],a),this.m_UseFullRange=a.Value,this.InitEdge(o[0],o[1],o[r],e[0]),this.InitEdge(o[r],o[0],o[r-1],e[r]),s=r-1;s>=1;--s)a.Value=this.m_UseFullRange,this.RangeTest(e[s],a),this.m_UseFullRange=a.Value,this.InitEdge(o[s],o[s+1],o[s-1],e[s]);for(var l,c=o[0],p=c,h=c;;)if(p.Curr!==p.Next.Curr||!n&&p.Next===c){if(p.Prev===p.Next)break;if(!n||!t.ClipperBase.SlopesEqual4(p.Prev.Curr,p.Curr,p.Next.Curr,this.m_UseFullRange)||this.PreserveCollinear&&this.Pt2IsBetweenPt1AndPt3(p.Prev.Curr,p.Curr,p.Next.Curr)){if((p=p.Next)===h||!n&&p.Next===c)break}else p===c&&(c=p.Next),h=p=(p=this.RemoveEdge(p)).Prev}else{if(p===p.Next)break;p===c&&(c=p.Next),h=p=this.RemoveEdge(p)}if(!n&&p===p.Next||n&&p.Prev===p.Next)return!1;n||(this.m_HasOpenPaths=!0,c.Prev.OutIdx=t.ClipperBase.Skip),p=c;do{this.InitEdge2(p,i),p=p.Next,A&&p.Curr.Y!==c.Curr.Y&&(A=!1)}while(p!==c);if(A){if(n)return!1;for(p.Prev.OutIdx=t.ClipperBase.Skip,(u=new t.LocalMinima).Next=null,u.Y=p.Bot.Y,u.LeftBound=null,u.RightBound=p,u.RightBound.Side=t.EdgeSide.esRight,u.RightBound.WindDelta=0;p.Bot.X!==p.Prev.Top.X&&this.ReverseHorizontal(p),p.Next.OutIdx!==t.ClipperBase.Skip;)p.NextInLML=p.Next,p=p.Next;return this.InsertLocalMinima(u),this.m_edges.push(o),!0}this.m_edges.push(o);var g=null;for(t.IntPoint.op_Equality(p.Prev.Bot,p.Prev.Top)&&(p=p.Next);(p=this.FindNextLocMin(p))!==g;){var u;null===g&&(g=p),(u=new t.LocalMinima).Next=null,u.Y=p.Bot.Y,p.Dx<p.Prev.Dx?(u.LeftBound=p.Prev,u.RightBound=p,l=!1):(u.LeftBound=p,u.RightBound=p.Prev,l=!0),u.LeftBound.Side=t.EdgeSide.esLeft,u.RightBound.Side=t.EdgeSide.esRight,n?u.LeftBound.Next===u.RightBound?u.LeftBound.WindDelta=-1:u.LeftBound.WindDelta=1:u.LeftBound.WindDelta=0,u.RightBound.WindDelta=-u.LeftBound.WindDelta,(p=this.ProcessBound(u.LeftBound,l)).OutIdx===t.ClipperBase.Skip&&(p=this.ProcessBound(p,l));var d=this.ProcessBound(u.RightBound,!l);d.OutIdx===t.ClipperBase.Skip&&(d=this.ProcessBound(d,!l)),u.LeftBound.OutIdx===t.ClipperBase.Skip?u.LeftBound=null:u.RightBound.OutIdx===t.ClipperBase.Skip&&(u.RightBound=null),this.InsertLocalMinima(u),l||(p=d)}return!0},t.ClipperBase.prototype.AddPaths=function(e,t,i){for(var n=!1,r=0,o=e.length;r<o;++r)this.AddPath(e[r],t,i)&&(n=!0);return n},t.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(e,i,n){return!(t.IntPoint.op_Equality(e,n)||t.IntPoint.op_Equality(e,i)||t.IntPoint.op_Equality(n,i))&&(e.X!==n.X?i.X>e.X==i.X<n.X:i.Y>e.Y==i.Y<n.Y)},t.ClipperBase.prototype.RemoveEdge=function(e){e.Prev.Next=e.Next,e.Next.Prev=e.Prev;var t=e.Next;return e.Prev=null,t},t.ClipperBase.prototype.SetDx=function(e){e.Delta.X=e.Top.X-e.Bot.X,e.Delta.Y=e.Top.Y-e.Bot.Y,0===e.Delta.Y?e.Dx=t.ClipperBase.horizontal:e.Dx=e.Delta.X/e.Delta.Y},t.ClipperBase.prototype.InsertLocalMinima=function(e){if(null===this.m_MinimaList)this.m_MinimaList=e;else if(e.Y>=this.m_MinimaList.Y)e.Next=this.m_MinimaList,this.m_MinimaList=e;else{for(var t=this.m_MinimaList;null!==t.Next&&e.Y<t.Next.Y;)t=t.Next;e.Next=t.Next,t.Next=e}},t.ClipperBase.prototype.PopLocalMinima=function(e,t){return t.v=this.m_CurrentLM,null!==this.m_CurrentLM&&this.m_CurrentLM.Y===e&&(this.m_CurrentLM=this.m_CurrentLM.Next,!0)},t.ClipperBase.prototype.ReverseHorizontal=function(e){var i=e.Top.X;e.Top.X=e.Bot.X,e.Bot.X=i,t.use_xyz&&(i=e.Top.Z,e.Top.Z=e.Bot.Z,e.Bot.Z=i)},t.ClipperBase.prototype.Reset=function(){if(this.m_CurrentLM=this.m_MinimaList,null!==this.m_CurrentLM){this.m_Scanbeam=null;for(var e=this.m_MinimaList;null!==e;){this.InsertScanbeam(e.Y);var i=e.LeftBound;null!==i&&(i.Curr.X=i.Bot.X,i.Curr.Y=i.Bot.Y,t.use_xyz&&(i.Curr.Z=i.Bot.Z),i.OutIdx=t.ClipperBase.Unassigned),null!==(i=e.RightBound)&&(i.Curr.X=i.Bot.X,i.Curr.Y=i.Bot.Y,t.use_xyz&&(i.Curr.Z=i.Bot.Z),i.OutIdx=t.ClipperBase.Unassigned),e=e.Next}this.m_ActiveEdges=null}},t.ClipperBase.prototype.InsertScanbeam=function(e){if(null===this.m_Scanbeam)this.m_Scanbeam=new t.Scanbeam,this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=e;else if(e>this.m_Scanbeam.Y){var i=new t.Scanbeam;i.Y=e,i.Next=this.m_Scanbeam,this.m_Scanbeam=i}else{for(var n=this.m_Scanbeam;null!==n.Next&&e<=n.Next.Y;)n=n.Next;if(e===n.Y)return;var r=new t.Scanbeam;r.Y=e,r.Next=n.Next,n.Next=r}},t.ClipperBase.prototype.PopScanbeam=function(e){return null===this.m_Scanbeam?(e.v=0,!1):(e.v=this.m_Scanbeam.Y,this.m_Scanbeam=this.m_Scanbeam.Next,!0)},t.ClipperBase.prototype.LocalMinimaPending=function(){return null!==this.m_CurrentLM},t.ClipperBase.prototype.CreateOutRec=function(){var e=new t.OutRec;return e.Idx=t.ClipperBase.Unassigned,e.IsHole=!1,e.IsOpen=!1,e.FirstLeft=null,e.Pts=null,e.BottomPt=null,e.PolyNode=null,this.m_PolyOuts.push(e),e.Idx=this.m_PolyOuts.length-1,e},t.ClipperBase.prototype.DisposeOutRec=function(e){var t=this.m_PolyOuts[e];t.Pts=null,t=null,this.m_PolyOuts[e]=null},t.ClipperBase.prototype.UpdateEdgeIntoAEL=function(e){null===e.NextInLML&&t.Error("UpdateEdgeIntoAEL: invalid call");var i=e.PrevInAEL,n=e.NextInAEL;return e.NextInLML.OutIdx=e.OutIdx,null!==i?i.NextInAEL=e.NextInLML:this.m_ActiveEdges=e.NextInLML,null!==n&&(n.PrevInAEL=e.NextInLML),e.NextInLML.Side=e.Side,e.NextInLML.WindDelta=e.WindDelta,e.NextInLML.WindCnt=e.WindCnt,e.NextInLML.WindCnt2=e.WindCnt2,(e=e.NextInLML).Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,e.PrevInAEL=i,e.NextInAEL=n,t.ClipperBase.IsHorizontal(e)||this.InsertScanbeam(e.Top.Y),e},t.ClipperBase.prototype.SwapPositionsInAEL=function(e,t){if(e.NextInAEL!==e.PrevInAEL&&t.NextInAEL!==t.PrevInAEL){if(e.NextInAEL===t){var i=t.NextInAEL;null!==i&&(i.PrevInAEL=e);var n=e.PrevInAEL;null!==n&&(n.NextInAEL=t),t.PrevInAEL=n,t.NextInAEL=e,e.PrevInAEL=t,e.NextInAEL=i}else if(t.NextInAEL===e){var r=e.NextInAEL;null!==r&&(r.PrevInAEL=t);var o=t.PrevInAEL;null!==o&&(o.NextInAEL=e),e.PrevInAEL=o,e.NextInAEL=t,t.PrevInAEL=e,t.NextInAEL=r}else{var s=e.NextInAEL,A=e.PrevInAEL;e.NextInAEL=t.NextInAEL,null!==e.NextInAEL&&(e.NextInAEL.PrevInAEL=e),e.PrevInAEL=t.PrevInAEL,null!==e.PrevInAEL&&(e.PrevInAEL.NextInAEL=e),t.NextInAEL=s,null!==t.NextInAEL&&(t.NextInAEL.PrevInAEL=t),t.PrevInAEL=A,null!==t.PrevInAEL&&(t.PrevInAEL.NextInAEL=t)}null===e.PrevInAEL?this.m_ActiveEdges=e:null===t.PrevInAEL&&(this.m_ActiveEdges=t)}},t.ClipperBase.prototype.DeleteFromAEL=function(e){var t=e.PrevInAEL,i=e.NextInAEL;null===t&&null===i&&e!==this.m_ActiveEdges||(null!==t?t.NextInAEL=i:this.m_ActiveEdges=i,null!==i&&(i.PrevInAEL=t),e.NextInAEL=null,e.PrevInAEL=null)},t.Clipper=function(e){void 0===e&&(e=0),this.m_PolyOuts=null,this.m_ClipType=t.ClipType.ctIntersection,this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=null,this.m_IntersectNodeComparer=null,this.m_ExecuteLocked=!1,this.m_ClipFillType=t.PolyFillType.pftEvenOdd,this.m_SubjFillType=t.PolyFillType.pftEvenOdd,this.m_Joins=null,this.m_GhostJoins=null,this.m_UsingPolyTree=!1,this.ReverseSolution=!1,this.StrictlySimple=!1,t.ClipperBase.call(this),this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=new Array,this.m_IntersectNodeComparer=t.MyIntersectNodeSort.Compare,this.m_ExecuteLocked=!1,this.m_UsingPolyTree=!1,this.m_PolyOuts=new Array,this.m_Joins=new Array,this.m_GhostJoins=new Array,this.ReverseSolution=!!(1&e),this.StrictlySimple=!!(2&e),this.PreserveCollinear=!!(4&e),t.use_xyz&&(this.ZFillFunction=null)},t.Clipper.ioReverseSolution=1,t.Clipper.ioStrictlySimple=2,t.Clipper.ioPreserveCollinear=4,t.Clipper.prototype.Clear=function(){0!==this.m_edges.length&&(this.DisposeAllPolyPts(),t.ClipperBase.prototype.Clear.call(this))},t.Clipper.prototype.InsertMaxima=function(e){var i=new t.Maxima;if(i.X=e,null===this.m_Maxima)this.m_Maxima=i,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(e<this.m_Maxima.X)i.Next=this.m_Maxima,i.Prev=null,this.m_Maxima=i;else{for(var n=this.m_Maxima;null!==n.Next&&e>=n.Next.X;)n=n.Next;if(e===n.X)return;i.Next=n.Next,i.Prev=n,null!==n.Next&&(n.Next.Prev=i),n.Next=i}},t.Clipper.prototype.Execute=function(){var e=arguments,i=e.length,n=e[1]instanceof t.PolyTree;if(4===i&&!n){var r=e[0],o=e[1],s=e[2],A=e[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&t.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,t.Clear(o),this.m_SubjFillType=s,this.m_ClipFillType=A,this.m_ClipType=r,this.m_UsingPolyTree=!1;try{(l=this.ExecuteInternal())&&this.BuildResult(o)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return l}if(4===i&&n){r=e[0];var a=e[1];if(s=e[2],A=e[3],this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=s,this.m_ClipFillType=A,this.m_ClipType=r,this.m_UsingPolyTree=!0;try{var l;(l=this.ExecuteInternal())&&this.BuildResult2(a)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return l}return 2!==i||n?2===i&&n?(r=e[0],a=e[1],this.Execute(r,a,t.PolyFillType.pftEvenOdd,t.PolyFillType.pftEvenOdd)):void 0:(r=e[0],o=e[1],this.Execute(r,o,t.PolyFillType.pftEvenOdd,t.PolyFillType.pftEvenOdd))},t.Clipper.prototype.FixHoleLinkage=function(e){if(null!==e.FirstLeft&&(e.IsHole===e.FirstLeft.IsHole||null===e.FirstLeft.Pts)){for(var t=e.FirstLeft;null!==t&&(t.IsHole===e.IsHole||null===t.Pts);)t=t.FirstLeft;e.FirstLeft=t}},t.Clipper.prototype.ExecuteInternal=function(){try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var e,t,i,n={},r={};if(!this.PopScanbeam(n))return!1;for(this.InsertLocalMinimaIntoAEL(n.v);this.PopScanbeam(r)||this.LocalMinimaPending();){if(this.ProcessHorizontals(),this.m_GhostJoins.length=0,!this.ProcessIntersections(r.v))return!1;this.ProcessEdgesAtTopOfScanbeam(r.v),n.v=r.v,this.InsertLocalMinimaIntoAEL(n.v)}for(t=0,i=this.m_PolyOuts.length;t<i;t++)null===(e=this.m_PolyOuts[t]).Pts||e.IsOpen||(e.IsHole^this.ReverseSolution)==this.Area$1(e)>0&&this.ReversePolyPtLinks(e.Pts);for(this.JoinCommonEdges(),t=0,i=this.m_PolyOuts.length;t<i;t++)null!==(e=this.m_PolyOuts[t]).Pts&&(e.IsOpen?this.FixupOutPolyline(e):this.FixupOutPolygon(e));return this.StrictlySimple&&this.DoSimplePolygons(),!0}finally{this.m_Joins.length=0,this.m_GhostJoins.length=0}},t.Clipper.prototype.DisposeAllPolyPts=function(){for(var e=0,i=this.m_PolyOuts.length;e<i;++e)this.DisposeOutRec(e);t.Clear(this.m_PolyOuts)},t.Clipper.prototype.AddJoin=function(e,i,n){var r=new t.Join;r.OutPt1=e,r.OutPt2=i,r.OffPt.X=n.X,r.OffPt.Y=n.Y,t.use_xyz&&(r.OffPt.Z=n.Z),this.m_Joins.push(r)},t.Clipper.prototype.AddGhostJoin=function(e,i){var n=new t.Join;n.OutPt1=e,n.OffPt.X=i.X,n.OffPt.Y=i.Y,t.use_xyz&&(n.OffPt.Z=i.Z),this.m_GhostJoins.push(n)},t.Clipper.prototype.SetZ=function(e,i,n){if(null!==this.ZFillFunction){if(0!==e.Z||null===this.ZFillFunction)return;t.IntPoint.op_Equality(e,i.Bot)?e.Z=i.Bot.Z:t.IntPoint.op_Equality(e,i.Top)?e.Z=i.Top.Z:t.IntPoint.op_Equality(e,n.Bot)?e.Z=n.Bot.Z:t.IntPoint.op_Equality(e,n.Top)?e.Z=n.Top.Z:this.ZFillFunction(i.Bot,i.Top,n.Bot,n.Top,e)}},t.Clipper.prototype.InsertLocalMinimaIntoAEL=function(e){for(var i,n,r={};this.PopLocalMinima(e,r);){i=r.v.LeftBound,n=r.v.RightBound;var o=null;if(null===i?(this.InsertEdgeIntoAEL(n,null),this.SetWindingCount(n),this.IsContributing(n)&&(o=this.AddOutPt(n,n.Bot))):null===n?(this.InsertEdgeIntoAEL(i,null),this.SetWindingCount(i),this.IsContributing(i)&&(o=this.AddOutPt(i,i.Bot)),this.InsertScanbeam(i.Top.Y)):(this.InsertEdgeIntoAEL(i,null),this.InsertEdgeIntoAEL(n,i),this.SetWindingCount(i),n.WindCnt=i.WindCnt,n.WindCnt2=i.WindCnt2,this.IsContributing(i)&&(o=this.AddLocalMinPoly(i,n,i.Bot)),this.InsertScanbeam(i.Top.Y)),null!==n&&(t.ClipperBase.IsHorizontal(n)?(null!==n.NextInLML&&this.InsertScanbeam(n.NextInLML.Top.Y),this.AddEdgeToSEL(n)):this.InsertScanbeam(n.Top.Y)),null!==i&&null!==n){if(null!==o&&t.ClipperBase.IsHorizontal(n)&&this.m_GhostJoins.length>0&&0!==n.WindDelta)for(var s=0,A=this.m_GhostJoins.length;s<A;s++){var a=this.m_GhostJoins[s];this.HorzSegmentsOverlap(a.OutPt1.Pt.X,a.OffPt.X,n.Bot.X,n.Top.X)&&this.AddJoin(a.OutPt1,o,a.OffPt)}if(i.OutIdx>=0&&null!==i.PrevInAEL&&i.PrevInAEL.Curr.X===i.Bot.X&&i.PrevInAEL.OutIdx>=0&&t.ClipperBase.SlopesEqual5(i.PrevInAEL.Curr,i.PrevInAEL.Top,i.Curr,i.Top,this.m_UseFullRange)&&0!==i.WindDelta&&0!==i.PrevInAEL.WindDelta){var l=this.AddOutPt(i.PrevInAEL,i.Bot);this.AddJoin(o,l,i.Top)}if(i.NextInAEL!==n){n.OutIdx>=0&&n.PrevInAEL.OutIdx>=0&&t.ClipperBase.SlopesEqual5(n.PrevInAEL.Curr,n.PrevInAEL.Top,n.Curr,n.Top,this.m_UseFullRange)&&0!==n.WindDelta&&0!==n.PrevInAEL.WindDelta&&(l=this.AddOutPt(n.PrevInAEL,n.Bot),this.AddJoin(o,l,n.Top));var c=i.NextInAEL;if(null!==c)for(;c!==n;)this.IntersectEdges(n,c,i.Curr),c=c.NextInAEL}}}},t.Clipper.prototype.InsertEdgeIntoAEL=function(e,t){if(null===this.m_ActiveEdges)e.PrevInAEL=null,e.NextInAEL=null,this.m_ActiveEdges=e;else if(null===t&&this.E2InsertsBeforeE1(this.m_ActiveEdges,e))e.PrevInAEL=null,e.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=e,this.m_ActiveEdges=e;else{for(null===t&&(t=this.m_ActiveEdges);null!==t.NextInAEL&&!this.E2InsertsBeforeE1(t.NextInAEL,e);)t=t.NextInAEL;e.NextInAEL=t.NextInAEL,null!==t.NextInAEL&&(t.NextInAEL.PrevInAEL=e),e.PrevInAEL=t,t.NextInAEL=e}},t.Clipper.prototype.E2InsertsBeforeE1=function(e,i){return i.Curr.X===e.Curr.X?i.Top.Y>e.Top.Y?i.Top.X<t.Clipper.TopX(e,i.Top.Y):e.Top.X>t.Clipper.TopX(i,e.Top.Y):i.Curr.X<e.Curr.X},t.Clipper.prototype.IsEvenOddFillType=function(e){return e.PolyTyp===t.PolyType.ptSubject?this.m_SubjFillType===t.PolyFillType.pftEvenOdd:this.m_ClipFillType===t.PolyFillType.pftEvenOdd},t.Clipper.prototype.IsEvenOddAltFillType=function(e){return e.PolyTyp===t.PolyType.ptSubject?this.m_ClipFillType===t.PolyFillType.pftEvenOdd:this.m_SubjFillType===t.PolyFillType.pftEvenOdd},t.Clipper.prototype.IsContributing=function(e){var i,n;switch(e.PolyTyp===t.PolyType.ptSubject?(i=this.m_SubjFillType,n=this.m_ClipFillType):(i=this.m_ClipFillType,n=this.m_SubjFillType),i){case t.PolyFillType.pftEvenOdd:if(0===e.WindDelta&&1!==e.WindCnt)return!1;break;case t.PolyFillType.pftNonZero:if(1!==Math.abs(e.WindCnt))return!1;break;case t.PolyFillType.pftPositive:if(1!==e.WindCnt)return!1;break;default:if(-1!==e.WindCnt)return!1}switch(this.m_ClipType){case t.ClipType.ctIntersection:switch(n){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return 0!==e.WindCnt2;case t.PolyFillType.pftPositive:return e.WindCnt2>0;default:return e.WindCnt2<0}case t.ClipType.ctUnion:switch(n){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return 0===e.WindCnt2;case t.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}case t.ClipType.ctDifference:if(e.PolyTyp===t.PolyType.ptSubject)switch(n){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return 0===e.WindCnt2;case t.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}else switch(n){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return 0!==e.WindCnt2;case t.PolyFillType.pftPositive:return e.WindCnt2>0;default:return e.WindCnt2<0}case t.ClipType.ctXor:if(0!==e.WindDelta)return!0;switch(n){case t.PolyFillType.pftEvenOdd:case t.PolyFillType.pftNonZero:return 0===e.WindCnt2;case t.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}}return!0},t.Clipper.prototype.SetWindingCount=function(e){for(var i=e.PrevInAEL;null!==i&&(i.PolyTyp!==e.PolyTyp||0===i.WindDelta);)i=i.PrevInAEL;if(null===i){var n=e.PolyTyp===t.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;0===e.WindDelta?e.WindCnt=n===t.PolyFillType.pftNegative?-1:1:e.WindCnt=e.WindDelta,e.WindCnt2=0,i=this.m_ActiveEdges}else if(0===e.WindDelta&&this.m_ClipType!==t.ClipType.ctUnion)e.WindCnt=1,e.WindCnt2=i.WindCnt2,i=i.NextInAEL;else if(this.IsEvenOddFillType(e)){if(0===e.WindDelta){for(var r=!0,o=i.PrevInAEL;null!==o;)o.PolyTyp===i.PolyTyp&&0!==o.WindDelta&&(r=!r),o=o.PrevInAEL;e.WindCnt=r?0:1}else e.WindCnt=e.WindDelta;e.WindCnt2=i.WindCnt2,i=i.NextInAEL}else i.WindCnt*i.WindDelta<0?Math.abs(i.WindCnt)>1?i.WindDelta*e.WindDelta<0?e.WindCnt=i.WindCnt:e.WindCnt=i.WindCnt+e.WindDelta:e.WindCnt=0===e.WindDelta?1:e.WindDelta:0===e.WindDelta?e.WindCnt=i.WindCnt<0?i.WindCnt-1:i.WindCnt+1:i.WindDelta*e.WindDelta<0?e.WindCnt=i.WindCnt:e.WindCnt=i.WindCnt+e.WindDelta,e.WindCnt2=i.WindCnt2,i=i.NextInAEL;if(this.IsEvenOddAltFillType(e))for(;i!==e;)0!==i.WindDelta&&(e.WindCnt2=0===e.WindCnt2?1:0),i=i.NextInAEL;else for(;i!==e;)e.WindCnt2+=i.WindDelta,i=i.NextInAEL},t.Clipper.prototype.AddEdgeToSEL=function(e){null===this.m_SortedEdges?(this.m_SortedEdges=e,e.PrevInSEL=null,e.NextInSEL=null):(e.NextInSEL=this.m_SortedEdges,e.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=e,this.m_SortedEdges=e)},t.Clipper.prototype.PopEdgeFromSEL=function(e){if(e.v=this.m_SortedEdges,null===e.v)return!1;var t=e.v;return this.m_SortedEdges=e.v.NextInSEL,null!==this.m_SortedEdges&&(this.m_SortedEdges.PrevInSEL=null),t.NextInSEL=null,t.PrevInSEL=null,!0},t.Clipper.prototype.CopyAELToSEL=function(){var e=this.m_ActiveEdges;for(this.m_SortedEdges=e;null!==e;)e.PrevInSEL=e.PrevInAEL,e.NextInSEL=e.NextInAEL,e=e.NextInAEL},t.Clipper.prototype.SwapPositionsInSEL=function(e,t){if(!(null===e.NextInSEL&&null===e.PrevInSEL||null===t.NextInSEL&&null===t.PrevInSEL)){if(e.NextInSEL===t)null!==(i=t.NextInSEL)&&(i.PrevInSEL=e),null!==(n=e.PrevInSEL)&&(n.NextInSEL=t),t.PrevInSEL=n,t.NextInSEL=e,e.PrevInSEL=t,e.NextInSEL=i;else if(t.NextInSEL===e)null!==(i=e.NextInSEL)&&(i.PrevInSEL=t),null!==(n=t.PrevInSEL)&&(n.NextInSEL=e),e.PrevInSEL=n,e.NextInSEL=t,t.PrevInSEL=e,t.NextInSEL=i;else{var i=e.NextInSEL,n=e.PrevInSEL;e.NextInSEL=t.NextInSEL,null!==e.NextInSEL&&(e.NextInSEL.PrevInSEL=e),e.PrevInSEL=t.PrevInSEL,null!==e.PrevInSEL&&(e.PrevInSEL.NextInSEL=e),t.NextInSEL=i,null!==t.NextInSEL&&(t.NextInSEL.PrevInSEL=t),t.PrevInSEL=n,null!==t.PrevInSEL&&(t.PrevInSEL.NextInSEL=t)}null===e.PrevInSEL?this.m_SortedEdges=e:null===t.PrevInSEL&&(this.m_SortedEdges=t)}},t.Clipper.prototype.AddLocalMaxPoly=function(e,t,i){this.AddOutPt(e,i),0===t.WindDelta&&this.AddOutPt(t,i),e.OutIdx===t.OutIdx?(e.OutIdx=-1,t.OutIdx=-1):e.OutIdx<t.OutIdx?this.AppendPolygon(e,t):this.AppendPolygon(t,e)},t.Clipper.prototype.AddLocalMinPoly=function(e,i,n){var r,o,s;if(t.ClipperBase.IsHorizontal(i)||e.Dx>i.Dx?(r=this.AddOutPt(e,n),i.OutIdx=e.OutIdx,e.Side=t.EdgeSide.esLeft,i.Side=t.EdgeSide.esRight,s=(o=e).PrevInAEL===i?i.PrevInAEL:o.PrevInAEL):(r=this.AddOutPt(i,n),e.OutIdx=i.OutIdx,e.Side=t.EdgeSide.esRight,i.Side=t.EdgeSide.esLeft,s=(o=i).PrevInAEL===e?e.PrevInAEL:o.PrevInAEL),null!==s&&s.OutIdx>=0&&s.Top.Y<n.Y&&o.Top.Y<n.Y){var A=t.Clipper.TopX(s,n.Y),a=t.Clipper.TopX(o,n.Y);if(A===a&&0!==o.WindDelta&&0!==s.WindDelta&&t.ClipperBase.SlopesEqual5(new t.IntPoint2(A,n.Y),s.Top,new t.IntPoint2(a,n.Y),o.Top,this.m_UseFullRange)){var l=this.AddOutPt(s,n);this.AddJoin(r,l,o.Top)}}return r},t.Clipper.prototype.AddOutPt=function(e,i){if(e.OutIdx<0){(r=this.CreateOutRec()).IsOpen=0===e.WindDelta;var n=new t.OutPt;return r.Pts=n,n.Idx=r.Idx,n.Pt.X=i.X,n.Pt.Y=i.Y,t.use_xyz&&(n.Pt.Z=i.Z),n.Next=n,n.Prev=n,r.IsOpen||this.SetHoleState(e,r),e.OutIdx=r.Idx,n}var r,o=(r=this.m_PolyOuts[e.OutIdx]).Pts,s=e.Side===t.EdgeSide.esLeft;return s&&t.IntPoint.op_Equality(i,o.Pt)?o:!s&&t.IntPoint.op_Equality(i,o.Prev.Pt)?o.Prev:((n=new t.OutPt).Idx=r.Idx,n.Pt.X=i.X,n.Pt.Y=i.Y,t.use_xyz&&(n.Pt.Z=i.Z),n.Next=o,n.Prev=o.Prev,n.Prev.Next=n,o.Prev=n,s&&(r.Pts=n),n)},t.Clipper.prototype.GetLastOutPt=function(e){var i=this.m_PolyOuts[e.OutIdx];return e.Side===t.EdgeSide.esLeft?i.Pts:i.Pts.Prev},t.Clipper.prototype.SwapPoints=function(e,i){var n=new t.IntPoint1(e.Value);e.Value.X=i.Value.X,e.Value.Y=i.Value.Y,t.use_xyz&&(e.Value.Z=i.Value.Z),i.Value.X=n.X,i.Value.Y=n.Y,t.use_xyz&&(i.Value.Z=n.Z)},t.Clipper.prototype.HorzSegmentsOverlap=function(e,t,i,n){var r;return e>t&&(r=e,e=t,t=r),i>n&&(r=i,i=n,n=r),e<n&&i<t},t.Clipper.prototype.SetHoleState=function(e,t){for(var i=e.PrevInAEL,n=null;null!==i;)i.OutIdx>=0&&0!==i.WindDelta&&(null===n?n=i:n.OutIdx===i.OutIdx&&(n=null)),i=i.PrevInAEL;null===n?(t.FirstLeft=null,t.IsHole=!1):(t.FirstLeft=this.m_PolyOuts[n.OutIdx],t.IsHole=!t.FirstLeft.IsHole)},t.Clipper.prototype.GetDx=function(e,i){return e.Y===i.Y?t.ClipperBase.horizontal:(i.X-e.X)/(i.Y-e.Y)},t.Clipper.prototype.FirstIsBottomPt=function(e,i){for(var n=e.Prev;t.IntPoint.op_Equality(n.Pt,e.Pt)&&n!==e;)n=n.Prev;var r=Math.abs(this.GetDx(e.Pt,n.Pt));for(n=e.Next;t.IntPoint.op_Equality(n.Pt,e.Pt)&&n!==e;)n=n.Next;var o=Math.abs(this.GetDx(e.Pt,n.Pt));for(n=i.Prev;t.IntPoint.op_Equality(n.Pt,i.Pt)&&n!==i;)n=n.Prev;var s=Math.abs(this.GetDx(i.Pt,n.Pt));for(n=i.Next;t.IntPoint.op_Equality(n.Pt,i.Pt)&&n!==i;)n=n.Next;var A=Math.abs(this.GetDx(i.Pt,n.Pt));return Math.max(r,o)===Math.max(s,A)&&Math.min(r,o)===Math.min(s,A)?this.Area(e)>0:r>=s&&r>=A||o>=s&&o>=A},t.Clipper.prototype.GetBottomPt=function(e){for(var i=null,n=e.Next;n!==e;)n.Pt.Y>e.Pt.Y?(e=n,i=null):n.Pt.Y===e.Pt.Y&&n.Pt.X<=e.Pt.X&&(n.Pt.X<e.Pt.X?(i=null,e=n):n.Next!==e&&n.Prev!==e&&(i=n)),n=n.Next;if(null!==i)for(;i!==n;)for(this.FirstIsBottomPt(n,i)||(e=i),i=i.Next;t.IntPoint.op_Inequality(i.Pt,e.Pt);)i=i.Next;return e},t.Clipper.prototype.GetLowermostRec=function(e,t){null===e.BottomPt&&(e.BottomPt=this.GetBottomPt(e.Pts)),null===t.BottomPt&&(t.BottomPt=this.GetBottomPt(t.Pts));var i=e.BottomPt,n=t.BottomPt;return i.Pt.Y>n.Pt.Y?e:i.Pt.Y<n.Pt.Y?t:i.Pt.X<n.Pt.X?e:i.Pt.X>n.Pt.X||i.Next===i?t:n.Next===n||this.FirstIsBottomPt(i,n)?e:t},t.Clipper.prototype.OutRec1RightOfOutRec2=function(e,t){do{if((e=e.FirstLeft)===t)return!0}while(null!==e);return!1},t.Clipper.prototype.GetOutRec=function(e){for(var t=this.m_PolyOuts[e];t!==this.m_PolyOuts[t.Idx];)t=this.m_PolyOuts[t.Idx];return t},t.Clipper.prototype.AppendPolygon=function(e,i){var n,r=this.m_PolyOuts[e.OutIdx],o=this.m_PolyOuts[i.OutIdx];n=this.OutRec1RightOfOutRec2(r,o)?o:this.OutRec1RightOfOutRec2(o,r)?r:this.GetLowermostRec(r,o);var s=r.Pts,A=s.Prev,a=o.Pts,l=a.Prev;e.Side===t.EdgeSide.esLeft?i.Side===t.EdgeSide.esLeft?(this.ReversePolyPtLinks(a),a.Next=s,s.Prev=a,A.Next=l,l.Prev=A,r.Pts=l):(l.Next=s,s.Prev=l,a.Prev=A,A.Next=a,r.Pts=a):i.Side===t.EdgeSide.esRight?(this.ReversePolyPtLinks(a),A.Next=l,l.Prev=A,a.Next=s,s.Prev=a):(A.Next=a,a.Prev=A,s.Prev=l,l.Next=s),r.BottomPt=null,n===o&&(o.FirstLeft!==r&&(r.FirstLeft=o.FirstLeft),r.IsHole=o.IsHole),o.Pts=null,o.BottomPt=null,o.FirstLeft=r;var c=e.OutIdx,p=i.OutIdx;e.OutIdx=-1,i.OutIdx=-1;for(var h=this.m_ActiveEdges;null!==h;){if(h.OutIdx===p){h.OutIdx=c,h.Side=e.Side;break}h=h.NextInAEL}o.Idx=r.Idx},t.Clipper.prototype.ReversePolyPtLinks=function(e){if(null!==e){var t,i;t=e;do{i=t.Next,t.Next=t.Prev,t.Prev=i,t=i}while(t!==e)}},t.Clipper.SwapSides=function(e,t){var i=e.Side;e.Side=t.Side,t.Side=i},t.Clipper.SwapPolyIndexes=function(e,t){var i=e.OutIdx;e.OutIdx=t.OutIdx,t.OutIdx=i},t.Clipper.prototype.IntersectEdges=function(e,i,n){var r=e.OutIdx>=0,o=i.OutIdx>=0;if(t.use_xyz&&this.SetZ(n,e,i),!t.use_lines||0!==e.WindDelta&&0!==i.WindDelta){if(e.PolyTyp===i.PolyTyp)if(this.IsEvenOddFillType(e)){var s=e.WindCnt;e.WindCnt=i.WindCnt,i.WindCnt=s}else e.WindCnt+i.WindDelta===0?e.WindCnt=-e.WindCnt:e.WindCnt+=i.WindDelta,i.WindCnt-e.WindDelta==0?i.WindCnt=-i.WindCnt:i.WindCnt-=e.WindDelta;else this.IsEvenOddFillType(i)?e.WindCnt2=0===e.WindCnt2?1:0:e.WindCnt2+=i.WindDelta,this.IsEvenOddFillType(e)?i.WindCnt2=0===i.WindCnt2?1:0:i.WindCnt2-=e.WindDelta;var A,a,l,c,p,h;switch(e.PolyTyp===t.PolyType.ptSubject?(A=this.m_SubjFillType,l=this.m_ClipFillType):(A=this.m_ClipFillType,l=this.m_SubjFillType),i.PolyTyp===t.PolyType.ptSubject?(a=this.m_SubjFillType,c=this.m_ClipFillType):(a=this.m_ClipFillType,c=this.m_SubjFillType),A){case t.PolyFillType.pftPositive:p=e.WindCnt;break;case t.PolyFillType.pftNegative:p=-e.WindCnt;break;default:p=Math.abs(e.WindCnt)}switch(a){case t.PolyFillType.pftPositive:h=i.WindCnt;break;case t.PolyFillType.pftNegative:h=-i.WindCnt;break;default:h=Math.abs(i.WindCnt)}if(r&&o)0!==p&&1!==p||0!==h&&1!==h||e.PolyTyp!==i.PolyTyp&&this.m_ClipType!==t.ClipType.ctXor?this.AddLocalMaxPoly(e,i,n):(this.AddOutPt(e,n),this.AddOutPt(i,n),t.Clipper.SwapSides(e,i),t.Clipper.SwapPolyIndexes(e,i));else if(r)0!==h&&1!==h||(this.AddOutPt(e,n),t.Clipper.SwapSides(e,i),t.Clipper.SwapPolyIndexes(e,i));else if(o)0!==p&&1!==p||(this.AddOutPt(i,n),t.Clipper.SwapSides(e,i),t.Clipper.SwapPolyIndexes(e,i));else if(!(0!==p&&1!==p||0!==h&&1!==h)){var g,u;switch(l){case t.PolyFillType.pftPositive:g=e.WindCnt2;break;case t.PolyFillType.pftNegative:g=-e.WindCnt2;break;default:g=Math.abs(e.WindCnt2)}switch(c){case t.PolyFillType.pftPositive:u=i.WindCnt2;break;case t.PolyFillType.pftNegative:u=-i.WindCnt2;break;default:u=Math.abs(i.WindCnt2)}if(e.PolyTyp!==i.PolyTyp)this.AddLocalMinPoly(e,i,n);else if(1===p&&1===h)switch(this.m_ClipType){case t.ClipType.ctIntersection:g>0&&u>0&&this.AddLocalMinPoly(e,i,n);break;case t.ClipType.ctUnion:g<=0&&u<=0&&this.AddLocalMinPoly(e,i,n);break;case t.ClipType.ctDifference:(e.PolyTyp===t.PolyType.ptClip&&g>0&&u>0||e.PolyTyp===t.PolyType.ptSubject&&g<=0&&u<=0)&&this.AddLocalMinPoly(e,i,n);break;case t.ClipType.ctXor:this.AddLocalMinPoly(e,i,n)}else t.Clipper.SwapSides(e,i)}}else{if(0===e.WindDelta&&0===i.WindDelta)return;e.PolyTyp===i.PolyTyp&&e.WindDelta!==i.WindDelta&&this.m_ClipType===t.ClipType.ctUnion?0===e.WindDelta?o&&(this.AddOutPt(e,n),r&&(e.OutIdx=-1)):r&&(this.AddOutPt(i,n),o&&(i.OutIdx=-1)):e.PolyTyp!==i.PolyTyp&&(0!==e.WindDelta||1!==Math.abs(i.WindCnt)||this.m_ClipType===t.ClipType.ctUnion&&0!==i.WindCnt2?0!==i.WindDelta||1!==Math.abs(e.WindCnt)||this.m_ClipType===t.ClipType.ctUnion&&0!==e.WindCnt2||(this.AddOutPt(i,n),o&&(i.OutIdx=-1)):(this.AddOutPt(e,n),r&&(e.OutIdx=-1)))}},t.Clipper.prototype.DeleteFromSEL=function(e){var t=e.PrevInSEL,i=e.NextInSEL;null===t&&null===i&&e!==this.m_SortedEdges||(null!==t?t.NextInSEL=i:this.m_SortedEdges=i,null!==i&&(i.PrevInSEL=t),e.NextInSEL=null,e.PrevInSEL=null)},t.Clipper.prototype.ProcessHorizontals=function(){for(var e={};this.PopEdgeFromSEL(e);)this.ProcessHorizontal(e.v)},t.Clipper.prototype.GetHorzDirection=function(e,i){e.Bot.X<e.Top.X?(i.Left=e.Bot.X,i.Right=e.Top.X,i.Dir=t.Direction.dLeftToRight):(i.Left=e.Top.X,i.Right=e.Bot.X,i.Dir=t.Direction.dRightToLeft)},t.Clipper.prototype.ProcessHorizontal=function(e){var i={Dir:null,Left:null,Right:null};this.GetHorzDirection(e,i);for(var n=i.Dir,r=i.Left,o=i.Right,s=0===e.WindDelta,A=e,a=null;null!==A.NextInLML&&t.ClipperBase.IsHorizontal(A.NextInLML);)A=A.NextInLML;null===A.NextInLML&&(a=this.GetMaximaPair(A));var l=this.m_Maxima;if(null!==l)if(n===t.Direction.dLeftToRight){for(;null!==l&&l.X<=e.Bot.X;)l=l.Next;null!==l&&l.X>=A.Top.X&&(l=null)}else{for(;null!==l.Next&&l.Next.X<e.Bot.X;)l=l.Next;l.X<=A.Top.X&&(l=null)}for(var c=null;;){for(var p=e===A,h=this.GetNextInAEL(e,n);null!==h;){if(null!==l)if(n===t.Direction.dLeftToRight)for(;null!==l&&l.X<h.Curr.X;)e.OutIdx>=0&&!s&&this.AddOutPt(e,new t.IntPoint2(l.X,e.Bot.Y)),l=l.Next;else for(;null!==l&&l.X>h.Curr.X;)e.OutIdx>=0&&!s&&this.AddOutPt(e,new t.IntPoint2(l.X,e.Bot.Y)),l=l.Prev;if(n===t.Direction.dLeftToRight&&h.Curr.X>o||n===t.Direction.dRightToLeft&&h.Curr.X<r)break;if(h.Curr.X===e.Top.X&&null!==e.NextInLML&&h.Dx<e.NextInLML.Dx)break;if(e.OutIdx>=0&&!s){t.use_xyz&&(n===t.Direction.dLeftToRight?this.SetZ(h.Curr,e,h):this.SetZ(h.Curr,h,e)),c=this.AddOutPt(e,h.Curr);for(var g=this.m_SortedEdges;null!==g;){if(g.OutIdx>=0&&this.HorzSegmentsOverlap(e.Bot.X,e.Top.X,g.Bot.X,g.Top.X)){var u=this.GetLastOutPt(g);this.AddJoin(u,c,g.Top)}g=g.NextInSEL}this.AddGhostJoin(c,e.Bot)}if(h===a&&p)return e.OutIdx>=0&&this.AddLocalMaxPoly(e,a,e.Top),this.DeleteFromAEL(e),void this.DeleteFromAEL(a);if(n===t.Direction.dLeftToRight){var d=new t.IntPoint2(h.Curr.X,e.Curr.Y);this.IntersectEdges(e,h,d)}else d=new t.IntPoint2(h.Curr.X,e.Curr.Y),this.IntersectEdges(h,e,d);var f=this.GetNextInAEL(h,n);this.SwapPositionsInAEL(e,h),h=f}if(null===e.NextInLML||!t.ClipperBase.IsHorizontal(e.NextInLML))break;(e=this.UpdateEdgeIntoAEL(e)).OutIdx>=0&&this.AddOutPt(e,e.Bot),i={Dir:n,Left:r,Right:o},this.GetHorzDirection(e,i),n=i.Dir,r=i.Left,o=i.Right}if(e.OutIdx>=0&&null===c){for(c=this.GetLastOutPt(e),g=this.m_SortedEdges;null!==g;)g.OutIdx>=0&&this.HorzSegmentsOverlap(e.Bot.X,e.Top.X,g.Bot.X,g.Top.X)&&(u=this.GetLastOutPt(g),this.AddJoin(u,c,g.Top)),g=g.NextInSEL;this.AddGhostJoin(c,e.Top)}if(null!==e.NextInLML)if(e.OutIdx>=0){if(c=this.AddOutPt(e,e.Top),0===(e=this.UpdateEdgeIntoAEL(e)).WindDelta)return;var I=e.PrevInAEL;f=e.NextInAEL,null!==I&&I.Curr.X===e.Bot.X&&I.Curr.Y===e.Bot.Y&&0===I.WindDelta&&I.OutIdx>=0&&I.Curr.Y>I.Top.Y&&t.ClipperBase.SlopesEqual3(e,I,this.m_UseFullRange)?(u=this.AddOutPt(I,e.Bot),this.AddJoin(c,u,e.Top)):null!==f&&f.Curr.X===e.Bot.X&&f.Curr.Y===e.Bot.Y&&0!==f.WindDelta&&f.OutIdx>=0&&f.Curr.Y>f.Top.Y&&t.ClipperBase.SlopesEqual3(e,f,this.m_UseFullRange)&&(u=this.AddOutPt(f,e.Bot),this.AddJoin(c,u,e.Top))}else e=this.UpdateEdgeIntoAEL(e);else e.OutIdx>=0&&this.AddOutPt(e,e.Top),this.DeleteFromAEL(e)},t.Clipper.prototype.GetNextInAEL=function(e,i){return i===t.Direction.dLeftToRight?e.NextInAEL:e.PrevInAEL},t.Clipper.prototype.IsMinima=function(e){return null!==e&&e.Prev.NextInLML!==e&&e.Next.NextInLML!==e},t.Clipper.prototype.IsMaxima=function(e,t){return null!==e&&e.Top.Y===t&&null===e.NextInLML},t.Clipper.prototype.IsIntermediate=function(e,t){return e.Top.Y===t&&null!==e.NextInLML},t.Clipper.prototype.GetMaximaPair=function(e){return t.IntPoint.op_Equality(e.Next.Top,e.Top)&&null===e.Next.NextInLML?e.Next:t.IntPoint.op_Equality(e.Prev.Top,e.Top)&&null===e.Prev.NextInLML?e.Prev:null},t.Clipper.prototype.GetMaximaPairEx=function(e){var i=this.GetMaximaPair(e);return null===i||i.OutIdx===t.ClipperBase.Skip||i.NextInAEL===i.PrevInAEL&&!t.ClipperBase.IsHorizontal(i)?null:i},t.Clipper.prototype.ProcessIntersections=function(e){if(null===this.m_ActiveEdges)return!0;try{if(this.BuildIntersectList(e),0===this.m_IntersectList.length)return!0;if(1!==this.m_IntersectList.length&&!this.FixupIntersectionOrder())return!1;this.ProcessIntersectList()}catch(e){this.m_SortedEdges=null,this.m_IntersectList.length=0,t.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0},t.Clipper.prototype.BuildIntersectList=function(e){if(null!==this.m_ActiveEdges){var i=this.m_ActiveEdges;for(this.m_SortedEdges=i;null!==i;)i.PrevInSEL=i.PrevInAEL,i.NextInSEL=i.NextInAEL,i.Curr.X=t.Clipper.TopX(i,e),i=i.NextInAEL;for(var n=!0;n&&null!==this.m_SortedEdges;){for(n=!1,i=this.m_SortedEdges;null!==i.NextInSEL;){var r=i.NextInSEL,o=new t.IntPoint0;if(i.Curr.X>r.Curr.X){this.IntersectPoint(i,r,o),o.Y<e&&(o=new t.IntPoint2(t.Clipper.TopX(i,e),e));var s=new t.IntersectNode;s.Edge1=i,s.Edge2=r,s.Pt.X=o.X,s.Pt.Y=o.Y,t.use_xyz&&(s.Pt.Z=o.Z),this.m_IntersectList.push(s),this.SwapPositionsInSEL(i,r),n=!0}else i=r}if(null===i.PrevInSEL)break;i.PrevInSEL.NextInSEL=null}this.m_SortedEdges=null}},t.Clipper.prototype.EdgesAdjacent=function(e){return e.Edge1.NextInSEL===e.Edge2||e.Edge1.PrevInSEL===e.Edge2},t.Clipper.IntersectNodeSort=function(e,t){return t.Pt.Y-e.Pt.Y},t.Clipper.prototype.FixupIntersectionOrder=function(){this.m_IntersectList.sort(this.m_IntersectNodeComparer),this.CopyAELToSEL();for(var e=this.m_IntersectList.length,t=0;t<e;t++){if(!this.EdgesAdjacent(this.m_IntersectList[t])){for(var i=t+1;i<e&&!this.EdgesAdjacent(this.m_IntersectList[i]);)i++;if(i===e)return!1;var n=this.m_IntersectList[t];this.m_IntersectList[t]=this.m_IntersectList[i],this.m_IntersectList[i]=n}this.SwapPositionsInSEL(this.m_IntersectList[t].Edge1,this.m_IntersectList[t].Edge2)}return!0},t.Clipper.prototype.ProcessIntersectList=function(){for(var e=0,t=this.m_IntersectList.length;e<t;e++){var i=this.m_IntersectList[e];this.IntersectEdges(i.Edge1,i.Edge2,i.Pt),this.SwapPositionsInAEL(i.Edge1,i.Edge2)}this.m_IntersectList.length=0},o.msie?t.Clipper.Round=function(e){return e<0?Math.ceil(e-.5):Math.round(e)}:o.chromium?t.Clipper.Round=function(e){return e<0?-Math.round(Math.abs(e)):Math.round(e)}:o.safari?t.Clipper.Round=function(e){return e<0?(e-=.5)<-2147483648?Math.ceil(e):0|e:(e+=.5)>2147483647?Math.floor(e):0|e}:t.Clipper.Round=function(e){return e<0?Math.ceil(e-.5):Math.floor(e+.5)},t.Clipper.TopX=function(e,i){return i===e.Top.Y?e.Top.X:e.Bot.X+t.Clipper.Round(e.Dx*(i-e.Bot.Y))},t.Clipper.prototype.IntersectPoint=function(e,i,n){var r,o;if(n.X=0,n.Y=0,e.Dx===i.Dx)return n.Y=e.Curr.Y,void(n.X=t.Clipper.TopX(e,n.Y));if(0===e.Delta.X)n.X=e.Bot.X,t.ClipperBase.IsHorizontal(i)?n.Y=i.Bot.Y:(o=i.Bot.Y-i.Bot.X/i.Dx,n.Y=t.Clipper.Round(n.X/i.Dx+o));else if(0===i.Delta.X)n.X=i.Bot.X,t.ClipperBase.IsHorizontal(e)?n.Y=e.Bot.Y:(r=e.Bot.Y-e.Bot.X/e.Dx,n.Y=t.Clipper.Round(n.X/e.Dx+r));else{r=e.Bot.X-e.Bot.Y*e.Dx;var s=((o=i.Bot.X-i.Bot.Y*i.Dx)-r)/(e.Dx-i.Dx);n.Y=t.Clipper.Round(s),Math.abs(e.Dx)<Math.abs(i.Dx)?n.X=t.Clipper.Round(e.Dx*s+r):n.X=t.Clipper.Round(i.Dx*s+o)}if(n.Y<e.Top.Y||n.Y<i.Top.Y){if(e.Top.Y>i.Top.Y)return n.Y=e.Top.Y,n.X=t.Clipper.TopX(i,e.Top.Y),n.X<e.Top.X;n.Y=i.Top.Y,Math.abs(e.Dx)<Math.abs(i.Dx)?n.X=t.Clipper.TopX(e,n.Y):n.X=t.Clipper.TopX(i,n.Y)}n.Y>e.Curr.Y&&(n.Y=e.Curr.Y,Math.abs(e.Dx)>Math.abs(i.Dx)?n.X=t.Clipper.TopX(i,n.Y):n.X=t.Clipper.TopX(e,n.Y))},t.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(e){for(var i=this.m_ActiveEdges;null!==i;){var n=this.IsMaxima(i,e);if(n){var r=this.GetMaximaPairEx(i);n=null===r||!t.ClipperBase.IsHorizontal(r)}if(n){this.StrictlySimple&&this.InsertMaxima(i.Top.X);var o=i.PrevInAEL;this.DoMaxima(i),i=null===o?this.m_ActiveEdges:o.NextInAEL}else{if(this.IsIntermediate(i,e)&&t.ClipperBase.IsHorizontal(i.NextInLML)?((i=this.UpdateEdgeIntoAEL(i)).OutIdx>=0&&this.AddOutPt(i,i.Bot),this.AddEdgeToSEL(i)):(i.Curr.X=t.Clipper.TopX(i,e),i.Curr.Y=e),t.use_xyz&&(i.Top.Y===e?i.Curr.Z=i.Top.Z:i.Bot.Y===e?i.Curr.Z=i.Bot.Z:i.Curr.Z=0),this.StrictlySimple&&(o=i.PrevInAEL,i.OutIdx>=0&&0!==i.WindDelta&&null!==o&&o.OutIdx>=0&&o.Curr.X===i.Curr.X&&0!==o.WindDelta)){var s=new t.IntPoint1(i.Curr);t.use_xyz&&this.SetZ(s,o,i);var A=this.AddOutPt(o,s),a=this.AddOutPt(i,s);this.AddJoin(A,a,s)}i=i.NextInAEL}}for(this.ProcessHorizontals(),this.m_Maxima=null,i=this.m_ActiveEdges;null!==i;){if(this.IsIntermediate(i,e)){A=null,i.OutIdx>=0&&(A=this.AddOutPt(i,i.Top)),o=(i=this.UpdateEdgeIntoAEL(i)).PrevInAEL;var l=i.NextInAEL;null!==o&&o.Curr.X===i.Bot.X&&o.Curr.Y===i.Bot.Y&&null!==A&&o.OutIdx>=0&&o.Curr.Y===o.Top.Y&&t.ClipperBase.SlopesEqual5(i.Curr,i.Top,o.Curr,o.Top,this.m_UseFullRange)&&0!==i.WindDelta&&0!==o.WindDelta?(a=this.AddOutPt(ePrev2,i.Bot),this.AddJoin(A,a,i.Top)):null!==l&&l.Curr.X===i.Bot.X&&l.Curr.Y===i.Bot.Y&&null!==A&&l.OutIdx>=0&&l.Curr.Y===l.Top.Y&&t.ClipperBase.SlopesEqual5(i.Curr,i.Top,l.Curr,l.Top,this.m_UseFullRange)&&0!==i.WindDelta&&0!==l.WindDelta&&(a=this.AddOutPt(l,i.Bot),this.AddJoin(A,a,i.Top))}i=i.NextInAEL}},t.Clipper.prototype.DoMaxima=function(e){var i=this.GetMaximaPairEx(e);if(null===i)return e.OutIdx>=0&&this.AddOutPt(e,e.Top),void this.DeleteFromAEL(e);for(var n=e.NextInAEL;null!==n&&n!==i;)this.IntersectEdges(e,n,e.Top),this.SwapPositionsInAEL(e,n),n=e.NextInAEL;-1===e.OutIdx&&-1===i.OutIdx?(this.DeleteFromAEL(e),this.DeleteFromAEL(i)):e.OutIdx>=0&&i.OutIdx>=0?(e.OutIdx>=0&&this.AddLocalMaxPoly(e,i,e.Top),this.DeleteFromAEL(e),this.DeleteFromAEL(i)):t.use_lines&&0===e.WindDelta?(e.OutIdx>=0&&(this.AddOutPt(e,e.Top),e.OutIdx=t.ClipperBase.Unassigned),this.DeleteFromAEL(e),i.OutIdx>=0&&(this.AddOutPt(i,e.Top),i.OutIdx=t.ClipperBase.Unassigned),this.DeleteFromAEL(i)):t.Error("DoMaxima error")},t.Clipper.ReversePaths=function(e){for(var t=0,i=e.length;t<i;t++)e[t].reverse()},t.Clipper.Orientation=function(e){return t.Clipper.Area(e)>=0},t.Clipper.prototype.PointCount=function(e){if(null===e)return 0;var t=0,i=e;do{t++,i=i.Next}while(i!==e);return t},t.Clipper.prototype.BuildResult=function(e){t.Clear(e);for(var i=0,n=this.m_PolyOuts.length;i<n;i++){var r=this.m_PolyOuts[i];if(null!==r.Pts){var o=r.Pts.Prev,s=this.PointCount(o);if(!(s<2)){for(var A=new Array(s),a=0;a<s;a++)A[a]=o.Pt,o=o.Prev;e.push(A)}}}},t.Clipper.prototype.BuildResult2=function(e){e.Clear();for(var i=0,n=this.m_PolyOuts.length;i<n;i++){var r=this.m_PolyOuts[i],o=this.PointCount(r.Pts);if(!(r.IsOpen&&o<2||!r.IsOpen&&o<3)){this.FixHoleLinkage(r);var s=new t.PolyNode;e.m_AllPolys.push(s),r.PolyNode=s,s.m_polygon.length=o;for(var A=r.Pts.Prev,a=0;a<o;a++)s.m_polygon[a]=A.Pt,A=A.Prev}}for(i=0,n=this.m_PolyOuts.length;i<n;i++)null!==(r=this.m_PolyOuts[i]).PolyNode&&(r.IsOpen?(r.PolyNode.IsOpen=!0,e.AddChild(r.PolyNode)):null!==r.FirstLeft&&null!==r.FirstLeft.PolyNode?r.FirstLeft.PolyNode.AddChild(r.PolyNode):e.AddChild(r.PolyNode))},t.Clipper.prototype.FixupOutPolyline=function(e){for(var i=e.Pts,n=i.Prev;i!==n;)if(i=i.Next,t.IntPoint.op_Equality(i.Pt,i.Prev.Pt)){i===n&&(n=i.Prev);var r=i.Prev;r.Next=i.Next,i.Next.Prev=r,i=r}i===i.Prev&&(e.Pts=null)},t.Clipper.prototype.FixupOutPolygon=function(e){var i=null;e.BottomPt=null;for(var n=e.Pts,r=this.PreserveCollinear||this.StrictlySimple;;){if(n.Prev===n||n.Prev===n.Next)return void(e.Pts=null);if(t.IntPoint.op_Equality(n.Pt,n.Next.Pt)||t.IntPoint.op_Equality(n.Pt,n.Prev.Pt)||t.ClipperBase.SlopesEqual4(n.Prev.Pt,n.Pt,n.Next.Pt,this.m_UseFullRange)&&(!r||!this.Pt2IsBetweenPt1AndPt3(n.Prev.Pt,n.Pt,n.Next.Pt)))i=null,n.Prev.Next=n.Next,n.Next.Prev=n.Prev,n=n.Prev;else{if(n===i)break;null===i&&(i=n),n=n.Next}}e.Pts=n},t.Clipper.prototype.DupOutPt=function(e,i){var n=new t.OutPt;return n.Pt.X=e.Pt.X,n.Pt.Y=e.Pt.Y,t.use_xyz&&(n.Pt.Z=e.Pt.Z),n.Idx=e.Idx,i?(n.Next=e.Next,n.Prev=e,e.Next.Prev=n,e.Next=n):(n.Prev=e.Prev,n.Next=e,e.Prev.Next=n,e.Prev=n),n},t.Clipper.prototype.GetOverlap=function(e,t,i,n,r){return e<t?i<n?(r.Left=Math.max(e,i),r.Right=Math.min(t,n)):(r.Left=Math.max(e,n),r.Right=Math.min(t,i)):i<n?(r.Left=Math.max(t,i),r.Right=Math.min(e,n)):(r.Left=Math.max(t,n),r.Right=Math.min(e,i)),r.Left<r.Right},t.Clipper.prototype.JoinHorz=function(e,i,n,r,o,s){var A=e.Pt.X>i.Pt.X?t.Direction.dRightToLeft:t.Direction.dLeftToRight,a=n.Pt.X>r.Pt.X?t.Direction.dRightToLeft:t.Direction.dLeftToRight;if(A===a)return!1;if(A===t.Direction.dLeftToRight){for(;e.Next.Pt.X<=o.X&&e.Next.Pt.X>=e.Pt.X&&e.Next.Pt.Y===o.Y;)e=e.Next;s&&e.Pt.X!==o.X&&(e=e.Next),i=this.DupOutPt(e,!s),t.IntPoint.op_Inequality(i.Pt,o)&&((e=i).Pt.X=o.X,e.Pt.Y=o.Y,t.use_xyz&&(e.Pt.Z=o.Z),i=this.DupOutPt(e,!s))}else{for(;e.Next.Pt.X>=o.X&&e.Next.Pt.X<=e.Pt.X&&e.Next.Pt.Y===o.Y;)e=e.Next;s||e.Pt.X===o.X||(e=e.Next),i=this.DupOutPt(e,s),t.IntPoint.op_Inequality(i.Pt,o)&&((e=i).Pt.X=o.X,e.Pt.Y=o.Y,t.use_xyz&&(e.Pt.Z=o.Z),i=this.DupOutPt(e,s))}if(a===t.Direction.dLeftToRight){for(;n.Next.Pt.X<=o.X&&n.Next.Pt.X>=n.Pt.X&&n.Next.Pt.Y===o.Y;)n=n.Next;s&&n.Pt.X!==o.X&&(n=n.Next),r=this.DupOutPt(n,!s),t.IntPoint.op_Inequality(r.Pt,o)&&((n=r).Pt.X=o.X,n.Pt.Y=o.Y,t.use_xyz&&(n.Pt.Z=o.Z),r=this.DupOutPt(n,!s))}else{for(;n.Next.Pt.X>=o.X&&n.Next.Pt.X<=n.Pt.X&&n.Next.Pt.Y===o.Y;)n=n.Next;s||n.Pt.X===o.X||(n=n.Next),r=this.DupOutPt(n,s),t.IntPoint.op_Inequality(r.Pt,o)&&((n=r).Pt.X=o.X,n.Pt.Y=o.Y,t.use_xyz&&(n.Pt.Z=o.Z),r=this.DupOutPt(n,s))}return A===t.Direction.dLeftToRight===s?(e.Prev=n,n.Next=e,i.Next=r,r.Prev=i):(e.Next=n,n.Prev=e,i.Prev=r,r.Next=i),!0},t.Clipper.prototype.JoinPoints=function(e,i,n){var r=e.OutPt1,o=new t.OutPt,s=e.OutPt2,A=new t.OutPt,a=e.OutPt1.Pt.Y===e.OffPt.Y;if(a&&t.IntPoint.op_Equality(e.OffPt,e.OutPt1.Pt)&&t.IntPoint.op_Equality(e.OffPt,e.OutPt2.Pt)){if(i!==n)return!1;for(o=e.OutPt1.Next;o!==r&&t.IntPoint.op_Equality(o.Pt,e.OffPt);)o=o.Next;var l=o.Pt.Y>e.OffPt.Y;for(A=e.OutPt2.Next;A!==s&&t.IntPoint.op_Equality(A.Pt,e.OffPt);)A=A.Next;return l!==A.Pt.Y>e.OffPt.Y&&(l?(o=this.DupOutPt(r,!1),A=this.DupOutPt(s,!0),r.Prev=s,s.Next=r,o.Next=A,A.Prev=o,e.OutPt1=r,e.OutPt2=o,!0):(o=this.DupOutPt(r,!0),A=this.DupOutPt(s,!1),r.Next=s,s.Prev=r,o.Prev=A,A.Next=o,e.OutPt1=r,e.OutPt2=o,!0))}if(a){for(o=r;r.Prev.Pt.Y===r.Pt.Y&&r.Prev!==o&&r.Prev!==s;)r=r.Prev;for(;o.Next.Pt.Y===o.Pt.Y&&o.Next!==r&&o.Next!==s;)o=o.Next;if(o.Next===r||o.Next===s)return!1;for(A=s;s.Prev.Pt.Y===s.Pt.Y&&s.Prev!==A&&s.Prev!==o;)s=s.Prev;for(;A.Next.Pt.Y===A.Pt.Y&&A.Next!==s&&A.Next!==r;)A=A.Next;if(A.Next===s||A.Next===r)return!1;var c={Left:null,Right:null};if(!this.GetOverlap(r.Pt.X,o.Pt.X,s.Pt.X,A.Pt.X,c))return!1;var p,h=c.Left,g=c.Right,u=new t.IntPoint0;return r.Pt.X>=h&&r.Pt.X<=g?(u.X=r.Pt.X,u.Y=r.Pt.Y,t.use_xyz&&(u.Z=r.Pt.Z),p=r.Pt.X>o.Pt.X):s.Pt.X>=h&&s.Pt.X<=g?(u.X=s.Pt.X,u.Y=s.Pt.Y,t.use_xyz&&(u.Z=s.Pt.Z),p=s.Pt.X>A.Pt.X):o.Pt.X>=h&&o.Pt.X<=g?(u.X=o.Pt.X,u.Y=o.Pt.Y,t.use_xyz&&(u.Z=o.Pt.Z),p=o.Pt.X>r.Pt.X):(u.X=A.Pt.X,u.Y=A.Pt.Y,t.use_xyz&&(u.Z=A.Pt.Z),p=A.Pt.X>s.Pt.X),e.OutPt1=r,e.OutPt2=s,this.JoinHorz(r,o,s,A,u,p)}for(o=r.Next;t.IntPoint.op_Equality(o.Pt,r.Pt)&&o!==r;)o=o.Next;var d=o.Pt.Y>r.Pt.Y||!t.ClipperBase.SlopesEqual4(r.Pt,o.Pt,e.OffPt,this.m_UseFullRange);if(d){for(o=r.Prev;t.IntPoint.op_Equality(o.Pt,r.Pt)&&o!==r;)o=o.Prev;if(o.Pt.Y>r.Pt.Y||!t.ClipperBase.SlopesEqual4(r.Pt,o.Pt,e.OffPt,this.m_UseFullRange))return!1}for(A=s.Next;t.IntPoint.op_Equality(A.Pt,s.Pt)&&A!==s;)A=A.Next;var f=A.Pt.Y>s.Pt.Y||!t.ClipperBase.SlopesEqual4(s.Pt,A.Pt,e.OffPt,this.m_UseFullRange);if(f){for(A=s.Prev;t.IntPoint.op_Equality(A.Pt,s.Pt)&&A!==s;)A=A.Prev;if(A.Pt.Y>s.Pt.Y||!t.ClipperBase.SlopesEqual4(s.Pt,A.Pt,e.OffPt,this.m_UseFullRange))return!1}return!(o===r||A===s||o===A||i===n&&d===f||(d?(o=this.DupOutPt(r,!1),A=this.DupOutPt(s,!0),r.Prev=s,s.Next=r,o.Next=A,A.Prev=o,e.OutPt1=r,e.OutPt2=o,0):(o=this.DupOutPt(r,!0),A=this.DupOutPt(s,!1),r.Next=s,s.Prev=r,o.Prev=A,A.Next=o,e.OutPt1=r,e.OutPt2=o,0)))},t.Clipper.GetBounds=function(e){for(var i=0,n=e.length;i<n&&0===e[i].length;)i++;if(i===n)return new t.IntRect(0,0,0,0);var r=new t.IntRect;for(r.left=e[i][0].X,r.right=r.left,r.top=e[i][0].Y,r.bottom=r.top;i<n;i++)for(var o=0,s=e[i].length;o<s;o++)e[i][o].X<r.left?r.left=e[i][o].X:e[i][o].X>r.right&&(r.right=e[i][o].X),e[i][o].Y<r.top?r.top=e[i][o].Y:e[i][o].Y>r.bottom&&(r.bottom=e[i][o].Y);return r},t.Clipper.prototype.GetBounds2=function(e){var i=e,n=new t.IntRect;for(n.left=e.Pt.X,n.right=e.Pt.X,n.top=e.Pt.Y,n.bottom=e.Pt.Y,e=e.Next;e!==i;)e.Pt.X<n.left&&(n.left=e.Pt.X),e.Pt.X>n.right&&(n.right=e.Pt.X),e.Pt.Y<n.top&&(n.top=e.Pt.Y),e.Pt.Y>n.bottom&&(n.bottom=e.Pt.Y),e=e.Next;return n},t.Clipper.PointInPolygon=function(e,t){var i=0,n=t.length;if(n<3)return 0;for(var r=t[0],o=1;o<=n;++o){var s=o===n?t[0]:t[o];if(s.Y===e.Y&&(s.X===e.X||r.Y===e.Y&&s.X>e.X==r.X<e.X))return-1;if(r.Y<e.Y!=s.Y<e.Y)if(r.X>=e.X)if(s.X>e.X)i=1-i;else{if(0==(A=(r.X-e.X)*(s.Y-e.Y)-(s.X-e.X)*(r.Y-e.Y)))return-1;A>0==s.Y>r.Y&&(i=1-i)}else if(s.X>e.X){var A;if(0==(A=(r.X-e.X)*(s.Y-e.Y)-(s.X-e.X)*(r.Y-e.Y)))return-1;A>0==s.Y>r.Y&&(i=1-i)}r=s}return i},t.Clipper.prototype.PointInPolygon=function(e,t){var i=0,n=t,r=e.X,o=e.Y,s=t.Pt.X,A=t.Pt.Y;do{var a=(t=t.Next).Pt.X,l=t.Pt.Y;if(l===o&&(a===r||A===o&&a>r==s<r))return-1;if(A<o!=l<o)if(s>=r)if(a>r)i=1-i;else{if(0==(c=(s-r)*(l-o)-(a-r)*(A-o)))return-1;c>0==l>A&&(i=1-i)}else if(a>r){var c;if(0==(c=(s-r)*(l-o)-(a-r)*(A-o)))return-1;c>0==l>A&&(i=1-i)}s=a,A=l}while(n!==t);return i},t.Clipper.prototype.Poly2ContainsPoly1=function(e,t){var i=e;do{var n=this.PointInPolygon(i.Pt,t);if(n>=0)return n>0;i=i.Next}while(i!==e);return!0},t.Clipper.prototype.FixupFirstLefts1=function(e,i){for(var n,r,o=0,s=this.m_PolyOuts.length;o<s;o++)n=this.m_PolyOuts[o],r=t.Clipper.ParseFirstLeft(n.FirstLeft),null!==n.Pts&&r===e&&this.Poly2ContainsPoly1(n.Pts,i.Pts)&&(n.FirstLeft=i)},t.Clipper.prototype.FixupFirstLefts2=function(e,i){for(var n,r,o=i.FirstLeft,s=0,A=this.m_PolyOuts.length;s<A;s++)null!==(n=this.m_PolyOuts[s]).Pts&&n!==i&&n!==e&&((r=t.Clipper.ParseFirstLeft(n.FirstLeft))!==o&&r!==e&&r!==i||(this.Poly2ContainsPoly1(n.Pts,e.Pts)?n.FirstLeft=e:this.Poly2ContainsPoly1(n.Pts,i.Pts)?n.FirstLeft=i:n.FirstLeft!==e&&n.FirstLeft!==i||(n.FirstLeft=o)))},t.Clipper.prototype.FixupFirstLefts3=function(e,i){for(var n,r,o=0,s=this.m_PolyOuts.length;o<s;o++)n=this.m_PolyOuts[o],r=t.Clipper.ParseFirstLeft(n.FirstLeft),null!==n.Pts&&r===e&&(n.FirstLeft=i)},t.Clipper.ParseFirstLeft=function(e){for(;null!==e&&null===e.Pts;)e=e.FirstLeft;return e},t.Clipper.prototype.JoinCommonEdges=function(){for(var e=0,t=this.m_Joins.length;e<t;e++){var i,n=this.m_Joins[e],r=this.GetOutRec(n.OutPt1.Idx),o=this.GetOutRec(n.OutPt2.Idx);null!==r.Pts&&null!==o.Pts&&(r.IsOpen||o.IsOpen||(i=r===o?r:this.OutRec1RightOfOutRec2(r,o)?o:this.OutRec1RightOfOutRec2(o,r)?r:this.GetLowermostRec(r,o),this.JoinPoints(n,r,o)&&(r===o?(r.Pts=n.OutPt1,r.BottomPt=null,(o=this.CreateOutRec()).Pts=n.OutPt2,this.UpdateOutPtIdxs(o),this.Poly2ContainsPoly1(o.Pts,r.Pts)?(o.IsHole=!r.IsHole,o.FirstLeft=r,this.m_UsingPolyTree&&this.FixupFirstLefts2(o,r),(o.IsHole^this.ReverseSolution)==this.Area$1(o)>0&&this.ReversePolyPtLinks(o.Pts)):this.Poly2ContainsPoly1(r.Pts,o.Pts)?(o.IsHole=r.IsHole,r.IsHole=!o.IsHole,o.FirstLeft=r.FirstLeft,r.FirstLeft=o,this.m_UsingPolyTree&&this.FixupFirstLefts2(r,o),(r.IsHole^this.ReverseSolution)==this.Area$1(r)>0&&this.ReversePolyPtLinks(r.Pts)):(o.IsHole=r.IsHole,o.FirstLeft=r.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(r,o))):(o.Pts=null,o.BottomPt=null,o.Idx=r.Idx,r.IsHole=i.IsHole,i===o&&(r.FirstLeft=o.FirstLeft),o.FirstLeft=r,this.m_UsingPolyTree&&this.FixupFirstLefts3(o,r)))))}},t.Clipper.prototype.UpdateOutPtIdxs=function(e){var t=e.Pts;do{t.Idx=e.Idx,t=t.Prev}while(t!==e.Pts)},t.Clipper.prototype.DoSimplePolygons=function(){for(var e=0;e<this.m_PolyOuts.length;){var i=this.m_PolyOuts[e++],n=i.Pts;if(null!==n&&!i.IsOpen)do{for(var r=n.Next;r!==i.Pts;){if(t.IntPoint.op_Equality(n.Pt,r.Pt)&&r.Next!==n&&r.Prev!==n){var o=n.Prev,s=r.Prev;n.Prev=s,s.Next=n,r.Prev=o,o.Next=r,i.Pts=n;var A=this.CreateOutRec();A.Pts=r,this.UpdateOutPtIdxs(A),this.Poly2ContainsPoly1(A.Pts,i.Pts)?(A.IsHole=!i.IsHole,A.FirstLeft=i,this.m_UsingPolyTree&&this.FixupFirstLefts2(A,i)):this.Poly2ContainsPoly1(i.Pts,A.Pts)?(A.IsHole=i.IsHole,i.IsHole=!A.IsHole,A.FirstLeft=i.FirstLeft,i.FirstLeft=A,this.m_UsingPolyTree&&this.FixupFirstLefts2(i,A)):(A.IsHole=i.IsHole,A.FirstLeft=i.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(i,A)),r=n}r=r.Next}n=n.Next}while(n!==i.Pts)}},t.Clipper.Area=function(e){if(!Array.isArray(e))return 0;var t=e.length;if(t<3)return 0;for(var i=0,n=0,r=t-1;n<t;++n)i+=(e[r].X+e[n].X)*(e[r].Y-e[n].Y),r=n;return.5*-i},t.Clipper.prototype.Area=function(e){var t=e;if(null===e)return 0;var i=0;do{i+=(e.Prev.Pt.X+e.Pt.X)*(e.Prev.Pt.Y-e.Pt.Y),e=e.Next}while(e!==t);return.5*i},t.Clipper.prototype.Area$1=function(e){return this.Area(e.Pts)},t.Clipper.SimplifyPolygon=function(e,i){var n=new Array,r=new t.Clipper(0);return r.StrictlySimple=!0,r.AddPath(e,t.PolyType.ptSubject,!0),r.Execute(t.ClipType.ctUnion,n,i,i),n},t.Clipper.SimplifyPolygons=function(e,i){void 0===i&&(i=t.PolyFillType.pftEvenOdd);var n=new Array,r=new t.Clipper(0);return r.StrictlySimple=!0,r.AddPaths(e,t.PolyType.ptSubject,!0),r.Execute(t.ClipType.ctUnion,n,i,i),n},t.Clipper.DistanceSqrd=function(e,t){var i=e.X-t.X,n=e.Y-t.Y;return i*i+n*n},t.Clipper.DistanceFromLineSqrd=function(e,t,i){var n=t.Y-i.Y,r=i.X-t.X,o=n*t.X+r*t.Y;return(o=n*e.X+r*e.Y-o)*o/(n*n+r*r)},t.Clipper.SlopesNearCollinear=function(e,i,n,r){return Math.abs(e.X-i.X)>Math.abs(e.Y-i.Y)?e.X>i.X==e.X<n.X?t.Clipper.DistanceFromLineSqrd(e,i,n)<r:i.X>e.X==i.X<n.X?t.Clipper.DistanceFromLineSqrd(i,e,n)<r:t.Clipper.DistanceFromLineSqrd(n,e,i)<r:e.Y>i.Y==e.Y<n.Y?t.Clipper.DistanceFromLineSqrd(e,i,n)<r:i.Y>e.Y==i.Y<n.Y?t.Clipper.DistanceFromLineSqrd(i,e,n)<r:t.Clipper.DistanceFromLineSqrd(n,e,i)<r},t.Clipper.PointsAreClose=function(e,t,i){var n=e.X-t.X,r=e.Y-t.Y;return n*n+r*r<=i},t.Clipper.ExcludeOp=function(e){var t=e.Prev;return t.Next=e.Next,e.Next.Prev=t,t.Idx=0,t},t.Clipper.CleanPolygon=function(e,i){void 0===i&&(i=1.415);var n=e.length;if(0===n)return new Array;for(var r=new Array(n),o=0;o<n;++o)r[o]=new t.OutPt;for(o=0;o<n;++o)r[o].Pt=e[o],r[o].Next=r[(o+1)%n],r[o].Next.Prev=r[o],r[o].Idx=0;for(var s=i*i,A=r[0];0===A.Idx&&A.Next!==A.Prev;)t.Clipper.PointsAreClose(A.Pt,A.Prev.Pt,s)?(A=t.Clipper.ExcludeOp(A),n--):t.Clipper.PointsAreClose(A.Prev.Pt,A.Next.Pt,s)?(t.Clipper.ExcludeOp(A.Next),A=t.Clipper.ExcludeOp(A),n-=2):t.Clipper.SlopesNearCollinear(A.Prev.Pt,A.Pt,A.Next.Pt,s)?(A=t.Clipper.ExcludeOp(A),n--):(A.Idx=1,A=A.Next);n<3&&(n=0);var a=new Array(n);for(o=0;o<n;++o)a[o]=new t.IntPoint1(A.Pt),A=A.Next;return r=null,a},t.Clipper.CleanPolygons=function(e,i){for(var n=new Array(e.length),r=0,o=e.length;r<o;r++)n[r]=t.Clipper.CleanPolygon(e[r],i);return n},t.Clipper.Minkowski=function(e,i,n,r){var o=r?1:0,s=e.length,A=i.length,a=new Array;if(n)for(var l=0;l<A;l++){for(var c=new Array(s),p=0,h=e.length,g=e[p];p<h;g=e[++p])c[p]=new t.IntPoint2(i[l].X+g.X,i[l].Y+g.Y);a.push(c)}else for(l=0;l<A;l++){for(c=new Array(s),p=0,h=e.length,g=e[p];p<h;g=e[++p])c[p]=new t.IntPoint2(i[l].X-g.X,i[l].Y-g.Y);a.push(c)}var u=new Array;for(l=0;l<A-1+o;l++)for(p=0;p<s;p++){var d=new Array;d.push(a[l%A][p%s]),d.push(a[(l+1)%A][p%s]),d.push(a[(l+1)%A][(p+1)%s]),d.push(a[l%A][(p+1)%s]),t.Clipper.Orientation(d)||d.reverse(),u.push(d)}return u},t.Clipper.MinkowskiSum=function(e,i,n){if(i[0]instanceof Array){l=i;for(var r=new t.Paths,o=(A=new t.Clipper,0);o<l.length;++o){var s=t.Clipper.Minkowski(e,l[o],!0,n);A.AddPaths(s,t.PolyType.ptSubject,!0),n&&(a=t.Clipper.TranslatePath(l[o],e[0]),A.AddPath(a,t.PolyType.ptClip,!0))}return A.Execute(t.ClipType.ctUnion,r,t.PolyFillType.pftNonZero,t.PolyFillType.pftNonZero),r}var A,a=i,l=t.Clipper.Minkowski(e,a,!0,n);return(A=new t.Clipper).AddPaths(l,t.PolyType.ptSubject,!0),A.Execute(t.ClipType.ctUnion,l,t.PolyFillType.pftNonZero,t.PolyFillType.pftNonZero),l},t.Clipper.TranslatePath=function(e,i){for(var n=new t.Path,r=0;r<e.length;r++)n.push(new t.IntPoint2(e[r].X+i.X,e[r].Y+i.Y));return n},t.Clipper.MinkowskiDiff=function(e,i){var n=t.Clipper.Minkowski(e,i,!1,!0),r=new t.Clipper;return r.AddPaths(n,t.PolyType.ptSubject,!0),r.Execute(t.ClipType.ctUnion,n,t.PolyFillType.pftNonZero,t.PolyFillType.pftNonZero),n},t.Clipper.PolyTreeToPaths=function(e){var i=new Array;return t.Clipper.AddPolyNodeToPaths(e,t.Clipper.NodeType.ntAny,i),i},t.Clipper.AddPolyNodeToPaths=function(e,i,n){var r=!0;switch(i){case t.Clipper.NodeType.ntOpen:return;case t.Clipper.NodeType.ntClosed:r=!e.IsOpen}e.m_polygon.length>0&&r&&n.push(e.m_polygon);for(var o=0,s=e.Childs(),A=s.length,a=s[o];o<A;a=s[++o])t.Clipper.AddPolyNodeToPaths(a,i,n)},t.Clipper.OpenPathsFromPolyTree=function(e){for(var i=new t.Paths,n=0,r=e.ChildCount();n<r;n++)e.Childs()[n].IsOpen&&i.push(e.Childs()[n].m_polygon);return i},t.Clipper.ClosedPathsFromPolyTree=function(e){var i=new t.Paths;return t.Clipper.AddPolyNodeToPaths(e,t.Clipper.NodeType.ntClosed,i),i},Inherit(t.Clipper,t.ClipperBase),t.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2},t.ClipperOffset=function(e,i){void 0===e&&(e=2),void 0===i&&(i=t.ClipperOffset.def_arc_tolerance),this.m_destPolys=new t.Paths,this.m_srcPoly=new t.Path,this.m_destPoly=new t.Path,this.m_normals=new Array,this.m_delta=0,this.m_sinA=0,this.m_sin=0,this.m_cos=0,this.m_miterLim=0,this.m_StepsPerRad=0,this.m_lowest=new t.IntPoint0,this.m_polyNodes=new t.PolyNode,this.MiterLimit=e,this.ArcTolerance=i,this.m_lowest.X=-1},t.ClipperOffset.two_pi=6.28318530717959,t.ClipperOffset.def_arc_tolerance=.25,t.ClipperOffset.prototype.Clear=function(){t.Clear(this.m_polyNodes.Childs()),this.m_lowest.X=-1},t.ClipperOffset.Round=t.Clipper.Round,t.ClipperOffset.prototype.AddPath=function(e,i,n){var r=e.length-1;if(!(r<0)){var o=new t.PolyNode;if(o.m_jointype=i,o.m_endtype=n,n===t.EndType.etClosedLine||n===t.EndType.etClosedPolygon)for(;r>0&&t.IntPoint.op_Equality(e[0],e[r]);)r--;o.m_polygon.push(e[0]);for(var s=0,A=0,a=1;a<=r;a++)t.IntPoint.op_Inequality(o.m_polygon[s],e[a])&&(s++,o.m_polygon.push(e[a]),(e[a].Y>o.m_polygon[A].Y||e[a].Y===o.m_polygon[A].Y&&e[a].X<o.m_polygon[A].X)&&(A=s));if(!(n===t.EndType.etClosedPolygon&&s<2)&&(this.m_polyNodes.AddChild(o),n===t.EndType.etClosedPolygon))if(this.m_lowest.X<0)this.m_lowest=new t.IntPoint2(this.m_polyNodes.ChildCount()-1,A);else{var l=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(o.m_polygon[A].Y>l.Y||o.m_polygon[A].Y===l.Y&&o.m_polygon[A].X<l.X)&&(this.m_lowest=new t.IntPoint2(this.m_polyNodes.ChildCount()-1,A))}}},t.ClipperOffset.prototype.AddPaths=function(e,t,i){for(var n=0,r=e.length;n<r;n++)this.AddPath(e[n],t,i)},t.ClipperOffset.prototype.FixOrientations=function(){if(this.m_lowest.X>=0&&!t.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var e=0;e<this.m_polyNodes.ChildCount();e++)((i=this.m_polyNodes.Childs()[e]).m_endtype===t.EndType.etClosedPolygon||i.m_endtype===t.EndType.etClosedLine&&t.Clipper.Orientation(i.m_polygon))&&i.m_polygon.reverse();else for(e=0;e<this.m_polyNodes.ChildCount();e++){var i;(i=this.m_polyNodes.Childs()[e]).m_endtype!==t.EndType.etClosedLine||t.Clipper.Orientation(i.m_polygon)||i.m_polygon.reverse()}},t.ClipperOffset.GetUnitNormal=function(e,i){var n=i.X-e.X,r=i.Y-e.Y;if(0===n&&0===r)return new t.DoublePoint2(0,0);var o=1/Math.sqrt(n*n+r*r);return n*=o,r*=o,new t.DoublePoint2(r,-n)},t.ClipperOffset.prototype.DoOffset=function(e){if(this.m_destPolys=new Array,this.m_delta=e,t.ClipperBase.near_zero(e))for(var i=0;i<this.m_polyNodes.ChildCount();i++)(o=this.m_polyNodes.Childs()[i]).m_endtype===t.EndType.etClosedPolygon&&this.m_destPolys.push(o.m_polygon);else{var n;this.MiterLimit>2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5,n=this.ArcTolerance<=0?t.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(e)*t.ClipperOffset.def_arc_tolerance?Math.abs(e)*t.ClipperOffset.def_arc_tolerance:this.ArcTolerance;var r=3.14159265358979/Math.acos(1-n/Math.abs(e));for(this.m_sin=Math.sin(t.ClipperOffset.two_pi/r),this.m_cos=Math.cos(t.ClipperOffset.two_pi/r),this.m_StepsPerRad=r/t.ClipperOffset.two_pi,e<0&&(this.m_sin=-this.m_sin),i=0;i<this.m_polyNodes.ChildCount();i++){var o=this.m_polyNodes.Childs()[i];this.m_srcPoly=o.m_polygon;var s=this.m_srcPoly.length;if(!(0===s||e<=0&&(s<3||o.m_endtype!==t.EndType.etClosedPolygon)))if(this.m_destPoly=new Array,1!==s){for(this.m_normals.length=0,h=0;h<s-1;h++)this.m_normals.push(t.ClipperOffset.GetUnitNormal(this.m_srcPoly[h],this.m_srcPoly[h+1]));if(o.m_endtype===t.EndType.etClosedLine||o.m_endtype===t.EndType.etClosedPolygon?this.m_normals.push(t.ClipperOffset.GetUnitNormal(this.m_srcPoly[s-1],this.m_srcPoly[0])):this.m_normals.push(new t.DoublePoint1(this.m_normals[s-2])),o.m_endtype===t.EndType.etClosedPolygon){var A=s-1;for(h=0;h<s;h++)A=this.OffsetPoint(h,A,o.m_jointype);this.m_destPolys.push(this.m_destPoly)}else if(o.m_endtype===t.EndType.etClosedLine){for(A=s-1,h=0;h<s;h++)A=this.OffsetPoint(h,A,o.m_jointype);this.m_destPolys.push(this.m_destPoly),this.m_destPoly=new Array;var a=this.m_normals[s-1];for(h=s-1;h>0;h--)this.m_normals[h]=new t.DoublePoint2(-this.m_normals[h-1].X,-this.m_normals[h-1].Y);for(this.m_normals[0]=new t.DoublePoint2(-a.X,-a.Y),A=0,h=s-1;h>=0;h--)A=this.OffsetPoint(h,A,o.m_jointype);this.m_destPolys.push(this.m_destPoly)}else{var l;for(A=0,h=1;h<s-1;++h)A=this.OffsetPoint(h,A,o.m_jointype);for(o.m_endtype===t.EndType.etOpenButt?(h=s-1,l=new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[h].X+this.m_normals[h].X*e),t.ClipperOffset.Round(this.m_srcPoly[h].Y+this.m_normals[h].Y*e)),this.m_destPoly.push(l),l=new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[h].X-this.m_normals[h].X*e),t.ClipperOffset.Round(this.m_srcPoly[h].Y-this.m_normals[h].Y*e)),this.m_destPoly.push(l)):(h=s-1,A=s-2,this.m_sinA=0,this.m_normals[h]=new t.DoublePoint2(-this.m_normals[h].X,-this.m_normals[h].Y),o.m_endtype===t.EndType.etOpenSquare?this.DoSquare(h,A):this.DoRound(h,A)),h=s-1;h>0;h--)this.m_normals[h]=new t.DoublePoint2(-this.m_normals[h-1].X,-this.m_normals[h-1].Y);for(this.m_normals[0]=new t.DoublePoint2(-this.m_normals[1].X,-this.m_normals[1].Y),h=(A=s-1)-1;h>0;--h)A=this.OffsetPoint(h,A,o.m_jointype);o.m_endtype===t.EndType.etOpenButt?(l=new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[0].X-this.m_normals[0].X*e),t.ClipperOffset.Round(this.m_srcPoly[0].Y-this.m_normals[0].Y*e)),this.m_destPoly.push(l),l=new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[0].X+this.m_normals[0].X*e),t.ClipperOffset.Round(this.m_srcPoly[0].Y+this.m_normals[0].Y*e)),this.m_destPoly.push(l)):(A=1,this.m_sinA=0,o.m_endtype===t.EndType.etOpenSquare?this.DoSquare(0,1):this.DoRound(0,1)),this.m_destPolys.push(this.m_destPoly)}}else{if(o.m_jointype===t.JoinType.jtRound)for(var c=1,p=0,h=1;h<=r;h++){this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[0].X+c*e),t.ClipperOffset.Round(this.m_srcPoly[0].Y+p*e)));var g=c;c=c*this.m_cos-this.m_sin*p,p=g*this.m_sin+p*this.m_cos}else{c=-1,p=-1;for(var h=0;h<4;++h)this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[0].X+c*e),t.ClipperOffset.Round(this.m_srcPoly[0].Y+p*e))),c<0?c=1:p<0?p=1:c=-1}this.m_destPolys.push(this.m_destPoly)}}}},t.ClipperOffset.prototype.Execute=function(){var e=arguments;if(e[0]instanceof t.PolyTree)if(s=e[1],(o=e[0]).Clear(),this.FixOrientations(),this.DoOffset(s),(r=new t.Clipper(0)).AddPaths(this.m_destPolys,t.PolyType.ptSubject,!0),s>0)r.Execute(t.ClipType.ctUnion,o,t.PolyFillType.pftPositive,t.PolyFillType.pftPositive);else if(a=t.Clipper.GetBounds(this.m_destPolys),(A=new t.Path).push(new t.IntPoint2(a.left-10,a.bottom+10)),A.push(new t.IntPoint2(a.right+10,a.bottom+10)),A.push(new t.IntPoint2(a.right+10,a.top-10)),A.push(new t.IntPoint2(a.left-10,a.top-10)),r.AddPath(A,t.PolyType.ptSubject,!0),r.ReverseSolution=!0,r.Execute(t.ClipType.ctUnion,o,t.PolyFillType.pftNegative,t.PolyFillType.pftNegative),1===o.ChildCount()&&o.Childs()[0].ChildCount()>0){var i=o.Childs()[0];o.Childs()[0]=i.Childs()[0],o.Childs()[0].m_Parent=o;for(var n=1;n<i.ChildCount();n++)o.AddChild(i.Childs()[n])}else o.Clear();else{var r,o=e[0],s=e[1];if(t.Clear(o),this.FixOrientations(),this.DoOffset(s),(r=new t.Clipper(0)).AddPaths(this.m_destPolys,t.PolyType.ptSubject,!0),s>0)r.Execute(t.ClipType.ctUnion,o,t.PolyFillType.pftPositive,t.PolyFillType.pftPositive);else{var A,a=t.Clipper.GetBounds(this.m_destPolys);(A=new t.Path).push(new t.IntPoint2(a.left-10,a.bottom+10)),A.push(new t.IntPoint2(a.right+10,a.bottom+10)),A.push(new t.IntPoint2(a.right+10,a.top-10)),A.push(new t.IntPoint2(a.left-10,a.top-10)),r.AddPath(A,t.PolyType.ptSubject,!0),r.ReverseSolution=!0,r.Execute(t.ClipType.ctUnion,o,t.PolyFillType.pftNegative,t.PolyFillType.pftNegative),o.length>0&&o.splice(0,1)}}},t.ClipperOffset.prototype.OffsetPoint=function(e,i,n){if(this.m_sinA=this.m_normals[i].X*this.m_normals[e].Y-this.m_normals[e].X*this.m_normals[i].Y,Math.abs(this.m_sinA*this.m_delta)<1){if(this.m_normals[i].X*this.m_normals[e].X+this.m_normals[e].Y*this.m_normals[i].Y>0)return this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[i].X*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[i].Y*this.m_delta))),i}else this.m_sinA>1?this.m_sinA=1:this.m_sinA<-1&&(this.m_sinA=-1);if(this.m_sinA*this.m_delta<0)this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[i].X*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[i].Y*this.m_delta))),this.m_destPoly.push(new t.IntPoint1(this.m_srcPoly[e])),this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[e].X*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[e].Y*this.m_delta)));else switch(n){case t.JoinType.jtMiter:var r=this.m_normals[e].X*this.m_normals[i].X+this.m_normals[e].Y*this.m_normals[i].Y+1;r>=this.m_miterLim?this.DoMiter(e,i,r):this.DoSquare(e,i);break;case t.JoinType.jtSquare:this.DoSquare(e,i);break;case t.JoinType.jtRound:this.DoRound(e,i)}return i=e},t.ClipperOffset.prototype.DoSquare=function(e,i){var n=Math.tan(Math.atan2(this.m_sinA,this.m_normals[i].X*this.m_normals[e].X+this.m_normals[i].Y*this.m_normals[e].Y)/4);this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[i].X-this.m_normals[i].Y*n)),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[i].Y+this.m_normals[i].X*n)))),this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[e].X+this.m_normals[e].Y*n)),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[e].Y-this.m_normals[e].X*n))))},t.ClipperOffset.prototype.DoMiter=function(e,i,n){var r=this.m_delta/n;this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+(this.m_normals[i].X+this.m_normals[e].X)*r),t.ClipperOffset.Round(this.m_srcPoly[e].Y+(this.m_normals[i].Y+this.m_normals[e].Y)*r)))},t.ClipperOffset.prototype.DoRound=function(e,i){for(var n,r=Math.atan2(this.m_sinA,this.m_normals[i].X*this.m_normals[e].X+this.m_normals[i].Y*this.m_normals[e].Y),o=Math.max(t.Cast_Int32(t.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(r))),1),s=this.m_normals[i].X,A=this.m_normals[i].Y,a=0;a<o;++a)this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+s*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+A*this.m_delta))),n=s,s=s*this.m_cos-this.m_sin*A,A=n*this.m_sin+A*this.m_cos;this.m_destPoly.push(new t.IntPoint2(t.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[e].X*this.m_delta),t.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[e].Y*this.m_delta)))},t.Error=function(e){try{throw new Error(e)}catch(e){alert(e.message)}},t.JS={},t.JS.AreaOfPolygon=function(e,i){return i||(i=1),t.Clipper.Area(e)/(i*i)},t.JS.AreaOfPolygons=function(e,i){i||(i=1);for(var n=0,r=0;r<e.length;r++)n+=t.Clipper.Area(e[r]);return n/(i*i)},t.JS.BoundsOfPath=function(e,i){return t.JS.BoundsOfPaths([e],i)},t.JS.BoundsOfPaths=function(e,i){i||(i=1);var n=t.Clipper.GetBounds(e);return n.left/=i,n.bottom/=i,n.right/=i,n.top/=i,n},t.JS.Clean=function(e,i){if(!(e instanceof Array))return[];var n=e[0]instanceof Array;if(e=t.JS.Clone(e),"number"!=typeof i||null===i)return t.Error("Delta is not a number in Clean()."),e;if(0===e.length||1===e.length&&0===e[0].length||i<0)return e;n||(e=[e]);for(var r,o,s,A,a,l,c,p=e.length,h=[],g=0;g<p;g++)if(0!==(r=(o=e[g]).length))if(r<3)s=o,h.push(s);else{for(s=o,A=i*i,a=o[0],l=1,c=1;c<r;c++)(o[c].X-a.X)*(o[c].X-a.X)+(o[c].Y-a.Y)*(o[c].Y-a.Y)<=A||(s[l]=o[c],a=o[c],l++);a=o[l-1],(o[0].X-a.X)*(o[0].X-a.X)+(o[0].Y-a.Y)*(o[0].Y-a.Y)<=A&&l--,l<r&&s.splice(l,r-l),s.length&&h.push(s)}return!n&&h.length?h=h[0]:n||0!==h.length?n&&0===h.length&&(h=[[]]):h=[],h},t.JS.Clone=function(e){if(!(e instanceof Array))return[];if(0===e.length)return[];if(1===e.length&&0===e[0].length)return[[]];var t=e[0]instanceof Array;t||(e=[e]);var i,n,r,o,s=e.length,A=new Array(s);for(n=0;n<s;n++){for(i=e[n].length,o=new Array(i),r=0;r<i;r++)o[r]={X:e[n][r].X,Y:e[n][r].Y};A[n]=o}return t||(A=A[0]),A},t.JS.Lighten=function(e,i){if(!(e instanceof Array))return[];if("number"!=typeof i||null===i)return t.Error("Tolerance is not a number in Lighten()."),t.JS.Clone(e);if(0===e.length||1===e.length&&0===e[0].length||i<0)return t.JS.Clone(e);var n,r,o,s,A,a,l,c,p,h,g,u,d,f,I,m,b=e[0]instanceof Array;b||(e=[e]);var C=e.length,B=i*i,y=[];for(n=0;n<C;n++)if(0!==(a=(o=e[n]).length)){for(s=0;s<1e6;s++){for(A=[],o[(a=o.length)-1].X!==o[0].X||o[a-1].Y!==o[0].Y?(g=1,o.push({X:o[0].X,Y:o[0].Y}),a=o.length):g=0,h=[],r=0;r<a-2;r++)l=o[r],p=o[r+1],c=o[r+2],I=l.X,m=l.Y,u=c.X-I,d=c.Y-m,0===u&&0===d||((f=((p.X-I)*u+(p.Y-m)*d)/(u*u+d*d))>1?(I=c.X,m=c.Y):f>0&&(I+=u*f,m+=d*f)),(u=p.X-I)*u+(d=p.Y-m)*d<=B&&(h[r+1]=1,r++);for(A.push({X:o[0].X,Y:o[0].Y}),r=1;r<a-1;r++)h[r]||A.push({X:o[r].X,Y:o[r].Y});if(A.push({X:o[a-1].X,Y:o[a-1].Y}),g&&o.pop(),!h.length)break;o=A}A[(a=A.length)-1].X===A[0].X&&A[a-1].Y===A[0].Y&&A.pop(),A.length>2&&y.push(A)}return b||(y=y[0]),void 0===y&&(y=[]),y},t.JS.PerimeterOfPath=function(e,t,i){if(void 0===e)return 0;var n,r,o=Math.sqrt,s=0,A=0,a=0,l=0,c=0,p=e.length;if(p<2)return 0;for(t&&(e[p]=e[0],p++);--p;)A=(n=e[p]).X,a=n.Y,s+=o((A-(l=(r=e[p-1]).X))*(A-l)+(a-(c=r.Y))*(a-c));return t&&e.pop(),s/i},t.JS.PerimeterOfPaths=function(e,i,n){n||(n=1);for(var r=0,o=0;o<e.length;o++)r+=t.JS.PerimeterOfPath(e[o],i,n);return r},t.JS.ScaleDownPath=function(e,t){var i,n;for(t||(t=1),i=e.length;i--;)(n=e[i]).X=n.X/t,n.Y=n.Y/t},t.JS.ScaleDownPaths=function(e,t){var i,n,r;for(t||(t=1),i=e.length;i--;)for(n=e[i].length;n--;)(r=e[i][n]).X=r.X/t,r.Y=r.Y/t},t.JS.ScaleUpPath=function(e,t){var i,n,r=Math.round;for(t||(t=1),i=e.length;i--;)(n=e[i]).X=r(n.X*t),n.Y=r(n.Y*t)},t.JS.ScaleUpPaths=function(e,t){var i,n,r,o=Math.round;for(t||(t=1),i=e.length;i--;)for(n=e[i].length;n--;)(r=e[i][n]).X=o(r.X*t),r.Y=o(r.Y*t)},t.ExPolygons=function(){return[]},t.ExPolygon=function(){this.outer=null,this.holes=null},t.JS.AddOuterPolyNodeToExPolygons=function(e,i){var n=new t.ExPolygon;n.outer=e.Contour();var r,o,s,A,a,l,c=e.Childs(),p=c.length;for(n.holes=new Array(p),s=0;s<p;s++)for(r=c[s],n.holes[s]=r.Contour(),A=0,l=(a=r.Childs()).length;A<l;A++)o=a[A],t.JS.AddOuterPolyNodeToExPolygons(o,i);i.push(n)},t.JS.ExPolygonsToPaths=function(e){var i,n,r,o,s=new t.Paths;for(i=0,r=e.length;i<r;i++)for(s.push(e[i].outer),n=0,o=e[i].holes.length;n<o;n++)s.push(e[i].holes[n]);return s},t.JS.PolyTreeToExPolygons=function(e){var i,n,r,o,s=new t.ExPolygons;for(n=0,o=(r=e.Childs()).length;n<o;n++)i=r[n],t.JS.AddOuterPolyNodeToExPolygons(i,s);return s}}();var ze=getDefaultExportFromCjs(He.exports);function alignByMinDist(e,t,i){const n=e.length,r=t.length;if(n<1||r<1)return t.slice();let o=0,s=1/0;for(let A=0;A<r;A++){const a=e[0],l=t[A%r],c=a.x-l.x,p=a.y-l.y,h=e[n-1],g=t[i?Math.min(A+n-1,r-1):(A+n-1)%r],u=h.x-g.x,d=h.y-g.y,f=c*c+p*p+u*u+d*d;f<s&&(s=f,o=A)}return[...t.slice(o),...t.slice(0,o)]}function shapeclip(){const e=1e4;function toclipformat(t){let i=t.map((t=>({X:Math.round(t.x*e),Y:Math.round(t.y*e)})));return ensureOrientation(i)}function fromclipformat(t){return t.map((t=>({x:t.X/e,y:t.Y/e})))}const ensureOrientation=e=>ze.Clipper.Orientation(e)?e:e.slice().reverse();function orientation(e){if(!e.length)return 0;let t=0;const i=e.length;for(let n=0;n<i;n++){const r=e[n],o=e[(n+1)%i];t+=r.X*o.Y-o.X*r.Y}return t>0?1:t<0?-1:0}const _inflate=(e,t,i=!1)=>{const n=new ze.ClipperOffset;n.MiterLimit=4,n.AddPath(e,ze.JoinType.jtMiter,i||2==e.length?ze.EndType.etOpenButt:ze.EndType.etClosedPolygon);const r=new ze.Paths;return n.Execute(r,t),r};function _inflateopen(t,i){const n=new ze.ClipperOffset;n.MiterLimit=4,n.ArcTolerance=.25;const r=i*e,o=toclipformat(t);n.AddPath(o,ze.JoinType.jtMiter,ze.EndType.etClosedPolygon);const s=new ze.Paths;n.Execute(s,r);let A=fromclipformat(s[0]);return getshape().frompt(A)}return{offset(t,i){const n=new ze.ClipperOffset;n.MiterLimit=4,n.ArcTolerance=.25;const r=Math.abs(i)*e,o=toclipformat(t.pt);n.AddPath(o,ze.JoinType.jtMiter,ze.EndType.etOpenButt);const s=new ze.Paths;n.Execute(s,r);let A=fromclipformat(s[0]);return getshape().frompt(A)},inflate:function inflate(t,i=2,n=!1,r=0){let o=toclipformat(t.pt),s=_inflate(o,i*e);if(!s||!s.length)return getshape().frompt([]);let A=getshape().frompt(fromclipformat(s[0]));if(n){A.orient!=t.orient&&A.reverse();let a=alignByMinDist(t.pt,A.pt,r);if(A.frompt(a),r>0&&t.pt.length>=3){function estendi1(e,t){let i=e.segment(0).ruotata(-Math.PI/2,200,!0),n=e.segment(-2).ruotata(-Math.PI/2,200),r=t.segment(-2).interseca(n),o=t.segment(0).interseca(i);o&&(t.pt[0]=o),r&&(t.pt[t.pt.length-1]=r)}function estendi2(e,t){let i=e.segment(-1),n=t.segment(0),r=i.interseca(n);r&&(t.pt[0]=r),n=t.segment(-2);let o=i.interseca(n);o&&(t.pt[t.pt.length-1]=o)}1==r?estendi1(t,A):estendi2(t,A)}}return A},inflateopen:_inflateopen,inflateclose(e,t){let i=_inflateopen(e.pt,t);i.orient!=e.orient&&i.reverse();let n=alignByMinDist(e.pt,i.pt,0);return i.frompt(n),i},inflatecornici(e,t=2,i,n){let r,o=e.npt;if(2==o){let i=e.segment(0).offset(t);r=getshape().frompt([i.p1,i.p2])}else if(3==o){let i=e.segment(0).offset(t),n=e.segment(1).offset(t);if(i.isparallela(n))r=getshape().frompt([i.p1,n.p2]);else{let e=i.interseca(n);r=getshape().frompt([i.p1,e,n.p2])}}else{let o=new Linea2(e.pt[0],e.pt[e.npt-1]),s=o.len,A=o.perpendicolare(o.p1,s),a=o.perpendicolare(o.p2,s);A.isparallela(e.segment(0))&&(A=o.perpendicolare(o.puntot(.1),s)),a.isparallela(e.segment(e.npt-2))&&(a=o.perpendicolare(o.puntot(.9),s));let l=Math.floor(e.npt/2),{t:c}=A.proiezionet(e.pt[l]),p=2*(c>0?-1:1),h=A.puntot(p),g=a.puntot(p);r=_inflateopen([...e.pt,g,h],t);let u=r.pt.reduce(((e,t,i)=>(t.x-h.x)**2+(t.y-h.y)**2<(r.pt[e].x-h.x)**2+(r.pt[e].y-h.y)**2?i:e),0);r.pt=r.pt.slice(u+2).concat(r.pt.slice(0,u)),r.orient!=e.orient&&r.reverse(),i&&(e.truncatebefore(i),r.truncatebefore(i)),n&&(r.truncateafter(n),e.truncateafter(n))}return r},intersecasplitter(e,t){const i=new ze.Clipper,n=[toclipformat(t.pt)],r=[toclipformat(e.pt)];i.AddPaths(n,ze.PolyType.ptSubject,!0),i.AddPaths(r,ze.PolyType.ptClip,!0);const o=new ze.Paths;let s;if(i.Execute(ze.ClipType.ctIntersection,o,ze.PolyFillType.pftNonZero,ze.PolyFillType.pftNonZero)&&o.length>0){const e=o[0];if(1===orientation(e)){s=getshape().frompt(fromclipformat(e)),s.orient!=t.orient&&s.reverse();for(let e=0;e<t.pt.length;e++){let i=t.pt[e],n=s.pt.findIndex((e=>Math.abs(e.x-i.x)<.01&&Math.abs(e.y-i.y)<.01));if(n>0){n-=e,0!=n&&s.selezionaprimo(n);break}}}}return s},offsetpts(t,i=.01){const n=e*i;let r=_inflate(toclipformat(t),n);if(r&&r.length)return fromclipformat(r[0])},areesplitter(e,t,i=!0){if(!Array.isArray(e)||e.length<3)return;if(!t||0==t.length)return[e];const n=new ze.Paths,r=new ze.Paths;let o=i?_inflate(toclipformat(e),-100):[toclipformat(e)],s=i?t.flatMap((e=>_inflate(toclipformat(e),100))):t.map((e=>toclipformat(e)));for(let e of o)n.push(e);for(let e of s)r.push(e);const A=new ze.Clipper;A.AddPaths(n,ze.PolyType.ptSubject,!0),A.AddPaths(r,ze.PolyType.ptClip,!0);const a=new ze.Paths;if(!A.Execute(ze.ClipType.ctDifference,a,ze.PolyFillType.pftNonZero,ze.PolyFillType.pftNonZero))return;let l=[];for(let e of a)if(i){const t=_inflate(e,100);for(const e of t)1===orientation(e)&&l.push(fromclipformat(e))}else if(e.length>4&&1==orientation(e)){const t=_inflate(e,-100);if(t.length>0)for(let e of t){const t=_inflate(e,100);for(const e of t)1===orientation(e)&&l.push(fromclipformat(e))}}else 1==orientation(e)&&l.push(fromclipformat(e));return l},unisci(e,t,i){const n=new ze.Paths,r=new ze.Paths;for(let t of e){let e=[toclipformat(t.pt)];for(let t of e)n.push(t)}if(t&&t.length)for(let e of t){let t=toclipformat(e.pt);r.push(t)}if(i&&i.length)for(let e of i){let t=toclipformat(e.pt),i=_inflate(t,1,!0);for(let e of i)r.push(e)}const o=new ze.Clipper;o.AddPaths(n,ze.PolyType.ptSubject,!0),o.AddPaths(r,ze.PolyType.ptClip,!0);const s=new ze.Paths;if(o.Execute(ze.ClipType.ctDifference,s,ze.PolyFillType.pftNonZero,ze.PolyFillType.pftNonZero)){let e=[],t=[];for(let i of s)if(1==orientation(i)){let t=[i];for(let i of t)e.push({shape:getshape().frompt(fromclipformat(i)),holes:[]})}else t.push(getshape().frompt(fromclipformat(i)));for(let i of t)for(let t of e)if(t.shape.pointinshape(i.pt[0])){t.holes.push(i);break}return e}return[]}}}class Vscene{constructor(e,t,i={}){this.x=e,this.y=t,this.info=i,this.clear()}addrow(e){e||(e={}),e.id=function newid(e){let t=0;for(let i of e)+i.id>t&&(t=+i.id);return t+1}(this.rows);let t=new Vobject(e);return this.rows.push(t),t}clear(){this.curlayer=0,this.rows=[],this.clines=[]}fromjson(e){let t,i;e||(e={info:{}}),this.clear(),this.x=e.x||4e3,this.y=e.y||3e3,this.info=e.info||{},this.curlayer=e.curlayer,e.clines&&(t=e.clines.map((e=>new Linea2(e.p1,e.p2))));let n=this.x,r=this.y;i=[new Linea2(0,0,100,0),new Linea2(n,0,n,100),new Linea2(n,r,n-100,r),new Linea2(0,r,0,r-100)],this.clines=[...i,...t],e.rows&&(this.rows=e.rows.map((e=>new Vobject(e))))}tojson(){let{x:e,y:t,info:i,curlayer:n,xrows:r,xclines:o}=this,s=r.map((e=>e.tojson())),A=o.map((e=>({p1:e.p1,p2:e.p2})));return A=A.slice(4),{x:e,y:t,curlayer:n,rows:s,clines:A}}}class Vobject{constructor(e){e||(e={}),this.fromjson(e)}get lines(){if(this._lines&&this._lines.length)return this._lines;{let{x:e,y:t}=this;return e||(e=100),t||(t=100),[new Linea2(0,0,0,t),new Linea2(e,0,e,t)]}}fromjson(e){let t;this.id=e.id??1,this.layer=e.layer||0,this.hidden=!!e.hidden,this.x=e.x||100,this.y=e.y||100,this.pc=e.pc||{x:0,y:0},e.shape?this.shape=getshape().frompt(e.shape):this.shape=void 0,e.lines&&e.lines.length&&(t=e.lines.map((e=>new Linea2(e.p1,e.p2)))),this._lines=t,this.draw=new Vis2d(`d:${e.id}`),e.draw&&this.draw.fromjson(e.draw),this.info=e.info||{},this.pos=e.pos||{x:0,y:0,rot:0}}tojson(){let{id:e,layer:t,x:i,y:n,pc:r,shape:o,hidden:s,_lines:A,info:a,pos:l}=this;return A=A&&A.length?A.map((e=>({p1:e.p1,p2:e.p2}))):void 0,o=o?o.pt:void 0,{id:e,layer:t,x:i,y:n,pc:r,shape:o,lines:A,hidden:s,info:a,pos:l,draw:this.draw.tojson()}}}class Vis2d{constructor(e){this.name=e,this.clear()}clear(){return this.vec=[],this.gr={},this}tojson(){let e={};for(let t in this.gr)e[t]=this.gr[t].tojson();return{name:this.name,rows:this.vec,groups:e}}fromjson(e){if(!(e&&e.name&&e.rows&&e.groups))throw new Error("wrong data JSON");this.clear(),this.name=e.name,this.vec=e.rows;for(let t in e.groups)this.gr[t]=new Vis2d(t).fromjson(e.groups[t])}creategr(e="grp"){return this.gr[e]||(this.gr[e]=new Vis2d(e)),this.gr[e]}push(e=0,t=0,i={}){"number"==typeof i&&(i={rot:i}),i||(i={}),this.vec.push({type:"push",x:e,y:t,op:i})}pop(){this.vec.push({type:"pop"})}randomcolor(e="100%"){return`hsl(${Math.floor(360*Math.random())}, 50%, 40%,${e})`}addgr(e){let t=e;e?.name&&(t=e.name),this.gr[t]?this.vec.push({type:"group",name:t}):this.vec.push({type:"err",err:`addgroup: ${t} => missing`})}addquota(e,t,i,n,r=0,o="",s=1,A=.25){this.vec.push({type:"quota",x1:e,y1:t,x2:i,y2:n,d:r,text:o,spessore:A,color:"black",scalafont:s})}addqpunto(e,t,i,n,r=0,o="",s=1,A=.25){this.vec.push({type:"qpunto",x1:e,y1:t,x2:i,y2:n,d:r,text:o,spessore:A,color:"black",scalafont:s})}addpoint(e,t=-1,i="red",n=8){return e&&this.vec.push({type:"point",p:e,id:t,color:i,spessore:1*n}),this}addline(e,t=-1,i=void 0,n=1){return e&&this.vec.push({type:"line",l:e,id:t,color:i,spessore:1*n}),this}addrect(e,t=-1,i=void 0,n=1){return e&&this.vec.push({type:"rect",l:e,id:t,color:i,spessore:1*n}),this}addimg(e,t){return e&&this.vec.push({type:"img",l:e,img:t}),this}addrecta(e,t=-1,i=void 0){return e&&this.vec.push({type:"recta",l:e,id:t,color:i,spessore:0}),this}addshape(e,t=void 0,i=1){return e&&this.vec.push({type:"shape",s:e,color:t||this.randomcolor(),spessore:1*i}),this}addshapelin(e,t=void 0,i=1){return e&&this.vec.push({type:"shapelin",s:e,color:t||this.randomcolor(),spessore:1*i}),this}addarea(e,t=void 0){return e&&this.vec.push({type:"area",s:e,color:t||this.randomcolor()}),this}addoffset(e,t){return this.vec.push({type:"offset",x:e||0,y:t||0}),this}}function checkoggetto(e,t,i,n){if("h"==t&&(t="o"),e||(e=[]),"number"==typeof i&&!["a","as"].includes(t))return{cod:"__",macro:"",sps:i};let r=e.find((e=>e.tipo.includes(t)&&e.cod==i&&(e.isshape||n||"a"!=t)));return r||(r=e.find((e=>e.tipo.includes(t)&&(e.isshape||n||"a"!=t)))),r||(r={cod:"__",macro:"",sps:0}),"a"!=t&&"as"!=t||"__"==r.cod||r.color||(r.color=`hsl(${function stringToHue(e){let t=0;for(let i=0;i<e.length;i++)t=31*t+e.charCodeAt(i)>>>0;return Math.floor(.6180339887*t%1*360)}(r.cod)}, 95%, 97%`),r}function getbordi(e,t){let i,n=!1;if(Array.isArray(t)){t.length=4;let r=t[0]||"";i=t.map((t=>checkoggetto(e,"b",t||r))),n=i.every((e=>e.sps===i[0].sps))}else{let r=checkoggetto(e,"b",t);i=[r,r,r,r],n=!0}return{bordi:i,uguali:n,senza:!(i[0].sps||i[1].sps||i[2].sps||i[3].sps),bl:i[0].sps,bt:i[1].sps,br:i[2].sps,bb:i[3].sps}}function elaborapercorso(e,t,i,n,r=0){let o,s,A,a,l,c,p,h,g,u,d,f,I,m,b,C,B=[],y=[];function eseguipezzo(e,t,i,n){let o=e.infoquad(t);if(o&&o.distanza){let s=getshape().frompt(n||[e.p1,e.p2,t.p2,t.p1]),A=s.clone();(o.sx||o.sy)&&A.move(-o.sx||0,-o.sy||0),o.angle&&A.rotate(-o.angle||0);let a={id:++r,type:`b${i}`,info:o};n&&(a.shape=A.pt),y.push({type:`b${i}`,pt:s.pt}),B.push(a)}}r=r||0;let E=e.pt.length,x=E-1;n||(n=[]);let{bordi:P,uguali:w,senza:v}=getbordi(n,t);if(w)if(v||!P[0].sps)o=e.clone();else{let t=P[0].sps;o=shapeclip().inflate(e,-t,!0)}else{let t,i=[],n=[];for(let n=0;n<E;n++){t=0==n?P[0].sps:n==x-1?P[2].sps:n==x?P[3].sps:P[1].sps,"number"!=typeof t&&(t=0);let r=e.segment(n).offset(-t);i.push(r)}for(let e=0;e<E;e++){let t=i[e].interseca(i[(e-1+E)%E]);n.push(t)}o=getshape().frompt(n)}if(!v){A=o.segment(x).interseca(e.segment(0)),a=o.segment(1).interseca(e.segment(0)),l=e.segment(x-1).interseca(o.segment(x-2)),c=e.segment(x-1).interseca(o.segment(x)),p=e.segment(x).interseca(o.segment(0)),h=e.segment(1).interseca(o.segment(0)),g=e.segment(x-2).interseca(o.segment(x-1)),u=e.segment(x).interseca(o.segment(x-1)),b=1,C=x-2,I=o.segment(0),m=o.segment(x-1);for(let t=1;t<x-1;t++){let i=e.segment(t),n=i.interseca(I);n&&i.onsegment(n)&&(b=t,h=n),n=i.interseca(m),n&&i.onsegment(n)&&(C=t,g=n)}b-=1,C=x-2-C;let n=e.pt[0],r=o.pt[0],B=o.pt[x],y=e.pt[x];switch(i[0]){case"v":eseguipezzo(new Linea2(u,p),o.segment(x),3),r=p,B=u;break;case"o":eseguipezzo(e.segment(x),new Linea2(c,A),3),n=A,y=c;break;default:eseguipezzo(e.segment(x),o.segment(x),3)}switch(d=e.pt.slice(1,x),f=o.pt.slice(1,x),i[1]){case"v":eseguipezzo(new Linea2(n,e.pt[1]),new Linea2(r,h),0),eseguipezzo(new Linea2(e.pt[x-1],y),new Linea2(g,B),2),b&&(d=d.slice(b)),C&&(d=d.slice(0,-C)),d[0]=h,d[d.length-1]=g;break;case"o":eseguipezzo(new Linea2(n,a),new Linea2(r,o.pt[1]),0),eseguipezzo(new Linea2(l,y),new Linea2(o.pt[x-1],B),2),f[0]=a,f[f.length-1]=l;break;default:eseguipezzo(new Linea2(n,e.pt[1]),new Linea2(r,o.pt[1]),0),eseguipezzo(new Linea2(e.pt[x-1],y),new Linea2(o.pt[x-1],B),2)}if(s=getshape().frompt(f),d.length<8&&d.length==f.length)for(let e=0;e<d.length-1;e++)eseguipezzo(new Linea2(d[e],d[e+1]),new Linea2(f[e],f[e+1]),1);else{let e=getshape().frompt([...d,...f.reverse()]),i=new Linea2(d[0],d[d.length-1]),n=i.offset(-t[1]);eseguipezzo(i,n,1,e.pt)}}return{countid:r,shape2:o,shapetop:s,bordi:P,dati:B,draws:y}}function creaprofiloesterno(e,t){let i,{x:n,y:r,tipo:o,bordo:s,taglio:A,h1:a,h2:l,l1:c,l2:p,forma:h}=e;n=n<50?50:n,r=r<50?50:r,c=c||0,p=p||0,a=a||0,l=l||0;let g=[0,0];switch(o){case"i":case"d":g.push(c>0&&c<n?c:0,a>0&&a<r?r-a:r),g.push(p>0&&p<n-c?n-p:n,l>0&&l<r&&l!=a?r-l:r);break;case"a":if(h){let e=getshape().fromstr(h);e.alignline({x:c,y:r-a},{x:n-p,y:r-l}),g.push(...e.vec)}else if((a||l)&&a>=0&&a<Math.min(r,n/2)&&l>=0&&l<Math.min(r,n/2)){let e=getshape().fromstr(`a30;${c||0};${r-a};${n/2};${r};${n-p};${r-l}`);g.push(...e.vec)}else g.push(0,r,n,r);break;case"s":c>0&&a>0?g.push(0,r-a,c,r):g.push(0,r),p&&p<n-c&&l>0&&l<r?g.push(n-p,r,n,r-l):g.push(n,r);break;default:g.push(0,r,n,r)}g.push(n,0),e.countid=0,i=getshape().fromvec(g);let{countid:u,shape2:d,shapetop:f,bordi:I,dati:m,draws:b}=elaborapercorso(i,s,A,t,e.countid);return e.countid=u,{shape:i,internalshape:d,shape2:d,shapetop:f,bordi:I,dati:m,draws:b}}const je={x:"normale",s:"smussato",i:"inclinato",a:"arco/sagomato",d:"diagonali"},Je={dd:"diagonale",vv:"verticale",oo:"orizzontale",vo:"verticale+orizzontale",vd:"verticale+diagonale",ov:"orizzontale+verticale",od:"orizzontale+diagonale"},We={d:"dist. positiva","d-":"dist. negativa",p:"perc. positiva","p-":"perc negativa"},Ke={l:"sinistra",c:"centro",r:"destra"};function findareacod(e,t,i){let n=1/0,r="";for(let o of e){let e=(o.x-t)**2+(o.y-i)**2;e<n&&(n=e,r=o.k)}return r}function generatesegments(e,t,i=!1,n=!1){let r=[];if(e?.length>=2){if(n){let t=[];for(let i of e)t.push({a:i.a,b:i.a}),i.a!=i.b&&t.push({a:i.b,b:i.b});e=t}if(e=e.sort(((e,t)=>e.a-t.a)),t?.length){let n=0;for(let o=1;o<e.length;o++){const s=1e-6;if(t.find((t=>t>e[o-1].b+s&&t<e[o].a-s))){if(o-1>n){let t;t=i?{a:e[n].b,b:e[o-1].a}:{a:e[n].a,b:e[o-1].b},r.push(t)}n=o}}n<e.length-1&&(i?r.push({a:e[n].b,b:e[e.length-1].a}):r.push({a:e[n].a,b:e[e.length-1].b}))}else r.push({a:e[0].b,b:e[e.length-1].a})}return r}function makedivisions(e,t,i){delete e.arre;let n=[],r=[],o=[],s=[],{x:A,y:a,oriz:l,vert:c,tipo:p,minvano:h,minvanox:g,minvanoy:u}=e,{bb:d,bt:f,bl:I,br:m}=getbordi(i,e.bordo);g=g||h||50,u=u||h||50;let{dati:b,punti:C}=ordinabase(i,"o",l,a,u,d,f,p),{dati:B,punti:y}=ordinabase(i,"v",c,A,g,I,m),E=t.clone();function adddatilin(e,t,A,a,l,c){if("l"==e)r.push([A.p1,A.p2]),s.push([A.p1.x,A.p1.y,A.p2.x,A.p2.y]);else{let p=[A.p1,A.p2,a.p2,a.p1];r.push(p);let h=getshape().frompt(p);if(E?.pt&&(h.orient!=E.orient&&h.reverse(),h=shapeclip().intersecasplitter(E,h)),h){h.pt.length>=4&&(A.p1=h.pt[0],A.p2=h.pt[1],a.p1=h.pt[h.pt.length-1],a.p2=h.pt[h.pt.length-2]),s.push([A.p1.x+("v"==e?l:0),A.p1.y+("v"!=e?l:0),A.p2.x+("v"==e?l:0),A.p2.y+("v"!=e?l:0)]);let r=A.infoquad(a);if(r&&r.distanza){let s=h.clone(),A=checkoggetto(i,e,t);(r.sx||r.sy)&&s.move(-r.sx||0,-r.sy||0),r.angle&&s.rotate(-r.angle||0);let a={id:c,type:e,cod:t,c2:A,shape:s.pt,info:r};o.push(a),a?.shape&&n.push({type:e,sx:a.info.sx,sy:a.info.sy,rot:a.info.angle,pt:a.shape})}}}}function isinseg(e,t){return!!e.find((e=>e.a<=t&&e.b>=t))}B.forEach(((e,t)=>{e.segs=generatesegments(C,e.cuts,!0),e.segs.forEach(((t,i)=>{let n=new Linea2({x:e.x,y:t.a},{x:e.x,y:t.b}),r=new Linea2({x:e.x+e.sp,y:t.a},{x:e.x+e.sp,y:t.b});adddatilin(e.sp?"v":"l",e.cod,n,r,e.sp/2,e.id)}))}));for(let e of b){let t=[...e.cuts],i=[...y];for(let n of B)i.push({a:n.x,b:n.x+n.sp}),isinseg(n.segs,e.x+e.sp/2)&&t.push(n.x+n.sp/2);e.segs=generatesegments(i,t,!0,!0),e.segs=e.segs.filter((e=>Math.abs(e.a-e.b)>40));for(let t of e.segs){let i=new Linea2({x:t.b,y:e.x+e.sp},{x:t.a,y:e.x+e.sp}),n=new Linea2({x:t.b,y:e.x},{x:t.a,y:e.x});adddatilin(e.sp?"o":"l",e.cod,n,i,e.sp,e.id)}}let x=shapeclip().areesplitter(t.pt,r),P=function getareacodes(e){let t,i,n,r,o=[];for(let s=0;s<=e.vert.length;s++){if(0==s)t="v0",i=0;else{let n=e.vert[s-1];t=`${n.dir}${n.id}`,i=n._v}for(let s=0;s<=e.oriz.length;s++){if(0==s)n="o0",r=0;else{let t=e.oriz[s-1];n=`${t.dir}${t.id}`,r=t._v}o.push({k:t+n,x:i,y:r})}}return o}(e);for(let t of x){let r=getshape().frompt(t),{p1:s,width:A,height:a,isrect:l}=r.dims(),c=findareacod(P,s.x,s.y),p=e.aree[c]||e.area||"",h=checkoggetto(i,"a",p,l),g=r.pt.findIndex((e=>Math.abs(e.x-s.x)<.001&&Math.abs(e.y-s.y)<.001));g>0&&r.selezionaprimo(g),r.pt.length&&(r.move(-s.x,-s.y),1==r.orient&&r.reverse()),o.push({id:c,cod:p,c2:h,type:"a",shape:l?null:r.pt,info:{isrect:l?1:0,sx:s.x,sy:s.y,rot:0,width:A,height:a}}),n.push({type:l?"a":"as",sx:s.x,sy:s.y,dx:A,dy:a,id:c,cod:p,rot:0,pt:r.pt,color:h.color})}return{ff:e,h1:b,ph:C,v1:B,pv:y,draws:n,lines:s,dati:o}}function ordinabase(e,t,i,n,r,o,s,A){let a=[];if(i){for(let r of i){let i=checkoggetto(e,t,r.cod).sps||0,A=0;switch(r.tipo){case"d-":A=n-r.v;break;case"p":A=n*r.v/100;break;case"p-":A=n*(100-r.v)/100;break;default:A=r.v}if(i&&"c"==r.align?A-=i/2:i&&"r"==r.align&&(A-=i),A=Math.round(10*A)/10,r._x0=A,r._x1=A+i,r._v=A+i/2,r._valid=A>0&&A<n,A>o&&A<n-s){let e=[];r.cuts&&r.cuts.length&&r.cuts.forEach((t=>{e.push(t<0?n+t:t)})),a.push({id:r.id,x:A,sp:i,cuts:e,cod:r.cod})}}a.sort(((e,t)=>e.x-t.x))}let l=[],c=o;"a"==A&&(n*=1.3);for(let e=0;e<a.length;e++){let t=a[e];t.x>=c+r&&t.x+t.sp<=n-s-r&&(t.min=c+r,t.max=n-s-r,l.length>0&&(l[l.length-1].max=t.x-r),l.push(t),c=t.x+t.sp)}let p=[];p.push({a:o,b:o});for(let e of l)p.push({a:e.x,b:e.x+e.sp});return p.push({a:n-s,b:n-s}),{dati:l,punti:p}}function check(e){let{x:t,y:i,area:n,bordo:r,gvert:o,goriz:s,priority:A,minvano:a,taglio:l,tipo:c,h1:p,h2:h,l1:g,l2:u,d1:d,x1:f,y1:I,d2:m,x2:b,y2:C,vert:B,oriz:y,aree:E,forma:x,countid:P}=e;return t=t||1e3,t<200&&(t=200),i=i||1e3,i<200&&(i=200),p=p||I||0,h=h||C||0,g=g||d||f||0,u=u||m||b||0,p<0&&p>i-100&&(p=0),h<0&&h>i-100&&(h=0),(u<0||u>t-g)&&(u=0),(g<0||g>t-u)&&(g=0),a=a||50,x&&(c="a"),n=n||"__",r=r||"__",A=A||"v",l=Je[l]?l:"dd",c=je[c]?c:"x",B=B||[],y=y||[],E=E||{},s=s||void 0,o=o||void 0,P=P||1,{x:t,y:i,area:n,bordo:r,gvert:o,goriz:s,priority:A,minvano:a,taglio:l,tipo:c,h1:p,h2:h,l1:g,l2:u,vert:B,oriz:y,aree:E,countid:P}}function addtaglio(e,t,i,n,r,o="c",s=[],A){return A||(console.log("manca id a addtaglio"),A=0),{dir:t,id:A,tipo:We[i]?i:"d",align:Ke[o]?o:"c",v:n,cod:r,cuts:s||[]}}function addoriz(e,t,i,n,r,o){let s=Array.isArray(e.bordo)?e.bordo[0]:e.bordo;n||(n=e.goriz||s||"__"),Array.isArray(r)&&(o=r,r="c"),e.oriz||(e.oriz=[]);let A=addtaglio(0,"o",t,i,n,r,o,(e.oriz.length?Math.max(...e.oriz.map((e=>e.id))):0)+1);return e.oriz.push(A),e}var Ve=Object.freeze({__proto__:null,addhoriz:function addhoriz(e,t,i,n,r,o){return addoriz(e,t,i,n,r,o)},addoriz:addoriz,addvert:function addvert(e,t,i,n,r,o){let s=Array.isArray(e.bordo)?e.bordo[0]:e.bordo;n||(n=e.gvert||s||"__"),Array.isArray(r)&&(o=r,r="c"),e.vert||(e.vert=[]);let A=addtaglio(0,"v",t,i,n,r,o,(e.vert.length?Math.max(...e.vert.map((e=>e.id))):0)+1);return e.vert.push(A),e},calcoladivisioni:function calcoladivisioni(e,t,i,n){return makedivisions(e,i,n)},check:check,checkoggetto:checkoggetto,creaprofiloesterno:creaprofiloesterno,create:function create(e,t,i,n){n||(n={});let{minvano:r,priority:o,taglio:s,tipo:A,h1:a,h2:l,d1:c,d2:p,l1:h,l2:g,x1:u,x2:d,y1:f,y2:I,gvert:m,goriz:b,forma:C,area:B}=n,y=check({x:e,y:t,area:B,bordo:i,gvert:m,goriz:b,priority:o,minvano:r,taglio:s,tipo:A,h1:a,h2:l,l1:h,l2:g,d1:c,x1:u,y1:f,d2:p,x2:d,y2:I});return y.forma=C,y},elaborapercorso:elaborapercorso,getbordi:getbordi,makedivisions:makedivisions,makeshape:function makeshape(e,t){return creaprofiloesterno(e,t)},priorita:{v:"verticale",h:"orizzontale"},tagli:Je,tipi:je,tipilocks:[{cod:"diml",des:"Larghezza"},{cod:"dima",des:"Altezza"},{cod:"etipo",des:"Modifica Tipo"},{cod:"etaglio",des:"Modifica Taglio"},{cod:"ebordi",des:"Modifica Bordi"},{cod:"esag",des:"Shape"},{cod:"vcrea",des:"Crea Div. Verticale"},{cod:"ocrea",des:"Crea Div. Orizzontale"},{cod:"vmov",des:"Sposta Div. Verticale"},{cod:"omov",des:"Sposta Div. Orizzontale"},{cod:"vedit",des:"Modifica Div. Verticale"},{cod:"oedit",des:"Modifica Div. Orizzontale"},{cod:"emods",des:"Modificatori Orizzontali/Verticali"},{cod:"ecuts",des:"Modifica/Aggiungi Cuts"},{cod:"earee",des:"Modifica Aree"}],tipoalign:Ke,tipocut:We});function joinlinestoshapes(e){let t=[];for(let i of e)for(let e of i.lines){let n=new Linea2(e.p1,e.p2);n.rotate(-i.ang),n.move(i.pos.x,i.pos.z),n.valid=!0,t.push(n)}const i=.1;function samepoint(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)<i}for(let e=0;e<t.length;e++){if(!t[e].valid)continue;if(t[e].len<i){t[e].valid=!1;continue}const n=t[e];for(let r=e+1;r<t.length;r++){const e=t[r];if(!e.valid)continue;if(!n.isparallela(e))continue;if(!n.isCollineare(e))continue;n.a1b=e.onsegment(n.p1,i),n.a2b=e.onsegment(n.p2,i),n.b1a=n.onsegment(e.p1,i),n.b2a=n.onsegment(e.p2,i);const{x:o,y:s}=n.direzione,{x:A,y:a}=e.direzione;if(o*A+s*a>0)if(n.b1a&&n.b2a)e.valid=!1;else{if(n.a1b&&n.a2b){n.valid=!1;break}if(n.a1b&&n.b2a){let i=new Linea2(e.p1,n.p2);i.valid=!0,t.push(i),n.valid=!1,e.valid=!1;break}if(n.a2b&&n.b1a){let i=new Linea2(n.p1,e.p2);i.valid=!0,t.push(i),n.valid=!1,e.valid=!1;break}}else{const r=n.proiezionet(n.p1).t,o=n.proiezionet(n.p2).t,s=n.proiezionet(e.p1).t,A=n.proiezionet(e.p2).t,a=Math.min(r,o),l=Math.max(r,o),c=Math.min(s,A),p=Math.max(s,A),h=Math.max(a,c),g=Math.min(l,p);if(g>h+i){if(a<h){let e=new Linea2(n.puntot(a),n.puntot(h));e.valid=!0,t.push(e)}if(l>g){let e=new Linea2(n.puntot(l),n.puntot(g));e.valid=!0,t.push(e)}if(c<h){let e=new Linea2(n.puntot(c),n.puntot(h));e.valid=!0,t.push(e)}if(p>g){let e=new Linea2(n.puntot(p),n.puntot(g));e.valid=!0,t.push(e)}n.valid=!1,e.valid=!1;break}}}}t=t.filter((e=>e.valid)).map((e=>getshape().frompt([e.p1,e.p2])));for(let e=0;e<t.length;e++){let i=t[e],n=!0;for(;n;){n=!1;for(let r=e+1;r<t.length;){let e=t[r];samepoint(i.pt[0],e.pt[0])?(e.pt.reverse(),i.pt.unshift(...e.pt.slice(0,-1)),t.splice(r,1),n=!0):samepoint(i.pt[i.pt.length-1],e.pt[e.pt.length-1])?(e.pt.reverse(),i.pt.push(...e.pt.slice(1)),t.splice(r,1),n=!0):samepoint(i.pt[0],e.pt[e.pt.length-1])?(i.pt.unshift(...e.pt.slice(0,-1)),t.splice(r,1),n=!0):samepoint(i.pt[i.pt.length-1],e.pt[0])?(i.pt.push(...e.pt.slice(1)),t.splice(r,1),n=!0):r++}}}return t}async function valutagrafica(e,t,i,n,r){let{getcolonne:o,muCalc:s,muEval:A,tipifree:a}=e.muvalutatore;i||(i={});for(let i of["l","a","p"]){!e.vari.var(i)&&t.dims&&e.vari.add(i,String(t.dims[i].val||100))}let l=new Set;const c=["sl","sa","sp","ul","ua","up","ax","ay","az","scx","scy","scz","scale"];let p,h=!1,g=await A(e,t,t.codice,{leveleval:0,checkheader:e=>{let{variante:i}=e;if(Array.isArray(t.head)){let e=t.head.find((e=>e.cod==i));h=!!e}},grafica:async t=>{let r,o,a,l,p,{id:h,pars:g,parametri:u,macro:d,options:f,vari:I}=t,m=!!(d&&d.head&&d.head.length),b={l:e.vari.var("l"),a:e.vari.var("a"),p:e.vari.var("p")};const C=["l","a","p","#d",...c];for(let t of C){let i=e.vari.dictionary[t];i&&(b[t]=i)}async function _parsepars(t,i){let n,A,c=/^#(d|des|descrizione)\s*=\s*(.*)\s*$/im.exec(t);if(c)n="#d",A=await e.vari.valuta(c[2]);else{let e=await I.parametrokeyval(t);n=e.k,A=e.v}n&&!p[n]&&(p[n]=!0,C.includes(n)?"#d"==n?l=A:("string"==typeof A&&(A=s(A)),["l","a","p"].includes(n)&&e.vari.add(n,String(A)),o[n]=A,a=!0):"string"==typeof A?r.push(`${n}=${A}`):e.vari.add(n,A))}let B;if(r=[],o={},a=!1,l="",p={},n&&n.keys&&n.keys[h]&&(B=n.keys[h].pars,B))for(let t in B){let i=e.vari.dictionary[t];i&&(b[t]=i),await _parsepars(`${t}=${B[t]}`)}if(g&&g.length)for(const e of g)await _parsepars(e);if(u&&u.length)for(const e of u)await _parsepars(e);if(d&&d.head&&d.head.length){let e=d.head.filter((e=>!["g","p"].includes(e.t)));for(const t of e)await _parsepars(t.cod)}let y={iscad:a,isheader:m,name:d.name,des:l,leveleval:f.leveleval};m&&h&&(y.id=h),a&&(o.l?e.vari.add("l",String(o.l)):o.l=s(e.vari.var("l")),o.a?e.vari.add("a",String(o.a)):o.a=s(e.vari.var("a")),o.p?e.vari.add("p",String(o.p)):o.p=s(e.vari.var("p")),y.cadv=o),await d.impostaparametri(u,r,!0,B);let E=i[h];h&&m&&E&&E.pars&&(y.pars=E.pars,f.leveleval++,await d.setparametri(E.pars));let x=e.vari.var("_rootnode");if(e.vari.add("_rootnode","0"),y.rows=await A(e,d,d.codice,f),e.vari.add("_rootnode",x),h&&m&&(y.spars=d.getparametri()),a)for(let t in b)e.vari.dictionary[t]=b[t];return y},parsefnpunto:async e=>{let{dati:t,vari:i,id:n,output:r}=e;t=t.trim();let A=t.indexOf(" "),a=t.indexOf(",");a>0&&A>0&&a<A&&(A=a);let p,h,g={},u={};A>1?(p=t.slice(1,A),h=o(t.slice(A+1))):(p=t.slice(1),h=[]),l.has(p)||l.add(p);for(let e of h){let{k:t,v:n}=await i.parametrokeyval(e);t&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&(g[t]=n||"")}for(let e of["l","a","p"])g[e]||(g[e]=i.var(e));let d=Object.keys(g);for(let e of c)d.includes(e)&&(u[e]=s(g[e]),u[e]&&(g[e]=u[e]));r.push({t:"fn",fn:p,id:n,pars:g,p2:u})}});for(let i of["l","a","p"])if(t.dims&&t.dims[i].val!=parseFloat(e.vari.var(i))){p=!0;break}return(h||p&&"function"==typeof r)&&await r(p,h),{oo:g,vari:e.vari.dump(!0),fnlist:[...l]}}function ismacro(e){return"object"==typeof e&&e?.name&&e.rows}function isfn(e){return"object"==typeof e&&"fn"==e?.t}function getnodebyid(e,t){let i;return t&&t.rows&&function _getnode(t){for(let n of t){if(ismacro(n)){if(n.id==e)return void(i=n);n.rows&&_getnode(n.rows)}if(i)return}}(t.rows),i}function getsubrules(e){let t=[];return t.push({id:"",level:0,name:"home"}),function _xfiltrati(e,i){if(e.rows&&e.rows.length)for(let n of e.rows)ismacro(n)&&(n.id&&n.isheader?(t.push({id:n.id,name:n.name,des:n.des||"",spec:n.pars?1:0,level:i}),_xfiltrati(n,i+1)):_xfiltrati(n,i))}(e,1),t}function getdumpmacro(e){let t=[];return function _dumpnodo(e){if(e.rows&&e.rows.length)for(let i of e.rows)if(ismacro(i)){i.name;let e=[];if(i.iscad&&i.cadv)for(let t in i.cadv){let n=i.cadv[t];"number"==typeof n&&n&&e.push(`${t}=${n}`)}if(i.pars)for(let t in i.pars){let n=i.pars[t];e.push(`${t}=${n}`)}e.length&&t.push(`--\x3e ${i.name} ${e.join(",")}`),_dumpnodo(i),e.length&&t.push("<--")}else isfn(i)?t.push(`FN: ${i.fn} ${JSON.stringify(i.pars)}`):"string"==typeof i&&i.length&&t.push(i)}(e),t.join("\n")}const Ze=new e.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:e.DoubleSide});function getorientate(e,t,i,n){switch(t=t||0,i=i||0,n=n||0,e.trim().toLowerCase()){case"alp":return{x:i,y:t,z:n};case"apl":return{x:i,y:n,z:t};case"pla":return{x:n,y:t,z:i};case"pal":return{x:n,y:i,z:t};case"lpa":return{x:t,y:n,z:i};default:return{x:t,y:i,z:n}}}function parselavs(e,t,i=0,n=0,r=0,o="",s="",A=""){let a=muClComments(o),l=[];for(let o of a){let A=/^([({}):$\w.\\/]+)[\s;,]*(.*)?$/im.exec(o);if(A&&A[1]){let o={name:A[1].trim().toLowerCase(),...getorientate(e,i,n,r),id:t,facce:s};if(A[2]){let e=getcolonne(A[2]);for(let t of e){let e=t.indexOf("=");e>0&&(o[t.slice(0,e).trim()]=t.slice(e+1).trim())}}l.push(o)}}return!l.length&&A&&l.push({name:A,...getorientate(e,i,n,r),id:t,facce:s}),l}function getemitter(t){let{d:i,name:n,x:r,y:o,z:s,lavs:A="",ids:a="",faces:l=null,size:c=5}=t;a=getcolonne(clean(a,!0));const p=new e.Object3D;if(p.position.set(r,o,s),p.userData={emitter:!0,lavs:A,ids:a,faces:l,size:c,name:n},i){const t=new e.SphereGeometry(c||5,8,8),i=new e.MeshBasicMaterial({color:16711680}),n=new e.Mesh(t,i);p.add(n)}return p}function getreceiver(t,i){t.gmats.__istask=1;let{d:n,ori:r="LAP",x:o=0,y:s=0,z:A=0,tipo:a="",start:l="",end:c=""}=i;a=clean(a,!0);const p=new e.Object3D;if(p.position.set(o/2,s/2,A/2),p.userData={receiver:!0,ori:(r||"").trim().toLowerCase(),x:o,y:s,z:A,tipo:a,start:l,end:c},n){const t=new e.BoxGeometry(o,s,A),i=new e.Mesh(t,Ze);i.position.set(0,0,0),p.add(i)}return p}function calcolatasks(t){const i=new WeakMap,n=new WeakMap;function boxBoxIntersects(e,t,i,n,r){return e.x+t>0&&e.x-t<i&&e.y+t>0&&e.y-t<n&&e.z+t>0&&e.z-t<r}function getFacceToccate(e,t,i,n,r,o){const s=[];function addfaccia(e){o&&!o.includes(e)||s.push(e)}return Math.abs(e.x-0)<t&&addfaccia("s"),Math.abs(e.x-i)<t&&addfaccia("d"),Math.abs(e.y-0)<t&&addfaccia("b"),Math.abs(e.y-n)<t&&addfaccia("a"),Math.abs(e.z-0)<t&&addfaccia("z"),Math.abs(e.z-r)<t&&addfaccia("f"),s.join("")}function getEmitterWorldPosition(t){if(!i.has(t)){const n=new e.Vector3;t.getWorldPosition(n),i.set(t,n)}return i.get(t)}function getReceiverWorldMatrixInverse(e){if(!n.has(e)){const t=e.matrixWorld.clone().invert();n.set(e,t)}return n.get(e)}t.updateMatrixWorld(!0);const r=[],o=[];!function scan(e){e.userData?.receiver&&r.push(e),e.userData?.emitter&&o.push(e),e.children&&e.children.forEach(scan)}(t);let s=[];for(const t of r){const{mat:i,ori:n,x:r,y:A,z:a,start:l,end:c,tipo:p,size:h}=t.userData;let g={id:i,...getorientate(n,r,A,a),tipo:p,ori:n,lavs:[]};l&&g.lavs.push(...parselavs(n,"_start",0,0,0,l,"",""));const u=getReceiverWorldMatrixInverse(t);for(const t of o){if("string"==typeof p&&""!==p){const e=t.userData.ids;if(Array.isArray(e)&&e.length>0&&!e.includes("*")&&!e.includes(p))continue}const i=getEmitterWorldPosition(t).clone().applyMatrix4(u).clone().add(new e.Vector3(r/2,A/2,a/2));if(!boxBoxIntersects(i,t.userData.size??0,r,A,a))continue;const o=getFacceToccate(i,t.userData.soglia??2,r,A,a,t.userData.faces);o&&o.length&&g.lavs.push(...parselavs(n,t.userData.name,i.x,i.y,i.z,t.userData.lavs,o,"nd"))}c&&g.lavs.push(...parselavs(n,"_end",0,0,0,c,"","")),g.lavs.length&&s.push(g)}return s}function getbb(t,i=!1){if(!i&&t.userData.bb)return t.userData._boundingbox;const n=(new e.Box3).setFromObject(t);return t.userData._boundingbox=n,n}function setorigine(t,i=0,n=0,r=0){const o=getbb(t).min,s=new e.Group;return s.add(t),t.position.sub(new e.Vector3(o.x+i,o.y+n,o.z+r)),s}function scalaoggetto(t,i,n={}){const r=getbb(i),o=new e.Vector3;r.getSize(o);const s=r.min,A=["x","y","z","u","v"],a={};for(let e of A){let t=n[e];if(void 0===t)a[e]={s:1};else if("number"==typeof t)a[e]={s:t};else if("object"==typeof t){let i=t.s??1,n="x"===e?o.x:"y"===e?o.y:o.z,r="x"===e?s.x:"y"===e?s.y:s.z;void 0!==t.distperc&&(t.dist=n*t.distperc),void 0!==t.dist&&(i=(n+t.dist)/n);let A=t.p1?t.p1+r:void 0,l=t.p2?t.p2+r:void 0;void 0!==t.p1perc&&(A=r+n*t.p1perc),void 0!==t.p2perc&&(l=r+n*t.p2perc),a[e]={s:i,p1:A,p2:l}}}if(A.every((e=>void 0===a[e].p1||void 0===a[e].p2))){if(1===a.x.s&&1===a.y.s&&1===a.z.s)return i;const t=new e.Group;return t.scale.set(a.x.s,a.y.s,a.z.s),t.add(i),t}const l=hash(`${i.uuid}|${JSON.stringify(a)}`);if(t.meshes[l])return t.meshes[l];const c={};A.forEach((e=>{const{s:t,p1:i,p2:n}=a[e];c[e]=!(1===t&&void 0===i&&void 0===n)}));const p=i.clone(!0);return delete p?.userData._boundingbox,p.traverse((e=>{if(e.isMesh){const t=e.scale.clone();e.geometry=e.geometry.clone();const i=e.geometry.attributes.position,n=e.geometry.attributes.uv,trasf=(e,t)=>{if(!c[t])return e;const{s:i,p1:n,p2:r}=a[t];if(void 0===n||void 0===r)return e*i;const o=r*i-r;if(e<n)return e;if(e>=r)return e+o;return n+(e-n)*((r-n+o)/(r-n))};if(i&&(c.x||c.y||c.z)){const t=i.array;for(let e=0;e<t.length;e+=3)c.x&&(t[e]=trasf(t[e],"x")),c.y&&(t[e+1]=trasf(t[e+1],"y")),c.z&&(t[e+2]=trasf(t[e+2],"z"));i.needsUpdate=!0,e.geometry.computeVertexNormals()}if(n&&(c.u||c.v)){const e=n.array;for(let t=0;t<e.length;t+=2)c.u&&(e[t]=trasf(e[t],"u")),c.v&&(e[t+1]=trasf(e[t+1],"v"));n.needsUpdate=!0}e.scale.set(t.x*a.x.s,t.y*a.y.s,t.z*a.z.s)}})),t.meshes[l]=p,p}function posiziona(t,i={}){let n=new e.Group;if(t){let r=t.clone(),o=r,{marker:s="",markerid:A="",sl:a=0,sa:l=0,sp:c=0,ax:p=0,ay:h=0,az:g=0,ul:u=0,ua:d=0,up:f=0,scale:I=1,scx:m=I,scy:b=I,scz:C=I,emitters:B,emittersname:y,order:E,ignoreTraverse:x}=i;if("number"==typeof E&&r.traverse((e=>{e.isMesh&&(e.renderOrder=E)})),n.position.set(a,l,c),n.rotation.set(p*Ue,h*Ue,g*Ue),(u||d||f)&&(o=new e.Group,o.add(r),o.position.set(u,d,f)),n.scale.set(m,b,C),n.add(o),s&&A&&(n.userData.marker=s,n.userData.markerid=`#mk_${A||""}`),x&&(n.userData.ignoreTraverse=!0),B&&B.length)for(let e of B)e.name=e.name||y,n.add(getemitter(e))}return n}const $e=e.DoubleSide;let et=new e.LineBasicMaterial({color:16711680,transparent:!1,opacity:1}),tt=new e.LineBasicMaterial({color:11579568,transparent:!1,opacity:1});const it=new e.MeshStandardMaterial({color:16777215,roughness:.5,metalness:.4,side:$e}),nt=new e.MeshStandardMaterial({color:8421504,roughness:.5,metalness:.4,side:$e}),rt=new e.MeshStandardMaterial({color:11579568,roughness:.5,metalness:.4,side:$e}),ot=new e.MeshStandardMaterial({color:16711680,roughness:.5,metalness:.4,side:$e}),st=new e.MeshStandardMaterial({color:1982639,roughness:.5,metalness:.4,side:$e}),At=new e.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:$e}),at=new e.MeshStandardMaterial({color:0,roughness:.5,metalness:.4,side:$e}),lt=.001;function groupfromgeometry(t,i,n,r,o,s,A){let a=new e.Group;a.position.set(n,r,o),a.name=s;const l=new e.Mesh(t,i);l.name=s,l.castShadow=!0,l.receiveShadow=!0,l.layers.set(A);const c=new e.EdgesGeometry(t),p=new e.LineSegments(c,et);return p.layers.set(30),a.add(l),a.add(p),a}function edgesfromgeometry(t,i=30){return getlinesgeom(new e.EdgesGeometry(t,40),i)}function getlinesgeom(t,i=30){const n=new e.LineSegments(t,et);return n.layers.set(i),n}function getmesh(t,i,n=1,r=!1){let o=new e.Mesh(t,r?i.clone():i);return o.castShadow=!0,o.receiveShadow=!0,o.layers.set(n),o}function get3dshape(t,i,n){if(!t||t.length<3)return new e.BufferGeometry;const r=[];for(let e=0;e<t.length;e++){const i=t[e],n=t[(e+1)%t.length];r.push(i.x,0,i.y),r.push(n.x,0,n.y)}const o=new e.BufferGeometry;o.setAttribute("position",new e.Float32BufferAttribute(r,3));let s=new e.LineSegments(o,i);return s.layers.set(n),s}function creategroup(t,i={}){let{ignoreTraverse:n}=i,r=new e.Group;return r.name=t||"$$",n&&(r.userData.ignoreTraverse=!0),r}function svuotanodo(e){!function _dispose(e){if(e.children.length){[...e.children].forEach((t=>{_dispose(t),e.remove(t)}))}e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach((e=>e.dispose())):e.material.dispose())}(e)}function deletegroup(e,t){if(!e?.children)return;let i=e.children.find((e=>e.name==t));if(i){for(;i.children.length>0;){const e=i.children[0];i.remove(e)}i.parent&&i.parent.remove(i),i=null}}function randombasemat(){const t=new e.LineBasicMaterial,i=new e.Color;return i.setHSL(Math.random(),.7,.4),t.color=i,t}function getspriteid(t,i=5,n="#000"){const r=document.createElement("canvas"),o=r.getContext("2d");o.font="48px sans-serif";const s=Math.ceil(o.measureText(t).width)+16;r.width=s,r.height=64,o.font="48px sans-serif",o.textBaseline="middle",o.fillStyle="rgba(0,0,0,0)",o.fillRect(0,0,s,64),o.fillStyle=n,o.fillText(t,8,32);const A=new e.CanvasTexture(r);A.needsUpdate=!0,A.minFilter=e.LinearFilter;const a=new e.SpriteMaterial({map:A,transparent:!0}),l=new e.Sprite(a),c=i/20;return l.scale.set(s*c,64*c,1),l}function getline(t,i,n=null){const r=(new e.BufferGeometry).setFromPoints([new e.Vector3(t.p1.x,0,t.p1.y),new e.Vector3(t.p2.x,0,t.p2.y)]);let o=new e.Line(r,n||randombasemat());if(i){let e=getspriteid(i||"",8,"#F00");e.position.set((t.p1.x+t.p2.x)/2,0,(t.p1.y+t.p2.y)/2),o.add(e)}return o}function getpoint(t,i,n=null,r=5){let o;const s=new e.SphereGeometry(r,8,8);if(o=new e.Mesh(s,n||randombasemat()),i){let e=getspriteid(i||"",r);e.position.set(1.2*r,0,1.2*r),o.add(e)}return o.position.set(t.x,0,t.y),o}async function smat(t,i,n={}){n||(n={});let r=hash(i+JSON.stringify(n));return t.smats[r]||(t.smats[r]=await async function smat0(t,i,n={}){let r=i,o="",s=!1;i.startsWith("#")&&(s=!0,/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})(?=$|[[(])/.test(i)||(i=i.slice(1)));let A=i;const a=i.match(/^(.*)\[([^\]]+)\]$/);a&&(A=a[1],o=a[2]);const l={};o&&o.split(/[,;]/).forEach((e=>{let[t,i]=e.split("=").map((e=>e.trim()));void 0!==i&&(["e"].includes(t)?l[t]=i.startsWith("0x")?parseInt(i):parseFloat(i):isNaN(parseFloat(i))?l[t]=i:l[t]=parseFloat(i))}));const c={s:["sx","sy"],sx:["sx"],sy:["sy"],rot:["rot"],br:["brightness"],r:["roughness"],m:["metalness"],h:["bumpScale"],n:["normalScale"],d:["bumpScale"],b:["bumpScale"],e:["emissiveIntensity"],ec:["emissive"],env:["envMapIntensity"],o:["opacity"],t:["transparent"],at:["alphaTest"]};let p=n.rot,h=parseFloat(n.s)||1;delete n.s;let g={...n};for(let e in l)if(c[e])for(let t of c[e])g[t]=l[e];let u=!!g?.transparent,d=(g.sx??g.s??l.sx??l.s??1)*h,f=(g.sy??g.s??l.sy??l.s??1)*h,I=Number((l.rot??0)+(p??0))*Ue;try{let n={roughness:g.roughness??.5,metalness:g.metalness??0,side:e.DoubleSide,envMapIntensity:g.env??.6};if(void 0!==g.normalScale){let t=Number(g.normalScale);isNaN(t)||0===t||(n.normalScale=new e.Vector2(t,t))}let r=!1,o=!1;if(i.includes("(")||s){let{base:i,files:a,transparent:l}=function getFilesToLoad(e,t){let i=[],n=t.match(/^([^(]+)\((([a-zA-Z0-9_\-/]+)_([a-z]+)|([a-z]+))\)$/);if(!n)return{base:t,files:i};let r=n[1],o=!1,s=n[3]||r,A=n[4]||n[5]||"";e||i.push({suff:"",file:`${r}.webp`,cs:!0});for(let e of A)"t"==e?(o=!0,n[3]&&ct[e]&&i.push({suff:e,file:`${s}_${e}.webp`,cs:!1})):ct[e]&&i.push({suff:e,file:`${s}_${e}.webp`,cs:!!["","n","e"].includes(e)});return{base:r,files:i,transparent:o}}(s,A);if(u=l,a.some((e=>"n"===e.suff))&&(a=a.filter((e=>"h"!==e.suff))),0===g.roughness&&(a=a.filter((e=>"r"!==e.suff))),0===g.metalness&&(a=a.filter((e=>"m"!==e.suff))),0===g.emissiveIntensity&&(a=a.filter((e=>"e"!==e.suff))),a&&a.length){let i=await Promise.all(a.map((e=>t.tex(e.file,d,f,I).catch((()=>null)))));for(let t=0;t<a.length;t++){let s=i[t];if(!s)continue;s&&s.isTexture&&(s.colorSpace=a[t].cs?e.SRGBColorSpace:e.LinearSRGBColorSpace);let A=a[t].suff,{prop:l,extra:c}=ct[A];n[l]=s,"normalMap"===c?(r=!0,n.normalMap=s,n.normalScale=n.normalScale??new e.Vector2(1,1)):"bumpScale"===c?(o=!0,n.bumpMap=s):Array.isArray(c)&&c.includes("emissive")&&void 0!==g.emissiveIntensity&&0!==g.emissiveIntensity&&(n.emissive=g.emissive||16777215,n.emissiveIntensity=g.emissiveIntensity??1)}}s&&(n.color=new e.Color(i))}else if(A.includes(".")){let e=await t.tex(A,d,f,I);if(!e)return it;n.map=e}if(r&&o?delete n.bumpMap:o&&(n.bumpScale=g.bumpScale??.03),n.transparent=!!u,n.transparent&&(n.depthWrite=!1,n.opacity=g?.opacity??1),void 0!==g.brightness){let t=Number(g.brightness);!isNaN(t)&&t>0&&1!==t&&(n.color||(n.color=new e.Color(1,1,1)),n.color.multiplyScalar(t))}return new e.MeshStandardMaterial(n)}catch(e){return console.log("errore mat:",e.message,r),it}}(t,i,n)),t.smats[r]}const ct={"":{prop:"map",extra:null},n:{prop:"normalMap",extra:null},a:{prop:"aoMap",extra:"aoMapIntensity"},r:{prop:"roughnessMap",extra:null},h:{prop:"bumpMap",extra:"bumpScale"},t:{prop:"alphaMap",extra:null},m:{prop:"metalnessMap",extra:null},e:{prop:"emissiveMap",extra:["emissive","emissiveIntensity"]}};async function extractTextures(e,t){const i={},n=[];function getName(e){i[e]=(i[e]||0)+1;let n=t;return e&&(n+=`_${e}`),i[e]>1&&(n+=i[e]),`${n}.webp`}return e.traverse((e=>{if(e.material){const t=Array.isArray(e.material)?e.material:[e.material];for(const e of t)for(const[t,{prop:i}]of Object.entries(ct)){const r=e[i];if(r&&r.image&&!r._extracted){r._extracted=!0;let e,i=r.image;if(i.toBlob)e=new Promise((e=>i.toBlob(e,"image/webp")));else if(i instanceof ImageBitmap){const t=document.createElement("canvas");t.width=i.width,t.height=i.height;t.getContext("2d").drawImage(i,0,0),e=new Promise((e=>t.toBlob(e,"image/webp")))}else{if(!(i instanceof HTMLImageElement))continue;{const t=document.createElement("canvas");t.width=i.naturalWidth||i.width,t.height=i.naturalHeight||i.height;t.getContext("2d").drawImage(i,0,0),e=new Promise((e=>t.toBlob(e,"image/webp")))}}n.push(e.then((e=>new File([e],getName(t),{type:"image/webp"}))))}}}})),e.traverse((e=>{if(e.material){const t=Array.isArray(e.material)?e.material:[e.material];for(const e of t)for(const{prop:t}of Object.values(ct)){const i=e[t];i&&i._extracted&&delete i._extracted}}})),Promise.all(n)}function uvswap(e){if(e&&e.attributes){const t=e.attributes.uv;if(t){const e=t.array;for(let t=0,i=e.length;t<i;t+=2){const i=e[t];e[t]=e[t+1],e[t+1]=i}t.needsUpdate=!0}const i=e.attributes.uv2;if(i){const e=i.array;for(let t=0,i=e.length;t<i;t+=2){const i=e[t];e[t]=e[t+1],e[t+1]=i}i.needsUpdate=!0}}}function getfakeshadow2(t,i,n){const r=(new e.Shape).moveTo(0,0).lineTo(t,0).lineTo(t,i).lineTo(0,i).lineTo(0,0),o=new e.ShapeGeometry(r),s=o.attributes.position,A=new Float32Array(2*s.count);for(let e=0;e<s.count;e++)A[2*e]=s.getX(e)/t,A[2*e+1]=s.getY(e)/i;o.setAttribute("uv",new e.BufferAttribute(A,2));const a=new e.MeshBasicMaterial({map:n,transparent:!0,alphaTest:.01,depthWrite:!1,side:e.DoubleSide}),l=new e.Mesh(o,a);return l.layers.set(9),l.rotation.x=Math.PI/2,l}function getfakeshadow(t,i,n){let r=`fk${i.key}${n}`,{p1:o,width:s,height:A}=i.dims();t.texture||(t.texture={});let a=t.texture[r];a||(a=function createBlurredShadowTextureFromPoints(t,i=256,n=32,r=.2,o,s,A){if(!s||!A||!t.pt||t.pt.length<2)return;const a=o.x,l=o.y,c=s,p=A,h=t.pt,g=2*n,u=document.createElement("canvas");u.width=i+2*g,u.height=i+2*g;const d=u.getContext("2d");d.save(),d.translate(g,g),d.scale(i/c,i/p),d.translate(-a,-l),d.filter=`blur(${n}px)`,d.beginPath(),d.moveTo(h[0].x,h[0].y);for(let e=1;e<h.length;e++)d.lineTo(h[e].x,h[e].y);d.closePath(),d.fillStyle=`rgba(0,0,0,${r})`,d.fill(),d.restore();const f=new e.CanvasTexture(u);return f.needsUpdate=!0,f}(i,256,32,n,o,s,A),t.texture[r]=a);const l=function pointsToShape(t){const i=new e.Shape;i.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)i.lineTo(t[e].x,t[e].y);return i}(i.pt),c=new e.ShapeGeometry(l);!function applyUVtoShapeGeometry(t,i,n,r,o){const s=t.attributes.position,A=[];for(let e=0;e<s.count;e++){const t=s.getX(e),a=s.getY(e);A.push((t-i)/r,(a-n)/o)}t.setAttribute("uv",new e.Float32BufferAttribute(A,2))}(c,o.x,o.y,s,A);const p=new e.MeshBasicMaterial({map:a,transparent:!0,depthWrite:!1,side:e.DoubleSide});let h=new e.Mesh(c,p);return h.layers.set(9),h.rotation.x=Math.PI/2,h}function addmovpivot(t,i,n,r={},o=0,s=0,A=0){if(n=clean(n,!0),!t.movs[n])return i;t.movs[n];const a=new e.Vector3(o,s,A),l=0===a.lengthSq(),c=new e.Group;c.name=`pivot_${n}`;const p=new e.Group;if(p.name=`mov_${n}`,l)c.position.copy(i.position),c.quaternion.copy(i.quaternion),i.position.set(0,0,0),i.rotation.set(0,0,0);else{const t=a.clone().applyMatrix4(i.matrixWorld);c.position.copy(t);const n=a.clone().negate();i.position.add(n),c.quaternion.copy(i.getWorldQuaternion(new e.Quaternion)),i.rotation.set(0,0,0)}return p.add(i),c.add(p),r||(r={}),r.inmov=!1,r.key=n,r.dt=0,r.dtstart=!1,p.userData.mov={...r},c}function getmovimento(e,t=[]){let i=0,n=[];const _cleartimeline=()=>{n=[],i=0},_add=(e,t={})=>{e&&n.push({...t,time:e}),i=n.reduce(((e,t)=>e+(t.time||0)),0)};_cleartimeline(),t&&t.length&&t.forEach((e=>_add(e.time,e)));const _resetmov=e=>{const{mov:t}=e?.userData||{};t&&(t.inmov=!1,e.position.set(0,0,0),e.scale.set(1,1,1),e.rotation.set(0,0,0))};return{get tline(){return i},clear:_cleartimeline,add:_add,key:e,step:(e,t)=>{if(!e||!e.userData?.mov||!i)return;const{mov:r}=e.userData;if(!r.inmov)return;let o=r.dt-r.dtstart;if(r.ripeti)o%=i;else if(o>i)return void _resetmov(e);let s=0,A=0,a=0,l=0,c=0,p=0,h=1,g=1,u=1,d=null,f=0;for(let e of n){if(f+=e.time,o<f){const t=e.time>0?(o-(f-e.time))/e.time:1,_calc=(e,i=0)=>"function"==typeof e?e(r)*t:(e||i)*t;s+=_calc(e.x),A+=_calc(e.y),a+=_calc(e.z),h*=1+_calc(e.sx??e.s,0),g*=1+_calc(e.sy??e.s,0),u*=1+_calc(e.sz??e.s,0),l+=_calc(e.ax)*Ue,c+=_calc(e.ay)*Ue,p+=_calc(e.az)*Ue,void 0!==e.t&&(d="function"==typeof e.t?e.t(r)*t:e.t*t);break}{const _calc=(e,t=0)=>"function"==typeof e?e(r):e||t;s+=_calc(e.x),A+=_calc(e.y),a+=_calc(e.z),h*=1+_calc(e.sx??e.s,0),g*=1+_calc(e.sy??e.s,0),u*=1+_calc(e.sz??e.s,0),l+=_calc(e.ax)*Ue,c+=_calc(e.ay)*Ue,p+=_calc(e.az)*Ue,void 0!==e.t&&(d="function"==typeof e.t?e.t(r):e.t)}}e.position.set(s,A,a),e.scale.set(h,g,u),e.rotation.set(l,c,p),null!==d&&e.traverse((e=>{if(e.material){(Array.isArray(e.material)?e.material:[e.material]).forEach((e=>{e.transparent&&(e.opacity=1-d)}))}})),t&&t(e,o)},reset:_resetmov}}let pt=null,ht=null;function getriferimento(t,i=0,n=0,r=0,o="rif"){"string"==typeof t&&(t={testo:t});let s=new e.Object3D;return s.position.set(i,n,r),o&&(s.name=o),s.userData={tipo:"rif",...t},s}function gettarghetta(t,i,n=100,r={}){const{noSfondo:o=!1,forcey:s=!1,coloreSfondo:A="white",coloreBordo:a="gray",spessoreBordo:l=2,padding:c=8,layer:p=21,size:h=24,fontFamily:g="Arial",raggioAngoli:u=10,order:d=0}=r;i=(i||"").replaceAll("\\n","\n");let f=hash(`T:${A}|${a}|${g}|${c}|${l}|${u}|${o}|${i}`);const I=h??24;i=i.split("\n").map((e=>{let t=I,i=!1,n=!1,r="black";e=e.trim();let o=/^\s*#(\w)([bi]?)([\d.]*)[,;](.*)$/.exec(e);if(o)switch(t=parseFloat(o[3]||1)*I,"b"===o[2]&&(i=!0),"i"===o[2]&&(n=!0),e=o[4],o[1].toLowerCase()){case"r":r="red";break;case"g":r="green";break;case"b":r="blue";break;case"w":r="white";break;case"c":r="cyan"}return{testo:e,size:t,color:r,bold:i,italic:n}})).filter((e=>e.testo));const{canvas:m,context:b}=function getGlobalCanvas(){return pt||(pt=document.createElement("canvas"),ht=pt.getContext("2d",{willReadFrequently:!0})),{canvas:pt,context:ht}}();let C=0,B=2*c;i.forEach(((e,t)=>{const{testo:n,size:r=12}=e,o=2*r;b.font=`${o}px ${g}`;const s=b.measureText(n).width,A=o*(t==i.length-1?1:1.2);C=Math.max(C,s),B+=A})),C+=2*c;const y=B/C||1;let E,x;if(s?(x=n,E=Math.ceil(x/y)):(E=n,x=Math.ceil(E*y)),!t.textures[f]){const n=Math.floor(C+2*l),r=Math.floor(B+2*l);(m.width<n||m.height<r)&&(m.width=Math.max(m.width,n),m.height=Math.max(m.height,r)),b.clearRect(0,0,n,r);const s=new e.Color(A),p=`rgb(${Math.floor(255*s.r)}, ${Math.floor(255*s.g)}, ${Math.floor(255*s.b)})`,h=new e.Color(a),d=`rgb(${Math.floor(255*h.r)}, ${Math.floor(255*h.g)}, ${Math.floor(255*h.b)})`,I=u;b.beginPath(),o||(drawRoundedRect(b,0,0,n,r,I+l/2),b.fillStyle=d,b.fill(),b.beginPath(),drawRoundedRect(b,l,l,n-2*l,r-2*l,I-l/2),b.fillStyle=p,b.fill());let y=c+l;i.forEach((e=>{const{testo:t,size:i=12,color:r="black",bold:o,italic:s}=e,A=2*i;b.font=`${o?"bold ":s?"italic ":""}${A}px ${g}`,b.fillStyle=r,b.textAlign="center",b.textBaseline="top",b.fillText(t,n/2,y),y+=1.2*A}));const E=b.getImageData(0,0,n,r),x=new e.DataTexture(E.data,E.width,E.height,e.RGBAFormat);x.needsUpdate=!0,x.flipY=!0,x.minFilter=e.LinearFilter,x.magFilter=e.LinearFilter,t.textures[f]=x}const P=new e.MeshBasicMaterial({map:t.textures[f],transparent:!0,alphaTest:.5,side:$e}),w=new e.PlaneGeometry(E,x),v=new e.Mesh(w,P);return v.layers.set(p),v.renderOrder=d,v.userData={dimx:E,dimy:x},v}function drawRoundedRect(e,t,i,n,r,o){o=Math.min(o,Math.min(n/2,r/2)),e.moveTo(t+o,i),e.lineTo(t+n-o,i),e.quadraticCurveTo(t+n,i,t+n,i+o),e.lineTo(t+n,i+r-o),e.quadraticCurveTo(t+n,i+r,t+n-o,i+r),e.lineTo(t+o,i+r),e.quadraticCurveTo(t,i+r,t,i+r-o),e.lineTo(t,i+o),e.quadraticCurveTo(t,i,t+o,i),e.closePath()}function getquota(t,i,n,r,o,s,A={}){const{altezza:a=30,offset:l=0,piano:c="xy",layer:p=22,delta:h=5,spessoreLinea:g=3}=A,pp=(e,t)=>"xz"===c?[e,0,t]:"yz"===c?[0,e,t]:[e,t,0],u=new e.Group;u.name="quota";const d=o-n,f=s-r,I=Math.sqrt(d*d+f*f),m=Math.atan2(f,d);i||(i="$$"),i.includes("$$")&&(i=i.replace("$$",`${I.toFixed(1)}`));let b=i.split("\n").length;const C=-Math.sin(m)*l,B=Math.cos(m)*l,y=gettarghetta(t,i,2*a*b,{noSfondo:!0,layer:p,forcey:!0}),{dimx:E,dimy:x}=y.userData;function getCilindro(i,n,r){const o=(new e.Vector3).subVectors(n,i),s=o.length();let A,a=hash(`c:${r}|${s}`);t.geo[a]?A=t.geo[a]:(A=new e.CylinderGeometry(r/2,r/2,s,3,1,!0),t.geo[a]=A);const l=new e.Mesh(A,at);l.position.copy(i).add(o.multiplyScalar(.5));const c=(new e.Vector3).copy(n);return l.lookAt(c),l.rotateX(Math.PI/2),l}if(E>I-h){y.position.set(I/2,a,0);const t=getCilindro(new e.Vector3(...pp(0,0)),new e.Vector3(...pp(I,0)),g);u.add(t)}else{const t=E+h,i=(I-t)/2,n=i+t,r=getCilindro(new e.Vector3(...pp(0,0)),new e.Vector3(...pp(i,0)),g);u.add(r);const o=getCilindro(new e.Vector3(...pp(n,0)),new e.Vector3(...pp(I,0)),g);u.add(o),y.position.set(...pp(I/2,0))}const P=l>a/2?-l:-a/2,w=-l>a/2?-l:a/2,v=new e.Vector3(...pp(0,P)),D=new e.Vector3(...pp(0,w)),S=new e.Vector3(...pp(I,P)),L=new e.Vector3(...pp(I,w)),M=getCilindro(v,D,g);u.add(M);const T=getCilindro(S,L,g);return u.add(T),y.userData.updateOrientation=function(e){e&&this.quaternion.copy(e.quaternion)},u.add(y),"xy"===c?(u.position.set(n+C,r+B,0),u.rotation.z=m):"xz"===c?(u.position.set(n+C,0,r+B),u.rotation.y=-m):"yz"===c&&(u.position.set(0,n+C,r+B),u.rotation.x=m),u.traverse((function(e){e.layers.set(p)})),u}function fillNoise(t,i,n={}){let{scale:r=8,octaves:o=3,persistence:s=.5,seed:A=0,contrast:a=1,color1:l="#000000",color2:c="#ffffff",alpha1:p=1,alpha2:h=1}=n;const g=new e.Color(l),u=new e.Color(c),fade=e=>e*e*e*(e*(6*e-15)+10),lerp=(e,t,i)=>e+(t-e)*i,d=i,f=new Uint16Array(2*d);let I=0|Math.floor(65536*A);for(let e=0;e<d;e++)f[e]=e;for(let e=0;e<d;e++){const t=Math.floor((I^=I<<13,I^=I>>17,I^=I<<5,(I<0?1+~I:I)%65536/65536*d));[f[e],f[t]]=[f[t],f[e]]}for(let e=0;e<d;e++)f[d+e]=f[e];const m=[[1,1],[-1,1],[1,-1],[-1,-1],[1,0],[-1,0],[0,1],[0,-1]];function grad(e,t){const i=f[(f[e%d]+t)%d]%8;return m[i]}function perlin(e,t,i,n){const r=Math.floor(e)%i,o=Math.floor(t)%n,s=e-Math.floor(e),A=t-Math.floor(t),a=grad(r,o),l=grad(r+1,o),c=grad(r,o+1),p=grad(r+1,o+1),h=a[0]*s+a[1]*A,g=l[0]*(s-1)+l[1]*A,u=c[0]*s+c[1]*(A-1),d=p[0]*(s-1)+p[1]*(A-1),f=fade(s),I=fade(A);return lerp(lerp(h,g,f),lerp(u,d,f),I)}let b=1/0,C=-1/0;const B=new Float32Array(i*i);for(let e=0;e<i;e++)for(let t=0;t<i;t++){let n=t/i*r,A=e/i*r,a=1,l=1,c=0,p=0;for(let e=0;e<o;e++){c+=perlin(n*l,A*l,d/l,d/l)*a,p+=a,a*=s,l*=2}let h=c/p;B[e*i+t]=h,h<b&&(b=h),h>C&&(C=h)}const y=1/(C-b);for(let e=0;e<i;e++)for(let n=0;n<i;n++){let r=(B[e*i+n]-b)*y;r=Math.pow(r,a);const o=g.r+(u.r-g.r)*r,s=g.g+(u.g-g.g)*r,A=g.b+(u.b-g.b)*r,l=0,c=4*(e*i+n);t[c]=Math.floor(255*o),t[c+1]=Math.floor(255*s),t[c+2]=Math.floor(255*A),t[c+3]=Math.floor(255*l)}}function texgen(t,i,n=256,r={}){[16,32,64,128,256,512,1024].includes(n)||(n=256);let o=hash(`gen|${i}|${n}|${JSON.stringify(r)}`);if(!t[o]){const s=new Uint8Array(n*n*4);switch(i){case"wood":let e={...r};e.scale=6+seeder(40,r.seed+"a")/10,e.octaves=r.octaves||3,e.persistence=.5+seeder(50,r.seed+"b")/100,e.rings=2+seeder(200,r.seed+"c")/100,e.distortion=.3+seeder(100,r.seed+"d")/300,e.color1=r.color1||"#442200",e.color2=r.color2||"#ffe0a0",fillNoise(s,n,e);break;case"marble":let t={...r};t.scale=r.scale||10,t.octaves=r.octaves||3,t.persistence=r.persistence||.6,t.rings=r.rings||1+seeder(100,r.seed+"m3")/50,t.distortion=r.distortion||.8+seeder(200,r.seed+"m4")/200,t.contrast=r.contrast||1.2,t.color1=r.color1||"#e0e0e0",t.color2=r.color2||"#909090",fillNoise(s,n,t);break;case"glass":let i={...r};i.scale=r.scale||32,i.octaves=r.octaves||2,i.persistence=r.persistence||.8,i.contrast=r.contrast||1,i.color1=r.color1||"rgba(255,255,255,0.2)",i.color2=r.color2||"rgba(255,255,255,0.6)",fillNoise(s,n,i);break;case"gradient":case"pattern":break;default:fillNoise(s,n,r)}const A=new e.DataTexture(s,n,n,e.RGBAFormat);A.needsUpdate=!0,A.wrapS=A.wrapT=e.RepeatWrapping,A.repeat.set(.002,.002),A.center.set(.5,.5),t[o]=A}return t[o]}function getcilindro(t,i,n,r,o,s=it,A){A||(A={}),Array.isArray(s)||(s=[s]);const a=function cylgeometry(t,i,n,r,o=16){if(!n||!i)return null;let s=hash(`cy${i}|${n}|${r||n}|${o}`);if(!t.geo[s]){const A=new e.CylinderGeometry(r||n,n,i,o);t.geo[s]=A}return t.geo[s]}(t,n,r,o,A.sides||16);let l=new e.Group;switch((i||"").trim().toUpperCase()){case"X":case"L":l.position.set(n/2,0,0),l.rotation.z=Math.PI/2;break;case"Z":case"P":l.position.set(0,0,n/2),l.rotation.x=Math.PI/2;break;default:l.position.set(0,n/2,0)}if(a){if(!A.nolines){let e=edgesfromgeometry(a);l.add(e)}A.uvswap&&uvswap(a);const e=s[0]||it,t=s[1]||e,i=s[2]||e;l.add(getmesh(a,[e,t,i]))}return l}function scalauv(e){const t=e.attributes.uv;if(t){const e=t.array;for(let t=0;t<e.length;t++)e[t]*=1e3;t.needsUpdate=!0}}function getface(t,i,n,r,o={}){let{repeat:s,order:A,center:a=!1}=o;const l=hash(`f:${i}|${n}|${s?1:0}`);if(!t.geo[l]){const r=new e.PlaneGeometry(i,n),o=r.attributes.uv;if(s)for(let e=0;e<o.count;e++)o.setXY(e,o.getX(e)*i,o.getY(e)*n);else{const e=[[0,1e3],[1e3,1e3],[0,0],[1e3,0]];for(let t=0;t<o.count;t++){const i=e[t];o.setXY(t,i[0],i[1])}}o.needsUpdate=!0,t.geo[l]=r}const c=new e.Mesh(t.geo[l],r);return"number"==typeof A&&(c.renderOrder=A),a||c.position.set(i/2,n/2,0),r?.transparent&&c.layers.set(2),c}function getbox(t,i,n,r,o,s){o&&o.isMaterial||(s=o,o=void 0),s||(s={});let{center:A=!1,nolines:a,centerbase:l=!1,px:c=0,py:p=0,pz:h=0}=s;const g=new e.BoxGeometry(i,n,r);scalauv(g);const u=new e.Group;if(l?u.position.set(0,n/2,0):c||p||h?u.position.set(c||0,p||0,h||0):A||u.position.set(i/2,n/2,r/2),!a||!o){let e=edgesfromgeometry(g);u.add(e)}return o&&u.add(getmesh(g,o)),u}function getcyl(t,i,n,r,o){o||(o={});let{center:s=!1,nolines:A=!1,segments:a=16,top:l=-1,bottom:c=-1,heightSegments:p=1,openEnded:h=!1,thetaStart:g=0,thetaLength:u=2*Math.PI}=o;l<0&&(l=n),c<0&&(c=n);const d=new e.CylinderGeometry(l,c,i,a,p,h,g,u);scalauv(d),o.uvswap&&uvswap(d);const f=getmesh(d,r||it),I=new e.Group;if(I.add(f),I.position.set(0,s?0:i/2,0),!A){let e=edgesfromgeometry(d);I.add(e)}return I}function getsphere(t,i,n,r){r||(r={});let{nolines:o,segmenti:s=16}=r,A=new e.Group;const a=new e.SphereGeometry(i,2*s,s);if(scalauv(a),!o){let e=edgesfromgeometry(a);A.add(e)}return A.add(getmesh(a,n||it)),A}function makeShape(t){const i=new e.Shape;i.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)i.lineTo(t[e].x,t[e].y);return i.closePath(),i}function extrudelines(t,i,n,r,o=3){const addring=i=>{const n=((t,i)=>{if(!t||t.length<2)return null;const n=t.length,r=new Float32Array(3*(n+1));for(let e=0;e<=n;e++){const o=t[e%n],s=3*e;r[s]=o.x,r[s+1]=o.y,r[s+2]=i}const o=new e.BufferGeometry;return o.setAttribute("position",new e.BufferAttribute(r,3)),new e.Line(o,et)})(i,-o);n&&(n.layers.set(30),t.add(n))};addring(i);for(const e of n)addring(e)}function getextrude(t,i,n=10,r=[],o=void 0,s={}){o&&o.isMaterial||(s=o,o=void 0),s=s??{};let{stonda:A,sx:a,sy:l,round:c,nolines:p}=s,h=hash(`${JSON.stringify(i)}|${n}|${JSON.stringify(s)}|${JSON.stringify(r)}`);a=a??A??0,l=l??A??0;let g=t.geo[h];if(!g){const o=makeShape(i);r.forEach((t=>o.holes.push(function makePath(t){const i=new e.Path;i.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)i.lineTo(t[e].x,t[e].y);return i.closePath(),i}(t))));const A=a>0&&l>0;g=new e.ExtrudeGeometry(o,{depth:n,bevelEnabled:A,bevelSize:a,bevelThickness:l,bevelSegments:A?c?3:1:0,curveSegments:A?10:1}),t.geo[h]=g,s.uvswap&&uvswap(g)}let u=new e.Group;return u.add(new e.Mesh(g,o||it)),p||extrudelines(u,i,r,0,l),u}function getthorus(t,i,n=.2,r,o){o||(o={});let{center:s,nolines:A,segmenti:a=16,tubi:l=12}=o,c=new e.Group;const p=new e.TorusGeometry(i,n,l,2*a);if(scalauv(p),c.position.set(0,s?0:i,0),!A){let e=edgesfromgeometry(p);c.add(e)}return c.add(getmesh(p,r||it)),c}function getluce(t,i,n="#ffffff",r=1){const o=i.pt;if(!o||!o.length)return null;const s=hash(`${i.key}|${n}|${r}`);if(!t.meshes[s]){const i=makeShape(o),A=new e.ShapeGeometry(i),a=new e.MeshStandardMaterial({color:new e.Color(n),emissive:new e.Color(n),emissiveIntensity:r,toneMapped:!1,transparent:!0,depthWrite:!1,side:e.DoubleSide,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:1}),l=new e.Mesh(A,a);l.layers.set(8),l.userData.isBloom=!0,t.meshes[s]=l,t.mustlight=!0}return t.meshes[s]}function getmarker(e,t,i,n,r,o,s={}){if(t&&i){s||(s={});let{markscale:A=.6}=s;s.markerid=t,s.marker=i;let a=getface(e,n*A,r*A,o,{order:1}),l=t;l.length>7&&(l=".."+l.slice(-6));let c=gettarghetta(e,`#w,${l}`,50,{noSfondo:!0,layer:11,forcey:!0});return a.add(posiziona(c,{sp:11,order:2})),s.center||(a=posiziona(a,{sl:n*(1-A)/2,sa:r*(1-A)/2})),posiziona(a,s)}}function toTrianglesDrawMode(e,r){if(r===t)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(r===i||r===n){let t=e.getIndex();if(null===t){const i=[],n=e.getAttribute("position");if(void 0===n)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<n.count;e++)i.push(e);e.setIndex(i),t=e.getIndex()}const n=t.count-2,o=[];if(r===i)for(let e=1;e<=n;e++)o.push(t.getX(0)),o.push(t.getX(e)),o.push(t.getX(e+1));else for(let e=0;e<n;e++)e%2==0?(o.push(t.getX(e)),o.push(t.getX(e+1)),o.push(t.getX(e+2))):(o.push(t.getX(e+2)),o.push(t.getX(e+1)),o.push(t.getX(e)));o.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=e.clone();return s.setIndex(o),s.clearGroups(),s}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",r),e}function pannellogeometry(t,i,n,r,o=0,s=0,A=0,a=0,l=0,c=2,p=!1){let h=hash(`pg--${i}|${n}|${r}|${o}|${s}|${A}|${a}|${l}|${c}|${p?1:0}`);if(i-=.01,n-=.01,r-=.01,!t.geo[h]){i-=2*l,n-=2*l,r-=2*l;let g=getshape();const u=[{x:a,y:0},{x:n-o,y:0},{x:n,y:o},{x:n,y:r-s},{x:n-s,y:r},{x:A,y:r},{x:0,y:r-A},{x:0,y:a}];g.addpt(u[0]),g.addpt(u[1]),o&&g.addpt(raccordabezier(u[0],u[1],u[2],u[3],c)),g.addpt(u[2]),g.addpt(u[3]),s&&g.addpt(raccordabezier(u[2],u[3],u[4],u[5],c)),g.addpt(u[4]),g.addpt(u[5]),A&&g.addpt(raccordabezier(u[4],u[5],u[6],u[7],c)),g.addpt(u[6]),g.addpt(u[7]),s&&g.addpt(raccordabezier(u[6],u[7],u[0],u[1],c)),g.removeduplicate(.01);let d=g.pt;const f=new e.Shape;f.moveTo(d[0].x,d[0].y);for(let e=1;e<d.length;e++)f.lineTo(d[e].x,d[e].y);f.lineTo(d[0].x,d[0].y);const I={depth:i,bevelEnabled:l>0,bevelThickness:l,bevelSize:l,bevelSegments:1};let m=new e.ExtrudeGeometry(f,I);m=function mergeVertices(e,t=1e-4){t=Math.max(t,Number.EPSILON);const i={},n=e.getIndex(),r=e.getAttribute("position"),o=n?n.count:r.count;let s=0;const A=Object.keys(e.attributes),a={},l={},c=[],p=["getX","getY","getZ","getW"],h=["setX","setY","setZ","setW"];for(let t=0,i=A.length;t<i;t++){const i=A[t],n=e.attributes[i];a[i]=new n.constructor(new n.array.constructor(n.count*n.itemSize),n.itemSize,n.normalized);const r=e.morphAttributes[i];r&&(l[i]||(l[i]=[]),r.forEach(((e,t)=>{const n=new e.array.constructor(e.count*e.itemSize);l[i][t]=new e.constructor(n,e.itemSize,e.normalized)})))}const g=.5*t,u=Math.log10(1/t),d=Math.pow(10,u),f=g*d;for(let t=0;t<o;t++){const r=n?n.getX(t):t;let o="";for(let t=0,i=A.length;t<i;t++){const i=A[t],n=e.getAttribute(i),s=n.itemSize;for(let e=0;e<s;e++)o+=~~(n[p[e]](r)*d+f)+","}if(o in i)c.push(i[o]);else{for(let t=0,i=A.length;t<i;t++){const i=A[t],n=e.getAttribute(i),o=e.morphAttributes[i],c=n.itemSize,g=a[i],u=l[i];for(let e=0;e<c;e++){const t=p[e],i=h[e];if(g[i](s,n[t](r)),o)for(let e=0,n=o.length;e<n;e++)u[e][i](s,o[e][t](r))}}i[o]=s,c.push(s),s++}}const I=e.clone();for(const t in e.attributes){const e=a[t];if(I.setAttribute(t,new e.constructor(e.array.slice(0,s*e.itemSize),e.itemSize,e.normalized)),t in l)for(let e=0;e<l[t].length;e++){const i=l[t][e];I.morphAttributes[t][e]=new i.constructor(i.array.slice(0,s*i.itemSize),i.itemSize,i.normalized)}}return I.setIndex(c),I}(m),m.computeVertexNormals();const b=m.attributes.uv;let C=Math.random()*i,B=Math.random()*(n+r);p&&uvswap(m);for(let e=0;e<b.count;e++)b.setXY(e,b.getY(e)+B,b.getX(e)+C);b.needsUpdate=!0,t.geo[h]=m}return t.geo[h]}function getpannello(t,i,n,r,o,s,A,a){a||(a={});let l,c,p,{r:h,r1:g,r2:u,r3:d,r4:f,b:I,npt:m}=a;g=g||h||0,u=u||h||0,d=d||h||0,f=f||h||0,m=m||2,I=I||0,(I>=n/2||I>=r/2||I>=o/2)&&(I=0),l="L"==(i=i.trim().toUpperCase())[0]?n:"A"==i[0]?r:o,c="L"==i[1]?n:"A"==i[1]?r:o,p="L"==i[2]?n:"A"==i[2]?r:o;let b=new e.Group;if(!a.nolines){let t=edgesfromgeometry(new e.BoxGeometry(n,r,o));t.position.set(n/2,r/2,o/2),b.add(t)}let C=getmesh(pannellogeometry(t,l,c,p,g,u,d,f,I,m,a.uvswap),[A||s||At,s||ot]);C.name="pannello",C.layers.set(1);let B=C;return I&&(C.position.set(I,I,I),B=new e.Group,B.add(C)),C=function meshrotate(e,t,i=0,n=0,r=0){switch(e.trim().toUpperCase()){case"LPA":t.rotation.y=Math.PI/2,t.rotation.x=Math.PI,t.position.set(0,r,0);break;case"ALP":t.rotation.x=Math.PI/2,t.position.set(0,i,0);break;case"APL":t.rotation.x=-Math.PI/2,t.rotation.z=-Math.PI/2;break;case"PLA":break;case"PAL":t.rotation.z=Math.PI/2,t.position.set(r,0,0);break;case"LAP":t.rotation.y=Math.PI/2,t.rotation.z=Math.PI/2}return t}(i,B,l,c,p),b.add(C),b}async function getpannello2(e,t,i,n,r,o,s=0){let A;switch((s<0||s>Math.max(i,n,r)/3)&&(s=0),t){case"lap":A=getextrude(e,getshape().fromrect(i-2*s,n-2*s).pt,r-2*s,[],o,{round:s,stonda:s}),A.position.x=s,A.position.z=r-s,A.position.y=n-s,A.rotation.x=Math.PI;break;case"alp":A=getextrude(e,getshape().fromrect(n-2*s,i-2*s).pt,r-2*s,[],o,{round:s,stonda:s}),A.position.x=s,A.position.z=s,A.position.y=n-s,A.rotation.z=-Math.PI/2;break;case"apl":A=getextrude(e,getshape().fromrect(n-2*s,r-2*s).pt,i-2*s,[],o,{round:s,stonda:s}),A.position.x=s,A.position.z=s,A.position.y=s,A.rotation.y=Math.PI/2,A.rotation.z=Math.PI/2;break;case"pal":A=getextrude(e,getshape().fromrect(r-2*s,n-2*s).pt,i-2*s,[],o,{round:s,stonda:s}),A.position.x=s,A.position.z=r-s,A.position.y=s,A.rotation.y=Math.PI/2;break;case"pla":A=getextrude(e,getshape().fromrect(r-2*s,i-2*s).pt,n-2*s,[],o,{round:s,stonda:s}),A.rotation.z=-Math.PI/2,A.rotation.x=-Math.PI/2,A.position.x=s,A.position.z=s,A.position.y=s;break;default:A=getextrude(e,getshape().fromrect(i-2*s,r-2*s).pt,n-2*s,[],o,{round:s,stonda:s}),A.position.x=s,A.position.z=s,A.rotation.x=Math.PI/2,A.position.y=n-s}return A}function earcut(e,t,i=2){const n=t&&t.length,r=n?t[0]*i:e.length;let o=linkedList(e,0,r,i,!0);const s=[];if(!o||o.next===o.prev)return s;let A,a,l;if(n&&(o=function eliminateHoles(e,t,i,n){const r=[];for(let i=0,o=t.length;i<o;i++){const s=linkedList(e,t[i]*n,i<o-1?t[i+1]*n:e.length,n,!1);s===s.next&&(s.steiner=!0),r.push(getLeftmost(s))}r.sort(compareXYSlope);for(let e=0;e<r.length;e++)i=eliminateHole(r[e],i);return i}(e,t,o,i)),e.length>80*i){A=1/0,a=1/0;let t=-1/0,n=-1/0;for(let o=i;o<r;o+=i){const i=e[o],r=e[o+1];i<A&&(A=i),r<a&&(a=r),i>t&&(t=i),r>n&&(n=r)}l=Math.max(t-A,n-a),l=0!==l?32767/l:0}return earcutLinked(o,s,i,A,a,l,0),s}function linkedList(e,t,i,n,r){let o;if(r===function signedArea(e,t,i,n){let r=0;for(let o=t,s=i-n;o<i;o+=n)r+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return r}(e,t,i,n)>0)for(let r=t;r<i;r+=n)o=insertNode(r/n|0,e[r],e[r+1],o);else for(let r=i-n;r>=t;r-=n)o=insertNode(r/n|0,e[r],e[r+1],o);return o&&equals(o,o.next)&&(removeNode(o),o=o.next),o}function filterPoints(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!equals(n,n.next)&&0!==area(n.prev,n,n.next))n=n.next;else{if(removeNode(n),n=t=n.prev,n===n.next)break;i=!0}}while(i||n!==t);return t}function earcutLinked(e,t,i,n,r,o,s){if(!e)return;!s&&o&&function indexCurve(e,t,i,n){let r=e;do{0===r.z&&(r.z=zOrder(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function sortLinked(e){let t,i=1;do{let n,r=e;e=null;let o=null;for(t=0;r;){t++;let s=r,A=0;for(let e=0;e<i&&(A++,s=s.nextZ,s);e++);let a=i;for(;A>0||a>0&&s;)0!==A&&(0===a||!s||r.z<=s.z)?(n=r,r=r.nextZ,A--):(n=s,s=s.nextZ,a--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;r=s}o.nextZ=null,i*=2}while(t>1);return e}(r)}(e,n,r,o);let A=e;for(;e.prev!==e.next;){const a=e.prev,l=e.next;if(o?isEarHashed(e,n,r,o):isEar(e))t.push(a.i,e.i,l.i),removeNode(e),e=l.next,A=l.next;else if((e=l)===A){s?1===s?earcutLinked(e=cureLocalIntersections(filterPoints(e),t),t,i,n,r,o,2):2===s&&splitEarcut(e,t,i,n,r,o):earcutLinked(filterPoints(e),t,i,n,r,o,1);break}}}function isEar(e){const t=e.prev,i=e,n=e.next;if(area(t,i,n)>=0)return!1;const r=t.x,o=i.x,s=n.x,A=t.y,a=i.y,l=n.y,c=Math.min(r,o,s),p=Math.min(A,a,l),h=Math.max(r,o,s),g=Math.max(A,a,l);let u=n.next;for(;u!==t;){if(u.x>=c&&u.x<=h&&u.y>=p&&u.y<=g&&pointInTriangleExceptFirst(r,A,o,a,s,l,u.x,u.y)&&area(u.prev,u,u.next)>=0)return!1;u=u.next}return!0}function isEarHashed(e,t,i,n){const r=e.prev,o=e,s=e.next;if(area(r,o,s)>=0)return!1;const A=r.x,a=o.x,l=s.x,c=r.y,p=o.y,h=s.y,g=Math.min(A,a,l),u=Math.min(c,p,h),d=Math.max(A,a,l),f=Math.max(c,p,h),I=zOrder(g,u,t,i,n),m=zOrder(d,f,t,i,n);let b=e.prevZ,C=e.nextZ;for(;b&&b.z>=I&&C&&C.z<=m;){if(b.x>=g&&b.x<=d&&b.y>=u&&b.y<=f&&b!==r&&b!==s&&pointInTriangleExceptFirst(A,c,a,p,l,h,b.x,b.y)&&area(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,C.x>=g&&C.x<=d&&C.y>=u&&C.y<=f&&C!==r&&C!==s&&pointInTriangleExceptFirst(A,c,a,p,l,h,C.x,C.y)&&area(C.prev,C,C.next)>=0)return!1;C=C.nextZ}for(;b&&b.z>=I;){if(b.x>=g&&b.x<=d&&b.y>=u&&b.y<=f&&b!==r&&b!==s&&pointInTriangleExceptFirst(A,c,a,p,l,h,b.x,b.y)&&area(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;C&&C.z<=m;){if(C.x>=g&&C.x<=d&&C.y>=u&&C.y<=f&&C!==r&&C!==s&&pointInTriangleExceptFirst(A,c,a,p,l,h,C.x,C.y)&&area(C.prev,C,C.next)>=0)return!1;C=C.nextZ}return!0}function cureLocalIntersections(e,t){let i=e;do{const n=i.prev,r=i.next.next;!equals(n,r)&&intersects(n,i,i.next,r)&&locallyInside(n,r)&&locallyInside(r,n)&&(t.push(n.i,i.i,r.i),removeNode(i),removeNode(i.next),i=e=r),i=i.next}while(i!==e);return filterPoints(i)}function splitEarcut(e,t,i,n,r,o){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&isValidDiagonal(s,e)){let A=splitPolygon(s,e);return s=filterPoints(s,s.next),A=filterPoints(A,A.next),earcutLinked(s,t,i,n,r,o,0),void earcutLinked(A,t,i,n,r,o,0)}e=e.next}s=s.next}while(s!==e)}function compareXYSlope(e,t){let i=e.x-t.x;if(0===i&&(i=e.y-t.y,0===i)){i=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}return i}function eliminateHole(e,t){const i=function findHoleBridge(e,t){let i=t;const n=e.x,r=e.y;let o,s=-1/0;if(equals(e,i))return i;do{if(equals(e,i.next))return i.next;if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const e=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=n&&e>s&&(s=e,o=i.x<i.next.x?i:i.next,e===n))return o}i=i.next}while(i!==t);if(!o)return null;const A=o,a=o.x,l=o.y;let c=1/0;i=o;do{if(n>=i.x&&i.x>=a&&n!==i.x&&pointInTriangle(r<l?n:s,r,a,l,r<l?s:n,r,i.x,i.y)){const t=Math.abs(r-i.y)/(n-i.x);locallyInside(i,e)&&(t<c||t===c&&(i.x>o.x||i.x===o.x&&sectorContainsSector(o,i)))&&(o=i,c=t)}i=i.next}while(i!==A);return o}(e,t);if(!i)return t;const n=splitPolygon(i,e);return filterPoints(n,n.next),filterPoints(i,i.next)}function sectorContainsSector(e,t){return area(e.prev,e,t.prev)<0&&area(t.next,e,e.next)<0}function zOrder(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function getLeftmost(e){let t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function pointInTriangle(e,t,i,n,r,o,s,A){return(r-s)*(t-A)>=(e-s)*(o-A)&&(e-s)*(n-A)>=(i-s)*(t-A)&&(i-s)*(o-A)>=(r-s)*(n-A)}function pointInTriangleExceptFirst(e,t,i,n,r,o,s,A){return!(e===s&&t===A)&&pointInTriangle(e,t,i,n,r,o,s,A)}function isValidDiagonal(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function intersectsPolygon(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&intersects(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(locallyInside(e,t)&&locallyInside(t,e)&&function middleInside(e,t){let i=e,n=!1;const r=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}(e,t)&&(area(e.prev,e,t.prev)||area(e,t.prev,t))||equals(e,t)&&area(e.prev,e,e.next)>0&&area(t.prev,t,t.next)>0)}function area(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function equals(e,t){return e.x===t.x&&e.y===t.y}function intersects(e,t,i,n){const r=sign(area(e,t,i)),o=sign(area(e,t,n)),s=sign(area(i,n,e)),A=sign(area(i,n,t));return r!==o&&s!==A||(!(0!==r||!onSegment(e,i,t))||(!(0!==o||!onSegment(e,n,t))||(!(0!==s||!onSegment(i,e,n))||!(0!==A||!onSegment(i,t,n)))))}function onSegment(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function sign(e){return e>0?1:e<0?-1:0}function locallyInside(e,t){return area(e.prev,e,e.next)<0?area(e,t,e.next)>=0&&area(e,e.prev,t)>=0:area(e,t,e.prev)<0||area(e,e.next,t)<0}function splitPolygon(e,t){const i=createNode(e.i,e.x,e.y),n=createNode(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,o.next=n,n.prev=o,n}function insertNode(e,t,i,n){const r=createNode(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function removeNode(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function createNode(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function unifyVertices(e,t,i){const n=new Map,r=[],o=[],s=[];for(let A=0;A<i.length;A++){const a=i[A],l=e[3*a+0],c=e[3*a+1],p=e[3*a+2],h=t[2*a+0],g=t[2*a+1],u=`${l},${c},${p}|${h},${g}`;if(n.has(u))s.push(n.get(u));else{const e=r.length/3;n.set(u,e),r.push(l,c,p),o.push(h,g),s.push(e)}}return{vertices:r,uvs:o,indices:s}}function infoestrudi(e,t,i,n,r){n||(n={}),i||(i=[]);let o=n.p0||0,s=Math.tan(n.coeffbase1*Ue||0),A=Math.tan(n.coeffbase2*Ue||0),a=t||n.p1||20,l=Math.tan(n.coefftop1*Ue||0),c=Math.tan(n.coefftop2*Ue||0),{mi:p,ma:h}=e.pt.reduce(((e,t)=>(e.mi.x=Math.min(e.mi.x,t.x),e.mi.y=Math.min(e.mi.y,t.y),e.ma.x=Math.max(e.ma.x,t.x),e.ma.y=Math.max(e.ma.y,t.y),e)),{mi:{x:1e9,y:1e9},ma:{x:-1e9,y:-1e9}}),g=0,u=1e9;function getpars(e){e.z1=getzeta(e.x,e.y,o,s,A,r),e.z2=getzeta(e.x,e.y,a,l,c,r),e.l=Math.abs(e.z2-e.z1)}for(let e of i)getpars(e);getpars(p),getpars(h);let d=[{x:p.x,y:p.y},{x:h.x,y:p.y},{x:h.x,y:h.y},{x:p.x,y:h.y}];for(let e of d)getpars(e),e.l>g&&(g=e.l),e.l<u&&(u=e.l);return{aini:n.coeffbase1||0,aini2:n.coeffbase2||0,afin:n.coefftop1||0,afin2:n.coefftop2||0,pts:i,mi:p,ma:h,rect:d,dimx:h.x-p.x,dimy:h.y-p.y,lnom:a-o,lmax:g,lmin:u,lmed:(g+u)/2}}function getzeta(e,t,i,n,r,o,s=!1){let A=e*n+t*r+i;if(o){let e=o.xfromy(-t,0,!0);s?A-=e:A=e}return A}function sidegeomfromshapes(t,i,n,r,o=!1,s=!1,A=!1){if(n&&r){if(n.length!==r.length)throw new Error("shapes with different length");if(n.length<2)throw new Error("I percorsi devono contenere almeno due punti ciascuno.");if(!t.geo[i]){const a=[],l=[],c=[],p=n.length,addpts=e=>{for(const t of e)a.push(t.x,t.y,t.z),A?l.push(t.v,t.u):l.push(t.u,t.v)},equalpos=(e,t)=>e.x===t.x&&e.y===t.y&&e.z===t.z,addindexquad=(e,t,i,n)=>{o?c.push(e,i,t,i,n,t):c.push(e,t,i,i,t,n)};addpts(n),addpts(r);for(let e=0;e<p-1;e++){const t=e+1;equalpos(n[e],n[t])||addindexquad(e,t,e+p,t+p)}const h=new e.BufferGeometry;if(s){let t=unifyVertices(a,l,c);h.setAttribute("position",new e.Float32BufferAttribute(t.vertices,3)),h.setAttribute("uv",new e.Float32BufferAttribute(t.uvs,2)),h.setIndex(t.indices)}else h.setAttribute("position",new e.Float32BufferAttribute(a,3)),h.setAttribute("uv",new e.Float32BufferAttribute(l,2)),h.setIndex(c);h.computeVertexNormals(),t.geo[i]=h}return t.geo[i]}}function bottomgeomfromshape(t,i,n,r,o=0,s=0,A=0,a=null,l=!1,c=!1){let p=`bg:${o}|${s}${A}|${n.key}|${i}|${a?.key||""}|${c?1:0}`;for(let h of r)p=`${p}|${h.key}`;if(p=hash(p),!t.geo[p]){let g,u=[],d=[],f=n.pt.length;u=n.vec;const I=new e.BufferGeometry,m=[],b=[],C=[];function addvertexes(e,t){let n=m.length/3;for(let n=0;n<e.length;n++){const r=e[n],l=t[2*r],p=-t[2*r+1],h=getzeta(l,p,o,s,A,a,i);m.push(l,p,h),c?b.push(l,p):b.push(p,l)}for(let t=0;t<e.length;t+=3)i?C.push(t+n,t+n+2,t+n+1):C.push(t+n,t+n+1,t+n+2)}if(a){let B=n.sliceony(a);for(let y of B){let E=y.flatMap((e=>[e.x,e.y]));addvertexes(earcut(E,[]),E)}}else if(Array.isArray(r)&&r.length){for(let x of r)d.push(f),f+=x.pt.length,u=[...u,...x.vec];g=earcut(u,d),addvertexes(g,u)}else g=earcut(u),addvertexes(g,u);if(l){let P=unifyVertices(m,b,C);I.setAttribute("position",new e.Float32BufferAttribute(P.vertices,3)),I.setAttribute("uv",new e.Float32BufferAttribute(P.uvs,2)),I.setIndex(P.indices)}else I.setAttribute("position",new e.Float32BufferAttribute(m,3)),I.setAttribute("uv",new e.Float32BufferAttribute(b,2)),I.setIndex(C);I.computeVertexNormals(),t.geo[p]=I}return t.geo[p]}function estrusorotate(e,t,i=0){switch(e.trim().toUpperCase().slice(0,1)){case"A":t.rotation.x=-Math.PI/2;break;case"L":t.rotation.y=Math.PI/2,t.rotation.z=Math.PI;break;case"P":t.rotation.z=Math.PI/2}return t}function estruso(t,i,n,r,o,s,A){A||(A={}),s||(s=[]),Array.isArray(s)||(s=[s,s,s]);let a=A.p0||0,l=Math.tan(A.coeffbase1*Ue||0),c=Math.tan(A.coeffbase2*Ue||0),p=n||A.p1||20,h=Math.tan(A.coefftop1*Ue||0),g=Math.tan(A.coefftop2*Ue||0),u=A.shapetop,d=A.shapebase||A.shapebottom;u&&(g=0),d&&(g=0);let f=d?d.key:"",I=u?u.key:"",m=A.notopholes||!1,b=A.nobottomholes||A.nobaseholes||!1,C=A.invert||!1,B=A.open||!1,y=new e.Group;if(r){if(!A.nobase){let e=o;b&&(e=Array.isArray(b)?e.filter(((e,t)=>!b[t])):[]);let i=bottomgeomfromshape(t,!0,r,B?[]:e,a,l,c,d,!1,A.uvswap);A.nolines||y.add(edgesfromgeometry(i)),y.add(getmesh(i,s[0]||it))}if(!A.notop){let e=o;m&&(e=Array.isArray(m)?e.filter(((e,t)=>!m[t])):[]);let i=bottomgeomfromshape(t,!1,r,B?[]:e,p,h,g,u,!1,A.uvswap);y.add(getmesh(i,s[1]||s[0]||it)),A.nolines||y.add(edgesfromgeometry(i))}if(!A.nosides){let e=r.to3d(0,a,l,-c,B,d,!C),i=r.to3d(1,p,h,-g,B,u,C),n=`${r.key}${C?1:0}|${a}|${p}|${l}|${c||f}|${h}|${g||I}|${B}|${A.wvswap?1:0}`,E=sidegeomfromshapes(t,n,e,i,!1,!1,A.uvswap);if(A.nolines||A.nosidelines||y.add(edgesfromgeometry(E)),y.add(getmesh(E,s[2]||s[0]||it)),o&&!B)for(let r=0;r<o.length;r++){let u=o[r];if(Array.isArray(m)){if(m[r])continue}else if(m)continue;if(Array.isArray(b)){if(b[r])continue}else if(b)continue;e=u.to3d(0,a,l,c),i=u.to3d(0,p,h,g),n=`${u.key}|${a}|${p}|${l}|${c}|${h}|${g}`;let d=sidegeomfromshapes(t,n,e,i,!0);A.nolines||A.nosidelines||y.add(edgesfromgeometry(d)),y.add(getmesh(d,s[3]||s[0]||it))}}return estrusorotate(i,y,n)}return y}function revolve(t,i,n,r,o){o||(o={});let s=o.segmenti??12,A=hash(`rev|${i.key}|${n}|${s}`),a=t.geo[A],l=new e.Group;if(!a){const n=i.pt.map((t=>new e.Vector3(t.x,t.y,0)));a=new e.LatheGeometry(n,s,0,2*Math.PI),t.geo[A]=a}o.uvswap&&uvswap(a);const c=new e.Mesh(a,r);return l.add(c),o.nolines||o.nosidelines||l.add(edgesfromgeometry(a)),l}function estrusopat(t,i,n,r,o,s,A){A||(A={});let a=A.invert;s||(s=[]);let l=A.open,c=A.closepat;if(!n.pt?.length)return;let p=o.to3d(0,0,0,0,l),h=new e.Group;if(!A.nobase&&!A.open&&!c){let i=new e.Group,a=angle3point(r[0],n.pt[0],n.pt[1])+Math.PI/2,l=bottomgeomfromshape(t,!1,o,[],0,-Math.tan(a),0,null,!1,A.uvswap);i.add(getmesh(l,s[0]||it)),i.add(edgesfromgeometry(l));let c=n.infosegmento(0,!0);h.add(posiziona(i,{sl:c.x,sp:c.y,sa:0,ay:90-c.ang}))}if(!A.notop&&!A.open&&!c){let i=new e.Group,a=-(angle3point(n.pt[n.npt-2],n.pt[n.npt-1],r[n.npt-1])+Math.PI/2),l=bottomgeomfromshape(t,!0,o,[],0,-Math.tan(a),0,null,!1,A.uvswap);i.add(getmesh(l,s[1]||s[0]||it)),i.add(edgesfromgeometry(l));let c=n.infosegmento(n.pt.length-1,!0);h.add(posiziona(i,{sl:c.x,sp:c.y,sa:0,ay:90-c.ang}))}const g=function sidegeomfrompat(t,i,n,r,o,s){let A=`bsg:${i.key}|${n.key}|${o}|${s}`;if(n.npt==r.length){if(A=hash(A),!t.geo[A]){const a=[],l=[],c=[],p=i.length,equalpos=(e,t)=>e.x===t.x&&e.y===t.y&&e.z===t.z;let h=0,g=n.pt,u=n.npt;const addpts=(t,i,n,r)=>{for(const o of t){let t=new e.Vector3(o.x,o.y,o.x*r);t.applyMatrix4(i),a.push(t.x,t.y,t.z),l.push(o.u,o.v+n)}};let d=u;for(let t=0;t<u;t++){let o;o=t<u-1?angle3point(r[t],g[t],g[t+1])+Math.PI/2:-(angle3point(g[t-1],g[t],r[t])+Math.PI/2);let s=-Math.tan(o),A=n.infosegmento(t,!0),a=new e.Object3D;a.position.set(A.x,0,A.y),a.rotation.set(0,(90-A.ang)*Ue,0),a.updateMatrix(),addpts(i,a.matrix,h,s),h+=A.l}if(o){let t=n.infosegmento(0,!0),o=new e.Object3D;o.position.set(t.x,0,t.y),o.rotation.set(0,(90-t.ang)*Ue,0);let s=angle3point(g[u-1],g[0],r[0])+Math.PI/2,A=-Math.tan(s);o.updateMatrix(),addpts(i,o.matrix,h,A),h+=t.l,d++}for(let e=0;e<d-1;e++)for(let t=0;t<p-1;t++){const addindexquad=(e,t,i,n)=>{s?c.push(e,i,t,i,n,t):c.push(e,t,i,i,t,n)},n=t+1;equalpos(i[t],i[n])||addindexquad(t+e*p,n+e*p,t+(e+1)*p,n+(e+1)*p)}const f=new e.BufferGeometry;f.setAttribute("position",new e.Float32BufferAttribute(a,3)),f.setAttribute("uv",new e.Float32BufferAttribute(l,2)),f.setIndex(c),f.computeVertexNormals(),t[A]=f}return t[A]}}(t,p,n,r,c?1:0,a?1:0,A.uvswap);return g&&(A.nolines||A.nosidelines||h.add(edgesfromgeometry(g)),h.add(getmesh(g,s[2]||s[0]||it))),estrusorotate(i,h,0)}async function spritemat(t,i){try{let n={transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1};if(i.startsWith("#"))n.color=i;else{let e=await t.tex(i,1e3,1e3);e?n.map=e:n.color="black"}return new e.SpriteMaterial(n)}catch(e){return it}}function getsprite0(t,i,n,r,o,s={}){s||(s={});let{size:A=50,pick:a=!1,screen:l=!1,sizex:c,sizey:p}=s;const h=new e.Sprite(o);h.position.set(0,0,0),h.userData.issprite=!0,h.userData.ispunto=t,h.userData.ispick=a,h.userData.isScreen=l,h.renderOrder=999,h.layers.set(29),h.name=t?"_punto":"_sprite";let g=new e.Group;return g.position.set(i,n,r),g.scale.set(c||A,p||c||A,1),g.add(h),g.traverse((e=>{e.material&&(e.material.depthTest=!1,e.material.depthWrite=!1)})),g.renderOrder=999,g}async function getpunto(t,i,n,r,o="yellow",s){s||(s={size:20}),s.screen=!0;const A=await function createCircleTexture(t,i=64,n="rgba(255,0,0,1)"){const r=`ct|${i}|${n}`;if(!t.textures[r]){const o=document.createElement("canvas");o.width=o.height=i;const s=o.getContext("2d"),A=i/2;s.clearRect(0,0,i,i),s.fillStyle=n,s.beginPath(),s.arc(A,A,A,0,2*Math.PI),s.fill();const a=new e.CanvasTexture(o);a.needsUpdate=!0,t.textures[r]=a}return t.textures[r]}(t,64,o);return getsprite0(!0,i,n,r,new e.SpriteMaterial({map:A,transparent:!0,fog:!1,toneMapped:!1}),s)}function getsprite(e,t,i,n,r,o={}){return getsprite0(!1,t,i,n,r,o)}class GLTFLoader extends r{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new GLTFMaterialsClearcoatExtension(e)})),this.register((function(e){return new GLTFMaterialsDispersionExtension(e)})),this.register((function(e){return new GLTFTextureBasisUExtension(e)})),this.register((function(e){return new GLTFTextureWebPExtension(e)})),this.register((function(e){return new GLTFTextureAVIFExtension(e)})),this.register((function(e){return new GLTFMaterialsSheenExtension(e)})),this.register((function(e){return new GLTFMaterialsTransmissionExtension(e)})),this.register((function(e){return new GLTFMaterialsVolumeExtension(e)})),this.register((function(e){return new GLTFMaterialsIorExtension(e)})),this.register((function(e){return new GLTFMaterialsEmissiveStrengthExtension(e)})),this.register((function(e){return new GLTFMaterialsSpecularExtension(e)})),this.register((function(e){return new GLTFMaterialsIridescenceExtension(e)})),this.register((function(e){return new GLTFMaterialsAnisotropyExtension(e)})),this.register((function(e){return new GLTFMaterialsBumpExtension(e)})),this.register((function(e){return new GLTFLightsExtension(e)})),this.register((function(e){return new GLTFMeshoptCompression(e)})),this.register((function(e){return new GLTFMeshGpuInstancing(e)}))}load(e,t,i,n){const r=this;let A;if(""!==this.resourcePath)A=this.resourcePath;else if(""!==this.path){const t=o.extractUrlBase(e);A=o.resolveURL(t,this.path)}else A=o.extractUrlBase(e);this.manager.itemStart(e);const _onError=function(t){n?n(t):console.error(t),r.manager.itemError(e),r.manager.itemEnd(e)},a=new s(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(i){try{r.parse(i,A,(function(i){t(i),r.manager.itemEnd(e)}),_onError)}catch(e){_onError(e)}}),i,_onError)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,n){let r;const o={},s={},A=new TextDecoder;if("string"==typeof e)r=JSON.parse(e);else if(e instanceof ArrayBuffer){if(A.decode(new Uint8Array(e,0,4))===ut){try{o[gt.KHR_BINARY_GLTF]=new GLTFBinaryExtension(e)}catch(e){return void(n&&n(e))}r=JSON.parse(o[gt.KHR_BINARY_GLTF].content)}else r=JSON.parse(A.decode(e))}else r=e;if(void 0===r.asset||r.asset.version[0]<2)return void(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const a=new GLTFParser(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](a);t.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),s[t.name]=t,o[t.name]=!0}if(r.extensionsUsed)for(let e=0;e<r.extensionsUsed.length;++e){const t=r.extensionsUsed[e],i=r.extensionsRequired||[];switch(t){case gt.KHR_MATERIALS_UNLIT:o[t]=new GLTFMaterialsUnlitExtension;break;case gt.KHR_DRACO_MESH_COMPRESSION:o[t]=new GLTFDracoMeshCompressionExtension(r,this.dracoLoader);break;case gt.KHR_TEXTURE_TRANSFORM:o[t]=new GLTFTextureTransformExtension;break;case gt.KHR_MESH_QUANTIZATION:o[t]=new GLTFMeshQuantizationExtension;break;default:i.indexOf(t)>=0&&void 0===s[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}a.setExtensions(o),a.setPlugins(s),a.parse(i,n)}parseAsync(e,t){const i=this;return new Promise((function(n,r){i.parse(e,t,n,r)}))}}function GLTFRegistry(){let e={};return{get:function(t){return e[t]},add:function(t,i){e[t]=i},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const gt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class GLTFLightsExtension{constructor(e){this.parser=e,this.name=gt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,n=t.length;i<n;i++){const n=t[i];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&e._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let n=t.cache.get(i);if(n)return n;const r=t.json,o=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let s;const A=new l(16777215);void 0!==o.color&&A.setRGB(o.color[0],o.color[1],o.color[2],c);const a=void 0!==o.range?o.range:0;switch(o.type){case"directional":s=new u(A),s.target.position.set(0,0,-1),s.add(s.target);break;case"point":s=new g(A),s.distance=a;break;case"spot":s=new h(A),s.distance=a,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,s.angle=o.spot.outerConeAngle,s.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,s.target.position.set(0,0,-1),s.add(s.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return s.position.set(0,0,0),s.decay=2,assignExtrasToUserData(s,o),void 0!==o.intensity&&(s.intensity=o.intensity),s.name=t.createUniqueName(o.name||"light_"+e),n=Promise.resolve(s),t.cache.add(i,n),n}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,n=i.json.nodes[e],r=(n.extensions&&n.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(e){return i._getNodeRef(t.cache,r,e)}))}}class GLTFMaterialsUnlitExtension{constructor(){this.name=gt.KHR_MATERIALS_UNLIT}getMaterialType(){return Y}extendParams(e,t,i){const n=[];e.color=new l(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const t=r.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],c),e.opacity=t[3]}void 0!==r.baseColorTexture&&n.push(i.assignTexture(e,"map",r.baseColorTexture,p))}return Promise.all(n)}}class GLTFMaterialsEmissiveStrengthExtension{constructor(e){this.parser=e,this.name=gt.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name].emissiveStrength;return void 0!==n&&(t.emissiveIntensity=n),Promise.resolve()}}class GLTFMaterialsClearcoatExtension{constructor(e){this.parser=e,this.name=gt.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?A:null}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];if(void 0!==o.clearcoatFactor&&(t.clearcoat=o.clearcoatFactor),void 0!==o.clearcoatTexture&&r.push(i.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),void 0!==o.clearcoatRoughnessFactor&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),void 0!==o.clearcoatRoughnessTexture&&r.push(i.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),void 0!==o.clearcoatNormalTexture&&(r.push(i.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),void 0!==o.clearcoatNormalTexture.scale)){const e=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new a(e,e)}return Promise.all(r)}}class GLTFMaterialsDispersionExtension{constructor(e){this.parser=e,this.name=gt.KHR_MATERIALS_DISPERSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?A:null}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name];return t.dispersion=void 0!==n.dispersion?n.dispersion:0,Promise.resolve()}}class GLTFMaterialsIridescenceExtension{constructor(e){this.parser=e,this.name=gt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?A:null}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return void 0!==o.iridescenceFactor&&(t.iridescence=o.iridescenceFactor),void 0!==o.iridescenceTexture&&r.push(i.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),void 0!==o.iridescenceIor&&(t.iridescenceIOR=o.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==o.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),void 0!==o.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),void 0!==o.iridescenceThicknessTexture&&r.push(i.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(r)}}class GLTFMaterialsSheenExtension{constructor(e){this.parser=e,this.name=gt.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?A:null}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new l(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=n.extensions[this.name];if(void 0!==o.sheenColorFactor){const e=o.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],c)}return void 0!==o.sheenRoughnessFactor&&(t.sheenRoughness=o.sheenRoughnessFactor),void 0!==o.sheenColorTexture&&r.push(i.assignTexture(t,"sheenColorMap",o.sheenColorTexture,p)),void 0!==o.sheenRoughnessTexture&&r.push(i.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(r)}}class GLTFMaterialsTransmissionExtension{constructor(e){this.parser=e,this.name=gt.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?A:null}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return void 0!==o.transmissionFactor&&(t.transmission=o.transmissionFactor),void 0!==o.transmissionTexture&&r.push(i.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(r)}}class GLTFMaterialsVolumeExtension{constructor(e){this.parser=e,this.name=gt.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?A:null}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];t.thickness=void 0!==o.thicknessFactor?o.thicknessFactor:0,void 0!==o.thicknessTexture&&r.push(i.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const s=o.attenuationColor||[1,1,1];return t.attenuationColor=(new l).setRGB(s[0],s[1],s[2],c),Promise.all(r)}}class GLTFMaterialsIorExtension{constructor(e){this.parser=e,this.name=gt.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?A:null}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name];return t.ior=void 0!==n.ior?n.ior:1.5,Promise.resolve()}}class GLTFMaterialsSpecularExtension{constructor(e){this.parser=e,this.name=gt.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?A:null}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];t.specularIntensity=void 0!==o.specularFactor?o.specularFactor:1,void 0!==o.specularTexture&&r.push(i.assignTexture(t,"specularIntensityMap",o.specularTexture));const s=o.specularColorFactor||[1,1,1];return t.specularColor=(new l).setRGB(s[0],s[1],s[2],c),void 0!==o.specularColorTexture&&r.push(i.assignTexture(t,"specularColorMap",o.specularColorTexture,p)),Promise.all(r)}}class GLTFMaterialsBumpExtension{constructor(e){this.parser=e,this.name=gt.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?A:null}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return t.bumpScale=void 0!==o.bumpFactor?o.bumpFactor:1,void 0!==o.bumpTexture&&r.push(i.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(r)}}class GLTFMaterialsAnisotropyExtension{constructor(e){this.parser=e,this.name=gt.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?A:null}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return void 0!==o.anisotropyStrength&&(t.anisotropy=o.anisotropyStrength),void 0!==o.anisotropyRotation&&(t.anisotropyRotation=o.anisotropyRotation),void 0!==o.anisotropyTexture&&r.push(i.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(r)}}class GLTFTextureBasisUExtension{constructor(e){this.parser=e,this.name=gt.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,n=i.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,o)}}class GLTFTextureWebPExtension{constructor(e){this.parser=e,this.name=gt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,n=i.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],s=n.images[o.source];let A=i.textureLoader;if(s.uri){const e=i.options.manager.getHandler(s.uri);null!==e&&(A=e)}return this.detectSupport().then((function(r){if(r)return i.loadTextureImage(e,o.source,A);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class GLTFTextureAVIFExtension{constructor(e){this.parser=e,this.name=gt.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,n=i.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],s=n.images[o.source];let A=i.textureLoader;if(s.uri){const e=i.options.manager.getHandler(s.uri);null!==e&&(A=e)}return this.detectSupport().then((function(r){if(r)return i.loadTextureImage(e,o.source,A);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class GLTFMeshoptCompression{constructor(e){this.name=gt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const e=i.extensions[this.name],n=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then((function(t){const i=e.byteOffset||0,n=e.byteLength||0,o=e.count,s=e.byteStride,A=new Uint8Array(t,i,n);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(o,s,A,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(o*s);return r.decodeGltfBuffer(new Uint8Array(t),o,s,A,e.mode,e.filter),t}))}))}return null}}class GLTFMeshGpuInstancing{constructor(e){this.name=gt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||void 0===i.mesh)return null;const n=t.meshes[i.mesh];for(const e of n.primitives)if(e.mode!==mt.TRIANGLES&&e.mode!==mt.TRIANGLE_STRIP&&e.mode!==mt.TRIANGLE_FAN&&void 0!==e.mode)return null;const r=i.extensions[this.name].attributes,o=[],s={};for(const e in r)o.push(this.parser.getDependency("accessor",r[e]).then((t=>(s[e]=t,s[e]))));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then((e=>{const t=e.pop(),i=t.isGroup?t.children:[t],n=e[0].count,r=[];for(const e of i){const t=new d,i=new f,o=new I,A=new f(1,1,1),a=new m(e.geometry,e.material,n);for(let e=0;e<n;e++)s.TRANSLATION&&i.fromBufferAttribute(s.TRANSLATION,e),s.ROTATION&&o.fromBufferAttribute(s.ROTATION,e),s.SCALE&&A.fromBufferAttribute(s.SCALE,e),a.setMatrixAt(e,t.compose(i,o,A));for(const t in s)if("_COLOR_0"===t){const e=s[t];a.instanceColor=new b(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,s[t]);C.prototype.copy.call(a,e),this.parser.assignFinalMaterial(a),r.push(a)}return t.isGroup?(t.clear(),t.add(...r),t):r[0]})))}}const ut="glTF",dt=1313821514,ft=5130562;class GLTFBinaryExtension{constructor(e){this.name=gt.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==ut)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(e,12);let o=0;for(;o<n;){const t=r.getUint32(o,!0);o+=4;const n=r.getUint32(o,!0);if(o+=4,n===dt){const n=new Uint8Array(e,12+o,t);this.content=i.decode(n)}else if(n===ft){const i=12+o;this.body=e.slice(i,i+t)}o+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class GLTFDracoMeshCompressionExtension{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=gt.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,n=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,s={},A={},a={};for(const e in o){const t=Et[e]||e.toLowerCase();s[t]=o[e]}for(const t in e.attributes){const n=Et[t]||t.toLowerCase();if(void 0!==o[t]){const r=i.accessors[e.attributes[t]],o=bt[r.componentType];a[n]=o.name,A[n]=!0===r.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t,i){n.decodeDracoFile(e,(function(e){for(const t in e.attributes){const i=e.attributes[t],n=A[t];void 0!==n&&(i.normalized=n)}t(e)}),s,a,c,i)}))}))}}class GLTFTextureTransformExtension{constructor(){this.name=gt.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class GLTFMeshQuantizationExtension{constructor(){this.name=gt.KHR_MESH_QUANTIZATION}}class GLTFCubicSplineInterpolant extends pe{constructor(e,t,i,n){super(e,t,i,n)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let e=0;e!==n;e++)t[e]=i[r+e];return t}interpolate_(e,t,i,n){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,A=2*s,a=3*s,l=n-t,c=(i-t)/l,p=c*c,h=p*c,g=e*a,u=g-a,d=-2*h+3*p,f=h-p,I=1-d,m=f-p+c;for(let e=0;e!==s;e++){const t=o[u+e+s],i=o[u+e+A]*l,n=o[g+e+s],a=o[g+e]*l;r[e]=I*t+m*i+d*n+f*a}return r}}const It=new I;class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant{interpolate_(e,t,i,n){const r=super.interpolate_(e,t,i,n);return It.fromArray(r).normalize().toArray(r),r}}const mt={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},bt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ct={9728:M,9729:L,9984:S,9985:D,9986:v,9987:w},Bt={33071:F,33648:_,10497:T},yt={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Et={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},xt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Qt={CUBICSPLINE:void 0,LINEAR:re,STEP:ne},Pt="OPAQUE",wt="MASK",vt="BLEND";function addUnknownExtensionsToUserData(e,t,i){for(const n in i.extensions)void 0===e[n]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=i.extensions[n])}function assignExtrasToUserData(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function updateMorphTargets(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let i=0,n=t.weights.length;i<n;i++)e.morphTargetInfluences[i]=t.weights[i];if(t.extras&&Array.isArray(t.extras.targetNames)){const i=t.extras.targetNames;if(e.morphTargetInfluences.length===i.length){e.morphTargetDictionary={};for(let t=0,n=i.length;t<n;t++)e.morphTargetDictionary[i[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function createPrimitiveKey(e){let t;const i=e.extensions&&e.extensions[gt.KHR_DRACO_MESH_COMPRESSION];if(t=i?"draco:"+i.bufferView+":"+i.indices+":"+createAttributesKey(i.attributes):e.indices+":"+createAttributesKey(e.attributes)+":"+e.mode,void 0!==e.targets)for(let i=0,n=e.targets.length;i<n;i++)t+=":"+createAttributesKey(e.targets[i]);return t}function createAttributesKey(e){let t="";const i=Object.keys(e).sort();for(let n=0,r=i.length;n<r;n++)t+=i[n]+":"+e[i[n]]+";";return t}function getNormalizedComponentScale(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const Dt=new d;class GLTFParser{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new GLTFRegistry,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,n=-1,r=!1,o=-1;if("undefined"!=typeof navigator){const e=navigator.userAgent;i=!0===/^((?!chrome|android).)*safari/i.test(e);const t=e.match(/Version\/(\d+)/);n=i&&t?parseInt(t[1],10):-1,r=e.indexOf("Firefox")>-1,o=r?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||i&&n<17||r&&o<98?this.textureLoader=new B(this.options.manager):this.textureLoader=new y(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new s(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])})).then((function(t){const o={scene:t[0][n.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:n.asset,parser:i,userData:{}};return addUnknownExtensionsToUserData(r,o,n),assignExtrasToUserData(o,n),Promise.all(i._invokeAll((function(e){return e.afterRoot&&e.afterRoot(o)}))).then((function(){for(const e of o.scenes)e.updateMatrixWorld();e(o)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let i=0,n=t.length;i<n;i++){const n=t[i].joints;for(let t=0,i=n.length;t<i;t++)e[n[t]].isBone=!0}for(let t=0,n=e.length;t<n;t++){const n=e[t];void 0!==n.mesh&&(this._addNodeRef(this.meshCache,n.mesh),void 0!==n.skin&&(i[n.mesh].isSkinnedMesh=!0)),void 0!==n.camera&&this._addNodeRef(this.cameraCache,n.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,i){if(e.refs[t]<=1)return i;const n=i.clone(),updateMappings=(e,t)=>{const i=this.associations.get(e);null!=i&&this.associations.set(t,i);for(const[i,n]of e.children.entries())updateMappings(n,t.children[i])};return updateMappings(i,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const n=e(t[i]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let n=0;n<t.length;n++){const r=e(t[n]);r&&i.push(r)}return i}getDependency(e,t){const i=e+":"+t;let n=this.cache.get(i);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":n=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":n=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne((function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)})),!n)throw new Error("Unknown type: "+e)}this.cache.add(i,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,n=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(n.map((function(t,n){return i.getDependency(e,n)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],i=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[gt.KHR_BINARY_GLTF].body);const n=this.options;return new Promise((function(e,r){i.load(o.resolveURL(t.uri,n.path),e,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const i=t.byteLength||0,n=t.byteOffset||0;return e.slice(n,n+i)}))}loadAccessor(e){const t=this,i=this.json,n=this.json.accessors[e];if(void 0===n.bufferView&&void 0===n.sparse){const e=yt[n.type],t=bt[n.componentType],i=!0===n.normalized,r=new t(n.count*e);return Promise.resolve(new E(r,e,i))}const r=[];return void 0!==n.bufferView?r.push(this.getDependency("bufferView",n.bufferView)):r.push(null),void 0!==n.sparse&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then((function(e){const r=e[0],o=yt[n.type],s=bt[n.componentType],A=s.BYTES_PER_ELEMENT,a=A*o,l=n.byteOffset||0,c=void 0!==n.bufferView?i.bufferViews[n.bufferView].byteStride:void 0,p=!0===n.normalized;let h,g;if(c&&c!==a){const e=Math.floor(l/c),i="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+e+":"+n.count;let a=t.cache.get(i);a||(h=new s(r,e*c,n.count*c/A),a=new x(h,c/A),t.cache.add(i,a)),g=new P(a,o,l%c/A,p)}else h=null===r?new s(n.count*o):new s(r,l,n.count*o),g=new E(h,o,p);if(void 0!==n.sparse){const t=yt.SCALAR,i=bt[n.sparse.indices.componentType],A=n.sparse.indices.byteOffset||0,a=n.sparse.values.byteOffset||0,l=new i(e[1],A,n.sparse.count*t),c=new s(e[2],a,n.sparse.count*o);null!==r&&(g=new E(g.array.slice(),g.itemSize,g.normalized));for(let e=0,t=l.length;e<t;e++){const t=l[e];if(g.setX(t,c[e*o]),o>=2&&g.setY(t,c[e*o+1]),o>=3&&g.setZ(t,c[e*o+2]),o>=4&&g.setW(t,c[e*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return g}))}loadTexture(e){const t=this.json,i=this.options,n=t.textures[e].source,r=t.images[n];let o=this.textureLoader;if(r.uri){const e=i.manager.getHandler(r.uri);null!==e&&(o=e)}return this.loadTextureImage(e,n,o)}loadTextureImage(e,t,i){const n=this,r=this.json,o=r.textures[e],s=r.images[t],A=(s.uri||s.bufferView)+":"+o.sampler;if(this.textureCache[A])return this.textureCache[A];const a=this.loadImageSource(t,i).then((function(t){t.flipY=!1,t.name=o.name||s.name||"",""===t.name&&"string"==typeof s.uri&&!1===s.uri.startsWith("data:image/")&&(t.name=s.uri);const i=(r.samplers||{})[o.sampler]||{};return t.magFilter=Ct[i.magFilter]||L,t.minFilter=Ct[i.minFilter]||w,t.wrapS=Bt[i.wrapS]||T,t.wrapT=Bt[i.wrapT]||T,n.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[A]=a,a}loadImageSource(e,t){const i=this,n=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const s=n.images[e],A=self.URL||self.webkitURL;let a=s.uri||"",l=!1;if(void 0!==s.bufferView)a=i.getDependency("bufferView",s.bufferView).then((function(e){l=!0;const t=new Blob([e],{type:s.mimeType});return a=A.createObjectURL(t),a}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(a).then((function(e){return new Promise((function(i,n){let s=i;!0===t.isImageBitmapLoader&&(s=function(e){const t=new oe(e);t.needsUpdate=!0,i(t)}),t.load(o.resolveURL(e,r.path),s,void 0,n)}))})).then((function(e){return!0===l&&A.revokeObjectURL(a),assignExtrasToUserData(e,s),e.userData.mimeType=s.mimeType||function getImageURIMimeType(e){return e.search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":"image/png"}(s.uri),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e}));return this.sourceCache[e]=c,c}assignTexture(e,t,i,n){const r=this;return this.getDependency("texture",i.index).then((function(o){if(!o)return null;if(void 0!==i.texCoord&&i.texCoord>0&&((o=o.clone()).channel=i.texCoord),r.extensions[gt.KHR_TEXTURE_TRANSFORM]){const e=void 0!==i.extensions?i.extensions[gt.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(o);o=r.extensions[gt.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),r.associations.set(o,t)}}return void 0!==n&&(o.colorSpace=n),e[t]=o,o}))}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const n=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,o=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+i.uuid;let t=this.cache.get(e);t||(t=new k,R.prototype.copy.call(t,i),t.color.copy(i.color),t.map=i.map,t.sizeAttenuation=!1,this.cache.add(e,t)),i=t}else if(e.isLine){const e="LineBasicMaterial:"+i.uuid;let t=this.cache.get(e);t||(t=new N,R.prototype.copy.call(t,i),t.color.copy(i.color),t.map=i.map,this.cache.add(e,t)),i=t}if(n||r||o){let e="ClonedMaterial:"+i.uuid+":";n&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=i.clone(),r&&(t.vertexColors=!0),o&&(t.flatShading=!0),n&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(i))),i=t}e.material=i}getMaterialType(){return G}loadMaterial(e){const t=this,i=this.json,n=this.extensions,r=i.materials[e];let o;const s={},A=[];if((r.extensions||{})[gt.KHR_MATERIALS_UNLIT]){const e=n[gt.KHR_MATERIALS_UNLIT];o=e.getMaterialType(),A.push(e.extendParams(s,r,t))}else{const i=r.pbrMetallicRoughness||{};if(s.color=new l(1,1,1),s.opacity=1,Array.isArray(i.baseColorFactor)){const e=i.baseColorFactor;s.color.setRGB(e[0],e[1],e[2],c),s.opacity=e[3]}void 0!==i.baseColorTexture&&A.push(t.assignTexture(s,"map",i.baseColorTexture,p)),s.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,s.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(A.push(t.assignTexture(s,"metalnessMap",i.metallicRoughnessTexture)),A.push(t.assignTexture(s,"roughnessMap",i.metallicRoughnessTexture))),o=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),A.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)}))))}!0===r.doubleSided&&(s.side=O);const h=r.alphaMode||Pt;if(h===vt?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,h===wt&&(s.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&o!==Y&&(A.push(t.assignTexture(s,"normalMap",r.normalTexture)),s.normalScale=new a(1,1),void 0!==r.normalTexture.scale)){const e=r.normalTexture.scale;s.normalScale.set(e,e)}if(void 0!==r.occlusionTexture&&o!==Y&&(A.push(t.assignTexture(s,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(s.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&o!==Y){const e=r.emissiveFactor;s.emissive=(new l).setRGB(e[0],e[1],e[2],c)}return void 0!==r.emissiveTexture&&o!==Y&&A.push(t.assignTexture(s,"emissiveMap",r.emissiveTexture,p)),Promise.all(A).then((function(){const i=new o(s);return r.name&&(i.name=r.name),assignExtrasToUserData(i,r),t.associations.set(i,{materials:e}),r.extensions&&addUnknownExtensionsToUserData(n,i,r),i}))}createUniqueName(e){const t=U.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,n=this.primitiveCache;function createDracoPrimitive(e){return i[gt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(i){return addPrimitiveAttributes(i,e,t)}))}const r=[];for(let i=0,o=e.length;i<o;i++){const o=e[i],s=createPrimitiveKey(o),A=n[s];if(A)r.push(A.promise);else{let e;e=o.extensions&&o.extensions[gt.KHR_DRACO_MESH_COMPRESSION]?createDracoPrimitive(o):addPrimitiveAttributes(new X,o,t),n[s]={primitive:o,promise:e},r.push(e)}}return Promise.all(r)}loadMesh(e){const t=this,r=this.json,o=this.extensions,s=r.meshes[e],A=s.primitives,a=[];for(let e=0,t=A.length;e<t;e++){const t=void 0===A[e].material?(void 0===(l=this.cache).DefaultMaterial&&(l.DefaultMaterial=new G({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:ce})),l.DefaultMaterial):this.getDependency("material",A[e].material);a.push(t)}var l;return a.push(t.loadGeometries(A)),Promise.all(a).then((function(r){const a=r.slice(0,r.length-1),l=r[r.length-1],c=[];for(let r=0,p=l.length;r<p;r++){const p=l[r],h=A[r];let g;const u=a[r];if(h.mode===mt.TRIANGLES||h.mode===mt.TRIANGLE_STRIP||h.mode===mt.TRIANGLE_FAN||void 0===h.mode)g=!0===s.isSkinnedMesh?new q(p,u):new H(p,u),!0===g.isSkinnedMesh&&g.normalizeSkinWeights(),h.mode===mt.TRIANGLE_STRIP?g.geometry=toTrianglesDrawMode(g.geometry,n):h.mode===mt.TRIANGLE_FAN&&(g.geometry=toTrianglesDrawMode(g.geometry,i));else if(h.mode===mt.LINES)g=new z(p,u);else if(h.mode===mt.LINE_STRIP)g=new j(p,u);else if(h.mode===mt.LINE_LOOP)g=new J(p,u);else{if(h.mode!==mt.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+h.mode);g=new W(p,u)}Object.keys(g.geometry.morphAttributes).length>0&&updateMorphTargets(g,s),g.name=t.createUniqueName(s.name||"mesh_"+e),assignExtrasToUserData(g,s),h.extensions&&addUnknownExtensionsToUserData(o,g,h),t.assignFinalMaterial(g),c.push(g)}for(let i=0,n=c.length;i<n;i++)t.associations.set(c[i],{meshes:e,primitives:i});if(1===c.length)return s.extensions&&addUnknownExtensionsToUserData(o,c[0],s),c[0];const p=new K;s.extensions&&addUnknownExtensionsToUserData(o,p,s),t.associations.set(p,{meshes:e});for(let e=0,t=c.length;e<t;e++)p.add(c[e]);return p}))}loadCamera(e){let t;const i=this.json.cameras[e],n=i[i.type];if(n)return"perspective"===i.type?t=new V(Z.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):"orthographic"===i.type&&(t=new $(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),assignExtrasToUserData(t,i),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],i=[];for(let e=0,n=t.joints.length;e<n;e++)i.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then((function(e){const i=e.pop(),n=e,r=[],o=[];for(let e=0,s=n.length;e<s;e++){const s=n[e];if(s){r.push(s);const t=new d;null!==i&&t.fromArray(i.array,16*e),o.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new ee(r,o)}))}loadAnimation(e){const t=this.json,i=this,n=t.animations[e],r=n.name?n.name:"animation_"+e,o=[],s=[],A=[],a=[],l=[];for(let e=0,t=n.channels.length;e<t;e++){const t=n.channels[e],i=n.samplers[t.sampler],r=t.target,c=r.node,p=void 0!==n.parameters?n.parameters[i.input]:i.input,h=void 0!==n.parameters?n.parameters[i.output]:i.output;void 0!==r.node&&(o.push(this.getDependency("node",c)),s.push(this.getDependency("accessor",p)),A.push(this.getDependency("accessor",h)),a.push(i),l.push(r))}return Promise.all([Promise.all(o),Promise.all(s),Promise.all(A),Promise.all(a),Promise.all(l)]).then((function(e){const t=e[0],n=e[1],o=e[2],s=e[3],A=e[4],a=[];for(let e=0,r=t.length;e<r;e++){const r=t[e],l=n[e],c=o[e],p=s[e],h=A[e];if(void 0===r)continue;r.updateMatrix&&r.updateMatrix();const g=i._createAnimationTracks(r,l,c,p,h);if(g)for(let e=0;e<g.length;e++)a.push(g[e])}return new te(r,void 0,a)}))}createNodeMesh(e){const t=this.json,i=this,n=t.nodes[e];return void 0===n.mesh?null:i.getDependency("mesh",n.mesh).then((function(e){const t=i._getNodeRef(i.meshCache,n.mesh,e);return void 0!==n.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,i=n.weights.length;t<i;t++)e.morphTargetInfluences[t]=n.weights[t]})),t}))}loadNode(e){const t=this,i=this.json.nodes[e],n=t._loadNodeShallow(e),r=[],o=i.children||[];for(let e=0,i=o.length;e<i;e++)r.push(t.getDependency("node",o[e]));const s=void 0===i.skin?Promise.resolve(null):t.getDependency("skin",i.skin);return Promise.all([n,Promise.all(r),s]).then((function(e){const t=e[0],i=e[1],n=e[2];null!==n&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(n,Dt)}));for(let e=0,n=i.length;e<n;e++)t.add(i[e]);return t}))}_loadNodeShallow(e){const t=this.json,i=this.extensions,n=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const r=t.nodes[e],o=r.name?n.createUniqueName(r.name):"",s=[],A=n._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return A&&s.push(A),void 0!==r.camera&&s.push(n.getDependency("camera",r.camera).then((function(e){return n._getNodeRef(n.cameraCache,r.camera,e)}))),n._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){s.push(e)})),this.nodeCache[e]=Promise.all(s).then((function(t){let s;if(s=!0===r.isBone?new ie:t.length>1?new K:1===t.length?t[0]:new C,s!==t[0])for(let e=0,i=t.length;e<i;e++)s.add(t[e]);if(r.name&&(s.userData.name=r.name,s.name=o),assignExtrasToUserData(s,r),r.extensions&&addUnknownExtensionsToUserData(i,s,r),void 0!==r.matrix){const e=new d;e.fromArray(r.matrix),s.applyMatrix4(e)}else void 0!==r.translation&&s.position.fromArray(r.translation),void 0!==r.rotation&&s.quaternion.fromArray(r.rotation),void 0!==r.scale&&s.scale.fromArray(r.scale);return n.associations.has(s)||n.associations.set(s,{}),n.associations.get(s).nodes=e,s})),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],n=this,r=new K;i.name&&(r.name=n.createUniqueName(i.name)),assignExtrasToUserData(r,i),i.extensions&&addUnknownExtensionsToUserData(t,r,i);const o=i.nodes||[],s=[];for(let e=0,t=o.length;e<t;e++)s.push(n.getDependency("node",o[e]));return Promise.all(s).then((function(e){for(let t=0,i=e.length;t<i;t++)r.add(e[t]);return n.associations=(e=>{const t=new Map;for(const[e,i]of n.associations)(e instanceof R||e instanceof oe)&&t.set(e,i);return e.traverse((e=>{const i=n.associations.get(e);null!=i&&t.set(e,i)})),t})(r),r}))}_createAnimationTracks(e,t,i,n,r){const o=[],s=e.name?e.name:e.uuid,A=[];let a;switch(xt[r.path]===xt.weights?e.traverse((function(e){e.morphTargetInfluences&&A.push(e.name?e.name:e.uuid)})):A.push(s),xt[r.path]){case xt.weights:a=Ae;break;case xt.rotation:a=ae;break;case xt.position:case xt.scale:a=se;break;default:if(1===i.itemSize)a=Ae;else a=se}const l=void 0!==n.interpolation?Qt[n.interpolation]:re,c=this._getArrayFromAccessor(i);for(let e=0,i=A.length;e<i;e++){const i=new a(A[e]+"."+xt[r.path],t.array,c,l);"CUBICSPLINE"===n.interpolation&&this._createCubicSplineTrackInterpolant(i),o.push(i)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=getNormalizedComponentScale(t.constructor),i=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n++)i[n]=t[n]*e;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function InterpolantFactoryMethodGLTFCubicSpline(e){return new(this instanceof ae?GLTFCubicSplineQuaternionInterpolant:GLTFCubicSplineInterpolant)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function addPrimitiveAttributes(e,t,i){const n=t.attributes,r=[];function assignAttributeAccessor(t,n){return i.getDependency("accessor",t).then((function(t){e.setAttribute(n,t)}))}for(const t in n){const i=Et[t]||t.toLowerCase();i in e.attributes||r.push(assignAttributeAccessor(n[t],i))}if(void 0!==t.indices&&!e.index){const n=i.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));r.push(n)}return le.workingColorSpace!==c&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${le.workingColorSpace}" not supported.`),assignExtrasToUserData(e,t),function computeBounds(e,t,i){const n=t.attributes,r=new he;if(void 0===n.POSITION)return;{const e=i.json.accessors[n.POSITION],t=e.min,o=e.max;if(void 0===t||void 0===o)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(r.set(new f(t[0],t[1],t[2]),new f(o[0],o[1],o[2])),e.normalized){const t=getNormalizedComponentScale(bt[e.componentType]);r.min.multiplyScalar(t),r.max.multiplyScalar(t)}}const o=t.targets;if(void 0!==o){const e=new f,t=new f;for(let n=0,r=o.length;n<r;n++){const r=o[n];if(void 0!==r.POSITION){const n=i.json.accessors[r.POSITION],o=n.min,s=n.max;if(void 0!==o&&void 0!==s){if(t.setX(Math.max(Math.abs(o[0]),Math.abs(s[0]))),t.setY(Math.max(Math.abs(o[1]),Math.abs(s[1]))),t.setZ(Math.max(Math.abs(o[2]),Math.abs(s[2]))),n.normalized){const e=getNormalizedComponentScale(bt[n.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(e)}e.boundingBox=r;const s=new ge;r.getCenter(s.center),s.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=s}(e,t,i),Promise.all(r).then((function(){return void 0!==t.targets?function addMorphTargets(e,t,i){let n=!1,r=!1,o=!1;for(let e=0,i=t.length;e<i;e++){const i=t[e];if(void 0!==i.POSITION&&(n=!0),void 0!==i.NORMAL&&(r=!0),void 0!==i.COLOR_0&&(o=!0),n&&r&&o)break}if(!n&&!r&&!o)return Promise.resolve(e);const s=[],A=[],a=[];for(let l=0,c=t.length;l<c;l++){const c=t[l];if(n){const t=void 0!==c.POSITION?i.getDependency("accessor",c.POSITION):e.attributes.position;s.push(t)}if(r){const t=void 0!==c.NORMAL?i.getDependency("accessor",c.NORMAL):e.attributes.normal;A.push(t)}if(o){const t=void 0!==c.COLOR_0?i.getDependency("accessor",c.COLOR_0):e.attributes.color;a.push(t)}}return Promise.all([Promise.all(s),Promise.all(A),Promise.all(a)]).then((function(t){const i=t[0],s=t[1],A=t[2];return n&&(e.morphAttributes.position=i),r&&(e.morphAttributes.normal=s),o&&(e.morphAttributes.color=A),e.morphTargetsRelative=!0,e}))}(e,t.targets,i):e}))}const St=new WeakMap;class DRACOLoader extends r{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,n){const r=new s(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,(e=>{this.parse(e,t,n)}),i,n)}parse(e,t,i=()=>{}){this.decodeDracoFile(e,t,null,null,p,i).catch(i)}decodeDracoFile(e,t,i,n,r=c,o=()=>{}){const s={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:r};return this.decodeGeometry(e,s).then(t).catch(o)}decodeGeometry(e,t){const i=JSON.stringify(t);if(St.has(e)){const t=St.get(e);if(t.key===i)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n;const r=this.workerNextTaskID++,o=e.byteLength,s=this._getWorker(r,o).then((i=>(n=i,new Promise(((i,o)=>{n._callbacks[r]={resolve:i,reject:o},n.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return s.catch((()=>!0)).then((()=>{n&&r&&this._releaseTask(n,r)})),St.set(e,{key:i,promise:s}),s}_createGeometry(e){const t=new X;e.index&&t.setIndex(new E(e.index.array,1));for(let i=0;i<e.attributes.length;i++){const n=e.attributes[i],r=n.name,o=n.array,s=n.itemSize,A=new E(o,s);"color"===r&&(this._assignVertexColorSpace(A,n.vertexColorSpace),A.normalized=o instanceof Float32Array==!1),t.setAttribute(r,A)}return t}_assignVertexColorSpace(e,t){if(t!==p)return;const i=new l;for(let t=0,n=e.count;t<n;t++)i.fromBufferAttribute(e,t).convertSRGBToLinear(),e.setXYZ(t,i.r,i.g,i.b)}_loadLibrary(e,t){const i=new s(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise(((t,n)=>{i.load(e,t,void 0,n)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const i=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const n=DRACOWorker.toString(),r=["/* draco decoder */",i,"","/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const i=t.data;switch(i.type){case"decode":e._callbacks[i.id].resolve(i);break;case"error":e._callbacks[i.id].reject(i);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+i.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}function DRACOWorker(){let e,t;function decodeAttribute(e,t,i,n,r,o){const s=o.num_components(),A=i.num_points()*s,a=A*r.BYTES_PER_ELEMENT,l=function getDracoDataType(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,r),c=e._malloc(a);t.GetAttributeDataArrayForAllPoints(i,o,l,a,c);const p=new r(e.HEAPF32.buffer,c,A).slice();return e._free(c),{name:n,array:p,itemSize:s}}onmessage=function(i){const n=i.data;switch(n.type){case"init":e=n.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const i=n.buffer,r=n.taskConfig;t.then((e=>{const t=e.draco,o=new t.Decoder;try{const e=function decodeGeometry(e,t,i,n){const r=n.attributeIDs,o=n.attributeTypes;let s,A;const a=t.GetEncodedGeometryType(i);if(a===e.TRIANGULAR_MESH)s=new e.Mesh,A=t.DecodeArrayToMesh(i,i.byteLength,s);else{if(a!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");s=new e.PointCloud,A=t.DecodeArrayToPointCloud(i,i.byteLength,s)}if(!A.ok()||0===s.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+A.error_msg());const l={index:null,attributes:[]};for(const i in r){const A=self[o[i]];let a,c;if(n.useUniqueIDs)c=r[i],a=t.GetAttributeByUniqueId(s,c);else{if(c=t.GetAttributeId(s,e[r[i]]),-1===c)continue;a=t.GetAttribute(s,c)}const p=decodeAttribute(e,t,s,i,A,a);"color"===i&&(p.vertexColorSpace=n.vertexColorSpace),l.attributes.push(p)}a===e.TRIANGULAR_MESH&&(l.index=function decodeIndex(e,t,i){const n=i.num_faces(),r=3*n,o=4*r,s=e._malloc(o);t.GetTrianglesUInt32Array(i,o,s);const A=new Uint32Array(e.HEAPF32.buffer,s,r).slice();return e._free(s),{array:A,itemSize:1}}(e,t,s));return e.destroy(s),l}(t,o,new Int8Array(i),r),s=e.attributes.map((e=>e.array.buffer));e.index&&s.push(e.index.array.buffer),self.postMessage({type:"decode",id:n.id,geometry:e},s)}catch(e){console.error(e),self.postMessage({type:"error",id:n.id,error:e.message})}finally{t.destroy(o)}}))}}}class WorkerPool{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const i=this.workersResolve[e];if(i&&i(t),this.queue.length){const{resolve:t,msg:i,transfer:n}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(i,n)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise((i=>{const n=this._getIdleWorker();-1!==n?(this._initWorker(n),this.workerStatus|=1<<n,this.workersResolve[n]=i,this.workers[n].postMessage(e,t)):this.queue.push({resolve:i,msg:e,transfer:t})}))}dispose(){this.workers.forEach((e=>e.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const Lt=9,Mt=15,Tt=16,_t=22,Ft=37,kt=43,Rt=76,Nt=83,Gt=97,Ot=100,Yt=103,Ut=109,Xt=165,qt=166;class Si{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class Ii{constructor(e,t,i,n){this._dataView=new DataView(e.buffer,e.byteOffset+t,i),this._littleEndian=n,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_nextInt32(){const e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_skip(e){return this._offset+=e,this}_scan(e,t=0){const i=this._offset;let n=0;for(;this._dataView.getUint8(this._offset)!==t&&n<e;)n++,this._offset++;return n<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+i,n)}}const Ht=[171,75,84,88,32,50,48,187,13,10,26,10];function Ei(e){return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(e):Buffer.from(e).toString("utf8")}let zt,jt,Jt;const Wt={env:{emscripten_notify_memory_growth:function(e){Jt=new Uint8Array(jt.exports.memory.buffer)}}};class Q{init(){return zt||(zt="undefined"!=typeof fetch?fetch("data:application/wasm;base64,"+Kt).then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,Wt))).then(this._init):WebAssembly.instantiate(Buffer.from(Kt,"base64"),Wt).then(this._init),zt)}_init(e){jt=e.instance,Wt.env.emscripten_notify_memory_growth(0)}decode(e,t=0){if(!jt)throw new Error("ZSTDDecoder: Await .init() before decoding.");const i=e.byteLength,n=jt.exports.malloc(i);Jt.set(e,n),t=t||Number(jt.exports.ZSTD_findDecompressedSize(n,i));const r=jt.exports.malloc(t),o=jt.exports.ZSTD_decompress(r,t,n,i),s=Jt.slice(r,r+o);return jt.exports.free(n),jt.exports.free(r),s}}const Kt="AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIAAgASABIAJrIANBA3YiBCABIARrIAJJIgEbIgJrIgQ2AgggACADIAJBA3RrNgIEIAAgBCgAADYCAAsgAQsUAQF/IAAgARACIQIgACABEAEgAgv3AQECfyACRQRAIABCADcCACAAQQA2AhAgAEIANwIIQbh/DwsgACABNgIMIAAgAUEEajYCECACQQRPBEAgACABIAJqIgFBfGoiAzYCCCAAIAMoAAA2AgAgAUF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EAgACACaxAdQX9GDQMLAkBBhCAoAgAiAUUEQEGAICAANgIADAELIAAgATYCBAtBhCAgADYCACAAIANBAXRBAXI2AgAMAQsgAEUNAQsgAEEIaiEBCyABC7kDAQJ/IAAgA2ohBQJAIANBB0wEQANAIAAgBU8NAiAAIAItAAA6AAAgAEEBaiEAIAJBAWohAgwAAAsACyAEQQFGBEACQCAAIAJrIgZBB00EQCAAIAItAAA6AAAgACACLQABOgABIAAgAi0AAjoAAiAAIAItAAM6AAMgAEEEaiACIAZBAnQiBkHAHmooAgBqIgIQFyACIAZB4B5qKAIAayECDAELIAAgAhAMCyACQQhqIQIgAEEIaiEACwJAAkACQAJAIAUgAU0EQCAAIANqIQEgBEEBRyAAIAJrQQ9Kcg0BA0AgACACEAwgAkEIaiECIABBCGoiACABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgt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hqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY0AAQMyIFEAMiBg0AIANBHzYCfCADIANB/ABqIANB+ABqIAQgBCAFaiAGGyIEIAEgAmoiAiAEaxAVIgUQAw0AIAMoAnwiBkEfSw0AIAMoAngiB0EJTw0AIABBiCBqIAMgBkGAC0GADCAHEBggA0E0NgJ8IAMgA0H8AGogA0H4AGogBCAFaiIEIAIgBGsQFSIFEAMNACADKAJ8IgZBNEsNACADKAJ4IgdBCk8NACAAQZAwaiADIAZBgA1B4A4gBxAYIANBIzYCfCADIANB/ABqIANB+ABqIAQgBWoiBC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gIMIAYgBDYCCEG4fyEHIAQNASAIIAFrIQcMAQsgBiADNgIMIAYgBDYCCAsgBkEQaiQAIAcLRgECfyABIAAoArjgASICRwRAIAAgAjYCxOABIAAgATYCuOABIAAoArzgASEDIAAgATYCvOABIAAgASADIAJrajYCwOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQA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HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ",Vt=new WeakMap;let Zt,$t=0;class KTX2Loader extends r{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new WorkerPool,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}async detectSupportAsync(e){return this.workerConfig={astcSupported:await e.hasFeatureAsync("texture-compression-astc"),etc1Supported:await e.hasFeatureAsync("texture-compression-etc1"),etc2Supported:await e.hasFeatureAsync("texture-compression-etc2"),dxtSupported:await e.hasFeatureAsync("texture-compression-bc"),bptcSupported:await e.hasFeatureAsync("texture-compression-bptc"),pvrtcSupported:await e.hasFeatureAsync("texture-compression-pvrtc")},this}detectSupport(e){return!0===e.isWebGPURenderer?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),etc1Supported:e.hasFeature("texture-compression-etc1"),etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-bc"),bptcSupported:e.hasFeature("texture-compression-bptc"),pvrtcSupported:e.hasFeature("texture-compression-pvrtc")}:this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},this}init(){if(!this.transcoderPending){const e=new s(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),i=new s(this.manager);i.setPath(this.transcoderPath),i.setResponseType("arraybuffer"),i.setWithCredentials(this.withCredentials);const n=i.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,n]).then((([e,t])=>{const i=KTX2Loader.BasisWorker.toString(),n=["/* constants */","let _EngineFormat = "+JSON.stringify(KTX2Loader.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(KTX2Loader.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(KTX2Loader.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([n])),this.transcoderBinary=t,this.workerPool.setWorkerCreator((()=>{const e=new Worker(this.workerSourceURL),t=this.transcoderBinary.slice(0);return e.postMessage({type:"init",config:this.workerConfig,transcoderBinary:t},[t]),e}))})),$t>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),$t++}return this.transcoderPending}load(e,t,i,n){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new s(this.manager);r.setResponseType("arraybuffer"),r.setWithCredentials(this.withCredentials),r.load(e,(e=>{this.parse(e,t,n)}),i,n)}parse(e,t,i){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(Vt.has(e)){return Vt.get(e).promise.then(t).catch(i)}this._createTexture(e).then((e=>t?t(e):null)).catch(i)}_createTextureFrom(e,t){const{faces:i,width:n,height:r,format:o,type:s,error:A,dfdFlags:a}=e;if("error"===s)return Promise.reject(A);let l;if(6===t.faceCount)l=new ue(i,o,de);else{const e=i[0].mipmaps;l=t.layerCount>1?new fe(e,n,r,t.layerCount,o,de):new Ie(e,n,r,o,de)}return l.minFilter=1===i[0].mipmaps.length?L:w,l.magFilter=L,l.generateMipmaps=!1,l.needsUpdate=!0,l.colorSpace=parseColorSpace(t),l.premultiplyAlpha=!!(1&a),l}async _createTexture(e,t={}){const i=function Pi(e){const t=new Uint8Array(e.buffer,e.byteOffset,Ht.length);if(t[0]!==Ht[0]||t[1]!==Ht[1]||t[2]!==Ht[2]||t[3]!==Ht[3]||t[4]!==Ht[4]||t[5]!==Ht[5]||t[6]!==Ht[6]||t[7]!==Ht[7]||t[8]!==Ht[8]||t[9]!==Ht[9]||t[10]!==Ht[10]||t[11]!==Ht[11])throw new Error("Missing KTX 2.0 identifier.");const i=new Si,n=17*Uint32Array.BYTES_PER_ELEMENT,r=new Ii(e,Ht.length,n,!0);i.vkFormat=r._nextUint32(),i.typeSize=r._nextUint32(),i.pixelWidth=r._nextUint32(),i.pixelHeight=r._nextUint32(),i.pixelDepth=r._nextUint32(),i.layerCount=r._nextUint32(),i.faceCount=r._nextUint32();const o=r._nextUint32();i.supercompressionScheme=r._nextUint32();const s=r._nextUint32(),A=r._nextUint32(),a=r._nextUint32(),l=r._nextUint32(),c=r._nextUint64(),p=r._nextUint64(),h=new Ii(e,Ht.length+n,3*o*8,!0);for(let t=0;t<o;t++)i.levels.push({levelData:new Uint8Array(e.buffer,e.byteOffset+h._nextUint64(),h._nextUint64()),uncompressedByteLength:h._nextUint64()});const g=new Ii(e,s,A,!0),u={vendorId:g._skip(4)._nextUint16(),descriptorType:g._nextUint16(),versionNumber:g._nextUint16(),descriptorBlockSize:g._nextUint16(),colorModel:g._nextUint8(),colorPrimaries:g._nextUint8(),transferFunction:g._nextUint8(),flags:g._nextUint8(),texelBlockDimension:[g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8()],bytesPlane:[g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8()],samples:[]},d=(u.descriptorBlockSize/4-6)/4;for(let e=0;e<d;e++){const t={bitOffset:g._nextUint16(),bitLength:g._nextUint8(),channelType:g._nextUint8(),samplePosition:[g._nextUint8(),g._nextUint8(),g._nextUint8(),g._nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&t.channelType?(t.sampleLower=g._nextInt32(),t.sampleUpper=g._nextInt32()):(t.sampleLower=g._nextUint32(),t.sampleUpper=g._nextUint32()),u.samples[e]=t}i.dataFormatDescriptor.length=0,i.dataFormatDescriptor.push(u);const f=new Ii(e,a,l,!0);for(;f._offset<l;){const e=f._nextUint32(),t=f._scan(e),n=Ei(t),r=f._scan(e-t.byteLength);i.keyValue[n]=n.match(/^ktx/i)?Ei(r):r,f._offset%4&&f._skip(4-f._offset%4)}if(p<=0)return i;const I=new Ii(e,c,p,!0),m=I._nextUint16(),b=I._nextUint16(),C=I._nextUint32(),B=I._nextUint32(),y=I._nextUint32(),E=I._nextUint32(),x=[];for(let e=0;e<o;e++)x.push({imageFlags:I._nextUint32(),rgbSliceByteOffset:I._nextUint32(),rgbSliceByteLength:I._nextUint32(),alphaSliceByteOffset:I._nextUint32(),alphaSliceByteLength:I._nextUint32()});const P=c+I._offset,w=P+C,v=w+B,D=v+y,S=new Uint8Array(e.buffer,e.byteOffset+P,C),L=new Uint8Array(e.buffer,e.byteOffset+w,B),M=new Uint8Array(e.buffer,e.byteOffset+v,y),T=new Uint8Array(e.buffer,e.byteOffset+D,E);return i.globalData={endpointCount:m,selectorCount:b,imageDescs:x,endpointsData:S,selectorsData:L,tablesData:M,extendedData:T},i}(new Uint8Array(e));if(0!==i.vkFormat)return async function createRawTexture(e){const{vkFormat:t}=e;if(void 0===ti[t])throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");let i;2===e.supercompressionScheme&&(Zt||(Zt=new Promise((async e=>{const t=new Q;await t.init(),e(t)}))),i=await Zt);const n=[];for(let r=0;r<e.levels.length;r++){const o=Math.max(1,e.pixelWidth>>r),s=Math.max(1,e.pixelHeight>>r),A=e.pixelDepth?Math.max(1,e.pixelDepth>>r):0,a=e.levels[r];let l,c;if(0===e.supercompressionScheme)l=a.levelData;else{if(2!==e.supercompressionScheme)throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");l=i.decode(a.levelData,a.uncompressedByteLength)}c=ii[t]===Pe?new Float32Array(l.buffer,l.byteOffset,l.byteLength/Float32Array.BYTES_PER_ELEMENT):ii[t]===Qe?new Uint16Array(l.buffer,l.byteOffset,l.byteLength/Uint16Array.BYTES_PER_ELEMENT):l,n.push({data:c,width:o,height:s,depth:A})}let r;if(ei.has(ti[t]))r=0===e.pixelDepth?new we(n[0].data,e.pixelWidth,e.pixelHeight):new ve(n[0].data,e.pixelWidth,e.pixelHeight,e.pixelDepth);else{if(e.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");r=new Ie(n,e.pixelWidth,e.pixelHeight)}return r.mipmaps=n,r.type=ii[t],r.format=ti[t],r.colorSpace=parseColorSpace(e),r.needsUpdate=!0,Promise.resolve(r)}(i);const n=t,r=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:n},[e]))).then((e=>this._createTextureFrom(e.data,i)));return Vt.set(e,{promise:r}),r}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),$t--,this}}KTX2Loader.BasisFormat={ETC1S:0,UASTC_4x4:1},KTX2Loader.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},KTX2Loader.EngineFormat={RGBAFormat:xe,RGBA_ASTC_4x4_Format:Re,RGBA_BPTC_Format:ke,RGBA_ETC2_EAC_Format:Fe,RGBA_PVRTC_4BPPV1_Format:_e,RGBA_S3TC_DXT5_Format:Te,RGB_ETC1_Format:Me,RGB_ETC2_Format:Le,RGB_PVRTC_4BPPV1_Format:Se,RGBA_S3TC_DXT1_Format:De},KTX2Loader.BasisWorker=function(){let e,t,i;const n=_EngineFormat,r=_TranscoderFormat,o=_BasisFormat;self.addEventListener("message",(function(s){const l=s.data;switch(l.type){case"init":e=l.config,function init(e){t=new Promise((t=>{i={wasmBinary:e,onRuntimeInitialized:t},BASIS(i)})).then((()=>{i.initializeBasis(),void 0===i.KTX2File&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")}))}(l.transcoderBinary);break;case"transcode":t.then((()=>{try{const{faces:t,buffers:s,width:c,height:p,hasAlpha:h,format:g,dfdFlags:u}=function transcode(t){const s=new i.KTX2File(new Uint8Array(t));function cleanup(){s.close(),s.delete()}if(!s.isValid())throw cleanup(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");const l=s.isUASTC()?o.UASTC_4x4:o.ETC1S,c=s.getWidth(),p=s.getHeight(),h=s.getLayers()||1,g=s.getLevels(),u=s.getFaces(),d=s.getHasAlpha(),f=s.getDFDFlags(),{transcoderFormat:I,engineFormat:m}=function getTranscoderFormat(t,i,s,l){let c,p;const h=t===o.ETC1S?A:a;for(let n=0;n<h.length;n++){const r=h[n];if(e[r.if]&&(r.basisFormat.includes(t)&&!(l&&r.transcoderFormat.length<2)&&(!r.needsPowerOfTwo||isPowerOfTwo(i)&&isPowerOfTwo(s))))return c=r.transcoderFormat[l?1:0],p=r.engineFormat[l?1:0],{transcoderFormat:c,engineFormat:p}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),c=r.RGBA32,p=n.RGBAFormat,{transcoderFormat:c,engineFormat:p}}(l,c,p,d);if(!c||!p||!g)throw cleanup(),new Error("THREE.KTX2Loader:\tInvalid texture");if(!s.startTranscoding())throw cleanup(),new Error("THREE.KTX2Loader: .startTranscoding failed");const b=[],C=[];for(let e=0;e<u;e++){const t=[];for(let i=0;i<g;i++){const n=[];let r,o;for(let t=0;t<h;t++){const A=s.getImageLevelInfo(i,t,e);0!==e||0!==i||0!==t||A.origWidth%4==0&&A.origHeight%4==0||console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),g>1?(r=A.origWidth,o=A.origHeight):(r=A.width,o=A.height);const a=new Uint8Array(s.getImageTranscodedSizeInBytes(i,t,0,I));if(!s.transcodeImage(a,i,t,e,I,0,-1,-1))throw cleanup(),new Error("THREE.KTX2Loader: .transcodeImage failed.");n.push(a)}const A=concat(n);t.push({data:A,width:r,height:o}),C.push(A.buffer)}b.push({mipmaps:t,width:c,height:p,format:m})}return cleanup(),{faces:b,buffers:C,width:c,height:p,hasAlpha:d,format:m,dfdFlags:f}}(l.buffer);self.postMessage({type:"transcode",id:l.id,faces:t,width:c,height:p,hasAlpha:h,format:g,dfdFlags:u},s)}catch(e){console.error(e),self.postMessage({type:"error",id:l.id,error:e.message})}}))}}));const s=[{if:"astcSupported",basisFormat:[o.UASTC_4x4],transcoderFormat:[r.ASTC_4x4,r.ASTC_4x4],engineFormat:[n.RGBA_ASTC_4x4_Format,n.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[o.ETC1S,o.UASTC_4x4],transcoderFormat:[r.BC7_M5,r.BC7_M5],engineFormat:[n.RGBA_BPTC_Format,n.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[o.ETC1S,o.UASTC_4x4],transcoderFormat:[r.BC1,r.BC3],engineFormat:[n.RGBA_S3TC_DXT1_Format,n.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[o.ETC1S,o.UASTC_4x4],transcoderFormat:[r.ETC1,r.ETC2],engineFormat:[n.RGB_ETC2_Format,n.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[o.ETC1S,o.UASTC_4x4],transcoderFormat:[r.ETC1],engineFormat:[n.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[o.ETC1S,o.UASTC_4x4],transcoderFormat:[r.PVRTC1_4_RGB,r.PVRTC1_4_RGBA],engineFormat:[n.RGB_PVRTC_4BPPV1_Format,n.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],A=s.sort((function(e,t){return e.priorityETC1S-t.priorityETC1S})),a=s.sort((function(e,t){return e.priorityUASTC-t.priorityUASTC}));function isPowerOfTwo(e){return e<=2||!(e&e-1)&&0!==e}function concat(e){if(1===e.length)return e[0];let t=0;for(let i=0;i<e.length;i++){t+=e[i].byteLength}const i=new Uint8Array(t);let n=0;for(let t=0;t<e.length;t++){const r=e[t];i.set(r,n),n+=r.byteLength}return i}};const ei=new Set([xe,Ee,ye]),ti={[Ut]:xe,[Gt]:xe,[Ft]:xe,[kt]:xe,[Yt]:Ee,[Nt]:Ee,[Tt]:Ee,[_t]:Ee,[Ot]:ye,[Rt]:ye,[Mt]:ye,[Lt]:ye,[qt]:Be,[Xt]:Be},ii={[Ut]:Pe,[Gt]:Qe,[Ft]:de,[kt]:de,[Yt]:Pe,[Nt]:Qe,[Tt]:de,[_t]:de,[Ot]:Pe,[Rt]:Qe,[Mt]:de,[Lt]:de,[qt]:de,[Xt]:de};function parseColorSpace(e){const t=e.dataFormatDescriptor[0];return 1===t.colorPrimaries?2===t.transferFunction?p:c:10===t.colorPrimaries?2===t.transferFunction?me:be:(0===t.colorPrimaries||console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${t.colorPrimaries}"`),Ce)}var ni=function(){var e=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),t=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if("object"!=typeof WebAssembly)return{supported:!1};var i,n=WebAssembly.validate(e)?"b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopbl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8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb":"b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb",r=WebAssembly.instantiate(unpack(n),{}).then((function(e){(i=e.instance).exports.__wasm_call_ctors()}));function unpack(e){for(var i=new Uint8Array(e.length),n=0;n<e.length;++n){var r=e.charCodeAt(n);i[n]=r>96?r-97:r>64?r-39:r+4}var o=0;for(n=0;n<e.length;++n)i[o++]=i[n]<60?t[i[n]]:64*(i[n]-60)+i[++n];return i.buffer.slice(0,o)}function decode(e,t,n,r,o,s){var A=i.exports.sbrk,a=n+3&-4,l=A(a*r),c=A(o.length),p=new Uint8Array(i.exports.memory.buffer);p.set(o,c);var h=e(l,n,r,c,o.length);if(0==h&&s&&s(l,a,r),t.set(p.subarray(l,l+n*r)),A(l-A(0)),0!=h)throw new Error("Malformed buffer data: "+h)}var o={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},s={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},A=[],a=0;function createWorker(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var i=e.data;t.pending-=i.count,t.requests[i.id][i.action](i.value),delete t.requests[i.id]},t}function initWorkers(e){for(var t="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(unpack(n))+"]), {}).then(function(result) { instance = result.instance; instance.exports.__wasm_call_ctors(); });self.onmessage = workerProcess;"+decode.toString()+workerProcess.toString(),i=new Blob([t],{type:"text/javascript"}),r=URL.createObjectURL(i),o=0;o<e;++o)A[o]=createWorker(r);URL.revokeObjectURL(r)}function workerProcess(e){r.then((function(){var t=e.data;try{var n=new Uint8Array(t.count*t.size);decode(i.exports[t.mode],n,t.count,t.size,t.source,i.exports[t.filter]),self.postMessage({id:t.id,count:t.count,action:"resolve",value:n},[n.buffer])}catch(e){self.postMessage({id:t.id,count:t.count,action:"reject",value:e})}}))}return{ready:r,supported:!0,useWorkers:function(e){initWorkers(e)},decodeVertexBuffer:function(e,t,n,r,s){decode(i.exports.meshopt_decodeVertexBuffer,e,t,n,r,i.exports[o[s]])},decodeIndexBuffer:function(e,t,n,r){decode(i.exports.meshopt_decodeIndexBuffer,e,t,n,r)},decodeIndexSequence:function(e,t,n,r){decode(i.exports.meshopt_decodeIndexSequence,e,t,n,r)},decodeGltfBuffer:function(e,t,n,r,A,a){decode(i.exports[s[A]],e,t,n,r,i.exports[o[a]])},decodeGltfBufferAsync:function(e,t,n,l,c){return A.length>0?function decodeWorker(e,t,i,n,r){for(var o=A[0],s=1;s<A.length;++s)A[s].pending<o.pending&&(o=A[s]);return new Promise((function(s,A){var l=new Uint8Array(i),c=a++;o.pending+=e,o.requests[c]={resolve:s,reject:A},o.object.postMessage({id:c,count:e,size:t,source:l,mode:n,filter:r},[l.buffer])}))}(e,t,n,s[l],o[c]):r.then((function(){var r=new Uint8Array(e*t);return decode(i.exports[s[l]],r,e,t,n,i.exports[o[c]]),r}))}}}();class TDSLoader extends r{constructor(e){super(e),this.debug=!1,this.group=null,this.materials=[],this.meshes=[]}load(e,t,i,n){const r=this,A=""===this.path?o.extractUrlBase(e):this.path,a=new s(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(i){try{t(r.parse(i,A))}catch(t){n?n(t):console.error(t),r.manager.itemError(e)}}),i,n)}parse(e,t){this.group=new K,this.materials=[],this.meshes=[],this.readFile(e,t);for(let e=0;e<this.meshes.length;e++)this.group.add(this.meshes[e]);return this.group}readFile(e,t){const i=new DataView(e),n=new Chunk(i,0,this.debugMessage);if(n.id===oi||n.id===si||n.id===ri){let e=n.readChunk();for(;e;){if(e.id===Ai){const t=e.readDWord();this.debugMessage("3DS file version: "+t)}else e.id===ui?this.readMeshData(e,t):this.debugMessage("Unknown main chunk: "+e.hexId);e=n.readChunk()}}this.debugMessage("Parsed "+this.meshes.length+" meshes")}readMeshData(e,t){let i=e.readChunk();for(;i;){if(i.id===di){const e=+i.readDWord();this.debugMessage("Mesh Version: "+e)}else if(i.id===fi){const e=i.readFloat();this.debugMessage("Master scale: "+e),this.group.scale.set(e,e,e)}else i.id===Yi?(this.debugMessage("Named Object"),this.readNamedObject(i)):i.id===mi?(this.debugMessage("Material"),this.readMaterialEntry(i,t)):this.debugMessage("Unknown MDATA chunk: "+i.hexId);i=e.readChunk()}}readNamedObject(e){const t=e.readString();let i=e.readChunk();for(;i;){if(i.id===Ui){const e=this.readMesh(i);e.name=t,this.meshes.push(e)}else this.debugMessage("Unknown named object chunk: "+i.hexId);i=e.readChunk()}}readMaterialEntry(e,t){let i=e.readChunk();const n=new Ne;for(;i;){if(i.id===bi)n.name=i.readString(),this.debugMessage(" Name: "+n.name);else if(i.id===Di)this.debugMessage(" Wireframe"),n.wireframe=!0;else if(i.id===Li){const e=i.readByte();n.wireframeLinewidth=e,this.debugMessage(" Wireframe Thickness: "+e)}else if(i.id===wi)n.side=O,this.debugMessage(" DoubleSided");else if(i.id===vi)this.debugMessage(" Additive Blending"),n.blending=Ge;else if(i.id===Bi)this.debugMessage(" Diffuse Color"),n.color=this.readColor(i);else if(i.id===yi)this.debugMessage(" Specular Color"),n.specular=this.readColor(i);else if(i.id===Ci)this.debugMessage(" Ambient color"),n.color=this.readColor(i);else if(i.id===xi){const e=this.readPercentage(i);n.shininess=100*e,this.debugMessage(" Shininess : "+e)}else if(i.id===Qi){const e=this.readPercentage(i);n.opacity=1-e,this.debugMessage(" Transparency : "+e),n.transparent=n.opacity<1}else i.id===Mi?(this.debugMessage(" ColorMap"),n.map=this.readMap(i,t)):i.id===_i?(this.debugMessage(" BumpMap"),n.bumpMap=this.readMap(i,t)):i.id===Ti?(this.debugMessage(" OpacityMap"),n.alphaMap=this.readMap(i,t)):i.id===Fi?(this.debugMessage(" SpecularMap"),n.specularMap=this.readMap(i,t)):this.debugMessage(" Unknown material chunk: "+i.hexId);i=e.readChunk()}this.materials[n.name]=n}readMesh(e){let t=e.readChunk();const i=new X,n=new Ne,r=new H(i,n);for(r.name="mesh";t;){if(t.id===Xi){const e=t.readWord();this.debugMessage(" Vertex: "+e);const n=[];for(let i=0;i<e;i++)n.push(t.readFloat()),n.push(t.readFloat()),n.push(t.readFloat());i.setAttribute("position",new Oe(n,3))}else if(t.id===qi)this.readFaceArray(t,r);else if(t.id===zi){const e=t.readWord();this.debugMessage(" UV: "+e);const n=[];for(let i=0;i<e;i++)n.push(t.readFloat()),n.push(t.readFloat());i.setAttribute("uv",new Oe(n,2))}else if(t.id===ji){this.debugMessage(" Tranformation Matrix (TODO)");const e=[];for(let i=0;i<12;i++)e[i]=t.readFloat();const n=new d;n.elements[0]=e[0],n.elements[1]=e[6],n.elements[2]=e[3],n.elements[3]=e[9],n.elements[4]=e[2],n.elements[5]=e[8],n.elements[6]=e[5],n.elements[7]=e[11],n.elements[8]=e[1],n.elements[9]=e[7],n.elements[10]=e[4],n.elements[11]=e[10],n.elements[12]=0,n.elements[13]=0,n.elements[14]=0,n.elements[15]=1,n.transpose();const o=new d;o.copy(n).invert(),i.applyMatrix4(o),n.decompose(r.position,r.quaternion,r.scale)}else this.debugMessage(" Unknown mesh chunk: "+t.hexId);t=e.readChunk()}return i.computeVertexNormals(),r}readFaceArray(e,t){const i=e.readWord();this.debugMessage(" Faces: "+i);const n=[];for(let t=0;t<i;++t)n.push(e.readWord(),e.readWord(),e.readWord()),e.readWord();t.geometry.setIndex(n);let r=0,o=0;for(;!e.endOfChunk;){const i=e.readChunk();if(i.id===Hi){this.debugMessage(" Material Group");const e=this.readMaterialGroup(i),n=3*e.index.length;t.geometry.addGroup(o,n,r),o+=n,r++;const s=this.materials[e.name];!1===Array.isArray(t.material)&&(t.material=[]),void 0!==s&&t.material.push(s)}else this.debugMessage(" Unknown face array chunk: "+i.hexId)}1===t.material.length&&(t.material=t.material[0])}readMap(e,t){let i=e.readChunk(),n={};const r=new B(this.manager);for(r.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);i;){if(i.id===ki){const e=i.readString();n=r.load(e),n.userData.name=e.split(".").slice(0,-1).join("."),this.debugMessage(" File: "+t+e)}else i.id===Gi?(n.offset.x=i.readFloat(),this.debugMessage(" OffsetX: "+n.offset.x)):i.id===Oi?(n.offset.y=i.readFloat(),this.debugMessage(" OffsetY: "+n.offset.y)):i.id===Ri?(n.repeat.x=i.readFloat(),this.debugMessage(" RepeatX: "+n.repeat.x)):i.id===Ni?(n.repeat.y=i.readFloat(),this.debugMessage(" RepeatY: "+n.repeat.y)):this.debugMessage(" Unknown map chunk: "+i.hexId);i=e.readChunk()}return n}readMaterialGroup(e){const t=e.readString(),i=e.readWord();this.debugMessage(" Name: "+t),this.debugMessage(" Faces: "+i);const n=[];for(let t=0;t<i;++t)n.push(e.readWord());return{name:t,index:n}}readColor(e){const t=e.readChunk(),i=new l;if(t.id===li||t.id===ci){const e=t.readByte(),n=t.readByte(),r=t.readByte();i.setRGB(e/255,n/255,r/255),this.debugMessage(" Color: "+i.r+", "+i.g+", "+i.b)}else if(t.id===ai||t.id===pi){const e=t.readFloat(),n=t.readFloat(),r=t.readFloat();i.setRGB(e,n,r),this.debugMessage(" Color: "+i.r+", "+i.g+", "+i.b)}else this.debugMessage(" Unknown color chunk: "+t.hexId);return i}readPercentage(e){const t=e.readChunk();switch(t.id){case hi:return t.readShort()/100;case gi:return t.readFloat();default:return this.debugMessage(" Unknown percentage chunk: "+t.hexId),0}}debugMessage(e){this.debug&&console.log(e)}}class Chunk{constructor(e,t,i){this.data=e,this.offset=t,this.position=t,this.debugMessage=i,this.debugMessage instanceof Function&&(this.debugMessage=function(){}),this.id=this.readWord(),this.size=this.readDWord(),this.end=this.offset+this.size,this.end>e.byteLength&&this.debugMessage("Bad chunk size for chunk at "+t)}readChunk(){if(this.endOfChunk)return null;try{const e=new Chunk(this.data,this.position,this.debugMessage);return this.position+=e.size,e}catch(e){return this.debugMessage("Unable to read chunk at "+this.position),null}}get hexId(){return this.id.toString(16)}get endOfChunk(){return this.position>=this.end}readByte(){const e=this.data.getUint8(this.position,!0);return this.position+=1,e}readFloat(){try{const e=this.data.getFloat32(this.position,!0);return this.position+=4,e}catch(e){return this.debugMessage(e+" "+this.position+" "+this.data.byteLength),0}}readInt(){const e=this.data.getInt32(this.position,!0);return this.position+=4,e}readShort(){const e=this.data.getInt16(this.position,!0);return this.position+=2,e}readDWord(){const e=this.data.getUint32(this.position,!0);return this.position+=4,e}readWord(){const e=this.data.getUint16(this.position,!0);return this.position+=2,e}readString(){let e="",t=this.readByte();for(;t;)e+=String.fromCharCode(t),t=this.readByte();return e}}const ri=19789,oi=15786,si=49725,Ai=2,ai=16,li=17,ci=18,pi=19,hi=48,gi=49,ui=15677,di=15678,fi=256,mi=45055,bi=40960,Ci=40976,Bi=40992,yi=41008,xi=41024,Qi=41040,wi=41089,vi=41091,Di=41093,Li=41095,Mi=41472,Ti=41488,_i=41520,Fi=41476,ki=41728,Ri=41812,Ni=41814,Gi=41816,Oi=41818,Yi=16384,Ui=16640,Xi=16656,qi=16672,Hi=16688,zi=16704,ji=16736;const to_std=(t,i)=>{if(!t||"MeshPhongMaterial"!==t.type)return t;if(i){const e=i.get(t);if(e)return e}const n=1-("number"==typeof t.shininess?Math.min(Math.max(t.shininess,0),100):30)/100,r=new e.MeshStandardMaterial({name:t.name,color:t.color,map:t.map,normalMap:t.normalMap,emissive:t.emissive,emissiveMap:t.emissiveMap,envMap:t.envMap,envMapIntensity:t.envMapIntensity??1,lightMap:t.lightMap,lightMapIntensity:t.lightMapIntensity,alphaTest:t.alphaTest,depthWrite:t.depthWrite,depthTest:t.depthTest,wireframe:t.wireframe,transparent:t.transparent,opacity:t.opacity,side:t.side,roughness:n,metalness:0});return i&&i.set(t,r),"function"==typeof t.dispose&&(t.dispose(),t.userData=t.userData||{},t.userData._replaced=!0),r.needsUpdate=!0,r};function newgcad(t,i,n,r=!0){let o={},s={},A={},a={},l={};const c=new Map;let p={},h={},g=new e.TextureLoader,u=new GLTFLoader,d=new TDSLoader;const f=new DRACOLoader;f.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.6/"),u.setDRACOLoader(f);const I=new KTX2Loader;I.setTranscoderPath("https://unpkg.com/three@0.159.0/examples/jsm/libs/basis/"),u.setKTX2Loader(I),u.setMeshoptDecoder(ni);let m=[n],getcat=()=>m[m.length-1],b={};async function clearmat(){for(const e in s)if(s[e]){const t=await s[e];t?.dispose()}for(const e in p)p[e]&&p[e]?.dispose();for(const[e,t]of c.entries()){const e=t instanceof Promise?await t:t;e?.dispose&&e.dispose()}c.clear(),s={},p={}}function getdims(t){let i=(new e.Box3).setFromObject(t),n2=e=>Math.round(100*e)/100;return{zero:{x:n2(-i.min.x),y:n2(-i.min.y),z:n2(-i.min.z)},dim:{x:n2(i.max.x-i.min.x),y:n2(i.max.y-i.min.y),z:n2(i.max.z-i.min.z)},position:t.position,rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z},scale:t.scale}}async function get3ds(e){e.endsWith(".3ds")&&(e=e.slice(0,-4));const i=hash(`${getcat()}|${e}.3ds`);return A[i]||(A[i]=await new Promise(((n,r)=>{let o,s="";e.startsWith("https://")?(o=`${e}.3ds`,s=o):t._cdn?(o=`${t._cdn}${getcat()}/3d/${e}.3ds`,s=`${t._cdn}${getcat()}/3d/${e}/`):(o=t.fullget("mufiles/getfile",{id:getcat(),subfolder:"3d",name:e,ext:".3ds"}),s=o+"&tex="),d.setResourcePath(s),d.load(o,(e=>{const t=new WeakMap;e.traverse((e=>{e.isMesh&&e.material&&(e.material=Array.isArray(e.material)?e.material.map((e=>to_std(e,t))):to_std(e.material,t))})),e.userData||(e.userData={}),e.userData._ky=i,n(e)}),void 0,(e=>{console.log(e),delete A[i],n(void 0)}))}))),A[i]}async function getglb(e){const i=".glb";e.endsWith(i)&&(e=e.slice(0,-4)),e.startsWith("https://")||(e=e.replace(/\//g,"+"));let n=(e=e.split("+"))[1];e=e[0];const r=hash(`${getcat()}|${e}${i}`);A[r]||(A[r]=await new Promise(((n,o)=>{let s;s=e.startsWith("https://")?`${e}.glb`:t._cdn?`${t._cdn}${getcat()}/3d/${e}.glb`:t.fullget("mufiles/getfile",{id:getcat(),subfolder:"3d",name:e,ext:i}),u.setPath(""),u.setResourcePath((e=>(console.log("risorsa",e),`${s}&tex=${e}`))),u.load(s,(async e=>{const t=e.scene;t.userData||(t.userData={}),t.userData._ky=r,n(t)}),void 0,(e=>{console.log(e),delete A[r],n(void 0)}))})));let o=A[r];if(n){let e=o?.getObjectByName(n);e&&(o=e)}return o}return{clearmatricole:()=>{b={}},P:t,bus:i,tex:async function tex(i,n=1,r,o){let A;return r||(r=n),o||(o=0),"__alpha"==i?(A=i,s[A]||(s[A]=function getfortransparent(){const t=new e.CanvasTexture(function generateTexture(){const e=document.createElement("canvas");e.width=2,e.height=2;const t=e.getContext("2d");return t.fillStyle="white",t.fillRect(0,1,2,1),e}());return t.magFilter=e.NearestFilter,t.wrapT=e.RepeatWrapping,t.wrapS=e.RepeatWrapping,t.repeat.set(1,3.5),t}()),s[A]):(A=hash(`${getcat()}|${i}|${n}|${r}|${o}`),s[A]||(s[A]=new Promise(((a,l)=>{let p;if(i.startsWith("https://"))p=i;else if(t._cdn)if(i.includes("/")){let e=i.split("/");p=`${t._cdn}${e[0]}/textures/${e[1]}`}else p=`${t._cdn}${getcat()}/textures/${i}`;else p=t.fullget("mufiles/getfile",{id:getcat(),subfolder:"textures",name:i,force:1});if(c.has(p)){const t=c.get(p).clone();return t.wrapS=e.RepeatWrapping,t.wrapT=e.RepeatWrapping,t.center.set(.5,.5),t.repeat.set(n*lt,lt*r),t.rotation=o,void a(t)}g.load(p,(t=>{c.set(p,t),t.wrapS=e.RepeatWrapping,t.wrapT=e.RepeatWrapping,t.repeat.set(n*lt,lt*r),t.center.set(.5,.5),t.rotation=o,a(t)}),void 0,(e=>{console.log(`Manca Texture ${i}!. questo rallenta molto il processo`),delete s[A],a(void 0)}))}))),s[A])},getglb:getglb,get3ds:get3ds,replacemats:function replacemats(e,t,i){if(!Array.isArray(t)||0==t.length)return e;const leggi_slot=e=>{if(!e)return-1;let t=(e?.map?.name||e?.name||e?.map?.userData?.name||"").toString().trim();if(i){const e=i(t);void 0!==e&&(t=e)}if(t.includes("_")&&(t=t.split("_").pop()),!t)return-1;const n=parseInt(t,10);return n>=1&&n<=9?n:-1};let n=!1,r=String(e.userData?._ky||"");if(e.traverse((e=>{if(!e.isMesh)return;const i=Array.isArray(e.material)?e.material:[e.material];for(const e of i){const i=leggi_slot(e);i>0&&t[i-1]&&(n=!0,r+="|"+(t[i-1].name||t[i-1].uuid))}})),n){if(r=hash(r),A[r])return A[r];const i=e.clone(!0);i.traverse((e=>{if(e.isMesh)if(Array.isArray(e.material))e.material=e.material.map((e=>{if(!e)return e;const i=leggi_slot(e);if(i>0&&t[i-1]){const e=t[i-1];return e.needsUpdate=!0,e}return e}));else{const i=e.material,n=leggi_slot(i);e.material=n>0&&t[n-1]?(t[n-1].needsUpdate=!0,t[n-1]):i}})),i.userData=i.userData||{},i.userData._ky=r,A[r]=i,e=i}return e},islog:r,clear:async function clear(){function destroymesh(e){function disposeMaterial(e){e.map&&e.map.dispose(),e.lightMap&&e.lightMap.dispose(),e.bumpMap&&e.bumpMap.dispose(),e.normalMap&&e.normalMap.dispose(),e.specularMap&&e.specularMap.dispose(),e.dispose()}e&&e.traverse((e=>{e.isMesh&&(e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(disposeMaterial):disposeMaterial(e.material)))}))}b={},l={},e.Cache.clear();for(const e in a)a[e]?.dispose();for(const e in A)if(A[e]){destroymesh(await A[e])}await clearmat(),o={},s={},A={},a={},p={},h={}},clearmat:clearmat,getdims:getdims,info3d:async function info3d(e,t=1,i=0,n=0){let r=(e||"").endsWith(".3ds")?await get3ds(e):await getglb(e);if(r)return t&&1!=t&&(r.scale.set(t||1,i||t||1,n||t||1),r.needsUpdate=!0),getdims(r)},getScript:async function getScript(e){e.endsWith(".custom")?e=e.slice(0,-7):e.endsWith(".js")&&(e=e.slice(0,-3));let i=hash(`${getcat()}|${e}`);if(!h[i]){let n;try{n=await t.fetch("mufiles/customfn",{id:getcat(),name:e,ispar:1})}catch(t){n=`log('undefined ${getcat()}/${e}: ${t.message}');`}h[i]=n}return h[i]},checkScripts:async function checkScripts(e){let i=[];if(!e||!Array.isArray(e))return;let n=getcat();e=[...e,"_ricalcolatop","_ricalcolaaltri","_ricalcolalinee"];for(let t of e){let e=hash(`${n}|${t}`);h[e]||i.push(t)}if(i?.length){let e=await t.fetch("mufiles/customfn",{id:n,name:i,ispar:1});if(e)for(let t of e){let e=hash(`${n}|${t.n}`);h[e]=t.v}}},get loaderGLTF(){return u},get gmats(){return b},scripts:()=>Object.keys(h),get geo(){return a},get movs(){return o},get textures(){return s},get smats(){return p},get meshes(){return A},get cacheFns(){return l},dump(){console.log(`SMATS:\n${Object.keys(p).join(" - ")};\nGEOMS:\n${Object.keys(a).join(" - ")};\nTEX:\n${Object.keys(s).join(" - ")};\nMESH:\n${Object.keys(A).join(" - ")};\n`)},get cat(){return getcat()},pushcat(e){m.push(e)},popcat:()=>(m.length>1&&m.length--,getcat())}}const Ji=new Map;function salvaMaterialiOriginali(e){e.traverse((e=>{if(!e.isMesh||e.layers.mask>1<<20)return;const t=e.material;if(!t)return;const i=Array.isArray(t)?t:[t];Ji.has(e)||Ji.set(e,i)}))}function ripristinaMaterialiOriginali(){for(let[e,t]of Ji.entries())e.material=Array.isArray(t)?[...t]:t;Ji.clear()}function applicaEvidenziazione(e,t,i,n){!function ricorsiva(e,r,o){const s=!!r||!!t&&t.includes(e?.userData?.mat),A=o||e.userData?.evidenziaMap;if(e.isMesh&&e.layers.mask<=1<<20){const t=Ji.get(e);if(!t)return;const r=t.map((e=>{const t=(s?n:i).clone();return A&&e.map&&(t.map=e.map),t.transparent=e.transparent,t.opacity=e.opacity,t}));e.material=Array.isArray(e.material)?r:r[0]}e.children.forEach((e=>ricorsiva(e,s,A)))}(e,!1,!1)}async function evidenziaColli(t,i,n){salvaMaterialiOriginali(t);const r=e.DoubleSide,o=new e.MeshStandardMaterial({color:16777215,roughness:.5,metalness:.4,side:r}),s=new e.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:r});let A=0;try{for(let e of i)A++,e.name||(e.name=`collo_${A}`),applicaEvidenziazione(t,e.mats,o,s),await n(e)}catch(e){console.error("Errore durante evidenzia:",e)}finally{ripristinaMaterialiOriginali()}}async function runScript(t,i,n,r,o){let s=await t.getScript(i),A=s.script,a=[],l=function toCadPars(e){const t=muClComments(e),i=[];for(const e of t){const t=e.includes("(")||e.includes("[")?[e]:getcolonne(e,!0);let n=!1;for(const e of t)!e.startsWith('"')&&e.includes("=")?(i.push(e),n=!0):n&&(i[i.length-1]+=","+e)}const n={};for(const e of i){let{v:t,o:i}=getcouple(e,"=",!1);i=i||"",t&&(/^[-+]?\d*\.?\d+$/.test(i)&&(i=parseFloat(i)),n[t]=i)}return n}(s.pars+("string"==typeof r?"\n"+r:""));function setmatricola(e){return e?.userData&&(e.userData.mat=`${i}_${t.gmats[i]}`),e}r&&"object"==typeof r&&(l={...l,...r}),t.gmats[i]||(t.gmats[i]=0);let c=(new Date).valueOf(),p=c;try{function movimento(e,i=[]){return e=clean(e,!0),t.movs[e]||(t.movs[e]=getmovimento(e,i)),t.movs[e]}function addlog(...e){if(t?.islog){const t=e.map((e=>getOggetto(e)));console.log(...t),a.push(...t)}}function dbadd(e,r,o,s={}){s||(s={}),t.gmats[i]++;let A=`${i}_${t.gmats[i]}`,{qt:a=1,l:l=0,a:c=0,p:p=0,vars:h="",shape:g=null,model:u,lavs:d=null}=s;if(n.DB&&r){let t={lev:"string"==typeof e?clean(e,!0):"l"+(e+(n?._level??0)),mat:A,cod:r,note:o||"",qt:a,l:l,a:c,p:p,vars:h};g&&(t.shape=g),d&&(t.lavs=d),u&&(t.model=u),n.DB.push(t)}return A}function addtop(e,t,i={}){i||(i={}),n.TOPS.push({key:e,shape:t,type:"top",op:i,posfn:o})}function addhole(e,t,i={}){i||(i={}),n.TOPS.push({key:e,shape:t,type:"hole",op:i,posfn:o})}function addaltri(e,t,i={}){i||(i={}),n.TOPS.push({key:e,data:t,type:"altri",op:i,posfn:o})}function addlines(e,t,i={}){i||(i={}),t&&(Array.isArray(t)||(t=[t]),n.TOPS.push({key:e,lines:t,type:"lines",op:i,posfn:o}))}function dbdes(e,t){n.DES&&t&&n.DES.push({lev:e+(n?._level??0),description:t})}function geturltex(e){let i=t.cat;if(!e)return t.P.baseurl+"noimage.jpg";if(t.P._cdn){if(e.includes("/")){let t=e.split("/");i=t[0],e=t[1]}return e.endsWith(".webp")||e.endsWith(".png")||e.endsWith(".jpeg")||e.endsWith(".jpg")||(e+=".webp"),`${t.P._cdn}${i}/textures/${e}`}return t.P.fullget("mufiles/getfile",{id:i,subfolder:"textures",name:e})}l||(l={}),n||(n={});const h={GCAD:!0,...n,...l,THREE:e,TODEG:TODEG,TORAD:TORAD,dbadd:dbadd,addtop:addtop,addhole:addhole,addlines:addlines,addaltri:addaltri,dbdes:dbdes,addpivot:(e,i,n={},r=0,o=0,s=0)=>setmatricola(addmovpivot(t,e,i,n,r,o,s)),movimento:movimento,Math:Math,info3d:t.info3d,gcad:t,SIDE:$e,seeder:seeder,seedarray:seedarray,baseurl:t.P.baseurl,Vis2d:Vis2d,joinlinestoshapes:joinlinestoshapes,groupfromgeometry:groupfromgeometry,creategroup:creategroup,deletegroup:deletegroup,Matrix3D:Matrix3D,geturltex:geturltex,clamp:clamp,Punto2:Punto2,Linea2:Linea2,getptsoffset:getptsoffset,hash:hash,PIF:Ue,raccordabezier:raccordabezier,svuotanodo:svuotanodo,normal2:normal2,angle3point:angle3point,angle2vec:angle2vec,getshape:getshape,shapeclip:shapeclip,mgray1:nt,mgray2:rt,mwhite:it,mred:ot,mgreen:At,mblack:at,mblue:st,materialline1:et,materialline2:tt,scaleunit:lt,edgesfromgeometry:edgesfromgeometry,getmesh:getmesh,getcolonne:getcolonne,posiziona:posiziona,getbb:getbb,scalaoggetto:(e,i)=>scalaoggetto(t,e,i),setorigine:setorigine,SP:Ve,elaborapercorso:elaborapercorso,gettarghetta:(e,i,n)=>gettarghetta(t,e,i,n),getquota:(e,i,n,r,o,s={})=>getquota(t,e,i,n,r,o,s),getsprite:(e,t,i,n,r)=>getsprite(0,e,t,i,n,r),getpunto:(e,i,n,r,o,s)=>getpunto(t,e,i,n,r,o),spritemat:e=>spritemat(t,e),getemitter:getemitter,getreceiver:e=>setmatricola(getreceiver(t,e)),getriferimento:getriferimento,get3dshape:get3dshape,getline:getline,getpoint:getpoint,randombasemat:randombasemat,texgen:(e,i=256,n={})=>texgen(t,e,i,n),getcilindro:(e,i,n,r,o=it,s)=>setmatricola(getcilindro(t,e,i,n,r,o,s)),getbox:(e,t,i,n,r)=>setmatricola(getbox(0,e,t,i,n,r)),getsphere:(e,t,i)=>setmatricola(getsphere(0,e,t,i)),replacemats:t.replacemats,getluce:(e,i="#ffffff",n=1)=>getluce(t,e,i,n),getthorus:(e,t,i,n)=>setmatricola(getthorus(0,e,t,i,n)),getcyl:(e,t,i=it,n)=>setmatricola(getcyl(0,e,t,i,n)),getpannello:(e,i,n,r,o,s,A)=>setmatricola(getpannello(t,e,i,n,r,o,s,A)),getpannello2:(e,i,n,r,o,s)=>setmatricola(getpannello2(t,e,i,n,r,o,s)),getface:(e,i,n,r)=>setmatricola(getface(t,e,i,n,r)),getmarker:(e,i,n,r,o,s={})=>getmarker(t,e,i,n,r,o,s),getglb:e=>setmatricola(t.getglb(e)),get3ds:e=>setmatricola(t.get3ds(e)),estruso:(e,i,n,r,o,s)=>setmatricola(estruso(t,e,i,n,r,o,s)),getextrude:(e,i,n,r,o)=>setmatricola(getextrude(t,e,i,n,r,o)),estrusopat:(e,i,n,r,o,s)=>setmatricola(estrusopat(t,e,i,n,r,o,s)),infoestrudi:infoestrudi,getfakeshadow:(e,i)=>getfakeshadow(t,e,i),getfakeshadow2:getfakeshadow2,revolve:(e,i,n,r)=>setmatricola(revolve(t,e,i,n,r)),smat:(e,i)=>smat(t,e,i),log:addlog,clean:clean,logtime:e=>{if(t?.islog){let t=(new Date).valueOf();addlog(`time: ${e} => ${t-p}ms / ${t-c}ms`),p=t}}},g=[...Object.keys(h),...Object.keys(Xe)],u=[...Object.values(h),...Object.values(Xe)],d=`//# sourceURL=${i}\n return (async () => {\n${A}\n })();`;try{let f=hash(i+JSON.stringify(Object.keys(l)));t.cacheFns[f]||(t.cacheFns[f]=new Function(...g,d));const I=t.cacheFns[f];return{res:await I(...u),LOGS:a}}catch(m){let b=await errorescript(`// errore\n async function script() {\n ${A}\n }`,m);console.error(m),t?.bus?.errore(b)}}catch(C){t?.bus?.errore(`${C.message}\nscript: ${i}`),console.error(C)}}async function processatop(e,t,i){if(!t)return;let n=t.getObjectByName("_mtop");if(n)for(;n.children.length>0;)n.remove(n.children[0]);else n=creategroup("_mtop"),t.add(n);const uk=e=>`${e.key}|${Math.round(((e.ang||0)+180)%180)/5}|${e.pos.y}`;let r=shapeclip();const o=[...new Set(i.filter((e=>"top"==e.type)).map(uk))];let s=[],A=0;for(let t of o){let o=i.filter((e=>"top"==e.type&&uk(e)===t));if(o.length){let t=o[0],a=i.filter((e=>"hole"==e.type&&e.key==t.key)),l=[],c=[],p=[];for(let e of o)l.push(e.shape.clone().rotate(-e.ang).move(e.pos.x,e.pos.z));let h=[];for(let e of a){let t=e.op.ptrif,i=e.op.ptapplica,n=e.shape.dims();t=t?[n.p1,...t]:[n.p1,n.p2],i||(i=n.p1);let r=e.shape.clone().rotate(-e.ang).move(e.pos.x,e.pos.z),o=getshape().frompt(t).rotate(-e.ang).move(e.pos.x,e.pos.z);h.push({pt:o.pt,shape:r,op:e.op,width:n.width,height:n.height}),e.op?.hidden||c.push(r)}let g,u=r.unisci(l,c,p);for(let t of u){let i=o[0],r=t.shape.rebase(-i.ang),a=t.shape.dims(),l=getshape().fromrect(a.width,a.height,a.p1.x,a.p1.y);r.holes=[],r.cuts=[];for(let e of t.holes)r.holes.push(e.rebase(-i.ang,!0,r.origine.x,r.origine.y));const to2dec=e=>Math.round(100*(Number(e)||0))/100;let c=h.map((e=>{let t=getshape().frompt(e.pt),{shape:n}=t.rebase(-i.ang,!0,r.origine.x,r.origine.y);return{op:e.op,pt:n.pt,px:to2dec(n.pt[0].x),py:to2dec(n.pt[0].y),dx:to2dec(e.width),dy:to2dec(e.height)}})),p=c.filter((e=>{for(let t of e.pt)if(l.pointinshape(t))return!0;return!1}));p.forEach((e=>delete e.pt));let u=[];await runScript(e,"_ricalcolatop",{BOX:u,DB:s,TOPS:[],_level:800,processatop:{top:r,base:i,lavs:p,idt:A}},{}),A++;for(let e of u)g=posiziona(posiziona(e,{sa:i.pos.y||0,sl:r.origine.x,sp:r.origine.y}),{ay:i.ang}),n.add(g)}}}const a=i.filter((e=>"altri"==e.type));let l=[];await runScript(e,"_ricalcolaaltri",{BOX:l,DB:s,TOPS:[],_level:800,processatop:{altri:a,idt:A}},{}),A++;for(let e of l)n.add(e);const uk1=e=>`${e.key}|${e.pos.y}`,c=i.filter((e=>"lines"==e.type)),p=[...new Set(c.map(uk1))];for(let t of p){const i=c.filter((e=>uk1(e)===t)),n=joinlinestoshapes(i);for(let r of n){let n={sh:r,key:t,data:i[0].op||{},idt:A};await runScript(e,"_ricalcolalinee",{BOX:l,DB:s,TOPS:[],_level:800,processatop:n},{})}A++}for(let e of l)n.add(e);return s}async function processamarker(t){t.updateMatrixWorld(!0);const i=new Map;!function traverse(n){if(n.userData?.markerid)i.set(n.userData.markerid,n);else if(n.name?.startsWith("#mk_")){const r=n.name,o=i.get(r);if(!o)return void t.remove(n);{o.updateMatrixWorld(!0);const i=o.matrixWorld.clone(),r=(new e.Matrix4).copy(t.matrixWorld).invert().multiply(i);n.matrix.copy(r),n.matrixAutoUpdate=!1,o.visible=!1,n.updateMatrixWorld(!0)}}for(const e of[...n.children])traverse(e)}(t)}async function processagruppo(e,t){Object.assign(t.userData,{SHAPES:[],DB:[],TOPS:[]});for(let i of t.userData.INFO.rows)if("fn"==i?.t){let n=creategroup(),r=[];await runScript(e,i.fn,{BOX:r,SHAPES:t.userData.SHAPES,DB:t.userData.DB,TOPS:t.userData.TOPS,_level:t.userData._level},i.pars,i.p2),r.length&&(r.forEach((e=>n.add(e))),Object.keys(i.p2).length&&(n=posiziona(n,i.p2)),t.add(n))}else if(i?.rows&&i.rows.length){let n=creategroup();i.iscad&&(n=posiziona(n,i.cadv)),n.name=i.id,Object.assign(n.userData,{INFO:i,_level:t.userData._level+1}),await processagruppo(e,n),t.add(n)}}function getalldb(t,i){let n=[],r=[],o=[];if(t){let i=new e.Matrix4,s=new e.Matrix4;t.updateMatrixWorld(),i.copy(t.matrixWorld);let A=i.clone().invert();t.traverse((t=>{if(t.userData?.DB&&Array.isArray(t.userData.DB)&&n.push(...t.userData.DB),t.userData?.TOPS&&t.userData.TOPS.length){t.updateMatrixWorld(),s.copy(t.matrixWorld);let i=s.clone().premultiply(A),n=new e.Vector3;n.setFromMatrixPosition(i),(new e.Euler).setFromRotationMatrix(i);let o=-e.MathUtils.radToDeg(Math.atan2(i.elements[2],i.elements[10]));for(let i of t.userData.TOPS){let{sl:t=0,sp:s=0,ay:A=0}=i?.posfn;if(t||s||A){let a=e.MathUtils.degToRad(-o),l=Math.cos(a),c=Math.sin(a),p=t*l-s*c,h=t*c+s*l,g=new e.Vector3(n.x+p,n.y,n.z+h),u=o-A;r.push({...i,pos:g,ang:u})}else r.push({...i,pos:n,ang:o})}}t.userData?.SHAPES&&Array.isArray(t.userData.SHAPES)&&o.push(...t.userData.SHAPES)}))}return i&&(i.DB=n,i.TOPS=r,i.SHAPES=o),{DB:n,TOPS:r,SHAPES:o}}async function evalcustomfunction(e,t,i,n){try{i||(i={}),n||(n={});const r={GCAD:!1,...i,A:e,V:e.vari,amb:e,info3d:async function info3d(t,i=1,n=0,r=0){if(e.gcad)return await e.gcad.info3d(t,i,n,r)},gcad:e.gcad,log:function addlog(...e){const t=e.map((e=>getOggetto(e)));console.log(...t)},Math:Math,getcolonne:getcolonne,clean:clean,SP:Ve,seeder:seeder,seedarray:seedarray,Punto2:Punto2,Linea2:Linea2,clamp:clamp,hash:hash,PIF:Ue,getshape:getshape,shapeclip:shapeclip,...n},o=[...Object.keys(r),...Object.keys(Xe)],s=[...Object.values(r),...Object.values(Xe)],A=new Function(...o,`\n try {\n return (async () => {\n ${t}\n })();\n } catch (err) {\n err.stack = '[SCRIPT] ' + err.stack;\n throw err;\n }`);return await A(...s)}catch(e){throw console.error("Errore durante l'esecuzione:",e),e}}function setLineColorMode(e,t){e?(et.color.set(16777215),tt.color.set(16777215)):t?(et.color.set(11579568),tt.color.set(10526880)):(et.color.set(6316128),tt.color.set(8421504)),et.needsUpdate=!0,tt.needsUpdate=!0}export{Linea2,Matrix3D,Ue as PIF,Punto2,$e as SIDE,Ve as SP,TODEG,TORAD,Vis2d,Vobject,Vscene,addmovpivot,angle2vec,angle3point,Xe as blocked,calcolatasks,clamp,clean,creategroup,deletegroup,dxfbulge,edgesfromgeometry,elaborapercorso,errorescript,estruso,estrusopat,evalcustomfunction,evidenziaColli,extractTextures,get3dshape,getOggetto,getalldb,getbb,getbordi,getbox,getcilindro,getcyl,getdumpmacro,getemitter,getextrude,getface,getfakeshadow,getfakeshadow2,getline,getlinesgeom,getluce,getmarker,getmesh,getmovimento,getnodebyid,getpannello,getpannello2,getpoint,getptsoffset,getpunto,getquota,getreceiver,getriferimento,getshape,getsphere,getsprite,getsubrules,gettarghetta,getthorus,groupfromgeometry,hash,infoestrudi,isfn,ismacro,joinlinestoshapes,mapvertices,et as materialline1,tt as materialline2,at as mblack,st as mblue,nt as mgray1,rt as mgray2,At as mgreen,ot as mred,it as mwhite,newgcad,normal2,posiziona,processagruppo,processamarker,processatop,raccordabezier,randombasemat,revolve,ripristinaMaterialiOriginali,runScript,salvaMaterialiOriginali,scalaoggetto,lt as scaleunit,seedarray,seeder,setLineColorMode,setorigine,shapeclip,smat,spritemat,svuotanodo,texgen,valutagrafica};