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