@gis_victory/gismap 2.0.46 → 2.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +12 -1
- package/dist/index.umd.js +1 -1
- package/package.json +2 -2
- package/dist/assets/data/mask.json +0 -14325
- package/dist/assets/icons/bg.png +0 -0
- package/dist/assets/icons/layer_default.png +0 -0
- package/dist/assets/icons/layer_group.png +0 -0
- package/dist/assets/icons/layer_query.png +0 -0
- package/dist/assets/icons//347/251/272/347/275/256/345/216/202/346/210/277.png +0 -0
- package/dist/assets/icons//351/227/262/347/275/256/345/234/260/345/235/227.png +0 -0
- package/dist/assets/template/data.json +0 -2671
- package/dist/assets/template/search_data.json +0 -14
- package/dist/hd.shared-CQ8V3LpU.js +0 -1
- package/dist/hd.worker-DtSZ3AI6.js +0 -1
- package/dist/hd.worker-DveeQM1R.js +0 -1
- package/dist/index-nTegTRc-.js +0 -13
- package/dist/vite.svg +0 -1
- package/dist/worker-DWfYi5c4.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,k as t,w as o,o as i,r as a,s as n,v as r,O as c,E as l,d as s,x as _,z as u,C as f,D as d,U as p,F as v,I as h,P as m,Q as g,R as x,W as y,a0 as w,a1 as b,a2 as T,a3 as S,a4 as R,a5 as A,a6 as P,a7 as C,a8 as E,a9 as z,aa as F,ab as O,ac as D,ad as I,ae as L,af as B,ag as N,ah as U,ai as M,aj as G,ak as V,al as k,am as X,u as H,an as j,ao as Y,ap as W,aq as Z,H as q,ar as Q,as as K,at as J,au as $,av as ee,aw as te,K as oe,ax as ie,N as ae,l as ne,ay as re,az as ce,aA as le}from"./index-nTegTRc-.js";const se=(e,t,o,i,a,n,r,c,l,s=[0,0,1])=>({u_matrix:e,u_normal_matrix:t,u_opacity:o,u_faux_facade_ao_intensity:i,u_camera_pos:a,u_tile_to_meter:n,u_facade_emissive_chance:r,u_flood_light_color:c,u_flood_light_intensity:l,u_front_cutoff_params:s}),_e=e=>({u_matrix:e}),ue=e=>({u_matrix:e}),fe=new Float32Array(16),de=new Float32Array(16);function pe(e){const{painter:t,source:o,layer:i,coords:a}=e;let n=e.defines;const r=t.context,c="shadow"===t.renderPass,l="light-beam"===t.renderPass,s=t.shadowRenderer,_=Q(t.transform.center.lat,t.transform.zoom),f=K(t,i.paint.get("building-cutoff-fade-range"));f.shouldRenderCutoff&&(n=n.concat("RENDER_CUTOFF"));const p=i.paint.get("building-front-cutoff"),v=p[2]<1&&!t.terrain,h=J(t.transform.pitch,p,!!t.terrain);v&&(n=n.concat("RENDER_FRONT_CUTOFF"),t.maxFrontCutoffRawStart=Math.max(t.maxFrontCutoffRawStart,p[0])),e.floodLightIntensity>0&&(n=n.concat("FLOOD_LIGHT"));for(const m of a){const a=o.getTile(m),p=a.getBucket(i);if(!p)continue;s&&0===s.getMaxCascadeForTile(m.toUnwrapped())&&(n=n.concat("SHADOWS_SINGLE_CASCADE"));const v=p.programConfigurations.get(i.id);let g,x;const y=t.translatePosMatrix(m.expandedProjMatrix,a,[0,0],"map");$(fe,y,[1,1,e.verticalScale]);const w=fe;let b;if(c&&s){if(ee(a.tileID,p.maxHeight*_,t))continue;const o=s.calculateShadowPassMatrixFromTile(a.tileID.toUnwrapped());$(o,o,[1,1,e.verticalScale]),b=ue(o),g=x=t.getOrCreateProgram("buildingDepth",{config:v,defines:n,overrideFog:!1})}else if(l)g=x=t.getOrCreateProgram("buildingBloom",{config:v,defines:n,overrideFog:!1}),b=_e(w);else{const o=t.transform.calculatePosMatrix(m.toUnwrapped(),t.transform.worldSize);$(o,o,[1,1,e.verticalScale]),$(de,o,[1,-1,1/_]),te(de,de),G(de,de);const i=de,a=t.transform.getFreeCameraOptions().position,r=1<<m.canonical.z;if(b=se(w,i,e.opacity,e.facadeAOIntensity,[((a.x-m.wrap)*r-m.canonical.x)*oe,(a.y*r-m.canonical.y)*oe,a.z*r*oe],p.tileToMeter,e.facadeEmissiveChance,e.floodLightColor,e.floodLightIntensity,h),x=t.getOrCreateProgram("building",{config:v,defines:n,overrideFog:!1}),!0===e.depthOnly)g=x;else{const e=n.concat(["BUILDING_FAUX_FACADE","HAS_ATTRIBUTE_a_faux_facade_color_emissive"]);g=t.getOrCreateProgram("building",{config:v,defines:e,overrideFog:!1})}s&&(s.setupShadowsFromMatrix(o,x,!0),g!==x&&s.setupShadowsFromMatrix(o,g,!0))}const T=(o,a)=>{if(l){const n=o.entranceBloom;a.draw(t,r.gl.TRIANGLES,e.depthMode,u.disabled,e.blendMode,d.disabled,b,i.id,n.layoutVertexBuffer,n.indexBuffer,n.segmentsBucket,i.paint,t.transform.zoom,v,[n.layoutAttenuationBuffer,n.layoutColorBuffer])}else{const n=o.segmentsBucket;let l=[o.layoutNormalBuffer,o.layoutCentroidBuffer,o.layoutColorBuffer,o.layoutFloodLightDataBuffer];o.layoutFacadePaintBuffer&&(l=l.concat([o.layoutFacadeDataBuffer,o.layoutFacadeVerticalRangeBuffer,o.layoutFacadePaintBuffer])),a.draw(t,r.gl.TRIANGLES,e.depthMode,u.disabled,e.blendMode,c?d.disabled:d.backCW,b,i.id,o.layoutVertexBuffer,o.indexBuffer,n,i.paint,t.transform.zoom,v,l)}};t.uploadCommonUniforms(r,x,m.toUnwrapped(),null,f),p.buildingWithoutFacade&&T(p.buildingWithoutFacade,x),p.buildingWithFacade&&(g!==x&&t.uploadCommonUniforms(r,g,m.toUnwrapped(),null,f),T(p.buildingWithFacade,g))}}function ve(e,t,o,i,a,n,r,c,l,s,p,v,h,m){const g=e.context.gl,x=e.depthModeForSublayer(1,_.ReadOnly,g.LEQUAL,!0),w=.1*(1-(b=p))+3*b;var b;const T=e._showOverdrawInspector,S=v,R=new ce;if(!T){const _=new u({func:g.ALWAYS,mask:255},255,255,g.KEEP,g.KEEP,g.REPLACE),p=new f([g.ONE,g.ONE,g.ONE,g.ONE],y.transparent,[!1,!1,!1,!0],g.MIN);ie(R,e,t,o,i,x,_,p,d.disabled,a,"sdf",n,r,c,l,s,w,S,!1,void 0)}{const _=T?u.disabled:new u({func:g.EQUAL,mask:255},255,255,g.KEEP,g.DECR,g.DECR),p=T?e.colorModeForRenderPass():new f([g.ONE_MINUS_DST_ALPHA,g.DST_ALPHA,g.ONE,g.ONE],y.transparent,[!0,!0,!0,!0]);ie(R,e,t,o,i,x,_,p,d.disabled,a,"color",n,r,c,l,s,w,S,!1,void 0)}}const he=.05,me=(e,t,o,i,a,n,r,c,l,s,_,u)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:o,u_merc_matrix:i,u_grid_matrix:a,u_tl_parent:n,u_scale_parent:s,u_fade_t:_.mix,u_opacity:_.opacity,u_image0:0,u_image1:1,u_raster_elevation:u,u_zoom_transition:r,u_merc_center:c,u_cutoff_params:l}),ge=(e,t,o,i,a,n,r,c,l,s)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:o,u_velocity:i,u_color_ramp:n,u_velocity_res:a,u_max_speed:r,u_uv_offset:c,u_data_scale:[255*l[0],255*l[1]],u_data_offset:s,u_particle_pos_scale:1.1,u_particle_pos_offset:[he,he]}),xe=(e,t,o,i,a,n,r,c,l,s)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:o,u_velocity_res:i,u_max_speed:a,u_speed_factor:n,u_reset_rate:r,u_rand_seed:Math.random(),u_uv_offset:c,u_data_scale:[255*l[0],255*l[1]],u_data_offset:s,u_particle_pos_scale:1.1,u_particle_pos_offset:[he,he]}),ye=H([{name:"a_index",type:"Int16",components:1}]);class we{constructor(e,t,o,i){const a={width:o[0],height:o[1],data:null},n=e.gl;this.targetColorTexture=new v(e,a,n.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new v(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 v(this.context,t,o.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new v(this.context,t,o.RGBA8,{premultiply:!1,useMipmap:!1});const a=new q;a.reserve(i);for(let n=0;n<i;n++)a.emplaceBack(n);this.particleIndexBuffer=this.context.createVertexBuffer(a,ye.members,!0),this.particleSegment=s.simpleSegment(0,0,this.particleIndexBuffer.length,0),this.particleTextureDimension=t.width}update(e){return!(this.lastInvalidatedAt<e&&(this.lastInvalidatedAt=x.now(),1))}destroy(){this.targetColorTexture.destroy(),this.backgroundColorTexture.destroy(),this.particleIndexBuffer.destroy(),this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleSegment.destroy()}}function be(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:l,format:s}=i;if(!a||!s)return null;let _=!1;return"uint32"===s&&(_=!0,n[3]=0,n=Y(W,n,[0,o.paint.get("raster-particle-max-speed")]),r=Z(W,r,[0,o.paint.get("raster-particle-max-speed")])),{texture:a,textureOffset:[l/(c+2*l),c/(c+2*l)],tileSize:c,scalarData:_,scale:n,offset:r,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[s]]}}function Te(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 Se="#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;}";le["_prelude_raster_particle.glsl"]||(le["_prelude_raster_particle.glsl"]=Se);const Re={building:I('#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:I("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:I("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),rasterParticle:I('#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:I("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:I("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:I('#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:I("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:I("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:I("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);}")};I(Se,"");const Ae=H([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]),Pe=H([{type:"Float32",name:"a_pos_2f",components:2}]);class Ce{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(e,t){const o=e.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const t=new ae,o=new l;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,Pe.members),this.vignetteIdx=e.context.createIndexBuffer(o)}const i=s.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){e.uploadCommonUniforms(e.context,o);const n={u_vignetteShape:(a={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]}).vignetteShape,u_vignetteColor:a.vignetteColor};o.draw(e,e.context.gl.TRIANGLES,_.disabled,u.disabled,f.alphaBlended,d.disabled,n,"vignette",this.vignetteVx,this.vignetteIdx,i)}var a}}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=N(a.lng),r=N(a.lat),c=e.pixelsPerMeter/t,l=n*re,s=re*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+s,t=-this._elevationPrev+i;this._accumulatedOffsetX+=(-this._offsetXPrev+l)*c,this._accumulatedOffsetY+=e*c,this._accumulatedElevation+=t*c,this._offsetXPrev=l,this._offsetYPrev=s,this._elevationPrev=i}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function ze(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 Fe(e){const t=k(1323123451230),o=[];for(let i=0;i<e;++i){const e=2*t()-1,i=2*t()-1,a=2*t()-1;o.push(X(e,i,a))}return o}function Oe(e,t,o,i,a){const n=ne((a-o)/(i-o),0,1);return(1-n)*e+n*t}class De{constructor(e){this._movement=new Ee,this._accumulatedTimeFromStart=0,this._prevTime=Date.now()/1e3,this._vignette=new Ce,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=L([]);B(a,a,N(90)-o._pitch),U(a,a,-o.angle);const n=M(new Float32Array(16),a),r=new Float32Array([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1]),c=G([],r),l=V([],c,n),s=Date.now()/1e3;return this._accumulatedTimeFromStart+=(s-this._prevTime)*t,this._prevTime=s,{projectionMatrix:i,modelviewMatrix:l}}}const Ie=H([{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}]),Le={building:e=>({u_matrix:new n(e),u_normal_matrix:new n(e),u_opacity:new o(e),u_faux_facade_ao_intensity:new o(e),u_camera_pos:new t(e),u_tile_to_meter:new o(e),u_facade_emissive_chance:new o(e),u_flood_light_color:new t(e),u_flood_light_intensity:new o(e),u_front_cutoff_params:new t(e)}),buildingBloom:e=>({u_matrix:new n(e)}),buildingDepth:e=>({u_matrix:new n(e)}),rasterParticle:t=>({u_matrix:new n(t),u_normalize_matrix:new n(t),u_globe_matrix:new n(t),u_merc_matrix:new n(t),u_grid_matrix:new r(t),u_tl_parent:new i(t),u_scale_parent:new o(t),u_fade_t:new o(t),u_opacity:new o(t),u_image0:new a(t),u_image1:new a(t),u_raster_elevation:new o(t),u_zoom_transition:new o(t),u_merc_center:new i(t),u_cutoff_params:new e(t)}),rasterParticleTexture:e=>({u_texture:new a(e),u_opacity:new o(e)}),rasterParticleDraw:e=>({u_particle_texture:new a(e),u_particle_texture_side_len:new o(e),u_tile_offset:new i(e),u_velocity:new a(e),u_color_ramp:new a(e),u_velocity_res:new i(e),u_max_speed:new o(e),u_uv_offset:new i(e),u_data_scale:new i(e),u_data_offset:new o(e),u_particle_pos_scale:new o(e),u_particle_pos_offset:new i(e)}),rasterParticleUpdate:e=>({u_particle_texture:new a(e),u_particle_texture_side_len:new o(e),u_velocity:new a(e),u_velocity_res:new i(e),u_max_speed:new o(e),u_speed_factor:new o(e),u_reset_rate:new o(e),u_rand_seed:new o(e),u_uv_offset:new i(e),u_data_scale:new i(e),u_data_offset:new o(e),u_particle_pos_scale:new o(e),u_particle_pos_offset:new i(e)}),snowParticle:a=>({u_modelview:new n(a),u_projection:new n(a),u_time:new o(a),u_cam_pos:new t(a),u_velocityConeAperture:new o(a),u_velocity:new o(a),u_horizontalOscillationRadius:new o(a),u_horizontalOscillationRate:new o(a),u_boxSize:new o(a),u_billboardSize:new o(a),u_simpleShapeParameters:new i(a),u_screenSize:new i(a),u_thinningCenterPos:new i(a),u_thinningShape:new t(a),u_thinningAffectedRatio:new o(a),u_thinningParticleOffset:new o(a),u_particleColor:new e(a),u_direction:new t(a)}),rainParticle:r=>({u_modelview:new n(r),u_projection:new n(r),u_time:new o(r),u_cam_pos:new t(r),u_texScreen:new a(r),u_velocityConeAperture:new o(r),u_velocity:new o(r),u_boxSize:new o(r),u_rainDropletSize:new i(r),u_distortionStrength:new o(r),u_rainDirection:new t(r),u_color:new e(r),u_screenSize:new i(r),u_thinningCenterPos:new i(r),u_thinningShape:new t(r),u_thinningAffectedRatio:new o(r),u_thinningParticleOffset:new o(r),u_shapeDirectionalPower:new o(r),u_shapeNormalPower:new o(r),u_mode:new o(r)}),vignette:o=>({u_vignetteShape:new t(o),u_vignetteColor:new e(o)})},Be={loaded:!0,drawBuilding:function(e,t,o,i){e.currentLayer<e.firstLightBeamLayer&&(e.firstLightBeamLayer=e.currentLayer);const a=o.paint.get("building-ambient-occlusion-ground-intensity"),n=o.paint.get("building-ambient-occlusion-ground-radius"),r=o.paint.get("building-ambient-occlusion-ground-attenuation"),c=o.paint.get("building-opacity");if(c<=0)return;let l=a>0&&n>0,s=!0;const u=o.paint.get("building-vertical-scale");if(u<=0)return;e.shadowRenderer||(s=!1);const d=e.conflationActive&&e.style.isLayerClipped(o,t.getSource()),p=e.style.order.indexOf(o.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,o,p,d,i),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,o,i),o.resetLayerRenderingStats(e),e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!0),"shadow"===e.renderPass&&e.shadowRenderer){const a=[],n=e.shadowRenderer.getShadowPassDepthMode();pe({painter:e,source:t,layer:o,coords:i,defines:a,blendMode:f.disabled,depthMode:n,opacity:c,verticalScale:u,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"];s&&(p=p.concat("RENDER_SHADOWS")),e.shadowRenderer&&e.shadowRenderer.useNormalOffset&&(p=p.concat("NORMAL_OFFSET"));const v=o.paint.get("building-facade-emissive-chance"),h=o.paint.get("building-ambient-occlusion-intensity"),m=o.paint.get("building-flood-light-intensity"),g="none"===o.paint.get("building-flood-light-color-use-theme").constantOr("default"),x=o.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(g?null:o.lut).toArray01().slice(0,3),y=o.paint.get("building-flood-light-ground-attenuation"),w=m>0,b=new _(e.context.gl.LEQUAL,_.ReadWrite,e.depthRangeFor3D);c<1&&pe({painter:e,source:t,layer:o,coords:i,defines:p,blendMode:f.disabled,depthMode:b,opacity:c,verticalScale:u,facadeEmissiveChance:v,facadeAOIntensity:h,floodLightIntensity:m,floodLightColor:x,depthOnly:!0});const T=e.colorModeForRenderPass();pe({painter:e,source:t,layer:o,coords:i,defines:p,blendMode:T,depthMode:b,opacity:c,verticalScale:u,facadeEmissiveChance:v,facadeAOIntensity:h,floodLightIntensity:m,floodLightColor:x}),o.paint.get("building-front-cutoff"),l&&ve(e,t,o,i,!0,c,a,n,m,x,r,d),w&&ve(e,t,o,i,!1,c,a,n,m,x,y,d)}else if("light-beam"===e.renderPass){const a=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],n=new _(e.context.gl.LEQUAL,_.ReadOnly,e.depthRangeFor3D);pe({painter:e,source:t,layer:o,coords:i,defines:a,blendMode:f.alphaBlended,depthMode:n,opacity:c,verticalScale:u,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!1),e.resetStencilClippingMasks()},drawRasterParticle:function(e,t,o,i,a,n){"offscreen"===e.renderPass&&function(e,t,o,i){if(!i.length)return;const a=e.context,n=a.gl,r=t.getSource();if(!(r instanceof h))return;const c=Math.ceil(Math.sqrt(o.paint.get("raster-particle-count")));let l=o.particlePositionRGBAImage;if(!l||l.width!==c){const e=function(e){const t=e*e,o=new Uint8Array(4*t),i=.9090909090909091;for(let a=0;a<t;a++){const e=i*(j(2*a+0)+he),t=i*(j(2*a+1)+he),n=255*e%1,r=255*t%1,c=n,l=t-r/255,s=r;o[4*a+0]=255*(e-n/255),o[4*a+1]=255*c,o[4*a+2]=255*l,o[4*a+3]=255*s}return o}(c);l=o.particlePositionRGBAImage=new m({width:c,height:c},e)}let s=o.particleFramebuffer;s?s.width!==c&&(s.destroy(),s=o.particleFramebuffer=a.createFramebuffer(c,c,1,null)):s=o.particleFramebuffer=a.createFramebuffer(c,c,1,null);const p=[];for(const _ of i){const e=t.getTile(_);if(!(e instanceof g))continue;const i=be(e,r,o);if(!i)continue;const n=[e.tileSize,e.tileSize];let s=o.tileFramebuffer;s||(s=o.tileFramebuffer=a.createFramebuffer(n[0],n[1],1,null));let u=e.rasterParticleState;u||(u=e.rasterParticleState=new we(a,_,n,l));const f=u.update(o.lastInvalidatedAt);u.particleTextureDimension!==c&&u.updateParticleTexture(_,l);const d=u.targetColorTexture;u.targetColorTexture=u.backgroundColorTexture,u.backgroundColorTexture=d;const v=u.particleTexture0;u.particleTexture0=u.particleTexture1,u.particleTexture1=v,p.push([_,i,u,f])}if(0===p.length)return;const b=x.now(),T=o.previousDrawTimestamp?.001*(b-o.previousDrawTimestamp):.0167;if(o.previousDrawTimestamp=b,o.hasColorMap()){a.activeTexture.set(n.TEXTURE0+2);let e=o.colorRampTexture;e||(e=o.colorRampTexture=new v(a,o.colorRamp,n.RGBA8)),e.bind(n.LINEAR,n.CLAMP_TO_EDGE)}a.bindFramebuffer.set(o.tileFramebuffer.framebuffer),function(e,t,o){const i=e.context,a=i.gl,n=t.tileFramebuffer;i.activeTexture.set(a.TEXTURE0);const r={u_texture:0,u_opacity:1.05*(l=t.paint.get("raster-particle-fade-opacity-factor"))/(l+.05)},c=e.getOrCreateProgram("rasterParticleTexture",{defines:[],overrideFog:!1});var l;for(const s of o){const[,,o,l]=s;n.colorAttachment0.set(o.targetColorTexture.texture),i.viewport.set([0,0,n.width,n.height]),i.clear({color:y.transparent}),l&&(o.backgroundColorTexture.bind(a.NEAREST,a.CLAMP_TO_EDGE),c.draw(e,a.TRIANGLES,_.disabled,u.disabled,f.alphaBlended,d.disabled,r,t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments))}}(e,o,p),function(e,t,o,i){const a=e.context,n=a.gl,r=o.tileFramebuffer,c="globe"===e.transform.projection.name,l=o.paint.get("raster-particle-max-speed");for(const s of i){const[i,p,v]=s;a.activeTexture.set(n.TEXTURE0+0),p.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),r.colorAttachment0.set(v.targetColorTexture.texture);const h=e.getOrCreateProgram("rasterParticleDraw",{defines:p.defines,overrideFog:!1});a.activeTexture.set(n.TEXTURE0+1);const m=p.scalarData?[]:[0,1,2,3].map(e=>w[e](i));m.push(i);const g=i.canonical.x,x=i.canonical.y;for(const a of m){const r=t.getTile(c?a.wrapped():a);if(!r)continue;const s=r.rasterParticleState;if(!s)continue;const v=a.canonical.x+(1<<a.canonical.z)*(a.wrap-i.wrap),m=a.canonical.y;s.particleTexture0.bind(n.NEAREST,n.CLAMP_TO_EDGE);const y=ge(1,s.particleTexture0.size[0],[v-g,m-x],0,p.texture.size,2,l,p.textureOffset,p.scale,p.offset);h.draw(e,n.POINTS,_.disabled,u.disabled,f.alphaBlended,d.disabled,y,o.id,s.particleIndexBuffer,void 0,s.particleSegment)}}}(e,t,o,p),a.bindFramebuffer.set(o.particleFramebuffer.framebuffer),function(e,t,o,i){const a=e.context,n=a.gl,r=t.paint.get("raster-particle-max-speed"),c=i*t.paint.get("raster-particle-speed-factor")*.15,l=(p=.01+1*t.paint.get("raster-particle-reset-rate-factor"),Math.pow(p,6)),s=t.particleFramebuffer;var p;a.viewport.set([0,0,s.width,s.height]);for(const v of o){const[,o,i]=v;a.activeTexture.set(n.TEXTURE0+0),o.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),a.activeTexture.set(n.TEXTURE0+1);const p=i.particleTexture0;p.bind(n.NEAREST,n.CLAMP_TO_EDGE);const h=xe(1,p.size[0],0,o.texture.size,r,c,l,o.textureOffset,o.scale,o.offset);s.colorAttachment0.set(i.particleTexture1.texture),a.clear({color:y.transparent}),e.getOrCreateProgram("rasterParticleUpdate",{defines:o.defines}).draw(e,n.TRIANGLES,_.disabled,u.disabled,f.unblended,d.disabled,h,t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments)}}(e,o,p,T)}(e,t,o,i),"translucent"===e.renderPass&&(function(e,t,o,i){const a=e.context,n=a.gl,r=t.getSource().tileSize,c=5*(1-b(T,T+1,e.transform.zoom))*r+o.paint.get("raster-particle-elevation"),l=!e.options.moving,s="globe"===e.transform.projection.name;if(!i.length)return;const[u,p]=e.stencilConfigForOverlap(i),v=[];s&&v.push("PROJECTION_GLOBE_VIEW");const h=e.stencilModeFor3D();for(const m of p){const i=m.toUnwrapped(),r=t.getTile(m);if(!r.rasterParticleState)continue;const p=r.rasterParticleState,g=100;r.registerFadeDuration(g);const x=t.findLoadedParent(m,0),y=S(r,x,t,e.transform,g);let w,b;e.terrain&&e.terrain.prepareDrawTile(),a.activeTexture.set(n.TEXTURE0),p.targetColorTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE),a.activeTexture.set(n.TEXTURE1),x&&x.rasterParticleState?(x.rasterParticleState.targetColorTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE),w=Math.pow(2,x.tileID.overscaledZ-r.tileID.overscaledZ),b=[r.tileID.canonical.x*w%1,r.tileID.canonical.y*w%1]):p.targetColorTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE);const T=s?e.transform.expandedFarZProjMatrix:e.transform.calculateProjMatrix(i,l),I=e.transform,L=Te(I),B=R(m.canonical),N=A(B.getCenter().lat);let U,M,G,V,k;s?(U=Float32Array.from(P(C(m.canonical))),M=Float32Array.from(I.globeMatrix),G=Float32Array.from(E(I)),V=[z(I.center.lng),F(I.center.lat)],k=Float32Array.from(O(m.canonical,B,N,I.worldSize/I._pixelsPerMercatorPixel))):(U=new Float32Array(16),M=new Float32Array(9),G=new Float32Array(16),V=[0,0],k=new Float32Array(9));const X=me(T,U,M,G,k,b||[0,0],D(e.transform.zoom),V,L,w||1,y,c),H=e.isTileAffectedByFog(m),j=e.getOrCreateProgram("rasterParticle",{defines:v,overrideFog:H});if(e.uploadCommonUniforms(a,j,i),s){const t=new _(n.LEQUAL,_.ReadOnly,e.depthRangeFor3D),i=0,a=e.globeSharedBuffers;if(a){const[r,c,l]=a.getGridBuffers(N,0!==i);j.draw(e,n.TRIANGLES,t,h,f.alphaBlended,e.renderElevatedRasterBackface?d.frontCCW:d.backCCW,X,o.id,r,c,l)}}else{const t=e.depthModeForSublayer(0,_.ReadOnly),i=u[m.overscaledZ],{tileBoundsBuffer:a,tileBoundsIndexBuffer:c,tileBoundsSegments:l}=e.getTileBoundsBuffers(r);j.draw(e,n.TRIANGLES,t,i,f.alphaBlended,d.disabled,X,o.id,a,c,l)}}e.resetStencilClippingMasks()}(e,t,o,i),e.style.map.triggerRepaint())},prepareRasterParticle:function(e,t,o){const i=t.getSource();if(!(i instanceof h&&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 c of r)c.updateNeeded(e.id,n)&&i.prepareTile(c,a,e.id,n)},Rain:class extends De{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=Fe(this.particlesCount),o=new p,i=new l;let a=0;const n=k(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,Ae.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:o,revealParams:i,direction:a,vignetteParams:n}=t,r=e.transform.zoom;if(i.revealStart>r)return;const c=Oe(0,1,i.revealStart,i.revealStart+i.revealRange,r);if(!this.particlesVx||!this.particlesIdx)return;n.strength*=c;const l=this.updateOnRender(e,o.timeFactor),p=e.context,h=p.gl,m=e.transform;this.screenTexture&&this.screenTexture.size[0]===e.width&&this.screenTexture.size[1]===e.height||(this.screenTexture=new v(p,{width:e.width,height:e.height,data:null},h.RGBA8)),o.distortionStrength>0&&(p.activeTexture.set(h.TEXTURE0),this.screenTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),h.copyTexSubImage2D(h.TEXTURE_2D,0,0,0,0,0,e.width,e.height));const g=e.getOrCreateProgram("rainParticle");e.uploadCommonUniforms(p,g),p.activeTexture.set(h.TEXTURE0),this.screenTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE);const x=[o.color.r,o.color.g,o.color.b,o.color.a],y=(t,i)=>{const n=ze(this._movement.getPosition(),t),r=o.dropletSizeX,c=o.dropletSizeX*o.dropletSizeYScale,p=e.width/2,v=e.height/2,y=Oe(0,o.screenThinning.start,0,1,o.screenThinning.intensity),w=Oe(.001,o.screenThinning.range,0,1,o.screenThinning.intensity),b=Oe(0,o.screenThinning.particleOffset,0,1,o.screenThinning.intensity),T=(S={modelview:l.modelviewMatrix,projection:l.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:n,velocityConeAperture:o.velocityConeAperture,velocity:o.velocity,boxSize:t,rainDropletSize:[r,c],distortionStrength:o.distortionStrength,rainDirection:a,color:x,screenSize:[m.width,m.height],thinningCenterPos:[p,v],thinningShape:[y,w,Math.pow(10,o.screenThinning.fadePower)],thinningAffectedRatio:o.screenThinning.affectedRatio,thinningParticleOffset:b,shapeDirectionalPower:o.shapeDirPower,shapeNormalPower:o.shapeNormalPower,mode:i?0:1},{u_modelview:Float32Array.from(S.modelview),u_projection:Float32Array.from(S.projection),u_time:S.time,u_cam_pos:S.camPos,u_texScreen:0,u_velocityConeAperture:S.velocityConeAperture,u_velocity:S.velocity,u_boxSize:S.boxSize,u_rainDropletSize:S.rainDropletSize,u_distortionStrength:S.distortionStrength,u_rainDirection:S.rainDirection,u_color:S.color,u_screenSize:S.screenSize,u_thinningCenterPos:S.thinningCenterPos,u_thinningShape:S.thinningShape,u_thinningAffectedRatio:S.thinningAffectedRatio,u_thinningParticleOffset:S.thinningParticleOffset,u_shapeDirectionalPower:S.shapeDirectionalPower,u_shapeNormalPower:S.shapeNormalPower,u_mode:S.mode});var S;const R=Math.round(o.intensity*this.particlesCount),A=s.simpleSegment(0,0,4*R,2*R);g.draw(e,h.TRIANGLES,_.disabled,u.disabled,f.alphaBlended,d.disabled,T,"rain_particles",this.particlesVx,this.particlesIdx,A)};o.distortionStrength>0&&y(o.boxSize,!0),y(o.boxSize,!1),this._vignette.draw(e,n)}},Snow:class extends De{constructor(){super(2.25),this._params={intensity:.85,timeFactor:.75,velocityConeAperture:70,velocity:40,horizontalOscillationRadius:4,horizontalOscillationRate:1.5,boxSize:2e3,billboardSize:2,shapeFadeStart:.27,shapeFadePower:.21,screenThinning:{intensity:.4,start:.15,range:1.4,fadePower:.24,affectedRatio:1,particleOffset:-.2},color:{r:1,g:1,b:1,a:1},direction:{x:-50,y:-35}},this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,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=Fe(this.particlesCount),o=new c,i=new l;let a=0;const n=k(1323123451230);for(let t=0;t<e.length;++t){const r=e[t],c=n(),l=n(),s=n(),_=[t/e.length,c,l,s],u=[n(),n()];o.emplaceBack(r[0],r[1],r[2],-1,-1,..._,...u),o.emplaceBack(r[0],r[1],r[2],1,-1,..._,...u),o.emplaceBack(r[0],r[1],r[2],1,1,..._,...u),o.emplaceBack(r[0],r[1],r[2],-1,1,..._,...u),i.emplaceBack(a+0,a+1,a+2),i.emplaceBack(a+0,a+2,a+3),a+=4}this.particlesVx=t.createVertexBuffer(o,Ie.members),this.particlesIdx=t.createIndexBuffer(i)}}getDrawParams(e){if(!e.style.snow)return null;const t=e.style.snow.state,o=structuredClone(this._params);o.intensity=t.density,o.timeFactor=t.intensity,o.color=structuredClone(t.color),o.screenThinning.intensity=t.centerThinning,o.billboardSize=2.79*t.flakeSize;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:o,revealParams:i,direction:a,vignetteParams:n}=t,r=e.transform.zoom;if(i.revealStart>r)return;const c=Oe(0,1,i.revealStart,i.revealStart+i.revealRange,r);n.strength*=c;const l=this.updateOnRender(e,o.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const p=e.context,v=p.gl,h=e.transform,m=e.getOrCreateProgram("snowParticle");e.uploadCommonUniforms(p,m),((t,o,i)=>{const n=ze(this._movement.getPosition(),t),r=h.width/2,c=h.height/2,p=Oe(0,i.screenThinning.start,0,1,i.screenThinning.intensity),g=Oe(.001,i.screenThinning.range,0,1,i.screenThinning.intensity),x=Oe(0,i.screenThinning.particleOffset,0,1,i.screenThinning.intensity),y=(w={modelview:l.modelviewMatrix,projection:l.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:n,velocityConeAperture:i.velocityConeAperture,velocity:i.velocity,horizontalOscillationRadius:i.horizontalOscillationRadius,horizontalOscillationRate:i.horizontalOscillationRate,boxSize:t,billboardSize:1*i.billboardSize,simpleShapeParameters:[i.shapeFadeStart,i.shapeFadePower],screenSize:[h.width,h.height],thinningCenterPos:[r,c],thinningShape:[p,g,Math.pow(10,i.screenThinning.fadePower)],thinningAffectedRatio:i.screenThinning.affectedRatio,thinningParticleOffset:x,color:[i.color.r,i.color.g,i.color.b,i.color.a],direction:a},{u_modelview:Float32Array.from(w.modelview),u_projection:Float32Array.from(w.projection),u_time:w.time,u_cam_pos:w.camPos,u_velocityConeAperture:w.velocityConeAperture,u_velocity:w.velocity,u_horizontalOscillationRadius:w.horizontalOscillationRadius,u_horizontalOscillationRate:w.horizontalOscillationRate,u_boxSize:w.boxSize,u_billboardSize:w.billboardSize,u_simpleShapeParameters:w.simpleShapeParameters,u_screenSize:w.screenSize,u_thinningCenterPos:w.thinningCenterPos,u_thinningShape:w.thinningShape,u_thinningAffectedRatio:w.thinningAffectedRatio,u_thinningParticleOffset:w.thinningParticleOffset,u_particleColor:w.color,u_direction:w.direction});var w;const b=Math.round(i.intensity*this.particlesCount),T=s.simpleSegment(0,0,4*b,2*b);this.particlesVx&&this.particlesIdx&&m.draw(e,v.TRIANGLES,_.disabled,u.disabled,f.alphaBlended,d.disabled,y,"snow_particles",this.particlesVx,this.particlesIdx,T)})(o.boxSize,0,o),this._vignette.draw(e,n)}},shaders:Re,programUniforms:Le};export{Be as HD};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{N as t,G as e,$ as r,L as a,A as o,f as n,B as i,Y as s,q as l,Z as u,J as d,V as h,n as c,a as f,y as g,b as y,c as p,S as m,M as x,T as A,m as F,K as b,t as B,l as w,d as v,e as C,g as M,h as I,H as V,X as L,E as O,_ as P,u as E,i as k,p as _}from"./index-nTegTRc-.js";const R=E([{name:"a_pos_3f",components:3,type:"Float32"}]),S=E([{name:"a_normal_3",components:3,type:"Int16"}]),U=E([{name:"a_centroid_3",components:3,type:"Int16"}]),N=E([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),T=E([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),z=E([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),D=E([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),W=E([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),H=E([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),G=4096;class j{constructor(t){this.module=t,this.memoryStack=this.module.malloc(G),this.memoryStackNextFree=this.memoryStack}createIntArray(t){const e=this.memoryStackNextFree;return this.memoryStackNextFree+=t.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>G?-1:(new Int32Array(this.module.heap32.buffer,e,t.length).set(t),e)}createFloatArray(t){const e=this.memoryStackNextFree;return this.memoryStackNextFree+=t.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>G?-1:(new Float32Array(this.module.heapF32.buffer,e,t.length).set(t),e)}readStringBuffer(t){let e="";for(;0!==this.module.heapU8[t];)e+=String.fromCharCode(this.module.heapU8[t]),++t;return e}setStyle(t){const e=t.normalScale;this.module.setStyle(e[0],e[1],e[2],t.tileToMeters)}setAOOptions(t,e){this.module.setAOOptions(t?1:0,e)}setMetricOptions(t,e){this.module.setMetricOptions(t?1:0,e)}setStructuralOptions(t){this.module.setStructuralOptions(t?1:0)}setFacadeOptions(t,e){this.module.setFacadeOptions(t,e?1:0)}setFauxFacadeOptions(t,e,r){this.module.setFauxFacadeOptions(t?1:0,e?1:0,r)}setFacadeClassifierOptions(t){this.module.setFacadeClassifierOptions(t)}generateMesh(t,e){this.memoryStackNextFree=this.memoryStack;for(const i of t){const t=this.createIntArray(i.ringIndices),e=this.createFloatArray(i.coordinates);if(-1===t||-1===e)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(i.id,i.sourceId,i.minHeight,i.height,i.roofType,e,t,i.ringIndices.length-1)}for(const i of e){let t;t=i.entrances?JSON.parse(i.entrances):[];const e=this.createFloatArray(t),r=this.createFloatArray(i.coordinates);if(-1===e||-1===r)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(i.sourceId,i.crossPerc,i.distanceToRoad,e,t.length,r,i.coordinates.length)}if(!this.module.generateMesh()){const t=this.module.getLastError();return this.readStringBuffer(t)}const r=this.module.getMeshCount(),a=new Array(r);for(let i=0;i<r;i++){const t=this.module.getPositionsPtr(i),e=this.module.getPositionsLength(i),r=new Float32Array(this.module.heapF32.buffer,t,e),o=this.module.getNormalsPtr(i),n=this.module.getNormalsLength(i),s=new Float32Array(this.module.heapF32.buffer,o,n),l=this.module.getAOPtr(i),u=this.module.getAOLength(i),d=new Float32Array(this.module.heapF32.buffer,l,u),h=this.module.getUVPtr(i),c=this.module.getUVLength(i),f=new Float32Array(this.module.heapF32.buffer,h,c),g=this.module.getFauxFacadePtr(i),y=this.module.getFauxFacadeLength(i),p=new Uint8Array(this.module.heapU8.buffer,g,y),m=this.module.getIndicesPtr(i),x=this.module.getIndicesLength(i),A=new Int16Array(this.module.heap16.buffer,m,x),F=this.module.getBuildingPart(i);a[i]={positions:r,normals:s,ao:d,uv:f,isFauxFacade:p,indices:A,buildingPart:F}}const o=this.module.getRingCount(),n=[];for(let i=0;i<o;i++){const t=this.module.getRingPtr(i),e=this.module.getRingLength(i),r=new Float32Array(this.module.heapF32.buffer,t,e);n.push(r)}return{meshes:a,outerRingLength:this.module.getOuterRingLength(),modifiedPolygonRings:n}}}const $=y.types,Y=32767;function q(t,e){const r=b+e;for(const a of t)for(const t of a)if(t.x<-e||t.x>r||t.y<-e||t.y>r)return!1;return!0}function J(t){switch(t){case"flat":return 3;case"hipped":return 1;case"gabled":return 2;case"parapet":return 0;case"mansard":return 4;case"skillion":return 5;case"pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${t}`)}}let K=null,X=null,Z=null;function Q(){if(!h(self))return null;if(null!=Z||null!=X)return null;if(null!=K)return K;const t=fetch(c());return K=function(t){let e,r,a,o,n;function i(){e=new Uint8Array(n.buffer),r=new Int16Array(n.buffer),a=new Int32Array(n.buffer),o=new Float32Array(n.buffer)}function s(){throw new Error("Unexpected BuildingGen error.")}const l=()=>{},u={a:{a:s,f:function(t){const r=e.length,a=Math.max(t>>>0,Math.ceil(1.2*r)),o=Math.ceil((a-r)/65536);try{return n.grow(o),i(),!0}catch(s){return!1}},g:s,b:l,c:l,d:l,e:l}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,u):t.then(t=>t.arrayBuffer()).then(t=>WebAssembly.instantiate(t,u))).then(t=>{const s=t.instance.exports;return(0,s.g)(),n=s.f,i(),new j({setStyle:s.h,setAOOptions:s.i,setMetricOptions:s.j,setStructuralOptions:s.k,setFacadeOptions:s.l,setFauxFacadeOptions:s.m,setFacadeClassifierOptions:s.n,addFeature:s.o,addFacade:s.p,generateMesh:s.q,getLastError:s.r,getOuterRingLength:s.s,getMeshCount:s.t,getPositionsPtr:s.u,getPositionsLength:s.v,getNormalsPtr:s.w,getNormalsLength:s.x,getAOPtr:s.y,getAOLength:s.z,getUVPtr:s.A,getUVLength:s.B,getFauxFacadePtr:s.C,getFauxFacadeLength:s.D,getIndicesPtr:s.E,getIndicesLength:s.F,getBuildingPart:s.G,getRingCount:s.H,getRingPtr:s.I,getRingLength:s.J,malloc:s.K,free:s.L,heapU8:e,heap16:r,heap32:a,heapF32:o})})}(t).then(t=>{K=null,Z=t}).catch(t=>{f("Could not load building-gen"),K=null,X=t}),K}class tt{constructor(){this.layoutVertexArray=new C,this.layoutAttenuationArray=new k,this.layoutColorArray=new I,this.indexArray=new O,this.indexArrayForConflation=new O,this.segmentsBucket=new v}}class et{constructor(t){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new v,this.entranceBloom=new tt;const e=66560;this.layoutVertexArray=new C,this.layoutVertexArray.reserve(e),this.layoutNormalArray=new M,this.layoutNormalArray.reserve(e),this.layoutCentroidArray=new M,this.layoutCentroidArray.reserve(e),this.layoutColorArray=new I,this.layoutColorArray.reserve(e),this.layoutFloodLightDataArray=new V,this.layoutFloodLightDataArray.reserve(e),this.layoutAOArray=new L,this.layoutAOArray.reserve(e),this.indexArray=new O,this.indexArray.reserve(66560),this.indexArrayForConflation=new O,this.segmentsBucket=new v,this.entranceBloom=new tt,t&&(this.layoutFacadePaintArray=new I,this.layoutFacadeDataArray=new P,this.layoutFacadeVerticalRangeArray=new I)}reserve(t,e,r){this.layoutVertexArray.reserveForAdditional(t),this.layoutCentroidArray.reserveForAdditional(t),this.layoutFloodLightDataArray.reserveForAdditional(t),this.layoutNormalArray.reserveForAdditional(t),this.layoutAOArray.reserveForAdditional(t),this.layoutColorArray.reserveForAdditional(t),this.indexArray.reserveForAdditional(e),r&&(this.layoutFacadePaintArray.reserveForAdditional(t),this.layoutFacadeDataArray.reserveForAdditional(t),this.layoutFacadeVerticalRangeArray.reserveForAdditional(t))}}class rt{constructor(i){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new t,this.footprintsIndices=new e,this.footprintsMin=new r(1/0,1/0),this.footprintsMax=new r(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new et(!1),this.buildingWithFacade=new et(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=/* @__PURE__ */new Map,this.buildingIds=/* @__PURE__ */new Set,this.footprintLookup={},this.zoom=i.zoom,this.canonical=i.canonical,this.layers=i.layers,this.layerIds=this.layers.map(t=>t.fqid),this.index=i.index,this.hasPattern=!1,this.worldview=i.worldview,this.lut=i.lut,this.programConfigurations=new a(i.layers,{zoom:i.zoom,lut:i.lut}),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.projection=i.projection,this.groundEffect=new o(i),this.groundEffect.groundRadiusArray=new n,this.hasAppearances=null}updateFootprints(t,e){const r=new i([],[],1),a={vertices:[],indices:new Uint32Array(0),grid:r,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};e.push({footprint:a,id:t})}updateAppearances(t,e,r,a){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(t,e,a,o){if(!Z)return;const n=g(a);this.tileToMeter=n,this.brightness=e.brightness,Z.setStyle({normalScale:[1,-1,n],tileToMeters:n}),Z.setAOOptions(!1,.3),Z.setMetricOptions(!1,16),Z.setStructuralOptions(!0),Z.setFacadeClassifierOptions(3);const i=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map;let u=0;for(const{feature:r}of t){if("LineString"!==$[r.type]){i.set(r.id,r.properties.source_id);continue}const t=this.layers[0]._featureFilter.needGeometry;if(t&&!this.layers[0]._featureFilter.filter(new p(this.zoom),r,a))continue;const e=m(r,t);if(!t&&!this.layers[0]._featureFilter.filter(new p(this.zoom),e,a))continue;const n=t?e.geometry:x(r,a,o),s=[];for(const r of n)for(const t of r)s.push(t.x),s.push(t.y);const d={coordinates:s,crossPerc:r.properties.cross_perc,distanceToRoad:r.properties.distance_to_road,entrances:r.properties.entrances,sourceId:0},h=r.properties.source_id;let c=l.get(h);c||(c=[],l.set(h,c)),c.push(d),++u}this.maxHeight=0;const d=new Array,h=/* @__PURE__ */new Set,c=t=>{null!=t&&h.add(t)},y=(t,e)=>{null!=t&&d.push({buildingId:t,footprintIndex:e})},v=64*(t.length-u),C=v/2;this.buildingWithFacade.reserve(v,C,!0),this.buildingWithoutFacade.reserve(2*v,2*C,!1),this.footprintsIndices.reserve(16*(t.length-u)),this.footprintsVertices.reserve(8*(t.length-u));for(const{feature:g,id:I,index:V,sourceLayerIndex:L}of t){if("LineString"===$[g.type])continue;const t=this.layers[0]._featureFilter.needGeometry;if(t&&!this.layers[0]._featureFilter.filter(new p(this.zoom),g,a))continue;let u=null;if(g.properties&&Object.hasOwn(g.properties,"building_id")&&(u=Number(g.properties.building_id),h.has(u)))continue;const d=m(g,t);if(!t&&!this.layers[0]._featureFilter.filter(new p(this.zoom),d,a))continue;const v=t?d.geometry:x(g,a,o),C=A(v,500);let M=!1;for(const e of C)if(1!==e.length){M=!0;break}if(M){c(u);continue}if(!q(v,163)){c(u);continue}const O=this.layers[0],P=J(O.layout.get("building-roof-shape").evaluate(g,{},a)),E=O.layout.get("building-base").evaluate(g,{},a),k=O.layout.get("building-height").evaluate(g,{},a),_=O.layout.get("building-flood-light-ground-radius").evaluate(g,{},a),R=O.paint.get("building-ambient-occlusion-intensity"),S=_/this.tileToMeter;g.properties["building-part"]="roof";const U=O.paint.get("building-color").evaluate(g,{},this.canonical).toPremultipliedRenderColor(this.lut),N=O.paint.get("building-emissive-strength").evaluate(g,{},this.canonical);g.properties["building-part"]="wall";const T=O.paint.get("building-color").evaluate(g,{},this.canonical).toPremultipliedRenderColor(this.lut),z=O.paint.get("building-emissive-strength").evaluate(g,{},this.canonical);g.properties["building-part"]="window";const D=O.paint.get("building-color").evaluate(g,{},this.canonical).toPremultipliedRenderColor(this.lut),W=O.paint.get("building-emissive-strength").evaluate(g,{},this.canonical);g.properties["building-part"]="door";const H=O.paint.get("building-color").evaluate(g,{},this.canonical).toPremultipliedRenderColor(this.lut),G=O.paint.get("building-emissive-strength").evaluate(g,{},this.canonical);let j=O.layout.get("building-flood-light-wall-radius").evaluate(g,{},a);j=w(j,0,2048);const K=j/2048*Y,X=i.get(I),Q=l.get(X)||[],tt=0!==Q.length&&O.layout.get("building-facade").evaluate(g,{},a);Z.setFacadeOptions(4,!0),Z.setFauxFacadeOptions(tt,!1,1);let et=0,rt=0,at=0,ot=0,nt=0,it=0,st=0,lt=0,ut=0,dt=0,ht=0;if(tt){let t=Math.round(O.layout.get("building-facade-floors").evaluate(g,{},a));if(0===E){t=Math.max(1,t-(Q.length>0?1:0));let e=4;if(k>100){const t=[10,13,15];e=t[g.id?g.id%t.length:0]}else k<=10&&(e=3);Z.setFacadeOptions(e,!0),nt=(k<15?1.3:1.61803)*e/n}else nt=E/n;it=k/n,nt=Math.min(nt,it),at=O.layout.get("building-facade-unit-width").evaluate(g,{},a)/n,ot=(it-nt)/t,Z.setFauxFacadeOptions(!0,!0,at);const e=O.layout.get("building-facade-window").evaluate(g,{},a);et=e[0],rt=e[1],st=Math.floor(65535*Math.min(1,nt/b)),lt=Math.floor(65535*Math.min(1,it/b)),ut=Math.floor(255*et)<<8|Math.floor(255*rt),dt=Math.floor(65535*Math.min(1,at/b)),ht=Math.floor(65535*Math.min(1,ot/b))}const ct=Array(C.length),ft={x:1/0,y:1/0},gt={x:-1/0,y:-1/0},yt={x:0,y:0};let pt=0;for(let e=0;e<C.length;e++){const t=C[e];if(t.length>0){const r=[],a=Array(t.length+1);a[0]=0;for(let e=0;e<t.length;e++){const o=t[e];for(let t=0;t<o.length;t++){const e=o[o.length-t-1];ft.x=Math.min(ft.x,e.x),ft.y=Math.min(ft.y,e.y),gt.x=Math.max(gt.x,e.x),gt.y=Math.max(gt.y,e.y),yt.x+=e.x,yt.y+=e.y,pt++,r.push(e.x),r.push(e.y)}a[e+1]=r.length}ct[e]={id:g.id?g.id:0,height:k,minHeight:E,sourceId:0,roofType:P,coordinates:r,ringIndices:a}}}yt.x/=pt||1,yt.y/=pt||1;const mt=Z.generateMesh(ct,Q);if("string"==typeof mt){f(`Unable to generate building ${g.id}: ${mt}`),c(u);continue}if(0===mt.meshes.length||0===mt.modifiedPolygonRings.length){c(u);continue}const xt=tt?this.buildingWithFacade:this.buildingWithoutFacade;let At=0;for(const e of mt.meshes)At+=e.positions.length/3;const Ft=xt.segmentsBucket.prepareSegment(At,xt.layoutVertexArray,xt.indexArray),bt=[];let Bt=null,wt=0,vt=-1;const Ct=xt.layoutVertexArray.length,Mt=Ct+At;xt.layoutVertexArray.resize(Mt),xt.layoutCentroidArray.resize(Mt),xt.layoutNormalArray.resize(Mt),xt.layoutAOArray.resize(Mt),xt.layoutColorArray.resize(Mt),xt.layoutFloodLightDataArray.resize(Mt),tt&&(xt.layoutFacadePaintArray.resize(Mt),xt.layoutFacadeDataArray.resize(Mt),xt.layoutFacadeVerticalRangeArray.resize(Mt));const It=xt.indexArray.length;let Vt=0,Lt=Ct;for(const e of mt.meshes){let t,r;if(1===e.buildingPart)t=U,r=N;else if(0===e.buildingPart)t=T,r=z;else if(2===e.buildingPart)t=D,r=W;else{if(3!==e.buildingPart)continue;t=H,r=G}if(r=w(r,0,1),3===e.buildingPart){const t=new Array;for(let n=0;n<e.positions.length;n+=12){const r=e.positions[n+0],a=e.positions[n+1],o=e.positions[n+3],i=e.positions[n+4],s=e.positions[n+2],l=e.positions[n+8]-s,u=1,d=o-r,h=i-a,c=Math.hypot(d,h);t.push({pos:[r+.5*d,a+.5*h,s],normal:[h/c,-d/c,0],width:c,height:l,depth:u,points:[r,a,o,i]})}const r=xt.entranceBloom.segmentsBucket.prepareSegment(10*t.length,xt.entranceBloom.layoutVertexArray,xt.entranceBloom.indexArray),a=xt.entranceBloom.layoutVertexArray.length;wt=xt.entranceBloom.indexArray.length,F(t,.5/this.tileToMeter,xt.entranceBloom.indexArray,xt.entranceBloom.layoutVertexArray,xt.entranceBloom.layoutAttenuationArray);const o=xt.entranceBloom.layoutVertexArray.length-a;vt=xt.entranceBloom.indexArray.length-wt;for(let e=0;e<o;e++)xt.entranceBloom.layoutColorArray.emplaceBack(255*H.r<<8|255*H.g,255*H.b<<8|51*G);r.vertexLength+=o,r.primitiveLength+=vt,Bt={part:e.buildingPart,vertexOffset:a,vertexLength:o}}xt.layoutVertexArray.float32.set(e.positions,3*Lt);const a=e.positions.length/3;for(let f=0;f<a;++f){const a=3*f;Vt=Math.max(Vt,e.positions[a+2]);const o=e.normals[a+1]*Y,n=e.normals[a+2]*Y,i=3*(Lt+f);xt.layoutNormalArray.int16[i]=e.normals[a]*Y,xt.layoutNormalArray.int16[i+1]=o,xt.layoutNormalArray.int16[i+2]=n;const s=e.ao[f];xt.layoutAOArray.uint8[Lt+f]=255*s;const l=1+(s-1)*R,u=255*t.b*l<<8|255*r;xt.layoutColorArray.uint16[2*(Lt+f)]=255*t.r*l<<8|255*t.g*l,xt.layoutColorArray.uint16[2*(Lt+f)+1]=u}const o=Math.min(8191,Math.max(0,Math.floor(yt.x))),n=Math.min(8191,Math.max(0,Math.floor(yt.y))),i=Math.floor(k),s=20,l=4*o+Math.min(3,Math.round((gt.x-ft.x)*this.tileToMeter/s)),u=4*n+Math.min(3,Math.round((gt.y-ft.y)*this.tileToMeter/s));for(let e=0;e<a;++e){const t=3*(Lt+e);xt.layoutCentroidArray.int16[t]=l,xt.layoutCentroidArray.int16[t+1]=u,xt.layoutCentroidArray.int16[t+2]=i}if(xt.layoutFloodLightDataArray.int16.fill(0===e.buildingPart?K:0,Lt,Lt+a),tt){const t=255*D.r<<8|255*D.g,r=255*D.b<<8|255*W;for(let e=0;e<a;++e){const a=2*(Lt+e);xt.layoutFacadePaintArray.uint16[a]=t,xt.layoutFacadePaintArray.uint16[a+1]=r}for(let o=0;o<a;++o)if(e.isFauxFacade[o]){const t=Math.min(65535,Math.floor(e.uv[2*o]*mt.outerRingLength));xt.layoutFacadeDataArray.emplace(Lt+o,1|t,ut,dt,ht),xt.layoutFacadeVerticalRangeArray.emplace(Lt+o,st,lt)}else xt.layoutFacadeDataArray.emplace(Lt+o,0,0,0,0),xt.layoutFacadeVerticalRangeArray.emplace(Lt+o,0,0)}const d=Ft.vertexLength,h=e.indices.length/3,c=xt.indexArray.length;xt.indexArray.resize(c+h);for(let f=0;f<h;++f){const t=3*f,r=3*c+t;xt.indexArray.uint16[r]=d+e.indices[t],xt.indexArray.uint16[r+1]=d+e.indices[t+1],xt.indexArray.uint16[r+2]=d+e.indices[t+2]}1!==e.buildingPart&&0!==e.buildingPart&&2!==e.buildingPart&&3!==e.buildingPart||bt.push({part:e.buildingPart,vertexOffset:Lt,vertexLength:e.positions.length/3}),Lt+=a,Ft.vertexLength+=a,Ft.primitiveLength+=e.indices.length/3}this.maxHeight=Math.max(this.maxHeight,Vt);const Ot=xt.indexArray.length-It,Pt=this.footprintsIndices.length,Et=this.footprintsVertices.length,kt=[],_t=new r(1/0,1/0),Rt=new r(-1/0,-1/0),St=this.groundEffect.vertexArray.length;for(const e of mt.modifiedPolygonRings){const t=[],a=new r(1/0,1/0),o=new r(-1/0,-1/0);for(let n=0;n<e.length;n+=2){const i=e.length-n-2;a.x=Math.min(a.x,e[i]),a.y=Math.min(a.y,e[i+1]),o.x=Math.max(o.x,e[i]),o.y=Math.max(o.y,e[i+1]);const s=new r(e[i],e[i+1]);t.push(s),kt.push(s.x,s.y),this.footprintsVertices.emplaceBack(s.x,s.y)}_t.x=Math.min(_t.x,a.x),_t.y=Math.min(_t.y,a.y),Rt.x=Math.max(Rt.x,o.x),Rt.y=Math.max(Rt.y,o.y),this.groundEffect.addData(t,[a,o],S)}const Ut=this.groundEffect.vertexArray.length-St;this.groundEffect.groundRadiusArray.reserveForAdditional(Ut);for(let e=0;e<Ut;e++)this.groundEffect.groundRadiusArray.emplaceBack(_);(ft.x<0||gt.x>b||ft.y<0||gt.y>b)&&this.featuresOnBorder.push({featureId:g.id,footprintIndex:this.footprints.length});{const t=B(kt,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+t.length),this.footprintsIndices.uint16.set(t,Pt),this.buildingIds.add(null!=u?u:g.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,_t.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,_t.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,Rt.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Rt.y);const e={footprintVertexOffset:Et,footprintVertexLength:this.footprintsVertices.length-Et,footprintIndexOffset:Pt,footprintIndexLength:this.footprintsIndices.length-Pt,min:_t,max:Rt,hiddenFlags:s,indicesOffset:It,indicesLength:Ot,bloomIndicesOffset:wt,bloomIndicesLength:vt,groundEffectVertexOffset:St,groundEffectVertexLength:Ut,hasFauxFacade:tt,height:Vt,promoteId:I,feature:d,parts:bt,buildingBloom:Bt},r=this.footprints.length;void 0!==g.id&&this.featureFootprintLookup.set(g.id,r),y(u,r),this.footprints.push(e)}this.programConfigurations.populatePaintArrays(xt.layoutVertexArray.length,g,V,{},e.availableImages,a,e.brightness),this.groundEffect.addPaintPropertiesData(g,V,{},e.availableImages,a,e.brightness),e.featureIndex.insert(g,v,V,L,this.index,Ct)}d.forEach(({buildingId:t,footprintIndex:e})=>{h.has(t)&&(this.footprints[e].hiddenFlags|=4)});const M=/* @__PURE__ */new Set;this.buildingIds.forEach((t,e,r)=>{h.has(t)||M.add(t)}),this.buildingIds=M,this.groundEffect.prepareBorderSegments()}update(t,e,r,a,o,n,i){this.programConfigurations.updatePaintArrays(t,e,o,r,a,n,i),this.groundEffect.update(t,e,o,r,a,n,i),this.evaluate(this.layers[0],t),this.colorBufferUploaded=!1}updateExpressions(t){this.programConfigurations.updateExpressions(t),this.groundEffect.programConfigurations.updateExpressions(t)}isEmpty(){return 0===this.buildingWithoutFacade.layoutVertexArray.length&&0===this.buildingWithFacade.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){const e=e=>{e.layoutVertexBuffer=t.createVertexBuffer(e.layoutVertexArray,R.members),e.layoutNormalBuffer=t.createVertexBuffer(e.layoutNormalArray,S.members),e.layoutCentroidBuffer=t.createVertexBuffer(e.layoutCentroidArray,U.members),e.layoutFloodLightDataBuffer=t.createVertexBuffer(e.layoutFloodLightDataArray,H.members),e.layoutFacadeDataArray&&e.layoutFacadeDataArray.length&&(e.layoutFacadeDataBuffer=t.createVertexBuffer(e.layoutFacadeDataArray,z.members)),e.layoutFacadeVerticalRangeArray&&e.layoutFacadeVerticalRangeArray.length&&(e.layoutFacadeVerticalRangeBuffer=t.createVertexBuffer(e.layoutFacadeVerticalRangeArray,D.members)),e.entranceBloom.layoutVertexArray.length&&(e.entranceBloom.layoutVertexBuffer=t.createVertexBuffer(e.entranceBloom.layoutVertexArray,R.members),e.entranceBloom.layoutAttenuationBuffer=t.createVertexBuffer(e.entranceBloom.layoutAttenuationArray,W.members)),this.uploadUpdatedColorBuffer(t),this.uploadUpdatedIndexBuffer(t)};this.uploaded||(e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){const t=t=>{t.layoutVertexBuffer&&(t.layoutVertexBuffer.destroy(),t.layoutNormalBuffer.destroy(),t.layoutColorBuffer.destroy(),t.segmentsBucket.destroy(),t.indexBuffer&&t.indexBuffer.destroy(),t.entranceBloom.layoutVertexBuffer&&(t.entranceBloom.layoutVertexBuffer.destroy(),t.entranceBloom.layoutColorBuffer.destroy(),t.entranceBloom.layoutAttenuationBuffer.destroy(),t.entranceBloom.indexBuffer.destroy(),t.entranceBloom.segmentsBucket.destroy()))};t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(t,e,r=!0){let a=!1;const o=r?e:0,n=0|(r?-1:~e);0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const i of t){const t=this.footprints[i],e=t.hiddenFlags&n|o;t.hiddenFlags!==e&&(t.hiddenFlags=e,a=!0,this.groundEffect.updateHiddenByLandmarkRange(t.groundEffectVertexOffset,t.groundEffectVertexLength,t.hiddenFlags!==s))}return a&&(this.indexArrayForConflationUploaded=!1),a}uploadUpdatedIndexBuffer(t){if(this.groundEffect.uploadHiddenByLandmark(t),this.indexArrayForConflationUploaded)return;const e=t=>{0!==t.indexArray.length&&(t.indexArrayForConflation.resize(t.indexArray.length),t.indexArrayForConflation.uint16.set(t.indexArray.uint16),t.entranceBloom.indexArrayForConflation.resize(t.entranceBloom.indexArray.length),t.entranceBloom.indexArrayForConflation.uint16.set(t.entranceBloom.indexArray.uint16))};e(this.buildingWithoutFacade),e(this.buildingWithFacade);for(const a of this.footprints){const t=a.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,e=a.indicesOffset+a.indicesLength;if(a.hiddenFlags!==s){for(let o=a.indicesOffset;o<e;o++)t.indexArrayForConflation.uint16[3*o+0]=0,t.indexArrayForConflation.uint16[3*o+1]=0,t.indexArrayForConflation.uint16[3*o+2]=0;const r=a.bloomIndicesOffset+a.bloomIndicesLength;for(let e=a.bloomIndicesOffset;e<r;e++)t.entranceBloom.indexArrayForConflation.uint16[3*e+0]=0,t.entranceBloom.indexArrayForConflation.uint16[3*e+1]=0,t.entranceBloom.indexArrayForConflation.uint16[3*e+2]=0}}const r=e=>{0!==e.indexArray.length&&(e.indexBuffer?e.indexBuffer.updateData(e.indexArrayForConflation):e.indexBuffer=t.createIndexBuffer(e.indexArrayForConflation,!0),e.entranceBloom.indexBuffer?e.entranceBloom.indexBuffer.updateData(e.entranceBloom.indexArrayForConflation):e.entranceBloom.indexBuffer=t.createIndexBuffer(e.entranceBloom.indexArrayForConflation,!0))};r(this.buildingWithoutFacade),r(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(t){const e=e=>{e.layoutColorBuffer?e.layoutColorBuffer.updateData(e.layoutColorArray):e.layoutColorBuffer=t.createVertexBuffer(e.layoutColorArray,N.members,!0),e.layoutFacadePaintArray&&(e.layoutFacadePaintBuffer?e.layoutFacadePaintBuffer.updateData(e.layoutFacadePaintArray):e.layoutFacadePaintBuffer=t.createVertexBuffer(e.layoutFacadePaintArray,T.members,!0)),e.entranceBloom.layoutColorBuffer?e.entranceBloom.layoutColorBuffer.updateData(e.entranceBloom.layoutColorArray):e.entranceBloom.layoutColorBuffer=t.createVertexBuffer(e.entranceBloom.layoutColorArray,N.members,!0)};e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(t,e){const r=t.paint.get("building-ambient-occlusion-intensity");for(const a of this.footprints){if(4&a.hiddenFlags)continue;const o=e[a.promoteId],n=a.feature;n.properties["building-part"]="roof";const i=t.paint.get("building-color").evaluate(n,o,this.canonical).toPremultipliedRenderColor(this.lut),s=t.paint.get("building-emissive-strength").evaluate(n,o,this.canonical);n.properties["building-part"]="wall";const l=t.paint.get("building-color").evaluate(n,o,this.canonical).toPremultipliedRenderColor(this.lut),u=t.paint.get("building-emissive-strength").evaluate(n,o,this.canonical);n.properties["building-part"]="window";const d=t.paint.get("building-color").evaluate(n,o,this.canonical).toPremultipliedRenderColor(this.lut),h=t.paint.get("building-emissive-strength").evaluate(n,o,this.canonical);n.properties["building-part"]="door";const c=t.paint.get("building-color").evaluate(n,o,this.canonical).toPremultipliedRenderColor(this.lut),f=t.paint.get("building-emissive-strength").evaluate(n,o,this.canonical),g=a.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const t of a.parts){let e,o=i;1===t.part?(o=i,e=s):0===t.part?(o=l,e=u):2===t.part?(o=d,e=h):3===t.part&&(o=c,e=f),e=w(e,0,1);for(let n=0;n<t.vertexLength;n++){const i=t.vertexOffset+n,s=1+(g.layoutAOArray.uint8[i]/255-1)*r;g.layoutColorArray.emplace(i,o.r*s*255<<8|o.g*s*255,o.b*s*255<<8|255*e),a.hasFauxFacade&&g.layoutFacadePaintArray.emplace(i,255*d.r<<8|255*d.g,255*d.b<<8|255*h)}}const y=a.buildingBloom;if(y)for(let t=0;t<y.vertexLength;t++)g.entranceBloom.layoutColorArray.emplace(y.vertexOffset+t,255*c.r<<8|255*c.g,255*c.b<<8|51*f)}}needsEvaluation(){return!this.colorBufferUploaded}updateReplacement(t,e,r){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const a=e.getReplacementRegionsForTile(t.toUnwrapped());if(l(this.activeReplacements,a))return;this.activeReplacements=a;for(const n of this.footprints)n.hiddenFlags&=~d;const o=[];for(const n of this.activeReplacements){if(n.order<r)continue;const e=Math.max(1,Math.pow(2,n.footprintTileId.canonical.z-t.canonical.z));for(const r of this.footprints)r.min.x>n.max.x||r.max.x<n.min.x||r.min.y>n.max.y||r.max.y<n.min.y||(o.length=0,ot(this.footprintsVertices,r.footprintVertexOffset,r.footprintVertexLength,n.footprintTileId.canonical,t.canonical,o),u(n.footprint,o,this.footprintsIndices.uint16,r.footprintIndexOffset,r.footprintIndexLength,0,-e)&&(r.hiddenFlags|=d))}0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const n of this.footprints)this.groundEffect.updateHiddenByLandmarkRange(n.groundEffectVertexOffset,n.groundEffectVertexLength,n.hiddenFlags!==s);this.indexArrayForConflationUploaded=!1}getFootprint(t){if(void 0!==t.id){const e=this.featureFootprintLookup.get(t.id);return this.footprints[e]}return null}getHeightAtTileCoord(t,e){let a=Number.NEGATIVE_INFINITY,o=!0;const n=4*(t+b)*b+(e+b);if(Object.hasOwn(this.footprintLookup,n)){const t=this.footprintLookup[n];return t?{height:t.height,hidden:t.hiddenFlags!==s}:void 0}const i=new r(t,e);for(const r of this.footprints)t>r.max.x||r.min.x>t||e>r.max.y||r.min.y>e||r.height<=a||at(i,this.footprintsVertices.float32.subarray(2*r.footprintVertexOffset,2*(r.footprintVertexOffset+r.footprintVertexLength)),this.footprintsIndices.uint16.subarray(r.footprintIndexOffset,r.footprintIndexOffset+r.footprintIndexLength))&&(a=r.height,this.footprintLookup[n]=r,o=r.hiddenFlags!==s);if(a!==Number.NEGATIVE_INFINITY)return{height:a,hidden:o};this.footprintLookup[n]=void 0}}function at(t,e,r){for(let a=0;a<r.length;a+=3){const o=r[a],n=r[a+1],i=r[a+2],s=e[2*o+0],l=e[2*o+1],u=e[2*n+0],d=e[2*n+1],h=e[2*i+0],c=e[2*i+1],f=(s-h)*(t.y-c)-(l-c)*(t.x-h),g=(u-s)*(t.y-l)-(d-l)*(t.x-s);if(f<0!=g<0&&0!==f&&0!==g)continue;const y=(h-u)*(t.y-d)-(c-d)*(t.x-u);if(0===y||y<0==f+g<=0)return!0}return!1}function ot(t,e,a,o,n,i){const s=Math.pow(2,o.z-n.z);for(let l=0;l<a;l++){let a=t.float32[2*(l+e)+0],u=t.float32[2*(l+e)+1];a=(a+n.x*b)*s-o.x*b,u=(u+n.y*b)*s-o.y*b,i.push(new r(a,u))}}_(rt,"BuildingBucket",{omit:["layers"]}),_(et,"BuildingGeometry"),_(tt,"BuildingBloomGeometry");export{rt as BuildingBucket,Q as waitForBuildingGen};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{N as t,G as e,$ as r,L as a,A as o,f as n,B as i,Y as s,q as l,Z as u,J as d,V as h,n as c,a as f,y as g,b as y,c as p,S as m,M as x,T as A,m as F,K as b,t as B,l as w,d as v,e as C,g as M,h as I,H as V,X as L,E as O,_ as P,u as E,i as k,p as _}from"./worker-DWfYi5c4.js";const R=E([{name:"a_pos_3f",components:3,type:"Float32"}]),S=E([{name:"a_normal_3",components:3,type:"Int16"}]),U=E([{name:"a_centroid_3",components:3,type:"Int16"}]),N=E([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),T=E([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),z=E([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),D=E([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),W=E([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),H=E([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),G=4096;class j{constructor(t){this.module=t,this.memoryStack=this.module.malloc(G),this.memoryStackNextFree=this.memoryStack}createIntArray(t){const e=this.memoryStackNextFree;return this.memoryStackNextFree+=t.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>G?-1:(new Int32Array(this.module.heap32.buffer,e,t.length).set(t),e)}createFloatArray(t){const e=this.memoryStackNextFree;return this.memoryStackNextFree+=t.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>G?-1:(new Float32Array(this.module.heapF32.buffer,e,t.length).set(t),e)}readStringBuffer(t){let e="";for(;0!==this.module.heapU8[t];)e+=String.fromCharCode(this.module.heapU8[t]),++t;return e}setStyle(t){const e=t.normalScale;this.module.setStyle(e[0],e[1],e[2],t.tileToMeters)}setAOOptions(t,e){this.module.setAOOptions(t?1:0,e)}setMetricOptions(t,e){this.module.setMetricOptions(t?1:0,e)}setStructuralOptions(t){this.module.setStructuralOptions(t?1:0)}setFacadeOptions(t,e){this.module.setFacadeOptions(t,e?1:0)}setFauxFacadeOptions(t,e,r){this.module.setFauxFacadeOptions(t?1:0,e?1:0,r)}setFacadeClassifierOptions(t){this.module.setFacadeClassifierOptions(t)}generateMesh(t,e){this.memoryStackNextFree=this.memoryStack;for(const i of t){const t=this.createIntArray(i.ringIndices),e=this.createFloatArray(i.coordinates);if(-1===t||-1===e)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(i.id,i.sourceId,i.minHeight,i.height,i.roofType,e,t,i.ringIndices.length-1)}for(const i of e){let t;t=i.entrances?JSON.parse(i.entrances):[];const e=this.createFloatArray(t),r=this.createFloatArray(i.coordinates);if(-1===e||-1===r)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(i.sourceId,i.crossPerc,i.distanceToRoad,e,t.length,r,i.coordinates.length)}if(!this.module.generateMesh()){const t=this.module.getLastError();return this.readStringBuffer(t)}const r=this.module.getMeshCount(),a=new Array(r);for(let i=0;i<r;i++){const t=this.module.getPositionsPtr(i),e=this.module.getPositionsLength(i),r=new Float32Array(this.module.heapF32.buffer,t,e),o=this.module.getNormalsPtr(i),n=this.module.getNormalsLength(i),s=new Float32Array(this.module.heapF32.buffer,o,n),l=this.module.getAOPtr(i),u=this.module.getAOLength(i),d=new Float32Array(this.module.heapF32.buffer,l,u),h=this.module.getUVPtr(i),c=this.module.getUVLength(i),f=new Float32Array(this.module.heapF32.buffer,h,c),g=this.module.getFauxFacadePtr(i),y=this.module.getFauxFacadeLength(i),p=new Uint8Array(this.module.heapU8.buffer,g,y),m=this.module.getIndicesPtr(i),x=this.module.getIndicesLength(i),A=new Int16Array(this.module.heap16.buffer,m,x),F=this.module.getBuildingPart(i);a[i]={positions:r,normals:s,ao:d,uv:f,isFauxFacade:p,indices:A,buildingPart:F}}const o=this.module.getRingCount(),n=[];for(let i=0;i<o;i++){const t=this.module.getRingPtr(i),e=this.module.getRingLength(i),r=new Float32Array(this.module.heapF32.buffer,t,e);n.push(r)}return{meshes:a,outerRingLength:this.module.getOuterRingLength(),modifiedPolygonRings:n}}}const $=y.types,Y=32767;function q(t,e){const r=b+e;for(const a of t)for(const t of a)if(t.x<-e||t.x>r||t.y<-e||t.y>r)return!1;return!0}function J(t){switch(t){case"flat":return 3;case"hipped":return 1;case"gabled":return 2;case"parapet":return 0;case"mansard":return 4;case"skillion":return 5;case"pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${t}`)}}let K=null,X=null,Z=null;function Q(){if(!h(self))return null;if(null!=Z||null!=X)return null;if(null!=K)return K;const t=fetch(c());return K=function(t){let e,r,a,o,n;function i(){e=new Uint8Array(n.buffer),r=new Int16Array(n.buffer),a=new Int32Array(n.buffer),o=new Float32Array(n.buffer)}function s(){throw new Error("Unexpected BuildingGen error.")}const l=()=>{},u={a:{a:s,f:function(t){const r=e.length,a=Math.max(t>>>0,Math.ceil(1.2*r)),o=Math.ceil((a-r)/65536);try{return n.grow(o),i(),!0}catch(s){return!1}},g:s,b:l,c:l,d:l,e:l}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,u):t.then(t=>t.arrayBuffer()).then(t=>WebAssembly.instantiate(t,u))).then(t=>{const s=t.instance.exports;return(0,s.g)(),n=s.f,i(),new j({setStyle:s.h,setAOOptions:s.i,setMetricOptions:s.j,setStructuralOptions:s.k,setFacadeOptions:s.l,setFauxFacadeOptions:s.m,setFacadeClassifierOptions:s.n,addFeature:s.o,addFacade:s.p,generateMesh:s.q,getLastError:s.r,getOuterRingLength:s.s,getMeshCount:s.t,getPositionsPtr:s.u,getPositionsLength:s.v,getNormalsPtr:s.w,getNormalsLength:s.x,getAOPtr:s.y,getAOLength:s.z,getUVPtr:s.A,getUVLength:s.B,getFauxFacadePtr:s.C,getFauxFacadeLength:s.D,getIndicesPtr:s.E,getIndicesLength:s.F,getBuildingPart:s.G,getRingCount:s.H,getRingPtr:s.I,getRingLength:s.J,malloc:s.K,free:s.L,heapU8:e,heap16:r,heap32:a,heapF32:o})})}(t).then(t=>{K=null,Z=t}).catch(t=>{f("Could not load building-gen"),K=null,X=t}),K}class tt{constructor(){this.layoutVertexArray=new C,this.layoutAttenuationArray=new k,this.layoutColorArray=new I,this.indexArray=new O,this.indexArrayForConflation=new O,this.segmentsBucket=new v}}class et{constructor(t){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new v,this.entranceBloom=new tt;const e=66560;this.layoutVertexArray=new C,this.layoutVertexArray.reserve(e),this.layoutNormalArray=new M,this.layoutNormalArray.reserve(e),this.layoutCentroidArray=new M,this.layoutCentroidArray.reserve(e),this.layoutColorArray=new I,this.layoutColorArray.reserve(e),this.layoutFloodLightDataArray=new V,this.layoutFloodLightDataArray.reserve(e),this.layoutAOArray=new L,this.layoutAOArray.reserve(e),this.indexArray=new O,this.indexArray.reserve(66560),this.indexArrayForConflation=new O,this.segmentsBucket=new v,this.entranceBloom=new tt,t&&(this.layoutFacadePaintArray=new I,this.layoutFacadeDataArray=new P,this.layoutFacadeVerticalRangeArray=new I)}reserve(t,e,r){this.layoutVertexArray.reserveForAdditional(t),this.layoutCentroidArray.reserveForAdditional(t),this.layoutFloodLightDataArray.reserveForAdditional(t),this.layoutNormalArray.reserveForAdditional(t),this.layoutAOArray.reserveForAdditional(t),this.layoutColorArray.reserveForAdditional(t),this.indexArray.reserveForAdditional(e),r&&(this.layoutFacadePaintArray.reserveForAdditional(t),this.layoutFacadeDataArray.reserveForAdditional(t),this.layoutFacadeVerticalRangeArray.reserveForAdditional(t))}}class rt{constructor(i){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new t,this.footprintsIndices=new e,this.footprintsMin=new r(1/0,1/0),this.footprintsMax=new r(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new et(!1),this.buildingWithFacade=new et(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=/* @__PURE__ */new Map,this.buildingIds=/* @__PURE__ */new Set,this.footprintLookup={},this.zoom=i.zoom,this.canonical=i.canonical,this.layers=i.layers,this.layerIds=this.layers.map(t=>t.fqid),this.index=i.index,this.hasPattern=!1,this.worldview=i.worldview,this.lut=i.lut,this.programConfigurations=new a(i.layers,{zoom:i.zoom,lut:i.lut}),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.projection=i.projection,this.groundEffect=new o(i),this.groundEffect.groundRadiusArray=new n,this.hasAppearances=null}updateFootprints(t,e){const r=new i([],[],1),a={vertices:[],indices:new Uint32Array(0),grid:r,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};e.push({footprint:a,id:t})}updateAppearances(t,e,r,a){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(t,e,a,o){if(!Z)return;const n=g(a);this.tileToMeter=n,this.brightness=e.brightness,Z.setStyle({normalScale:[1,-1,n],tileToMeters:n}),Z.setAOOptions(!1,.3),Z.setMetricOptions(!1,16),Z.setStructuralOptions(!0),Z.setFacadeClassifierOptions(3);const i=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map;let u=0;for(const{feature:r}of t){if("LineString"!==$[r.type]){i.set(r.id,r.properties.source_id);continue}const t=this.layers[0]._featureFilter.needGeometry;if(t&&!this.layers[0]._featureFilter.filter(new p(this.zoom),r,a))continue;const e=m(r,t);if(!t&&!this.layers[0]._featureFilter.filter(new p(this.zoom),e,a))continue;const n=t?e.geometry:x(r,a,o),s=[];for(const r of n)for(const t of r)s.push(t.x),s.push(t.y);const d={coordinates:s,crossPerc:r.properties.cross_perc,distanceToRoad:r.properties.distance_to_road,entrances:r.properties.entrances,sourceId:0},h=r.properties.source_id;let c=l.get(h);c||(c=[],l.set(h,c)),c.push(d),++u}this.maxHeight=0;const d=new Array,h=/* @__PURE__ */new Set,c=t=>{null!=t&&h.add(t)},y=(t,e)=>{null!=t&&d.push({buildingId:t,footprintIndex:e})},v=64*(t.length-u),C=v/2;this.buildingWithFacade.reserve(v,C,!0),this.buildingWithoutFacade.reserve(2*v,2*C,!1),this.footprintsIndices.reserve(16*(t.length-u)),this.footprintsVertices.reserve(8*(t.length-u));for(const{feature:g,id:I,index:V,sourceLayerIndex:L}of t){if("LineString"===$[g.type])continue;const t=this.layers[0]._featureFilter.needGeometry;if(t&&!this.layers[0]._featureFilter.filter(new p(this.zoom),g,a))continue;let u=null;if(g.properties&&Object.hasOwn(g.properties,"building_id")&&(u=Number(g.properties.building_id),h.has(u)))continue;const d=m(g,t);if(!t&&!this.layers[0]._featureFilter.filter(new p(this.zoom),d,a))continue;const v=t?d.geometry:x(g,a,o),C=A(v,500);let M=!1;for(const e of C)if(1!==e.length){M=!0;break}if(M){c(u);continue}if(!q(v,163)){c(u);continue}const O=this.layers[0],P=J(O.layout.get("building-roof-shape").evaluate(g,{},a)),E=O.layout.get("building-base").evaluate(g,{},a),k=O.layout.get("building-height").evaluate(g,{},a),_=O.layout.get("building-flood-light-ground-radius").evaluate(g,{},a),R=O.paint.get("building-ambient-occlusion-intensity"),S=_/this.tileToMeter;g.properties["building-part"]="roof";const U=O.paint.get("building-color").evaluate(g,{},this.canonical).toPremultipliedRenderColor(this.lut),N=O.paint.get("building-emissive-strength").evaluate(g,{},this.canonical);g.properties["building-part"]="wall";const T=O.paint.get("building-color").evaluate(g,{},this.canonical).toPremultipliedRenderColor(this.lut),z=O.paint.get("building-emissive-strength").evaluate(g,{},this.canonical);g.properties["building-part"]="window";const D=O.paint.get("building-color").evaluate(g,{},this.canonical).toPremultipliedRenderColor(this.lut),W=O.paint.get("building-emissive-strength").evaluate(g,{},this.canonical);g.properties["building-part"]="door";const H=O.paint.get("building-color").evaluate(g,{},this.canonical).toPremultipliedRenderColor(this.lut),G=O.paint.get("building-emissive-strength").evaluate(g,{},this.canonical);let j=O.layout.get("building-flood-light-wall-radius").evaluate(g,{},a);j=w(j,0,2048);const K=j/2048*Y,X=i.get(I),Q=l.get(X)||[],tt=0!==Q.length&&O.layout.get("building-facade").evaluate(g,{},a);Z.setFacadeOptions(4,!0),Z.setFauxFacadeOptions(tt,!1,1);let et=0,rt=0,at=0,ot=0,nt=0,it=0,st=0,lt=0,ut=0,dt=0,ht=0;if(tt){let t=Math.round(O.layout.get("building-facade-floors").evaluate(g,{},a));if(0===E){t=Math.max(1,t-(Q.length>0?1:0));let e=4;if(k>100){const t=[10,13,15];e=t[g.id?g.id%t.length:0]}else k<=10&&(e=3);Z.setFacadeOptions(e,!0),nt=(k<15?1.3:1.61803)*e/n}else nt=E/n;it=k/n,nt=Math.min(nt,it),at=O.layout.get("building-facade-unit-width").evaluate(g,{},a)/n,ot=(it-nt)/t,Z.setFauxFacadeOptions(!0,!0,at);const e=O.layout.get("building-facade-window").evaluate(g,{},a);et=e[0],rt=e[1],st=Math.floor(65535*Math.min(1,nt/b)),lt=Math.floor(65535*Math.min(1,it/b)),ut=Math.floor(255*et)<<8|Math.floor(255*rt),dt=Math.floor(65535*Math.min(1,at/b)),ht=Math.floor(65535*Math.min(1,ot/b))}const ct=Array(C.length),ft={x:1/0,y:1/0},gt={x:-1/0,y:-1/0},yt={x:0,y:0};let pt=0;for(let e=0;e<C.length;e++){const t=C[e];if(t.length>0){const r=[],a=Array(t.length+1);a[0]=0;for(let e=0;e<t.length;e++){const o=t[e];for(let t=0;t<o.length;t++){const e=o[o.length-t-1];ft.x=Math.min(ft.x,e.x),ft.y=Math.min(ft.y,e.y),gt.x=Math.max(gt.x,e.x),gt.y=Math.max(gt.y,e.y),yt.x+=e.x,yt.y+=e.y,pt++,r.push(e.x),r.push(e.y)}a[e+1]=r.length}ct[e]={id:g.id?g.id:0,height:k,minHeight:E,sourceId:0,roofType:P,coordinates:r,ringIndices:a}}}yt.x/=pt||1,yt.y/=pt||1;const mt=Z.generateMesh(ct,Q);if("string"==typeof mt){f(`Unable to generate building ${g.id}: ${mt}`),c(u);continue}if(0===mt.meshes.length||0===mt.modifiedPolygonRings.length){c(u);continue}const xt=tt?this.buildingWithFacade:this.buildingWithoutFacade;let At=0;for(const e of mt.meshes)At+=e.positions.length/3;const Ft=xt.segmentsBucket.prepareSegment(At,xt.layoutVertexArray,xt.indexArray),bt=[];let Bt=null,wt=0,vt=-1;const Ct=xt.layoutVertexArray.length,Mt=Ct+At;xt.layoutVertexArray.resize(Mt),xt.layoutCentroidArray.resize(Mt),xt.layoutNormalArray.resize(Mt),xt.layoutAOArray.resize(Mt),xt.layoutColorArray.resize(Mt),xt.layoutFloodLightDataArray.resize(Mt),tt&&(xt.layoutFacadePaintArray.resize(Mt),xt.layoutFacadeDataArray.resize(Mt),xt.layoutFacadeVerticalRangeArray.resize(Mt));const It=xt.indexArray.length;let Vt=0,Lt=Ct;for(const e of mt.meshes){let t,r;if(1===e.buildingPart)t=U,r=N;else if(0===e.buildingPart)t=T,r=z;else if(2===e.buildingPart)t=D,r=W;else{if(3!==e.buildingPart)continue;t=H,r=G}if(r=w(r,0,1),3===e.buildingPart){const t=new Array;for(let n=0;n<e.positions.length;n+=12){const r=e.positions[n+0],a=e.positions[n+1],o=e.positions[n+3],i=e.positions[n+4],s=e.positions[n+2],l=e.positions[n+8]-s,u=1,d=o-r,h=i-a,c=Math.hypot(d,h);t.push({pos:[r+.5*d,a+.5*h,s],normal:[h/c,-d/c,0],width:c,height:l,depth:u,points:[r,a,o,i]})}const r=xt.entranceBloom.segmentsBucket.prepareSegment(10*t.length,xt.entranceBloom.layoutVertexArray,xt.entranceBloom.indexArray),a=xt.entranceBloom.layoutVertexArray.length;wt=xt.entranceBloom.indexArray.length,F(t,.5/this.tileToMeter,xt.entranceBloom.indexArray,xt.entranceBloom.layoutVertexArray,xt.entranceBloom.layoutAttenuationArray);const o=xt.entranceBloom.layoutVertexArray.length-a;vt=xt.entranceBloom.indexArray.length-wt;for(let e=0;e<o;e++)xt.entranceBloom.layoutColorArray.emplaceBack(255*H.r<<8|255*H.g,255*H.b<<8|51*G);r.vertexLength+=o,r.primitiveLength+=vt,Bt={part:e.buildingPart,vertexOffset:a,vertexLength:o}}xt.layoutVertexArray.float32.set(e.positions,3*Lt);const a=e.positions.length/3;for(let f=0;f<a;++f){const a=3*f;Vt=Math.max(Vt,e.positions[a+2]);const o=e.normals[a+1]*Y,n=e.normals[a+2]*Y,i=3*(Lt+f);xt.layoutNormalArray.int16[i]=e.normals[a]*Y,xt.layoutNormalArray.int16[i+1]=o,xt.layoutNormalArray.int16[i+2]=n;const s=e.ao[f];xt.layoutAOArray.uint8[Lt+f]=255*s;const l=1+(s-1)*R,u=255*t.b*l<<8|255*r;xt.layoutColorArray.uint16[2*(Lt+f)]=255*t.r*l<<8|255*t.g*l,xt.layoutColorArray.uint16[2*(Lt+f)+1]=u}const o=Math.min(8191,Math.max(0,Math.floor(yt.x))),n=Math.min(8191,Math.max(0,Math.floor(yt.y))),i=Math.floor(k),s=20,l=4*o+Math.min(3,Math.round((gt.x-ft.x)*this.tileToMeter/s)),u=4*n+Math.min(3,Math.round((gt.y-ft.y)*this.tileToMeter/s));for(let e=0;e<a;++e){const t=3*(Lt+e);xt.layoutCentroidArray.int16[t]=l,xt.layoutCentroidArray.int16[t+1]=u,xt.layoutCentroidArray.int16[t+2]=i}if(xt.layoutFloodLightDataArray.int16.fill(0===e.buildingPart?K:0,Lt,Lt+a),tt){const t=255*D.r<<8|255*D.g,r=255*D.b<<8|255*W;for(let e=0;e<a;++e){const a=2*(Lt+e);xt.layoutFacadePaintArray.uint16[a]=t,xt.layoutFacadePaintArray.uint16[a+1]=r}for(let o=0;o<a;++o)if(e.isFauxFacade[o]){const t=Math.min(65535,Math.floor(e.uv[2*o]*mt.outerRingLength));xt.layoutFacadeDataArray.emplace(Lt+o,1|t,ut,dt,ht),xt.layoutFacadeVerticalRangeArray.emplace(Lt+o,st,lt)}else xt.layoutFacadeDataArray.emplace(Lt+o,0,0,0,0),xt.layoutFacadeVerticalRangeArray.emplace(Lt+o,0,0)}const d=Ft.vertexLength,h=e.indices.length/3,c=xt.indexArray.length;xt.indexArray.resize(c+h);for(let f=0;f<h;++f){const t=3*f,r=3*c+t;xt.indexArray.uint16[r]=d+e.indices[t],xt.indexArray.uint16[r+1]=d+e.indices[t+1],xt.indexArray.uint16[r+2]=d+e.indices[t+2]}1!==e.buildingPart&&0!==e.buildingPart&&2!==e.buildingPart&&3!==e.buildingPart||bt.push({part:e.buildingPart,vertexOffset:Lt,vertexLength:e.positions.length/3}),Lt+=a,Ft.vertexLength+=a,Ft.primitiveLength+=e.indices.length/3}this.maxHeight=Math.max(this.maxHeight,Vt);const Ot=xt.indexArray.length-It,Pt=this.footprintsIndices.length,Et=this.footprintsVertices.length,kt=[],_t=new r(1/0,1/0),Rt=new r(-1/0,-1/0),St=this.groundEffect.vertexArray.length;for(const e of mt.modifiedPolygonRings){const t=[],a=new r(1/0,1/0),o=new r(-1/0,-1/0);for(let n=0;n<e.length;n+=2){const i=e.length-n-2;a.x=Math.min(a.x,e[i]),a.y=Math.min(a.y,e[i+1]),o.x=Math.max(o.x,e[i]),o.y=Math.max(o.y,e[i+1]);const s=new r(e[i],e[i+1]);t.push(s),kt.push(s.x,s.y),this.footprintsVertices.emplaceBack(s.x,s.y)}_t.x=Math.min(_t.x,a.x),_t.y=Math.min(_t.y,a.y),Rt.x=Math.max(Rt.x,o.x),Rt.y=Math.max(Rt.y,o.y),this.groundEffect.addData(t,[a,o],S)}const Ut=this.groundEffect.vertexArray.length-St;this.groundEffect.groundRadiusArray.reserveForAdditional(Ut);for(let e=0;e<Ut;e++)this.groundEffect.groundRadiusArray.emplaceBack(_);(ft.x<0||gt.x>b||ft.y<0||gt.y>b)&&this.featuresOnBorder.push({featureId:g.id,footprintIndex:this.footprints.length});{const t=B(kt,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+t.length),this.footprintsIndices.uint16.set(t,Pt),this.buildingIds.add(null!=u?u:g.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,_t.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,_t.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,Rt.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Rt.y);const e={footprintVertexOffset:Et,footprintVertexLength:this.footprintsVertices.length-Et,footprintIndexOffset:Pt,footprintIndexLength:this.footprintsIndices.length-Pt,min:_t,max:Rt,hiddenFlags:s,indicesOffset:It,indicesLength:Ot,bloomIndicesOffset:wt,bloomIndicesLength:vt,groundEffectVertexOffset:St,groundEffectVertexLength:Ut,hasFauxFacade:tt,height:Vt,promoteId:I,feature:d,parts:bt,buildingBloom:Bt},r=this.footprints.length;void 0!==g.id&&this.featureFootprintLookup.set(g.id,r),y(u,r),this.footprints.push(e)}this.programConfigurations.populatePaintArrays(xt.layoutVertexArray.length,g,V,{},e.availableImages,a,e.brightness),this.groundEffect.addPaintPropertiesData(g,V,{},e.availableImages,a,e.brightness),e.featureIndex.insert(g,v,V,L,this.index,Ct)}d.forEach(({buildingId:t,footprintIndex:e})=>{h.has(t)&&(this.footprints[e].hiddenFlags|=4)});const M=/* @__PURE__ */new Set;this.buildingIds.forEach((t,e,r)=>{h.has(t)||M.add(t)}),this.buildingIds=M,this.groundEffect.prepareBorderSegments()}update(t,e,r,a,o,n,i){this.programConfigurations.updatePaintArrays(t,e,o,r,a,n,i),this.groundEffect.update(t,e,o,r,a,n,i),this.evaluate(this.layers[0],t),this.colorBufferUploaded=!1}updateExpressions(t){this.programConfigurations.updateExpressions(t),this.groundEffect.programConfigurations.updateExpressions(t)}isEmpty(){return 0===this.buildingWithoutFacade.layoutVertexArray.length&&0===this.buildingWithFacade.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){const e=e=>{e.layoutVertexBuffer=t.createVertexBuffer(e.layoutVertexArray,R.members),e.layoutNormalBuffer=t.createVertexBuffer(e.layoutNormalArray,S.members),e.layoutCentroidBuffer=t.createVertexBuffer(e.layoutCentroidArray,U.members),e.layoutFloodLightDataBuffer=t.createVertexBuffer(e.layoutFloodLightDataArray,H.members),e.layoutFacadeDataArray&&e.layoutFacadeDataArray.length&&(e.layoutFacadeDataBuffer=t.createVertexBuffer(e.layoutFacadeDataArray,z.members)),e.layoutFacadeVerticalRangeArray&&e.layoutFacadeVerticalRangeArray.length&&(e.layoutFacadeVerticalRangeBuffer=t.createVertexBuffer(e.layoutFacadeVerticalRangeArray,D.members)),e.entranceBloom.layoutVertexArray.length&&(e.entranceBloom.layoutVertexBuffer=t.createVertexBuffer(e.entranceBloom.layoutVertexArray,R.members),e.entranceBloom.layoutAttenuationBuffer=t.createVertexBuffer(e.entranceBloom.layoutAttenuationArray,W.members)),this.uploadUpdatedColorBuffer(t),this.uploadUpdatedIndexBuffer(t)};this.uploaded||(e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){const t=t=>{t.layoutVertexBuffer&&(t.layoutVertexBuffer.destroy(),t.layoutNormalBuffer.destroy(),t.layoutColorBuffer.destroy(),t.segmentsBucket.destroy(),t.indexBuffer&&t.indexBuffer.destroy(),t.entranceBloom.layoutVertexBuffer&&(t.entranceBloom.layoutVertexBuffer.destroy(),t.entranceBloom.layoutColorBuffer.destroy(),t.entranceBloom.layoutAttenuationBuffer.destroy(),t.entranceBloom.indexBuffer.destroy(),t.entranceBloom.segmentsBucket.destroy()))};t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(t,e,r=!0){let a=!1;const o=r?e:0,n=0|(r?-1:~e);0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const i of t){const t=this.footprints[i],e=t.hiddenFlags&n|o;t.hiddenFlags!==e&&(t.hiddenFlags=e,a=!0,this.groundEffect.updateHiddenByLandmarkRange(t.groundEffectVertexOffset,t.groundEffectVertexLength,t.hiddenFlags!==s))}return a&&(this.indexArrayForConflationUploaded=!1),a}uploadUpdatedIndexBuffer(t){if(this.groundEffect.uploadHiddenByLandmark(t),this.indexArrayForConflationUploaded)return;const e=t=>{0!==t.indexArray.length&&(t.indexArrayForConflation.resize(t.indexArray.length),t.indexArrayForConflation.uint16.set(t.indexArray.uint16),t.entranceBloom.indexArrayForConflation.resize(t.entranceBloom.indexArray.length),t.entranceBloom.indexArrayForConflation.uint16.set(t.entranceBloom.indexArray.uint16))};e(this.buildingWithoutFacade),e(this.buildingWithFacade);for(const a of this.footprints){const t=a.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,e=a.indicesOffset+a.indicesLength;if(a.hiddenFlags!==s){for(let o=a.indicesOffset;o<e;o++)t.indexArrayForConflation.uint16[3*o+0]=0,t.indexArrayForConflation.uint16[3*o+1]=0,t.indexArrayForConflation.uint16[3*o+2]=0;const r=a.bloomIndicesOffset+a.bloomIndicesLength;for(let e=a.bloomIndicesOffset;e<r;e++)t.entranceBloom.indexArrayForConflation.uint16[3*e+0]=0,t.entranceBloom.indexArrayForConflation.uint16[3*e+1]=0,t.entranceBloom.indexArrayForConflation.uint16[3*e+2]=0}}const r=e=>{0!==e.indexArray.length&&(e.indexBuffer?e.indexBuffer.updateData(e.indexArrayForConflation):e.indexBuffer=t.createIndexBuffer(e.indexArrayForConflation,!0),e.entranceBloom.indexBuffer?e.entranceBloom.indexBuffer.updateData(e.entranceBloom.indexArrayForConflation):e.entranceBloom.indexBuffer=t.createIndexBuffer(e.entranceBloom.indexArrayForConflation,!0))};r(this.buildingWithoutFacade),r(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(t){const e=e=>{e.layoutColorBuffer?e.layoutColorBuffer.updateData(e.layoutColorArray):e.layoutColorBuffer=t.createVertexBuffer(e.layoutColorArray,N.members,!0),e.layoutFacadePaintArray&&(e.layoutFacadePaintBuffer?e.layoutFacadePaintBuffer.updateData(e.layoutFacadePaintArray):e.layoutFacadePaintBuffer=t.createVertexBuffer(e.layoutFacadePaintArray,T.members,!0)),e.entranceBloom.layoutColorBuffer?e.entranceBloom.layoutColorBuffer.updateData(e.entranceBloom.layoutColorArray):e.entranceBloom.layoutColorBuffer=t.createVertexBuffer(e.entranceBloom.layoutColorArray,N.members,!0)};e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(t,e){const r=t.paint.get("building-ambient-occlusion-intensity");for(const a of this.footprints){if(4&a.hiddenFlags)continue;const o=e[a.promoteId],n=a.feature;n.properties["building-part"]="roof";const i=t.paint.get("building-color").evaluate(n,o,this.canonical).toPremultipliedRenderColor(this.lut),s=t.paint.get("building-emissive-strength").evaluate(n,o,this.canonical);n.properties["building-part"]="wall";const l=t.paint.get("building-color").evaluate(n,o,this.canonical).toPremultipliedRenderColor(this.lut),u=t.paint.get("building-emissive-strength").evaluate(n,o,this.canonical);n.properties["building-part"]="window";const d=t.paint.get("building-color").evaluate(n,o,this.canonical).toPremultipliedRenderColor(this.lut),h=t.paint.get("building-emissive-strength").evaluate(n,o,this.canonical);n.properties["building-part"]="door";const c=t.paint.get("building-color").evaluate(n,o,this.canonical).toPremultipliedRenderColor(this.lut),f=t.paint.get("building-emissive-strength").evaluate(n,o,this.canonical),g=a.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const t of a.parts){let e,o=i;1===t.part?(o=i,e=s):0===t.part?(o=l,e=u):2===t.part?(o=d,e=h):3===t.part&&(o=c,e=f),e=w(e,0,1);for(let n=0;n<t.vertexLength;n++){const i=t.vertexOffset+n,s=1+(g.layoutAOArray.uint8[i]/255-1)*r;g.layoutColorArray.emplace(i,o.r*s*255<<8|o.g*s*255,o.b*s*255<<8|255*e),a.hasFauxFacade&&g.layoutFacadePaintArray.emplace(i,255*d.r<<8|255*d.g,255*d.b<<8|255*h)}}const y=a.buildingBloom;if(y)for(let t=0;t<y.vertexLength;t++)g.entranceBloom.layoutColorArray.emplace(y.vertexOffset+t,255*c.r<<8|255*c.g,255*c.b<<8|51*f)}}needsEvaluation(){return!this.colorBufferUploaded}updateReplacement(t,e,r){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const a=e.getReplacementRegionsForTile(t.toUnwrapped());if(l(this.activeReplacements,a))return;this.activeReplacements=a;for(const n of this.footprints)n.hiddenFlags&=~d;const o=[];for(const n of this.activeReplacements){if(n.order<r)continue;const e=Math.max(1,Math.pow(2,n.footprintTileId.canonical.z-t.canonical.z));for(const r of this.footprints)r.min.x>n.max.x||r.max.x<n.min.x||r.min.y>n.max.y||r.max.y<n.min.y||(o.length=0,ot(this.footprintsVertices,r.footprintVertexOffset,r.footprintVertexLength,n.footprintTileId.canonical,t.canonical,o),u(n.footprint,o,this.footprintsIndices.uint16,r.footprintIndexOffset,r.footprintIndexLength,0,-e)&&(r.hiddenFlags|=d))}0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const n of this.footprints)this.groundEffect.updateHiddenByLandmarkRange(n.groundEffectVertexOffset,n.groundEffectVertexLength,n.hiddenFlags!==s);this.indexArrayForConflationUploaded=!1}getFootprint(t){if(void 0!==t.id){const e=this.featureFootprintLookup.get(t.id);return this.footprints[e]}return null}getHeightAtTileCoord(t,e){let a=Number.NEGATIVE_INFINITY,o=!0;const n=4*(t+b)*b+(e+b);if(Object.hasOwn(this.footprintLookup,n)){const t=this.footprintLookup[n];return t?{height:t.height,hidden:t.hiddenFlags!==s}:void 0}const i=new r(t,e);for(const r of this.footprints)t>r.max.x||r.min.x>t||e>r.max.y||r.min.y>e||r.height<=a||at(i,this.footprintsVertices.float32.subarray(2*r.footprintVertexOffset,2*(r.footprintVertexOffset+r.footprintVertexLength)),this.footprintsIndices.uint16.subarray(r.footprintIndexOffset,r.footprintIndexOffset+r.footprintIndexLength))&&(a=r.height,this.footprintLookup[n]=r,o=r.hiddenFlags!==s);if(a!==Number.NEGATIVE_INFINITY)return{height:a,hidden:o};this.footprintLookup[n]=void 0}}function at(t,e,r){for(let a=0;a<r.length;a+=3){const o=r[a],n=r[a+1],i=r[a+2],s=e[2*o+0],l=e[2*o+1],u=e[2*n+0],d=e[2*n+1],h=e[2*i+0],c=e[2*i+1],f=(s-h)*(t.y-c)-(l-c)*(t.x-h),g=(u-s)*(t.y-l)-(d-l)*(t.x-s);if(f<0!=g<0&&0!==f&&0!==g)continue;const y=(h-u)*(t.y-d)-(c-d)*(t.x-u);if(0===y||y<0==f+g<=0)return!0}return!1}function ot(t,e,a,o,n,i){const s=Math.pow(2,o.z-n.z);for(let l=0;l<a;l++){let a=t.float32[2*(l+e)+0],u=t.float32[2*(l+e)+1];a=(a+n.x*b)*s-o.x*b,u=(u+n.y*b)*s-o.y*b,i.push(new r(a,u))}}_(rt,"BuildingBucket",{omit:["layers"]}),_(et,"BuildingGeometry"),_(tt,"BuildingBloomGeometry");export{rt as BuildingBucket,Q as waitForBuildingGen};
|