2 lines
42 KiB
JavaScript
2 lines
42 KiB
JavaScript
|
define(["exports"],(function(e){"use strict";class t{constructor(e){this.segments=e||[]}prepareSegment(e,n,i,r){let s=this.segments[this.segments.length-1];return e>t.MAX_VERTEX_ARRAY_LENGTH&&console.log(`Max vertices per segment is ${t.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!s||s.vertexLength+e>t.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==r)&&(s={vertexOffset:n.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0},void 0!==r&&(s.sortKey=r),this.segments.push(s)),s}get(){return this.segments}destroy(){for(const e of this.segments)e.vao&&e.vao.destroy()}static simpleSegment(e,n,i,r){return new t([{vertexOffset:e,primitiveOffset:n,vertexLength:i,primitiveLength:r,sortKey:0}])}}t.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1;class n{constructor(e){this.style=e.style,this.type=e.type,this.tileSize=e.tileSize}serialize(e){}destroy(){}}function i(e,t,n,i,s){r(e,t,n||0,i||e.length-1,s||h)}function r(e,t,n,i,h){for(;i>n;){if(i-n>600){var o=i-n+1,a=t-n+1,l=Math.log(o),d=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*d*(o-d)/o)*(a-o/2<0?-1:1);r(e,t,Math.max(n,Math.floor(t-a*d/o+u)),Math.min(i,Math.floor(t+(o-a)*d/o+u)),h)}var c=e[t],g=n,f=i;for(s(e,n,t),h(e[i],c)>0&&s(e,n,i);g<f;){for(s(e,g,f),g++,f--;h(e[g],c)<0;)g++;for(;h(e[f],c)>0;)f--}0===h(e[n],c)?s(e,n,f):s(e,++f,i),f<=t&&(n=f+1),t<=f&&(i=f-1)}}function s(e,t,n){var i=e[t];e[t]=e[n],e[n]=i}function h(e,t){return e<t?-1:e>t?1:0}function o(e){let t=0;for(let n,i,r=0,s=e.length,h=s-1;r<s;h=r++)n=e[r],i=e[h],t+=(i.x-n.x)*(n.y+i.y);return t}function a(e,t){return t.area-e.area}var l={WINDING_ODD:0,WINDING_NONZERO:1,WINDING_POSITIVE:2,WINDING_NEGATIVE:3,WINDING_ABS_GEQ_TWO:4,POLYGONS:0,CONNECTED_POLYGONS:1,BOUNDARY_CONTOURS:2,tesselate:function(e){for(var t=e.debug||!1,n=new S,i=0;i<e.contours.length;i++)n.addContour(e.vertexSize||2,e.contours[i]);return n.tesselate(e.windingRule||l.WINDING_ODD,e.elementType||l.POLYGONS,e.polySize||3,e.vertexSize||2,e.normal||[0,0,1]),{vertices:n.vertices,vertexIndices:n.vertexIndices,vertexCount:n.vertexCount,elements:n.elements,elementCount:n.elementCount,mesh:t?n.mesh:void 0}}},d=function(e){if(!e)throw"Assertion Failed!"};function u(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}function c(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}function g(e){this.next=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Org=null,this.Lface=null,this.activeRegion=null,this.winding=0,this.side=e}function f(){var e=new u,t=new c,n=new g(0),i=new g(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,t.anEdge=null,t.trail=null,t.marked=!1,t.inside=!1,n.next=n,n.Sym=i,n.Onext=null,n.Lnext=null,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,i.next=i,i.Sym=n,i.Onext=null,i.Lnext=null,i.Org=null,i.Lface=null,i.winding=0,i.activeRegion=null,this.vHead=e,this.fHead=t,this.eHead=n,this.eHeadSym=i}g.prototype={get Rface(){return this.Sym.Lface},set Rface(e){this.Sym.Lface=e},get Dst(){return this.Sym.Org},set Dst(e){this.Sym.Org=e},get Oprev(){return this.Sym.Lnext},set Oprev(e){this.Sym.Lnext=e},get Lprev(){return this.Onext.Sym},set Lprev(e){this.Onext.Sym=e},get Dprev(){return this.Lnext.Sym},set Dprev(e){this.Lnext.Sym=e},get Rprev(){return this.Sym.Onext},set Rprev(e){this.Sym.Onext=e},get Dnext(){return this.Sym.Onext.Sym},set Dnext(e){this.Sym.Onext.Sym=e},get Rnext(){return this.Sym.Lnext.Sym},set Rnext(e){this.Sym.Lnext.Sym=e}},f.prototype={makeEdge_:function(e){var t=new g(0),n=new g(1);e.Sym.side<e.side&&(e=e.Sym);var i=e.Sym.next;return n.next=i,i.Sym.next=t,t.next=e,e.Sym.next=n,t.Sym=n,t.Onext=t,t.Lnext=n,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,n.Sym=t,n.Onext=n,n.Lnext=t,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,t},splice_:function(e,t){var n=e.Onext,i=t.Onext;n.Sym.Lnext=t,i.Sym.Lnext=e,e.Onext=i,t.Onext=n},makeVertex_:function(e,t,n){var i=e;d(null!==i);var r=n.prev;i.prev=r,r.next=i,i.next=n,n.prev=i,i.anEdge=t;var s=t;do{s.Org=i,s=s.Onext}while(s!==t)},makeFace_:function(e,
|