@naivemap/image-layer-core 0.1.0 → 0.2.0-alpha.0
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.
|
@@ -0,0 +1,75 @@
|
|
|
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.ImageLayerCore=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,gr=5122,Pr=5123,Nr=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 xt(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 mt(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||(xt(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=mt(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(!xt(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:x}=s(e,o,n),f=o.normalize!==void 0?o.normalize:Dr(x),m=Or(o,n,c);r[i]={buffer:a,numComponents:m,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===gr||t===Pr?2:t===Nr||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=mt(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 J(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,qr=34074,Me=10241,Oe=10240,xe=10242,me=10243,pt=32882,Jr=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,xn=33330,mn=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,gn=33333,Pn=32849,Nn=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,qn=36238,Jn=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,gt=32820,Pt=33635,N=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,N,te,F]},t[_t]={textureFormat:_t,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[A,N,te,F]},t[Et]={textureFormat:Et,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[A,N,te,F]},t[v]={textureFormat:v,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[A,N,te,F,Pt]},t[b]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[A,N,te,F,Ft,gt]},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,N]},t[ln]={textureFormat:_e,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[F]},t[xn]={textureFormat:Z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[A]},t[mn]={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[gn]={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,N]},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[Pn]={textureFormat:v,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[A]},t[Nn]={textureFormat:v,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[A]},t[vn]={textureFormat:v,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[A,Pt]},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,N,uo]},t[Bn]={textureFormat:v,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[F,N,co]},t[wn]={textureFormat:v,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[F,N]},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,gt,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,N]},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[qn]={textureFormat:k,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[L]},t[Jn]={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 xo(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 Nt(e){return(e&e-1)===0}function mo(e,t,r,n){if(!J(e))return Nt(t)&&Nt(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),J(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,xe,n.wrap),r.call(e,t,me,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,xe,n.wrapS),n.wrapT&&r.call(e,t,me,n.wrapT),n.minLod!==void 0&&r.call(e,t,Jr,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),mo(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,xe,le),e.texParameteri(s,me,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,qr]}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),x=n.format||c.format,f=n.type||c.type;if(K(e,n),e.bindTexture(o,t),o===w){const m=r.width,h=r.height;let l,_;if(m/6===h)l=h,_=[0,0,1,0,2,0,3,0,4,0,5,0];else if(h/6===m)l=m,_=[0,0,0,1,0,2,0,3,0,4,0,5];else if(m/3===h/2)l=m/3,_=[0,0,1,0,2,0,0,1,1,1,2,1];else if(m/2===h/3)l=m/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,x,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,x,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,x,f,E),ne(n)&&ke(e,t,n,s,a,u)})}))}else if(o===C||o===G){const m=Math.min(r.width,r.height),h=Math.max(r.width,r.height),l=h/m;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,m,m,m,0,x,f,null);for(let p=0;p<l;++p){const R=p*m*_,y=p*m*T;e.pixelStorei(St,R),e.pixelStorei(It,y),e.texSubImage3D(o,i,0,0,p,m,m,1,x,f,r)}vt(e)}else e.texImage2D(o,i,u,x,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,x=r.target||B;if(x!==w)throw"target must be TEXTURE_CUBE_MAP";Ye(e,t,r),r=Object.assign({},r);let f=6;const m=[],h=ze(e,r);let l;function _(T){return function(p,R){--f,p?m.push(p):R.width!==R.height?m.push("cubemap face img is not a square: "+R.src):(K(e,r),e.bindTexture(x,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(x)),f===0&&n(m.length?m: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 x=o.length;const f=[];let m;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(--x,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)}x===0&&n(f.length?f:void 0,t,m)}}m=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,x=re(c),f=n.format||x.format,m=n.type||yo(e,r,x.type);if(Q(r))r instanceof Uint8ClampedArray&&(r=new Uint8Array(r.buffer));else{const T=ot(m);r=new T(r)}const h=xo(c,m),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,m,E)})}else o===C||o===G?e.texImage3D(o,u,c,i,s,a,0,f,m,r):e.texImage2D(o,u,c,i,s,0,f,m,r);return{width:i,height:s,depth:a,type:m}}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 go(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,xe,le),e.texParameteri(o,me,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,Po=34963,No=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,qo=36289,Jo=36292,Qo=36293,Ze=5125,Wt=36294,Kt=36295,qt=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 Jt(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 xi(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 mi(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 g(e,t,r,n){const o=Jt(e,t);return J(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 P(e,t,r,n,o){const i=Jt(e,t),s=new Int32Array(o);for(let a=0;a<o;++a)s[a]=r+a;return J(e)?function(a){e.uniform1iv(n,s),a.forEach(function(u,c){e.activeTexture(pe+s[c]);let x,f;!u||at(e,u)?(x=u,f=null):(x=u.texture,f=u.sampler),e.bindSampler(r,f),e.bindTexture(i,x)})}: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:xi,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:mi,arraySetter:hi},d[Wt]={Type:Uint32Array,size:8,setter:yi,cols:2},d[Kt]={Type:Uint32Array,size:12,setter:di,cols:3},d[qt]={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:g,arraySetter:P,bindPoint:Se},d[zo]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Ie},d[Vo]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:We},d[Ho]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Se},d[qo]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Re},d[Jo]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Re},d[Qo]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Ie},d[ei]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Se},d[ti]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:We},d[ri]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Ie},d[ni]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Re},d[oi]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Se},d[ii]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:We},d[si]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Ie},d[ai]={Type:null,size:0,setter:g,arraySetter:P,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 ge(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,x=d[u].size*s,f=i.normalize||!1,m=i.offset||0,h=x/o;for(let l=0;l<o;++l)e.enableVertexAttribArray(t+l),e.vertexAttribPointer(t+l,a,u,f,x,m+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:ge},I[Wt]={size:8,setter:ge},I[Kt]={size:12,setter:ge},I[qt]={size:16,setter:ge},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 gi=/ERROR:\s*\d+:(\d+)/gi;function Pi(e,t="",r=0){const n=[...t.matchAll(gi)],o=new Map(n.map((i,s)=>{const a=parseInt(i[1]),u=n[s+1],c=u?u.index:t.length,x=t.substring(i.index,c);return[a-1,x]}));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 Ni(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,No)){const i=e.getShaderInfoLog(r),{lineOffset:s,shaderSource:a}=ir(e.getShaderSource(r)),u=`${Pi(a,i,s)}
|
|
10
|
+
Error compiling ${ht(e,t)}: ${i}`;return n(u),u}return""}function qe(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,...x){a.push(c),s(c,...x)},transformFeedbackVaryings:n,transformFeedbackMode:o,callback:i,errors:a};{let c={};Array.isArray(e)?e.forEach(function(x,f){c[x]=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}=qe(r);for(let a=0;a<t.length;++a){let u=t[a];if(typeof u=="string"){const c=wt(u),x=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(x).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=qe(r,n,o),s=new Set(t),a=Li(e,t,i);function u(c,x){const f=Ci(c,x,i.errorCallback);return f&&Bi(c,x,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++],m=f==="[",h=r[c]||(m?[]:{});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 x=u.name.endsWith("[0]"),f=u.type,m=d[f];if(!m)throw new Error(`unknown type: 0x${f.toString(16)}`);let h;if(m.bindPoint){const l=r;r+=u.size,x?h=m.arraySetter(e,f,l,c,u.size):h=m.setter(e,f,l,c,u.size)}else m.arraySetter&&x?h=m.arraySetter(e,c):h=m.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 x=e.getUniformLocation(t,u.name);if(x){const f=n(t,u,x);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(x,f){n[f][c]=x})});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 Je(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)Je(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(Po,r.indices))}function cr(e,t){const r=Vi(e,t),n=Xi(e,t),o={program:t,uniformSetters:r,attribSetters:n};return J(e)&&(o.uniformBlockSpec=Yi(e,t),o.transformFeedbackInfo=Hi(e,t)),o}const Zi=/\s|{|}|;/;function Qe(e,t,r,n,o){const i=qe(r,n,o),s=[];if(t=t.map(function(c){if(!Zi.test(c)){const x=wt(c);if(x)c=x.text;else{const f=`no element with id: ${c}`;i.errorCallback(f),s.push(f)}}return c}),s.length)return Ni(i,"");const a=i.callback;a&&(i.callback=(c,x)=>{a(c,c?void 0:cr(e,x))});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 x=this._vertToSeg[t][r];return this._segTrigs[x].includes(n)||this._segTrigs[x].push(n),x}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 x=this._vertToSeg[t]&&this._vertToSeg[t][r],f=this._vertToSeg[r]&&this._vertToSeg[r][a],m=this._vertToSeg[a]&&this._vertToSeg[a][t];function h(l){return l!==o}x!==void 0&&(this._segTrigs[x]=this._segTrigs[x].filter(h)),f!==void 0&&(this._segTrigs[f]=this._segTrigs[f].filter(h)),m!==void 0&&(this._segTrigs[m]=this._segTrigs[m].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(x){const f=i(x),m=Math.abs((f[0]-n[0])/(20037508342789244e-9*2)),h=Math.abs((f[1]-n[1])/(20037508342789244e-9*2));return[m,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 x=0;x<r;x++)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=xr(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 x=-1/0,f=-1/0;for(let m=r;m<o;m+=r){const h=e[m],l=e[m+1];h<a&&(a=h),l<u&&(u=l),h>x&&(x=h),l>f&&(f=l)}c=Math.max(x-a,f-u),c=c!==0?32767/c:0}return ie(i,s,r,a,u,c,0),s}function xr(e,t,r,n,o){let i;if(o===xs(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&&q(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&&(q(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?Ji(e,n,o,i):qi(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 qi(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,x=Math.min(o,i,s),f=Math.min(a,u,c),m=Math.max(o,i,s),h=Math.max(a,u,c);let l=n.next;for(;l!==t;){if(l.x>=x&&l.x<=m&&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 Ji(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,x=o.y,f=i.y,m=s.y,h=Math.min(a,u,c),l=Math.min(x,f,m),_=Math.max(a,u,c),T=Math.max(x,f,m),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,x,u,f,c,m,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,x,u,f,c,m,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,x,u,f,c,m,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,x,u,f,c,m,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;!q(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=xr(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(q(e,r))return r;do{if(q(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 x=1/0;r=s;do{if(n>=r.x&&r.x>=u&&n!==r.x&&mr(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<x||f===x&&(r.x>s.x||r.x===s.x&&is(s,r)))&&(s=r,x=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 mr(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)&&mr(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))||q(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 q(e,t){return e.x===t.x&&e.y===t.y}function hr(e,t,r,n){const o=Ne(S(e,t,r)),i=Ne(S(e,t,n)),s=Ne(S(r,n,e)),a=Ne(S(r,n,t));return!!(o!==i&&s!==a||o===0&&Pe(e,r,t)||i===0&&Pe(e,n,t)||s===0&&Pe(r,e,n)||a===0&&Pe(r,t,n))}function Pe(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 Ne(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 xs(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 ms(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:x}=a,m=lr(u,c,x).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<m.length;h++)r.push(m[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;
|
|
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
|
+
}
|
|
75
|
+
`;class _s{option;map;gl;loaded;arrugado;programInfo;bufferInfo;texture;maskProperty;maskProgramInfo;maskBufferInfo;constructor(t){this.option=t,this.loaded=!1,this.maskProperty=Object.assign({type:"in"},t.mask);const{projection:r,coordinates:n}=t;this.arrugado=fr(r,n,t.arrugatorStep)}onAdd(t,r){if(!r)throw new Error("ImageLayerCore requires a WebGL rendering context during onAdd.");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){r&&(this.programInfo&&r.deleteProgram(this.programInfo.program),this.maskProgramInfo&&r.deleteProgram(this.maskProgramInfo.program),this.texture&&(r.deleteTexture(this.texture),this.texture=void 0))}render(t){if(this.maskProperty.data&&!this.maskBufferInfo)return;const r=t.gl;if(this.loaded&&this.programInfo&&this.bufferInfo){if(r.enable(r.BLEND),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),this.maskProgramInfo&&this.maskBufferInfo){t.prepareStencilMask?.(),r.useProgram(this.maskProgramInfo.program),r.enable(r.STENCIL_TEST),r.stencilFunc(r.ALWAYS,1,255),r.stencilOp(r.REPLACE,r.REPLACE,r.REPLACE),r.stencilMask(255),r.clear(r.STENCIL_BUFFER_BIT),Je(this.maskProgramInfo,{u_matrix:t.matrix}),ur(r,this.maskProgramInfo,this.maskBufferInfo);let n=r.UNSIGNED_SHORT;this.maskBufferInfo.numElements/3>65535&&(r.getExtension("OES_element_index_uint"),n=r.UNSIGNED_INT),r.drawElements(r.TRIANGLES,this.maskBufferInfo.numElements,n,0)}if(r.useProgram(this.programInfo.program),this.maskProgramInfo?.program){const n=this.maskProperty.type==="out"?0:1;r.stencilFunc(r.EQUAL,n,255),r.stencilOp(r.KEEP,r.KEEP,r.KEEP)}Je(this.programInfo,{u_matrix:t.matrix,u_opacity:this.option.opacity??1,u_sampler:this.texture}),ur(r,this.programInfo,this.bufferInfo),r.drawElements(r.TRIANGLES,this.arrugado.trigs.length,r.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()}):Object.prototype.hasOwnProperty.call(t,"data")&&t.data===void 0?(this.maskBufferInfo=void 0,this.map?.triggerRepaint()):this.map?.triggerRepaint(),this)}loadTexture(t,r){this.texture&&(r.deleteTexture(this.texture),this.texture=void 0);const n=this.option.resampling==="nearest"?r.NEAREST:r.LINEAR;go(r,{src:this.option.url,crossOrigin:this.option.crossOrigin,minMag:n,flipY:0,premultiplyAlpha:1},(o,i,s)=>{if(o)throw o;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 ms(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});
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naivemap/image-layer-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-alpha.0",
|
|
4
4
|
"description": "Map engine agnostic image custom layer core.",
|
|
5
|
-
"main": "./dist/index.
|
|
6
|
-
"module": "./dist/index.js",
|
|
5
|
+
"main": "./dist/index.umd.js",
|
|
6
|
+
"module": "./dist/index.es.js",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.js",
|
|
12
|
-
"require": "./dist/index.
|
|
11
|
+
"import": "./dist/index.es.js",
|
|
12
|
+
"require": "./dist/index.umd.js"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"earcut": "^3.0.1",
|
|
36
36
|
"tinyqueue": "^3.0.0",
|
|
37
37
|
"twgl.js": "^5.5.4",
|
|
38
|
-
"@naivemap/map-gl-layer-adaptor": "0.
|
|
38
|
+
"@naivemap/map-gl-layer-adaptor": "0.2.0-alpha.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"proj4": "^2.8.0"
|
package/dist/index.cjs
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";const Ir=require("proj4");/* @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 $e=5120,ee=5121,Ve=5122,He=5123,Xe=5124,Ze=5125,je=5126,gr=32819,Pr=32820,vr=33635,Nr=5131,Ur=33640,Br=35899,wr=35902,Dr=36269,Lr=34042,gt={};{const e=gt;e[$e]=Int8Array,e[ee]=Uint8Array,e[Ve]=Int16Array,e[He]=Uint16Array,e[Xe]=Int32Array,e[Ze]=Uint32Array,e[je]=Float32Array,e[gr]=Uint16Array,e[Pr]=Uint16Array,e[vr]=Uint16Array,e[Nr]=Uint16Array,e[Ur]=Uint32Array,e[Br]=Uint32Array,e[wr]=Uint32Array,e[Dr]=Uint32Array,e[Lr]=Uint32Array}function We(e){if(e instanceof Int8Array)return $e;if(e instanceof Uint8Array||e instanceof Uint8ClampedArray)return ee;if(e instanceof Int16Array)return Ve;if(e instanceof Uint16Array)return He;if(e instanceof Int32Array)return Xe;if(e instanceof Uint32Array)return Ze;if(e instanceof Float32Array)return je;throw new Error("unsupported typed array type")}function Pt(e){if(e===Int8Array)return $e;if(e===Uint8Array||e===Uint8ClampedArray)return ee;if(e===Int16Array)return Ve;if(e===Uint16Array)return He;if(e===Int32Array)return Xe;if(e===Uint32Array)return Ze;if(e===Float32Array)return je;throw new Error("unsupported typed array type")}function vt(e){const t=gt[e];if(!t)throw new Error("unknown gl type");return t}const de=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 Nt(...e){console.error(...e)}const at=new Map;function Ye(e,t){if(!e||typeof e!="object")return!1;let r=at.get(t);r||(r=new WeakMap,at.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 Mr(e,t){return typeof WebGLBuffer<"u"&&Ye(t,"WebGLBuffer")}function Ut(e,t){return typeof WebGLTexture<"u"&&Ye(t,"WebGLTexture")}function Cr(e,t){return typeof WebGLSampler<"u"&&Ye(t,"WebGLSampler")}const Bt=35044,z=34962,Or=34963,Gr=34660,kr=5120,zr=5121,$r=5122,Vr=5123,Hr=5124,Xr=5125,wt=5126,Dt={attribPrefix:""};function Zr(e,t,r,n,o){e.bindBuffer(t,r),e.bufferData(t,n,o||Bt)}function Lt(e,t,r,n){if(Mr(e,t))return t;r=r||z;const o=e.createBuffer();return Zr(e,r,o,t,n),o}function Mt(e){return e==="indices"}function jr(e){return e===Int8Array||e===Uint8Array}function Wr(e){return e.length?e:e.data}const Yr=/coord|texture/i,Kr=/color|colour/i;function qr(e,t){let r;if(Yr.test(e)?r=2:Kr.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 Jr(e,t,r){return e.numComponents||e.size||qr(t,r||Wr(e).length)}function Ct(e,t){if(de(e))return e;if(de(e.data))return e.data;Array.isArray(e)&&(e={data:e});let r=e.type?Ke(e.type):void 0;return r||(Mt(t)?r=Uint16Array:r=Float32Array),new r(e.data)}function Qr(e){return typeof e=="number"?e:e?Pt(e):wt}function Ke(e){return typeof e=="number"?vt(e):e||Float32Array}function en(e,t){return{buffer:t.buffer,numValues:2*3*4,type:Qr(t.type),arrayType:Ke(t.type)}}function tn(e,t){const r=t.data||t,n=Ke(t.type),o=r*n.BYTES_PER_ELEMENT,i=e.createBuffer();return e.bindBuffer(z,i),e.bufferData(z,o,t.drawType||Bt),{buffer:i,numValues:r,type:Pt(n),arrayType:n}}function rn(e,t,r){const n=Ct(t,r);return{arrayType:n.constructor,buffer:Lt(e,n,void 0,t.drawType),type:We(n),numValues:0}}function nn(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||Dt.attribPrefix+n;if(o.value){if(!Array.isArray(o.value)&&!de(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=en:typeof o=="number"||typeof o.data=="number"?s=tn:s=rn;const{buffer:a,type:u,numValues:c,arrayType:x}=s(e,o,n),f=o.normalize!==void 0?o.normalize:jr(x),m=Jr(o,n,c);r[i]={buffer:a,numComponents:m,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(z,null),r}function on(e,t){return t===kr||t===zr?1:t===$r||t===Vr?2:t===Hr||t===Xr||t===wt?4:0}const ve=["position","positions","a_position"];function sn(e,t){let r,n;for(n=0;n<ve.length&&(r=ve[n],!(r in t||(r=Dt.attribPrefix+r,r in t)));++n);n===ve.length&&(r=Object.keys(t)[0]);const o=t[r];if(!o.buffer)return 1;e.bindBuffer(z,o.buffer);const i=e.getBufferParameter(z,Gr);e.bindBuffer(z,null);const s=on(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 Ne(e,t,r){const n=nn(e,t),o=Object.assign({},r||{});o.attribs=Object.assign({},r?r.attribs:{},n);const i=t.indices;if(i){const s=Ct(i,"indices");o.indices=Lt(e,s,Or),o.numElements=s.length,o.elementType=We(s)}else o.numElements||(o.numElements=sn(e,o.attribs));return o}function se(e){return!!e.texStorage2D}const Ot=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},te=de,Gt=function(){let e;return function(){return e=e||(typeof document<"u"&&document.createElement?document.createElement("canvas").getContext("2d"):null),e}}(),ut=6406,N=6407,b=6408,ct=6409,ft=6410,q=6402,lt=34041,Ee=33071,an=9728,un=9729,L=3553,w=34067,$=32879,V=35866,qe=34069,cn=34070,fn=34071,ln=34072,xn=34073,mn=34074,De=10241,Le=10240,_e=10242,pe=10243,xt=32882,hn=33082,yn=33083,dn=33084,En=33085,_n=34892,pn=34893,Je=3317,kt=3314,zt=32878,$t=3316,Vt=3315,Ht=32877,Tn=37443,An=37441,bn=37440,Sn=33321,Fn=36756,Rn=33325,In=33326,gn=33330,Pn=33329,vn=33338,Nn=33337,Un=33340,Bn=33339,wn=33323,Dn=36757,Ln=33327,Mn=33328,Cn=33336,On=33335,Gn=33332,kn=33331,zn=33334,$n=33333,Vn=32849,Hn=35905,Xn=36194,Zn=36758,jn=35898,Wn=35901,Yn=34843,Kn=34837,qn=36221,Jn=36239,Qn=36215,eo=36233,to=36209,ro=36227,no=32856,oo=35907,io=36759,so=32855,ao=32854,uo=32857,co=34842,fo=34836,lo=36220,xo=36238,mo=36975,ho=36214,yo=36232,Eo=36226,_o=36208,po=33189,To=33190,Ao=36012,bo=36013,So=35056,B=5120,A=5121,ce=5122,X=5123,fe=5124,G=5125,I=5126,mt=32819,ht=32820,yt=33635,v=5131,J=36193,Ue=33640,Fo=35899,Ro=35902,Io=36269,go=34042,le=33319,Z=33320,xe=6403,j=36244,W=36248,k=36249;let Be;function Ae(e){if(!Be){const t={};t[ut]={textureFormat:ut,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[A,v,J,I]},t[ct]={textureFormat:ct,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[A,v,J,I]},t[ft]={textureFormat:ft,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[A,v,J,I]},t[N]={textureFormat:N,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[A,v,J,I,yt]},t[b]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[A,v,J,I,mt,ht]},t[q]={textureFormat:q,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[G,X]},t[Sn]={textureFormat:xe,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[A]},t[Fn]={textureFormat:xe,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[B]},t[Rn]={textureFormat:xe,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[I,v]},t[In]={textureFormat:xe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[I]},t[gn]={textureFormat:j,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[A]},t[Pn]={textureFormat:j,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[B]},t[Gn]={textureFormat:j,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[X]},t[kn]={textureFormat:j,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[ce]},t[zn]={textureFormat:j,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[G]},t[$n]={textureFormat:j,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[fe]},t[wn]={textureFormat:le,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[A]},t[Dn]={textureFormat:le,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[B]},t[Ln]={textureFormat:le,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[I,v]},t[Mn]={textureFormat:le,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[I]},t[Cn]={textureFormat:Z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[A]},t[On]={textureFormat:Z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[B]},t[vn]={textureFormat:Z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[X]},t[Nn]={textureFormat:Z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ce]},t[Un]={textureFormat:Z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[G]},t[Bn]={textureFormat:Z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[fe]},t[Vn]={textureFormat:N,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[A]},t[Hn]={textureFormat:N,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[A]},t[Xn]={textureFormat:N,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[A,yt]},t[Zn]={textureFormat:N,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[B]},t[jn]={textureFormat:N,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[I,v,Fo]},t[Wn]={textureFormat:N,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[I,v,Ro]},t[Yn]={textureFormat:N,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[I,v]},t[Kn]={textureFormat:N,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[I]},t[qn]={textureFormat:W,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[A]},t[Jn]={textureFormat:W,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[B]},t[Qn]={textureFormat:W,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[X]},t[eo]={textureFormat:W,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[ce]},t[to]={textureFormat:W,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[G]},t[ro]={textureFormat:W,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[fe]},t[no]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[A]},t[oo]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[A]},t[io]={textureFormat:b,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[B]},t[so]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[A,ht,Ue]},t[ao]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[A,mt]},t[uo]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[Ue]},t[co]={textureFormat:b,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[I,v]},t[fo]={textureFormat:b,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[I]},t[lo]={textureFormat:k,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[A]},t[xo]={textureFormat:k,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[B]},t[mo]={textureFormat:k,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Ue]},t[ho]={textureFormat:k,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[X]},t[yo]={textureFormat:k,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[ce]},t[Eo]={textureFormat:k,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[fe]},t[_o]={textureFormat:k,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[G]},t[po]={textureFormat:q,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[X,G]},t[To]={textureFormat:q,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[G]},t[Ao]={textureFormat:q,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[I]},t[So]={textureFormat:lt,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[go]},t[bo]={textureFormat:lt,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Io]},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})}),Be=t}return Be[e]}function Po(e,t){const r=Ae(e);if(!r)throw"unknown internal format";const n=r.bytesPerElementMap[t];if(n===void 0)throw"unknown internal format";return n}function ae(e){const t=Ae(e);if(!t)throw"unknown internal format";return{format:t.textureFormat,type:t.type[0]}}function dt(e){return(e&e-1)===0}function vo(e,t,r,n){if(!se(e))return dt(t)&&dt(r);const o=Ae(n);if(!o)throw"unknown internal format";return o.colorRenderable&&o.textureFilterable}function No(e){const t=Ae(e);if(!t)throw"unknown internal format";return t.textureFilterable}function Uo(e,t,r){return te(t)?We(t):r||A}function me(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 Y(e,t){t.colorspaceConversion!==void 0&&e.pixelStorei(Tn,t.colorspaceConversion),t.premultiplyAlpha!==void 0&&e.pixelStorei(An,t.premultiplyAlpha),t.flipY!==void 0&&e.pixelStorei(bn,t.flipY)}function Xt(e){e.pixelStorei(Je,4),se(e)&&(e.pixelStorei(kt,0),e.pixelStorei(zt,0),e.pixelStorei($t,0),e.pixelStorei(Vt,0),e.pixelStorei(Ht,0))}function Bo(e,t,r,n){n.minMag&&(r.call(e,t,De,n.minMag),r.call(e,t,Le,n.minMag)),n.min&&r.call(e,t,De,n.min),n.mag&&r.call(e,t,Le,n.mag),n.wrap&&(r.call(e,t,_e,n.wrap),r.call(e,t,pe,n.wrap),(t===$||Cr(e,t))&&r.call(e,t,xt,n.wrap)),n.wrapR&&r.call(e,t,xt,n.wrapR),n.wrapS&&r.call(e,t,_e,n.wrapS),n.wrapT&&r.call(e,t,pe,n.wrapT),n.minLod!==void 0&&r.call(e,t,hn,n.minLod),n.maxLod!==void 0&&r.call(e,t,yn,n.maxLod),n.baseLevel!==void 0&&r.call(e,t,dn,n.baseLevel),n.maxLevel!==void 0&&r.call(e,t,En,n.maxLevel),n.compareFunc!==void 0&&r.call(e,t,pn,n.compareFunc),n.compareMode!==void 0&&r.call(e,t,_n,n.compareMode)}function Zt(e,t,r){const n=r.target||L;e.bindTexture(n,t),Bo(e,n,e.texParameteri,r)}function wo(e){return e=e||D.textureColor,te(e)?e:new Uint8Array([e[0]*255,e[1]*255,e[2]*255,e[3]*255])}function Me(e,t,r,n,o,i){r=r||D.textureOptions,i=i||b;const s=r.target||L;if(n=n||r.width,o=o||r.height,e.bindTexture(s,t),vo(e,n,o,i))e.generateMipmap(s);else{const a=No(i)?un:an;e.texParameteri(s,De,a),e.texParameteri(s,Le,a),e.texParameteri(s,_e,Ee),e.texParameteri(s,pe,Ee)}}function re(e){return e.auto===!0||e.auto===void 0&&e.level===void 0}function Ce(e,t){return t=t||{},t.cubeFaceOrder||[qe,cn,fn,ln,xn,mn]}function Oe(e,t){const n=Ce(e,t).map(function(o,i){return{face:o,ndx:i}});return n.sort(function(o,i){return o.face-i.face}),n}function jt(e,t,r,n){n=n||D.textureOptions;const o=n.target||L,i=n.level||0;let s=r.width,a=r.height;const u=n.internalFormat||n.format||b,c=ae(u),x=n.format||c.format,f=n.type||c.type;if(Y(e,n),e.bindTexture(o,t),o===w){const m=r.width,h=r.height;let l,E;if(m/6===h)l=h,E=[0,0,1,0,2,0,3,0,4,0,5,0];else if(h/6===m)l=m,E=[0,0,0,1,0,2,0,3,0,4,0,5];else if(m/3===h/2)l=m/3,E=[0,0,1,0,2,0,0,1,1,1,2,1];else if(m/2===h/3)l=m/2,E=[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 p=Gt();p?(p.canvas.width=l,p.canvas.height=l,s=l,a=l,Oe(e,n).forEach(function(T){const R=E[T.ndx*2+0]*l,y=E[T.ndx*2+1]*l;p.drawImage(r,R,y,l,l,0,0,l,l),e.texImage2D(T.face,i,u,x,f,p.canvas)}),p.canvas.width=1,p.canvas.height=1):typeof createImageBitmap<"u"&&(s=l,a=l,Oe(e,n).forEach(function(T){const R=E[T.ndx*2+0]*l,y=E[T.ndx*2+1]*l;e.texImage2D(T.face,i,u,l,l,0,x,f,null),createImageBitmap(r,R,y,l,l,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(function(_){Y(e,n),e.bindTexture(o,t),e.texImage2D(T.face,i,u,x,f,_),re(n)&&Me(e,t,n,s,a,u)})}))}else if(o===$||o===V){const m=Math.min(r.width,r.height),h=Math.max(r.width,r.height),l=h/m;if(l%1!==0)throw"can not compute 3D dimensions of element";const E=r.width===h?1:0,p=r.height===h?1:0;e.pixelStorei(Je,1),e.pixelStorei(kt,r.width),e.pixelStorei(zt,0),e.pixelStorei(Ht,0),e.texImage3D(o,i,u,m,m,m,0,x,f,null);for(let T=0;T<l;++T){const R=T*m*E,y=T*m*p;e.pixelStorei($t,R),e.pixelStorei(Vt,y),e.texSubImage3D(o,i,0,0,T,m,m,1,x,f,r)}Xt(e)}else e.texImage2D(o,i,u,x,f,r);re(n)&&Me(e,t,n,s,a,u),Zt(e,t,n)}function ue(){}function Do(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 Lo(e,t){return t===void 0&&!Do(e)?"anonymous":t}function Mo(e,t,r){r=r||ue;let n;if(t=t!==void 0?t:D.crossOrigin,t=Lo(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;Nt(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 Wt(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof ImageData<"u"&&e instanceof ImageData||typeof HTMLElement<"u"&&e instanceof HTMLElement}function Qe(e,t,r){return Wt(e)?(setTimeout(function(){r(null,e)}),e):Mo(e,t,r)}function et(e,t,r){r=r||D.textureOptions;const n=r.target||L;if(e.bindTexture(n,t),r.color===!1)return;const o=wo(r.color);if(n===w)for(let i=0;i<6;++i)e.texImage2D(qe+i,0,b,1,1,0,b,A,o);else n===$||n===V?e.texImage3D(n,0,b,1,1,1,0,b,A,o):e.texImage2D(n,0,b,1,1,0,b,A,o)}function Co(e,t,r,n){return n=n||ue,r=r||D.textureOptions,et(e,t,r),r=Object.assign({},r),Qe(r.src,r.crossOrigin,function(i,s){i?n(i,t,s):(jt(e,t,s,r),n(null,t,s))})}function Oo(e,t,r,n){n=n||ue;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=ae(s),u=r.format||a.format,c=r.type||A,x=r.target||L;if(x!==w)throw"target must be TEXTURE_CUBE_MAP";et(e,t,r),r=Object.assign({},r);let f=6;const m=[],h=Ce(e,r);let l;function E(p){return function(T,R){--f,T?m.push(T):R.width!==R.height?m.push("cubemap face img is not a square: "+R.src):(Y(e,r),e.bindTexture(x,t),f===5?Ce().forEach(function(y){e.texImage2D(y,i,s,u,c,R)}):e.texImage2D(p,i,s,u,c,R),re(r)&&e.generateMipmap(x)),f===0&&n(m.length?m:void 0,t,l)}}l=o.map(function(p,T){return Qe(p,r.crossOrigin,E(h[T]))})}function Go(e,t,r,n){n=n||ue;const o=r.src,i=r.internalFormat||r.format||b,s=ae(i),a=r.format||s.format,u=r.type||A,c=r.target||V;if(c!==$&&c!==V)throw"target must be TEXTURE_3D or TEXTURE_2D_ARRAY";et(e,t,r),r=Object.assign({},r);let x=o.length;const f=[];let m;const h=r.level||0;let l=r.width,E=r.height;const p=o.length;let T=!0;function R(y){return function(_,C){if(--x,_)f.push(_);else{if(Y(e,r),e.bindTexture(c,t),T){T=!1,l=r.width||C.width,E=r.height||C.height,e.texImage3D(c,h,i,l,E,p,0,a,u,null);for(let O=0;O<p;++O)e.texSubImage3D(c,h,0,0,O,l,E,1,a,u,C)}else{let O=C,U;(C.width!==l||C.height!==E)&&(U=Gt(),O=U.canvas,U.canvas.width=l,U.canvas.height=E,U.drawImage(C,0,0,l,E)),e.texSubImage3D(c,h,0,0,y,l,E,1,a,u,O),U&&O===U.canvas&&(U.canvas.width=0,U.canvas.height=0)}re(r)&&e.generateMipmap(c)}x===0&&n(f.length?f:void 0,t,m)}}m=o.map(function(y,_){return Qe(y,r.crossOrigin,R(_))})}function ko(e,t,r,n){n=n||D.textureOptions;const o=n.target||L;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,x=ae(c),f=n.format||x.format,m=n.type||Uo(e,r,x.type);if(te(r))r instanceof Uint8ClampedArray&&(r=new Uint8Array(r.buffer));else{const p=vt(m);r=new p(r)}const h=Po(c,m),l=r.byteLength/h;if(l%1)throw"length wrong size for format: "+Ot(e,f);let E;if(o===$||o===V)if(!i&&!s&&!a){const p=Math.cbrt(l);if(p%1!==0)throw"can't guess cube size of array of numElements: "+l;i=p,s=p,a=p}else i&&(!s||!a)?(E=me(e,o,s,a,l/i),s=E.width,a=E.height):s&&(!i||!a)?(E=me(e,o,i,a,l/s),i=E.width,a=E.height):(E=me(e,o,i,s,l/a),i=E.width,s=E.height);else E=me(e,o,i,s,l),i=E.width,s=E.height;if(Xt(e),e.pixelStorei(Je,n.unpackAlignment||1),Y(e,n),o===w){const p=h/r.BYTES_PER_ELEMENT,T=l/6*p;Oe(e,n).forEach(R=>{const y=T*R.ndx,_=r.subarray(y,y+T);e.texImage2D(R.face,u,c,i,s,0,f,m,_)})}else o===$||o===V?e.texImage3D(o,u,c,i,s,a,0,f,m,r):e.texImage2D(o,u,c,i,s,0,f,m,r);return{width:i,height:s,depth:a,type:m}}function zo(e,t,r){const n=r.target||L;e.bindTexture(n,t);const o=r.level||0,i=r.internalFormat||r.format||b,s=ae(i),a=r.format||s.format,u=r.type||s.type;if(Y(e,r),n===w)for(let c=0;c<6;++c)e.texImage2D(qe+c,o,i,r.width,r.height,0,a,u,null);else n===$||n===V?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 $o(e,t,r){r=r||ue,t=t||D.textureOptions;const n=e.createTexture(),o=t.target||L;let i=t.width||1,s=t.height||1;const a=t.internalFormat||b;e.bindTexture(o,n),o===w&&(e.texParameteri(o,_e,Ee),e.texParameteri(o,pe,Ee));let u=t.src;if(u)if(typeof u=="function"&&(u=u(e,t)),typeof u=="string")Co(e,n,t,r);else if(te(u)||Array.isArray(u)&&(typeof u[0]=="number"||Array.isArray(u[0])||te(u[0]))){const c=ko(e,n,u,t);i=c.width,s=c.height}else Array.isArray(u)&&(typeof u[0]=="string"||Wt(u[0]))?o===w?Oo(e,n,t,r):Go(e,n,t,r):(jt(e,n,u,t),i=u.width,s=u.height);else zo(e,n,t);return re(t)&&Me(e,n,t,i,s,a),Zt(e,n,t),n}const tt=Nt;function Yt(e){return typeof document<"u"&&document.getElementById?document.getElementById(e):null}const Te=33984,be=34962,Vo=34963,Ho=35713,Xo=35714,Zo=35632,jo=35633,Wo=35981,Kt=35718,Yo=35721,Ko=35971,qo=35382,Jo=35396,Qo=35398,ei=35392,ti=35395,Se=5126,qt=35664,Jt=35665,Qt=35666,rt=5124,er=35667,tr=35668,rr=35669,nr=35670,or=35671,ir=35672,sr=35673,ar=35674,ur=35675,cr=35676,ri=35678,ni=35680,oi=35679,ii=35682,si=35685,ai=35686,ui=35687,ci=35688,fi=35689,li=35690,xi=36289,mi=36292,hi=36293,nt=5125,fr=36294,lr=36295,xr=36296,yi=36298,di=36299,Ei=36300,_i=36303,pi=36306,Ti=36307,Ai=36308,bi=36311,Fe=3553,Re=34067,ot=32879,Ie=35866,d={};function mr(e,t){return d[t].bindPoint}function Si(e,t){return function(r){e.uniform1f(t,r)}}function Fi(e,t){return function(r){e.uniform1fv(t,r)}}function Ri(e,t){return function(r){e.uniform2fv(t,r)}}function Ii(e,t){return function(r){e.uniform3fv(t,r)}}function gi(e,t){return function(r){e.uniform4fv(t,r)}}function hr(e,t){return function(r){e.uniform1i(t,r)}}function yr(e,t){return function(r){e.uniform1iv(t,r)}}function dr(e,t){return function(r){e.uniform2iv(t,r)}}function Er(e,t){return function(r){e.uniform3iv(t,r)}}function _r(e,t){return function(r){e.uniform4iv(t,r)}}function Pi(e,t){return function(r){e.uniform1ui(t,r)}}function vi(e,t){return function(r){e.uniform1uiv(t,r)}}function Ni(e,t){return function(r){e.uniform2uiv(t,r)}}function Ui(e,t){return function(r){e.uniform3uiv(t,r)}}function Bi(e,t){return function(r){e.uniform4uiv(t,r)}}function wi(e,t){return function(r){e.uniformMatrix2fv(t,!1,r)}}function Di(e,t){return function(r){e.uniformMatrix3fv(t,!1,r)}}function Li(e,t){return function(r){e.uniformMatrix4fv(t,!1,r)}}function Mi(e,t){return function(r){e.uniformMatrix2x3fv(t,!1,r)}}function Ci(e,t){return function(r){e.uniformMatrix3x2fv(t,!1,r)}}function Oi(e,t){return function(r){e.uniformMatrix2x4fv(t,!1,r)}}function Gi(e,t){return function(r){e.uniformMatrix4x2fv(t,!1,r)}}function ki(e,t){return function(r){e.uniformMatrix3x4fv(t,!1,r)}}function zi(e,t){return function(r){e.uniformMatrix4x3fv(t,!1,r)}}function g(e,t,r,n){const o=mr(e,t);return se(e)?function(i){let s,a;!i||Ut(e,i)?(s=i,a=null):(s=i.texture,a=i.sampler),e.uniform1i(n,r),e.activeTexture(Te+r),e.bindTexture(o,s),e.bindSampler(r,a)}:function(i){e.uniform1i(n,r),e.activeTexture(Te+r),e.bindTexture(o,i)}}function P(e,t,r,n,o){const i=mr(e,t),s=new Int32Array(o);for(let a=0;a<o;++a)s[a]=r+a;return se(e)?function(a){e.uniform1iv(n,s),a.forEach(function(u,c){e.activeTexture(Te+s[c]);let x,f;!u||Ut(e,u)?(x=u,f=null):(x=u.texture,f=u.sampler),e.bindSampler(r,f),e.bindTexture(i,x)})}:function(a){e.uniform1iv(n,s),a.forEach(function(u,c){e.activeTexture(Te+s[c]),e.bindTexture(i,u)})}}d[Se]={Type:Float32Array,size:4,setter:Si,arraySetter:Fi};d[qt]={Type:Float32Array,size:8,setter:Ri,cols:2};d[Jt]={Type:Float32Array,size:12,setter:Ii,cols:3};d[Qt]={Type:Float32Array,size:16,setter:gi,cols:4};d[rt]={Type:Int32Array,size:4,setter:hr,arraySetter:yr};d[er]={Type:Int32Array,size:8,setter:dr,cols:2};d[tr]={Type:Int32Array,size:12,setter:Er,cols:3};d[rr]={Type:Int32Array,size:16,setter:_r,cols:4};d[nt]={Type:Uint32Array,size:4,setter:Pi,arraySetter:vi};d[fr]={Type:Uint32Array,size:8,setter:Ni,cols:2};d[lr]={Type:Uint32Array,size:12,setter:Ui,cols:3};d[xr]={Type:Uint32Array,size:16,setter:Bi,cols:4};d[nr]={Type:Uint32Array,size:4,setter:hr,arraySetter:yr};d[or]={Type:Uint32Array,size:8,setter:dr,cols:2};d[ir]={Type:Uint32Array,size:12,setter:Er,cols:3};d[sr]={Type:Uint32Array,size:16,setter:_r,cols:4};d[ar]={Type:Float32Array,size:32,setter:wi,rows:2,cols:2};d[ur]={Type:Float32Array,size:48,setter:Di,rows:3,cols:3};d[cr]={Type:Float32Array,size:64,setter:Li,rows:4,cols:4};d[si]={Type:Float32Array,size:32,setter:Mi,rows:2,cols:3};d[ai]={Type:Float32Array,size:32,setter:Oi,rows:2,cols:4};d[ui]={Type:Float32Array,size:48,setter:Ci,rows:3,cols:2};d[ci]={Type:Float32Array,size:48,setter:ki,rows:3,cols:4};d[fi]={Type:Float32Array,size:64,setter:Gi,rows:4,cols:2};d[li]={Type:Float32Array,size:64,setter:zi,rows:4,cols:3};d[ri]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Fe};d[ni]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Re};d[oi]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:ot};d[ii]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Fe};d[xi]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Ie};d[mi]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Ie};d[hi]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Re};d[yi]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Fe};d[di]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:ot};d[Ei]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Re};d[_i]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Ie};d[pi]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Fe};d[Ti]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:ot};d[Ai]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Re};d[bi]={Type:null,size:0,setter:g,arraySetter:P,bindPoint:Ie};function ge(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(be,r.buffer),e.enableVertexAttribArray(t),e.vertexAttribPointer(t,r.numComponents||r.size,r.type||Se,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(be,r.buffer),e.enableVertexAttribArray(t),e.vertexAttribIPointer(t,r.numComponents||r.size,r.type||rt,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(be,r.buffer),e.enableVertexAttribArray(t),e.vertexAttribIPointer(t,r.numComponents||r.size,r.type||nt,r.stride||0,r.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,r.divisor||0)}}function it(e,t,r){const n=r.size,o=r.count;return function(i){e.bindBuffer(be,i.buffer);const s=i.size||i.numComponents||n,a=s/o,u=i.type||Se,x=d[u].size*s,f=i.normalize||!1,m=i.offset||0,h=x/o;for(let l=0;l<o;++l)e.enableVertexAttribArray(t+l),e.vertexAttribPointer(t+l,a,u,f,x,m+h*l),e.vertexAttribDivisor&&e.vertexAttribDivisor(t+l,i.divisor||0)}}const F={};F[Se]={size:4,setter:ge};F[qt]={size:8,setter:ge};F[Jt]={size:12,setter:ge};F[Qt]={size:16,setter:ge};F[rt]={size:4,setter:M};F[er]={size:8,setter:M};F[tr]={size:12,setter:M};F[rr]={size:16,setter:M};F[nt]={size:4,setter:Pe};F[fr]={size:8,setter:Pe};F[lr]={size:12,setter:Pe};F[xr]={size:16,setter:Pe};F[nr]={size:4,setter:M};F[or]={size:8,setter:M};F[ir]={size:12,setter:M};F[sr]={size:16,setter:M};F[ar]={size:4,setter:it,count:2};F[ur]={size:9,setter:it,count:3};F[cr]={size:16,setter:it,count:4};const $i=/ERROR:\s*\d+:(\d+)/gi;function Vi(e,t="",r=0){const n=[...t.matchAll($i)],o=new Map(n.map((i,s)=>{const a=parseInt(i[1]),u=n[s+1],c=u?u.index:t.length,x=t.substring(i.index,c);return[a-1,x]}));return e.split(`
|
|
4
|
-
`).map((i,s)=>{const a=o.get(s);return`${s+1+r}: ${i}${a?`
|
|
5
|
-
|
|
6
|
-
^^^ ${a}`:""}`}).join(`
|
|
7
|
-
`)}const Et=/^[ \t]*\n/;function pr(e){let t=0;return Et.test(e)&&(t=1,e=e.replace(Et,"")),{lineOffset:t,shaderSource:e}}function Hi(e,t){return e.errorCallback(t),e.callback&&setTimeout(()=>{e.callback(`${t}
|
|
8
|
-
${e.errors.join(`
|
|
9
|
-
`)}`)}),null}function Xi(e,t,r,n){if(n=n||tt,!e.getShaderParameter(r,Ho)){const i=e.getShaderInfoLog(r),{lineOffset:s,shaderSource:a}=pr(e.getShaderSource(r)),u=`${Vi(a,i,s)}
|
|
10
|
-
Error compiling ${Ot(e,t)}: ${i}`;return n(u),u}return""}function st(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||tt,a=[],u={errorCallback(c,...x){a.push(c),s(c,...x)},transformFeedbackVaryings:n,transformFeedbackMode:o,callback:i,errors:a};{let c={};Array.isArray(e)?e.forEach(function(x,f){c[x]=t?t[f]:f}):c=e||{},u.attribLocations=c}return u}const Zi=["VERTEX_SHADER","FRAGMENT_SHADER"];function ji(e,t){if(t.indexOf("frag")>=0)return Zo;if(t.indexOf("vert")>=0)return jo}function Wi(e,t,r){const n=e.getAttachedShaders(t);for(const o of n)r.has(o)&&e.deleteShader(o);e.deleteProgram(t)}const Yi=(e=0)=>new Promise(t=>setTimeout(t,e));function Ki(e,t,r){const n=e.createProgram(),{attribLocations:o,transformFeedbackVaryings:i,transformFeedbackMode:s}=st(r);for(let a=0;a<t.length;++a){let u=t[a];if(typeof u=="string"){const c=Yt(u),x=c?c.text:u;let f=e[Zi[a]];c&&c.type&&(f=ji(e,c.type)||f),u=e.createShader(f),e.shaderSource(u,pr(x).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||Wo))}return e.linkProgram(n),n}function qi(e,t,r,n,o){const i=st(r,n,o),s=new Set(t),a=Ki(e,t,i);function u(c,x){const f=Qi(c,x,i.errorCallback);return f&&Wi(c,x,s),f}if(i.callback){Ji(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 Ji(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 Yi(o),o=1e3/60;while(!n(e,t))}function Qi(e,t,r){if(r=r||tt,!e.getProgramParameter(t,Xo)){const o=e.getProgramInfoLog(t);r(`Error in program linking: ${o}`);const s=e.getAttachedShaders(t).map(a=>Xi(e,e.getShaderParameter(a,e.SHADER_TYPE),a,r));return`${o}
|
|
11
|
-
${s.filter(a=>a).join(`
|
|
12
|
-
`)}`}}function es(e,t,r,n,o){return qi(e,t,r,n,o)}function Tr(e){const t=e.name;return t.startsWith("gl_")||t.startsWith("webgl_")}const ts=/(\.|\[|]|\w+)/g,rs=e=>e>="0"&&e<="9";function ns(e,t,r,n){const o=e.split(ts).filter(a=>a!=="");let i=0,s="";for(;;){const a=o[i++];s+=a;const u=rs(a[0]),c=u?parseInt(a):a;if(u&&(s+=o[i++]),i===o.length){r[c]=t;break}else{const f=o[i++],m=f==="[",h=r[c]||(m?[]:{});r[c]=h,r=h,n[s]=n[s]||function(l){return function(E){Ar(l,E)}}(h),s+=f}}}function os(e,t){let r=0;function n(a,u,c){const x=u.name.endsWith("[0]"),f=u.type,m=d[f];if(!m)throw new Error(`unknown type: 0x${f.toString(16)}`);let h;if(m.bindPoint){const l=r;r+=u.size,x?h=m.arraySetter(e,f,l,c,u.size):h=m.setter(e,f,l,c,u.size)}else m.arraySetter&&x?h=m.arraySetter(e,c):h=m.setter(e,c);return h.location=c,h}const o={},i={},s=e.getProgramParameter(t,Kt);for(let a=0;a<s;++a){const u=e.getActiveUniform(t,a);if(Tr(u))continue;let c=u.name;c.endsWith("[0]")&&(c=c.substr(0,c.length-3));const x=e.getUniformLocation(t,u.name);if(x){const f=n(t,u,x);o[c]=f,ns(c,f,i,o)}}return o}function is(e,t){const r={},n=e.getProgramParameter(t,Ko);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 ss(e,t){const r=e.getProgramParameter(t,Kt),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(x,f){n[f][c]=x})});const i={},s=e.getProgramParameter(t,qo);for(let a=0;a<s;++a){const u=e.getActiveUniformBlockName(t,a),c={index:e.getUniformBlockIndex(t,u),usedByVertexShader:e.getActiveUniformBlockParameter(t,a,Jo),usedByFragmentShader:e.getActiveUniformBlockParameter(t,a,Qo),size:e.getActiveUniformBlockParameter(t,a,ei),uniformIndices:e.getActiveUniformBlockParameter(t,a,ti)};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 Ge(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)Ge(r,i[a])}else for(const s in i){const a=r[s];a&&a(i[s])}}}function as(e,t){const r={},n=e.getProgramParameter(t,Yo);for(let o=0;o<n;++o){const i=e.getActiveAttrib(t,o);if(Tr(i))continue;const s=e.getAttribLocation(t,i.name),a=F[i.type],u=a.setter(e,s,a);u.location=s,r[i.name]=u}return r}function us(e,t){for(const r in t){const n=e[r];n&&n(t[r])}}function _t(e,t,r){r.vertexArrayObject?e.bindVertexArray(r.vertexArrayObject):(us(t.attribSetters||t,r.attribs),r.indices&&e.bindBuffer(Vo,r.indices))}function pt(e,t){const r=os(e,t),n=as(e,t),o={program:t,uniformSetters:r,attribSetters:n};return se(e)&&(o.uniformBlockSpec=ss(e,t),o.transformFeedbackInfo=is(e,t)),o}const cs=/\s|{|}|;/;function we(e,t,r,n,o){const i=st(r,n,o),s=[];if(t=t.map(function(c){if(!cs.test(c)){const x=Yt(c);if(x)c=x.text;else{const f=`no element with id: ${c}`;i.errorCallback(f),s.push(f)}}return c}),s.length)return Hi(i,"");const a=i.callback;a&&(i.callback=(c,x)=>{a(c,c?void 0:pt(e,x))});const u=es(e,t,i);return u?pt(e,u):null}class fs{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 ls{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 fs([],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 x=this._vertToSeg[t][r];return this._segTrigs[x].includes(n)||this._segTrigs[x].push(n),x}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 x=this._vertToSeg[t]&&this._vertToSeg[t][r],f=this._vertToSeg[r]&&this._vertToSeg[r][a],m=this._vertToSeg[a]&&this._vertToSeg[a][t];function h(l){return l!==o}x!==void 0&&(this._segTrigs[x]=this._segTrigs[x].filter(h)),f!==void 0&&(this._segTrigs[f]=this._segTrigs[f].filter(h)),m!==void 0&&(this._segTrigs[m]=this._segTrigs[m].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 Tt(e,t,r=100){const n=[-20037508342789244e-9,20037508342789244e-9],o=[t[0],t[3],t[1],t[2]],i=Ir(e,"EPSG:3857").forward;function s(x){const f=i(x),m=Math.abs((f[0]-n[0])/(20037508342789244e-9*2)),h=Math.abs((f[1]-n[1])/(20037508342789244e-9*2));return[m,h]}const a=[[0,0],[0,1],[1,0],[1,1]],u=new ls(s,o,a,[[0,1,3],[0,3,2]]);if(r>0){u.force();for(let x=0;x<r;x++)u.step()}const c=u.output();return{pos:c.projected.flat(),uv:c.uv.flat(),trigs:c.trigs.flat()}}function At(e,t,r=2){const n=t&&t.length,o=n?t[0]*r:e.length;let i=br(e,0,o,r,!0);const s=[];if(!i||i.next===i.prev)return s;let a,u,c;if(n&&(i=ds(e,t,i,r)),e.length>80*r){a=1/0,u=1/0;let x=-1/0,f=-1/0;for(let m=r;m<o;m+=r){const h=e[m],l=e[m+1];h<a&&(a=h),l<u&&(u=l),h>x&&(x=h),l>f&&(f=l)}c=Math.max(x-a,f-u),c=c!==0?32767/c:0}return ne(i,s,r,a,u,c,0),s}function br(e,t,r,n,o){let i;if(o===gs(e,t,r,n)>0)for(let s=t;s<r;s+=n)i=bt(s/n|0,e[s],e[s+1],i);else for(let s=r-n;s>=t;s-=n)i=bt(s/n|0,e[s],e[s+1],i);return i&&K(i,i.next)&&(ie(i),i=i.next),i}function H(e,t){if(!e)return e;t||(t=e);let r=e,n;do if(n=!1,!r.steiner&&(K(r,r.next)||S(r.prev,r,r.next)===0)){if(ie(r),r=t=r.prev,r===r.next)break;n=!0}else r=r.next;while(n||r!==t);return t}function ne(e,t,r,n,o,i,s){if(!e)return;!s&&i&&As(e,n,o,i);let a=e;for(;e.prev!==e.next;){const u=e.prev,c=e.next;if(i?ms(e,n,o,i):xs(e)){t.push(u.i,e.i,c.i),ie(e),e=c.next,a=c.next;continue}if(e=c,e===a){s?s===1?(e=hs(H(e),t),ne(e,t,r,n,o,i,2)):s===2&&ys(e,t,r,n,o,i):ne(H(e),t,r,n,o,i,1);break}}}function xs(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,x=Math.min(o,i,s),f=Math.min(a,u,c),m=Math.max(o,i,s),h=Math.max(a,u,c);let l=n.next;for(;l!==t;){if(l.x>=x&&l.x<=m&&l.y>=f&&l.y<=h&&Q(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 ms(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,x=o.y,f=i.y,m=s.y,h=Math.min(a,u,c),l=Math.min(x,f,m),E=Math.max(a,u,c),p=Math.max(x,f,m),T=ke(h,l,t,r,n),R=ke(E,p,t,r,n);let y=e.prevZ,_=e.nextZ;for(;y&&y.z>=T&&_&&_.z<=R;){if(y.x>=h&&y.x<=E&&y.y>=l&&y.y<=p&&y!==o&&y!==s&&Q(a,x,u,f,c,m,y.x,y.y)&&S(y.prev,y,y.next)>=0||(y=y.prevZ,_.x>=h&&_.x<=E&&_.y>=l&&_.y<=p&&_!==o&&_!==s&&Q(a,x,u,f,c,m,_.x,_.y)&&S(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;y&&y.z>=T;){if(y.x>=h&&y.x<=E&&y.y>=l&&y.y<=p&&y!==o&&y!==s&&Q(a,x,u,f,c,m,y.x,y.y)&&S(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;_&&_.z<=R;){if(_.x>=h&&_.x<=E&&_.y>=l&&_.y<=p&&_!==o&&_!==s&&Q(a,x,u,f,c,m,_.x,_.y)&&S(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function hs(e,t){let r=e;do{const n=r.prev,o=r.next.next;!K(n,o)&&Fr(n,r,r.next,o)&&oe(n,o)&&oe(o,n)&&(t.push(n.i,r.i,o.i),ie(r),ie(r.next),r=e=o),r=r.next}while(r!==e);return H(r)}function ys(e,t,r,n,o,i){let s=e;do{let a=s.next.next;for(;a!==s.prev;){if(s.i!==a.i&&Fs(s,a)){let u=Rr(s,a);s=H(s,s.next),u=H(u,u.next),ne(s,t,r,n,o,i,0),ne(u,t,r,n,o,i,0);return}a=a.next}s=s.next}while(s!==e)}function ds(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=br(e,a,u,n,!1);c===c.next&&(c.steiner=!0),o.push(Ss(c))}o.sort(Es);for(let i=0;i<o.length;i++)r=_s(o[i],r);return r}function Es(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 _s(e,t){const r=ps(e,t);if(!r)return t;const n=Rr(r,e);return H(n,n.next),H(r,r.next)}function ps(e,t){let r=t;const n=e.x,o=e.y;let i=-1/0,s;if(K(e,r))return r;do{if(K(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 x=1/0;r=s;do{if(n>=r.x&&r.x>=u&&n!==r.x&&Sr(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);oe(r,e)&&(f<x||f===x&&(r.x>s.x||r.x===s.x&&Ts(s,r)))&&(s=r,x=f)}r=r.next}while(r!==a);return s}function Ts(e,t){return S(e.prev,e,t.prev)<0&&S(t.next,e,e.next)<0}function As(e,t,r,n){let o=e;do o.z===0&&(o.z=ke(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,bs(o)}function bs(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 ke(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 Ss(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 Sr(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 Q(e,t,r,n,o,i,s,a){return!(e===s&&t===a)&&Sr(e,t,r,n,o,i,s,a)}function Fs(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Rs(e,t)&&(oe(e,t)&&oe(t,e)&&Is(e,t)&&(S(e.prev,e,t.prev)||S(e,t.prev,t))||K(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 K(e,t){return e.x===t.x&&e.y===t.y}function Fr(e,t,r,n){const o=ye(S(e,t,r)),i=ye(S(e,t,n)),s=ye(S(r,n,e)),a=ye(S(r,n,t));return!!(o!==i&&s!==a||o===0&&he(e,r,t)||i===0&&he(e,n,t)||s===0&&he(r,e,n)||a===0&&he(r,t,n))}function he(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 ye(e){return e>0?1:e<0?-1:0}function Rs(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&&Fr(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}function oe(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 Is(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 Rr(e,t){const r=ze(e.i,e.x,e.y),n=ze(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 bt(e,t,r,n){const o=ze(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 ie(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 ze(e,t,r){return{i:e,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function gs(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 St(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 Ft(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 Ps(e){return typeof e=="string"?fetch(e).then(t=>t.json()).then(t=>Ft(t)):Promise.resolve(Ft(e))}function vs(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=St(s),{vertices:u,holes:c,dimensions:x}=a,m=At(u,c,x).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<m.length;h++)r.push(m[h])}}else{const n=St(e.coordinates),{vertices:o,holes:i,dimensions:s}=n;t=o,r=At(o,i,s)}return{vertices:t,indices:r}}const Ns=`
|
|
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
|
-
`,Us=`
|
|
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
|
-
`,Rt=`
|
|
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
|
-
`,It=`
|
|
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;
|
|
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
|
-
}
|
|
75
|
-
`;class Bs{option;map;gl;loaded;arrugado;programInfo;bufferInfo;texture;maskProperty;maskProgramInfo;maskBufferInfo;constructor(t){this.option=t,this.loaded=!1,this.maskProperty=Object.assign({type:"in"},t.mask);const{projection:r,coordinates:n}=t;this.arrugado=Tt(r,n,t.arrugatorStep)}onAdd(t,r){if(!r)throw new Error("ImageLayerCore requires a WebGL rendering context during onAdd.");this.map=t,this.gl=r,this.programInfo=we(r,[Us,Ns]),this.loadTexture(t,r),this.bufferInfo=Ne(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=we(r,[It,Rt]),this.maskBufferInfo=n})}onRemove(t,r){r&&(this.programInfo&&r.deleteProgram(this.programInfo.program),this.maskProgramInfo&&r.deleteProgram(this.maskProgramInfo.program),this.texture&&(r.deleteTexture(this.texture),this.texture=void 0))}render(t){if(this.maskProperty.data&&!this.maskBufferInfo)return;const r=t.gl;if(this.loaded&&this.programInfo&&this.bufferInfo){if(r.enable(r.BLEND),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),this.maskProgramInfo&&this.maskBufferInfo){t.prepareStencilMask?.(),r.useProgram(this.maskProgramInfo.program),r.enable(r.STENCIL_TEST),r.stencilFunc(r.ALWAYS,1,255),r.stencilOp(r.REPLACE,r.REPLACE,r.REPLACE),r.stencilMask(255),r.clear(r.STENCIL_BUFFER_BIT),Ge(this.maskProgramInfo,{u_matrix:t.matrix}),_t(r,this.maskProgramInfo,this.maskBufferInfo);let n=r.UNSIGNED_SHORT;this.maskBufferInfo.numElements/3>65535&&(r.getExtension("OES_element_index_uint"),n=r.UNSIGNED_INT),r.drawElements(r.TRIANGLES,this.maskBufferInfo.numElements,n,0)}if(r.useProgram(this.programInfo.program),this.maskProgramInfo?.program){const n=this.maskProperty.type==="out"?0:1;r.stencilFunc(r.EQUAL,n,255),r.stencilOp(r.KEEP,r.KEEP,r.KEEP)}Ge(this.programInfo,{u_matrix:t.matrix,u_opacity:this.option.opacity??1,u_sampler:this.texture}),_t(r,this.programInfo,this.bufferInfo),r.drawElements(r.TRIANGLES,this.arrugado.trigs.length,r.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=Tt(this.option.projection,this.option.coordinates,this.option.arrugatorStep),this.bufferInfo=Ne(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=we(this.gl,[It,Rt])),this.maskBufferInfo=r,this.map?.triggerRepaint()}):Object.prototype.hasOwnProperty.call(t,"data")&&t.data===void 0?(this.maskBufferInfo=void 0,this.map?.triggerRepaint()):this.map?.triggerRepaint(),this)}loadTexture(t,r){this.texture&&(r.deleteTexture(this.texture),this.texture=void 0);const n=this.option.resampling==="nearest"?r.NEAREST:r.LINEAR;$o(r,{src:this.option.url,crossOrigin:this.option.crossOrigin,minMag:n,flipY:0,premultiplyAlpha:1},(o,i,s)=>{if(o)throw o;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 Ps(r).then(n=>{const{vertices:o,indices:i}=vs(n);return Ne(t,{a_pos:{numComponents:2,data:o},indices:i.length/3>65535?new Uint32Array(i):new Uint16Array(i)})})}}module.exports=Bs;
|
|
File without changes
|