@naivemap/maplibre-gl-image-layer 0.1.0 → 0.2.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,76 +0,0 @@
1
- (function(Y,ce){typeof exports=="object"&&typeof module<"u"?module.exports=ce(require("proj4")):typeof define=="function"&&define.amd?define(["proj4"],ce):(Y=typeof globalThis<"u"?globalThis:Y||self,Y.ImageLayer=ce(Y.proj4))})(this,function(Y){"use strict";/* @license twgl.js 5.5.4 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
2
- Available via the MIT license.
3
- see: http://github.com/greggman/twgl.js for details */const rt={};{const e=rt;e[5120]=Int8Array,e[5121]=Uint8Array,e[5122]=Int16Array,e[5123]=Uint16Array,e[5124]=Int32Array,e[5125]=Uint32Array,e[5126]=Float32Array,e[32819]=Uint16Array,e[32820]=Uint16Array,e[33635]=Uint16Array,e[5131]=Uint16Array,e[33640]=Uint32Array,e[35899]=Uint32Array,e[35902]=Uint32Array,e[36269]=Uint32Array,e[34042]=Uint32Array}function ve(e){if(e instanceof Int8Array)return 5120;if(e instanceof Uint8Array||e instanceof Uint8ClampedArray)return 5121;if(e instanceof Int16Array)return 5122;if(e instanceof Uint16Array)return 5123;if(e instanceof Int32Array)return 5124;if(e instanceof Uint32Array)return 5125;if(e instanceof Float32Array)return 5126;throw new Error("unsupported typed array type")}function nt(e){if(e===Int8Array)return 5120;if(e===Uint8Array||e===Uint8ClampedArray)return 5121;if(e===Int16Array)return 5122;if(e===Uint16Array)return 5123;if(e===Int32Array)return 5124;if(e===Uint32Array)return 5125;if(e===Float32Array)return 5126;throw new Error("unsupported typed array type")}function ot(e){const t=rt[e];if(!t)throw new Error("unknown gl type");return t}const fe=typeof SharedArrayBuffer<"u"?function(t){return t&&t.buffer&&(t.buffer instanceof ArrayBuffer||t.buffer instanceof SharedArrayBuffer)}:function(t){return t&&t.buffer&&t.buffer instanceof ArrayBuffer};function it(...e){console.error(...e)}const st=new Map;function Ue(e,t){if(!e||typeof e!="object")return!1;let r=st.get(t);r||(r=new WeakMap,st.set(t,r));let n=r.get(e);if(n===void 0){const o=Object.prototype.toString.call(e);n=o.substring(8,o.length-1)===t,r.set(e,n)}return n}function Ar(e,t){return typeof WebGLBuffer<"u"&&Ue(t,"WebGLBuffer")}function at(e,t){return typeof WebGLTexture<"u"&&Ue(t,"WebGLTexture")}function br(e,t){return typeof WebGLSampler<"u"&&Ue(t,"WebGLSampler")}const ut=35044,O=34962,Sr=34963,Ir=34660,Rr=5120,Fr=5121,Pr=5122,Nr=5123,gr=5124,vr=5125,ct=5126,ft={attribPrefix:""};function Ur(e,t,r,n,o){e.bindBuffer(t,r),e.bufferData(t,n,o||ut)}function lt(e,t,r,n){if(Ar(e,t))return t;r=r||O;const o=e.createBuffer();return Ur(e,r,o,t,n),o}function mt(e){return e==="indices"}function Dr(e){return e===Int8Array||e===Uint8Array}function Br(e){return e.length?e:e.data}const wr=/coord|texture/i,Lr=/color|colour/i;function Mr(e,t){let r;if(wr.test(e)?r=2:Lr.test(e)?r=4:r=3,t%r>0)throw new Error(`Can not guess numComponents for attribute '${e}'. Tried ${r} but ${t} values is not evenly divisible by ${r}. You should specify it.`);return r}function Or(e,t,r){return e.numComponents||e.size||Mr(t,r||Br(e).length)}function xt(e,t){if(fe(e))return e;if(fe(e.data))return e.data;Array.isArray(e)&&(e={data:e});let r=e.type?De(e.type):void 0;return r||(mt(t)?r=Uint16Array:r=Float32Array),new r(e.data)}function Cr(e){return typeof e=="number"?e:e?nt(e):ct}function De(e){return typeof e=="number"?ot(e):e||Float32Array}function Gr(e,t){return{buffer:t.buffer,numValues:2*3*4,type:Cr(t.type),arrayType:De(t.type)}}function $r(e,t){const r=t.data||t,n=De(t.type),o=r*n.BYTES_PER_ELEMENT,i=e.createBuffer();return e.bindBuffer(O,i),e.bufferData(O,o,t.drawType||ut),{buffer:i,numValues:r,type:nt(n),arrayType:n}}function kr(e,t,r){const n=xt(t,r);return{arrayType:n.constructor,buffer:lt(e,n,void 0,t.drawType),type:ve(n),numValues:0}}function zr(e,t){const r={};return Object.keys(t).forEach(function(n){if(!mt(n)){const o=t[n],i=o.attrib||o.name||o.attribName||ft.attribPrefix+n;if(o.value){if(!Array.isArray(o.value)&&!fe(o.value))throw new Error("array.value is not array or typedarray");r[i]={value:o.value}}else{let s;o.buffer&&o.buffer instanceof WebGLBuffer?s=Gr:typeof o=="number"||typeof o.data=="number"?s=$r:s=kr;const{buffer:a,type:u,numValues:c,arrayType:m}=s(e,o,n),f=o.normalize!==void 0?o.normalize:Dr(m),x=Or(o,n,c);r[i]={buffer:a,numComponents:x,type:u,normalize:f,stride:o.stride||0,offset:o.offset||0,divisor:o.divisor===void 0?void 0:o.divisor,drawType:o.drawType}}}}),e.bindBuffer(O,null),r}function Vr(e,t){return t===Rr||t===Fr?1:t===Pr||t===Nr?2:t===gr||t===vr||t===ct?4:0}const Be=["position","positions","a_position"];function Hr(e,t){let r,n;for(n=0;n<Be.length&&(r=Be[n],!(r in t||(r=ft.attribPrefix+r,r in t)));++n);n===Be.length&&(r=Object.keys(t)[0]);const o=t[r];if(!o.buffer)return 1;e.bindBuffer(O,o.buffer);const i=e.getBufferParameter(O,Ir);e.bindBuffer(O,null);const s=Vr(e,o.type),a=i/s,u=o.numComponents||o.size,c=a/u;if(c%1!==0)throw new Error(`numComponents ${u} not correct for length ${length}`);return c}function we(e,t,r){const n=zr(e,t),o=Object.assign({},r||{});o.attribs=Object.assign({},r?r.attribs:{},n);const i=t.indices;if(i){const s=xt(i,"indices");o.indices=lt(e,s,Sr),o.numElements=s.length,o.elementType=ve(s)}else o.numElements||(o.numElements=Hr(e,o.attribs));return o}function Q(e){return!!e.texStorage2D}const ht=function(){const e={},t={};function r(n){const o=n.constructor.name;if(!e[o]){for(const i in n)if(typeof n[i]=="number"){const s=t[n[i]];t[n[i]]=s?`${s} | ${i}`:i}e[o]=!0}}return function(o,i){return r(o),t[i]||(typeof i=="number"?`0x${i.toString(16)}`:i)}}(),D={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{},crossOrigin:void 0},q=fe,yt=function(){let e;return function(){return e=e||(typeof document<"u"&&document.createElement?document.createElement("canvas").getContext("2d"):null),e}}(),dt=6406,v=6407,b=6408,_t=6409,Et=6410,ee=6402,Tt=34041,le=33071,Yr=9728,Xr=9729,B=3553,w=34067,C=32879,G=35866,Le=34069,jr=34070,Zr=34071,Wr=34072,Kr=34073,Jr=34074,Me=10241,Oe=10240,me=10242,xe=10243,pt=32882,Qr=33082,qr=33083,en=33084,tn=33085,rn=34892,nn=34893,Ce=3317,At=3314,bt=32878,St=3316,It=3315,Rt=32877,on=37443,sn=37441,an=37440,un=33321,cn=36756,fn=33325,ln=33326,mn=33330,xn=33329,hn=33338,yn=33337,dn=33340,_n=33339,En=33323,Tn=36757,pn=33327,An=33328,bn=33336,Sn=33335,In=33332,Rn=33331,Fn=33334,Pn=33333,Nn=32849,gn=35905,vn=36194,Un=36758,Dn=35898,Bn=35901,wn=34843,Ln=34837,Mn=36221,On=36239,Cn=36215,Gn=36233,$n=36209,kn=36227,zn=32856,Vn=35907,Hn=36759,Yn=32855,Xn=32854,jn=32857,Zn=34842,Wn=34836,Kn=36220,Jn=36238,Qn=36975,qn=36214,eo=36232,to=36226,ro=36208,no=33189,oo=33190,io=36012,so=36013,ao=35056,L=5120,A=5121,he=5122,X=5123,ye=5124,$=5125,F=5126,Ft=32819,Pt=32820,Nt=33635,g=5131,te=36193,Ge=33640,uo=35899,co=35902,fo=36269,lo=34042,de=33319,j=33320,_e=6403,Z=36244,W=36248,k=36249;let $e;function Ee(e){if(!$e){const t={};t[dt]={textureFormat:dt,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[A,g,te,F]},t[_t]={textureFormat:_t,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[A,g,te,F]},t[Et]={textureFormat:Et,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[A,g,te,F]},t[v]={textureFormat:v,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[A,g,te,F,Nt]},t[b]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[A,g,te,F,Ft,Pt]},t[ee]={textureFormat:ee,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[$,X]},t[un]={textureFormat:_e,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[A]},t[cn]={textureFormat:_e,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[L]},t[fn]={textureFormat:_e,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[F,g]},t[ln]={textureFormat:_e,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[F]},t[mn]={textureFormat:Z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[A]},t[xn]={textureFormat:Z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[L]},t[In]={textureFormat:Z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[X]},t[Rn]={textureFormat:Z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[he]},t[Fn]={textureFormat:Z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[$]},t[Pn]={textureFormat:Z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ye]},t[En]={textureFormat:de,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[A]},t[Tn]={textureFormat:de,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[L]},t[pn]={textureFormat:de,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[F,g]},t[An]={textureFormat:de,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[F]},t[bn]={textureFormat:j,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[A]},t[Sn]={textureFormat:j,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[L]},t[hn]={textureFormat:j,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[X]},t[yn]={textureFormat:j,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[he]},t[dn]={textureFormat:j,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[$]},t[_n]={textureFormat:j,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[ye]},t[Nn]={textureFormat:v,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[A]},t[gn]={textureFormat:v,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[A]},t[vn]={textureFormat:v,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[A,Nt]},t[Un]={textureFormat:v,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[L]},t[Dn]={textureFormat:v,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[F,g,uo]},t[Bn]={textureFormat:v,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[F,g,co]},t[wn]={textureFormat:v,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[F,g]},t[Ln]={textureFormat:v,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[F]},t[Mn]={textureFormat:W,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[A]},t[On]={textureFormat:W,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[L]},t[Cn]={textureFormat:W,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[X]},t[Gn]={textureFormat:W,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[he]},t[$n]={textureFormat:W,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[$]},t[kn]={textureFormat:W,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[ye]},t[zn]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[A]},t[Vn]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[A]},t[Hn]={textureFormat:b,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[L]},t[Yn]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[A,Pt,Ge]},t[Xn]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[A,Ft]},t[jn]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[Ge]},t[Zn]={textureFormat:b,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[F,g]},t[Wn]={textureFormat:b,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[F]},t[Kn]={textureFormat:k,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[A]},t[Jn]={textureFormat:k,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[L]},t[Qn]={textureFormat:k,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Ge]},t[qn]={textureFormat:k,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[X]},t[eo]={textureFormat:k,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[he]},t[to]={textureFormat:k,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[ye]},t[ro]={textureFormat:k,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[$]},t[no]={textureFormat:ee,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[X,$]},t[oo]={textureFormat:ee,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[$]},t[io]={textureFormat:ee,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[F]},t[ao]={textureFormat:Tt,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[lo]},t[so]={textureFormat:Tt,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[fo]},Object.keys(t).forEach(function(r){const n=t[r];n.bytesPerElementMap={},n.bytesPerElement.forEach(function(o,i){const s=n.type[i];n.bytesPerElementMap[s]=o})}),$e=t}return $e[e]}function mo(e,t){const r=Ee(e);if(!r)throw"unknown internal format";const n=r.bytesPerElementMap[t];if(n===void 0)throw"unknown internal format";return n}function re(e){const t=Ee(e);if(!t)throw"unknown internal format";return{format:t.textureFormat,type:t.type[0]}}function gt(e){return(e&e-1)===0}function xo(e,t,r,n){if(!Q(e))return gt(t)&&gt(r);const o=Ee(n);if(!o)throw"unknown internal format";return o.colorRenderable&&o.textureFilterable}function ho(e){const t=Ee(e);if(!t)throw"unknown internal format";return t.textureFilterable}function yo(e,t,r){return q(t)?ve(t):r||A}function Te(e,t,r,n,o){if(o%1!==0)throw"can't guess dimensions";if(!r&&!n){const i=Math.sqrt(o/(t===w?6:1));i%1===0?(r=i,n=i):(r=o,n=1)}else if(n){if(!r&&(r=o/n,r%1))throw"can't guess dimensions"}else if(n=o/r,n%1)throw"can't guess dimensions";return{width:r,height:n}}function K(e,t){t.colorspaceConversion!==void 0&&e.pixelStorei(on,t.colorspaceConversion),t.premultiplyAlpha!==void 0&&e.pixelStorei(sn,t.premultiplyAlpha),t.flipY!==void 0&&e.pixelStorei(an,t.flipY)}function vt(e){e.pixelStorei(Ce,4),Q(e)&&(e.pixelStorei(At,0),e.pixelStorei(bt,0),e.pixelStorei(St,0),e.pixelStorei(It,0),e.pixelStorei(Rt,0))}function _o(e,t,r,n){n.minMag&&(r.call(e,t,Me,n.minMag),r.call(e,t,Oe,n.minMag)),n.min&&r.call(e,t,Me,n.min),n.mag&&r.call(e,t,Oe,n.mag),n.wrap&&(r.call(e,t,me,n.wrap),r.call(e,t,xe,n.wrap),(t===C||br(e,t))&&r.call(e,t,pt,n.wrap)),n.wrapR&&r.call(e,t,pt,n.wrapR),n.wrapS&&r.call(e,t,me,n.wrapS),n.wrapT&&r.call(e,t,xe,n.wrapT),n.minLod!==void 0&&r.call(e,t,Qr,n.minLod),n.maxLod!==void 0&&r.call(e,t,qr,n.maxLod),n.baseLevel!==void 0&&r.call(e,t,en,n.baseLevel),n.maxLevel!==void 0&&r.call(e,t,tn,n.maxLevel),n.compareFunc!==void 0&&r.call(e,t,nn,n.compareFunc),n.compareMode!==void 0&&r.call(e,t,rn,n.compareMode)}function Ut(e,t,r){const n=r.target||B;e.bindTexture(n,t),_o(e,n,e.texParameteri,r)}function Eo(e){return e=e||D.textureColor,q(e)?e:new Uint8Array([e[0]*255,e[1]*255,e[2]*255,e[3]*255])}function ke(e,t,r,n,o,i){r=r||D.textureOptions,i=i||b;const s=r.target||B;if(n=n||r.width,o=o||r.height,e.bindTexture(s,t),xo(e,n,o,i))e.generateMipmap(s);else{const a=ho(i)?Xr:Yr;e.texParameteri(s,Me,a),e.texParameteri(s,Oe,a),e.texParameteri(s,me,le),e.texParameteri(s,xe,le)}}function ne(e){return e.auto===!0||e.auto===void 0&&e.level===void 0}function ze(e,t){return t=t||{},t.cubeFaceOrder||[Le,jr,Zr,Wr,Kr,Jr]}function Ve(e,t){const n=ze(e,t).map(function(o,i){return{face:o,ndx:i}});return n.sort(function(o,i){return o.face-i.face}),n}function Dt(e,t,r,n){n=n||D.textureOptions;const o=n.target||B,i=n.level||0;let s=r.width,a=r.height;const u=n.internalFormat||n.format||b,c=re(u),m=n.format||c.format,f=n.type||c.type;if(K(e,n),e.bindTexture(o,t),o===w){const x=r.width,h=r.height;let l,_;if(x/6===h)l=h,_=[0,0,1,0,2,0,3,0,4,0,5,0];else if(h/6===x)l=x,_=[0,0,0,1,0,2,0,3,0,4,0,5];else if(x/3===h/2)l=x/3,_=[0,0,1,0,2,0,0,1,1,1,2,1];else if(x/2===h/3)l=x/2,_=[0,0,1,0,0,1,1,1,0,2,1,2];else throw"can't figure out cube map from element: "+(r.src?r.src:r.nodeName);const T=yt();T?(T.canvas.width=l,T.canvas.height=l,s=l,a=l,Ve(e,n).forEach(function(p){const R=_[p.ndx*2+0]*l,y=_[p.ndx*2+1]*l;T.drawImage(r,R,y,l,l,0,0,l,l),e.texImage2D(p.face,i,u,m,f,T.canvas)}),T.canvas.width=1,T.canvas.height=1):typeof createImageBitmap<"u"&&(s=l,a=l,Ve(e,n).forEach(function(p){const R=_[p.ndx*2+0]*l,y=_[p.ndx*2+1]*l;e.texImage2D(p.face,i,u,l,l,0,m,f,null),createImageBitmap(r,R,y,l,l,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(function(E){K(e,n),e.bindTexture(o,t),e.texImage2D(p.face,i,u,m,f,E),ne(n)&&ke(e,t,n,s,a,u)})}))}else if(o===C||o===G){const x=Math.min(r.width,r.height),h=Math.max(r.width,r.height),l=h/x;if(l%1!==0)throw"can not compute 3D dimensions of element";const _=r.width===h?1:0,T=r.height===h?1:0;e.pixelStorei(Ce,1),e.pixelStorei(At,r.width),e.pixelStorei(bt,0),e.pixelStorei(Rt,0),e.texImage3D(o,i,u,x,x,x,0,m,f,null);for(let p=0;p<l;++p){const R=p*x*_,y=p*x*T;e.pixelStorei(St,R),e.pixelStorei(It,y),e.texSubImage3D(o,i,0,0,p,x,x,1,m,f,r)}vt(e)}else e.texImage2D(o,i,u,m,f,r);ne(n)&&ke(e,t,n,s,a,u),Ut(e,t,n)}function oe(){}function To(e){if(typeof document<"u"){const t=document.createElement("a");return t.href=e,t.hostname===location.hostname&&t.port===location.port&&t.protocol===location.protocol}else{const t=new URL(location.href).origin;return new URL(e,location.href).origin===t}}function po(e,t){return t===void 0&&!To(e)?"anonymous":t}function Ao(e,t,r){r=r||oe;let n;if(t=t!==void 0?t:D.crossOrigin,t=po(e,t),typeof Image<"u"){n=new Image,t!==void 0&&(n.crossOrigin=t);const o=function(){n.removeEventListener("error",i),n.removeEventListener("load",s),n=null},i=function(){const u="couldn't load image: "+e;it(u),r(u,n),o()},s=function(){r(null,n),o()};return n.addEventListener("error",i),n.addEventListener("load",s),n.src=e,n}else if(typeof ImageBitmap<"u"){let o,i;const s=function(){r(o,i)},a={};t&&(a.mode="cors"),fetch(e,a).then(function(u){if(!u.ok)throw u;return u.blob()}).then(function(u){return createImageBitmap(u,{premultiplyAlpha:"none",colorSpaceConversion:"none"})}).then(function(u){i=u,setTimeout(s)}).catch(function(u){o=u,setTimeout(s)}),n=null}return n}function Bt(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof ImageData<"u"&&e instanceof ImageData||typeof HTMLElement<"u"&&e instanceof HTMLElement}function He(e,t,r){return Bt(e)?(setTimeout(function(){r(null,e)}),e):Ao(e,t,r)}function Ye(e,t,r){r=r||D.textureOptions;const n=r.target||B;if(e.bindTexture(n,t),r.color===!1)return;const o=Eo(r.color);if(n===w)for(let i=0;i<6;++i)e.texImage2D(Le+i,0,b,1,1,0,b,A,o);else n===C||n===G?e.texImage3D(n,0,b,1,1,1,0,b,A,o):e.texImage2D(n,0,b,1,1,0,b,A,o)}function bo(e,t,r,n){return n=n||oe,r=r||D.textureOptions,Ye(e,t,r),r=Object.assign({},r),He(r.src,r.crossOrigin,function(i,s){i?n(i,t,s):(Dt(e,t,s,r),n(null,t,s))})}function So(e,t,r,n){n=n||oe;const o=r.src;if(o.length!==6)throw"there must be 6 urls for a cubemap";const i=r.level||0,s=r.internalFormat||r.format||b,a=re(s),u=r.format||a.format,c=r.type||A,m=r.target||B;if(m!==w)throw"target must be TEXTURE_CUBE_MAP";Ye(e,t,r),r=Object.assign({},r);let f=6;const x=[],h=ze(e,r);let l;function _(T){return function(p,R){--f,p?x.push(p):R.width!==R.height?x.push("cubemap face img is not a square: "+R.src):(K(e,r),e.bindTexture(m,t),f===5?ze().forEach(function(y){e.texImage2D(y,i,s,u,c,R)}):e.texImage2D(T,i,s,u,c,R),ne(r)&&e.generateMipmap(m)),f===0&&n(x.length?x:void 0,t,l)}}l=o.map(function(T,p){return He(T,r.crossOrigin,_(h[p]))})}function Io(e,t,r,n){n=n||oe;const o=r.src,i=r.internalFormat||r.format||b,s=re(i),a=r.format||s.format,u=r.type||A,c=r.target||G;if(c!==C&&c!==G)throw"target must be TEXTURE_3D or TEXTURE_2D_ARRAY";Ye(e,t,r),r=Object.assign({},r);let m=o.length;const f=[];let x;const h=r.level||0;let l=r.width,_=r.height;const T=o.length;let p=!0;function R(y){return function(E,V){if(--m,E)f.push(E);else{if(K(e,r),e.bindTexture(c,t),p){p=!1,l=r.width||V.width,_=r.height||V.height,e.texImage3D(c,h,i,l,_,T,0,a,u,null);for(let H=0;H<T;++H)e.texSubImage3D(c,h,0,0,H,l,_,1,a,u,V)}else{let H=V,U;(V.width!==l||V.height!==_)&&(U=yt(),H=U.canvas,U.canvas.width=l,U.canvas.height=_,U.drawImage(V,0,0,l,_)),e.texSubImage3D(c,h,0,0,y,l,_,1,a,u,H),U&&H===U.canvas&&(U.canvas.width=0,U.canvas.height=0)}ne(r)&&e.generateMipmap(c)}m===0&&n(f.length?f:void 0,t,x)}}x=o.map(function(y,E){return He(y,r.crossOrigin,R(E))})}function Ro(e,t,r,n){n=n||D.textureOptions;const o=n.target||B;e.bindTexture(o,t);let i=n.width,s=n.height,a=n.depth;const u=n.level||0,c=n.internalFormat||n.format||b,m=re(c),f=n.format||m.format,x=n.type||yo(e,r,m.type);if(q(r))r instanceof Uint8ClampedArray&&(r=new Uint8Array(r.buffer));else{const T=ot(x);r=new T(r)}const h=mo(c,x),l=r.byteLength/h;if(l%1)throw"length wrong size for format: "+ht(e,f);let _;if(o===C||o===G)if(!i&&!s&&!a){const T=Math.cbrt(l);if(T%1!==0)throw"can't guess cube size of array of numElements: "+l;i=T,s=T,a=T}else i&&(!s||!a)?(_=Te(e,o,s,a,l/i),s=_.width,a=_.height):s&&(!i||!a)?(_=Te(e,o,i,a,l/s),i=_.width,a=_.height):(_=Te(e,o,i,s,l/a),i=_.width,s=_.height);else _=Te(e,o,i,s,l),i=_.width,s=_.height;if(vt(e),e.pixelStorei(Ce,n.unpackAlignment||1),K(e,n),o===w){const T=h/r.BYTES_PER_ELEMENT,p=l/6*T;Ve(e,n).forEach(R=>{const y=p*R.ndx,E=r.subarray(y,y+p);e.texImage2D(R.face,u,c,i,s,0,f,x,E)})}else o===C||o===G?e.texImage3D(o,u,c,i,s,a,0,f,x,r):e.texImage2D(o,u,c,i,s,0,f,x,r);return{width:i,height:s,depth:a,type:x}}function Fo(e,t,r){const n=r.target||B;e.bindTexture(n,t);const o=r.level||0,i=r.internalFormat||r.format||b,s=re(i),a=r.format||s.format,u=r.type||s.type;if(K(e,r),n===w)for(let c=0;c<6;++c)e.texImage2D(Le+c,o,i,r.width,r.height,0,a,u,null);else n===C||n===G?e.texImage3D(n,o,i,r.width,r.height,r.depth,0,a,u,null):e.texImage2D(n,o,i,r.width,r.height,0,a,u,null)}function Po(e,t,r){r=r||oe,t=t||D.textureOptions;const n=e.createTexture(),o=t.target||B;let i=t.width||1,s=t.height||1;const a=t.internalFormat||b;e.bindTexture(o,n),o===w&&(e.texParameteri(o,me,le),e.texParameteri(o,xe,le));let u=t.src;if(u)if(typeof u=="function"&&(u=u(e,t)),typeof u=="string")bo(e,n,t,r);else if(q(u)||Array.isArray(u)&&(typeof u[0]=="number"||Array.isArray(u[0])||q(u[0]))){const c=Ro(e,n,u,t);i=c.width,s=c.height}else Array.isArray(u)&&(typeof u[0]=="string"||Bt(u[0]))?o===w?So(e,n,t,r):Io(e,n,t,r):(Dt(e,n,u,t),i=u.width,s=u.height);else Fo(e,n,t);return ne(t)&&ke(e,n,t,i,s,a),Ut(e,n,t),n}const Xe=it;function wt(e){return typeof document<"u"&&document.getElementById?document.getElementById(e):null}const pe=33984,Ae=34962,No=34963,go=35713,vo=35714,Uo=35632,Do=35633,Bo=35981,Lt=35718,wo=35721,Lo=35971,Mo=35382,Oo=35396,Co=35398,Go=35392,$o=35395,be=5126,Mt=35664,Ot=35665,Ct=35666,je=5124,Gt=35667,$t=35668,kt=35669,zt=35670,Vt=35671,Ht=35672,Yt=35673,Xt=35674,jt=35675,Zt=35676,ko=35678,zo=35680,Vo=35679,Ho=35682,Yo=35685,Xo=35686,jo=35687,Zo=35688,Wo=35689,Ko=35690,Jo=36289,Qo=36292,qo=36293,Ze=5125,Wt=36294,Kt=36295,Jt=36296,ei=36298,ti=36299,ri=36300,ni=36303,oi=36306,ii=36307,si=36308,ai=36311,Se=3553,Ie=34067,We=32879,Re=35866,d={};function Qt(e,t){return d[t].bindPoint}function ui(e,t){return function(r){e.uniform1f(t,r)}}function ci(e,t){return function(r){e.uniform1fv(t,r)}}function fi(e,t){return function(r){e.uniform2fv(t,r)}}function li(e,t){return function(r){e.uniform3fv(t,r)}}function mi(e,t){return function(r){e.uniform4fv(t,r)}}function qt(e,t){return function(r){e.uniform1i(t,r)}}function er(e,t){return function(r){e.uniform1iv(t,r)}}function tr(e,t){return function(r){e.uniform2iv(t,r)}}function rr(e,t){return function(r){e.uniform3iv(t,r)}}function nr(e,t){return function(r){e.uniform4iv(t,r)}}function xi(e,t){return function(r){e.uniform1ui(t,r)}}function hi(e,t){return function(r){e.uniform1uiv(t,r)}}function yi(e,t){return function(r){e.uniform2uiv(t,r)}}function di(e,t){return function(r){e.uniform3uiv(t,r)}}function _i(e,t){return function(r){e.uniform4uiv(t,r)}}function Ei(e,t){return function(r){e.uniformMatrix2fv(t,!1,r)}}function Ti(e,t){return function(r){e.uniformMatrix3fv(t,!1,r)}}function pi(e,t){return function(r){e.uniformMatrix4fv(t,!1,r)}}function Ai(e,t){return function(r){e.uniformMatrix2x3fv(t,!1,r)}}function bi(e,t){return function(r){e.uniformMatrix3x2fv(t,!1,r)}}function Si(e,t){return function(r){e.uniformMatrix2x4fv(t,!1,r)}}function Ii(e,t){return function(r){e.uniformMatrix4x2fv(t,!1,r)}}function Ri(e,t){return function(r){e.uniformMatrix3x4fv(t,!1,r)}}function Fi(e,t){return function(r){e.uniformMatrix4x3fv(t,!1,r)}}function P(e,t,r,n){const o=Qt(e,t);return Q(e)?function(i){let s,a;!i||at(e,i)?(s=i,a=null):(s=i.texture,a=i.sampler),e.uniform1i(n,r),e.activeTexture(pe+r),e.bindTexture(o,s),e.bindSampler(r,a)}:function(i){e.uniform1i(n,r),e.activeTexture(pe+r),e.bindTexture(o,i)}}function N(e,t,r,n,o){const i=Qt(e,t),s=new Int32Array(o);for(let a=0;a<o;++a)s[a]=r+a;return Q(e)?function(a){e.uniform1iv(n,s),a.forEach(function(u,c){e.activeTexture(pe+s[c]);let m,f;!u||at(e,u)?(m=u,f=null):(m=u.texture,f=u.sampler),e.bindSampler(r,f),e.bindTexture(i,m)})}:function(a){e.uniform1iv(n,s),a.forEach(function(u,c){e.activeTexture(pe+s[c]),e.bindTexture(i,u)})}}d[be]={Type:Float32Array,size:4,setter:ui,arraySetter:ci},d[Mt]={Type:Float32Array,size:8,setter:fi,cols:2},d[Ot]={Type:Float32Array,size:12,setter:li,cols:3},d[Ct]={Type:Float32Array,size:16,setter:mi,cols:4},d[je]={Type:Int32Array,size:4,setter:qt,arraySetter:er},d[Gt]={Type:Int32Array,size:8,setter:tr,cols:2},d[$t]={Type:Int32Array,size:12,setter:rr,cols:3},d[kt]={Type:Int32Array,size:16,setter:nr,cols:4},d[Ze]={Type:Uint32Array,size:4,setter:xi,arraySetter:hi},d[Wt]={Type:Uint32Array,size:8,setter:yi,cols:2},d[Kt]={Type:Uint32Array,size:12,setter:di,cols:3},d[Jt]={Type:Uint32Array,size:16,setter:_i,cols:4},d[zt]={Type:Uint32Array,size:4,setter:qt,arraySetter:er},d[Vt]={Type:Uint32Array,size:8,setter:tr,cols:2},d[Ht]={Type:Uint32Array,size:12,setter:rr,cols:3},d[Yt]={Type:Uint32Array,size:16,setter:nr,cols:4},d[Xt]={Type:Float32Array,size:32,setter:Ei,rows:2,cols:2},d[jt]={Type:Float32Array,size:48,setter:Ti,rows:3,cols:3},d[Zt]={Type:Float32Array,size:64,setter:pi,rows:4,cols:4},d[Yo]={Type:Float32Array,size:32,setter:Ai,rows:2,cols:3},d[Xo]={Type:Float32Array,size:32,setter:Si,rows:2,cols:4},d[jo]={Type:Float32Array,size:48,setter:bi,rows:3,cols:2},d[Zo]={Type:Float32Array,size:48,setter:Ri,rows:3,cols:4},d[Wo]={Type:Float32Array,size:64,setter:Ii,rows:4,cols:2},d[Ko]={Type:Float32Array,size:64,setter:Fi,rows:4,cols:3},d[ko]={Type:null,size:0,setter:P,arraySetter:N,bindPoint:Se},d[zo]={Type:null,size:0,setter:P,arraySetter:N,bindPoint:Ie},d[Vo]={Type:null,size:0,setter:P,arraySetter:N,bindPoint:We},d[Ho]={Type:null,size:0,setter:P,arraySetter:N,bindPoint:Se},d[Jo]={Type:null,size:0,setter:P,arraySetter:N,bindPoint:Re},d[Qo]={Type:null,size:0,setter:P,arraySetter:N,bindPoint:Re},d[qo]={Type:null,size:0,setter:P,arraySetter:N,bindPoint:Ie},d[ei]={Type:null,size:0,setter:P,arraySetter:N,bindPoint:Se},d[ti]={Type:null,size:0,setter:P,arraySetter:N,bindPoint:We},d[ri]={Type:null,size:0,setter:P,arraySetter:N,bindPoint:Ie},d[ni]={Type:null,size:0,setter:P,arraySetter:N,bindPoint:Re},d[oi]={Type:null,size:0,setter:P,arraySetter:N,bindPoint:Se},d[ii]={Type:null,size:0,setter:P,arraySetter:N,bindPoint:We},d[si]={Type:null,size:0,setter:P,arraySetter:N,bindPoint:Ie},d[ai]={Type:null,size:0,setter:P,arraySetter:N,bindPoint:Re};function Fe(e,t){return function(r){if(r.value)switch(e.disableVertexAttribArray(t),r.value.length){case 4:e.vertexAttrib4fv(t,r.value);break;case 3:e.vertexAttrib3fv(t,r.value);break;case 2:e.vertexAttrib2fv(t,r.value);break;case 1:e.vertexAttrib1fv(t,r.value);break;default:throw new Error("the length of a float constant value must be between 1 and 4!")}else e.bindBuffer(Ae,r.buffer),e.enableVertexAttribArray(t),e.vertexAttribPointer(t,r.numComponents||r.size,r.type||be,r.normalize||!1,r.stride||0,r.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,r.divisor||0)}}function M(e,t){return function(r){if(r.value)if(e.disableVertexAttribArray(t),r.value.length===4)e.vertexAttrib4iv(t,r.value);else throw new Error("The length of an integer constant value must be 4!");else e.bindBuffer(Ae,r.buffer),e.enableVertexAttribArray(t),e.vertexAttribIPointer(t,r.numComponents||r.size,r.type||je,r.stride||0,r.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,r.divisor||0)}}function Pe(e,t){return function(r){if(r.value)if(e.disableVertexAttribArray(t),r.value.length===4)e.vertexAttrib4uiv(t,r.value);else throw new Error("The length of an unsigned integer constant value must be 4!");else e.bindBuffer(Ae,r.buffer),e.enableVertexAttribArray(t),e.vertexAttribIPointer(t,r.numComponents||r.size,r.type||Ze,r.stride||0,r.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,r.divisor||0)}}function Ke(e,t,r){const n=r.size,o=r.count;return function(i){e.bindBuffer(Ae,i.buffer);const s=i.size||i.numComponents||n,a=s/o,u=i.type||be,m=d[u].size*s,f=i.normalize||!1,x=i.offset||0,h=m/o;for(let l=0;l<o;++l)e.enableVertexAttribArray(t+l),e.vertexAttribPointer(t+l,a,u,f,m,x+h*l),e.vertexAttribDivisor&&e.vertexAttribDivisor(t+l,i.divisor||0)}}const I={};I[be]={size:4,setter:Fe},I[Mt]={size:8,setter:Fe},I[Ot]={size:12,setter:Fe},I[Ct]={size:16,setter:Fe},I[je]={size:4,setter:M},I[Gt]={size:8,setter:M},I[$t]={size:12,setter:M},I[kt]={size:16,setter:M},I[Ze]={size:4,setter:Pe},I[Wt]={size:8,setter:Pe},I[Kt]={size:12,setter:Pe},I[Jt]={size:16,setter:Pe},I[zt]={size:4,setter:M},I[Vt]={size:8,setter:M},I[Ht]={size:12,setter:M},I[Yt]={size:16,setter:M},I[Xt]={size:4,setter:Ke,count:2},I[jt]={size:9,setter:Ke,count:3},I[Zt]={size:16,setter:Ke,count:4};const Pi=/ERROR:\s*\d+:(\d+)/gi;function Ni(e,t="",r=0){const n=[...t.matchAll(Pi)],o=new Map(n.map((i,s)=>{const a=parseInt(i[1]),u=n[s+1],c=u?u.index:t.length,m=t.substring(i.index,c);return[a-1,m]}));return e.split(`
4
- `).map((i,s)=>{const a=o.get(s);return`${s+1+r}: ${i}${a?`
5
-
6
- ^^^ ${a}`:""}`}).join(`
7
- `)}const or=/^[ \t]*\n/;function ir(e){let t=0;return or.test(e)&&(t=1,e=e.replace(or,"")),{lineOffset:t,shaderSource:e}}function gi(e,t){return e.errorCallback(t),e.callback&&setTimeout(()=>{e.callback(`${t}
8
- ${e.errors.join(`
9
- `)}`)}),null}function vi(e,t,r,n){if(n=n||Xe,!e.getShaderParameter(r,go)){const i=e.getShaderInfoLog(r),{lineOffset:s,shaderSource:a}=ir(e.getShaderSource(r)),u=`${Ni(a,i,s)}
10
- Error compiling ${ht(e,t)}: ${i}`;return n(u),u}return""}function Je(e,t,r){let n,o,i;if(typeof t=="function"&&(r=t,t=void 0),typeof e=="function")r=e,e=void 0;else if(e&&!Array.isArray(e)){const c=e;r=c.errorCallback,e=c.attribLocations,n=c.transformFeedbackVaryings,o=c.transformFeedbackMode,i=c.callback}const s=r||Xe,a=[],u={errorCallback(c,...m){a.push(c),s(c,...m)},transformFeedbackVaryings:n,transformFeedbackMode:o,callback:i,errors:a};{let c={};Array.isArray(e)?e.forEach(function(m,f){c[m]=t?t[f]:f}):c=e||{},u.attribLocations=c}return u}const Ui=["VERTEX_SHADER","FRAGMENT_SHADER"];function Di(e,t){if(t.indexOf("frag")>=0)return Uo;if(t.indexOf("vert")>=0)return Do}function Bi(e,t,r){const n=e.getAttachedShaders(t);for(const o of n)r.has(o)&&e.deleteShader(o);e.deleteProgram(t)}const wi=(e=0)=>new Promise(t=>setTimeout(t,e));function Li(e,t,r){const n=e.createProgram(),{attribLocations:o,transformFeedbackVaryings:i,transformFeedbackMode:s}=Je(r);for(let a=0;a<t.length;++a){let u=t[a];if(typeof u=="string"){const c=wt(u),m=c?c.text:u;let f=e[Ui[a]];c&&c.type&&(f=Di(e,c.type)||f),u=e.createShader(f),e.shaderSource(u,ir(m).shaderSource),e.compileShader(u),e.attachShader(n,u)}}Object.entries(o).forEach(([a,u])=>e.bindAttribLocation(n,u,a));{let a=i;a&&(a.attribs&&(a=a.attribs),Array.isArray(a)||(a=Object.keys(a)),e.transformFeedbackVaryings(n,a,s||Bo))}return e.linkProgram(n),n}function Mi(e,t,r,n,o){const i=Je(r,n,o),s=new Set(t),a=Li(e,t,i);function u(c,m){const f=Ci(c,m,i.errorCallback);return f&&Bi(c,m,s),f}if(i.callback){Oi(e,a).then(()=>{const c=u(e,a);i.callback(c,c?void 0:a)});return}return u(e,a)?void 0:a}async function Oi(e,t){const r=e.getExtension("KHR_parallel_shader_compile"),n=r?(i,s)=>i.getProgramParameter(s,r.COMPLETION_STATUS_KHR):()=>!0;let o=0;do await wi(o),o=1e3/60;while(!n(e,t))}function Ci(e,t,r){if(r=r||Xe,!e.getProgramParameter(t,vo)){const o=e.getProgramInfoLog(t);r(`Error in program linking: ${o}`);const s=e.getAttachedShaders(t).map(a=>vi(e,e.getShaderParameter(a,e.SHADER_TYPE),a,r));return`${o}
11
- ${s.filter(a=>a).join(`
12
- `)}`}}function Gi(e,t,r,n,o){return Mi(e,t,r,n,o)}function sr(e){const t=e.name;return t.startsWith("gl_")||t.startsWith("webgl_")}const $i=/(\.|\[|]|\w+)/g,ki=e=>e>="0"&&e<="9";function zi(e,t,r,n){const o=e.split($i).filter(a=>a!=="");let i=0,s="";for(;;){const a=o[i++];s+=a;const u=ki(a[0]),c=u?parseInt(a):a;if(u&&(s+=o[i++]),i===o.length){r[c]=t;break}else{const f=o[i++],x=f==="[",h=r[c]||(x?[]:{});r[c]=h,r=h,n[s]=n[s]||function(l){return function(_){ar(l,_)}}(h),s+=f}}}function Vi(e,t){let r=0;function n(a,u,c){const m=u.name.endsWith("[0]"),f=u.type,x=d[f];if(!x)throw new Error(`unknown type: 0x${f.toString(16)}`);let h;if(x.bindPoint){const l=r;r+=u.size,m?h=x.arraySetter(e,f,l,c,u.size):h=x.setter(e,f,l,c,u.size)}else x.arraySetter&&m?h=x.arraySetter(e,c):h=x.setter(e,c);return h.location=c,h}const o={},i={},s=e.getProgramParameter(t,Lt);for(let a=0;a<s;++a){const u=e.getActiveUniform(t,a);if(sr(u))continue;let c=u.name;c.endsWith("[0]")&&(c=c.substr(0,c.length-3));const m=e.getUniformLocation(t,u.name);if(m){const f=n(t,u,m);o[c]=f,zi(c,f,i,o)}}return o}function Hi(e,t){const r={},n=e.getProgramParameter(t,Lo);for(let o=0;o<n;++o){const i=e.getTransformFeedbackVarying(t,o);r[i.name]={index:o,type:i.type,size:i.size}}return r}function Yi(e,t){const r=e.getProgramParameter(t,Lt),n=[],o=[];for(let a=0;a<r;++a){o.push(a),n.push({});const u=e.getActiveUniform(t,a);n[a].name=u.name}[["UNIFORM_TYPE","type"],["UNIFORM_SIZE","size"],["UNIFORM_BLOCK_INDEX","blockNdx"],["UNIFORM_OFFSET","offset"]].forEach(function(a){const u=a[0],c=a[1];e.getActiveUniforms(t,o,e[u]).forEach(function(m,f){n[f][c]=m})});const i={},s=e.getProgramParameter(t,Mo);for(let a=0;a<s;++a){const u=e.getActiveUniformBlockName(t,a),c={index:e.getUniformBlockIndex(t,u),usedByVertexShader:e.getActiveUniformBlockParameter(t,a,Oo),usedByFragmentShader:e.getActiveUniformBlockParameter(t,a,Co),size:e.getActiveUniformBlockParameter(t,a,Go),uniformIndices:e.getActiveUniformBlockParameter(t,a,$o)};c.used=c.usedByVertexShader||c.usedByFragmentShader,i[u]=c}return{blockSpecs:i,uniformData:n}}function ar(e,t){for(const r in t){const n=e[r];typeof n=="function"?n(t[r]):ar(e[r],t[r])}}function Qe(e,...t){const r=e.uniformSetters||e,n=t.length;for(let o=0;o<n;++o){const i=t[o];if(Array.isArray(i)){const s=i.length;for(let a=0;a<s;++a)Qe(r,i[a])}else for(const s in i){const a=r[s];a&&a(i[s])}}}function Xi(e,t){const r={},n=e.getProgramParameter(t,wo);for(let o=0;o<n;++o){const i=e.getActiveAttrib(t,o);if(sr(i))continue;const s=e.getAttribLocation(t,i.name),a=I[i.type],u=a.setter(e,s,a);u.location=s,r[i.name]=u}return r}function ji(e,t){for(const r in t){const n=e[r];n&&n(t[r])}}function ur(e,t,r){r.vertexArrayObject?e.bindVertexArray(r.vertexArrayObject):(ji(t.attribSetters||t,r.attribs),r.indices&&e.bindBuffer(No,r.indices))}function cr(e,t){const r=Vi(e,t),n=Xi(e,t),o={program:t,uniformSetters:r,attribSetters:n};return Q(e)&&(o.uniformBlockSpec=Yi(e,t),o.transformFeedbackInfo=Hi(e,t)),o}const Zi=/\s|{|}|;/;function qe(e,t,r,n,o){const i=Je(r,n,o),s=[];if(t=t.map(function(c){if(!Zi.test(c)){const m=wt(c);if(m)c=m.text;else{const f=`no element with id: ${c}`;i.errorCallback(f),s.push(f)}}return c}),s.length)return gi(i,"");const a=i.callback;a&&(i.callback=(c,m)=>{a(c,c?void 0:cr(e,m))});const u=Gi(e,t,i);return u?cr(e,u):null}class Wi{constructor(t=[],r=(n,o)=>n<o?-1:n>o?1:0){if(this.data=t,this.length=this.data.length,this.compare=r,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;const t=this.data[0],r=this.data.pop();return--this.length>0&&(this.data[0]=r,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:r,compare:n}=this,o=r[t];for(;t>0;){const i=t-1>>1,s=r[i];if(n(o,s)>=0)break;r[t]=s,t=i}r[t]=o}_down(t){const{data:r,compare:n}=this,o=this.length>>1,i=r[t];for(;t<o;){let s=(t<<1)+1;const a=s+1;if(a<this.length&&n(r[a],r[s])<0&&(s=a),n(r[s],i)>=0)break;r[t]=r[s],t=s}r[t]=i}}class Ki{constructor(t,r,n,o){this._projector=t,this._verts=r,this._uv=n,this._projVerts=r.map(t),this._trigs=o,this._segs=[],this._segCount=0,this._segTrigs=[],this._queue=new Wi([],function(i,s){return s.epsilon-i.epsilon}),this._vertToSeg=new Array(r.length);for(const i in this._verts)this._vertToSeg[i]=[];for(const i in this._trigs){const s=this._trigs[i],a=s[0],u=s[1],c=s[2];this._segment(a,u,i),this._segment(u,c,i),this._segment(c,a,i)}}_segment(t,r,n,o=1/0){if(this._vertToSeg[t]&&this._vertToSeg[t][r]!==void 0){const m=this._vertToSeg[t][r];return this._segTrigs[m].includes(n)||this._segTrigs[m].push(n),m}const i=this._segCount++;this._segs[i]=[t,r],this._vertToSeg[t][r]=i,this._vertToSeg[r][t]=i,this._segTrigs[i]=[n];const s=[(this._verts[t][0]+this._verts[r][0])/2,(this._verts[t][1]+this._verts[r][1])/2],a=this._projector(s),u=[(this._projVerts[t][0]+this._projVerts[r][0])/2,(this._projVerts[t][1]+this._projVerts[r][1])/2],c=(a[0]-u[0])**2+(a[1]-u[1])**2;return Number.isFinite(c)&&c<o&&this._queue.push({v1:t,v2:r,epsilon:c,midpoint:s,projectedMid:a}),i}output(){return{unprojected:Array.from(this._verts),projected:Array.from(this._projVerts),uv:Array.from(this._uv),trigs:Array.from(this._trigs)}}_stepsWithSameEpsilon=0;lowerEpsilon(t){let r=this._queue.peek().epsilon,n=r;for(;r>=t;)if(this.step(),r=this._queue.peek().epsilon,r===n){if(this._stepsWithSameEpsilon++,this._stepsWithSameEpsilon<500){console.warn("Arrugator stopped due to epsilon stall. Raster may need hints for proper arrugation.");break}}else this._stepsWithSameEpsilon=0,n=r}get epsilon(){return this._queue.peek().epsilon}set epsilon(t){return this.lowerEpsilon(t)}step(){const t=this._queue.pop();return this._splitSegment(t,t.epsilon)}force(){const t=this._queue.data;this._queue.data=[],this._queue.length=0,t.forEach(r=>this._splitSegment(r,1/0))}_splitSegment(t,r){const n=t.v1,o=t.v2,i=this._vertToSeg[n]&&this._vertToSeg[n][o],s=this._segTrigs[i];if(s.length>=3)throw new Error("Somehow a segment is shared by three triangles");delete this._segTrigs[i],delete this._segs[i],delete this._vertToSeg[n][o],delete this._vertToSeg[o][n];const a=this._verts.length;this._projVerts[a]=t.projectedMid,this._verts[a]=t.midpoint,this._vertToSeg[a]=[],this._uv[a]=[(this._uv[n][0]+this._uv[o][0])/2,(this._uv[n][1]+this._uv[o][1])/2];for(const u of s)this._splitTriangle(n,o,a,u,r)}_splitTriangle(t,r,n,o,i=1/0){const s=this._trigs[o];let a,u=!1;if(s[0]===t&&s[1]===r)a=s[2],u=!0;else if(s[1]===t&&s[2]===r)a=s[0],u=!0;else if(s[2]===t&&s[0]===r)a=s[1],u=!0;else if(s[1]===t&&s[0]===r)a=s[2],u=!1;else if(s[2]===t&&s[1]===r)a=s[0],u=!1;else if(s[0]===t&&s[2]===r)a=s[1],u=!1;else throw new Error("Data structure mishap: could not fetch 3rd vertex used in triangle");const c=this._trigs.length;u?(this._trigs[o]=[t,n,a],this._trigs[c]=[n,r,a]):(this._trigs[o]=[n,t,a],this._trigs[c]=[r,n,a]);const m=this._vertToSeg[t]&&this._vertToSeg[t][r],f=this._vertToSeg[r]&&this._vertToSeg[r][a],x=this._vertToSeg[a]&&this._vertToSeg[a][t];function h(l){return l!==o}m!==void 0&&(this._segTrigs[m]=this._segTrigs[m].filter(h)),f!==void 0&&(this._segTrigs[f]=this._segTrigs[f].filter(h)),x!==void 0&&(this._segTrigs[x]=this._segTrigs[x].filter(h)),this._segment(t,n,o,i),this._segment(n,a,o,i),this._segment(a,t,o,i),this._segment(r,n,c,i),this._segment(n,a,c,i),this._segment(a,r,c,i)}}function fr(e,t,r=100){const n=[-20037508342789244e-9,20037508342789244e-9],o=[t[0],t[3],t[1],t[2]],i=Y(e,"EPSG:3857").forward;function s(m){const f=i(m),x=Math.abs((f[0]-n[0])/(20037508342789244e-9*2)),h=Math.abs((f[1]-n[1])/(20037508342789244e-9*2));return[x,h]}const a=[[0,0],[0,1],[1,0],[1,1]],u=new Ki(s,o,a,[[0,1,3],[0,3,2]]);if(r>0){u.force();for(let m=0;m<r;m++)u.step()}const c=u.output();return{pos:c.projected.flat(),uv:c.uv.flat(),trigs:c.trigs.flat()}}function lr(e,t,r=2){const n=t&&t.length,o=n?t[0]*r:e.length;let i=mr(e,0,o,r,!0);const s=[];if(!i||i.next===i.prev)return s;let a,u,c;if(n&&(i=ts(e,t,i,r)),e.length>80*r){a=1/0,u=1/0;let m=-1/0,f=-1/0;for(let x=r;x<o;x+=r){const h=e[x],l=e[x+1];h<a&&(a=h),l<u&&(u=l),h>m&&(m=h),l>f&&(f=l)}c=Math.max(m-a,f-u),c=c!==0?32767/c:0}return ie(i,s,r,a,u,c,0),s}function mr(e,t,r,n,o){let i;if(o===ms(e,t,r,n)>0)for(let s=t;s<r;s+=n)i=dr(s/n|0,e[s],e[s+1],i);else for(let s=r-n;s>=t;s-=n)i=dr(s/n|0,e[s],e[s+1],i);return i&&J(i,i.next)&&(ue(i),i=i.next),i}function z(e,t){if(!e)return e;t||(t=e);let r=e,n;do if(n=!1,!r.steiner&&(J(r,r.next)||S(r.prev,r,r.next)===0)){if(ue(r),r=t=r.prev,r===r.next)break;n=!0}else r=r.next;while(n||r!==t);return t}function ie(e,t,r,n,o,i,s){if(!e)return;!s&&i&&ss(e,n,o,i);let a=e;for(;e.prev!==e.next;){const u=e.prev,c=e.next;if(i?Qi(e,n,o,i):Ji(e)){t.push(u.i,e.i,c.i),ue(e),e=c.next,a=c.next;continue}if(e=c,e===a){s?s===1?(e=qi(z(e),t),ie(e,t,r,n,o,i,2)):s===2&&es(e,t,r,n,o,i):ie(z(e),t,r,n,o,i,1);break}}}function Ji(e){const t=e.prev,r=e,n=e.next;if(S(t,r,n)>=0)return!1;const o=t.x,i=r.x,s=n.x,a=t.y,u=r.y,c=n.y,m=Math.min(o,i,s),f=Math.min(a,u,c),x=Math.max(o,i,s),h=Math.max(a,u,c);let l=n.next;for(;l!==t;){if(l.x>=m&&l.x<=x&&l.y>=f&&l.y<=h&&se(o,a,i,u,s,c,l.x,l.y)&&S(l.prev,l,l.next)>=0)return!1;l=l.next}return!0}function Qi(e,t,r,n){const o=e.prev,i=e,s=e.next;if(S(o,i,s)>=0)return!1;const a=o.x,u=i.x,c=s.x,m=o.y,f=i.y,x=s.y,h=Math.min(a,u,c),l=Math.min(m,f,x),_=Math.max(a,u,c),T=Math.max(m,f,x),p=et(h,l,t,r,n),R=et(_,T,t,r,n);let y=e.prevZ,E=e.nextZ;for(;y&&y.z>=p&&E&&E.z<=R;){if(y.x>=h&&y.x<=_&&y.y>=l&&y.y<=T&&y!==o&&y!==s&&se(a,m,u,f,c,x,y.x,y.y)&&S(y.prev,y,y.next)>=0||(y=y.prevZ,E.x>=h&&E.x<=_&&E.y>=l&&E.y<=T&&E!==o&&E!==s&&se(a,m,u,f,c,x,E.x,E.y)&&S(E.prev,E,E.next)>=0))return!1;E=E.nextZ}for(;y&&y.z>=p;){if(y.x>=h&&y.x<=_&&y.y>=l&&y.y<=T&&y!==o&&y!==s&&se(a,m,u,f,c,x,y.x,y.y)&&S(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;E&&E.z<=R;){if(E.x>=h&&E.x<=_&&E.y>=l&&E.y<=T&&E!==o&&E!==s&&se(a,m,u,f,c,x,E.x,E.y)&&S(E.prev,E,E.next)>=0)return!1;E=E.nextZ}return!0}function qi(e,t){let r=e;do{const n=r.prev,o=r.next.next;!J(n,o)&&hr(n,r,r.next,o)&&ae(n,o)&&ae(o,n)&&(t.push(n.i,r.i,o.i),ue(r),ue(r.next),r=e=o),r=r.next}while(r!==e);return z(r)}function es(e,t,r,n,o,i){let s=e;do{let a=s.next.next;for(;a!==s.prev;){if(s.i!==a.i&&cs(s,a)){let u=yr(s,a);s=z(s,s.next),u=z(u,u.next),ie(s,t,r,n,o,i,0),ie(u,t,r,n,o,i,0);return}a=a.next}s=s.next}while(s!==e)}function ts(e,t,r,n){const o=[];for(let i=0,s=t.length;i<s;i++){const a=t[i]*n,u=i<s-1?t[i+1]*n:e.length,c=mr(e,a,u,n,!1);c===c.next&&(c.steiner=!0),o.push(us(c))}o.sort(rs);for(let i=0;i<o.length;i++)r=ns(o[i],r);return r}function rs(e,t){let r=e.x-t.x;if(r===0&&(r=e.y-t.y,r===0)){const n=(e.next.y-e.y)/(e.next.x-e.x),o=(t.next.y-t.y)/(t.next.x-t.x);r=n-o}return r}function ns(e,t){const r=os(e,t);if(!r)return t;const n=yr(r,e);return z(n,n.next),z(r,r.next)}function os(e,t){let r=t;const n=e.x,o=e.y;let i=-1/0,s;if(J(e,r))return r;do{if(J(e,r.next))return r.next;if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){const f=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(f<=n&&f>i&&(i=f,s=r.x<r.next.x?r:r.next,f===n))return s}r=r.next}while(r!==t);if(!s)return null;const a=s,u=s.x,c=s.y;let m=1/0;r=s;do{if(n>=r.x&&r.x>=u&&n!==r.x&&xr(o<c?n:i,o,u,c,o<c?i:n,o,r.x,r.y)){const f=Math.abs(o-r.y)/(n-r.x);ae(r,e)&&(f<m||f===m&&(r.x>s.x||r.x===s.x&&is(s,r)))&&(s=r,m=f)}r=r.next}while(r!==a);return s}function is(e,t){return S(e.prev,e,t.prev)<0&&S(t.next,e,e.next)<0}function ss(e,t,r,n){let o=e;do o.z===0&&(o.z=et(o.x,o.y,t,r,n)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next;while(o!==e);o.prevZ.nextZ=null,o.prevZ=null,as(o)}function as(e){let t,r=1;do{let n=e,o;e=null;let i=null;for(t=0;n;){t++;let s=n,a=0;for(let c=0;c<r&&(a++,s=s.nextZ,!!s);c++);let u=r;for(;a>0||u>0&&s;)a!==0&&(u===0||!s||n.z<=s.z)?(o=n,n=n.nextZ,a--):(o=s,s=s.nextZ,u--),i?i.nextZ=o:e=o,o.prevZ=i,i=o;n=s}i.nextZ=null,r*=2}while(t>1);return e}function et(e,t,r,n,o){return e=(e-r)*o|0,t=(t-n)*o|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function us(e){let t=e,r=e;do(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next;while(t!==e);return r}function xr(e,t,r,n,o,i,s,a){return(o-s)*(t-a)>=(e-s)*(i-a)&&(e-s)*(n-a)>=(r-s)*(t-a)&&(r-s)*(i-a)>=(o-s)*(n-a)}function se(e,t,r,n,o,i,s,a){return!(e===s&&t===a)&&xr(e,t,r,n,o,i,s,a)}function cs(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!fs(e,t)&&(ae(e,t)&&ae(t,e)&&ls(e,t)&&(S(e.prev,e,t.prev)||S(e,t.prev,t))||J(e,t)&&S(e.prev,e,e.next)>0&&S(t.prev,t,t.next)>0)}function S(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function J(e,t){return e.x===t.x&&e.y===t.y}function hr(e,t,r,n){const o=ge(S(e,t,r)),i=ge(S(e,t,n)),s=ge(S(r,n,e)),a=ge(S(r,n,t));return!!(o!==i&&s!==a||o===0&&Ne(e,r,t)||i===0&&Ne(e,n,t)||s===0&&Ne(r,e,n)||a===0&&Ne(r,t,n))}function Ne(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function ge(e){return e>0?1:e<0?-1:0}function fs(e,t){let r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&hr(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}function ae(e,t){return S(e.prev,e,e.next)<0?S(e,t,e.next)>=0&&S(e,e.prev,t)>=0:S(e,t,e.prev)<0||S(e,e.next,t)<0}function ls(e,t){let r=e,n=!1;const o=(e.x+t.x)/2,i=(e.y+t.y)/2;do r.y>i!=r.next.y>i&&r.next.y!==r.y&&o<(r.next.x-r.x)*(i-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;while(r!==e);return n}function yr(e,t){const r=tt(e.i,e.x,e.y),n=tt(t.i,t.x,t.y),o=e.next,i=t.prev;return e.next=t,t.prev=e,r.next=o,o.prev=r,n.next=r,r.prev=n,i.next=n,n.prev=i,n}function dr(e,t,r,n){const o=tt(e,t,r);return n?(o.next=n.next,o.prev=n,n.next.prev=o,n.next=o):(o.prev=o,o.next=o),o}function ue(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 tt(e,t,r){return{i:e,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function ms(e,t,r,n){let o=0;for(let i=t,s=r-n;i<r;i+=n)o+=(e[s]-e[i])*(e[i+1]+e[s+1]),s=i;return o}function _r(e){const t=[],r=[],n=e[0][0].length;let o=0,i=0;for(const s of e){for(const a of s)for(let u=0;u<n;u++)t.push(a[u]);i&&(o+=i,r.push(o)),i=s.length}return{vertices:t,holes:r,dimensions:n}}function Er(e){if(Object.prototype.hasOwnProperty.call(e,"type")){const t=e.type;if(t==="Polygon"||t==="MultiPolygon")return e;if(t==="Feature"&&(e.geometry.type==="Polygon"||e.geometry.type==="MultiPolygon"))return e.geometry;if(t==="FeatureCollection"){const r=e.features.filter(n=>n.geometry.type==="Polygon"||n.geometry.type==="MultiPolygon");if(r.length===1)return r[0].geometry;if(r.length>1){const n=[];for(const o of r){const i=o.geometry;if(i.type==="MultiPolygon")for(const s of i.coordinates)n.push(s);else n.push(i.coordinates)}return{type:"MultiPolygon",coordinates:n}}else throw new Error("No valid Polygon or MultiPolygon features found")}else throw new Error("Invalid GeoJSON format, only support Polygon, MultiPolygon, Feature, FeatureCollection")}else throw new Error("Invalid GeoJSON format")}function xs(e){return typeof e=="string"?fetch(e).then(t=>t.json()).then(t=>Er(t)):Promise.resolve(Er(e))}function hs(e){let t=[],r=[];if(e.type==="MultiPolygon"){const n=e.coordinates.length;let o=0;for(let i=0;i<n;i++){const s=e.coordinates[i],a=_r(s),{vertices:u,holes:c,dimensions:m}=a,x=lr(u,c,m).map(h=>h+o);o+=u.length/2;for(let h=0;h<u.length;h++)t.push(u[h]);for(let h=0;h<x.length;h++)r.push(x[h])}}else{const n=_r(e.coordinates),{vertices:o,holes:i,dimensions:s}=n;t=o,r=lr(o,i,s)}return{vertices:t,indices:r}}const ys=`
13
- #ifdef GL_ES
14
- precision highp int;
15
- precision mediump float;
16
- #endif
17
- uniform sampler2D u_sampler;
18
- uniform float u_opacity;
19
- varying vec2 v_uv;
20
- void main() {
21
- vec4 color = texture2D(u_sampler, v_uv);
22
- gl_FragColor = color * u_opacity;
23
- }
24
- `,ds=`
25
- uniform mat4 u_matrix;
26
- attribute vec2 a_pos;
27
- attribute vec2 a_uv;
28
- varying vec2 v_uv;
29
- void main() {
30
- gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);
31
- v_uv = a_uv;
32
- }
33
- `,Tr=`
34
- #ifdef GL_ES
35
- precision highp int;
36
- precision mediump float;
37
- #endif
38
-
39
- void main() {
40
- gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
41
- }
42
- `,pr=`
43
- uniform mat4 u_matrix;
44
- uniform float u_alt;
45
- attribute vec2 a_pos;
46
-
47
- const float PI = 3.1415926536;
48
- const float earthRadius = 6371008.8;
49
- const float earthCircumference = 2.0 * PI * earthRadius; // meters
50
-
51
- float circumferenceAtLatitude(float latitude) {
52
- return earthCircumference * cos(latitude * PI / 180.0);
53
- }
54
-
55
- float mercatorXfromLng(float lng) {
56
- return (180.0 + lng) / 360.0;
57
- }
58
-
59
- float mercatorYfromLat(float lat) {
60
- return (180.0 - (180.0 / PI * log(tan(PI / 4.0 + lat * PI / 360.0)))) / 360.0;
61
- }
62
-
63
- float mercatorZfromAltitude(float altitude, float lat) {
64
- return altitude / circumferenceAtLatitude(lat);
65
- }
66
-
67
- vec3 mercatorfromLngLat(vec2 lnglat, float alt) {
68
- return vec3(mercatorXfromLng(lnglat.x), mercatorYfromLat(lnglat.y), mercatorZfromAltitude(alt, lnglat.y));
69
- }
70
-
71
- void main() {
72
- vec3 mercator = mercatorfromLngLat(a_pos, 0.0);
73
- gl_Position = u_matrix * vec4(mercator, 1.0);
74
- // gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);
75
- }
76
- `;class _s{id;type="custom";renderingMode="2d";option;map;gl;loaded;arrugado;programInfo;bufferInfo;texture;maskProperty;maskProgramInfo;maskBufferInfo;constructor(t,r){this.id=t,this.option=r,this.loaded=!1,this.maskProperty=Object.assign({type:"in"},r.mask);const{projection:n,coordinates:o}=r;this.arrugado=fr(n,o,r.arrugatorStep)}onAdd(t,r){this.map=t,this.gl=r,this.programInfo=qe(r,[ds,ys]),this.loadTexture(t,r),this.bufferInfo=we(r,{a_pos:{numComponents:2,data:this.arrugado.pos},a_uv:{numComponents:2,data:this.arrugado.uv},indices:this.arrugado.trigs}),this.maskProperty.data&&this.getMaskBufferInfo(r,this.maskProperty.data).then(n=>{this.maskProgramInfo=qe(r,[pr,Tr]),this.maskBufferInfo=n})}onRemove(t,r){this.programInfo&&r.deleteProgram(this.programInfo.program),this.maskProgramInfo&&r.deleteProgram(this.maskProgramInfo.program),this.texture&&r.deleteTexture(this.texture)}render(t,r){if(!(this.maskProperty.data&&!this.maskBufferInfo)&&this.loaded&&this.programInfo&&this.bufferInfo){const n=Array.isArray(r)?r:r.defaultProjectionData.mainMatrix;if(t.enable(t.BLEND),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA),this.maskProgramInfo&&this.maskBufferInfo){this.map&&!this.map.painter.terrain&&(this.map.painter.currentStencilSource=void 0,this.map.painter._tileClippingMaskIDs={}),t.useProgram(this.maskProgramInfo.program),t.enable(t.STENCIL_TEST),t.stencilFunc(t.ALWAYS,1,255),t.stencilOp(t.REPLACE,t.REPLACE,t.REPLACE),t.stencilMask(255),t.clear(t.STENCIL_BUFFER_BIT),Qe(this.maskProgramInfo,{u_matrix:n}),ur(t,this.maskProgramInfo,this.maskBufferInfo);let o=t.UNSIGNED_SHORT;this.maskBufferInfo.numElements/3>65535&&(t.getExtension("OES_element_index_uint"),o=t.UNSIGNED_INT),t.drawElements(t.TRIANGLES,this.maskBufferInfo.numElements,o,0)}if(t.useProgram(this.programInfo.program),this.maskProgramInfo?.program){const o=this.maskProperty.type==="out"?0:1;t.stencilFunc(t.EQUAL,o,255),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}Qe(this.programInfo,{u_matrix:n,u_opacity:this.option.opacity??1,u_sampler:this.texture}),ur(t,this.programInfo,this.bufferInfo),t.drawElements(t.TRIANGLES,this.arrugado.trigs.length,t.UNSIGNED_SHORT,0)}}updateImage(t){return!this.map||!this.gl?this:(this.option.opacity=t.opacity??this.option.opacity,this.option.crossOrigin=t.crossOrigin??this.option.crossOrigin,(t.projection||t.coordinates||t.arrugatorStep)&&(this.option.projection=t.projection??this.option.projection,this.option.coordinates=t.coordinates??this.option.coordinates,this.option.arrugatorStep=t.arrugatorStep??this.option.arrugatorStep,this.arrugado=fr(this.option.projection,this.option.coordinates,this.option.arrugatorStep),this.bufferInfo=we(this.gl,{a_pos:{numComponents:2,data:this.arrugado.pos},a_uv:{numComponents:2,data:this.arrugado.uv},indices:this.arrugado.trigs})),t.url||t.resampling?(this.loaded=!1,this.option.url=t.url??this.option.url,this.option.resampling=t.resampling??this.option.resampling,this.loadTexture(this.map,this.gl)):this.map.triggerRepaint(),this)}updateMask(t){return!this.map||!this.gl?this:(this.maskProperty=Object.assign(this.maskProperty,t),t.data?this.getMaskBufferInfo(this.gl,t.data).then(r=>{this.maskProgramInfo||(this.maskProgramInfo=qe(this.gl,[pr,Tr])),this.maskBufferInfo=r,this.map?.triggerRepaint()}):t.hasOwnProperty("data")&&t.data===void 0?(this.maskBufferInfo=void 0,this.map?.triggerRepaint()):this.map?.triggerRepaint(),this)}loadTexture(t,r){const n=this.option.resampling==="nearest"?r.NEAREST:r.LINEAR;Po(r,{src:this.option.url,crossOrigin:this.option.crossOrigin,minMag:n,flipY:0,premultiplyAlpha:1},(o,i,s)=>{const a=r.getParameter(r.MAX_TEXTURE_SIZE),{width:u,height:c}=s;if(u>a||c>a)throw new Error(`The texture size exceeds the maximum supported size: ${a}x${a}`);this.texture=i,this.loaded=!0,t.triggerRepaint()})}getMaskBufferInfo(t,r){return xs(r).then(n=>{const{vertices:o,indices:i}=hs(n);return we(t,{a_pos:{numComponents:2,data:o},indices:i.length/3>65535?new Uint32Array(i):new Uint16Array(i)})})}}return _s});
@@ -1,36 +0,0 @@
1
- import * as GeoJSON from 'geojson';
2
- /**
3
- * The properties for masking the image layer.
4
- */
5
- export interface MaskProperty {
6
- /**
7
- * The type of mask operation to perform.
8
- * - 'in': The image will be visible only within the mask area.
9
- * - 'out': The image will be visible outside the mask area.
10
- * If not specified, defaults to 'in'.
11
- * @default 'in'
12
- */
13
- type?: 'in' | 'out';
14
- /**
15
- * The mask data, supporting inline GeoJSON and remote addresses.
16
- */
17
- data: GeoJSON.GeoJSON | string;
18
- }
19
- /**
20
- * Extracts a polygon or multipolygon from GeoJSON data.
21
- * Supports GeoJSON types: Polygon, MultiPolygon, Feature, and FeatureCollection.
22
- * @param data
23
- * @returns
24
- */
25
- export declare function extractPolygon(data: GeoJSON.GeoJSON): GeoJSON.Polygon | GeoJSON.MultiPolygon;
26
- export declare function extractPolygonAsync(data: GeoJSON.GeoJSON | string): Promise<GeoJSON.Polygon | GeoJSON.MultiPolygon>;
27
- /**
28
- * 三角化多边形
29
- * @param poly 多边形
30
- * @param poly
31
- * @returns 顶点和三角形索引
32
- */
33
- export declare function earcutPolygon(poly: GeoJSON.Polygon | GeoJSON.MultiPolygon): {
34
- vertices: number[];
35
- indices: number[];
36
- };
@@ -1,2 +0,0 @@
1
- declare const _default: "\n#ifdef GL_ES\n precision highp int;\n precision mediump float;\n#endif\nuniform sampler2D u_sampler;\nuniform float u_opacity;\nvarying vec2 v_uv;\nvoid main() {\n vec4 color = texture2D(u_sampler, v_uv);\n gl_FragColor = color * u_opacity;\n}\n";
2
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: "\nuniform mat4 u_matrix;\nattribute vec2 a_pos;\nattribute vec2 a_uv;\nvarying vec2 v_uv;\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);\n v_uv = a_uv;\n}\n";
2
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: "\n#ifdef GL_ES\nprecision highp int;\nprecision mediump float;\n#endif\n\nvoid main() {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n}\n";
2
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: "\nuniform mat4 u_matrix;\nuniform float u_alt;\nattribute vec2 a_pos;\n\nconst float PI = 3.1415926536;\nconst float earthRadius = 6371008.8;\nconst float earthCircumference = 2.0 * PI * earthRadius; // meters\n\nfloat circumferenceAtLatitude(float latitude) {\n return earthCircumference * cos(latitude * PI / 180.0);\n}\n\nfloat mercatorXfromLng(float lng) {\n return (180.0 + lng) / 360.0;\n}\n\nfloat mercatorYfromLat(float lat) {\n return (180.0 - (180.0 / PI * log(tan(PI / 4.0 + lat * PI / 360.0)))) / 360.0;\n}\n\nfloat mercatorZfromAltitude(float altitude, float lat) {\n return altitude / circumferenceAtLatitude(lat);\n}\n\nvec3 mercatorfromLngLat(vec2 lnglat, float alt) {\n return vec3(mercatorXfromLng(lnglat.x), mercatorYfromLat(lnglat.y), mercatorZfromAltitude(alt, lnglat.y));\n}\n\nvoid main() {\n vec3 mercator = mercatorfromLngLat(a_pos, 0.0);\n gl_Position = u_matrix * vec4(mercator, 1.0);\n // gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);\n}\n";
2
- export default _default;