@naivemap/image-layer-core 0.1.0

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