UNPKG

mapbox-gl

Version:
1 lines 55.2 kB
import{g as e,f as t,D as o,C as i,d as a,S as n,a as r,b as c,c as s,e as l,G as _,h as f,R as d,i as u,r as p,j as v,k as h,l as m,m as g,n as x,o as y,p as w,q as b,s as T,t as S,v as R,u as A,w as E}from"./core.js";import{cz as P,bf as C,bb as F,ey as O,ap as z,e9 as D,ao as I,ee as L,T as B,fW as N,dD as U,o as M,q as G,ai as V,cr as X,dw as k,dx as H,dz as Y,dA as W,du as j,dy as Z,al as q,f_ as Q,e4 as K,eC as J,aI as $,aK as ee,fI as te,dH as oe,bP as ie,bR as ae,aq as ne,bQ as re,bU as ce,f$ as se,aD as le,cT as _e,en as fe,eX as de,aC as ue,g0 as pe,g1 as ve}from"./shared.js";function he(o){const{painter:i,source:a,layer:_,coords:d}=o;let u=o.defines;const p=i.context,v="shadow"===i.renderPass,h="light-beam"===i.renderPass,m=i.shadowRenderer,g=D(i.transform.center.lat,i.transform.zoom),x=e(i,_.paint.get("building-cutoff-fade-range"));x.shouldRenderCutoff&&(u=u.concat("RENDER_CUTOFF"));const y=_.paint.get("building-front-cutoff"),w=y[2]<1&&!i.terrain,b=f(i.transform.pitch,y,!!i.terrain);w&&(u=u.concat("RENDER_FRONT_CUTOFF"),i.maxFrontCutoffRawStart=Math.max(i.maxFrontCutoffRawStart,y[0])),o.floodLightIntensity>0&&(u=u.concat("FLOOD_LIGHT"));for(const e of d){const f=a.getTile(e),d=f.getBucket(_);if(!d)continue;m&&0===m.getMaxCascadeForTile(e.toUnwrapped())&&(u=u.concat("SHADOWS_SINGLE_CASCADE"));const y=d.programConfigurations.get(_.id);let w,T,S,R=i.translatePosMatrix(e.expandedProjMatrix,f,[0,0],"map");if(R=P(C(),R,[1,1,o.verticalScale]),v&&m){if(t(f.tileID,d.maxHeight*g,i))continue;let e=m.calculateShadowPassMatrixFromTile(f.tileID.toUnwrapped());e=P(C(),e,[1,1,o.verticalScale]),S=c(e),w=T=i.getOrCreateProgram("buildingDepth",{config:y,defines:u,overrideFog:!1})}else if(h)w=T=i.getOrCreateProgram("buildingBloom",{config:y,defines:u,overrideFog:!1}),S=l(R);else{const t=i.transform.calculatePosMatrix(e.toUnwrapped(),i.transform.worldSize);P(t,t,[1,1,o.verticalScale]);const a=C();P(a,t,[1,-1,1/g]),F(a,a),O(a,a);const n=i.transform.getFreeCameraOptions().position,r=1<<e.canonical.z;if(S=s(R,a,o.opacity,o.facadeAOIntensity,[((n.x-e.wrap)*r-e.canonical.x)*I,(n.y*r-e.canonical.y)*I,n.z*r*I],d.tileToMeter,o.facadeEmissiveChance,o.floodLightColor,o.floodLightIntensity,b),T=i.getOrCreateProgram("building",{config:y,defines:u,overrideFog:!1}),!0===o.depthOnly)w=T;else{const e=u.concat(["BUILDING_FAUX_FACADE","HAS_ATTRIBUTE_a_faux_facade_color_emissive"]);w=i.getOrCreateProgram("building",{config:y,defines:e,overrideFog:!1})}m&&(m.setupShadowsFromMatrix(t,T,!0),w!==T&&m.setupShadowsFromMatrix(t,w,!0))}const A=(e,t)=>{if(h){const a=e.entranceBloom;t.draw(i,p.gl.TRIANGLES,o.depthMode,n.disabled,o.blendMode,r.disabled,S,_.id,a.layoutVertexBuffer,a.indexBuffer,a.segmentsBucket,_.paint,i.transform.zoom,y,[a.layoutAttenuationBuffer,a.layoutColorBuffer])}else{const a=e.segmentsBucket;let c=[e.layoutNormalBuffer,e.layoutCentroidBuffer,e.layoutColorBuffer,e.layoutFloodLightDataBuffer];e.layoutFacadePaintBuffer&&(c=c.concat([e.layoutFacadeDataBuffer,e.layoutFacadeVerticalRangeBuffer,e.layoutFacadePaintBuffer])),t.draw(i,p.gl.TRIANGLES,o.depthMode,n.disabled,o.blendMode,v?r.disabled:r.backCW,S,_.id,e.layoutVertexBuffer,e.indexBuffer,a,_.paint,i.transform.zoom,y,c)}};i.uploadCommonUniforms(p,T,e.toUnwrapped(),null,x),d.buildingWithoutFacade&&A(d.buildingWithoutFacade,T),d.buildingWithFacade&&(w!==T&&i.uploadCommonUniforms(p,w,e.toUnwrapped(),null,x),A(d.buildingWithFacade,w))}}function me(e,t,c,s,l,f,d,u,p,v,h,m,g,x){const y=e.context.gl,w=e.depthModeForSublayer(1,o.ReadOnly,y.LEQUAL,!0),b=.1*(1-(T=h))+3*T;var T;const S=e._showOverdrawInspector,R=m,A=new _;if(!S){const o=new n({func:y.ALWAYS,mask:255},255,255,y.KEEP,y.KEEP,y.REPLACE),_=new i([y.ONE,y.ONE,y.ONE,y.ONE],z.transparent,[!1,!1,!1,!0],y.MIN);a(A,e,t,c,s,w,o,_,r.disabled,l,"sdf",f,d,u,p,v,b,R,!1,void 0)}{const o=S?n.disabled:new n({func:y.EQUAL,mask:255},255,255,y.KEEP,y.DECR,y.DECR),_=S?e.colorModeForRenderPass():new i([y.ONE_MINUS_DST_ALPHA,y.DST_ALPHA,y.ONE,y.ONE],z.transparent,[!0,!0,!0,!0]);a(A,e,t,c,s,w,o,_,r.disabled,l,"color",f,d,u,p,v,b,R,!1,void 0)}}const ge=L([{name:"a_index",type:"Int16",components:1}]);class xe{constructor(e,t,o,i){const a={width:o[0],height:o[1],data:null},n=e.gl;this.targetColorTexture=new B(e,a,n.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new B(e,a,n.RGBA8,{useMipmap:!1}),this.context=e,this.updateParticleTexture(t,i),this.lastInvalidatedAt=0}updateParticleTexture(e,t){if(this.particleTextureDimension===t.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const o=this.context.gl,i=t.width*t.height;this.particleTexture0=new B(this.context,t,o.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new B(this.context,t,o.RGBA8,{premultiply:!1,useMipmap:!1});const a=new N;a.reserve(i);for(let e=0;e<i;e++)a.emplaceBack(e);this.particleIndexBuffer=this.context.createVertexBuffer(a,ge.members,!0),this.particleSegment=U.simpleSegment(0,0,this.particleIndexBuffer.length,0),this.particleTextureDimension=t.width}update(e){return!(this.lastInvalidatedAt<e&&(this.lastInvalidatedAt=M.now(),1))}destroy(){this.targetColorTexture.destroy(),this.backgroundColorTexture.destroy(),this.particleIndexBuffer.destroy(),this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleSegment.destroy()}}function ye(e,t,o){if(!e)return null;const i=t.getTextureDescriptor(e,o,!0);if(!i)return null;let{texture:a,mix:n,offset:r,tileSize:c,buffer:s,format:l}=i;if(!a||!l)return null;let _=!1;return"uint32"===l&&(_=!0,n[3]=0,n=h(Q,n,[0,o.paint.get("raster-particle-max-speed")]),r=m(Q,r,[0,o.paint.get("raster-particle-max-speed")])),{texture:a,textureOffset:[s/(c+2*s),c/(c+2*s)],tileSize:c,scalarData:_,scale:n,offset:r,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[l]]}}function we(e){const t=e._nearZ,o=e.projection.farthestPixelDistance(e),i=o-t,a=.2*e.height,n=t+a;return[t,o,(n-a-t)/i,(n-t)/i]}const be="#ifdef RASTER_ARRAY\nuniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec2 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=u_data_offset+vec2(dot(t.rg,u_data_scale),dot(t.ba,u_data_scale));velocity.y=-velocity.y;velocity/=max(u_max_speed,length(velocity));return velocity;}\n#endif\nuniform highp float u_particle_pos_scale;uniform highp vec2 u_particle_pos_offset;highp vec4 pack_pos_to_rgba(highp vec2 p) {highp vec2 v=(p+u_particle_pos_offset)/u_particle_pos_scale;highp vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}highp vec2 unpack_pos_from_rgba(highp vec4 v) {v=floor(v*255.0+0.5)/255.0;highp vec2 p=vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));return u_particle_pos_scale*p-u_particle_pos_offset;}";S["_prelude_raster_particle.glsl"]||(S["_prelude_raster_particle.glsl"]=be);const Te={building:T('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nconst float window_depth=0.5;const float ao_radius=0.2;in vec4 v_color;in highp vec3 v_normal;in highp vec3 v_pos;\n#ifdef RENDER_FRONT_CUTOFF\nin float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nin vec4 v_ground_roof;\n#endif\n#endif\n#ifdef BUILDING_FAUX_FACADE\nin lowp float v_faux_facade;in highp float v_faux_facade_ed;in highp vec2 v_faux_facade_window;in highp vec2 v_faux_facade_floor;in highp vec2 v_faux_facade_range;in highp float v_aspect;in highp vec3 v_tbn_0;in highp vec3 v_tbn_1;in highp vec3 v_tbn_2;in highp vec4 v_faux_color_emissive;uniform float u_faux_facade_ao_intensity;\n#endif\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\n#ifdef FLOOD_LIGHT\nin highp float v_flood_radius;in float v_has_flood_light;\n#endif\nuniform lowp float u_opacity;uniform vec3 u_camera_pos;uniform highp float u_tile_to_meter;uniform float u_facade_emissive_chance;uniform vec3 u_flood_light_color;uniform float u_flood_light_intensity;vec3 linearTosRGB(in vec3 color) {return pow(color,vec3(1./2.2));}\n#ifdef BUILDING_FAUX_FACADE\nhighp float hash12(in highp vec2 p) {highp vec3 p3 =fract(vec3(p.xyx)*0.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}float min3(in vec3 v) {return min(min(v.x,v.y),v.z);}highp vec2 get_uv_mask_id(in highp vec2 q,out highp float mask,out highp vec2 id) {highp vec2 p=q;mask=step(v_faux_facade_range.x,p.y)*step(p.y,v_faux_facade_range.y);p.y=p.y-v_faux_facade_range.x;highp vec2 uv=modf(p/v_faux_facade_floor,id);highp vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;highp vec4 edge=d/v_faux_facade_floor.xyxy;highp vec2 m=step(edge.xy,uv)*step(uv,edge.zw);mask*=m.x*m.y;uv-=vec2(0.5);uv*=vec2(0.5)/(vec2(0.5)-edge.xy);uv+=vec2(0.5);return uv;}highp float ray_unit_box(in highp vec3 ray_o,in highp vec3 ray_d,in highp vec3 bmin,in highp vec3 bmax) {highp vec3 planes=mix(bmin,bmax,step(0.0,ray_d));highp vec3 t=(planes-ray_o)/ray_d;return min3(t);}float get_emissive(in vec2 id) {if (u_facade_emissive_chance > 0.0) {return (step(hash12(id),u_facade_emissive_chance)+0.05)*v_faux_color_emissive.a;}return 0.0;}vec3 get_shade_info(in highp vec3 v,in highp vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;highp vec3 abs_v=abs(v_normalized);bool x_major=abs_v.x >=abs_v.y && abs_v.x >=abs_v.z;bool y_major=abs_v.y >=abs_v.x && abs_v.y >=abs_v.z;bool z_major=abs_v.z >=abs_v.x && abs_v.z >=abs_v.y;\n#if 0\nif (x_major) {out_color=v.x > 0.0 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,1.0);} else if (y_major) {out_color=v.y > 0.0 ? vec3(0.0,1.0,0.0) : vec3(1.0,0.0,1.0);} else if (z_major) {out_color=v.z > 0.0 ? vec3(0.0,0.0,1.0) : vec3(1.0,1.0,0.0);}out_emissive=1.0;\n#else\nif (x_major) {out_normal=-sign(v.x)*tbn[0];} else if (y_major) {out_normal=vec3(0.0,0.0,-sign(v.y));} else if (z_major) {out_color=v_faux_color_emissive.rgb;out_emissive=v.z <=0.0 ? get_emissive(id) : out_emissive;}float ao=1.0;if (u_faux_facade_ao_intensity > 0.0) {vec4 ao_range=v_faux_facade_window.xxyy*0.5-vec4(0,ao_radius,0,ao_radius);vec2 ao_range_z=vec2(window_depth*0.5)-vec2(0.0,ao_radius);if (x_major || y_major) {ao*=smoothstep(-ao_range_z.x,-ao_range_z.y,v.z);} else if (z_major) {ao*=smoothstep(-ao_range.x,-ao_range.y,v.x)*(1.0-smoothstep(ao_range.y,ao_range.x,v.x));ao*=smoothstep(-ao_range.z,-ao_range.w,v.y)*(1.0-smoothstep(ao_range.w,ao_range.z,v.y));}ao=mix(1.0,min(1.0,ao+0.25),u_faux_facade_ao_intensity);}out_color*=ao;\n#endif\nreturn out_color;}\n#endif\nvec3 apply_lighting_linear(in vec3 color,in vec3 normal,in float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return color*(ambient_contrib+directional_contrib);}void main() {vec3 normal=normalize(v_normal);vec3 base_color=v_color.rgb;float emissive=v_color.a;\n#ifdef BUILDING_FAUX_FACADE\nif (v_faux_facade > 0.0) {highp mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);highp vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;highp vec3 view_tangent=transpose(tbn)*v;highp vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);highp vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;highp vec3 bmin=vec3(0.0,0.0,-window_depth);highp vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);highp vec3 ray_o=vec3(uv,0.0);highp vec3 ray_d=normalize(view_tangent);highp float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);highp vec3 hit=ray_o+t_min*ray_d;highp vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;highp vec3 normalized=hit/r;vec3 out_normal=normal;float out_emissive=emissive;vec3 room_color=get_shade_info(hit,normalized,base_color,id,tbn,out_normal,out_emissive);base_color=mix(base_color,room_color,mask);normal=mix(normal,out_normal,mask);emissive=mix(emissive,out_emissive,mask);}\n#endif\nvec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0;\n#ifdef RENDER_SHADOWS\n#ifdef RENDER_CUTOFF\nshadowed_lighting_factor=shadowed_light_factor_normal_opacity(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\n#else\nshadowed_lighting_factor=max(0.0,dot(xy_flipped_normal,u_lighting_directional_dir));\n#endif\ncolor.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb);\n#ifdef FLOOD_LIGHT\nfloat flood_radiance=(1.0-min(v_pos.z/v_flood_radius,1.0))*u_flood_light_intensity*v_has_flood_light;color.rgb=mix(color.rgb,u_flood_light_color,flood_radiance);\n#endif\ncolor.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z));\n#endif\ncolor*=u_opacity;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\n{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}\n#else\ncolor=applyCutout(color,v_pos.z);\n#endif\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nif (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x);\n#endif\nglFragColor=color;\n#ifdef DEBUG_SHOW_NORMALS\ncolor.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color;\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;in ivec4 a_normal_3;in ivec4 a_centroid_3;\n#ifdef FLOOD_LIGHT\nin int a_flood_light_wall_radius_1i16;\n#endif\n#ifdef BUILDING_FAUX_FACADE\nin uvec4 a_faux_facade_data;in uvec2 a_faux_facade_vertical_range;\n#endif\nuniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;\n#ifdef RENDER_FRONT_CUTOFF\nuniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nout vec4 v_ground_roof;\n#endif\n#endif\nout vec4 v_color;out vec3 v_normal;out highp vec3 v_pos;\n#ifdef BUILDING_FAUX_FACADE\nout lowp float v_faux_facade;out highp float v_faux_facade_ed;out highp vec2 v_faux_facade_window;out highp vec2 v_faux_facade_floor;out highp vec2 v_faux_facade_range;out highp float v_aspect;out highp vec3 v_tbn_0;out highp vec3 v_tbn_1;out highp vec3 v_tbn_2;out highp vec4 v_faux_color_emissive;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;\n#endif\n#ifdef FLOOD_LIGHT\nout highp float v_flood_radius;out float v_has_flood_light;\n#endif\nconst float MAX_UINT_16=65535.0;const float MAX_INT_16=32767.0;const float MAX_UINT_8=255.0;const float TWO_POW_8=256.0;const float FLOOD_LIGHT_MAX_RADIUS_METER=2048.0;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\n#ifdef BUILDING_FAUX_FACADE\nmat3 get_tbn(in vec3 normal) {const vec3 bitangent=vec3(0.0,0.0,1.0);vec3 tangent=normalize(vec3(normal.y,-normal.x,0.0));return mat3(tangent,bitangent,normal);}\n#endif\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 faux_facade_color_emissive\nvoid main() {\n#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive\n#pragma mapbox: initialize-attribute-custom highp uvec2 faux_facade_color_emissive\n#ifdef FLOOD_LIGHT\nv_flood_radius=(float(a_flood_light_wall_radius_1i16)/MAX_INT_16*FLOOD_LIGHT_MAX_RADIUS_METER);v_has_flood_light=step(0.0,v_flood_radius);\n#endif\nvec4 color_emissive=decode_color(vec2(part_color_emissive));v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=vec3(a_normal_3)/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;float depth_offset=0.0;vec2 centroid_xy=vec2(a_centroid_3.xy >> 2);vec2 spanBits=vec2(a_centroid_3.xy & 3);\n#ifdef BUILDING_FAUX_FACADE\nvec4 faux_facade_data=vec4(a_faux_facade_data);v_faux_facade=faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(faux_facade_data.y/TWO_POW_8);float window_y_perc=faux_facade_data.y-TWO_POW_8*window_x_perc;vec2 window_perc=vec2(window_x_perc,window_y_perc)/MAX_UINT_8;v_faux_facade_floor=(faux_facade_data.zw/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_faux_facade_window=window_perc*v_faux_facade_floor;v_faux_facade_range=(vec2(a_faux_facade_vertical_range)/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_aspect=v_faux_facade_window.x/v_faux_facade_window.y;mat3 tbn=get_tbn(normalize(v_normal));v_tbn_0=tbn[0];v_tbn_1=tbn[1];v_tbn_2=tbn[2];v_faux_color_emissive=decode_color(vec2(faux_facade_color_emissive));v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);depth_offset=min(1000.0,float(a_centroid_3.z))*0.0000002;}\n#endif\nv_pos=a_pos_3f;\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nfloat halfSpanX=spanBits.x*10.0/u_tile_to_meter;float halfSpanY=spanBits.y*10.0/u_tile_to_meter;vec2 screenUpInTile=vec2(u_matrix[0][1],u_matrix[1][1]);vec2 spanOffset=vec2(halfSpanX,halfSpanY)*sign(screenUpInTile);vec2 cutoff_highestCorner=centroid_xy+spanOffset;vec2 cutoff_lowestCorner=centroid_xy-spanOffset;\n#endif\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec4 ground=u_matrix*vec4(centroid_xy,0.0,1.0);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shadow_pos=v_pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1.0);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(v_pos);\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nv_front_cutoff_opacity=1.0;{hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;hidden=max(hidden,float(ndc_y < threshold-range_ndc));float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);}\n#endif\ngl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nvec4 ic_ground=u_matrix*vec4(v_pos.xy,0.0,1.0);vec4 ic_roof=u_matrix*vec4(v_pos.xy,v_pos.z,1.0);v_ground_roof=vec4(ic_ground.xy/ic_ground.w,ic_roof.xy/ic_roof.w);\n#endif\n#endif\n}'),buildingBloom:T("in vec4 v_color_emissive;\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\nfloat saturate(float val) {return clamp(val,0.0,1.0);}void main() {float emission=v_color_emissive.a;float opacity=1.0;\n#ifdef HAS_ATTRIBUTE_a_bloom_attenuation\nfloat distance=length(vec2(1.3*max(0.0,abs(bloom_attenuation.x)-bloom_attenuation.z),bloom_attenuation.y));distance+= mix(0.5,0.0,clamp(emission-1.0,0.0,1.0));opacity*=saturate(1.0-distance*distance);\n#endif\n#ifdef RENDER_CUTOFF\nopacity*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}","in vec3 a_pos_3f;\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\nout vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\n#ifdef HAS_ATTRIBUTE_a_part_color_emissive\nvec4 color_emissive=decode_color(vec2(part_color_emissive));float part_emissive=color_emissive.a*5.0;v_color_emissive=vec4(sRGBToLinear(color_emissive.rgb),part_emissive);\n#else\nv_color_emissive=vec4(1.0);\n#endif\ngl_Position=u_matrix*vec4(a_pos_3f,1.0);\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}"),buildingDepth:T("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),rasterParticle:T('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 out_color=color.rgb;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\nin ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 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 mercatorX=mercatorXfromLng(latLng[1]);float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvX=mercatorX*tiles-idx;float uvY=mercatorY*tiles-idy;uv=vec2(uvX,uvY);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;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) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,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)*w,w);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nuv=vec2(a_texture_pos)/8192.0;gl_Position=u_matrix*vec4(vec2(a_pos)*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'),rasterParticleDraw:T("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",'#include "_prelude_raster_particle.glsl"\nin int a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2(\nmod(float(a_index),u_particle_texture_side_len),float(a_index)/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-1.0,0,1);v_particle_speed=length(velocity);}gl_PointSize=1.0;}'),rasterParticleTexture:T("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in ivec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*vec2(a_pos)+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:T('#include "_prelude_raster_particle.glsl"\nuniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;vec2 linearstep(vec2 edge0,vec2 edge1,vec2 x) {return clamp((x-edge0)/(edge1-edge0),vec2(0),vec2(1));}const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp vec2 persist_rate=pow(\nlinearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4)\n);highp vec2 per_frame_persist=pow(persist_rate,abs(dp)/u_particle_pos_offset);highp float drop_rate=1.0-per_frame_persist.x*per_frame_persist.y;drop_rate=any(greaterThanEqual(abs(pos-0.5),vec2(0.5+u_particle_pos_offset))) ? 1.0 : drop_rate;highp float drop=step(1.0-drop_rate-u_reset_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}',"in ivec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*vec2(a_pos+ivec2(1));gl_Position=vec4(a_pos,0.0,1.0);}"),snowParticle:T("in highp vec2 uv;in highp float alphaMultiplier;uniform vec4 u_particleColor;uniform vec2 u_simpleShapeParameters;void main() {float t=clamp((length(uv)-u_simpleShapeParameters.x)/(1.0-u_simpleShapeParameters.x),0.0,1.0);float alpha=1.0-pow(t,pow(10.0,u_simpleShapeParameters.y));alpha*=alphaMultiplier;alpha*=u_particleColor.a;vec3 color=u_particleColor.rgb*alpha;glFragColor=vec4(color,alpha) ;HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_snowParticleData;in highp vec4 a_snowParticleDataHorizontalOscillation;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform vec2 u_screenSize;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; \nuniform float u_horizontalOscillationRate; \nuniform float u_billboardSize;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;out highp vec2 uv;out highp float alphaMultiplier;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos.xyz*=halfBoxSize;pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_snowParticleData.z;float coneAngleHeadingRad=a_snowParticleData.w*radians(360.0);vec3 localZ=normalize(u_direction);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 direction;direction.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.z=cos(coneAnglePichRad);direction=normalize(direction);vec3 simPosLocal=vec3(0,0,0);float velocityScale=(1.0+3.0*a_snowParticleData.y)*u_velocity;simPosLocal+=direction*velocityScale*u_time;float horizontalOscillationRadius=u_horizontalOscillationRadius*a_snowParticleDataHorizontalOscillation.x;float horizontalOscillationAngle=u_horizontalOscillationRate*u_time*(-1.0+2.0*a_snowParticleDataHorizontalOscillation.y);simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);float clipZ=-u_cam_pos.z+pos.z;vec4 posView=u_modelview*vec4(pos,1.0);float size=u_billboardSize;alphaMultiplier=1.0;vec4 posScreen=u_projection*posView;posScreen/=posScreen.w;posScreen.xy=vec2(0.5)+posScreen.xy*0.5;posScreen.xy*=u_screenSize;vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=u_screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-posScreen.xy)/(0.5*u_screenSize));screenDist+=a_snowParticleData.x*u_thinningParticleOffset;float scaleFactorMode=0.0;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);if (a_snowParticleData.x < u_thinningAffectedRatio) {scaleFactorMode=1.0-thinningFadeRatio;alphaMultiplier=thinningFadeRatio;}}vec4 posScreen1=u_projection*vec4(posView.x-size,posView.yzw);posScreen1/=posScreen1.w;vec4 posScreen2=u_projection*vec4(posView.x+size,posView.yzw);posScreen2/=posScreen2.w;posScreen1.xy=vec2(0.5)+posScreen1.xy*0.5;posScreen1.xy*=u_screenSize;posScreen2.xy=vec2(0.5)+posScreen2.xy*0.5;posScreen2.xy*=u_screenSize;float screenLength=length(posScreen1.xy-posScreen2.xy);float screenEpsilon=3.0;float scaleFactor=1.0;if (screenLength < screenEpsilon) {scaleFactor=screenEpsilon/max(screenLength,0.01);scaleFactor=mix(scaleFactor,1.0,scaleFactorMode);}float screenEpsilon2=15.0;if (screenLength > screenEpsilon2) {scaleFactor=screenEpsilon2/max(screenLength,0.01);}size*=scaleFactor;vec2 right=size*vec2(1,0);vec2 up=size*vec2(0,1);posView.xy+=right*a_uv.x;posView.xy+=up*a_uv.y;uv=a_uv;gl_Position=u_projection*posView;}"),rainParticle:T("in highp vec2 uv;in highp float particleRandomValue;uniform sampler2D u_texScreen;uniform float u_distortionStrength;uniform vec4 u_color;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;uniform float u_shapeDirectionalPower;uniform float u_mode;void main() {vec2 st=uv*0.5+vec2(0.5);vec2 uvm=uv;uvm.y=-1.0+2.0*pow(st.y,u_shapeDirectionalPower);float shape=clamp(1.0-length(uvm),0.0,1.0);float alpha=abs(shape)*u_color.a;vec2 screenSize=vec2(textureSize(u_texScreen,0));vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-gl_FragCoord.xy)/(0.5*screenSize));screenDist+=(0.5+0.5*particleRandomValue)*u_thinningParticleOffset;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;float thinningAlpha=1.0;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);thinningAlpha*=thinningFadeRatio;}vec2 offsetXY=normalize(uvm)*abs(shape);vec2 stScreen=(gl_FragCoord.xy+offsetXY*u_distortionStrength*thinningAlpha)/screenSize;vec3 colorScreen=texture(u_texScreen,stScreen).rgb;alpha*=thinningAlpha;glFragColor=mix(vec4(colorScreen,1.0),vec4(u_color.rgb*alpha,alpha),u_mode);HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_rainParticleData;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity; \nuniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize; \npos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_rainParticleData.z;float coneAngleHeadingRad=a_rainParticleData.w*radians(360.0);vec3 localZ=normalize(u_rainDirection);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 directionLocal;directionLocal.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.z=cos(coneAnglePichRad);directionLocal=normalize(directionLocal);vec3 directionWorld=localX*directionLocal.x+localY*directionLocal.y+localZ*directionLocal.z;float velocityScale=(1.0+3.0*a_rainParticleData.y)*u_velocity;vec3 simPosLocal=vec3(0,0,0);simPosLocal+=directionLocal*velocityScale*u_time;vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);vec4 posView=u_modelview*vec4(pos,1.0);vec3 directionView=normalize((u_modelview*vec4(directionWorld,0.0)).xyz);vec3 side=cross(directionView,normalize(posView.xyz));posView.xyz+=side*a_uv.x*u_rainDropletSize.x;posView.xyz+=directionView*a_uv.y*u_rainDropletSize.y;uv=a_uv;particleRandomValue=a_rainParticleData.x;gl_Position=u_projection*posView;}"),vignette:T("uniform vec3 u_vignetteShape;uniform vec4 u_vignetteColor;in vec2 st;void main() {float screenDist=length(st);float alpha=clamp((screenDist-u_vignetteShape.x)/u_vignetteShape.y,0.0,1.0);alpha=pow(alpha,u_vignetteShape.z)*u_vignetteColor.a;vec3 color=u_vignetteColor.rgb;glFragColor=vec4(color*alpha,alpha) ;}","in vec2 a_pos_2f;out vec2 st;void main() {st=a_pos_2f;gl_Position=vec4(a_pos_2f,0,1);}")};T(be,"");const Se=L([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]),Re=L([{type:"Float32",name:"a_pos_2f",components:2}]);class Ae{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(e,t){const a=e.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const t=new te,o=new oe;t.emplaceBack(-1,-1),t.emplaceBack(1,-1),t.emplaceBack(1,1),t.emplaceBack(-1,1),o.emplaceBack(0,1,2),o.emplaceBack(0,2,3),this.vignetteVx=e.context.createVertexBuffer(t,Re.members),this.vignetteIdx=e.context.createIndexBuffer(o)}const c=U.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){e.uploadCommonUniforms(e.context,a);const s=R({vignetteShape:[t.start,t.range,Math.pow(10,t.fadePower)],vignetteColor:[t.color.r,t.color.g,t.color.b,t.color.a*t.strength]});a.draw(e,e.context.gl.TRIANGLES,o.disabled,n.disabled,i.alphaBlended,r.disabled,s,"vignette",this.vignetteVx,this.vignetteIdx,c)}}}class Ee{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(e,t){const o=e.getFreeCameraOptions().position,i=o.toAltitude(),a=o.toLngLat(),n=ne(a.lng),r=ne(a.lat),c=e.pixelsPerMeter/t,s=n*de,l=de*Math.log(Math.tan(Math.PI/4+r/2));if(void 0===this._offsetXPrev)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else{const e=-this._offsetYPrev+l,t=-this._elevationPrev+i;this._accumulatedOffsetX+=(-this._offsetXPrev+s)*c,this._accumulatedOffsetY+=e*c,this._accumulatedElevation+=t*c,this._offsetXPrev=s,this._offsetYPrev=l,this._elevationPrev=i}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function Pe(e,t){return[-(e[0]-Math.floor(e[0]/t)*t),-(e[1]-Math.floor(e[1]/t)*t),-(e[2]-Math.floor(e[2]/t)*t)]}function Ce(e){const t=fe(1323123451230),o=[];for(let i=0;i<e;++i){const e=2*t()-1,i=2*t()-1,a=2*t()-1;o.push(_e(e,i,a))}return o}function Fe(e,t,o,i,a){const n=ue((a-o)/(i-o),0,1);return(1-n)*e+n*t}class Oe{constructor(e){this._movement=new Ee,this._accumulatedTimeFromStart=0,this._prevTime=Date.now()/1e3,this._vignette=new Ae,this._ppmScaleFactor=e}destroy(){this.particlesVx&&this.particlesVx.destroy(),this.particlesIdx&&this.particlesIdx.destroy(),this._vignette&&this._vignette.destroy()}updateOnRender(e,t){const o=e.transform;this._movement.update(o,this._ppmScaleFactor);const i=o.starsProjMatrix,a=ie([]);ae(a,a,ne(90)-o._pitch),re(a,a,-o.angle);const n=ce(new Float32Array(16),a),r=se(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),c=O([],r),s=le([],c,n),l=Date.now()/1e3;return this._accumulatedTimeFromStart+=(l-this._prevTime)*t,this._prevTime=l,{projectionMatrix:i,modelviewMatrix:s}}}const ze=L([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_snowParticleData",components:4},{type:"Float32",name:"a_snowParticleDataHorizontalOscillation",components:2}]),De={loaded:!0,drawBuilding:function(e,t,a,n){e.currentLayer<e.firstLightBeamLayer&&(e.firstLightBeamLayer=e.currentLayer);const r=a.paint.get("building-ambient-occlusion-ground-intensity"),c=a.paint.get("building-ambient-occlusion-ground-radius"),s=a.paint.get("building-ambient-occlusion-ground-attenuation"),l=a.paint.get("building-opacity");if(l<=0)return;let _=r>0&&c>0,f=!0;const d=a.paint.get("building-vertical-scale");if(d<=0)return;e.shadowRenderer||(f=!1);const u=e.conflationActive&&e.style.isLayerClipped(a,t.getSource()),p=e.style.order.indexOf(a.fqid);if(function(e,t,o,i,a,n){for(const r of n){const n=t.getTile(r).getBucket(o);n&&(a&&n.updateReplacement(r,e.replacementSource,i),n.uploadUpdatedIndexBuffer(e.context))}}(e,t,a,p,u,n),function(e,t,o,i){for(const a of i){const i=t.getTile(a).getBucket(o);i&&i.needsEvaluation()&&i.uploadUpdatedColorBuffer(e.context)}}(e,t,a,n),a.resetLayerRenderingStats(e),e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!0),"shadow"===e.renderPass&&e.shadowRenderer){const o=[],r=e.shadowRenderer.getShadowPassDepthMode();he({painter:e,source:t,layer:a,coords:n,defines:o,blendMode:i.disabled,depthMode:r,opacity:l,verticalScale:d,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if("translucent"===e.renderPass){let p=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];f&&(p=p.concat("RENDER_SHADOWS")),e.shadowRenderer&&e.shadowRenderer.useNormalOffset&&(p=p.concat("NORMAL_OFFSET"));const v=a.paint.get("building-facade-emissive-chance"),h=a.paint.get("building-ambient-occlusion-intensity"),m=a.paint.get("building-flood-light-intensity"),g="none"===a.paint.get("building-flood-light-color-use-theme").constantOr("default"),x=a.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(g?null:a.lut).toArray01().slice(0,3),y=a.paint.get("building-flood-light-ground-attenuation"),w=m>0,b=new o(e.context.gl.LEQUAL,o.ReadWrite,e.depthRangeFor3D);l<1&&he({painter:e,source:t,layer:a,coords:n,defines:p,blendMode:i.disabled,depthMode:b,opacity:l,verticalScale:d,facadeEmissiveChance:v,facadeAOIntensity:h,floodLightIntensity:m,floodLightColor:x,depthOnly:!0});const T=e.colorModeForRenderPass();he({painter:e,source:t,layer:a,coords:n,defines:p,blendMode:T,depthMode:b,opacity:l,verticalScale:d,facadeEmissiveChance:v,facadeAOIntensity:h,floodLightIntensity:m,floodLightColor:x}),a.paint.get("building-front-cutoff"),_&&me(e,t,a,n,!0,l,r,c,m,x,s,u),w&&me(e,t,a,n,!1,l,r,c,m,x,y,u)}else if("light-beam"===e.renderPass){const r=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],c=new o(e.context.gl.LEQUAL,o.ReadOnly,e.depthRangeFor3D);he({painter:e,source:t,layer:a,coords:n,defines:r,blendMode:i.alphaBlended,depthMode:c,opacity:l,verticalScale:d,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!1),e.resetStencilClippingMasks()},drawRasterParticle:function(e,t,a,c,s,l){"offscreen"===e.renderPass&&function(e,t,a,c){if(!c.length)return;const s=e.context,l=s.gl,_=t.getSource();if(!(_ instanceof d))return;const f=Math.ceil(Math.sqrt(a.paint.get("raster-particle-count")));let p=a.particlePositionRGBAImage;if(!p||p.width!==f){const e=function(e){const t=e*e,o=new Uint8Array(4*t),i=1/b;for(let e=0;e<t;e++){const t=i*(J(2*e+0)+w),a=i*(J(2*e+1)+w),n=255*t%1,r=255*a%1,c=n,s=a-r/255,l=r;o[4*e+0]=255*(t-n/255),o[4*e+1]=255*c,o[4*e+2]=255*s,o[4*e+3]=255*l}return o}(f);p=a.particlePositionRGBAImage=new G({width:f,height:f},e)}let v=a.particleFramebuffer;v?v.width!==f&&(v.destroy(),v=a.particleFramebuffer=s.createFramebuffer(f,f,1,null)):v=a.particleFramebuffer=s.createFramebuffer(f,f,1,null);const h=[];for(const e of c){const o=t.getTile(e);if(!(o instanceof u))continue;const i=ye(o,_,a);if(!i)continue;const n=[o.tileSize,o.tileSize];let r=a.tileFramebuffer;r||(r=a.tileFramebuffer=s.createFramebuffer(n[0],n[1],1,null));let c=o.rasterParticleState;c||(c=o.rasterParticleState=new xe(s,e,n,p));const l=c.update(a.lastInvalidatedAt);c.particleTextureDimension!==f&&c.updateParticleTexture(e,p);const d=c.targetColorTexture;c.targetColorTexture=c.backgroundColorTexture,c.backgroundColorTexture=d;const v=c.particleTexture0;c.particleTexture0=c.particleTexture1,c.particleTexture1=v,h.push([e,i,c,l])}if(0===h.length)return;const m=M.now(),T=a.previousDrawTimestamp?.001*(m-a.previousDrawTimestamp):.0167;if(a.previousDrawTimestamp=m,a.hasColorMap()){s.activeTexture.set(l.TEXTURE0+2);let e=a.colorRampTexture;e||(e=a.colorRampTexture=new B(s,a.colorRamp,l.RGBA8)),e.bind(l.LINEAR,l.CLAMP_TO_EDGE)}s.bindFramebuffer.set(a.tileFramebuffer.framebuffer),function(e,t,a){const c=e.context,s=c.gl,l=t.tileFramebuffer;c.activeTexture.set(s.TEXTURE0);const _=1.05*(u=t.paint.get("raster-particle-fade-opacity-factor"))/(u+.05),f=g(0,_),d=e.getOrCreateProgram("rasterParticleTexture",{defines:[],overrideFog:!1});var u;for(const _ of a){const[,,a,u]=_;l.colorAttachment0.set(a.targetColorTexture.texture),c.viewport.set([0,0,l.width,l.height]),c.clear({color:z.transparent}),u&&(a.backgroundColorTexture.bind(s.NEAREST,s.CLAMP_TO_EDGE),d.draw(e,s.TRIANGLES,o.disabled,n.disabled,i.alphaBlended,r.disabled,f,t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments))}}(e,a,h),function(e,t,a,c){const s=e.context,l=s.gl,_=a.tileFramebuffer,f="globe"===e.transform.projection.name,d=a.paint.get("raster-particle-max-speed");for(const u of c){const[c,p,v]=u;s.activeTexture.set(l.TEXTURE0+0),p.texture.bind(l.LINEAR,l.CLAMP_TO_EDGE),_.colorAttachment0.set(v.targetColorTexture.texture);const h=e.getOrCreateProgram("rasterParticleDraw",{defines:p.defines,overrideFog:!1});s.activeTexture.set(l.TEXTURE0+1);const m=p.scalarData?[]:[0,1,2,3].map(e=>K[e](c));m.push(c);const g=c.canonical.x,y=c.canonical.y;for(const s of m){const _=t.getTile(f?s.wrapped():s);if(!_)continue;const u=_.rasterParticleState;if(!u)continue;const v=s.canonical.x+(1<<s.canonical.z)*(s.wrap-c.wrap),m=s.canonical.y;u.particleTexture0.bind(l.NEAREST,l.CLAMP_TO_EDGE);const w=x(1,u.particleTexture0.size[0],[v-g,m-y],0,p.texture.size,2,d,p.textureOffset,p.scale,p.offset);h.draw(e,l.POINTS,o.disabled,n.disabled,i.alphaBlended,r.disabled,w,a.id,u.particleIndexBuffer,void 0,u.particleSegment)}}}(e,t,a,h),s.bindFramebuffer.set(a.particleFramebuffer.framebuffer),function(e,t,a,c){const s=e.context,l=s.gl,_=t.paint.get("raster-particle-max-speed"),f=c*t.paint.get("raster-particle-speed-factor")*.15,d=function(e){return Math.pow(e,6)}(.01+1*t.paint.get("raster-particle-reset-rate-factor")),u=t.particleFramebuffer;s.viewport.set([0,0,u.width,u.height]);for(const c of a){const[,a,p]=c;s.activeTexture.set(l.TEXTURE0+0),a.texture.bind(l.LINEAR,l.CLAMP_TO_EDGE),s.activeTexture.set(l.TEXTURE0+1);const v=p.particleTexture0;v.bind(l.NEAREST,l.CLAMP_TO_EDGE);const h=y(1,v.size[0],0,a.texture.size,_,f,d,a.textureOffset,a.scale,a.offset);u.colorAttachment0.set(p.particleTexture1.texture),s.clear({color:z.transparent}),e.getOrCreateProgram("rasterParticleUpdate",{defines:a.defines}).draw(e,l.TRIANGLES,o.disabled,n.disabled,i.unblended,r.disabled,h,t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments)}}(e,a,h,T)}(e,t,a,c),"translucent"===e.renderPass&&(function(e,t,a,n){const c=e.context,s=c.gl,l=t.getSource().tileSize,_=5*(1-V(X,X+1,e.transform.zoom))*l+a.paint.get("raster-particle-elevation"),f=!e.options.moving,d="globe"===e.transform.projection.name;if(!n.length)return;const[u,h]=e.stencilConfigForOverlap(n),m=[];d&&m.push("PROJECTION_GLOBE_VIEW");const g=e.stencilModeFor3D();for(const n of h){const l=n.toUnwrapped(),h=t.getTile(n);if(!h.rasterParticleState)continue;const x=h.rasterParticleState,y=100;h.registerFadeDuration(y);const w=t.findLoadedParent(n,0),b=p(h,w,t,e.transform,y);let T,S;e.terrain&&e.terrain.prepareDrawTile(),c.activeTexture.set(s.TEXTURE0),x.targetColorTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),c.activeTexture.set(s.TEXTURE1),w&&w.rasterParticleState?(w.rasterParticleState.targetColorTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),T=Math.pow(2,w.tileID.overscaledZ-h.tileID.overscaledZ),S=[h.tileID.canonical.x*T%1,h.tileID.canonical.y*T%1]):x.targetColorTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const R=d?Float32Array.from(e.transform.expandedFarZProjMatrix):e.transform.calculateProjMatrix(l,f),A=e.transform,E=we(A),P=k(n.canonical),C=H(P.getCenter().lat);let F,O,z,D,I;d?(F=Float32Array.from(Y(W(n.canonical))),O=Float32Array.from(A.globeMatrix),z=Float32Array.from(j(A)),D=[$(A.center.lng),ee(A.center.lat)],I=Float32Array.from(Z(n.canonical,P,C,A.worldSize/A._pixelsPerMercatorPixel))):(F=new Float32Array(16),O=new Float32Array(9),z=new Float32Array(16),D=[0,0],I=new Float32Array(9));const L=v(R,F,O,z,I,S||[0,0],q(e.transform.zoom),D,E,T||1,b,_),B=e.isTileAffectedByFog(n),N=e.getOrCreateProgram("rasterParticle",{defines:m,overrideFog:B});if(e.uploadCommonUniforms(c,N,l),d){const t=new o(s.LEQUAL,o.ReadOnly,e.depthRangeFor3D),n=0,c=e.globeSharedBuffers;if(c){const[o,l,_]=c.getGridBuffers(C,0!==n);N.draw(e,s.TRIANGLES,t,g,i.alphaBlended,e.renderElevatedRasterBackface?r.frontCCW:r.backCCW,L,a.id,o,l,_)}}else{const t=e.depthModeForSublayer(0,o.ReadOnly),c=u[n.overscaledZ],{tileBoundsBuffer:l,tileBoundsIndexBuffer:_,tileBoundsSegments:f}=e.getTileBoundsBuffers(h);N.draw(e,s.TRIANGLES,t,c,i.alphaBlended,r.disabled,L,a.id,l,_,f)}}e.resetStencilClippingMasks()}(e,t,a,c),e.style.map.triggerRepaint())},prepareRasterParticle:function(e,t,o){const i=t.getSource();if(!(i instanceof d&&i.loaded()))return;const a=e.sourceLayer||i.rasterLayerIds&&i.rasterLayerIds[0];if(!a)return;const n=e.paint.get("raster-particle-array-band")||i.getInitialBand(a);if(null==n)return;const r=t.getIds().map(e=>t.getTileByID(e));for(const t of r)t.updateNeeded(e.id,n)&&i.prepareTile(t,a,e.id,n)},Rain:class extends Oe{constructor(){super(4.25),this._params={intensity:.5,timeFactor:1,velocityConeAperture:0,velocity:300,boxSize:2500,dropletSizeX:1,dropletSizeYScale:10,distortionStrength:70,screenThinning:{intensity:.57,start:.46,range:1.17,fadePower:.17,affectedRatio:1,particleOffset:-.2},color:{r:.66,g:.68,b:.74,a:.7},direction:{x:-50,y:-35},shapeDirPower:2,shapeNormalPower:1},this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3,this._devtoolsFolder=null,this._painter=null}destroy(){super.destroy()}update(e){const t=e.context;if(!this.particlesVx){const e=Ce(this.particlesCount),o=new pe,i=new oe;let a=0;const n=fe(1323123451230);for(let t=0;t<e.length;++t){const r=e[t],c=[2*n()-1,n(),n(),n()];o.emplaceBack(r[0],r[1],r[2],-1,-1,...c),o.emplaceBack(r[0],r[1],r[2],1,-1,...c),o.emplaceBack(r[0],r[1],r[2],1,1,...c),o.emplaceBack(r[0],r[1],r[2],-1,1,...c),i.emplaceBack(a+0,a+1,a+2),i.emplaceBack(a+0,a+2,a+3),a+=4}this.particlesVx=t.createVertexBuffer(o,Se.members),this.particlesIdx=t.createIndexBuffer(i)}}getDrawParams(e){if(!e.style.rain)return null;const t=e.style.rain.state,o=structuredClone(this._params);o.intensity=t.density,o.timeFactor=t.intensity,o.color=structuredClone(t.color),o.screenThinning.intensity=t.centerThinning,o.dropletSizeX=t.dropletSize[0],o.dropletSizeYScale=t.dropletSize[1]/t.dropletSize[0],o.distortionStrength=100*t.distortionStrength;const i=structuredClone(this._vignetteParams);return i.strength=1,i.color=structuredClone(t.vignetteColor),{params:o,vignetteParams:i,revealParams:{revealStart:0,revealRange:.01},direction:structuredClone(t.direction)}}draw(e){const t=this.getDrawParams(e);if(!t)return;const{params:a,revealParams:c,direction:s,vignetteParams:l}=t,_=e.transform.zoom;if(c.revealStart>_)return;const f=Fe(0,1,c.r