You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1379 lines
1.5 MiB
JavaScript
1379 lines
1.5 MiB
JavaScript
|
1 month ago
|
var HDmap=function(){"use strict";var pp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function pu(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}function Qg(a){if(a.__esModule)return a;var i=a.default;if(typeof i=="function"){var s=function l(){return this instanceof l?Reflect.construct(i,arguments,this.constructor):i.apply(this,arguments)};s.prototype=i.prototype}else s={};return Object.defineProperty(s,"__esModule",{value:!0}),Object.keys(a).forEach(function(l){var h=Object.getOwnPropertyDescriptor(a,l);Object.defineProperty(s,l,h.get?h:{enumerable:!0,get:function(){return a[l]}})}),s}var e_={exports:{}};(function(a,i){(function(s,l){a.exports=l()})(pp,function(){var s,l,h;function f(t,E){if(!s)s=E;else if(!l)l=E;else{var k="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+s+")(sharedChunk); ("+l+")(sharedChunk); self.onerror = null;",P={};s(P),h=E(P),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(h.workerUrl=window.URL.createObjectURL(new Blob([k],{type:"text/javascript"})))}}f(["exports"],function(t){var E=typeof self<"u"?self:{},k="2.15.0";let P;const R={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(P==null){const n=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{P=process.env.API_URL_REGEX!=null?new RegExp(process.env.API_URL_REGEX):n}catch{P=n}}return P},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!R.API_URL)return null;try{const n=new URL(R.API_URL);return n.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":n.hostname==="api.mapbox.com"?"https://events.mapbox.com/events/v2":null}catch{return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},F={supported:!1,testSupport:function(n){!J&&Z&&(he?ye(n):U=n)}};let U,Z,J=!1,he=!1;function ye(n){const e=n.createTexture();n.bindTexture(n.TEXTURE_2D,e);try{if(n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,Z),n.isContextLost())return;F.supported=!0}catch{}n.deleteTexture(e),J=!0}E.document&&(Z=E.document.createElement("img"),Z.onload=function(){U&&ye(U),U=null,he=!0},Z.onerror=function(){J=!0,U=null},Z.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const te="01";function ce(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var be=we;function we(n,e,r,u){this.cx=3*n,this.bx=3*(r-n)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(u-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=n,this.p1y=e,this.p2x=r,this.p2y=u}we.prototype={sampleCurveX:function(n){return((this.ax*n+this.bx)*n+this.cx)*n},sampleCurveY:function(n){return((this.ay*n+this.by)*n+this.cy)*n},sampleCurveDerivativeX:function(n){return(3*this.ax*n+2*this.bx)*n+this.cx},solveCurveX:function(n,e){if(e===void 0&&(e=1e-6),n<0)return 0;if(n>1)return 1;for(var r=n,u=0;u<8;u++){var m=this.sampleCurveX(r)-n;if(Math.abs(m)<e)return r;var y=this.sampleCurveDerivativeX(r);if(Math.abs(y)<1e-6)break;r-=m/y}var b=0,I=1;for(r=n,u=0;u<20&&(m=this.sampleCurveX(r),!(Math.abs(m-n)<e));u++)n>m?b=r:I=r,r=.5*(I-b)+b;return r},solve:function(n,e){return this.sampleCurveY(this.solveCurveX(n,e))}};var Ue=ce(be),ze=Ve;func
|
||
|
|
This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md
|
||
|
|
and paste the contents of this message in the report.
|
||
|
|
Thank you!
|
||
|
|
Filter Expression:
|
||
|
|
${JSON.stringify(r,null,2)}
|
||
|
|
`)}const m=Qe[`filter_${e}`],y=sl(u,m);let b=null;if(y.result==="error")throw new Error(y.value.map(A=>`${A.key}: ${A.message}`).join(", "));b=(A,O,B)=>y.value.evaluate(A,O,{},B);let I=null,C=null;if(u!==r){const A=sl(r,m);if(A.result==="error")throw new Error(A.value.map(O=>`${O.key}: ${O.message}`).join(", "));I=(O,B,j,$,W)=>A.value.evaluate(O,B,{},j,void 0,void 0,$,W),C=!Jo(A.value.expression)}return{filter:b,dynamicFilter:I||void 0,needGeometry:_d(u),needFeature:!!C}}function gd(n){if(!Array.isArray(n))return n;const e=function(r){if(ch.has(r[0])){for(let u=1;u<r.length;u++)if(al(r[u]))return!0}return r}(n);return e===!0?e:e.map(r=>gd(r))}function Ju(n){let e=!1;const r=[];if(n[0]==="case"){for(let u=1;u<n.length-1;u+=2)e=e||al(n[u]),r.push(n[u+1]);r.push(n[n.length-1])}else if(n[0]==="match"){e=e||al(n[1]);for(let u=2;u<n.length-1;u+=2)r.push(n[u+1]);r.push(n[n.length-1])}else if(n[0]==="step"){e=e||al(n[1]);for(let u=1;u<n.length-1;u+=2)r.push(n[u+1])}e&&(n.length=0,n.push("any",...r));for(let u=1;u<n.length;u++)Ju(n[u])}function al(n){if(!Array.isArray(n))return!1;if((e=n[0])==="pitch"||e==="distance-from-center")return!0;var e;for(let r=1;r<n.length;r++)if(al(n[r]))return!0;return!1}const ch=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function Dm(n,e){return n<e?-1:n>e?1:0}function _d(n){if(!Array.isArray(n))return!1;if(n[0]==="within")return!0;for(let e=1;e<n.length;e++)if(_d(n[e]))return!0;return!1}function ll(n){if(!n)return!0;const e=n[0];return n.length<=1?e!=="any":e==="=="?hh(n[1],n[2],"=="):e==="!="?Qu(hh(n[1],n[2],"==")):e==="<"||e===">"||e==="<="||e===">="?hh(n[1],n[2],e):e==="any"?(r=n.slice(1),["any"].concat(r.map(ll))):e==="all"?["all"].concat(n.slice(1).map(ll)):e==="none"?["all"].concat(n.slice(1).map(ll).map(Qu)):e==="in"?fh(n[1],n.slice(2)):e==="!in"?Qu(fh(n[1],n.slice(2))):e==="has"?dh(n[1]):e==="!has"?Qu(dh(n[1])):e!=="within"||n;var r}function hh(n,e,r){switch(n){case"$type":return[`filter-type-${r}`,e];case"$id":return[`filter-id-${r}`,e];default:return[`filter-${r}`,n,e]}}function fh(n,e){if(e.length===0)return!1;switch(n){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(r=>typeof r!=typeof e[0])?["filter-in-large",n,["literal",e.sort(Dm)]]:["filter-in-small",n,["literal",e]]}}function dh(n){switch(n){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",n]}}function Qu(n){return["!",n]}function Kl(n){return uh(Ki(n.value))?pr(kr({},n,{expressionContext:"filter",valueSpec:n.styleSpec[`filter_${n.layerType||"fill"}`]})):Jl(n)}function Jl(n){const e=n.value,r=n.key;if(Dn(e)!=="array")return[new Ot(r,e,`array expected, ${Dn(e)} found`)];const u=n.styleSpec;let m,y=[];if(e.length<1)return[new Ot(r,e,"filter array must have at least 1 element")];switch(y=y.concat(Hu({key:`${r}[0]`,value:e[0],valueSpec:u.filter_operator,style:n.style,styleSpec:n.styleSpec})),Ti(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&Ti(e[1])==="$type"&&y.push(new Ot(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&y.push(new Ot(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(m=Dn(e[1]),m!=="string"&&y.push(new Ot(`${r}[1]`,e[1],`string expected, ${m} found`)));for(let b=2;b<e.length;b++)m=Dn(e[b]),Ti(e[1])==="$type"?y=y.concat(Hu({key:`${r}[${b}]`,value:e[b],valueSpec:u.geometry_type,style:n.style,styleSpec:n.styleSpec})):m!=="string"&&m!=="number"&&m!=="boolean"&&y.push(new Ot(`${r}[${b}]`,e[b],`string, number, or boolean expected, ${m} found`));break;case"any":case"all":case"none":for(let b=1;b<e.length;b++)y=y.concat(Jl({key:`${r}[${b}]`,value:e[b],style:n.style,styleSpec:n.styleSpec}));break;case"has":case"!has":m=Dn(e[1]),e.length!==2?y.push(new Ot(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):m!=="string"&&y.push(new Ot(`${r}[1]`,e[1],`string expected, ${m} found`));break;case"within":m=Dn(e[1]),e.length!==2?y.push(new Ot(r,e,`filter array for "${e[0]}" operator must have
|
||
|
|
Use an identity property function instead: ${j}.`)]}const B=[];return n.layerType==="symbol"&&(b==="text-field"&&u&&!u.glyphs&&B.push(new Ot(r,y,'use of "text-field" requires a style "glyphs" property')),b==="text-font"&&Vo(Ki(y))&&Ti(y.type)==="identity"&&B.push(new Ot(r,y,'"text-font" does not support identity functions'))),B.concat(Rr({key:n.key,value:y,valueSpec:A,style:u,styleSpec:m,expressionContext:"property",propertyType:e,propertyKey:b}))}function yd(n){return ph(n,"paint")}function mh(n){return ph(n,"layout")}function vd(n){let e=[];const r=n.value,u=n.key,m=n.style,y=n.styleSpec;r.type||r.ref||e.push(new Ot(u,r,'either "type" or "ref" is required'));let b=Ti(r.type);const I=Ti(r.ref);if(r.id){const C=Ti(r.id);for(let A=0;A<n.arrayIndex;A++){const O=m.layers[A];Ti(O.id)===C&&e.push(new Ot(u,r.id,`duplicate layer id "${r.id}", previously used at line ${O.id.__line__}`))}}if("ref"in r){let C;["type","source","source-layer","filter","layout"].forEach(A=>{A in r&&e.push(new Ot(u,r[A],`"${A}" is prohibited for ref layers`))}),m.layers.forEach(A=>{Ti(A.id)===I&&(C=A)}),C?C.ref?e.push(new Ot(u,r.ref,"ref cannot reference another ref layer")):b=Ti(C.type):typeof I=="string"&&e.push(new Ot(u,r.ref,`ref layer "${I}" not found`))}else if(b!=="background"&&b!=="sky")if(r.source){const C=m.sources&&m.sources[r.source],A=C&&Ti(C.type);C?A==="vector"&&b==="raster"?e.push(new Ot(u,r.source,`layer "${r.id}" requires a raster source`)):A==="raster"&&b!=="raster"?e.push(new Ot(u,r.source,`layer "${r.id}" requires a vector source`)):A!=="vector"||r["source-layer"]?A==="raster-dem"&&b!=="hillshade"?e.push(new Ot(u,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):b!=="line"||!r.paint||!r.paint["line-gradient"]&&!r.paint["line-trim-offset"]||A==="geojson"&&C.lineMetrics||e.push(new Ot(u,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Ot(u,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new Ot(u,r.source,`source "${r.source}" not found`))}else e.push(new Ot(u,r,'missing required property "source"'));return e=e.concat(Uo({key:u,value:r,valueSpec:y.layer,style:n.style,styleSpec:n.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Rr({key:`${u}.type`,value:r.type,valueSpec:y.layer.type,style:n.style,styleSpec:n.styleSpec,object:r,objectKey:"type"}),filter:C=>Kl(kr({layerType:b},C)),layout:C=>Uo({layer:r,key:C.key,value:C.value,valueSpec:{},style:C.style,styleSpec:C.styleSpec,objectElementValidators:{"*":A=>mh(kr({layerType:b},A))}}),paint:C=>Uo({layer:r,key:C.key,value:C.value,valueSpec:{},style:C.style,styleSpec:C.styleSpec,objectElementValidators:{"*":A=>yd(kr({layerType:b},A))}})}})),e}function Gs(n){const e=n.value,r=n.key,u=Dn(e);return u!=="string"?[new Ot(r,e,`string expected, ${u} found`)]:[]}const xd={promoteId:function({key:n,value:e}){if(Dn(e)==="string")return Gs({key:n,value:e});{const r=[];for(const u in e)r.push(...Gs({key:`${n}.${u}`,value:e[u]}));return r}}};function bd(n){const e=n.value,r=n.key,u=n.styleSpec,m=n.style;if(!e.type)return[new Ot(r,e,'"type" is required')];const y=Ti(e.type);let b;switch(y){case"vector":case"raster":case"raster-dem":return b=Uo({key:r,value:e,valueSpec:u[`source_${y.replace("-","_")}`],style:n.style,styleSpec:u,objectElementValidators:xd}),b;case"geojson":if(b=Uo({key:r,value:e,valueSpec:u.source_geojson,style:m,styleSpec:u,objectElementValidators:xd}),e.cluster)for(const I in e.clusterProperties){const[C,A]=e.clusterProperties[I],O=typeof C=="string"?[C,["accumulated"],["get",I]]:C;b.push(...pr({key:`${r}.${I}.map`,value:A,expressionContext:"cluster-map"})),b.push(...pr({key:`${r}.${I}.reduce`,value:O,expressionContext:"cluster-reduce"}))}return b;case"video":return Uo({key:r,value:e,valueSpec:u.source_video,style:m,styleSpec:u});case"image":return Uo({key:r,value:e,valueSpec:u.source_image,style:m,styleSpec:u});case"canvas":return[new Ot(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Hu({
|
||
|
|
#define EPSILON 0.0000001
|
||
|
|
#define PI 3.141592653589793
|
||
|
|
#define EXTENT 8192.0
|
||
|
|
#define HALF_PI PI/2.0
|
||
|
|
#define QUARTER_PI PI/4.0
|
||
|
|
#define RAD_TO_DEG 180.0/PI
|
||
|
|
#define DEG_TO_RAD PI/180.0
|
||
|
|
#define GLOBE_RADIUS EXTENT/PI/2.0`,er="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",Ar=`
|
||
|
|
#define ELEVATION_SCALE 7.0
|
||
|
|
#define ELEVATION_OFFSET 450.0
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
uniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(
|
||
|
|
mix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}
|
||
|
|
#else
|
||
|
|
vec3 elevationVector(vec2 pos) { return vec3(0,0,1); }
|
||
|
|
#endif
|
||
|
|
const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)
|
||
|
|
{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}
|
||
|
|
#ifdef TERRAIN
|
||
|
|
#ifdef TERRAIN_DEM_FLOAT_FORMAT
|
||
|
|
uniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;
|
||
|
|
#else
|
||
|
|
uniform sampler2D u_dem;uniform sampler2D u_dem_prev;
|
||
|
|
#endif
|
||
|
|
uniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {
|
||
|
|
#ifdef TERRAIN_DEM_FLOAT_FORMAT
|
||
|
|
vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;
|
||
|
|
#else
|
||
|
|
float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));
|
||
|
|
#ifdef TERRAIN_DEM_NEAREST_FILTER
|
||
|
|
return u_exaggeration*tl;
|
||
|
|
#endif
|
||
|
|
float tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
|
||
|
|
#endif
|
||
|
|
}float prevElevation(vec2 apos) {
|
||
|
|
#ifdef TERRAIN_DEM_FLOAT_FORMAT
|
||
|
|
vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;
|
||
|
|
#else
|
||
|
|
float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
#ifdef TERRAIN_VERTEX_MORPHING
|
||
|
|
float elevation(vec2 apos) {
|
||
|
|
#ifdef ZERO_EXAGGERATION
|
||
|
|
return 0.0;
|
||
|
|
#endif
|
||
|
|
float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}
|
||
|
|
#else
|
||
|
|
float elevation(vec2 apos) {
|
||
|
|
#ifdef ZERO_EXAGGERATION
|
||
|
|
return 0.0;
|
||
|
|
#endif
|
||
|
|
return currentElevation(apos);}
|
||
|
|
#endif
|
||
|
|
highp float unpack_depth(highp vec4 rgba_depth)
|
||
|
|
{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(
|
||
|
|
unpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))
|
||
|
|
);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {
|
||
|
|
#ifdef TERRAIN_DEM_FLOAT_FORMAT
|
||
|
|
float tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;
|
||
|
|
#else
|
||
|
|
vec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);
|
||
|
|
#endif
|
||
|
|
return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}
|
||
|
|
#else
|
||
|
|
float elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }
|
||
|
|
#endif`,fa=`#ifdef FOG
|
||
|
|
uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}
|
||
|
|
#endif`,Pr=`#ifdef FOG
|
||
|
|
uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump float u_fog_temporal_offset;varying vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(
|
||
|
|
mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}
|
||
|
|
#endif`;let da={},mo={};const pa=[];Ns(Ol,pa),Ns(Ar,pa),Ns(fa,pa),Ns(Pr,pa),da=Un("",Ar),mo=Un(Pr,fa);const go=Un(`
|
||
|
|
#if __VERSION__ >=300
|
||
|
|
#define varying in
|
||
|
|
#define gl_FragColor glFragColor
|
||
|
|
#define texture2D texture
|
||
|
|
#define textureCube texture
|
||
|
|
out vec4 glFragColor;
|
||
|
|
#endif
|
||
|
|
highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}highp float unpack_depth(highp vec4 rgba_depth)
|
||
|
|
{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}`,`
|
||
|
|
#if __VERSION__ >=300
|
||
|
|
#define attribute in
|
||
|
|
#define varying out
|
||
|
|
#define texture2D texture
|
||
|
|
#endif
|
||
|
|
float wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {
|
||
|
|
#ifndef PROJECTED_POS_ON_VIEWPORT
|
||
|
|
float tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;
|
||
|
|
#else
|
||
|
|
return vec3(0.0);
|
||
|
|
#endif
|
||
|
|
}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}
|
||
|
|
#endif
|
||
|
|
vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(
|
||
|
|
unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
|
||
|
|
);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered.`),ma=Ol,Nl=`
|
||
|
|
#ifdef GL_ES
|
||
|
|
precision mediump float;
|
||
|
|
#else
|
||
|
|
|
||
|
|
#if !defined(lowp)
|
||
|
|
#define lowp
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#if !defined(mediump)
|
||
|
|
#define mediump
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#if !defined(highp)
|
||
|
|
#define highp
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#endif`;var Bl={background:Un(`uniform vec4 u_color;uniform float u_opacity;
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
varying vec4 v_color;
|
||
|
|
#endif
|
||
|
|
void main() {vec4 out_color;
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
out_color=v_color;
|
||
|
|
#else
|
||
|
|
out_color=u_color;
|
||
|
|
#endif
|
||
|
|
#ifdef FOG
|
||
|
|
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
||
|
|
#endif
|
||
|
|
gl_FragColor=out_color*u_opacity;
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`attribute vec2 a_pos;uniform mat4 u_matrix;
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
uniform vec4 u_color;varying vec4 v_color;
|
||
|
|
#endif
|
||
|
|
void main() {gl_Position=u_matrix*vec4(a_pos,0,1);
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
v_color=apply_lighting(u_color);
|
||
|
|
#endif
|
||
|
|
#ifdef FOG
|
||
|
|
v_fog_pos=fog_position(a_pos);
|
||
|
|
#endif
|
||
|
|
}`),backgroundPattern:Un(`uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
out_color=apply_lighting(out_color);
|
||
|
|
#endif
|
||
|
|
#ifdef FOG
|
||
|
|
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
||
|
|
#endif
|
||
|
|
gl_FragColor=out_color*u_opacity;
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos);
|
||
|
|
#ifdef FOG
|
||
|
|
v_fog_pos=fog_position(a_pos);
|
||
|
|
#endif
|
||
|
|
}`),circle:Un(`varying vec3 v_data;varying float v_visibility;
|
||
|
|
#pragma mapbox: define highp vec4 color
|
||
|
|
#pragma mapbox: define mediump float radius
|
||
|
|
#pragma mapbox: define lowp float blur
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
#pragma mapbox: define highp vec4 stroke_color
|
||
|
|
#pragma mapbox: define mediump float stroke_width
|
||
|
|
#pragma mapbox: define lowp float stroke_opacity
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize highp vec4 color
|
||
|
|
#pragma mapbox: initialize mediump float radius
|
||
|
|
#pragma mapbox: initialize lowp float blur
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
#pragma mapbox: initialize highp vec4 stroke_color
|
||
|
|
#pragma mapbox: initialize mediump float stroke_width
|
||
|
|
#pragma mapbox: initialize lowp float stroke_opacity
|
||
|
|
vec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(
|
||
|
|
antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)
|
||
|
|
);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
out_color=apply_lighting(out_color);
|
||
|
|
#endif
|
||
|
|
#ifdef FOG
|
||
|
|
out_color=fog_apply_premultiplied(out_color,v_fog_pos);
|
||
|
|
#endif
|
||
|
|
gl_FragColor=out_color*(v_visibility*opacity_t);
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`#define NUM_VISIBILITY_RINGS 2
|
||
|
|
#define INV_SQRT2 0.70710678
|
||
|
|
#define ELEVATION_BIAS 0.0001
|
||
|
|
#define NUM_SAMPLES_PER_RING 16
|
||
|
|
uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
|
||
|
|
#endif
|
||
|
|
varying vec3 v_data;varying float v_visibility;
|
||
|
|
#pragma mapbox: define highp vec4 color
|
||
|
|
#pragma mapbox: define mediump float radius
|
||
|
|
#pragma mapbox: define lowp float blur
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
#pragma mapbox: define highp vec4 stroke_color
|
||
|
|
#pragma mapbox: define mediump float stroke_width
|
||
|
|
#pragma mapbox: define lowp float stroke_opacity
|
||
|
|
vec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {
|
||
|
|
#if defined(TERRAIN)
|
||
|
|
return elevation(pos)+ELEVATION_BIAS;
|
||
|
|
#else
|
||
|
|
return 0.0;
|
||
|
|
#endif
|
||
|
|
}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);
|
||
|
|
#ifdef PITCH_WITH_MAP
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );
|
||
|
|
#else
|
||
|
|
return u_matrix*( world_center+vec4(sample_offset,0,0) );
|
||
|
|
#endif
|
||
|
|
#else
|
||
|
|
return projected_center+vec4(sample_offset,0,0);
|
||
|
|
#endif
|
||
|
|
}float get_sample_step() {
|
||
|
|
#ifdef PITCH_WITH_MAP
|
||
|
|
return 2.0*PI/float(NUM_SAMPLES_PER_RING);
|
||
|
|
#else
|
||
|
|
return PI/float(NUM_SAMPLES_PER_RING);
|
||
|
|
#endif
|
||
|
|
}void main(void) {
|
||
|
|
#pragma mapbox: initialize highp vec4 color
|
||
|
|
#pragma mapbox: initialize mediump float radius
|
||
|
|
#pragma mapbox: initialize lowp float blur
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
#pragma mapbox: initialize highp vec4 stroke_color
|
||
|
|
#pragma mapbox: initialize mediump float stroke_width
|
||
|
|
#pragma mapbox: initialize lowp float stroke_opacity
|
||
|
|
vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
vec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);
|
||
|
|
#else
|
||
|
|
surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);
|
||
|
|
#endif
|
||
|
|
vec4 projected_center=u_matrix*world_center;float view_scale=0.0;
|
||
|
|
#ifdef PITCH_WITH_MAP
|
||
|
|
#ifdef SCALE_WITH_MAP
|
||
|
|
view_scale=1.0;
|
||
|
|
#else
|
||
|
|
view_scale=projected_center.w/u_camera_to_center_distance;
|
||
|
|
#endif
|
||
|
|
#else
|
||
|
|
#ifdef SCALE_WITH_MAP
|
||
|
|
view_scale=u_camera_to_center_distance;
|
||
|
|
#else
|
||
|
|
view_scale=projected_center.w;
|
||
|
|
#endif
|
||
|
|
#endif
|
||
|
|
gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;
|
||
|
|
#ifdef TERRAIN
|
||
|
|
float step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;
|
||
|
|
#ifdef PITCH_WITH_MAP
|
||
|
|
float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;
|
||
|
|
#else
|
||
|
|
occlusion_world_center=world_center;occlusion_projected_center=projected_center;
|
||
|
|
#endif
|
||
|
|
for(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);
|
||
|
|
#else
|
||
|
|
visibility=1.0;
|
||
|
|
#endif
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
visibility=1.0;
|
||
|
|
#endif
|
||
|
|
v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);
|
||
|
|
#ifdef FOG
|
||
|
|
v_fog_pos=fog_position(world_center.xyz);
|
||
|
|
#endif
|
||
|
|
}`),clippingMask:Un("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Un(`uniform highp float u_intensity;varying vec2 v_extrude;
|
||
|
|
#pragma mapbox: define highp float weight
|
||
|
|
#define GAUSS_COEF 0.3989422804014327
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize highp float weight
|
||
|
|
float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);
|
||
|
|
#ifdef FOG
|
||
|
|
if (u_is_globe==0) {gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}
|
||
|
|
#endif
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
|
||
|
|
#endif
|
||
|
|
varying vec2 v_extrude;
|
||
|
|
#pragma mapbox: define highp float weight
|
||
|
|
#pragma mapbox: define mediump float radius
|
||
|
|
const highp float ZERO=1.0/255.0/16.0;
|
||
|
|
#define GAUSS_COEF 0.3989422804014327
|
||
|
|
void main(void) {
|
||
|
|
#pragma mapbox: initialize highp float weight
|
||
|
|
#pragma mapbox: initialize mediump float radius
|
||
|
|
vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
|
||
|
|
#else
|
||
|
|
pos=vec3(tilePos+extrude,elevation(tilePos));
|
||
|
|
#endif
|
||
|
|
gl_Position=u_matrix*vec4(pos,1);
|
||
|
|
#ifdef FOG
|
||
|
|
v_fog_pos=fog_position(pos);
|
||
|
|
#endif
|
||
|
|
}`),heatmapTexture:Un(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(0.0);
|
||
|
|
#endif
|
||
|
|
}`,"attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Un("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",`attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(
|
||
|
|
0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}`),collisionCircle:Un("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}",`attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(
|
||
|
|
mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(
|
||
|
|
0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),debug:Un("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}",`attribute vec2 a_pos;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
attribute vec3 a_pos_3;
|
||
|
|
#endif
|
||
|
|
varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
gl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);
|
||
|
|
#else
|
||
|
|
gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);
|
||
|
|
#endif
|
||
|
|
}`),fill:Un(`#pragma mapbox: define highp vec4 color
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize highp vec4 color
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
vec4 out_color=color;
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
out_color=apply_lighting(out_color);
|
||
|
|
#endif
|
||
|
|
#ifdef FOG
|
||
|
|
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
||
|
|
#endif
|
||
|
|
gl_FragColor=out_color*opacity;
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`attribute vec2 a_pos;uniform mat4 u_matrix;
|
||
|
|
#pragma mapbox: define highp vec4 color
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize highp vec4 color
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
gl_Position=u_matrix*vec4(a_pos,0,1);
|
||
|
|
#ifdef FOG
|
||
|
|
v_fog_pos=fog_position(a_pos);
|
||
|
|
#endif
|
||
|
|
}`),fillOutline:Un(`varying vec2 v_pos;
|
||
|
|
#pragma mapbox: define highp vec4 outline_color
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize highp vec4 outline_color
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
out_color=apply_lighting(out_color);
|
||
|
|
#endif
|
||
|
|
#ifdef FOG
|
||
|
|
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
||
|
|
#endif
|
||
|
|
gl_FragColor=out_color*(alpha*opacity);
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;
|
||
|
|
#pragma mapbox: define highp vec4 outline_color
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize highp vec4 outline_color
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
|
||
|
|
#ifdef FOG
|
||
|
|
v_fog_pos=fog_position(a_pos);
|
||
|
|
#endif
|
||
|
|
}`),fillOutlinePattern:Un(`uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;varying vec2 v_pos_world;
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
#pragma mapbox: define lowp vec4 pattern
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
#pragma mapbox: initialize mediump vec4 pattern
|
||
|
|
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=texture2D(u_image,pos);
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
out_color=apply_lighting(out_color);
|
||
|
|
#endif
|
||
|
|
#ifdef FOG
|
||
|
|
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
||
|
|
#endif
|
||
|
|
gl_FragColor=out_color*(alpha*opacity);
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;varying vec2 v_pos_world;
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
#pragma mapbox: define lowp vec4 pattern
|
||
|
|
#pragma mapbox: define lowp float pixel_ratio
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
#pragma mapbox: initialize mediump vec4 pattern
|
||
|
|
#pragma mapbox: initialize lowp float pixel_ratio
|
||
|
|
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
|
||
|
|
#ifdef FOG
|
||
|
|
v_fog_pos=fog_position(a_pos);
|
||
|
|
#endif
|
||
|
|
}`),fillPattern:Un(`uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
#pragma mapbox: define lowp vec4 pattern
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
#pragma mapbox: initialize mediump vec4 pattern
|
||
|
|
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
out_color=apply_lighting(out_color);
|
||
|
|
#endif
|
||
|
|
#ifdef FOG
|
||
|
|
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
||
|
|
#endif
|
||
|
|
gl_FragColor=out_color*opacity;
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
#pragma mapbox: define lowp vec4 pattern
|
||
|
|
#pragma mapbox: define lowp float pixel_ratio
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
#pragma mapbox: initialize mediump vec4 pattern
|
||
|
|
#pragma mapbox: initialize lowp float pixel_ratio
|
||
|
|
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);
|
||
|
|
#ifdef FOG
|
||
|
|
v_fog_pos=fog_position(a_pos);
|
||
|
|
#endif
|
||
|
|
}`),fillExtrusion:Un(`varying vec4 v_color;
|
||
|
|
#ifdef RENDER_SHADOWS
|
||
|
|
varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;
|
||
|
|
#endif
|
||
|
|
#ifdef FAUX_AO
|
||
|
|
uniform lowp vec2 u_ao;varying vec3 v_ao;
|
||
|
|
#endif
|
||
|
|
#ifdef ZERO_ROOF_RADIUS
|
||
|
|
varying vec4 v_roof_color;
|
||
|
|
#endif
|
||
|
|
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)
|
||
|
|
varying highp vec3 v_normal;
|
||
|
|
#endif
|
||
|
|
void main() {
|
||
|
|
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)
|
||
|
|
vec3 normal=v_normal;
|
||
|
|
#endif
|
||
|
|
float z;vec4 color;
|
||
|
|
#ifdef ZERO_ROOF_RADIUS
|
||
|
|
z=float(normal.z > 0.00001);color=mix(v_color,v_roof_color,z);
|
||
|
|
#else
|
||
|
|
color=v_color;
|
||
|
|
#endif
|
||
|
|
#ifdef FAUX_AO
|
||
|
|
float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;
|
||
|
|
#ifdef ZERO_ROOF_RADIUS
|
||
|
|
concave*=(1.0-z);
|
||
|
|
#endif
|
||
|
|
float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);color.rgb=color.rgb*shade;
|
||
|
|
#endif
|
||
|
|
#ifdef RENDER_SHADOWS
|
||
|
|
#ifdef ZERO_ROOF_RADIUS
|
||
|
|
normal=mix(normal,vec3(0.0,0.0,1.0),z);
|
||
|
|
#endif
|
||
|
|
color.xyz=shadowed_color_normal(color.xyz,normalize(normal),v_pos_light_view_0,v_pos_light_view_1,v_depth);
|
||
|
|
#endif
|
||
|
|
#ifdef FOG
|
||
|
|
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
|
||
|
|
#endif
|
||
|
|
gl_FragColor=color;
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
|
||
|
|
#endif
|
||
|
|
varying vec4 v_color;
|
||
|
|
#ifdef RENDER_SHADOWS
|
||
|
|
uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;
|
||
|
|
#endif
|
||
|
|
#ifdef ZERO_ROOF_RADIUS
|
||
|
|
varying vec4 v_roof_color;
|
||
|
|
#endif
|
||
|
|
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)
|
||
|
|
varying highp vec3 v_normal;
|
||
|
|
#endif
|
||
|
|
#ifdef FAUX_AO
|
||
|
|
uniform lowp vec2 u_ao;varying vec3 v_ao;
|
||
|
|
#endif
|
||
|
|
#pragma mapbox: define highp float base
|
||
|
|
#pragma mapbox: define highp float height
|
||
|
|
#pragma mapbox: define highp vec4 color
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize highp float base
|
||
|
|
#pragma mapbox: initialize highp float height
|
||
|
|
#pragma mapbox: initialize highp vec4 color
|
||
|
|
vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));
|
||
|
|
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)
|
||
|
|
v_normal=normal;
|
||
|
|
#endif
|
||
|
|
base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);
|
||
|
|
#if defined(HAS_CENTROID) || defined(TERRAIN)
|
||
|
|
centroid_pos=a_centroid_pos;
|
||
|
|
#endif
|
||
|
|
float ele=0.0;float h=0.0;float c_ele;vec3 pos;
|
||
|
|
#ifdef TERRAIN
|
||
|
|
bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);
|
||
|
|
#else
|
||
|
|
h=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);
|
||
|
|
#endif
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
|
||
|
|
#endif
|
||
|
|
float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);
|
||
|
|
#ifdef RENDER_SHADOWS
|
||
|
|
v_pos_light_view_0=u_light_matrix_0*vec4(pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1);v_depth=gl_Position.w;
|
||
|
|
#endif
|
||
|
|
float NdotL=0.0;float colorvalue=0.0;
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
NdotL=calculate_NdotL(normal);
|
||
|
|
#else
|
||
|
|
colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);
|
||
|
|
#endif
|
||
|
|
if (normal.y !=0.0) {float r=0.84;
|
||
|
|
#ifndef LIGHTING_3D_MODE
|
||
|
|
r=mix(0.7,0.98,1.0-u_lightintensity);
|
||
|
|
#endif
|
||
|
|
NdotL*=(
|
||
|
|
(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}v_color=vec4(0.0,0.0,0.0,1.0);
|
||
|
|
#ifdef FAUX_AO
|
||
|
|
float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;
|
||
|
|
#ifdef TERRAIN
|
||
|
|
top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);
|
||
|
|
#endif
|
||
|
|
v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
top_height+=u_height_lift;
|
||
|
|
#endif
|
||
|
|
gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;
|
||
|
|
#endif
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
v_color=apply_lighting(color,NdotL);
|
||
|
|
#else
|
||
|
|
v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));
|
||
|
|
#endif
|
||
|
|
v_color*=u_opacity;
|
||
|
|
#ifdef ZERO_ROOF_RADIUS
|
||
|
|
v_roof_color=vec4(0.0,0.0,0.0,1.0);
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
v_roof_color=apply_lighting(color,calculate_NdotL(vec3(0.0,0.0,1.0)));
|
||
|
|
#else
|
||
|
|
float roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));
|
||
|
|
#endif
|
||
|
|
v_roof_color*=u_opacity;
|
||
|
|
#endif
|
||
|
|
#ifdef FOG
|
||
|
|
v_fog_pos=fog_position(pos);
|
||
|
|
#endif
|
||
|
|
}`),fillExtrusionPattern:Un(`uniform vec2 u_texsize;uniform sampler2D u_image;
|
||
|
|
#ifdef FAUX_AO
|
||
|
|
uniform lowp vec2 u_ao;varying vec3 v_ao;
|
||
|
|
#endif
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
varying float v_NdotL;
|
||
|
|
#endif
|
||
|
|
varying vec2 v_pos;varying vec4 v_lighting;uniform lowp float u_opacity;
|
||
|
|
#pragma mapbox: define lowp float base
|
||
|
|
#pragma mapbox: define lowp float height
|
||
|
|
#pragma mapbox: define lowp vec4 pattern
|
||
|
|
#pragma mapbox: define lowp float pixel_ratio
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize lowp float base
|
||
|
|
#pragma mapbox: initialize lowp float height
|
||
|
|
#pragma mapbox: initialize mediump vec4 pattern
|
||
|
|
#pragma mapbox: initialize lowp float pixel_ratio
|
||
|
|
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
out_color=apply_lighting(out_color,v_NdotL)*u_opacity;
|
||
|
|
#else
|
||
|
|
out_color=out_color*v_lighting;
|
||
|
|
#endif
|
||
|
|
#ifdef FAUX_AO
|
||
|
|
float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;
|
||
|
|
#endif
|
||
|
|
#ifdef FOG
|
||
|
|
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
||
|
|
#endif
|
||
|
|
gl_FragColor=out_color;
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
|
||
|
|
#endif
|
||
|
|
varying vec2 v_pos;varying vec4 v_lighting;
|
||
|
|
#ifdef FAUX_AO
|
||
|
|
uniform lowp vec2 u_ao;varying vec3 v_ao;
|
||
|
|
#endif
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
varying float v_NdotL;
|
||
|
|
#endif
|
||
|
|
#pragma mapbox: define lowp float base
|
||
|
|
#pragma mapbox: define lowp float height
|
||
|
|
#pragma mapbox: define lowp vec4 pattern
|
||
|
|
#pragma mapbox: define lowp float pixel_ratio
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize lowp float base
|
||
|
|
#pragma mapbox: initialize lowp float height
|
||
|
|
#pragma mapbox: initialize mediump vec4 pattern
|
||
|
|
#pragma mapbox: initialize lowp float pixel_ratio
|
||
|
|
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);
|
||
|
|
#if defined(HAS_CENTROID) || defined(TERRAIN)
|
||
|
|
centroid_pos=a_centroid_pos;
|
||
|
|
#endif
|
||
|
|
float ele=0.0;float h=z;vec3 p;float c_ele;
|
||
|
|
#ifdef TERRAIN
|
||
|
|
bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);
|
||
|
|
#else
|
||
|
|
p=vec3(pos_nx.xy,z);
|
||
|
|
#endif
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
|
||
|
|
#endif
|
||
|
|
float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0
|
||
|
|
? pos_nx.xy
|
||
|
|
: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
NdotL=calculate_NdotL(normal);
|
||
|
|
#else
|
||
|
|
NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);
|
||
|
|
#endif
|
||
|
|
if (normal.y !=0.0) {float r=0.84;
|
||
|
|
#ifndef LIGHTING_3D_MODE
|
||
|
|
r=mix(0.7,0.98,1.0-u_lightintensity);
|
||
|
|
#endif
|
||
|
|
NdotL*=(
|
||
|
|
(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}
|
||
|
|
#ifdef FAUX_AO
|
||
|
|
float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;
|
||
|
|
#ifdef TERRAIN
|
||
|
|
top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);
|
||
|
|
#endif
|
||
|
|
v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
top_height+=u_height_lift;
|
||
|
|
#endif
|
||
|
|
gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;
|
||
|
|
#endif
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
v_NdotL=NdotL;
|
||
|
|
#else
|
||
|
|
v_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;
|
||
|
|
#endif
|
||
|
|
#ifdef FOG
|
||
|
|
v_fog_pos=fog_position(p);
|
||
|
|
#endif
|
||
|
|
}`),hillshadePrepare:Un(`#ifdef GL_ES
|
||
|
|
precision highp float;
|
||
|
|
#endif
|
||
|
|
uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {
|
||
|
|
#ifdef TERRAIN_DEM_FLOAT_FORMAT
|
||
|
|
return texture2D(u_image,coord).a/4.0;
|
||
|
|
#else
|
||
|
|
vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;
|
||
|
|
#endif
|
||
|
|
}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(
|
||
|
|
(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)
|
||
|
|
)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(
|
||
|
|
deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,"uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Un(`uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
gl_FragColor=apply_lighting(gl_FragColor);
|
||
|
|
#endif
|
||
|
|
#ifdef FOG
|
||
|
|
gl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));
|
||
|
|
#endif
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;
|
||
|
|
#ifdef FOG
|
||
|
|
v_fog_pos=fog_position(a_pos);
|
||
|
|
#endif
|
||
|
|
}`),line:Un(`uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv;
|
||
|
|
#ifdef RENDER_LINE_DASH
|
||
|
|
uniform sampler2D u_dash_image;varying vec2 v_tex;
|
||
|
|
#endif
|
||
|
|
#ifdef RENDER_LINE_GRADIENT
|
||
|
|
uniform sampler2D u_gradient_image;
|
||
|
|
#endif
|
||
|
|
uniform float u_border_width;uniform vec4 u_border_color;float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}
|
||
|
|
#pragma mapbox: define highp vec4 color
|
||
|
|
#pragma mapbox: define lowp float floorwidth
|
||
|
|
#pragma mapbox: define lowp vec4 dash
|
||
|
|
#pragma mapbox: define lowp float blur
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
float linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {
|
||
|
|
#pragma mapbox: initialize highp vec4 color
|
||
|
|
#pragma mapbox: initialize lowp float floorwidth
|
||
|
|
#pragma mapbox: initialize lowp vec4 dash
|
||
|
|
#pragma mapbox: initialize lowp float blur
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);
|
||
|
|
#ifdef RENDER_LINE_DASH
|
||
|
|
float sdfdist=texture2D(u_dash_image,v_tex).a;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);
|
||
|
|
#endif
|
||
|
|
highp vec4 out_color;
|
||
|
|
#ifdef RENDER_LINE_GRADIENT
|
||
|
|
out_color=texture2D(u_gradient_image,v_uv.xy);
|
||
|
|
#else
|
||
|
|
out_color=color;
|
||
|
|
#endif
|
||
|
|
float trimmed=1.0;
|
||
|
|
#ifdef RENDER_LINE_TRIM_OFFSET
|
||
|
|
highp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);trimmed=0.0;}}
|
||
|
|
#endif
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
out_color=apply_lighting(out_color);
|
||
|
|
#endif
|
||
|
|
#ifdef FOG
|
||
|
|
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
|
||
|
|
#endif
|
||
|
|
#ifdef RENDER_LINE_ALPHA_DISCARD
|
||
|
|
if (alpha < u_alpha_discard_threshold) {discard;}
|
||
|
|
#endif
|
||
|
|
#ifdef RENDER_LINE_BORDER
|
||
|
|
float edgeBlur=(u_border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);
|
||
|
|
#ifdef RENDER_LINE_BORDER_AUTO
|
||
|
|
float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}
|
||
|
|
#else
|
||
|
|
out_color.rgb=mix(u_border_color.rgb*u_border_color.a*trimmed,out_color.rgb,smoothAlpha);
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
gl_FragColor=out_color*(alpha*opacity);
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`
|
||
|
|
#define EXTRUDE_SCALE 0.015873016
|
||
|
|
attribute vec2 a_pos_normal;attribute vec4 a_data;
|
||
|
|
#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)
|
||
|
|
attribute highp vec4 a_packed;
|
||
|
|
#endif
|
||
|
|
#ifdef RENDER_LINE_DASH
|
||
|
|
attribute float a_linesofar;
|
||
|
|
#endif
|
||
|
|
uniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec4 v_uv;
|
||
|
|
#ifdef RENDER_LINE_DASH
|
||
|
|
uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;varying vec2 v_tex;
|
||
|
|
#endif
|
||
|
|
#ifdef RENDER_LINE_GRADIENT
|
||
|
|
uniform float u_image_height;
|
||
|
|
#endif
|
||
|
|
#pragma mapbox: define highp vec4 color
|
||
|
|
#pragma mapbox: define lowp float floorwidth
|
||
|
|
#pragma mapbox: define lowp vec4 dash
|
||
|
|
#pragma mapbox: define lowp float blur
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
#pragma mapbox: define mediump float gapwidth
|
||
|
|
#pragma mapbox: define lowp float offset
|
||
|
|
#pragma mapbox: define mediump float width
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize highp vec4 color
|
||
|
|
#pragma mapbox: initialize lowp float floorwidth
|
||
|
|
#pragma mapbox: initialize lowp vec4 dash
|
||
|
|
#pragma mapbox: initialize lowp float blur
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
#pragma mapbox: initialize mediump float gapwidth
|
||
|
|
#pragma mapbox: initialize lowp float offset
|
||
|
|
#pragma mapbox: initialize mediump float width
|
||
|
|
float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;
|
||
|
|
#ifndef RENDER_TO_TEXTURE
|
||
|
|
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
||
|
|
#else
|
||
|
|
v_gamma_scale=1.0;
|
||
|
|
#endif
|
||
|
|
#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)
|
||
|
|
float a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];
|
||
|
|
#ifdef RENDER_LINE_GRADIENT
|
||
|
|
highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);
|
||
|
|
#else
|
||
|
|
v_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);
|
||
|
|
#endif
|
||
|
|
#endif
|
||
|
|
#ifdef RENDER_LINE_DASH
|
||
|
|
float scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y);
|
||
|
|
#endif
|
||
|
|
v_width2=vec2(outset,inset);
|
||
|
|
#ifdef FOG
|
||
|
|
v_fog_pos=fog_position(pos);
|
||
|
|
#endif
|
||
|
|
}`),linePattern:Un(`uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
|
||
|
|
#pragma mapbox: define lowp vec4 pattern
|
||
|
|
#pragma mapbox: define lowp float pixel_ratio
|
||
|
|
#pragma mapbox: define lowp float blur
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize mediump vec4 pattern
|
||
|
|
#pragma mapbox: initialize lowp float pixel_ratio
|
||
|
|
#pragma mapbox: initialize lowp float blur
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x=mod(v_linesofar/pattern_size.x*aspect,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec4 color=texture2D(u_image,pos);
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
color=apply_lighting(color);
|
||
|
|
#endif
|
||
|
|
#ifdef FOG
|
||
|
|
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
|
||
|
|
#endif
|
||
|
|
gl_FragColor=color*(alpha*opacity);
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`
|
||
|
|
#define scale 0.015873016
|
||
|
|
attribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
|
||
|
|
#pragma mapbox: define lowp float blur
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
#pragma mapbox: define lowp float offset
|
||
|
|
#pragma mapbox: define mediump float gapwidth
|
||
|
|
#pragma mapbox: define mediump float width
|
||
|
|
#pragma mapbox: define lowp float floorwidth
|
||
|
|
#pragma mapbox: define lowp vec4 pattern
|
||
|
|
#pragma mapbox: define lowp float pixel_ratio
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize lowp float blur
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
#pragma mapbox: initialize lowp float offset
|
||
|
|
#pragma mapbox: initialize mediump float gapwidth
|
||
|
|
#pragma mapbox: initialize mediump float width
|
||
|
|
#pragma mapbox: initialize lowp float floorwidth
|
||
|
|
#pragma mapbox: initialize mediump vec4 pattern
|
||
|
|
#pragma mapbox: initialize lowp float pixel_ratio
|
||
|
|
float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;
|
||
|
|
#ifndef RENDER_TO_TEXTURE
|
||
|
|
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
|
||
|
|
#else
|
||
|
|
v_gamma_scale=1.0;
|
||
|
|
#endif
|
||
|
|
v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;
|
||
|
|
#ifdef FOG
|
||
|
|
v_fog_pos=fog_position(pos);
|
||
|
|
#endif
|
||
|
|
}`),raster:Un(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(
|
||
|
|
dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);
|
||
|
|
#ifdef LIGHTING_3D_MODE
|
||
|
|
out_color=apply_lighting(out_color);
|
||
|
|
#endif
|
||
|
|
#ifdef FOG
|
||
|
|
out_color=fog_dither(fog_apply(out_color,v_fog_pos));
|
||
|
|
#endif
|
||
|
|
gl_FragColor=vec4(out_color*color.a,color.a);
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;
|
||
|
|
#ifdef FOG
|
||
|
|
v_fog_pos=fog_position(a_pos);
|
||
|
|
#endif
|
||
|
|
}`),symbolIcon:Un(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;
|
||
|
|
#endif
|
||
|
|
uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
|
||
|
|
#endif
|
||
|
|
varying vec2 v_tex;varying float v_fade_opacity;
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
|
||
|
|
#else
|
||
|
|
world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;
|
||
|
|
#endif
|
||
|
|
vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
|
||
|
|
camera_to_anchor_distance/u_camera_to_center_distance :
|
||
|
|
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
|
||
|
|
0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);
|
||
|
|
#else
|
||
|
|
offsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);
|
||
|
|
#endif
|
||
|
|
vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);
|
||
|
|
#else
|
||
|
|
projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);
|
||
|
|
#endif
|
||
|
|
highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);
|
||
|
|
#ifdef TERRAIN
|
||
|
|
#ifdef PITCH_WITH_MAP_TERRAIN
|
||
|
|
vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
|
||
|
|
#endif
|
||
|
|
#endif
|
||
|
|
float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
|
||
|
|
#else
|
||
|
|
gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
|
||
|
|
#endif
|
||
|
|
float projection_transition_fade=1.0;
|
||
|
|
#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
|
||
|
|
projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
|
||
|
|
#endif
|
||
|
|
v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}`),symbolSDF:Un(`#define SDF_PX 8.0
|
||
|
|
uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;
|
||
|
|
#pragma mapbox: define highp vec4 fill_color
|
||
|
|
#pragma mapbox: define highp vec4 halo_color
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
#pragma mapbox: define lowp float halo_width
|
||
|
|
#pragma mapbox: define lowp float halo_blur
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize highp vec4 fill_color
|
||
|
|
#pragma mapbox: initialize highp vec4 halo_color
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
#pragma mapbox: initialize lowp float halo_width
|
||
|
|
#pragma mapbox: initialize lowp float halo_blur
|
||
|
|
float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;
|
||
|
|
#endif
|
||
|
|
uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
|
||
|
|
#endif
|
||
|
|
varying vec2 v_data0;varying vec3 v_data1;
|
||
|
|
#pragma mapbox: define highp vec4 fill_color
|
||
|
|
#pragma mapbox: define highp vec4 halo_color
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
#pragma mapbox: define lowp float halo_width
|
||
|
|
#pragma mapbox: define lowp float halo_blur
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize highp vec4 fill_color
|
||
|
|
#pragma mapbox: initialize highp vec4 halo_color
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
#pragma mapbox: initialize lowp float halo_width
|
||
|
|
#pragma mapbox: initialize lowp float halo_blur
|
||
|
|
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
|
||
|
|
#else
|
||
|
|
world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;
|
||
|
|
#endif
|
||
|
|
vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
|
||
|
|
camera_to_anchor_distance/u_camera_to_center_distance :
|
||
|
|
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
|
||
|
|
0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);
|
||
|
|
#else
|
||
|
|
offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);
|
||
|
|
#endif
|
||
|
|
vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);
|
||
|
|
#else
|
||
|
|
projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);
|
||
|
|
#endif
|
||
|
|
highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);
|
||
|
|
#ifdef TERRAIN
|
||
|
|
#ifdef PITCH_WITH_MAP_TERRAIN
|
||
|
|
vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
|
||
|
|
#endif
|
||
|
|
#endif
|
||
|
|
float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
|
||
|
|
#else
|
||
|
|
gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
|
||
|
|
#endif
|
||
|
|
float gamma_scale=gl_Position.w;float projection_transition_fade=1.0;
|
||
|
|
#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
|
||
|
|
projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
|
||
|
|
#endif
|
||
|
|
vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}`),symbolTextAndIcon:Un(`#define SDF_PX 8.0
|
||
|
|
#define SDF 1.0
|
||
|
|
#define ICON 0.0
|
||
|
|
uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;
|
||
|
|
#pragma mapbox: define highp vec4 fill_color
|
||
|
|
#pragma mapbox: define highp vec4 halo_color
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
#pragma mapbox: define lowp float halo_width
|
||
|
|
#pragma mapbox: define lowp float halo_blur
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize highp vec4 fill_color
|
||
|
|
#pragma mapbox: initialize highp vec4 halo_color
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
#pragma mapbox: initialize lowp float halo_width
|
||
|
|
#pragma mapbox: initialize lowp float halo_blur
|
||
|
|
float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_projected_pos;attribute float a_fade_opacity;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;
|
||
|
|
#endif
|
||
|
|
uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
|
||
|
|
#endif
|
||
|
|
varying vec4 v_data0;varying vec4 v_data1;
|
||
|
|
#pragma mapbox: define highp vec4 fill_color
|
||
|
|
#pragma mapbox: define highp vec4 halo_color
|
||
|
|
#pragma mapbox: define lowp float opacity
|
||
|
|
#pragma mapbox: define lowp float halo_width
|
||
|
|
#pragma mapbox: define lowp float halo_blur
|
||
|
|
void main() {
|
||
|
|
#pragma mapbox: initialize highp vec4 fill_color
|
||
|
|
#pragma mapbox: initialize highp vec4 halo_color
|
||
|
|
#pragma mapbox: initialize lowp float opacity
|
||
|
|
#pragma mapbox: initialize lowp float halo_width
|
||
|
|
#pragma mapbox: initialize lowp float halo_blur
|
||
|
|
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
|
||
|
|
#else
|
||
|
|
world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;
|
||
|
|
#endif
|
||
|
|
vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
|
||
|
|
camera_to_anchor_distance/u_camera_to_center_distance :
|
||
|
|
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
|
||
|
|
0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);
|
||
|
|
#else
|
||
|
|
projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);
|
||
|
|
#endif
|
||
|
|
highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);
|
||
|
|
#ifdef TERRAIN
|
||
|
|
#ifdef PITCH_WITH_MAP_TERRAIN
|
||
|
|
vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
|
||
|
|
#endif
|
||
|
|
#endif
|
||
|
|
float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
|
||
|
|
#else
|
||
|
|
gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
|
||
|
|
#endif
|
||
|
|
float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;
|
||
|
|
#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
|
||
|
|
projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
|
||
|
|
#endif
|
||
|
|
v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}`),terrainRaster:Un(`uniform sampler2D u_image0;varying vec2 v_pos0;
|
||
|
|
#ifdef FOG
|
||
|
|
varying float v_fog_opacity;
|
||
|
|
#endif
|
||
|
|
#ifdef RENDER_SHADOWS
|
||
|
|
varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;
|
||
|
|
#endif
|
||
|
|
void main() {vec4 color=texture2D(u_image0,v_pos0);
|
||
|
|
#ifdef RENDER_SHADOWS
|
||
|
|
color.xyz=shadowed_color(color.xyz,v_pos_light_view_0,v_pos_light_view_1,v_depth);
|
||
|
|
#endif
|
||
|
|
#ifdef FOG
|
||
|
|
#ifdef ZERO_EXAGGERATION
|
||
|
|
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
|
||
|
|
#else
|
||
|
|
color=fog_dither(fog_apply_from_vert(color,v_fog_opacity));
|
||
|
|
#endif
|
||
|
|
#endif
|
||
|
|
gl_FragColor=color;
|
||
|
|
#ifdef TERRAIN_WIREFRAME
|
||
|
|
gl_FragColor=vec4(1.0,0.0,0.0,0.8);
|
||
|
|
#endif
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;varying vec2 v_pos0;
|
||
|
|
#ifdef FOG
|
||
|
|
varying float v_fog_opacity;
|
||
|
|
#endif
|
||
|
|
#ifdef RENDER_SHADOWS
|
||
|
|
uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;
|
||
|
|
#endif
|
||
|
|
const float wireframeOffset=0.00015;void main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;
|
||
|
|
#ifdef TERRAIN_WIREFRAME
|
||
|
|
elevation+=wireframeOffset;
|
||
|
|
#endif
|
||
|
|
v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);
|
||
|
|
#ifdef FOG
|
||
|
|
#ifdef ZERO_EXAGGERATION
|
||
|
|
v_fog_pos=fog_position(decodedPos);
|
||
|
|
#else
|
||
|
|
v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));
|
||
|
|
#endif
|
||
|
|
#endif
|
||
|
|
#ifdef RENDER_SHADOWS
|
||
|
|
vec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);v_depth=gl_Position.w;
|
||
|
|
#endif
|
||
|
|
}`),terrainDepth:Un(`#ifdef GL_ES
|
||
|
|
precision highp float;
|
||
|
|
#endif
|
||
|
|
varying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}`,"uniform mat4 u_matrix;attribute vec2 a_pos;varying float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:Un(`
|
||
|
|
varying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(
|
||
|
|
cos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;
|
||
|
|
#ifdef FOG
|
||
|
|
sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);
|
||
|
|
#endif
|
||
|
|
sky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,er),skyboxGradient:Un(`varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));
|
||
|
|
#ifdef FOG
|
||
|
|
color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;
|
||
|
|
#endif
|
||
|
|
color*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,er),skyboxCapture:Un(`
|
||
|
|
varying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;
|
||
|
|
#ifdef GL_ES
|
||
|
|
precision highp float;
|
||
|
|
#endif
|
||
|
|
#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)
|
||
|
|
#define BETA_M vec3(21e-6,21e-6,21e-6)
|
||
|
|
#define MIE_G 0.76
|
||
|
|
#define DENSITY_HEIGHT_SCALE_R 8000.0
|
||
|
|
#define DENSITY_HEIGHT_SCALE_M 1200.0
|
||
|
|
#define PLANET_RADIUS 6360e3
|
||
|
|
#define ATMOSPHERE_RADIUS 6420e3
|
||
|
|
#define SAMPLE_STEPS 10
|
||
|
|
#define DENSITY_STEPS 4
|
||
|
|
float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}`,"attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:Un(`uniform sampler2D u_image0;varying vec2 v_pos0;
|
||
|
|
#ifndef FOG
|
||
|
|
uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;
|
||
|
|
#endif
|
||
|
|
void main() {vec4 color;
|
||
|
|
#ifdef CUSTOM_ANTIALIASING
|
||
|
|
vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(
|
||
|
|
mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);color=vec4(raster.rgb*antialias,raster.a*antialias);
|
||
|
|
#else
|
||
|
|
color=texture2D(u_image0,v_pos0);
|
||
|
|
#endif
|
||
|
|
#ifdef FOG
|
||
|
|
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
|
||
|
|
#endif
|
||
|
|
gl_FragColor=color;
|
||
|
|
#ifdef TERRAIN_WIREFRAME
|
||
|
|
gl_FragColor=vec4(1.0,0.0,0.0,0.8);
|
||
|
|
#endif
|
||
|
|
#ifdef OVERDRAW_INSPECTOR
|
||
|
|
gl_FragColor=vec4(1.0);
|
||
|
|
#endif
|
||
|
|
}`,`uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;
|
||
|
|
#ifdef GLOBE_POLES
|
||
|
|
attribute vec3 a_globe_pos;attribute vec2 a_uv;
|
||
|
|
#else
|
||
|
|
attribute vec2 a_pos;
|
||
|
|
#endif
|
||
|
|
varying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() {
|
||
|
|
#ifdef GLOBE_POLES
|
||
|
|
vec3 globe_pos=a_globe_pos;vec2 uv=a_uv;
|
||
|
|
#else
|
||
|
|
float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);
|
||
|
|
#endif
|
||
|
|
v_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;
|
||
|
|
#ifdef GLOBE_POLES
|
||
|
|
vec3 up_vector=globe_derived_up_vector;
|
||
|
|
#else
|
||
|
|
vec3 up_vector=elevationVector(tile_pos);
|
||
|
|
#endif
|
||
|
|
float height=elevation(tile_pos);
|
||
|
|
#ifdef TERRAIN_WIREFRAME
|
||
|
|
height+=wireframeOffset;
|
||
|
|
#endif
|
||
|
|
globe_pos+=up_vector*height;
|
||
|
|
#ifndef GLOBE_POLES
|
||
|
|
globe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;
|
||
|
|
#endif
|
||
|
|
#ifdef GLOBE_POLES
|
||
|
|
vec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);
|
||
|
|
#else
|
||
|
|
vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);
|
||
|
|
#endif
|
||
|
|
gl_Position=u_proj_matrix*interpolated_pos;
|
||
|
|
#ifdef FOG
|
||
|
|
v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
|
||
|
|
#endif
|
||
|
|
}`),globeAtmosphere:Un(`uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec3 u_start_color;uniform vec4 u_color;uniform vec4 u_space_color;uniform vec4 u_high_color;uniform float u_star_intensity;uniform float u_star_size;uniform float u_star_density;uniform float u_horizon_angle;uniform mat4 u_rotation_matrix;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;highp float random(highp vec3 p) {p=fract(p*vec3(23.2342,97.1231,91.2342));p+=dot(p.zxy,p.yxz+123.1234);return fract(p.x*p.y);}float stars(vec3 p,float scale,vec2 offset) {vec2 uv_scale=(u_viewport/u_star_size)*scale;vec3 position=vec3(p.xy*uv_scale+offset*u_viewport,p.z);vec3 q=fract(position)-0.5;vec3 id=floor(position);float random_visibility=step(random(id),u_star_density);float circle=smoothstep(0.5+u_star_intensity,0.5,length(q));return circle*random_visibility;}void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {discard;return;}
|
||
|
|
#endif
|
||
|
|
highp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?
|
||
|
|
0.0 : max(acos(dot(dir,horizon_dir)),0.0);float horizon_angle;
|
||
|
|
#ifdef PROJECTION_GLOBE_VIEW
|
||
|
|
highp vec3 closest_point=globe_pos_dot_dir*dir;float closest_point_to_center=length(closest_point-u_globe_pos);float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?
|
||
|
|
PI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);
|
||
|
|
#else
|
||
|
|
horizon_angle=horizon_angle_mercator;
|
||
|
|
#endif
|
||
|
|
horizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c =mix(color_stop_2,c2,t);float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);vec2 uv=gl_FragCoord.xy/u_viewport-0.5;float aspect_ratio=u_viewport.x/u_viewport.y;vec4 uv_dir=vec4(normalize(vec3(uv.x*aspect_ratio,uv.y,1.0)),1.0);uv_dir=u_rotation_matrix*uv_dir;vec3 n=abs(uv_dir.xyz);vec2 uv_remap=(n.x > n.y && n.x > n.z) ? uv_dir.yz/uv_dir.x:
|
||
|
|
(n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y:
|
||
|
|
uv_dir.xy/uv_dir.z;uv_remap.x/=aspect_ratio;vec3 D=vec3(uv_remap,1.0);highp float star_field=0.0;if (u_star_intensity > 0.0) {star_field+=stars(D,1.2,vec2(0.0,0.0));star_field+=stars(D,1.0,vec2(1.0,0.0));star_field+=stars(D,0.8,vec2(0.0,1.0));star_field+=stars(D,0.6,vec2(1.0,1.0));star_field*=(1.0-pow(t,0.25+(1.0-u_high_color.a)*0.75));c+=star_field*alpha_2;}c=dither(c,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=vec4(c,a);}`,`attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(
|
||
|
|
mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(
|
||
|
|
mix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}`)};function Ns(_,o){const d=_.replace(/\s*\/\/[^\n]*\n/g,`
|
||
|
|
`).split(`
|
||
|
|
`);for(let v of d)if(v=v.trim(),v[0]==="#"&&v.includes("if")&&!v.includes("endif")){v=v.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const T=v.split(" ");for(const S of T)o.includes(S)||o.push(S)}}function Un(_,o){const d=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,v=o.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),T={},S=[...pa];return Ns(_,S),Ns(o,S),{fragmentSource:_=_.replace(d,(D,z,N,q,G)=>(T[G]=!0,z==="define"?`
|
||
|
|
#ifndef HAS_UNIFORM_u_${G}
|
||
|
|
varying ${N} ${q} ${G};
|
||
|
|
#else
|
||
|
|
uniform ${N} ${q} u_${G};
|
||
|
|
#endif
|
||
|
|
`:`
|
||
|
|
#ifdef HAS_UNIFORM_u_${G}
|
||
|
|
${N} ${q} ${G} = u_${G};
|
||
|
|
#endif
|
||
|
|
`)),vertexSource:o=o.replace(d,(D,z,N,q,G)=>{const Y=q==="float"?"vec2":"vec4",ie=G.match(/color/)?"color":Y;return T[G]?z==="define"?`
|
||
|
|
#ifndef HAS_UNIFORM_u_${G}
|
||
|
|
uniform lowp float u_${G}_t;
|
||
|
|
attribute ${N} ${Y} a_${G};
|
||
|
|
varying ${N} ${q} ${G};
|
||
|
|
#else
|
||
|
|
uniform ${N} ${q} u_${G};
|
||
|
|
#endif
|
||
|
|
`:ie==="vec4"?`
|
||
|
|
#ifndef HAS_UNIFORM_u_${G}
|
||
|
|
${G} = a_${G};
|
||
|
|
#else
|
||
|
|
${N} ${q} ${G} = u_${G};
|
||
|
|
#endif
|
||
|
|
`:`
|
||
|
|
#ifndef HAS_UNIFORM_u_${G}
|
||
|
|
${G} = unpack_mix_${ie}(a_${G}, u_${G}_t);
|
||
|
|
#else
|
||
|
|
${N} ${q} ${G} = u_${G};
|
||
|
|
#endif
|
||
|
|
`:z==="define"?`
|
||
|
|
#ifndef HAS_UNIFORM_u_${G}
|
||
|
|
uniform lowp float u_${G}_t;
|
||
|
|
attribute ${N} ${Y} a_${G};
|
||
|
|
#else
|
||
|
|
uniform ${N} ${q} u_${G};
|
||
|
|
#endif
|
||
|
|
`:ie==="vec4"?`
|
||
|
|
#ifndef HAS_UNIFORM_u_${G}
|
||
|
|
${N} ${q} ${G} = a_${G};
|
||
|
|
#else
|
||
|
|
${N} ${q} ${G} = u_${G};
|
||
|
|
#endif
|
||
|
|
`:`
|
||
|
|
#ifndef HAS_UNIFORM_u_${G}
|
||
|
|
${N} ${q} ${G} = unpack_mix_${ie}(a_${G}, u_${G}_t);
|
||
|
|
#else
|
||
|
|
${N} ${q} ${G} = u_${G};
|
||
|
|
#endif
|
||
|
|
`}),staticAttributes:v,usedDefines:S}}class ih{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(o,d,v,T,S,D,z){this.context=o;let N=this.boundPaintVertexBuffers.length!==T.length;for(let G=0;!N&&G<T.length;G++)this.boundPaintVertexBuffers[G]!==T[G]&&(N=!0);let q=this.boundDynamicVertexBuffers.length!==z.length;for(let G=0;!q&&G<z.length;G++)this.boundDynamicVertexBuffers[G]!==z[G]&&(q=!0);if(!o.extVertexArrayObject||!this.vao||this.boundProgram!==d||this.boundLayoutVertexBuffer!==v||N||q||this.boundIndexBuffer!==S||this.boundVertexOffset!==D)this.freshBind(d,v,T,S,D,z);else{o.bindVertexArrayOES.set(this.vao);for(const G of z)G&&G.bind();S&&S.dynamicDraw&&S.bind()}}freshBind(o,d,v,T,S,D){let z;const N=o.numAttributes,q=this.context,G=q.gl;if(q.extVertexArrayObject)this.vao&&this.destroy(),this.vao=q.extVertexArrayObject.createVertexArrayOES(),q.bindVertexArrayOES.set(this.vao),z=0,this.boundProgram=o,this.boundLayoutVertexBuffer=d,this.boundPaintVertexBuffers=v,this.boundIndexBuffer=T,this.boundVertexOffset=S,this.boundDynamicVertexBuffers=D;else{z=q.currentNumAttributes||0;for(let Y=N;Y<z;Y++)G.disableVertexAttribArray(Y)}d.enableAttributes(G,o),d.bind(),d.setVertexAttribPointers(G,o,S);for(const Y of v)Y.enableAttributes(G,o),Y.bind(),Y.setVertexAttribPointers(G,o,S);for(const Y of D)Y&&(Y.enableAttributes(G,o),Y.bind(),Y.setVertexAttribPointers(G,o,S));T&&T.bind(),q.currentNumAttributes=N}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function Fl(_,o){const d=Math.pow(2,o.canonical.z),v=o.canonical.y;return[new t.MercatorCoordinate(0,v/d).toLngLat().lat,new t.MercatorCoordinate(0,(v+1)/d).toLngLat().lat]}function Fu(_,o,d,v,T,S,D){const z=_.context,N=z.gl,q=d.fbo;if(!q)return;_.prepareDrawTile();const G=_.useProgram("hillshade");z.activeTexture.set(N.TEXTURE0),N.bindTexture(N.TEXTURE_2D,q.colorAttachment.get());const Y=((le,fe,H,oe)=>{const ge=H.paint.get("hillshade-shadow-color"),_e=H.paint.get("hillshade-highlight-color"),Ae=H.paint.get("hillshade-accent-color");let Re=H.paint.get("hillshade-illumination-direction")*(Math.PI/180);H.paint.get("hillshade-illumination-anchor")==="viewport"&&(Re-=le.transform.angle);const Pe=!le.options.moving;return{u_matrix:oe||le.transform.calculateProjMatrix(fe.tileID.toUnwrapped(),Pe),u_image:0,u_latrange:Fl(0,fe.tileID),u_light:[H.paint.get("hillshade-exaggeration"),Re],u_shadow:ge,u_highlight:_e,u_accent:Ae}})(_,d,v,_.terrain?o.projMatrix:null);_.prepareDrawProgram(z,G,o.toUnwrapped());const{tileBoundsBuffer:ie,tileBoundsIndexBuffer:se,tileBoundsSegments:ue}=_.getTileBoundsBuffers(d);G.draw(z,N.TRIANGLES,T,S,D,t.CullFaceMode.disabled,Y,v.id,ie,se,ue)}function Bo(_,o,d){if(!o.needsDEMTextureUpload)return;const v=_.context,T=v.gl;v.pixelStoreUnpackPremultiplyAlpha.set(!1),o.demTexture=o.demTexture||_.getTileTexture(d.stride);const S=d.getPixels();o.demTexture?o.demTexture.update(S,{premultiply:!1}):o.demTexture=new t.Texture(v,S,T.RGBA,{premultiply:!1}),o.needsDEMTextureUpload=!1}function Lr(_,o,d,v,T,S){const D=_.context,z=D.gl;if(!o.dem)return;const N=o.dem;if(D.activeTexture.set(z.TEXTURE1),Bo(_,o,N),!o.demTexture)return;o.demTexture.bind(z.NEAREST,z.CLAMP_TO_EDGE);const q=N.dim;D.activeTexture.set(z.TEXTURE0);let G=o.fbo;if(!G){const ue=new t.Texture(D,{width:q,height:q,data:null},z.RGBA);ue.bind(z.LINEAR,z.CLAMP_TO_EDGE),G=o.fbo=D.createFramebuffer(q,q,!0),G.colorAttachment.set(ue.texture)}D.bindFramebuffer.set(G.framebuffer),D.viewport.set([0,0,q,q]);const{tileBoundsBuffer:Y,tileBoundsIndexBuffer:ie,tileBoundsSegments:se}=_.getMercatorTileBoundsBuffers();_.useProgram("hillshadePrepare").draw(D,z.TRIANGLES,v,T,S,t.CullFaceMode.disabled,((ue,le)=>{const fe=le.stride,H=t.create();return t.ortho(H,0,t.EXTENT,-t.EXTENT,0,0,1),t.translate(H,H,[0,-t.EXTENT,0]),{u_matrix:H,u_image:1,u_dimension:[fe,fe],u_zoom:ue.overscaledZ,u_unpack:le.unpackVector}})(o.tileID,N),d.id,Y,
|
||
|
|
This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const D=this.getScaledDemTileSize();this.sourceCache.update(d,D,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,S(),this._initializing=!0),S(),d.updateElevation(!0,v),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(d),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(o){this._findCoveringTileCache[o]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const o=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||o.efficiency!==100&&t.warnOnce(`Terrain render cache efficiency is not optimal (${o.efficiency}%) and performance
|
||
|
|
may be affected negatively, consider placing all background, fill and line layers before layer
|
||
|
|
with id '${o.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(o){o.coord&&o.dataType==="source"?this._clearRenderCacheForTile(o.sourceCacheId,o.coord):o.dataType==="style"&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const o in this._style._sourceCaches)this._style._sourceCaches[o].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(o=>o.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const o=2*this.proxySourceCache.getSource().tileSize;return[o,o]}set useVertexMorphing(o){this._useVertexMorphing=o}updateTileBinding(o){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const d=this.proxySourceCache,v=this.painter.transform;this._initializing&&(this._initializing=v._centerAltitude===0&&this.getAtPointOrZero(t.MercatorCoordinate.fromLngLat(v.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const T=this.proxyCoords=d.getIds().map(N=>{const q=d.getTileByID(N).tileID;return q.projMatrix=v.calculateProjMatrix(q.toUnwrapped()),q});(function(N,q){const G=q.transform.pointCoordinate(q.transform.getCameraPoint()),Y=new t.Point(G.x,G.y);N.sort((ie,se)=>{if(se.overscaledZ-ie.overscaledZ)return se.overscaledZ-ie.overscaledZ;const ue=new t.Point(ie.canonical.x+(1<<ie.canonical.z)*ie.wrap,ie.canonical.y),le=new t.Point(se.canonical.x+(1<<se.canonical.z)*se.wrap,se.canonical.y),fe=Y.mult(1<<ie.canonical.z);return fe.x-=.5,fe.y-=.5,fe.distSqr(ue)-fe.distSqr(le)})})(T,this.painter),this._previousZoom=v.zoom;const S=this.proxyToSource||{};this.proxyToSource={},T.forEach(N=>{this.proxyToSource[N.key]={}}),this.terrainTileForTile={};const D=this._style._sourceCaches;for(const N in D){const q=D[N];if(!q.used||(q!==this.sourceCache&&this.resetTileLookupCache(q.id),this._setupProxiedCoordsForOrtho(q,o[N],S),q.usedForTerrain))continue;const G=o[N];q.getSource().reparseOverscaled&&this._assignTerrainTiles(G)}this.proxiedCoords[d.id]=T.map(N=>new _a(N,N.key,this.orthoMatrix)),this._assignTerrainTiles(T),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(S),this.renderingToTexture=!1,this._updateTimestamp=t.exported.now();const z={};this._visibleDemTiles=[];for(const N of this.proxyCoords){const q=this.terrainTileForTile[N.key];if(!q)continue;const G=q.tileID.key;G in z||(this._visibleDemTiles.push(q),z[G]=G)}}_assignTerrainTiles(o){this._initializing||o.forEach(d=>{if(this.terrainTileForTile[d.key])return;const v=this._findTileCoveringTileID(d,this.sourceCache);v&&(this.terrainTileForTile[d.key]=v)})}_prepareDEMTextures(){const o=this.painter.context,d=o.gl;for(const v in this.terrainTileForTile){const T=this.terrainTileForTile[v],S=T.dem;!S||T.demTexture&&!T.needsDEMTextureUpload||(o.activeTexture.set(d.TEXTURE1),Bo(this.painter,T,S))}}_prepareDemTileUniforms(o,d,v,T){if(!d||d.demTexture==null)return!1;const S=o.tileID.canonical,D=Math.pow(2,d.tileID.canonical.z-S.z),z=T||"";return v[`u_dem_tl${z}`]=[S.x*D%1,S.y*D%1],v[`u_dem_scale${z}`]=D,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const o=this.painter.context,d=o.gl;if(!this._emptyDepthBufferTexture){const v=new t.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new t.Texture(o,v,d.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let o=0;const d=this._visibleDemTiles.reduce((v,T)=>{if(!T.dem)
|
||
|
|
`:"",se=ie+Y.concat(o.extStandardDerivatives&&ie.length===0?`#extension GL_OES_standard_derivatives : enable
|
||
|
|
`.concat(Nl):Nl,Nl,ma,go.fragmentSource,mo.fragmentSource,v.fragmentSource).join(`
|
||
|
|
`),ue=ie+Y.concat(`
|
||
|
|
#ifdef GL_ES
|
||
|
|
precision highp float;
|
||
|
|
#else
|
||
|
|
|
||
|
|
#if !defined(lowp)
|
||
|
|
#define lowp
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#if !defined(mediump)
|
||
|
|
#define mediump
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#if !defined(highp)
|
||
|
|
#define highp
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#endif`,ma,go.vertexSource,mo.vertexSource,da.vertexSource,v.vertexSource).join(`
|
||
|
|
`),le=z.createShader(z.FRAGMENT_SHADER);if(z.isContextLost())return void(this.failedToCreate=!0);z.shaderSource(le,se),z.compileShader(le),z.attachShader(this.program,le);const fe=z.createShader(z.VERTEX_SHADER);if(z.isContextLost())this.failedToCreate=!0;else{z.shaderSource(fe,ue),z.compileShader(fe),z.attachShader(this.program,fe),this.attributes={},this.numAttributes=G.length;for(let H=0;H<this.numAttributes;H++)G[H]&&(z.bindAttribLocation(this.program,H,G[H]),this.attributes[G[H]]=H);z.linkProgram(this.program),z.deleteShader(fe),z.deleteShader(le),this.fixedUniforms=S(o),this.binderUniforms=T?T.getUniforms(o):[],D.includes("TERRAIN")&&(this.terrainUniforms=(H=>({u_dem:new t.Uniform1i(H),u_dem_prev:new t.Uniform1i(H),u_dem_unpack:new t.Uniform4f(H),u_dem_tl:new t.Uniform2f(H),u_dem_scale:new t.Uniform1f(H),u_dem_tl_prev:new t.Uniform2f(H),u_dem_scale_prev:new t.Uniform1f(H),u_dem_size:new t.Uniform1f(H),u_dem_lerp:new t.Uniform1f(H),u_exaggeration:new t.Uniform1f(H),u_depth:new t.Uniform1i(H),u_depth_size_inv:new t.Uniform2f(H),u_meter_to_dem:new t.Uniform1f(H),u_label_plane_matrix_inv:new t.UniformMatrix4f(H)}))(o)),D.includes("GLOBE")&&(this.globeUniforms=(H=>({u_tile_tl_up:new t.Uniform3f(H),u_tile_tr_up:new t.Uniform3f(H),u_tile_br_up:new t.Uniform3f(H),u_tile_bl_up:new t.Uniform3f(H),u_tile_up_scale:new t.Uniform1f(H)}))(o)),D.includes("FOG")&&(this.fogUniforms=(H=>({u_fog_matrix:new t.UniformMatrix4f(H),u_fog_range:new t.Uniform2f(H),u_fog_color:new t.Uniform4f(H),u_fog_horizon_blend:new t.Uniform1f(H),u_fog_temporal_offset:new t.Uniform1f(H),u_frustum_tl:new t.Uniform3f(H),u_frustum_tr:new t.Uniform3f(H),u_frustum_br:new t.Uniform3f(H),u_frustum_bl:new t.Uniform3f(H),u_globe_pos:new t.Uniform3f(H),u_globe_radius:new t.Uniform1f(H),u_globe_transition:new t.Uniform1f(H),u_is_globe:new t.Uniform1i(H),u_viewport:new t.Uniform2f(H)}))(o))}}setTerrainUniformValues(o,d){if(!this.terrainUniforms)return;const v=this.terrainUniforms;if(!this.failedToCreate){o.program.set(this.program);for(const T in d)v[T]&&v[T].set(this.program,T,d[T])}}setGlobeUniformValues(o,d){if(!this.globeUniforms)return;const v=this.globeUniforms;if(!this.failedToCreate){o.program.set(this.program);for(const T in d)v[T]&&v[T].set(this.program,T,d[T])}}setFogUniformValues(o,d){if(!this.fogUniforms)return;const v=this.fogUniforms;if(!this.failedToCreate){o.program.set(this.program);for(const T in d)v[T].set(this.program,T,d[T])}}draw(o,d,v,T,S,D,z,N,q,G,Y,ie,se,ue,le){const fe=o.gl;if(this.failedToCreate)return;o.program.set(this.program),o.setDepthMode(v),o.setStencilMode(T),o.setColorMode(S),o.setCullFace(D);for(const oe of Object.keys(this.fixedUniforms))this.fixedUniforms[oe].set(this.program,oe,z[oe]);ue&&ue.setUniforms(this.program,o,this.binderUniforms,ie,{zoom:se});const H={[fe.LINES]:2,[fe.TRIANGLES]:3,[fe.LINE_STRIP]:1}[d];for(const oe of Y.get()){const ge=oe.vaos||(oe.vaos={});(ge[N]||(ge[N]=new ih)).bind(o,this,q,ue?ue.getPaintVertexBuffers():[],G,oe.vertexOffset,le||[]),fe.drawElements(d,oe.primitiveLength*H,fe.UNSIGNED_SHORT,oe.primitiveOffset*H*2)}}}function gs(_,o){const d=Math.pow(2,o.tileID.overscaledZ),v=o.tileSize*Math.pow(2,_.transform.tileZoom)/d,T=v*(o.tileID.canonical.x+o.tileID.wrap*d),S=v*o.tileID.canonical.y;return{u_image:0,u_texsize:o.imageAtlasTexture.size,u_tile_units_to_pixels:1/Bt(o,1,_.transform.tileZoom),u_pixel_coord_upper:[T>>16,S>>16],u_pixel_coord_lower:[65535&T,65535&S]}}const Vu=t.create(),Ul=(_,o,d,v,T,S,D,z,N,q,G)=>{const Y=o.style.light,ie=Y.properties.get("position"),se=[ie.x,ie.y,ie.z],ue=t.create$1();Y.properties.get("anchor")==="viewport"&&(t.fromRotation(ue,-o.transform.angle),t.transformMat3(se,se,ue));const le=Y.properties.get("color"),fe=o.transform,H={u_matrix:_,u_lightpos:se,u_lightintensity:Y.properties.get("intensity"),u_lightcolor:[le.r,le.g,le.b],u_vertical_gradient:+d,u_opacity:v,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Vu,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:T,u_edge_radius:S};return fe.projection.name==="globe"&&(H.u_tile_id=[D.canonical.x,D.canonical.y
|
||
|
|
translate(${o.x}px,${o.y}px)
|
||
|
|
${ba[this._anchor]}
|
||
|
|
${this._calculateXYTransform()} ${this._calculateZTransform()}
|
||
|
|
translate(${d.x}px,${d.y}px)
|
||
|
|
`}_calculateXYTransform(){const o=this._pos,d=this._map,v=this.getPitchAlignment();if(!d||!o||v!=="map")return"";if(!d._showingGlobe()){const N=d.getPitch();return N?`rotateX(${N}deg)`:""}const T=t.radToDeg(t.globeTiltAtLngLat(d.transform,this._lngLat)),S=o.sub(t.globeCenterToScreenPoint(d.transform)),D=Math.abs(S.x)+Math.abs(S.y);if(D===0)return"";const z=T/D;return`rotateX(${-S.y*z}deg) rotateY(${S.x*z}deg)`}_calculateZTransform(){const o=this._pos,d=this._map;if(!d||!o)return"";let v=0;const T=this.getRotationAlignment();if(T==="map")if(d._showingGlobe()){const S=d.project(new t.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),D=d.project(new t.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(S);v=t.radToDeg(Math.atan2(D.y,D.x))-90}else v=-d.getBearing();else if(T==="horizon"){const S=t.smoothstep(4,6,d.getZoom()),D=t.globeCenterToScreenPoint(d.transform);D.y+=S*d.transform.height;const z=o.sub(D),N=t.radToDeg(Math.atan2(z.y,z.x));v=(N>90?N-270:N+90)*(1-S)}return v+=this._rotation,v?`rotateZ(${v}deg)`:""}_update(o){t.window.cancelAnimationFrame(this._updateFrameId);const d=this._map;d&&(d.transform.renderWorldCopies&&(this._lngLat=ul(this._lngLat,this._pos,d.transform)),this._pos=d.project(this._lngLat),o===!0?this._updateFrameId=t.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),d._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(d._showingGlobe()||d.getTerrain()||d.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(o){return this._offset=t.Point.convert(o),this._update(),this}_onMove(o){const d=this._map;if(!d)return;const v=this._pointerdownPos,T=this._positionDelta;if(v&&T){if(!this._isDragging){const S=this._clickTolerance||d._clickTolerance;if(o.point.dist(v)<S)return;this._isDragging=!0}this._pos=o.point.sub(T),this._lngLat=d.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new t.Event("dragstart"))),this.fire(new t.Event("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const o=this._map;o&&(o.off("mousemove",this._onMove),o.off("touchmove",this._onMove)),this._state==="active"&&this.fire(new t.Event("dragend")),this._state="inactive"}_addDragHandler(o){const d=this._map,v=this._pos;d&&v&&this._element.contains(o.originalEvent.target)&&(o.preventDefault(),this._positionDelta=o.point.sub(v),this._pointerdownPos=o.point,this._state="pending",d.on("mousemove",this._onMove),d.on("touchmove",this._onMove),d.once("mouseup",this._onUp),d.once("touchend",this._onUp))}setDraggable(o){this._draggable=!!o;const d=this._map;return d&&(o?(d.on("mousedown",this._addDragHandler),d.on("touchstart",this._addDragHandler)):(d.off("mousedown",this._addDragHandler),d.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(o){return this._rotation=o||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(o){return this._rotationAlignment=o||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment==="auto"||this._rotationAlignment==="horizon"&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(o){return this._pitchAlignment=o||"auto",this._update(),this}getPitchAlignment(){return this._pitchAlignment==="auto"?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(o){return this._occludedOpacity=o||.2,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const vh={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Vm=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Sd(
|
||
|
|
must be that same as the previous version of the image
|
||
|
|
(${d.data.width}, ${d.data.height})`))):this.fire(new t.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")))}hasImage(_){return _?!!this.style.getImage(_):(this.fire(new t.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(_){this.style.removeImage(_)}loadImage(_,o){t.getImage(this._requestManager.transformRequest(_,t.ResourceType.Image),(d,v)=>{o(d,v instanceof t.window.HTMLImageElement?t.exported.getImageData(v):v)})}listImages(){return this.style.listImages()}addLayer(_,o){return this._lazyInitEmptyStyle(),this.style.addLayer(_,o),this._update(!0)}moveLayer(_,o){return this.style.moveLayer(_,o),this._update(!0)}removeLayer(_){return this.style.removeLayer(_),this._update(!0)}getLayer(_){return this.style.getLayer(_)}setLayerZoomRange(_,o,d){return this.style.setLayerZoomRange(_,o,d),this._update(!0)}setFilter(_,o,d={}){return this.style.setFilter(_,o,d),this._update(!0)}getFilter(_){return this.style.getFilter(_)}setPaintProperty(_,o,d,v={}){return this.style.setPaintProperty(_,o,d,v),this._update(!0)}getPaintProperty(_,o){return this.style.getPaintProperty(_,o)}setLayoutProperty(_,o,d,v={}){return this.style.setLayoutProperty(_,o,d,v),this._update(!0)}getLayoutProperty(_,o){return this.style.getLayoutProperty(_,o)}setLight(_,o={}){return this._lazyInitEmptyStyle(),this.style.setLight(_,o),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(_){return this._lazyInitEmptyStyle(),!_&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(_),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(_){return this._lazyInitEmptyStyle(),this.style.setFog(_),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(_){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(t.LngLat.convert(_),this.transform):0}setFeatureState(_,o){return this.style.setFeatureState(_,o),this._update()}removeFeatureState(_,o){return this.style.removeFeatureState(_,o),this._update()}getFeatureState(_){return this.style.getFeatureState(_)}_updateContainerDimensions(){if(!this._container)return;const _=this._container.getBoundingClientRect().width||400,o=this._container.getBoundingClientRect().height||300;let d,v,T,S=this._container;for(;S&&(!v||!T);){const D=t.window.getComputedStyle(S).transform;D&&D!=="none"&&(d=D.match(/matrix.*\((.+)\)/)[1].split(", "),d[0]&&d[0]!=="0"&&d[0]!=="1"&&(v=d[0]),d[3]&&d[3]!=="0"&&d[3]!=="1"&&(T=d[3])),S=S.parentElement}this._containerWidth=v?Math.abs(_/v):_,this._containerHeight=T?Math.abs(o/T):o}_detectMissingCSS(){t.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&t.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const _=this._container;_.classList.add("mapboxgl-map"),(this._missingCSSCanary=F("div","mapboxgl-canary",_)).style.visibility="hidden",this._detectMissingCSS();const o=this._canvasContainer=F("div","mapboxgl-canvas-container",_);this._interactive&&o.classList.add("mapboxgl-interactive"),this._canvas=F("canvas","mapboxgl-canvas",o),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const d=this._controlContainer=F("div","mapboxgl-control-container",_),v=this._controlPositions={};["top-left","top-right","bottom-left","botto
|
||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function he(M,c){if(M){if(typeof M=="string")return ye(M,c);var p=Object.prototype.toString.call(M).slice(8,-1);return p==="Object"&&M.constructor&&(p=M.constructor.name),p==="Map"||p==="Set"?Array.from(M):p==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(p)?ye(M,c):void 0}}function ye(M,c){(c==null||c>M.length)&&(c=M.length);for(var p=0,g=new Array(c);p<c;p++)g[p]=M[p];return g}function te(M,c){var p=typeof Symbol<"u"&&M[Symbol.iterator]||M["@@iterator"];if(!p){if(Array.isArray(M)||(p=he(M))||c){p&&(M=p);var g=0,w=function(){};return{s:w,n:function(){return g>=M.length?{done:!0}:{done:!1,value:M[g++]}},e:function(Q){throw Q},f:w}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
||
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var L,V=!0,X=!1;return{s:function(){p=p.call(M)},n:function(){var Q=p.next();return V=Q.done,Q},e:function(Q){X=!0,L=Q},f:function(){try{V||p.return==null||p.return()}finally{if(X)throw L}}}}var ce=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getEndCapStyle",value:function(){return this._endCapStyle}},{key:"isSingleSided",value:function(){return this._isSingleSided}},{key:"setQuadrantSegments",value:function(c){this._quadrantSegments=c,this._quadrantSegments===0&&(this._joinStyle=M.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=M.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),c<=0&&(this._quadrantSegments=1),this._joinStyle!==M.JOIN_ROUND&&(this._quadrantSegments=M.DEFAULT_QUADRANT_SEGMENTS)}},{key:"getJoinStyle",value:function(){return this._joinStyle}},{key:"setJoinStyle",value:function(c){this._joinStyle=c}},{key:"setSimplifyFactor",value:function(c){this._simplifyFactor=c<0?0:c}},{key:"getSimplifyFactor",value:function(){return this._simplifyFactor}},{key:"getQuadrantSegments",value:function(){return this._quadrantSegments}},{key:"setEndCapStyle",value:function(c){this._endCapStyle=c}},{key:"getMitreLimit",value:function(){return this._mitreLimit}},{key:"setMitreLimit",value:function(c){this._mitreLimit=c}},{key:"setSingleSided",value:function(c){this._isSingleSided=c}}],[{key:"constructor_",value:function(){if(this._quadrantSegments=M.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=M.CAP_ROUND,this._joinStyle=M.JOIN_ROUND,this._mitreLimit=M.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=M.DEFAULT_SIMPLIFY_FACTOR,arguments.length!==0){if(arguments.length===1){var c=arguments[0];this.setQuadrantSegments(c)}else if(arguments.length===2){var p=arguments[0],g=arguments[1];this.setQuadrantSegments(p),this.setEndCapStyle(g)}else if(arguments.length===4){var w=arguments[0],L=arguments[1],V=arguments[2],X=arguments[3];this.setQuadrantSegments(w),this.setEndCapStyle(L),this.setJoinStyle(V),this.setMitreLimit(X)}}}},{key:"bufferDistanceError",value:function(c){var p=Math.PI/2/c;return 1-Math.cos(p/2)}}]),M}();ce.CAP_ROUND=1,ce.CAP_FLAT=2,ce.CAP_SQUARE=3,ce.JOIN_ROUND=1,ce.JOIN_MITRE=2,ce.JOIN_BEVEL=3,ce.DEFAULT_QUADRANT_SEGMENTS=8,ce.DEFAULT_MITRE_LIMIT=5,ce.DEFAULT_SIMPLIFY_FACTOR=.01;var be=function(M){f(p,M);var c=U(p);function p(g){var w;return s(this,p),(w=c.call(this,g)).name=Object.keys({Exception:p})[0],w}return h(p,[{key:"toString",value:function(){return this.message}}]),p}(P(Error)),we=function(M){f(p,M);var c=U(p);function p(g){var w;return s(this,p),(w=c.call(this,g)).name=Object.keys({IllegalArgumentException:p})[0],w}return p}(be),Ue=function(){function M(){s(this,M)}return h(M,[{key:"filter",value:function(c){}}]),M}();function ze(){}function Ve(){}function Ie(){}var ft,lt,Je,At,ut,Nt,Lt,Yt,Mt=function(){function M(){s(this,M)}return h(M,null,[{key:"equalsWithTolerance",value:function(c,p,g){return Math.abs(c-p)<=g}}]),M}(),Gt=function(){function M(c,p){s(this,M),this.low=p||0,this.high=c||0}return h(M,null,[{key:"toBinaryString",value:function(c){var p,g="";for(p=2147483648;p>0;p>>>=1)g+=(c.high&p)===p?"1":"0";for(p=2147483648;p>0;p>>>=1)g+=(c.low&p)===p?"1":"0";return g}}]),M}();function tt(){}function Bt(){}tt.NaN=NaN,tt.isNaN=function(M){return Number.isNaN(M)},tt.isInfinite=function(M){return!Number.isFinite(M)},tt.MAX_VALUE=Number.MAX_VALUE,tt.POSITIVE_INFINITY=Number.POSITIVE_INFINITY,tt.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,typeof Float64Array=="function"&&typeof Int32Array=="function"?(Nt=2146435072,Lt=new Float64Array(1),Yt=new Int32Array(Lt.buffer),tt.doubleToLongBits=function(M){Lt[0]=M;var c=0|Yt[0],p=0|Yt[1];return(p&Nt)===Nt&&1048575&p&&c!==0&&(c=0,p=2146959360),new Gt(p,c)},tt.longBitsToDouble=function(M){return Yt[0]=M.low,Yt[1]=M.high,Lt[0]}):(ft=1023,lt=Math.log2,Je=Math.floor,At=Math.pow,ut=function(){for(var M=53;M>0;M--){var c=At(2,M)-1;if(Je(lt(c))+1===M)return c}return 0}(),tt.doubleToLongBits=function(M){var c,p,g,w,L,
|
||
|
|
`}[c]}}]),M}(),ee=function(){function M(){s(this,M)}return h(M,null,[{key:"log10",value:function(c){var p=Math.log(c);return tt.isInfinite(p)||tt.isNaN(p)?p:p/M.LOG_10}},{key:"min",value:function(c,p,g,w){var L=c;return p<L&&(L=p),g<L&&(L=g),w<L&&(L=w),L}},{key:"clamp",value:function(){if(typeof arguments[2]=="number"&&typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var c=arguments[0],p=arguments[1],g=arguments[2];return c<p?p:c>g?g:c}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var w=arguments[0],L=arguments[1],V=arguments[2];return w<L?L:w>V?V:w}}},{key:"wrap",value:function(c,p){return c<0?p- -c%p:c%p}},{key:"max",value:function(){if(arguments.length===3){var c=arguments[0],p=arguments[1],g=arguments[2],w=c;return p>w&&(w=p),g>w&&(w=g),w}if(arguments.length===4){var L=arguments[0],V=arguments[1],X=arguments[2],Q=arguments[3],ae=L;return V>ae&&(ae=V),X>ae&&(ae=X),Q>ae&&(ae=Q),ae}}},{key:"average",value:function(c,p){return(c+p)/2}}]),M}();ee.LOG_10=Math.log(10);var ne=function(){function M(){s(this,M)}return h(M,null,[{key:"segmentToSegment",value:function(c,p,g,w){if(c.equals(p))return M.pointToSegment(c,g,w);if(g.equals(w))return M.pointToSegment(w,c,p);var L=!1;if(bn.intersects(c,p,g,w)){var V=(p.x-c.x)*(w.y-g.y)-(p.y-c.y)*(w.x-g.x);if(V===0)L=!0;else{var X=(c.y-g.y)*(w.x-g.x)-(c.x-g.x)*(w.y-g.y),Q=((c.y-g.y)*(p.x-c.x)-(c.x-g.x)*(p.y-c.y))/V,ae=X/V;(ae<0||ae>1||Q<0||Q>1)&&(L=!0)}}else L=!0;return L?ee.min(M.pointToSegment(c,g,w),M.pointToSegment(p,g,w),M.pointToSegment(g,c,p),M.pointToSegment(w,c,p)):0}},{key:"pointToSegment",value:function(c,p,g){if(p.x===g.x&&p.y===g.y)return c.distance(p);var w=(g.x-p.x)*(g.x-p.x)+(g.y-p.y)*(g.y-p.y),L=((c.x-p.x)*(g.x-p.x)+(c.y-p.y)*(g.y-p.y))/w;if(L<=0)return c.distance(p);if(L>=1)return c.distance(g);var V=((p.y-c.y)*(g.x-p.x)-(p.x-c.x)*(g.y-p.y))/w;return Math.abs(V)*Math.sqrt(w)}},{key:"pointToLinePerpendicular",value:function(c,p,g){var w=(g.x-p.x)*(g.x-p.x)+(g.y-p.y)*(g.y-p.y),L=((p.y-c.y)*(g.x-p.x)-(p.x-c.x)*(g.y-p.y))/w;return Math.abs(L)*Math.sqrt(w)}},{key:"pointToSegmentString",value:function(c,p){if(p.length===0)throw new we("Line array must contain at least one vertex");for(var g=c.distance(p[0]),w=0;w<p.length-1;w++){var L=M.pointToSegment(c,p[w],p[w+1]);L<g&&(g=L)}return g}}]),M}(),ve=function(){function M(){s(this,M)}return h(M,[{key:"create",value:function(){if(arguments.length===1)arguments[0]instanceof Array||an(arguments[0],Ln);else if(arguments.length!==2){if(arguments.length===3){var c=arguments[0],p=arguments[1];return this.create(c,p)}}}}]),M}(),ke=function(){function M(){s(this,M)}return h(M,[{key:"filter",value:function(c){}}]),M}(),De=function(){function M(){s(this,M)}return h(M,null,[{key:"ofLine",value:function(c){var p=c.size();if(p<=1)return 0;var g=0,w=new je;c.getCoordinate(0,w);for(var L=w.x,V=w.y,X=1;X<p;X++){c.getCoordinate(X,w);var Q=w.x,ae=w.y,Le=Q-L,Ne=ae-V;g+=Math.sqrt(Le*Le+Ne*Ne),L=Q,V=ae}return g}}]),M}(),Ge=function M(){s(this,M)},Fe=function(){function M(){s(this,M)}return h(M,null,[{key:"copyCoord",value:function(c,p,g,w){for(var L=Math.min(c.getDimension(),g.getDimension()),V=0;V<L;V++)g.setOrdinate(w,V,c.getOrdinate(p,V))}},{key:"isRing",value:function(c){var p=c.size();return p===0||!(p<=3)&&c.getOrdinate(0,Ln.X)===c.getOrdinate(p-1,Ln.X)&&c.getOrdinate(0,Ln.Y)===c.getOrdinate(p-1,Ln.Y)}},{key:"scroll",value:function(){if(arguments.length===2){if(an(arguments[0],Ln)&&Number.isInteger(arguments[1])){var c=arguments[0],p=arguments[1];M.scroll(c,p,M.isRing(c))}else if(an(arguments[0],Ln)&&arguments[1]instanceof je){var g=arguments[0],w=arguments[1],L=M.indexOf(w,g);if(L<=0)return null;M.scroll(g,L)}}else if(arguments.length===3){var V=arguments[0],X=arguments[1],Q=arguments[2],ae=X;if(ae<=0)return null;for(var Le=V.copy(),Ne=Q?V.size()-1:V.size(),rt=0;rt<Ne;rt++)for(var kt=0;kt<V.getDimension();kt++)V.setOrdinate(rt,kt,Le.getOrdinate((X+rt)%Ne,kt));if(Q)for(var Ct=0;Ct<V.getDimension();Ct++)V.setOrdinate(Ne,Ct,V.getOrdinate(0,Ct))}}},{key:"isEqual",value:function(c,p
|
||
|
|
`}},{key:"nextChar_",value:function(){return this.wkt.charAt(++this.index_)}},{key:"nextToken",value:function(){var c,p=this.nextChar_(),g=this.index_,w=p;if(p=="(")c=Pt;else if(p==",")c=Ji;else if(p==")")c=fn;else if(this.isNumeric_(p)||p=="-")c=In,w=this.readNumber_();else if(this.isAlpha_(p))c=Oo,w=this.readText_();else{if(this.isWhiteSpace_(p))return this.nextToken();if(p!=="")throw new Error("Unexpected character: "+p);c=ho}return{position:g,value:w,type:c}}},{key:"readNumber_",value:function(){var c,p=this.index_,g=!1,w=!1;do c=="."?g=!0:c!="e"&&c!="E"||(w=!0),c=this.nextChar_();while(this.isNumeric_(c,g)||!w&&(c=="e"||c=="E")||w&&(c=="-"||c=="+"));return parseFloat(this.wkt.substring(p,this.index_--))}},{key:"readText_",value:function(){var c,p=this.index_;do c=this.nextChar_();while(this.isAlpha_(c));return this.wkt.substring(p,this.index_--).toUpperCase()}}]),M}(),la=function(){function M(c,p){s(this,M),this.lexer_=c,this.token_,this.layout_=Ti,this.factory=p}return h(M,[{key:"consume_",value:function(){this.token_=this.lexer_.nextToken()}},{key:"isTokenType",value:function(c){return this.token_.type==c}},{key:"match",value:function(c){var p=this.isTokenType(c);return p&&this.consume_(),p}},{key:"parse",value:function(){return this.consume_(),this.parseGeometry_()}},{key:"parseGeometryLayout_",value:function(){var c=Ti,p=this.token_;if(this.isTokenType(Oo)){var g=p.value;g==="Z"?c=Ki:g==="M"?c=Nu:g==="ZM"&&(c=Eo),c!==Ti&&this.consume_()}return c}},{key:"parseGeometryCollectionText_",value:function(){if(this.match(Pt)){var c=[];do c.push(this.parseGeometry_());while(this.match(Ji));if(this.match(fn))return c}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePointText_",value:function(){if(this.match(Pt)){var c=this.parsePoint_();if(this.match(fn))return c}else if(this.isEmptyGeometry_())return null;throw new Error(this.formatErrorMessage_())}},{key:"parseLineStringText_",value:function(){if(this.match(Pt)){var c=this.parsePointList_();if(this.match(fn))return c}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePolygonText_",value:function(){if(this.match(Pt)){var c=this.parseLineStringTextList_();if(this.match(fn))return c}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPointText_",value:function(){var c;if(this.match(Pt)){if(c=this.token_.type==Pt?this.parsePointTextList_():this.parsePointList_(),this.match(fn))return c}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiLineStringText_",value:function(){if(this.match(Pt)){var c=this.parseLineStringTextList_();if(this.match(fn))return c}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPolygonText_",value:function(){if(this.match(Pt)){var c=this.parsePolygonTextList_();if(this.match(fn))return c}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePoint_",value:function(){for(var c=[],p=this.layout_.length,g=0;g<p;++g){var w=this.token_;if(!this.match(In))break;c.push(w.value)}if(c.length==p)return c;throw new Error(this.formatErrorMessage_())}},{key:"parsePointList_",value:function(){for(var c=[this.parsePoint_()];this.match(Ji);)c.push(this.parsePoint_());return c}},{key:"parsePointTextList_",value:function(){for(var c=[this.parsePointText_()];this.match(Ji);)c.push(this.parsePointText_());return c}},{key:"parseLineStringTextList_",value:function(){for(var c=[this.parseLineStringText_()];this.match(Ji);)c.push(this.parseLineStringText_());return c}},{key:"parsePolygonTextList_",value:function(){for(var c=[this.parsePolygonText_()];this.match(Ji);)c.push(this.parsePolygonText_());return c}},{key:"isEmptyGeometry_",value:function(){var c=this.isTokenType(Oo)&&this.token_.value==Rl;return c&&this.consume_(),c}},{key:"formatErrorMessage_",value:function(){return"Unexpected `"+this.token_.value+"` at position "+this.token_.position+" in `"+this.lexer_.wkt+"`"}},{key:"pa
|
||
|
|
`);for(var p=this.iterator();p.hasNext();){var g=p.next();c.append(g),c.append(`
|
||
|
|
`)}return c.toString()}},{key:"computeEdgeEndLabels",value:function(c){for(var p=this.iterator();p.hasNext();)p.next().computeLabel(c)}},{key:"computeLabelling",value:function(c){this.computeEdgeEndLabels(c[0].getBoundaryNodeRule()),this.propagateSideLabels(0),this.propagateSideLabels(1);for(var p=[!1,!1],g=this.iterator();g.hasNext();)for(var w=g.next().getLabel(),L=0;L<2;L++)w.isLine(L)&&w.getLocation(L)===Me.BOUNDARY&&(p[L]=!0);for(var V=this.iterator();V.hasNext();)for(var X=V.next(),Q=X.getLabel(),ae=0;ae<2;ae++)if(Q.isAnyNull(ae)){var Le=Me.NONE;if(p[ae])Le=Me.EXTERIOR;else{var Ne=X.getCoordinate();Le=this.getLocation(ae,Ne,c)}Q.setAllLocationsIfNull(ae,Le)}}},{key:"getDegree",value:function(){return this._edgeMap.size()}},{key:"insertEdgeEnd",value:function(c,p){this._edgeMap.put(c,p),this._edgeList=null}}],[{key:"constructor_",value:function(){this._edgeMap=new fo,this._edgeList=null,this._ptInAreaLocation=[Me.NONE,Me.NONE]}}]),M}(),oh=function(M){f(p,M);var c=U(p);function p(){var g;return s(this,p),g=c.call(this),p.constructor_.apply(R(g),arguments),g}return h(p,[{key:"linkResultDirectedEdges",value:function(){this.getResultAreaEdges();for(var g=null,w=null,L=this._SCANNING_FOR_INCOMING,V=0;V<this._resultAreaEdgeList.size();V++){var X=this._resultAreaEdgeList.get(V),Q=X.getSym();if(X.getLabel().isArea())switch(g===null&&X.isInResult()&&(g=X),L){case this._SCANNING_FOR_INCOMING:if(!Q.isInResult())continue;w=Q,L=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(!X.isInResult())continue;w.setNext(X),L=this._SCANNING_FOR_INCOMING}}if(L===this._LINKING_TO_OUTGOING){if(g===null)throw new vr("no outgoing dirEdge found",this.getCoordinate());St.isTrue(g.isInResult(),"unable to link last incoming dirEdge"),w.setNext(g)}}},{key:"insert",value:function(g){var w=g;this.insertEdgeEnd(w,w)}},{key:"getRightmostEdge",value:function(){var g=this.getEdges(),w=g.size();if(w<1)return null;var L=g.get(0);if(w===1)return L;var V=g.get(w-1),X=L.getQuadrant(),Q=V.getQuadrant();return ar.isNorthern(X)&&ar.isNorthern(Q)?L:ar.isNorthern(X)||ar.isNorthern(Q)?L.getDy()!==0?L:V.getDy()!==0?V:(St.shouldNeverReachHere("found two horizontal edges incident on node"),null):V}},{key:"print",value:function(g){xe.out.println("DirectedEdgeStar: "+this.getCoordinate());for(var w=this.iterator();w.hasNext();){var L=w.next();g.print("out "),L.print(g),g.println(),g.print("in "),L.getSym().print(g),g.println()}}},{key:"getResultAreaEdges",value:function(){if(this._resultAreaEdgeList!==null)return this._resultAreaEdgeList;this._resultAreaEdgeList=new nn;for(var g=this.iterator();g.hasNext();){var w=g.next();(w.isInResult()||w.getSym().isInResult())&&this._resultAreaEdgeList.add(w)}return this._resultAreaEdgeList}},{key:"updateLabelling",value:function(g){for(var w=this.iterator();w.hasNext();){var L=w.next().getLabel();L.setAllLocationsIfNull(0,g.getLocation(0)),L.setAllLocationsIfNull(1,g.getLocation(1))}}},{key:"linkAllDirectedEdges",value:function(){this.getEdges();for(var g=null,w=null,L=this._edgeList.size()-1;L>=0;L--){var V=this._edgeList.get(L),X=V.getSym();w===null&&(w=X),g!==null&&X.setNext(g),g=V}w.setNext(g)}},{key:"computeDepths",value:function(){if(arguments.length===1){var g=arguments[0],w=this.findIndex(g),L=g.getDepth(wt.LEFT),V=g.getDepth(wt.RIGHT),X=this.computeDepths(w+1,this._edgeList.size(),L),Q=this.computeDepths(0,w,X);if(Q!==V)throw new vr("depth mismatch at "+g.getCoordinate())}else if(arguments.length===3){for(var ae=arguments[0],Le=arguments[1],Ne=arguments[2],rt=Ne,kt=ae;kt<Le;kt++){var Ct=this._edgeList.get(kt);Ct.setEdgeDepths(wt.RIGHT,rt),rt=Ct.getDepth(wt.LEFT)}return rt}}},{key:"mergeSymLabels",value:function(){for(var g=this.iterator();g.hasNext();){var w=g.next();w.getLabel().merge(w.getSym().getLabel())}}},{key:"linkMinimalDirectedEdges",value:function(g){for(var w=null,L=null,V=this._SCANNING_FOR_INCOMING,X=this._resultAreaEdgeList.size()-1;X>=0;X--){var Q=this._resultAreaEdgeList.get(X),ae=Q.getSym();switch(w===null&&Q.getEdgeRing()===g&&(w=Q),V){case this._SCANNING_FOR_INCOMING:if(ae.getEdgeRing()!
|
||
|
|
* splaytree v3.1.2
|
||
|
|
* Fast Splay tree for Node and browser
|
||
|
|
*
|
||
|
|
* @author Alexander Milevski <info@w8r.name>
|
||
|
|
* @license MIT
|
||
|
|
* @preserve
|
||
|
|
*//*! *****************************************************************************
|
||
|
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||
|
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||
|
|
this file except in compliance with the License. You may obtain a copy of the
|
||
|
|
License at http://www.apache.org/licenses/LICENSE-2.0
|
||
|
|
|
||
|
|
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||
|
|
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||
|
|
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||
|
|
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||
|
|
|
||
|
|
See the Apache Version 2.0 License for specific language governing permissions
|
||
|
|
and limitations under the License.
|
||
|
|
***************************************************************************** */function JT(a,i){var s={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,h,f,x;return x={next:t(0),throw:t(1),return:t(2)},typeof Symbol=="function"&&(x[Symbol.iterator]=function(){return this}),x;function t(k){return function(P){return E([k,P])}}function E(k){if(l)throw new TypeError("Generator is already executing.");for(;s;)try{if(l=1,h&&(f=k[0]&2?h.return:k[0]?h.throw||((f=h.return)&&f.call(h),0):h.next)&&!(f=f.call(h,k[1])).done)return f;switch(h=0,f&&(k=[k[0]&2,f.value]),k[0]){case 0:case 1:f=k;break;case 4:return s.label++,{value:k[1],done:!1};case 5:s.label++,h=k[1],k=[0];continue;case 7:k=s.ops.pop(),s.trys.pop();continue;default:if(f=s.trys,!(f=f.length>0&&f[f.length-1])&&(k[0]===6||k[0]===2)){s=0;continue}if(k[0]===3&&(!f||k[1]>f[0]&&k[1]<f[3])){s.label=k[1];break}if(k[0]===6&&s.label<f[1]){s.label=f[1],f=k;break}if(f&&s.label<f[2]){s.label=f[2],s.ops.push(k);break}f[2]&&s.ops.pop(),s.trys.pop();continue}k=i.call(a,s)}catch(P){k=[6,P],h=0}finally{l=f=0}if(k[0]&5)throw k[1];return{value:k[0]?k[1]:void 0,done:!0}}}var Oa=function(){function a(i,s){this.next=null,this.key=i,this.data=s,this.left=null,this.right=null}return a}();function QT(a,i){return a>i?1:a<i?-1:0}function Na(a,i,s){for(var l=new Oa(null,null),h=l,f=l;;){var x=s(a,i.key);if(x<0){if(i.left===null)break;if(s(a,i.left.key)<0){var t=i.left;if(i.left=t.right,t.right=i,i=t,i.left===null)break}f.left=i,f=i,i=i.left}else if(x>0){if(i.right===null)break;if(s(a,i.right.key)>0){var t=i.right;if(i.right=t.left,t.left=i,i=t,i.right===null)break}h.right=i,h=i,i=i.right}else break}return h.right=i.left,f.left=i.right,i.left=l.right,i.right=l.left,i}function sm(a,i,s,l){var h=new Oa(a,i);if(s===null)return h.left=h.right=null,h;s=Na(a,s,l);var f=l(a,s.key);return f<0?(h.left=s.left,h.right=s,s.left=null):f>=0&&(h.right=s.right,h.left=s,s.right=null),h}function Qy(a,i,s){var l=null,h=null;if(i){i=Na(a,i,s);var f=s(i.key,a);f===0?(l=i.left,h=i.right):f<0?(h=i.right,i.right=null,l=i):(l=i.left,i.left=null,h=i)}return{left:l,right:h}}function e2(a,i,s){return i===null?a:(a===null||(i=Na(a.key,i,s),i.left=a),i)}function am(a,i,s,l,h){if(a){l(""+i+(s?"└── ":"├── ")+h(a)+`
|
||
|
|
`);var f=i+(s?" ":"│ ");a.left&&am(a.left,f,!1,l,h),a.right&&am(a.right,f,!0,l,h)}}var lm=function(){function a(i){i===void 0&&(i=QT),this._root=null,this._size=0,this._comparator=i}return a.prototype.insert=function(i,s){return this._size++,this._root=sm(i,s,this._root,this._comparator)},a.prototype.add=function(i,s){var l=new Oa(i,s);this._root===null&&(l.left=l.right=null,this._size++,this._root=l);var h=this._comparator,f=Na(i,this._root,h),x=h(i,f.key);return x===0?this._root=f:(x<0?(l.left=f.left,l.right=f,f.left=null):x>0&&(l.right=f.right,l.left=f,f.right=null),this._size++,this._root=l),this._root},a.prototype.remove=function(i){this._root=this._remove(i,this._root,this._comparator)},a.prototype._remove=function(i,s,l){var h;if(s===null)return null;s=Na(i,s,l);var f=l(i,s.key);return f===0?(s.left===null?h=s.right:(h=Na(i,s.left,l),h.right=s.right),this._size--,h):s},a.prototype.pop=function(){var i=this._root;if(i){for(;i.left;)i=i.left;return this._root=Na(i.key,this._root,this._comparator),this._root=this._remove(i.key,this._root,this._comparator),{key:i.key,data:i.data}}return null},a.prototype.findStatic=function(i){for(var s=this._root,l=this._comparator;s;){var h=l(i,s.key);if(h===0)return s;h<0?s=s.left:s=s.right}return null},a.prototype.find=function(i){return this._root&&(this._root=Na(i,this._root,this._comparator),this._comparator(i,this._root.key)!==0)?null:this._root},a.prototype.contains=function(i){for(var s=this._root,l=this._comparator;s;){var h=l(i,s.key);if(h===0)return!0;h<0?s=s.left:s=s.right}return!1},a.prototype.forEach=function(i,s){for(var l=this._root,h=[],f=!1;!f;)l!==null?(h.push(l),l=l.left):h.length!==0?(l=h.pop(),i.call(s,l),l=l.right):f=!0;return this},a.prototype.range=function(i,s,l,h){for(var f=[],x=this._comparator,t=this._root,E;f.length!==0||t;)if(t)f.push(t),t=t.left;else{if(t=f.pop(),E=x(t.key,s),E>0)break;if(x(t.key,i)>=0&&l.call(h,t))return this;t=t.right}return this},a.prototype.keys=function(){var i=[];return this.forEach(function(s){var l=s.key;return i.push(l)}),i},a.prototype.values=function(){var i=[];return this.forEach(function(s){var l=s.data;return i.push(l)}),i},a.prototype.min=function(){return this._root?this.minNode(this._root).key:null},a.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},a.prototype.minNode=function(i){if(i===void 0&&(i=this._root),i)for(;i.left;)i=i.left;return i},a.prototype.maxNode=function(i){if(i===void 0&&(i=this._root),i)for(;i.right;)i=i.right;return i},a.prototype.at=function(i){for(var s=this._root,l=!1,h=0,f=[];!l;)if(s)f.push(s),s=s.left;else if(f.length>0){if(s=f.pop(),h===i)return s;h++,s=s.right}else l=!0;return null},a.prototype.next=function(i){var s=this._root,l=null;if(i.right){for(l=i.right;l.left;)l=l.left;return l}for(var h=this._comparator;s;){var f=h(i.key,s.key);if(f===0)break;f<0?(l=s,s=s.left):s=s.right}return l},a.prototype.prev=function(i){var s=this._root,l=null;if(i.left!==null){for(l=i.left;l.right;)l=l.right;return l}for(var h=this._comparator;s;){var f=h(i.key,s.key);if(f===0)break;f<0?s=s.left:(l=s,s=s.right)}return l},a.prototype.clear=function(){return this._root=null,this._size=0,this},a.prototype.toList=function(){return n2(this._root)},a.prototype.load=function(i,s,l){s===void 0&&(s=[]),l===void 0&&(l=!1);var h=i.length,f=this._comparator;if(l&&hm(i,s,0,h-1,f),this._root===null)this._root=um(i,s,0,h),this._size=h;else{var x=i2(this.toList(),t2(i,s),f);h=this._size+h,this._root=cm({head:x},0,h)}return this},a.prototype.isEmpty=function(){return this._root===null},Object.defineProperty(a.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),a.prototype.toString=function(i){i===void 0&&(i=function(l){return String(l.key)});var s=[];return am(this._root,"",!0,function(l){return s.push(l)},i),s.join("")},a.prototype.update=function(i,s,l){var h=this._comparator,f=Qy(i,this._root,h),x=f.left,t=f.right;h(i,s)<0?t=sm(s,l,t,h):x=sm(s,l,x
|
||
|
|
* Copyright (c) 2019, Dane Springmeyer
|
||
|
|
*
|
||
|
|
* Redistribution and use in source and binary forms, with or without
|
||
|
|
* modification, are permitted provided that the following conditions are
|
||
|
|
* met:
|
||
|
|
*
|
||
|
|
* * Redistributions of source code must retain the above copyright
|
||
|
|
* notice, this list of conditions and the following disclaimer.
|
||
|
|
* * Redistributions in binary form must reproduce the above copyright
|
||
|
|
* notice, this list of conditions and the following disclaimer in
|
||
|
|
* the documentation and/or other materials provided with the
|
||
|
|
* distribution.
|
||
|
|
*
|
||
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||
|
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||
|
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
|
|
*/function qc(a,i={}){const s=[];if(Br(a,h=>{s.push(h.coordinates)}),s.length<2)throw new Error("Must specify at least 2 geometries");const l=Ds.intersection(s[0],...s.slice(1));return l.length===0?null:l.length===1?Mn(l[0],i.properties):oo(l,i.properties)}function b0(a,i,s={}){const l=JSON.stringify(s.properties||{}),[h,f,x,t]=a,E=(f+t)/2,k=(h+x)/2,R=i*2/Wn([h,E],[x,E],s)*(x-h),U=i*2/Wn([k,f],[k,t],s)*(t-f),Z=R/2,J=Z*2,he=Math.sqrt(3)/2*U,ye=x-h,te=t-f,ce=3/4*J,be=he,we=(ye-J)/(J-Z/2),Ue=Math.floor(we),ze=(Ue*ce-Z/2-ye)/2-Z/2+ce/2,Ve=Math.floor((te-he)/he);let Ie=(te-Ve*he)/2;const ft=Ve*he-te>he/2;ft&&(Ie-=he/4);const lt=[],Je=[];for(let ut=0;ut<6;ut++){const Nt=2*Math.PI/6*ut;lt.push(Math.cos(Nt)),Je.push(Math.sin(Nt))}const At=[];for(let ut=0;ut<=Ue;ut++)for(let Nt=0;Nt<=Ve;Nt++){const Lt=ut%2===1;if(Nt===0&&Lt||Nt===0&&ft)continue;const Yt=ut*ce+h-ze;let Mt=Nt*be+f+Ie;if(Lt&&(Mt-=he/2),s.triangles===!0)A2([Yt,Mt],R/2,U/2,JSON.parse(l),lt,Je).forEach(function(Gt){s.mask?qc(Jt([s.mask,Gt]))&&At.push(Gt):At.push(Gt)});else{const Gt=C2([Yt,Mt],R/2,U/2,JSON.parse(l),lt,Je);s.mask?qc(Jt([s.mask,Gt]))&&At.push(Gt):At.push(Gt)}}return Jt(At)}function C2(a,i,s,l,h,f){const x=[];for(let t=0;t<6;t++){const E=a[0]+i*h[t],k=a[1]+s*f[t];x.push([E,k])}return x.push(x[0].slice()),Mn([x],l)}function A2(a,i,s,l,h,f){const x=[];for(let t=0;t<6;t++){const E=[];E.push(a),E.push([a[0]+i*h[t],a[1]+s*f[t]]),E.push([a[0]+i*h[(t+1)%6],a[1]+s*f[(t+1)%6]]),E.push(a),x.push(Mn([E],l))}return x}function w0(a,i,s={}){s.mask&&!s.units&&(s.units="kilometers");for(var l=[],h=a[0],f=a[1],x=a[2],t=a[3],E=i/Wn([h,f],[x,f],s),k=E*(x-h),P=i/Wn([h,f],[h,t],s),R=P*(t-f),F=x-h,U=t-f,Z=Math.floor(F/k),J=Math.floor(U/R),he=(F-Z*k)/2,ye=(U-J*R)/2,te=h+he;te<=x;){for(var ce=f+ye;ce<=t;){var be=cn([te,ce],s.properties);s.mask?$_(be,s.mask)&&l.push(be):l.push(be),ce+=R}te+=k}return Jt(l)}function E0(a,i,s,l={}){const h=[],f=a[0],x=a[1],t=a[2],E=a[3],k=t-f,P=El(i,l.units,"degrees"),R=E-x,F=El(s,l.units,"degrees"),U=Math.floor(Math.abs(k)/P),Z=Math.floor(Math.abs(R)/F),J=(k-U*P)/2,he=(R-Z*F)/2;let ye=f+J;for(let te=0;te<U;te++){let ce=x+he;for(let be=0;be<Z;be++){const we=Mn([[[ye,ce],[ye,ce+F],[ye+P,ce+F],[ye+P,ce],[ye,ce]]],l.properties);l.mask?O_(l.mask,we)&&h.push(we):h.push(we),ce+=F}ye+=P}return Jt(h)}function _m(a,i,s={}){return E0(a,i,i,s)}function T0(a,i,s={}){for(var l=[],h=i/Wn([a[0],a[1]],[a[2],a[1]],s),f=h*(a[2]-a[0]),x=i/Wn([a[0],a[1]],[a[0],a[3]],s),t=x*(a[3]-a[1]),E=0,k=a[0];k<=a[2];){for(var P=0,R=a[1];R<=a[3];){var F=null,U=null;E%2===0&&P%2===0?(F=Mn([[[k,R],[k,R+t],[k+f,R],[k,R]]],s.properties),U=Mn([[[k,R+t],[k+f,R+t],[k+f,R],[k,R+t]]],s.properties)):E%2===0&&P%2===1?(F=Mn([[[k,R],[k+f,R+t],[k+f,R],[k,R]]],s.properties),U=Mn([[[k,R],[k,R+t],[k+f,R+t],[k,R]]],s.properties)):P%2===0&&E%2===1?(F=Mn([[[k,R],[k,R+t],[k+f,R+t],[k,R]]],s.properties),U=Mn([[[k,R],[k+f,R+t],[k+f,R],[k,R]]],s.properties)):P%2===1&&E%2===1&&(F=Mn([[[k,R],[k,R+t],[k+f,R],[k,R]]],s.properties),U=Mn([[[k,R+t],[k+f,R+t],[k+f,R],[k,R+t]]],s.properties)),s.mask?(qc(Jt([s.mask,F]))&&l.push(F),qc(Jt([s.mask,U]))&&l.push(U)):(l.push(F),l.push(U)),R+=t,P++}E++,k+=f}return Jt(l)}function P2(a,i,s){if(s=s||{},typeof s!="object")throw new Error("options is invalid");var l=s.gridType,h=s.property,f=s.weight;if(!a)throw new Error("points is required");if(Qs(a,"Point","input must contain Points"),!i)throw new Error("cellSize is required");if(f!==void 0&&typeof f!="number")throw new Error("weight must be a number");h=h||"elevation",l=l||"square",f=f||1;var x=pi(a),t;switch(l){case"point":case"points":t=w0(x,i,s);break;case"square":case"squares":t=_m(x,i,s);break;case"hex":case"hexes":t=b0(x,i,s);break;case"triangle":case"triangles":t=T0(x,i,s);break;default:throw new Error("invalid gridType")}var E=[];return Bn(t,function(k){var P=0,R=0;Bn(a,function(U){var Z=l==="point"?k:na(k),J=Wn(Z,U,s),he;if(h!==void 0&&(he=U.properties[h]),he===void 0&&(he=U.geometry.coordinates[2]),he===void 0)throw new Error("zValue is missing");J===0&&(P=he);var ye=1/Math.pow(J,f);R+=ye,P+=ye*he});var F=yr(k);F
|
||
|
|
* MarchingSquaresJS
|
||
|
|
* version 1.3.3
|
||
|
|
* https://github.com/RaumZeit/MarchingSquares.js
|
||
|
|
*
|
||
|
|
* @license GNU Affero General Public License.
|
||
|
|
* Copyright (c) 2015-2019 Ronny Lorenz <ronny@tbi.univie.ac.at>
|
||
|
|
*/function L2(a,i,s){return a<i?(s-a)/(i-a):(a-s)/(a-i)}function R2(a,i,s,l){var h;return s>l&&(h=s,s=l,l=h),a<i?a<s?(s-a)/(i-a):(l-a)/(i-a):a>l?(a-l)/(a-i):(a-s)/(a-i)}function D2(a,i,s,l){return a<i?(s-a)/(i-a):(a-l)/(a-i)}function z2(a,i,s,l){return a<i?(l-a)/(i-a):(a-s)/(a-i)}function I0(){this.successCallback=null,this.verbose=!1,this.polygons=!1,this.polygons_full=!1,this.linearRing=!0,this.noQuadTree=!1,this.noFrame=!1}function O2(a){var i,s,l,h,f;for(h=new I0,a=a||{},f=Object.keys(h),i=0;i<f.length;i++)s=f[i],l=a[s],typeof l<"u"&&l!==null&&(h[s]=l);return h.polygons_full=!h.polygons,h.interpolate=R2,h.interpolate_a=D2,h.interpolate_b=z2,h}function N2(a){var i,s,l,h,f;for(h=new I0,a=a||{},f=Object.keys(h),i=0;i<f.length;i++)s=f[i],l=a[s],typeof l<"u"&&l!==null&&(h[s]=l);return h.polygons_full=!h.polygons,h.interpolate=L2,h}function Wf(a,i,s,l){var h=[];return a.polygons.forEach(function(f){f.forEach(function(x){x[0]+=i,x[1]+=s}),l.linearRing&&f.push(f[0]),h.push(f)}),h}function M0(a,i,s,l){return s===0?(a+=1,i+=l[0][1]):s===1?a+=l[0][0]:s===2?i+=l[0][1]:s===3&&(a+=l[0][0],i+=1),[a,i]}function S0(a,i,s){return s===0?a++:s===1||(s===2?i++:s===3&&(a++,i++)),[a,i]}function B2(a,i,s){var l,h,f,x,t;for(l=!0,h=a[0].length,f=a.length,t=0;t<f;t++)if(a[t][0]<i||a[t][0]>s||a[t][h-1]<i||a[t][h-1]>s){l=!1;break}if(l&&(a[f-1][0]<i||a[f-1][0]>s||a[f-1][h-1]<i||a[f-1][h-1]>s)&&(l=!1),l){for(x=0;x<h-1;x++)if(a[0][x]<i||a[0][x]>s||a[f-1][x]<i||a[f-1][x]>s){l=!1;break}}return l}function F2(a,i){var s,l,h,f,x;for(s=!0,l=a[0].length,h=a.length,x=0;x<h;x++)if(a[x][0]>=i||a[x][l-1]>=i){s=!1;break}if(s&&(a[h-1][0]>=i||a[h-1][l-1]>=i)&&(s=!1),s){for(f=0;f<l-1;f++)if(a[0][f]>=i||a[h-1][f]>i){s=!1;break}}return s}function V2(a,i,s){var l,h,f,x,t,E,k,P,R,F,U,Z,J,he,ye,te,ce=[],be=a.length-1,we=a[0].length-1,Ue=[["rt","rb"],["br","bl"],["lb","lt"],["tl","tr"]],ze=[0,-1,0,1],Ve=[-1,0,1,0],Ie=["bl","lb","lt","tl","tr","rt","rb","br"],ft={bl:1,br:1,lb:2,lt:2,tl:3,tr:3,rt:0,rb:0};return B2(a,s.minV,s.maxV)&&(s.linearRing?ce.push([[0,0],[0,be],[we,be],[we,0],[0,0]]):ce.push([[0,0],[0,be],[we,be],[we,0]])),i.forEach(function(lt,Je){lt.forEach(function(At,ut){for(l=null,f=0;f<8;f++)if(l=Ie[f],typeof At.edges[l]=="object"){for(h=[],x=At.edges[l],k=l,P=Je,R=ut,F=!1,U=[Je+x.path[0][0],ut+x.path[0][1]],h.push(U);!F&&(Z=i[P][R],typeof Z.edges[k]=="object");)if(x=Z.edges[k],delete Z.edges[k],ye=x.path[1],ye[0]+=P,ye[1]+=R,h.push(ye),k=x.move.enter,P=P+x.move.x,R=R+x.move.y,typeof i[P]>"u"||typeof i[P][R]>"u"){if(J=0,he=0,P===we)P--,J=0;else if(P<0)P++,J=2;else if(R===be)R--,J=3;else if(R<0)R++,J=1;else throw new Error("Left the grid somewhere in the interior!");if(P===Je&&R===ut&&J===ft[l]){F=!0,k=l;break}for(;;){if(te=!1,he>4)throw new Error("Direction change counter overflow! This should never happen!");if(!(typeof i[P]>"u"||typeof i[P][R]>"u")){for(Z=i[P][R],t=0;t<Ue[J].length;t++)if(E=Ue[J][t],typeof Z.edges[E]=="object"){x=Z.edges[E],h.push(M0(P,R,J,x.path)),k=E,te=!0;break}}if(te)break;if(h.push(S0(P,R,J)),P+=ze[J],R+=Ve[J],(typeof i[P]>"u"||typeof i[P][R]>"u")&&(J===0&&R<0||J===1&&P<0||J===2&&R===be||J===3&&P===we)&&(P-=ze[J],R-=Ve[J],J=(J+1)%4,he++),P===Je&&R===ut&&J===ft[l]){F=!0,k=l;break}}}s.linearRing&&(h[h.length-1][0]!==U[0]||h[h.length-1][1]!==U[1])&&h.push(U),ce.push(h)}})}),ce}function U2(a,i,s){var l,h,f,x,t,E,k,P,R,F,U,Z,J,he,ye,te=[],ce=a.length-1,be=a[0].length-1,we=["right","bottom","left","top"],Ue=[0,-1,0,1],ze=[-1,0,1,0],Ve={bottom:1,left:2,top:3,right:0};return s.noFrame||F2(a,s.threshold)&&(s.linearRing?te.push([[0,0],[0,ce],[be,ce],[be,0],[0,0]]):te.push([[0,0],[0,ce],[be,ce],[be,0]])),i.forEach(function(Ie,ft){Ie.forEach(function(lt,Je){for(l=null,h=0;h<4;h++)if(l=we[h],typeof lt.edges[l]=="object"){for(t=[],f=lt.edges[l],E=l,k=ft,P=Je,R=!1,F=[ft+f.path[0][0],Je+f.path[0][1]],t.push(F);!R&&(x=i[k][P],typeof x.edges[E]=="object");)if(f=x.edges[E],delete x.edges[E],U=f.path[1],U[0]+=k,U[1]+=P,t.push(U),E=f.move.enter,k=k+f.move.x,P=P+f.move.y,typeof i[k]>"u"||typeof i[k][P]>"u"){if(!s.linearRing)break;if(Z=0,J=0,k===be?(k--,Z=0
|
||
|
|
`)};function rd(a,i,s){this.x=a,this.y=i,this.weight=s}rd.prototype.toString=function(){return"["+this.x+" "+this.y+"]"},rd.prototype.getCost=function(a){return a&&a.x!==this.x&&a.y!==this.y?this.weight*1.41421:this.weight},rd.prototype.isWall=function(){return this.weight===0};function Ev(a){this.content=[],this.scoreFunction=a}Ev.prototype={push:function(a){this.content.push(a),this.sinkDown(this.content.length-1)},pop:function(){var a=this.content[0],i=this.content.pop();return this.content.length>0&&(this.content[0]=i,this.bubbleUp(0)),a},remove:function(a){var i=this.content.indexOf(a),s=this.content.pop();i!==this.content.length-1&&(this.content[i]=s,this.scoreFunction(s)<this.scoreFunction(a)?this.sinkDown(i):this.bubbleUp(i))},size:function(){return this.content.length},rescoreElement:function(a){this.sinkDown(this.content.indexOf(a))},sinkDown:function(a){for(var i=this.content[a];a>0;){var s=(a+1>>1)-1,l=this.content[s];if(this.scoreFunction(i)<this.scoreFunction(l))this.content[s]=i,this.content[a]=l,a=s;else break}},bubbleUp:function(a){for(var i=this.content.length,s=this.content[a],l=this.scoreFunction(s);;){var h=a+1<<1,f=h-1,x=null,t;if(f<i){var E=this.content[f];t=this.scoreFunction(E),t<l&&(x=f)}if(h<i){var k=this.content[h],P=this.scoreFunction(k);P<(x===null?l:t)&&(x=h)}if(x!==null)this.content[a]=this.content[x],this.content[x]=s,a=x;else break}}};function wM(a,i,s={}){if(s=s||{},!Hn(s))throw new Error("options is invalid");let l=s.obstacles||Jt([]),h=s.resolution||100;if(!a)throw new Error("start is required");if(!i)throw new Error("end is required");if(h&&(!cr(h)||h<=0))throw new Error("options.resolution must be a number, greater than 0");const f=Jn(a),x=Jn(i);if(a=cn(f),i=cn(x),l.type==="FeatureCollection"){if(l.features.length===0)return Zn([f,x])}else if(l.type==="Polygon")l=Jt([nr(Ei(l))]);else throw new Error("invalid obstacles");const t=l;t.features.push(a),t.features.push(i);const E=pi(xv(kc(pi(t)),1.15)),[k,P,R,F]=E,Z=Wn([k,P],[R,P],s)/h;t.features.pop(),t.features.pop();const he=Z/Wn([k,P],[R,P],s)*(R-k),te=Z/Wn([k,P],[k,F],s)*(F-P),ce=R-k,be=F-P,we=Math.floor(ce/he),Ue=Math.floor(be/te),ze=(ce-we*he)/2,Ve=(be-Ue*te)/2,Ie=[],ft=[];let lt,Je,At=1/0,ut=1/0,Nt=F-Ve,Lt=0;for(;Nt>=P;){const Zt=[],Vt=[];let St=k+ze,hn=0;for(;St<=R;){const rn=cn([St,Nt]),Tn=EM(rn,l);Zt.push(Tn?0:1),Vt.push(St+"|"+Nt);const je=Wn(rn,a);!Tn&&je<At&&(At=je,lt={x:hn,y:Lt});const Kn=Wn(rn,i);!Tn&&Kn<ut&&(ut=Kn,Je={x:hn,y:Lt}),St+=he,hn++}ft.push(Zt),Ie.push(Vt),Nt-=te,Lt++}const Yt=new Pu(ft,{diagonal:!0}),Mt=Yt.grid[lt.y][lt.x],Gt=Yt.grid[Je.y][Je.x],tt=id.search(Yt,Mt,Gt),Bt=[f];return tt.forEach(function(Zt){const Vt=Ie[Zt.x][Zt.y].split("|");Bt.push([+Vt[0],+Vt[1]])}),Bt.push(x),La(Zn(Bt))}function EM(a,i){for(let s=0;s<i.features.length;s++)if(Pn(a,i.features[s]))return!0;return!1}function TM(a,i){var s=a[0]-i[0],l=a[1]-i[1];return s*s+l*l}function IM(a,i,s){var l=i[0],h=i[1],f=s[0]-l,x=s[1]-h;if(f!==0||x!==0){var t=((a[0]-l)*f+(a[1]-h)*x)/(f*f+x*x);t>1?(l=s[0],h=s[1]):t>0&&(l+=f*t,h+=x*t)}return f=a[0]-l,x=a[1]-h,f*f+x*x}function MM(a,i){for(var s=a[0],l=[s],h,f=1,x=a.length;f<x;f++)h=a[f],TM(h,s)>i&&(l.push(h),s=h);return s!==h&&l.push(h),l}function Mm(a,i,s,l,h){for(var f=l,x,t=i+1;t<s;t++){var E=IM(a[t],a[i],a[s]);E>f&&(x=t,f=E)}f>l&&(x-i>1&&Mm(a,i,x,l,h),h.push(a[x]),s-x>1&&Mm(a,x,s,l,h))}function SM(a,i){var s=a.length-1,l=[a[0]];return Mm(a,0,s,i,l),l.push(a[s]),l}function od(a,i,s){if(a.length<=2)return a;var l=i!==void 0?i*i:1;return a=s?a:MM(a,l),a=SM(a,l),a}function kM(a,i={}){var s,l,h;if(i=i??{},!Hn(i))throw new Error("options is invalid");const f=(s=i.tolerance)!=null?s:1,x=(l=i.highQuality)!=null?l:!1,t=(h=i.mutate)!=null?h:!1;if(!a)throw new Error("geojson is required");if(f&&f<0)throw new Error("invalid tolerance");return t!==!0&&(a=yr(a)),Br(a,function(E){CM(E,f,x)}),a}function CM(a,i,s){const l=a.type;if(l==="Point"||l==="MultiPoint")return a;if(La(a,{mutate:!0}),l!=="GeometryCollection")switch(l){case"LineString":a.coordinates=od(a.coordinates,i,s);break;case"MultiLineString":a.coordinates=a
|