@deck.gl/extensions 9.3.7 → 9.4.0-alpha.1
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/dist.dev.js +81 -35
- package/dist/fill-style/shader-module.d.ts +1 -1
- package/dist/index.cjs +78 -35
- package/dist/index.cjs.map +4 -4
- package/dist/mask/shader-module.d.ts +1 -1
- package/dist/terrain/height-map-builder.d.ts.map +1 -1
- package/dist/terrain/height-map-builder.js +16 -10
- package/dist/terrain/height-map-builder.js.map +1 -1
- package/dist/terrain/shader-module.d.ts +6 -6
- package/dist/terrain/shader-module.d.ts.map +1 -1
- package/dist/terrain/shader-module.js +38 -11
- package/dist/terrain/shader-module.js.map +1 -1
- package/dist/terrain/terrain-cover.d.ts.map +1 -1
- package/dist/terrain/terrain-cover.js +10 -5
- package/dist/terrain/terrain-cover.js.map +1 -1
- package/dist/utils/projection-utils.d.ts +4 -0
- package/dist/utils/projection-utils.d.ts.map +1 -1
- package/dist/utils/projection-utils.js +25 -5
- package/dist/utils/projection-utils.js.map +1 -1
- package/dist.min.js +95 -65
- package/package.json +3 -3
- package/src/terrain/height-map-builder.ts +25 -10
- package/src/terrain/shader-module.ts +38 -11
- package/src/terrain/terrain-cover.ts +21 -5
- package/src/utils/projection-utils.ts +28 -5
package/dist.min.js
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['deck'] = factory();
|
|
6
6
|
else root['deck'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var
|
|
7
|
+
"use strict";var __exports__=(()=>{var Kt=Object.create;var Q=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var $t=Object.getOwnPropertyNames;var Zt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var Le=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Se=(r,e)=>{for(var t in e)Q(r,t,{get:e[t],enumerable:!0})},X=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of $t(e))!Jt.call(r,i)&&i!==t&&Q(r,i,{get:()=>e[i],enumerable:!(o=Yt(e,i))||o.enumerable});return r},y=(r,e,t)=>(X(r,e,"default"),t&&X(t,e,"default")),d=(r,e,t)=>(t=r!=null?Kt(Zt(r)):{},X(e||!r||!r.__esModule?Q(t,"default",{value:r,enumerable:!0}):t,r)),Xt=r=>X(Q({},"__esModule",{value:!0}),r);var _=Le((Wo,Ie)=>{Ie.exports=globalThis.deck});var Ke=Le((Xo,We)=>{We.exports=globalThis.luma});var J={};Se(J,{BrushingExtension:()=>Be,ClipExtension:()=>Ft,CollisionFilterExtension:()=>It,DataFilterExtension:()=>Qe,FillStyleExtension:()=>bt,Fp64Extension:()=>dt,MaskExtension:()=>Nt,PathStyleExtension:()=>gt,_TerrainExtension:()=>Wt,project64:()=>ie});var x={},Re=d(_(),1);y(x,d(_(),1));if(!Re.Layer)throw new Error("@deck.gl/core is not found");y(J,x);var Ne=d(_(),1);var Ce=d(_(),1),ke=`layout(std140) uniform brushingUniforms {
|
|
8
8
|
bool enabled;
|
|
9
9
|
highp int target;
|
|
10
10
|
vec2 mousePos;
|
|
11
11
|
float radius;
|
|
12
12
|
} brushing;
|
|
13
|
-
`,
|
|
13
|
+
`,Qt=`
|
|
14
14
|
in vec2 brushingTargets;
|
|
15
15
|
|
|
16
16
|
out float brushing_isVisible;
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
void brushing_setVisible(bool visible) {
|
|
34
34
|
brushing_isVisible = float(visible);
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
${
|
|
38
|
-
${
|
|
39
|
-
`,
|
|
36
|
+
`,er=`
|
|
37
|
+
${ke}
|
|
38
|
+
${Qt}
|
|
39
|
+
`,tr=`
|
|
40
40
|
in float brushing_isVisible;
|
|
41
|
-
`,
|
|
42
|
-
${
|
|
43
|
-
${
|
|
44
|
-
`,
|
|
41
|
+
`,rr=`
|
|
42
|
+
${ke}
|
|
43
|
+
${tr}
|
|
44
|
+
`,or={source:0,target:1,custom:2,source_target:3},ir={"vs:DECKGL_FILTER_GL_POSITION":`
|
|
45
45
|
vec2 brushingTarget;
|
|
46
46
|
vec2 brushingSource;
|
|
47
47
|
if (brushing.target == 3) {
|
|
@@ -65,7 +65,7 @@ ${Zt}
|
|
|
65
65
|
if (brushing.enabled && brushing_isVisible < 0.5) {
|
|
66
66
|
discard;
|
|
67
67
|
}
|
|
68
|
-
`},
|
|
68
|
+
`},we={name:"brushing",dependencies:[Ce.project],vs:er,fs:rr,inject:ir,getUniforms:r=>{if(!r||!("viewport"in r))return{};let{brushingEnabled:e=!0,brushingRadius:t=1e4,brushingTarget:o="source",mousePosition:i,viewport:s}=r;return{enabled:Boolean(e&&i&&s.containsPixel(i)),radius:t,target:or[o]||0,mousePos:i?s.unproject([i.x-s.x,i.y-s.y]):[0,0]}},uniformTypes:{enabled:"i32",target:"i32",mousePos:"vec2<f32>",radius:"f32"}};var sr={getBrushingTarget:{type:"accessor",value:[0,0]},brushingTarget:"source",brushingEnabled:!0,brushingRadius:1e4},S=class extends Ne.LayerExtension{getShaders(){return{modules:[we]}}initializeState(e,t){let o=this.getAttributeManager();o&&o.add({brushingTargets:{size:2,stepMode:"dynamic",accessor:"getBrushingTarget"}});let i=()=>{this.getCurrentLayer()?.setNeedsRedraw()};this.state.onMouseMove=i,e.deck&&e.deck.eventManager.on({pointermove:i,pointerleave:i})}finalizeState(e,t){if(e.deck){let o=this.state.onMouseMove;e.deck.eventManager.off({pointermove:o,pointerleave:o})}}draw(e,t){let{viewport:o,mousePosition:i}=e.context,{brushingEnabled:s,brushingRadius:a,brushingTarget:n}=this.props,l={viewport:o,mousePosition:i,brushingEnabled:s,brushingRadius:a,brushingTarget:n};this.setShaderModuleProps({brushing:l})}};S.defaultProps=sr;S.extensionName="BrushingExtension";var Be=S;var M=d(_(),1);var De=`layout(std140) uniform dataFilterUniforms {
|
|
69
69
|
bool useSoftMargin;
|
|
70
70
|
bool enabled;
|
|
71
71
|
bool transformSize;
|
|
@@ -78,7 +78,7 @@ ${Zt}
|
|
|
78
78
|
vec4 max64High;
|
|
79
79
|
highp uvec4 categoryBitMask;
|
|
80
80
|
} dataFilter;
|
|
81
|
-
`,
|
|
81
|
+
`,ar=`
|
|
82
82
|
#ifdef DATAFILTER_TYPE
|
|
83
83
|
in DATAFILTER_TYPE filterValues;
|
|
84
84
|
#ifdef DATAFILTER_DOUBLE
|
|
@@ -239,15 +239,15 @@ float dataFilter_reduceValue(vec4 value) {
|
|
|
239
239
|
#endif
|
|
240
240
|
}
|
|
241
241
|
#endif
|
|
242
|
-
`,
|
|
243
|
-
${
|
|
244
|
-
${
|
|
245
|
-
`,
|
|
242
|
+
`,ze=`
|
|
243
|
+
${De}
|
|
244
|
+
${ar}
|
|
245
|
+
`,nr=`
|
|
246
246
|
in float dataFilter_value;
|
|
247
|
-
`,
|
|
248
|
-
${
|
|
249
|
-
${
|
|
250
|
-
`;function
|
|
247
|
+
`,Ve=`
|
|
248
|
+
${De}
|
|
249
|
+
${nr}
|
|
250
|
+
`;function je(r){if(!r||!("extensions"in r))return{};let{filterRange:e=[-1,1],filterEnabled:t=!0,filterTransformSize:o=!0,filterTransformColor:i=!0,categoryBitMask:s}=r,a=r.filterSoftRange||e,n=l=>Array.isArray(l)?[l[0]||0,l[1]||0,l[2]||0,l[3]||0]:[l,0,0,0];return{...Number.isFinite(e[0])?{min:n(e[0]),softMin:n(a[0]),softMax:n(a[1]),max:n(e[1])}:{min:n(e.map(l=>l[0])),softMin:n(a.map(l=>l[0])),softMax:n(a.map(l=>l[1])),max:n(e.map(l=>l[1]))},enabled:t,useSoftMargin:Boolean(r.filterSoftRange),transformSize:t&&o,transformColor:t&&i,...s&&{categoryBitMask:s}}}function lr(r){if(!r||!("extensions"in r))return{};let e=je(r),t=e.min.map(Math.fround);e.min=e.min.map((i,s)=>i-t[s]),e.softMin=e.softMin.map((i,s)=>i-t[s]),e.min64High=t;let o=e.max.map(Math.fround);return e.max=e.max.map((i,s)=>i-o[s]),e.softMax=e.softMax.map((i,s)=>i-o[s]),e.max64High=o,e}var Ue={"vs:#main-start":`
|
|
251
251
|
dataFilter_value = 1.0;
|
|
252
252
|
if (dataFilter.enabled) {
|
|
253
253
|
#ifdef DATAFILTER_TYPE
|
|
@@ -278,7 +278,7 @@ ${rr}
|
|
|
278
278
|
if (dataFilter.transformColor) {
|
|
279
279
|
color.a *= dataFilter_value;
|
|
280
280
|
}
|
|
281
|
-
`};function
|
|
281
|
+
`};function Ge(r){return{useSoftMargin:"i32",enabled:"i32",transformSize:"i32",transformColor:"i32",min:"vec4<f32>",softMin:"vec4<f32>",softMax:"vec4<f32>",max:"vec4<f32>",min64High:"vec4<f32>",max64High:"vec4<f32>",categoryBitMask:"vec4<u32>"}}var He={name:"dataFilter",vs:ze,fs:Ve,inject:Ue,getUniforms:je,uniformTypesFromOptions:Ge},qe={name:"dataFilter",vs:ze,fs:Ve,inject:Ue,getUniforms:lr,uniformTypesFromOptions:Ge};var Ye=d(Ke(),1),cr=`#version 300 es
|
|
282
282
|
#define SHADER_NAME data-filter-vertex-shader
|
|
283
283
|
|
|
284
284
|
#ifdef FLOAT_TARGET
|
|
@@ -309,7 +309,7 @@ void main() {
|
|
|
309
309
|
#endif
|
|
310
310
|
gl_PointSize = 1.0;
|
|
311
311
|
}
|
|
312
|
-
`,
|
|
312
|
+
`,fr=`#version 300 es
|
|
313
313
|
#define SHADER_NAME data-filter-fragment-shader
|
|
314
314
|
precision highp float;
|
|
315
315
|
|
|
@@ -323,7 +323,7 @@ void main() {
|
|
|
323
323
|
}
|
|
324
324
|
fragColor = vColor;
|
|
325
325
|
}
|
|
326
|
-
`,ar=["float32-renderable-webgl","texture-blend-float-webgl"];function We(r){return ar.every(e=>r.features.has(e))}function Ke(r,e){return e?r.createFramebuffer({width:1,height:1,colorAttachments:[r.createTexture({format:"rgba32float",dimension:"2d",width:1,height:1})]}):r.createFramebuffer({width:256,height:64,colorAttachments:[r.createTexture({format:"rgba8unorm",dimension:"2d",width:256,height:64})]})}function Ye(r,e,t,i){return t.defines.NON_INSTANCED_MODEL=1,i&&(t.defines.FLOAT_TARGET=1),new qe.Model(r,{id:"data-filter-aggregation-model",vertexCount:1,isInstanced:!1,topology:"point-list",disableWarnings:!0,vs:or,fs:sr,bufferLayout:e,...t})}var $e={blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendColorOperation:"add",blendAlphaOperation:"add",depthCompare:"never"};var lr={getFilterValue:{type:"accessor",value:0},getFilterCategory:{type:"accessor",value:0},onFilteredItemsChange:{type:"function",value:null,optional:!0},filterEnabled:!0,filterRange:[-1,1],filterSoftRange:null,filterCategories:[0],filterTransformSize:!0,filterTransformColor:!0},fr={categorySize:0,filterSize:1,fp64:!1,countItems:!1},cr={1:"uint",2:"uvec2",3:"uvec3",4:"uvec4"},pr={1:"float",2:"vec2",3:"vec3",4:"vec4"},I=class extends M.LayerExtension{constructor(e={}){super({...fr,...e})}getShaders(e){let{categorySize:t,filterSize:i,fp64:o}=e.opts,s={};t&&(s.DATACATEGORY_TYPE=cr[t],s.DATACATEGORY_CHANNELS=t),i&&(s.DATAFILTER_TYPE=pr[i],s.DATAFILTER_DOUBLE=Boolean(o));let a=o?Ue:je;return a.uniformTypes=a.uniformTypesFromOptions(e.opts),{modules:[a],defines:s}}initializeState(e,t){let i=this.getAttributeManager(),{categorySize:o,filterSize:s,fp64:a}=t.opts;i&&(s&&i.add({filterValues:{size:s,type:a?"float64":"float32",stepMode:"dynamic",accessor:"getFilterValue"}}),o&&i.add({filterCategoryValues:{size:o,stepMode:"dynamic",accessor:"getFilterCategory",type:"uint32",transform:o===1?l=>t._getCategoryKey.call(this,l,0):l=>l.map((f,p)=>t._getCategoryKey.call(this,f,p))}}));let{device:n}=this.context;if(i&&t.opts.countItems){let l=We(n);i.add({filterVertexIndices:{size:l?1:2,vertexOffset:1,type:"unorm8",accessor:(c,{index:u})=>{let m=c&&c.__source?c.__source.index:u;return l?(m+1)%255:[(m+1)%255,Math.floor(m/255)%255]},shaderAttributes:{filterPrevIndices:{vertexOffset:0},filterIndices:{vertexOffset:1}}}});let f=Ke(n,l),p=Ye(n,i.getBufferLayouts({isInstanced:!1}),t.getShaders.call(this,t),l);this.setState({filterFBO:f,filterModel:p})}}updateState({props:e,oldProps:t,changeFlags:i},o){let s=this.getAttributeManager(),{categorySize:a}=o.opts;if(this.state.filterModel){let n=s.attributes.filterValues?.needsUpdate()||s.attributes.filterCategoryValues?.needsUpdate()||e.filterEnabled!==t.filterEnabled||e.filterRange!==t.filterRange||e.filterSoftRange!==t.filterSoftRange||e.filterCategories!==t.filterCategories;n&&this.setState({filterNeedsUpdate:n})}s?.attributes.filterCategoryValues&&((s.attributes.filterCategoryValues.needsUpdate()||!(0,M._deepEqual)(e.filterCategories,t.filterCategories,2))&&this.setState({categoryBitMask:null}),i.dataChanged&&(this.setState({categoryMap:Array(a).fill(0).map(()=>({}))}),s.attributes.filterCategoryValues.setNeedsUpdate("categoryMap")))}draw(e,t){let i=this.state.filterFBO,o=this.state.filterModel,s=this.state.filterNeedsUpdate;this.state.categoryBitMask||t._updateCategoryBitMask.call(this,e,t);let{onFilteredItemsChange:a,extensions:n,filterEnabled:l,filterRange:f,filterSoftRange:p,filterTransformSize:c,filterTransformColor:u,filterCategories:m}=this.props,h={extensions:n,filterEnabled:l,filterRange:f,filterSoftRange:p,filterTransformSize:c,filterTransformColor:u,filterCategories:m};if(this.state.categoryBitMask&&(h.categoryBitMask=this.state.categoryBitMask),this.setShaderModuleProps({dataFilter:h}),s&&a&&o){let b=this.getAttributeManager(),{attributes:{filterValues:v,filterCategoryValues:O,filterVertexIndices:fe}}=b;o.setVertexCount(this.getNumInstances());let ce={...v?.getValue(),...O?.getValue(),...fe?.getValue()};o.setAttributes(ce),o.shaderInputs.setProps({dataFilter:h});let pe=[0,0,i.width,i.height],Me=o.device.beginRenderPass({id:"data-filter-aggregation",framebuffer:i,parameters:{viewport:pe},clearColor:[0,0,0,0]});o.setParameters($e),o.draw(Me),Me.end();let Ee=o.device.readPixelsToArrayWebGL(i),Fe=0;for(let ue=0;ue<Ee.length;ue++)Fe+=Ee[ue];a({id:this.id,count:Fe}),this.state.filterNeedsUpdate=!1}}finalizeState(){let e=this.state.filterFBO,t=this.state.filterModel;e?.destroy(),t?.destroy()}_updateCategoryBitMask(e,t){let{categorySize:i}=t.opts;if(!i)return;let{filterCategories:o}=this.props,s=new Uint32Array([0,0,0,0]),a=i===1?[o]:o,n=i===1?128:i===2?64:32;for(let l=0;l<a.length;l++){let f=a[l];for(let p of f){let c=t._getCategoryKey.call(this,p,l);if(c<n){let u=l*(n/32)+Math.floor(c/32);s[u]+=Math.pow(2,c%32)}else M.log.warn(`Exceeded maximum number of categories (${n})`)()}}this.state.categoryBitMask=s}_getCategoryKey(e,t){let i=this.state.categoryMap[t];return e in i||(i[e]=Object.keys(i).length),i[e]}};I.defaultProps=lr;I.extensionName="DataFilterExtension";var Ze=I;var ft=d(_(),1);var $i=1/Math.PI*180,Zi=1/180*Math.PI,ur={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...ur}};var k=globalThis.mathgl.config;function de(r){return Array.isArray(r)||ArrayBuffer.isView(r)&&!(r instanceof DataView)}function E(r,e,t){let i=k.EPSILON;t&&(k.EPSILON=t);try{if(r===e)return!0;if(de(r)&&de(e)){if(r.length!==e.length)return!1;for(let o=0;o<r.length;++o)if(!E(r[o],e[o]))return!1;return!0}return r&&r.equals?r.equals(e):e&&e.equals?e.equals(r):typeof r=="number"&&typeof e=="number"?Math.abs(r-e)<=k.EPSILON*Math.max(1,Math.abs(r),Math.abs(e)):!1}finally{k.EPSILON=i}}var R=typeof Float32Array<"u"?Float32Array:Array,_e=Math.random;function Q(r){return r>=0?Math.round(r):r%.5===0?Math.floor(r):Math.round(r)}var Qi=Math.PI/180;var C={};Ae(C,{add:()=>gr,angle:()=>jr,bezier:()=>Rr,ceil:()=>xr,clone:()=>_r,copy:()=>hr,create:()=>Xe,cross:()=>Or,dist:()=>$r,distance:()=>rt,div:()=>Yr,divide:()=>tt,dot:()=>he,equals:()=>qr,exactEquals:()=>Hr,floor:()=>yr,forEach:()=>Jr,fromValues:()=>mr,hermite:()=>kr,inverse:()=>Ar,len:()=>Xr,length:()=>Qe,lerp:()=>Sr,max:()=>br,min:()=>Pr,mul:()=>Kr,multiply:()=>et,negate:()=>Tr,normalize:()=>Lr,random:()=>Cr,rotateX:()=>Dr,rotateY:()=>zr,rotateZ:()=>Vr,round:()=>Mr,scale:()=>Er,scaleAndAdd:()=>Fr,set:()=>vr,slerp:()=>Ir,sqrDist:()=>Zr,sqrLen:()=>Qr,squaredDistance:()=>it,squaredLength:()=>ot,str:()=>Gr,sub:()=>Wr,subtract:()=>Je,transformMat3:()=>Nr,transformMat4:()=>wr,transformQuat:()=>Br,zero:()=>Ur});function Xe(){let r=new R(3);return R!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r}function _r(r){let e=new R(3);return e[0]=r[0],e[1]=r[1],e[2]=r[2],e}function Qe(r){let e=r[0],t=r[1],i=r[2];return Math.sqrt(e*e+t*t+i*i)}function mr(r,e,t){let i=new R(3);return i[0]=r,i[1]=e,i[2]=t,i}function hr(r,e){return r[0]=e[0],r[1]=e[1],r[2]=e[2],r}function vr(r,e,t,i){return r[0]=e,r[1]=t,r[2]=i,r}function gr(r,e,t){return r[0]=e[0]+t[0],r[1]=e[1]+t[1],r[2]=e[2]+t[2],r}function Je(r,e,t){return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],r}function et(r,e,t){return r[0]=e[0]*t[0],r[1]=e[1]*t[1],r[2]=e[2]*t[2],r}function tt(r,e,t){return r[0]=e[0]/t[0],r[1]=e[1]/t[1],r[2]=e[2]/t[2],r}function xr(r,e){return r[0]=Math.ceil(e[0]),r[1]=Math.ceil(e[1]),r[2]=Math.ceil(e[2]),r}function yr(r,e){return r[0]=Math.floor(e[0]),r[1]=Math.floor(e[1]),r[2]=Math.floor(e[2]),r}function Pr(r,e,t){return r[0]=Math.min(e[0],t[0]),r[1]=Math.min(e[1],t[1]),r[2]=Math.min(e[2],t[2]),r}function br(r,e,t){return r[0]=Math.max(e[0],t[0]),r[1]=Math.max(e[1],t[1]),r[2]=Math.max(e[2],t[2]),r}function Mr(r,e){return r[0]=Q(e[0]),r[1]=Q(e[1]),r[2]=Q(e[2]),r}function Er(r,e,t){return r[0]=e[0]*t,r[1]=e[1]*t,r[2]=e[2]*t,r}function Fr(r,e,t,i){return r[0]=e[0]+t[0]*i,r[1]=e[1]+t[1]*i,r[2]=e[2]+t[2]*i,r}function rt(r,e){let t=e[0]-r[0],i=e[1]-r[1],o=e[2]-r[2];return Math.sqrt(t*t+i*i+o*o)}function it(r,e){let t=e[0]-r[0],i=e[1]-r[1],o=e[2]-r[2];return t*t+i*i+o*o}function ot(r){let e=r[0],t=r[1],i=r[2];return e*e+t*t+i*i}function Tr(r,e){return r[0]=-e[0],r[1]=-e[1],r[2]=-e[2],r}function Ar(r,e){return r[0]=1/e[0],r[1]=1/e[1],r[2]=1/e[2],r}function Lr(r,e){let t=e[0],i=e[1],o=e[2],s=t*t+i*i+o*o;return s>0&&(s=1/Math.sqrt(s)),r[0]=e[0]*s,r[1]=e[1]*s,r[2]=e[2]*s,r}function he(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]}function Or(r,e,t){let i=e[0],o=e[1],s=e[2],a=t[0],n=t[1],l=t[2];return r[0]=o*l-s*n,r[1]=s*a-i*l,r[2]=i*n-o*a,r}function Sr(r,e,t,i){let o=e[0],s=e[1],a=e[2];return r[0]=o+i*(t[0]-o),r[1]=s+i*(t[1]-s),r[2]=a+i*(t[2]-a),r}function Ir(r,e,t,i){let o=Math.acos(Math.min(Math.max(he(e,t),-1),1)),s=Math.sin(o),a=Math.sin((1-i)*o)/s,n=Math.sin(i*o)/s;return r[0]=a*e[0]+n*t[0],r[1]=a*e[1]+n*t[1],r[2]=a*e[2]+n*t[2],r}function kr(r,e,t,i,o,s){let a=s*s,n=a*(2*s-3)+1,l=a*(s-2)+s,f=a*(s-1),p=a*(3-2*s);return r[0]=e[0]*n+t[0]*l+i[0]*f+o[0]*p,r[1]=e[1]*n+t[1]*l+i[1]*f+o[1]*p,r[2]=e[2]*n+t[2]*l+i[2]*f+o[2]*p,r}function Rr(r,e,t,i,o,s){let a=1-s,n=a*a,l=s*s,f=n*a,p=3*s*n,c=3*l*a,u=l*s;return r[0]=e[0]*f+t[0]*p+i[0]*c+o[0]*u,r[1]=e[1]*f+t[1]*p+i[1]*c+o[1]*u,r[2]=e[2]*f+t[2]*p+i[2]*c+o[2]*u,r}function Cr(r,e){e=e===void 0?1:e;let t=_e()*2*Math.PI,i=_e()*2-1,o=Math.sqrt(1-i*i)*e;return r[0]=Math.cos(t)*o,r[1]=Math.sin(t)*o,r[2]=i*e,r}function wr(r,e,t){let i=e[0],o=e[1],s=e[2],a=t[3]*i+t[7]*o+t[11]*s+t[15];return a=a||1,r[0]=(t[0]*i+t[4]*o+t[8]*s+t[12])/a,r[1]=(t[1]*i+t[5]*o+t[9]*s+t[13])/a,r[2]=(t[2]*i+t[6]*o+t[10]*s+t[14])/a,r}function Nr(r,e,t){let i=e[0],o=e[1],s=e[2];return r[0]=i*t[0]+o*t[3]+s*t[6],r[1]=i*t[1]+o*t[4]+s*t[7],r[2]=i*t[2]+o*t[5]+s*t[8],r}function Br(r,e,t){let i=t[0],o=t[1],s=t[2],a=t[3],n=e[0],l=e[1],f=e[2],p=o*f-s*l,c=s*n-i*f,u=i*l-o*n,m=o*u-s*c,h=s*p-i*u,b=i*c-o*p,v=a*2;return p*=v,c*=v,u*=v,m*=2,h*=2,b*=2,r[0]=n+p+m,r[1]=l+c+h,r[2]=f+u+b,r}function Dr(r,e,t,i){let o=[],s=[];return o[0]=e[0]-t[0],o[1]=e[1]-t[1],o[2]=e[2]-t[2],s[0]=o[0],s[1]=o[1]*Math.cos(i)-o[2]*Math.sin(i),s[2]=o[1]*Math.sin(i)+o[2]*Math.cos(i),r[0]=s[0]+t[0],r[1]=s[1]+t[1],r[2]=s[2]+t[2],r}function zr(r,e,t,i){let o=[],s=[];return o[0]=e[0]-t[0],o[1]=e[1]-t[1],o[2]=e[2]-t[2],s[0]=o[2]*Math.sin(i)+o[0]*Math.cos(i),s[1]=o[1],s[2]=o[2]*Math.cos(i)-o[0]*Math.sin(i),r[0]=s[0]+t[0],r[1]=s[1]+t[1],r[2]=s[2]+t[2],r}function Vr(r,e,t,i){let o=[],s=[];return o[0]=e[0]-t[0],o[1]=e[1]-t[1],o[2]=e[2]-t[2],s[0]=o[0]*Math.cos(i)-o[1]*Math.sin(i),s[1]=o[0]*Math.sin(i)+o[1]*Math.cos(i),s[2]=o[2],r[0]=s[0]+t[0],r[1]=s[1]+t[1],r[2]=s[2]+t[2],r}function jr(r,e){let t=r[0],i=r[1],o=r[2],s=e[0],a=e[1],n=e[2],l=Math.sqrt((t*t+i*i+o*o)*(s*s+a*a+n*n)),f=l&&he(r,e)/l;return Math.acos(Math.min(Math.max(f,-1),1))}function Ur(r){return r[0]=0,r[1]=0,r[2]=0,r}function Gr(r){return`vec3(${r[0]}, ${r[1]}, ${r[2]})`}function Hr(r,e){return r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]}function qr(r,e){let t=r[0],i=r[1],o=r[2],s=e[0],a=e[1],n=e[2];return Math.abs(t-s)<=1e-6*Math.max(1,Math.abs(t),Math.abs(s))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(o-n)<=1e-6*Math.max(1,Math.abs(o),Math.abs(n))}var Wr=Je,Kr=et,Yr=tt,$r=rt,Zr=it,Xr=Qe,Qr=ot,Jr=function(){let r=Xe();return function(e,t,i,o,s,a){let n,l;for(t||(t=3),i||(i=0),o?l=Math.min(o*t+i,e.length):l=e.length,n=i;n<l;n+=t)r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],s(r,r,a),e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2];return e}}();function J(r,e=[],t=0){let i=Math.fround(r),o=r-i;return e[t]=i,e[t+1]=o,e}function ve(r){return r-Math.fround(r)}function ge(r){let e=new Float32Array(32);for(let t=0;t<4;++t)for(let i=0;i<4;++i){let o=t*4+i;J(r[i*4+t],e,o*2)}return e}var xe=`
|
|
326
|
+
`,pr=["float32-renderable-webgl","texture-blend-float-webgl"];function $e(r){return pr.every(e=>r.features.has(e))}function Ze(r,e){return e?r.createFramebuffer({width:1,height:1,colorAttachments:[r.createTexture({format:"rgba32float",dimension:"2d",width:1,height:1})]}):r.createFramebuffer({width:256,height:64,colorAttachments:[r.createTexture({format:"rgba8unorm",dimension:"2d",width:256,height:64})]})}function Je(r,e,t,o){return t.defines.NON_INSTANCED_MODEL=1,o&&(t.defines.FLOAT_TARGET=1),new Ye.Model(r,{id:"data-filter-aggregation-model",vertexCount:1,isInstanced:!1,topology:"point-list",disableWarnings:!0,vs:cr,fs:fr,bufferLayout:e,...t})}var Xe={blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendColorOperation:"add",blendAlphaOperation:"add",depthCompare:"never"};var dr={getFilterValue:{type:"accessor",value:0},getFilterCategory:{type:"accessor",value:0},onFilteredItemsChange:{type:"function",value:null,optional:!0},filterEnabled:!0,filterRange:[-1,1],filterSoftRange:null,filterCategories:[0],filterTransformSize:!0,filterTransformColor:!0},_r={categorySize:0,filterSize:1,fp64:!1,countItems:!1},mr={1:"uint",2:"uvec2",3:"uvec3",4:"uvec4"},hr={1:"float",2:"vec2",3:"vec3",4:"vec4"},I=class extends M.LayerExtension{constructor(e={}){super({..._r,...e})}getShaders(e){let{categorySize:t,filterSize:o,fp64:i}=e.opts,s={};t&&(s.DATACATEGORY_TYPE=mr[t],s.DATACATEGORY_CHANNELS=t),o&&(s.DATAFILTER_TYPE=hr[o],s.DATAFILTER_DOUBLE=Boolean(i));let a=i?qe:He;return a.uniformTypes=a.uniformTypesFromOptions(e.opts),{modules:[a],defines:s}}initializeState(e,t){let o=this.getAttributeManager(),{categorySize:i,filterSize:s,fp64:a}=t.opts;o&&(s&&o.add({filterValues:{size:s,type:a?"float64":"float32",stepMode:"dynamic",accessor:"getFilterValue"}}),i&&o.add({filterCategoryValues:{size:i,stepMode:"dynamic",accessor:"getFilterCategory",type:"uint32",transform:i===1?l=>t._getCategoryKey.call(this,l,0):l=>l.map((c,p)=>t._getCategoryKey.call(this,c,p))}}));let{device:n}=this.context;if(o&&t.opts.countItems){let l=$e(n);o.add({filterVertexIndices:{size:l?1:2,vertexOffset:1,type:"unorm8",accessor:(f,{index:u})=>{let m=f&&f.__source?f.__source.index:u;return l?(m+1)%255:[(m+1)%255,Math.floor(m/255)%255]},shaderAttributes:{filterPrevIndices:{vertexOffset:0},filterIndices:{vertexOffset:1}}}});let c=Ze(n,l),p=Je(n,o.getBufferLayouts({isInstanced:!1}),t.getShaders.call(this,t),l);this.setState({filterFBO:c,filterModel:p})}}updateState({props:e,oldProps:t,changeFlags:o},i){let s=this.getAttributeManager(),{categorySize:a}=i.opts;if(this.state.filterModel){let n=s.attributes.filterValues?.needsUpdate()||s.attributes.filterCategoryValues?.needsUpdate()||e.filterEnabled!==t.filterEnabled||e.filterRange!==t.filterRange||e.filterSoftRange!==t.filterSoftRange||e.filterCategories!==t.filterCategories;n&&this.setState({filterNeedsUpdate:n})}s?.attributes.filterCategoryValues&&((s.attributes.filterCategoryValues.needsUpdate()||!(0,M._deepEqual)(e.filterCategories,t.filterCategories,2))&&this.setState({categoryBitMask:null}),o.dataChanged&&(this.setState({categoryMap:Array(a).fill(0).map(()=>({}))}),s.attributes.filterCategoryValues.setNeedsUpdate("categoryMap")))}draw(e,t){let o=this.state.filterFBO,i=this.state.filterModel,s=this.state.filterNeedsUpdate;this.state.categoryBitMask||t._updateCategoryBitMask.call(this,e,t);let{onFilteredItemsChange:a,extensions:n,filterEnabled:l,filterRange:c,filterSoftRange:p,filterTransformSize:f,filterTransformColor:u,filterCategories:m}=this.props,h={extensions:n,filterEnabled:l,filterRange:c,filterSoftRange:p,filterTransformSize:f,filterTransformColor:u,filterCategories:m};if(this.state.categoryBitMask&&(h.categoryBitMask=this.state.categoryBitMask),this.setShaderModuleProps({dataFilter:h}),s&&a&&i){let b=this.getAttributeManager(),{attributes:{filterValues:v,filterCategoryValues:L,filterVertexIndices:pe}}=b;i.setVertexCount(this.getNumInstances());let ue={...v?.getValue(),...L?.getValue(),...pe?.getValue()};i.setAttributes(ue),i.shaderInputs.setProps({dataFilter:h});let de=[0,0,o.width,o.height],Te=i.device.beginRenderPass({id:"data-filter-aggregation",framebuffer:o,parameters:{viewport:de},clearColor:[0,0,0,0]});i.setParameters(Xe),i.draw(Te),Te.end();let Oe=i.device.readPixelsToArrayWebGL(o),Ae=0;for(let _e=0;_e<Oe.length;_e++)Ae+=Oe[_e];a({id:this.id,count:Ae}),this.state.filterNeedsUpdate=!1}}finalizeState(){let e=this.state.filterFBO,t=this.state.filterModel;e?.destroy(),t?.destroy()}_updateCategoryBitMask(e,t){let{categorySize:o}=t.opts;if(!o)return;let{filterCategories:i}=this.props,s=new Uint32Array([0,0,0,0]),a=o===1?[i]:i,n=o===1?128:o===2?64:32;for(let l=0;l<a.length;l++){let c=a[l];for(let p of c){let f=t._getCategoryKey.call(this,p,l);if(f<n){let u=l*(n/32)+Math.floor(f/32);s[u]+=Math.pow(2,f%32)}else M.log.warn(`Exceeded maximum number of categories (${n})`)()}}this.state.categoryBitMask=s}_getCategoryKey(e,t){let o=this.state.categoryMap[t];return e in o||(o[e]=Object.keys(o).length),o[e]}};I.defaultProps=dr;I.extensionName="DataFilterExtension";var Qe=I;var ut=d(_(),1);var ti=1/Math.PI*180,ri=1/180*Math.PI,vr={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...vr}};var R=globalThis.mathgl.config;function me(r){return Array.isArray(r)||ArrayBuffer.isView(r)&&!(r instanceof DataView)}function E(r,e,t){let o=R.EPSILON;t&&(R.EPSILON=t);try{if(r===e)return!0;if(me(r)&&me(e)){if(r.length!==e.length)return!1;for(let i=0;i<r.length;++i)if(!E(r[i],e[i]))return!1;return!0}return r&&r.equals?r.equals(e):e&&e.equals?e.equals(r):typeof r=="number"&&typeof e=="number"?Math.abs(r-e)<=R.EPSILON*Math.max(1,Math.abs(r),Math.abs(e)):!1}finally{R.EPSILON=o}}var C=typeof Float32Array<"u"?Float32Array:Array,he=Math.random;function ee(r){return r>=0?Math.round(r):r%.5===0?Math.floor(r):Math.round(r)}var ii=Math.PI/180;var k={};Se(k,{add:()=>Mr,angle:()=>Wr,bezier:()=>Dr,ceil:()=>Er,clone:()=>xr,copy:()=>Pr,create:()=>et,cross:()=>kr,dist:()=>eo,distance:()=>st,div:()=>Qr,divide:()=>it,dot:()=>ge,equals:()=>Zr,exactEquals:()=>$r,floor:()=>Fr,forEach:()=>io,fromValues:()=>yr,hermite:()=>Br,inverse:()=>Rr,len:()=>ro,length:()=>tt,lerp:()=>wr,max:()=>Or,min:()=>Tr,mul:()=>Xr,multiply:()=>ot,negate:()=>Ir,normalize:()=>Cr,random:()=>zr,rotateX:()=>Gr,rotateY:()=>Hr,rotateZ:()=>qr,round:()=>Ar,scale:()=>Lr,scaleAndAdd:()=>Sr,set:()=>br,slerp:()=>Nr,sqrDist:()=>to,sqrLen:()=>oo,squaredDistance:()=>at,squaredLength:()=>nt,str:()=>Yr,sub:()=>Jr,subtract:()=>rt,transformMat3:()=>jr,transformMat4:()=>Vr,transformQuat:()=>Ur,zero:()=>Kr});function et(){let r=new C(3);return C!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r}function xr(r){let e=new C(3);return e[0]=r[0],e[1]=r[1],e[2]=r[2],e}function tt(r){let e=r[0],t=r[1],o=r[2];return Math.sqrt(e*e+t*t+o*o)}function yr(r,e,t){let o=new C(3);return o[0]=r,o[1]=e,o[2]=t,o}function Pr(r,e){return r[0]=e[0],r[1]=e[1],r[2]=e[2],r}function br(r,e,t,o){return r[0]=e,r[1]=t,r[2]=o,r}function Mr(r,e,t){return r[0]=e[0]+t[0],r[1]=e[1]+t[1],r[2]=e[2]+t[2],r}function rt(r,e,t){return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],r}function ot(r,e,t){return r[0]=e[0]*t[0],r[1]=e[1]*t[1],r[2]=e[2]*t[2],r}function it(r,e,t){return r[0]=e[0]/t[0],r[1]=e[1]/t[1],r[2]=e[2]/t[2],r}function Er(r,e){return r[0]=Math.ceil(e[0]),r[1]=Math.ceil(e[1]),r[2]=Math.ceil(e[2]),r}function Fr(r,e){return r[0]=Math.floor(e[0]),r[1]=Math.floor(e[1]),r[2]=Math.floor(e[2]),r}function Tr(r,e,t){return r[0]=Math.min(e[0],t[0]),r[1]=Math.min(e[1],t[1]),r[2]=Math.min(e[2],t[2]),r}function Or(r,e,t){return r[0]=Math.max(e[0],t[0]),r[1]=Math.max(e[1],t[1]),r[2]=Math.max(e[2],t[2]),r}function Ar(r,e){return r[0]=ee(e[0]),r[1]=ee(e[1]),r[2]=ee(e[2]),r}function Lr(r,e,t){return r[0]=e[0]*t,r[1]=e[1]*t,r[2]=e[2]*t,r}function Sr(r,e,t,o){return r[0]=e[0]+t[0]*o,r[1]=e[1]+t[1]*o,r[2]=e[2]+t[2]*o,r}function st(r,e){let t=e[0]-r[0],o=e[1]-r[1],i=e[2]-r[2];return Math.sqrt(t*t+o*o+i*i)}function at(r,e){let t=e[0]-r[0],o=e[1]-r[1],i=e[2]-r[2];return t*t+o*o+i*i}function nt(r){let e=r[0],t=r[1],o=r[2];return e*e+t*t+o*o}function Ir(r,e){return r[0]=-e[0],r[1]=-e[1],r[2]=-e[2],r}function Rr(r,e){return r[0]=1/e[0],r[1]=1/e[1],r[2]=1/e[2],r}function Cr(r,e){let t=e[0],o=e[1],i=e[2],s=t*t+o*o+i*i;return s>0&&(s=1/Math.sqrt(s)),r[0]=e[0]*s,r[1]=e[1]*s,r[2]=e[2]*s,r}function ge(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]}function kr(r,e,t){let o=e[0],i=e[1],s=e[2],a=t[0],n=t[1],l=t[2];return r[0]=i*l-s*n,r[1]=s*a-o*l,r[2]=o*n-i*a,r}function wr(r,e,t,o){let i=e[0],s=e[1],a=e[2];return r[0]=i+o*(t[0]-i),r[1]=s+o*(t[1]-s),r[2]=a+o*(t[2]-a),r}function Nr(r,e,t,o){let i=Math.acos(Math.min(Math.max(ge(e,t),-1),1)),s=Math.sin(i),a=Math.sin((1-o)*i)/s,n=Math.sin(o*i)/s;return r[0]=a*e[0]+n*t[0],r[1]=a*e[1]+n*t[1],r[2]=a*e[2]+n*t[2],r}function Br(r,e,t,o,i,s){let a=s*s,n=a*(2*s-3)+1,l=a*(s-2)+s,c=a*(s-1),p=a*(3-2*s);return r[0]=e[0]*n+t[0]*l+o[0]*c+i[0]*p,r[1]=e[1]*n+t[1]*l+o[1]*c+i[1]*p,r[2]=e[2]*n+t[2]*l+o[2]*c+i[2]*p,r}function Dr(r,e,t,o,i,s){let a=1-s,n=a*a,l=s*s,c=n*a,p=3*s*n,f=3*l*a,u=l*s;return r[0]=e[0]*c+t[0]*p+o[0]*f+i[0]*u,r[1]=e[1]*c+t[1]*p+o[1]*f+i[1]*u,r[2]=e[2]*c+t[2]*p+o[2]*f+i[2]*u,r}function zr(r,e){e=e===void 0?1:e;let t=he()*2*Math.PI,o=he()*2-1,i=Math.sqrt(1-o*o)*e;return r[0]=Math.cos(t)*i,r[1]=Math.sin(t)*i,r[2]=o*e,r}function Vr(r,e,t){let o=e[0],i=e[1],s=e[2],a=t[3]*o+t[7]*i+t[11]*s+t[15];return a=a||1,r[0]=(t[0]*o+t[4]*i+t[8]*s+t[12])/a,r[1]=(t[1]*o+t[5]*i+t[9]*s+t[13])/a,r[2]=(t[2]*o+t[6]*i+t[10]*s+t[14])/a,r}function jr(r,e,t){let o=e[0],i=e[1],s=e[2];return r[0]=o*t[0]+i*t[3]+s*t[6],r[1]=o*t[1]+i*t[4]+s*t[7],r[2]=o*t[2]+i*t[5]+s*t[8],r}function Ur(r,e,t){let o=t[0],i=t[1],s=t[2],a=t[3],n=e[0],l=e[1],c=e[2],p=i*c-s*l,f=s*n-o*c,u=o*l-i*n,m=i*u-s*f,h=s*p-o*u,b=o*f-i*p,v=a*2;return p*=v,f*=v,u*=v,m*=2,h*=2,b*=2,r[0]=n+p+m,r[1]=l+f+h,r[2]=c+u+b,r}function Gr(r,e,t,o){let i=[],s=[];return i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],s[0]=i[0],s[1]=i[1]*Math.cos(o)-i[2]*Math.sin(o),s[2]=i[1]*Math.sin(o)+i[2]*Math.cos(o),r[0]=s[0]+t[0],r[1]=s[1]+t[1],r[2]=s[2]+t[2],r}function Hr(r,e,t,o){let i=[],s=[];return i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],s[0]=i[2]*Math.sin(o)+i[0]*Math.cos(o),s[1]=i[1],s[2]=i[2]*Math.cos(o)-i[0]*Math.sin(o),r[0]=s[0]+t[0],r[1]=s[1]+t[1],r[2]=s[2]+t[2],r}function qr(r,e,t,o){let i=[],s=[];return i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],s[0]=i[0]*Math.cos(o)-i[1]*Math.sin(o),s[1]=i[0]*Math.sin(o)+i[1]*Math.cos(o),s[2]=i[2],r[0]=s[0]+t[0],r[1]=s[1]+t[1],r[2]=s[2]+t[2],r}function Wr(r,e){let t=r[0],o=r[1],i=r[2],s=e[0],a=e[1],n=e[2],l=Math.sqrt((t*t+o*o+i*i)*(s*s+a*a+n*n)),c=l&&ge(r,e)/l;return Math.acos(Math.min(Math.max(c,-1),1))}function Kr(r){return r[0]=0,r[1]=0,r[2]=0,r}function Yr(r){return`vec3(${r[0]}, ${r[1]}, ${r[2]})`}function $r(r,e){return r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]}function Zr(r,e){let t=r[0],o=r[1],i=r[2],s=e[0],a=e[1],n=e[2];return Math.abs(t-s)<=1e-6*Math.max(1,Math.abs(t),Math.abs(s))&&Math.abs(o-a)<=1e-6*Math.max(1,Math.abs(o),Math.abs(a))&&Math.abs(i-n)<=1e-6*Math.max(1,Math.abs(i),Math.abs(n))}var Jr=rt,Xr=ot,Qr=it,eo=st,to=at,ro=tt,oo=nt,io=function(){let r=et();return function(e,t,o,i,s,a){let n,l;for(t||(t=3),o||(o=0),i?l=Math.min(i*t+o,e.length):l=e.length,n=o;n<l;n+=t)r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],s(r,r,a),e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2];return e}}();function te(r,e=[],t=0){let o=Math.fround(r),i=r-o;return e[t]=o,e[t+1]=i,e}function xe(r){return r-Math.fround(r)}function ye(r){let e=new Float32Array(32);for(let t=0;t<4;++t)for(let o=0;o<4;++o){let i=t*4+o;te(r[o*4+t],e,i*2)}return e}var Pe=`
|
|
327
327
|
layout(std140) uniform fp64arithmeticUniforms {
|
|
328
328
|
uniform float ONE;
|
|
329
329
|
uniform float SPLIT;
|
|
@@ -522,7 +522,7 @@ vec2 sqrt_fp64(vec2 a) {
|
|
|
522
522
|
return sum_fp64(vec2(yn, 0.0), prod);
|
|
523
523
|
#endif
|
|
524
524
|
}
|
|
525
|
-
`;var
|
|
525
|
+
`;var lt=`struct Fp64ArithmeticUniforms {
|
|
526
526
|
ONE: f32,
|
|
527
527
|
SPLIT: f32,
|
|
528
528
|
};
|
|
@@ -728,7 +728,7 @@ fn sqrt_fp64(a: vec2f) -> vec2f {
|
|
|
728
728
|
return sum_fp64(vec2f(yn, 0.0), prod);
|
|
729
729
|
#endif
|
|
730
730
|
}
|
|
731
|
-
`;var
|
|
731
|
+
`;var ct=`const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
|
|
732
732
|
const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);
|
|
733
733
|
const vec2 PI_FP64 = vec2(3.1415927410125732, -8.742278012618954e-8);
|
|
734
734
|
const vec2 TWO_PI_FP64 = vec2(6.2831854820251465, -1.7484556025237907e-7);
|
|
@@ -1397,7 +1397,7 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
|
|
|
1397
1397
|
vec4_dot_fp64(a, tmp, out_val[i]);
|
|
1398
1398
|
}
|
|
1399
1399
|
}
|
|
1400
|
-
`;var
|
|
1400
|
+
`;var so={ONE:1,SPLIT:4097},ft={name:"fp64arithmetic",source:lt,fs:Pe,vs:Pe,defaultUniforms:so,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:te,fp64LowPart:xe,fp64ifyMatrix4:ye},re={name:"fp64",vs:ct,dependencies:[ft],fp64ify:te,fp64LowPart:xe,fp64ifyMatrix4:ye};var oe=d(_(),1);var pt=`const vec2 WORLD_SCALE_FP64 = vec2(81.4873275756836, 0.0000032873668232014097);
|
|
1401
1401
|
layout(std140) uniform project64Uniforms {
|
|
1402
1402
|
vec2 scale;
|
|
1403
1403
|
mat4 viewProjectionMatrix;
|
|
@@ -1470,7 +1470,7 @@ return project_position_to_clipspace(
|
|
|
1470
1470
|
position, position64xyLow, offset, commonPosition
|
|
1471
1471
|
);
|
|
1472
1472
|
}
|
|
1473
|
-
`;var{fp64ify:
|
|
1473
|
+
`;var{fp64ify:ao,fp64ifyMatrix4:no}=re,ie={name:"project64",dependencies:[oe.project,re],vs:pt,getUniforms:co,uniformTypes:{scale:"vec2<f32>",viewProjectionMatrix:"mat4x4<f32>",viewProjectionMatrix64Low:"mat4x4<f32>"}},lo=(0,oe._memoize)(fo);function co(r){if(r&&"viewport"in r){let{viewProjectionMatrix:e,scale:t}=r.viewport;return lo({viewProjectionMatrix:e,scale:t})}return{}}function fo({viewProjectionMatrix:r,scale:e}){let t=no(r),o=new Float32Array(16),i=new Float32Array(16);for(let s=0;s<4;s++)for(let a=0;a<4;a++){let n=4*s+a,l=4*a+s;o[l]=t[2*n],i[l]=t[2*n+1]}return{scale:ao(e),viewProjectionMatrix:[...o],viewProjectionMatrix64Low:[...i]}}var se=class extends ut.LayerExtension{getShaders(){let{coordinateSystem:e}=this.props;if(e!=="lnglat"&&e!=="default")throw new Error("fp64: coordinateSystem must be LNGLAT");return{modules:[ie]}}draw(e,t){let{viewport:o}=e.context;this.setShaderModuleProps({project64:{viewport:o}})}};se.extensionName="Fp64Extension";var dt=se;var w=d(_(),1);var _t={inject:{"vs:#decl":`
|
|
1474
1474
|
in vec2 instanceDashArrays;
|
|
1475
1475
|
#ifdef HIGH_PRECISION_DASH
|
|
1476
1476
|
in float instanceDashOffsets;
|
|
@@ -1522,7 +1522,7 @@ discard;
|
|
|
1522
1522
|
}
|
|
1523
1523
|
}
|
|
1524
1524
|
}
|
|
1525
|
-
`}},
|
|
1525
|
+
`}},mt={inject:{"vs:#decl":`
|
|
1526
1526
|
in vec2 instanceDashArrays;
|
|
1527
1527
|
out vec2 vDashArray;
|
|
1528
1528
|
`,"vs:#main-end":`
|
|
@@ -1564,7 +1564,7 @@ fragColor = vec4(vFillColor.rgb, vFillColor.a * alphaFactor);
|
|
|
1564
1564
|
fragColor = picking_filterPickingColor(fragColor);
|
|
1565
1565
|
fragColor = picking_filterHighlightColor(fragColor);
|
|
1566
1566
|
}
|
|
1567
|
-
`}},
|
|
1567
|
+
`}},ht={inject:{"vs:#decl":`
|
|
1568
1568
|
in vec2 instanceDashArrays;
|
|
1569
1569
|
out vec2 vDashArray;
|
|
1570
1570
|
`,"vs:#main-end":`
|
|
@@ -1686,7 +1686,7 @@ fragColor = vec4(vFillColor.rgb, vFillColor.a * alphaFactor);
|
|
|
1686
1686
|
fragColor = picking_filterPickingColor(fragColor);
|
|
1687
1687
|
fragColor = picking_filterHighlightColor(fragColor);
|
|
1688
1688
|
}
|
|
1689
|
-
`}},
|
|
1689
|
+
`}},vt={inject:{"vs:#decl":`
|
|
1690
1690
|
in float instanceOffsets;
|
|
1691
1691
|
`,"vs:DECKGL_FILTER_SIZE":`
|
|
1692
1692
|
float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
|
|
@@ -1703,14 +1703,14 @@ isInside = step(-1.0, vPathPosition.x) * step(vPathPosition.x, 1.0);
|
|
|
1703
1703
|
if (isInside == 0.0) {
|
|
1704
1704
|
discard;
|
|
1705
1705
|
}
|
|
1706
|
-
`}};var
|
|
1706
|
+
`}};var po={getDashArray:{type:"accessor",value:[0,0]},getOffset:{type:"accessor",value:0},dashJustified:!1,dashGapPickable:!1},N=class extends w.LayerExtension{constructor({dash:e=!1,offset:t=!1,highPrecisionDash:o=!1}={}){super({dash:e||o,offset:t,highPrecisionDash:o})}getLayerType(e){if("pathTesselator"in e.state)return"path";let t=e.constructor.layerName;return t==="ScatterplotLayer"?"scatterplot":t==="TextBackgroundLayer"?"textBackground":null}isEnabled(e){return this.getLayerType(e)!==null}getShaders(e){let t=e.getLayerType(this);if(!t)return null;if(t==="scatterplot"||t==="textBackground")return e.opts.dash?{modules:[{name:"pathStyle",inject:t==="scatterplot"?mt.inject:ht.inject,uniformTypes:{dashGapPickable:"i32"}}]}:null;let o={},i={};e.opts.dash&&(o=(0,w._mergeShaders)(o,_t),e.opts.highPrecisionDash&&(i.HIGH_PRECISION_DASH=!0)),e.opts.offset&&(o=(0,w._mergeShaders)(o,vt));let{inject:s}=o;return{modules:[{name:"pathStyle",inject:s,uniformTypes:{dashAlignMode:"f32",dashGapPickable:"i32"}}],defines:i}}initializeState(e,t){let o=this.getAttributeManager(),i=t.getLayerType(this);!o||!i||(t.opts.dash&&o.addInstanced({instanceDashArrays:{size:2,accessor:"getDashArray"},...i==="path"&&t.opts.highPrecisionDash?{instanceDashOffsets:{size:1,accessor:"getPath",transform:t.getDashOffsets.bind(this)}}:{}}),i==="path"&&t.opts.offset&&o.addInstanced({instanceOffsets:{size:1,accessor:"getOffset"}}))}updateState(e,t){if(t.isEnabled(this)&&t.opts.dash){let o=t.getLayerType(this);if(o==="scatterplot"||o==="textBackground"){let i={dashGapPickable:Boolean(this.props.dashGapPickable)};this.setShaderModuleProps({pathStyle:i})}else{let i={dashAlignMode:this.props.dashJustified?1:0,dashGapPickable:Boolean(this.props.dashGapPickable)};this.setShaderModuleProps({pathStyle:i})}}}getDashOffsets(e){let t=[0],o=this.props.positionFormat==="XY"?2:3,i=Array.isArray(e[0]),s=i?e.length:e.length/o,a,n;for(let l=0;l<s-1;l++)a=i?e[l]:e.slice(l*o,l*o+o),a=this.projectPosition(a),l>0&&(t[l]=t[l-1]+k.dist(n,a)),n=a;return t[s-1]=0,t}};N.defaultProps=po;N.extensionName="PathStyleExtension";var gt=N;var Pt=d(_(),1);var F=d(_(),1),xt=`layout(std140) uniform fillUniforms {
|
|
1707
1707
|
vec2 patternTextureSize;
|
|
1708
1708
|
bool patternEnabled;
|
|
1709
1709
|
bool patternMask;
|
|
1710
1710
|
vec2 uvCoordinateOrigin;
|
|
1711
1711
|
vec2 uvCoordinateOrigin64Low;
|
|
1712
1712
|
} fill;
|
|
1713
|
-
`,
|
|
1713
|
+
`,uo=`
|
|
1714
1714
|
in vec4 fillPatternFrames;
|
|
1715
1715
|
in float fillPatternScales;
|
|
1716
1716
|
in vec2 fillPatternOffsets;
|
|
@@ -1718,10 +1718,10 @@ in vec2 fillPatternOffsets;
|
|
|
1718
1718
|
out vec2 fill_uv;
|
|
1719
1719
|
out vec4 fill_patternBounds;
|
|
1720
1720
|
out vec4 fill_patternPlacement;
|
|
1721
|
-
`,
|
|
1722
|
-
${
|
|
1723
|
-
${
|
|
1724
|
-
`,
|
|
1721
|
+
`,_o=`
|
|
1722
|
+
${xt}
|
|
1723
|
+
${uo}
|
|
1724
|
+
`,mo=`
|
|
1725
1725
|
uniform sampler2D fill_patternTexture;
|
|
1726
1726
|
|
|
1727
1727
|
in vec4 fill_patternBounds;
|
|
@@ -1729,10 +1729,10 @@ in vec4 fill_patternPlacement;
|
|
|
1729
1729
|
in vec2 fill_uv;
|
|
1730
1730
|
|
|
1731
1731
|
const float FILL_UV_SCALE = 512.0 / 40000000.0;
|
|
1732
|
-
`,
|
|
1733
|
-
${
|
|
1734
|
-
${
|
|
1735
|
-
`,
|
|
1732
|
+
`,ho=`
|
|
1733
|
+
${xt}
|
|
1734
|
+
${mo}
|
|
1735
|
+
`,vo={"vs:DECKGL_FILTER_GL_POSITION":`
|
|
1736
1736
|
fill_uv = geometry.position.xy;
|
|
1737
1737
|
`,"vs:DECKGL_FILTER_COLOR":`
|
|
1738
1738
|
if (fill.patternEnabled) {
|
|
@@ -1754,7 +1754,7 @@ ${fi}
|
|
|
1754
1754
|
color.rgb = patternColor.rgb;
|
|
1755
1755
|
}
|
|
1756
1756
|
}
|
|
1757
|
-
`};function
|
|
1757
|
+
`};function go(r){if(!r)return{};let e={};if("fillPatternTexture"in r){let{fillPatternTexture:t}=r;e.fill_patternTexture=t,e.patternTextureSize=[t.width,t.height]}if("project"in r){let{fillPatternMask:t=!0,fillPatternEnabled:o=!0}=r,i=F.project.getUniforms(r.project),{commonOrigin:s}=i,a=[(0,F.fp64LowPart)(s[0]),(0,F.fp64LowPart)(s[1])];e.uvCoordinateOrigin=s.slice(0,2),e.uvCoordinateOrigin64Low=a,e.patternMask=t,e.patternEnabled=o}return e}var yt={name:"fill",vs:_o,fs:ho,inject:vo,dependencies:[F.project],getUniforms:go,uniformTypes:{patternTextureSize:"vec2<f32>",patternEnabled:"i32",patternMask:"i32",uvCoordinateOrigin:"vec2<f32>",uvCoordinateOrigin64Low:"vec2<f32>"}};var xo={fillPatternEnabled:!0,fillPatternAtlas:{type:"image",value:null,async:!0,parameters:{lodMaxClamp:0}},fillPatternMapping:{type:"object",value:{},async:!0},fillPatternMask:!0,getFillPattern:{type:"accessor",value:r=>r.pattern},getFillPatternScale:{type:"accessor",value:1},getFillPatternOffset:{type:"accessor",value:[0,0]}},B=class extends Pt.LayerExtension{constructor({pattern:e=!1}={}){super({pattern:e})}isEnabled(e){return e.getAttributeManager()!==null&&!("pathTesselator"in e.state)}getShaders(e){return e.isEnabled(this)?{modules:[e.opts.pattern&&yt].filter(Boolean)}:null}initializeState(e,t){if(!t.isEnabled(this))return;let o=this.getAttributeManager();t.opts.pattern&&o.add({fillPatternFrames:{size:4,stepMode:"dynamic",accessor:"getFillPattern",transform:t.getPatternFrame.bind(this)},fillPatternScales:{size:1,stepMode:"dynamic",accessor:"getFillPatternScale",defaultValue:1},fillPatternOffsets:{size:2,stepMode:"dynamic",accessor:"getFillPatternOffset"}}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState({props:e,oldProps:t},o){o.isEnabled(this)&&e.fillPatternMapping&&e.fillPatternMapping!==t.fillPatternMapping&&this.getAttributeManager().invalidate("getFillPattern")}draw(e,t){if(!t.isEnabled(this))return;let{fillPatternAtlas:o,fillPatternEnabled:i,fillPatternMask:s}=this.props,a={project:e.shaderModuleProps.project,fillPatternEnabled:i,fillPatternMask:s,fillPatternTexture:o||this.state.emptyTexture};this.setShaderModuleProps({fill:a})}finalizeState(){this.state.emptyTexture?.delete()}getPatternFrame(e){let{fillPatternMapping:t}=this.getCurrentLayer().props,o=t&&t[e];return o?[o.x,o.y,o.width,o.height]:[0,0,0,0]}};B.defaultProps=xo;B.extensionName="FillStyleExtension";var bt=B;var Mt=d(_(),1),yo={clipBounds:[0,0,1,1],clipByInstance:void 0},Et=`
|
|
1758
1758
|
layout(std140) uniform clipUniforms {
|
|
1759
1759
|
vec4 bounds;
|
|
1760
1760
|
} clip;
|
|
@@ -1762,7 +1762,7 @@ layout(std140) uniform clipUniforms {
|
|
|
1762
1762
|
bool clip_isInBounds(vec2 position) {
|
|
1763
1763
|
return position.x >= clip.bounds[0] && position.y >= clip.bounds[1] && position.x < clip.bounds[2] && position.y < clip.bounds[3];
|
|
1764
1764
|
}
|
|
1765
|
-
`,
|
|
1765
|
+
`,Po={name:"clip",vs:Et,uniformTypes:{bounds:"vec4<f32>"}},bo={"vs:#decl":`
|
|
1766
1766
|
out float clip_isVisible;
|
|
1767
1767
|
`,"vs:DECKGL_FILTER_GL_POSITION":`
|
|
1768
1768
|
clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));
|
|
@@ -1770,7 +1770,7 @@ out float clip_isVisible;
|
|
|
1770
1770
|
in float clip_isVisible;
|
|
1771
1771
|
`,"fs:DECKGL_FILTER_COLOR":`
|
|
1772
1772
|
if (clip_isVisible < 0.5) discard;
|
|
1773
|
-
`},
|
|
1773
|
+
`},Mo={name:"clip",fs:Et,uniformTypes:{bounds:"vec4<f32>"}},Eo={"vs:#decl":`
|
|
1774
1774
|
out vec2 clip_commonPosition;
|
|
1775
1775
|
`,"vs:DECKGL_FILTER_GL_POSITION":`
|
|
1776
1776
|
clip_commonPosition = geometry.position.xy;
|
|
@@ -1778,7 +1778,7 @@ out vec2 clip_commonPosition;
|
|
|
1778
1778
|
in vec2 clip_commonPosition;
|
|
1779
1779
|
`,"fs:DECKGL_FILTER_COLOR":`
|
|
1780
1780
|
if (!clip_isInBounds(clip_commonPosition)) discard;
|
|
1781
|
-
`},D=class extends
|
|
1781
|
+
`},D=class extends Mt.LayerExtension{getShaders(){let e="instancePositions"in this.getAttributeManager().attributes;return this.props.clipByInstance!==void 0&&(e=Boolean(this.props.clipByInstance)),this.state.clipByInstance=e,e?{modules:[Po],inject:bo}:{modules:[Mo],inject:Eo}}draw(){let{clipBounds:e}=this.props,t={};if(this.state.clipByInstance)t.bounds=e;else{let o=this.projectPosition([e[0],e[1],0]),i=this.projectPosition([e[2],e[3],0]);t.bounds=[Math.min(o[0],i[0]),Math.min(o[1],i[1]),Math.max(o[0],i[0]),Math.max(o[1],i[1])]}this.setShaderModuleProps({clip:t})}};D.defaultProps=yo;D.extensionName="ClipExtension";var Ft=D;var St=d(_(),1);var Tt=d(_(),1),Fo=`
|
|
1782
1782
|
in float collisionPriorities;
|
|
1783
1783
|
|
|
1784
1784
|
uniform sampler2D collision_texture;
|
|
@@ -1826,7 +1826,7 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
|
|
|
1826
1826
|
float W = 2.0 * floatN + 1.0;
|
|
1827
1827
|
return pow(accumulator / (W * W), 2.2);
|
|
1828
1828
|
}
|
|
1829
|
-
`,
|
|
1829
|
+
`,To={"vs:#decl":`
|
|
1830
1830
|
float collision_fade = 1.0;
|
|
1831
1831
|
`,"vs:DECKGL_FILTER_GL_POSITION":`
|
|
1832
1832
|
if (collision.sort) {
|
|
@@ -1845,21 +1845,21 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
|
|
|
1845
1845
|
}
|
|
1846
1846
|
`,"vs:DECKGL_FILTER_COLOR":`
|
|
1847
1847
|
color.a *= collision_fade;
|
|
1848
|
-
`},
|
|
1848
|
+
`},Oo=r=>{if(!r||!("dummyCollisionMap"in r))return{};let{enabled:e,collisionFBO:t,drawToCollisionMap:o,dummyCollisionMap:i}=r;return{enabled:e&&!o,sort:Boolean(o),collision_texture:!o&&t?t.colorAttachments[0]:i}},Ot={name:"collision",dependencies:[Tt.project],vs:Fo,inject:To,getUniforms:Oo,uniformTypes:{sort:"i32",enabled:"i32"}};var Lt=d(_(),1);var At=d(_(),1),z=class extends At._LayersPass{renderCollisionMap(e,t){let i=[0,0,0,0],s=[1,1,e.width-2*1,e.height-2*1];this.render({...t,clearColor:i,scissorRect:s,target:e,pass:"collision"})}getLayerParameters(e,t,o){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}getShaderModuleProps(){return{collision:{drawToCollisionMap:!0},picking:{isActive:1,isAttribute:!1},lighting:{enabled:!1}}}};var be=2,V=class{constructor(){this.id="collision-filter-effect",this.props=null,this.useInPicking=!0,this.order=1,this.channels={},this.collisionFBOs={}}setup(e){this.context=e;let{device:t}=e;this.dummyCollisionMap=t.createTexture({width:1,height:1}),this.collisionFilterPass=new z(t,{id:"default-collision-filter"})}preRender({effects:e,layers:t,layerFilter:o,viewports:i,onViewportActive:s,views:a,isPicking:n,preRenderStats:l={}}){let{device:c}=this.context;if(n)return;let p=t.filter(({props:{visible:v,collisionEnabled:L}})=>v&&L);if(p.length===0){this.channels={};return}let f=e?.filter(v=>v.useInPicking&&l[v.id]),u=l["mask-effect"]?.didRender,m=this._groupByCollisionGroup(c,p),h=i[0],b=!this.lastViewport||!this.lastViewport.equals(h)||u;for(let v in m){let L=this.collisionFBOs[v],pe=m[v],[ue,de]=c.canvasContext.getPixelSize();L.resize({width:ue/be,height:de/be}),this._render(pe,{effects:f,layerFilter:o,onViewportActive:s,views:a,viewport:h,viewportChanged:b})}}_render(e,{effects:t,layerFilter:o,onViewportActive:i,views:s,viewport:a,viewportChanged:n}){let{collisionGroup:l}=e,c=this.channels[l];if(!c)return;let p=n||e===c||!(0,Lt._deepEqual)(c.layers,e.layers,1)||e.layerBounds.some((f,u)=>!E(f,c.layerBounds[u]))||e.allLayersLoaded!==c.allLayersLoaded||e.layers.some(f=>f.props.transitions);if(this.channels[l]=e,p){this.lastViewport=a;let f=this.collisionFBOs[l];this.collisionFilterPass.renderCollisionMap(f,{pass:"collision-filter",isPicking:!0,layers:e.layers,effects:t,layerFilter:o,viewports:a?[a]:[],onViewportActive:i,views:s,shaderModuleProps:{collision:{enabled:!0,dummyCollisionMap:this.dummyCollisionMap},project:{devicePixelRatio:f.device.canvasContext.getDevicePixelRatio()/be}}})}}_groupByCollisionGroup(e,t){let o={};for(let i of t){let s=i.props.collisionGroup,a=o[s];a||(a={collisionGroup:s,layers:[],layerBounds:[],allLayersLoaded:!0},o[s]=a),a.layers.push(i),a.layerBounds.push(i.getBounds()),i.isLoaded||(a.allLayersLoaded=!1)}for(let i of Object.keys(o))this.collisionFBOs[i]||this.createFBO(e,i),this.channels[i]||(this.channels[i]=o[i]);for(let i of Object.keys(this.collisionFBOs))o[i]||this.destroyFBO(i);return o}getShaderModuleProps(e){let{collisionGroup:t,collisionEnabled:o}=e.props,{collisionFBOs:i,dummyCollisionMap:s}=this,a=i[t];return{collision:{enabled:o&&Boolean(a),collisionFBO:a,dummyCollisionMap:s}}}cleanup(){this.dummyCollisionMap&&(this.dummyCollisionMap.delete(),this.dummyCollisionMap=void 0),this.channels={};for(let e of Object.keys(this.collisionFBOs))this.destroyFBO(e);this.collisionFBOs={},this.lastViewport=void 0}createFBO(e,t){let{width:o,height:i}=e.getDefaultCanvasContext().canvas,s=e.createTexture({format:"rgba8unorm",width:o,height:i,sampler:{minFilter:"nearest",magFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),a=e.createTexture({format:"depth16unorm",width:o,height:i});this.collisionFBOs[t]=e.createFramebuffer({id:`collision-${t}`,width:o,height:i,colorAttachments:[s],depthStencilAttachment:a})}destroyFBO(e){let t=this.collisionFBOs[e];t.colorAttachments[0]?.destroy(),t.depthStencilAttachment?.destroy(),t.destroy(),delete this.collisionFBOs[e]}};var Ao={getCollisionPriority:{type:"accessor",value:0},collisionEnabled:!0,collisionGroup:{type:"string",value:"default"},collisionTestProps:{}},j=class extends St.LayerExtension{getShaders(){return{modules:[Ot]}}draw({shaderModuleProps:e}){e.collision?.drawToCollisionMap&&(this.props=this.clone(this.props.collisionTestProps).props)}initializeState(e,t){if(this.getAttributeManager()===null)return;this.context.deck?._addDefaultEffect(new V),this.getAttributeManager().add({collisionPriorities:{size:1,stepMode:"dynamic",accessor:"getCollisionPriority"}})}getNeedsPickingBuffer(){return this.props.collisionEnabled}};j.defaultProps=Ao;j.extensionName="CollisionFilterExtension";var It=j;var P=d(_(),1);var Rt=d(_(),1),Ct=`layout(std140) uniform maskUniforms {
|
|
1849
1849
|
vec4 bounds;
|
|
1850
1850
|
highp int channel;
|
|
1851
1851
|
bool enabled;
|
|
1852
1852
|
bool inverted;
|
|
1853
1853
|
bool maskByInstance;
|
|
1854
1854
|
} mask;
|
|
1855
|
-
`,
|
|
1855
|
+
`,Lo=`
|
|
1856
1856
|
vec2 mask_getCoords(vec4 position) {
|
|
1857
1857
|
return (position.xy - mask.bounds.xy) / (mask.bounds.zw - mask.bounds.xy);
|
|
1858
1858
|
}
|
|
1859
|
-
`,
|
|
1860
|
-
${
|
|
1861
|
-
${
|
|
1862
|
-
`,
|
|
1859
|
+
`,So=`
|
|
1860
|
+
${Ct}
|
|
1861
|
+
${Lo}
|
|
1862
|
+
`,Io=`
|
|
1863
1863
|
uniform sampler2D mask_texture;
|
|
1864
1864
|
|
|
1865
1865
|
bool mask_isInBounds(vec2 texCoords) {
|
|
@@ -1884,10 +1884,10 @@ bool mask_isInBounds(vec2 texCoords) {
|
|
|
1884
1884
|
return maskValue < 0.5;
|
|
1885
1885
|
}
|
|
1886
1886
|
}
|
|
1887
|
-
`,
|
|
1888
|
-
${
|
|
1889
|
-
${
|
|
1890
|
-
`,
|
|
1887
|
+
`,Ro=`
|
|
1888
|
+
${Ct}
|
|
1889
|
+
${Io}
|
|
1890
|
+
`,Co={"vs:#decl":`
|
|
1891
1891
|
out vec2 mask_texCoords;
|
|
1892
1892
|
`,"vs:#main-end":`
|
|
1893
1893
|
vec4 mask_common_position;
|
|
@@ -1909,45 +1909,75 @@ in vec2 mask_texCoords;
|
|
|
1909
1909
|
|
|
1910
1910
|
if (!mask) discard;
|
|
1911
1911
|
}
|
|
1912
|
-
`},
|
|
1913
|
-
`),
|
|
1912
|
+
`},ko=r=>r&&"maskMap"in r?{mask_texture:r.maskMap}:r||{},kt={name:"mask",dependencies:[Rt.project],vs:So,fs:Ro,inject:Co,getUniforms:ko,uniformTypes:{bounds:"vec4<f32>",channel:"i32",enabled:"i32",inverted:"i32",maskByInstance:"i32"}};var Ee=d(_(),1);var wt=d(_(),1),wo={blendColorOperation:"subtract",blendColorSrcFactor:"zero",blendColorDstFactor:"one",blendAlphaOperation:"subtract",blendAlphaSrcFactor:"zero",blendAlphaDstFactor:"one"},U=class extends wt._LayersPass{constructor(e,t){super(e,t);let{mapSize:o=2048}=t;this.maskMap=e.createTexture({format:"rgba8unorm",width:o,height:o,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),this.fbo=e.createFramebuffer({id:"maskmap",width:o,height:o,colorAttachments:[this.maskMap]})}render(e){let t=2**e.channel,o=[255,255,255,255];super.render({...e,clearColor:o,colorMask:t,target:this.fbo,pass:"mask"})}getLayerParameters(e,t,o){return{...e.props.parameters,blend:!0,depthCompare:"always",...wo}}shouldDrawLayer(e){return e.props.operation.includes("mask")}delete(){this.fbo.delete(),this.maskMap.delete()}};var G=d(_(),1),Me=new G.WebMercatorViewport({width:1,height:1,longitude:0,latitude:0,zoom:0});function H(r){let[e,t]=Me.projectPosition(r);return[e,t]}function ae(r){return r.isGeospatial?Me:r}function T(r,e){let t=[1/0,1/0,-1/0,-1/0];for(let o of r){let i=o.getBounds();if(i){let s=o.projectPosition(i[0],{viewport:e,autoOffset:!1}),a=o.projectPosition(i[1],{viewport:e,autoOffset:!1});t[0]=Math.min(t[0],s[0]),t[1]=Math.min(t[1],s[1]),t[2]=Math.max(t[2],a[0]),t[3]=Math.max(t[3],a[1])}}return Number.isFinite(t[0])?t:null}var No=2048;function O(r){let{bounds:e,viewport:t,border:o=0}=r,{isGeospatial:i}=t;if(e[2]<=e[0]||e[3]<=e[1])return null;let s=i?Me.unprojectPosition([(e[0]+e[2])/2,(e[1]+e[3])/2,0]):t.unprojectPosition([(e[0]+e[2])/2,(e[1]+e[3])/2,0]),{width:a,height:n,zoom:l}=r;if(l===void 0){a=a-o*2,n=n-o*2;let c=Math.min(a/(e[2]-e[0]),n/(e[3]-e[1]));l=Math.min(Math.log2(c),20)}else if(!a||!n){let c=2**l;a=Math.round(Math.abs(e[2]-e[0])*c),n=Math.round(Math.abs(e[3]-e[1])*c);let p=No-o*2;if(a>p||n>p){let f=p/Math.max(a,n);a=Math.round(a*f),n=Math.round(n*f),l+=Math.log2(f)}}return i?new G.WebMercatorViewport({id:t.id,x:o,y:o,width:a,height:n,longitude:s[0],latitude:s[1],zoom:l,orthographic:!0}):new G.OrthographicViewport({id:t.id,x:o,y:o,width:a,height:n,target:s,zoom:l,flipY:!1})}function Bo(r,e){let t;if(e&&e.length===2){let[s,a]=e,n=r.getBounds({z:s}),l=r.getBounds({z:a});t=[Math.min(n[0],l[0]),Math.min(n[1],l[1]),Math.max(n[2],l[2]),Math.max(n[3],l[3])]}else t=r.getBounds();let o=r.projectPosition(t.slice(0,2)),i=r.projectPosition(t.slice(2,4));return[o[0],o[1],i[0],i[1]]}function A(r,e,t){if(!r)return[0,0,1,1];let o=Bo(e,t),i=Do(o);return r[2]-r[0]<=i[2]-i[0]&&r[3]-r[1]<=i[3]-i[1]?r:[Math.max(r[0],i[0]),Math.max(r[1],i[1]),Math.min(r[2],i[2]),Math.min(r[3],i[3])]}function Do(r){let e=r[2]-r[0],t=r[3]-r[1],o=(r[0]+r[2])/2,i=(r[1]+r[3])/2;return[o-e,i-t,o+e,i+t]}var q=class{constructor(){this.id="mask-effect",this.props=null,this.useInPicking=!0,this.order=0,this.channels=[],this.masks=null}setup({device:e}){this.dummyMaskMap=e.createTexture({width:1,height:1}),this.maskPass=new U(e,{id:"default-mask"}),this.maskMap=this.maskPass.maskMap}preRender({layers:e,layerFilter:t,viewports:o,onViewportActive:i,views:s,effects:a,isPicking:n}){let l=!1;if(n)return{didRender:l};let c=e.filter(m=>m.props.visible&&m.props.operation.includes("mask"));if(c.length===0)return this.masks=null,this.channels.length=0,{didRender:l};this.masks={};let p=this._sortMaskChannels(c),f=o[0],u=!this.lastViewport||!this.lastViewport.equals(f);if(f.resolution!==void 0)return Ee.log.warn("MaskExtension is not supported in GlobeView")(),{didRender:l};for(let m in p){let h=this._renderChannel(p[m],{layerFilter:t,onViewportActive:i,views:s,effects:a,viewport:f,viewportChanged:u});l||(l=h)}return{didRender:l}}_renderChannel(e,{layerFilter:t,onViewportActive:o,views:i,effects:s,viewport:a,viewportChanged:n}){let l=!1,c=this.channels[e.index];if(!c)return l;let p=e===c||e.layers.length!==c.layers.length||e.layers.some((f,u)=>f!==c.layers[u]||f.props.transitions)||e.layerBounds.some((f,u)=>f!==c.layerBounds[u]);if(e.bounds=c.bounds,e.maskBounds=c.maskBounds,this.channels[e.index]=e,p||n){this.lastViewport=a;let f=T(e.layers,a);if(e.bounds=f&&A(f,a),p||!E(e.bounds,c.bounds)){let{maskPass:u,maskMap:m}=this,h=f&&O({bounds:e.bounds,viewport:a,width:m.width,height:m.height,border:1});e.maskBounds=h?h.getBounds():[0,0,1,1],u.render({pass:"mask",channel:e.index,layers:e.layers,layerFilter:t,viewports:h?[h]:[],onViewportActive:o,views:i,effects:s,shaderModuleProps:{project:{devicePixelRatio:1}}}),l=!0}}return this.masks[e.id]={index:e.index,bounds:e.maskBounds,coordinateOrigin:e.coordinateOrigin,coordinateSystem:e.coordinateSystem},l}_sortMaskChannels(e){let t={},o=0;for(let i of e){let{id:s}=i.root,a=t[s];if(!a){if(++o>4){Ee.log.warn("Too many mask layers. The max supported is 4")();continue}a={id:s,index:this.channels.findIndex(n=>n?.id===s),layers:[],layerBounds:[],coordinateOrigin:i.root.props.coordinateOrigin,coordinateSystem:i.root.props.coordinateSystem},t[s]=a}a.layers.push(i),a.layerBounds.push(i.getBounds())}for(let i=0;i<4;i++){let s=this.channels[i];(!s||!(s.id in t))&&(this.channels[i]=null)}for(let i in t){let s=t[i];s.index<0&&(s.index=this.channels.findIndex(a=>!a),this.channels[s.index]=s)}return t}getShaderModuleProps(){return{mask:{maskMap:this.masks?this.maskMap:this.dummyMaskMap,maskChannels:this.masks}}}cleanup(){this.dummyMaskMap&&(this.dummyMaskMap.delete(),this.dummyMaskMap=void 0),this.maskPass&&(this.maskPass.delete(),this.maskPass=void 0,this.maskMap=void 0),this.lastViewport=void 0,this.masks=null,this.channels.length=0}};var zo={maskId:"",maskByInstance:void 0,maskInverted:!1},W=class extends P.LayerExtension{initializeState(){this.context.deck?._addDefaultEffect(new q)}getShaders(){let e="instancePositions"in this.getAttributeManager().attributes;return this.props.maskByInstance!==void 0&&(e=Boolean(this.props.maskByInstance)),this.state.maskByInstance=e,{modules:[kt]}}draw({context:e,shaderModuleProps:t}){let o={};o.maskByInstance=Boolean(this.state.maskByInstance);let{maskId:i,maskInverted:s}=this.props,{maskChannels:a}=t.mask||{},{viewport:n}=e;if(a&&a[i]){let{index:l,bounds:c,coordinateOrigin:p}=a[i],{coordinateSystem:f}=a[i];o.enabled=!0,o.channel=l,o.inverted=s,f===P.COORDINATE_SYSTEM.DEFAULT&&(f=n.isGeospatial?P.COORDINATE_SYSTEM.LNGLAT:P.COORDINATE_SYSTEM.CARTESIAN);let u={modelMatrix:null,fromCoordinateOrigin:p,fromCoordinateSystem:f},m=this.projectPosition([c[0],c[1],0],u),h=this.projectPosition([c[2],c[3],0],u);o.bounds=[m[0],m[1],h[0],h[1]]}else i&&P.log.warn(`Could not find a mask layer with id: ${i}`)(),o.enabled=!1;this.setShaderModuleProps({mask:o})}};W.defaultProps=zo;W.extensionName="MaskExtension";var Nt=W;var qt=d(_(),1);var Ht=d(_(),1);var Fe=d(_(),1),g={NONE:0,WRITE_HEIGHT_MAP:1,USE_HEIGHT_MAP:2,USE_COVER:3,USE_COVER_ONLY:4,SKIP:5},Vo=Object.keys(g).map(r=>`const float TERRAIN_MODE_${r} = ${g[r]}.0;`).join(`
|
|
1913
|
+
`),Bt=Vo+`
|
|
1914
1914
|
layout(std140) uniform terrainUniforms {
|
|
1915
1915
|
float mode;
|
|
1916
1916
|
vec4 bounds;
|
|
1917
1917
|
} terrain;
|
|
1918
1918
|
|
|
1919
1919
|
uniform sampler2D terrain_map;
|
|
1920
|
-
`,
|
|
1920
|
+
`,K={name:"terrain",dependencies:[Fe.project],vs:`${Bt}
|
|
1921
|
+
out vec3 commonPos;
|
|
1922
|
+
// In globe mode, absolute Mercator position for terrain FBO UV lookups
|
|
1923
|
+
out vec2 terrainMercPos;
|
|
1924
|
+
out float terrainHeight;
|
|
1925
|
+
|
|
1926
|
+
vec2 terrain_globe_to_mercator(vec3 globePosition) {
|
|
1927
|
+
float D = length(globePosition);
|
|
1928
|
+
float sinLat = clamp(globePosition.z / D, -0.999998, 0.999998);
|
|
1929
|
+
float x = atan(globePosition.x, -globePosition.y);
|
|
1930
|
+
float y = atanh(sinLat);
|
|
1931
|
+
return (vec2(x, y) + PI) * WORLD_SCALE;
|
|
1932
|
+
}
|
|
1933
|
+
`,fs:`${Bt}in vec2 terrainMercPos;
|
|
1934
|
+
in float terrainHeight;`,inject:{"vs:#main-start":`
|
|
1921
1935
|
if (terrain.mode == TERRAIN_MODE_SKIP) {
|
|
1922
1936
|
gl_Position = vec4(0.0);
|
|
1923
1937
|
return;
|
|
1924
1938
|
}
|
|
1925
1939
|
`,"vs:DECKGL_FILTER_GL_POSITION":`
|
|
1926
1940
|
commonPos = geometry.position.xyz;
|
|
1941
|
+
terrainHeight = commonPos.z + project.commonOrigin.z;
|
|
1942
|
+
if (project.projectionMode == PROJECTION_MODE_GLOBE) {
|
|
1943
|
+
terrainMercPos = terrain_globe_to_mercator(commonPos);
|
|
1944
|
+
terrainHeight = length(commonPos) - GLOBE_RADIUS;
|
|
1945
|
+
} else {
|
|
1946
|
+
terrainMercPos = commonPos.xy;
|
|
1947
|
+
}
|
|
1927
1948
|
if (terrain.mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
|
|
1928
|
-
vec2 texCoords = (
|
|
1949
|
+
vec2 texCoords = (terrainMercPos - terrain.bounds.xy) / terrain.bounds.zw;
|
|
1929
1950
|
position = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0);
|
|
1930
|
-
commonPos.z += project.commonOrigin.z;
|
|
1931
1951
|
}
|
|
1932
1952
|
if (terrain.mode == TERRAIN_MODE_USE_HEIGHT_MAP) {
|
|
1933
1953
|
vec3 anchor = geometry.worldPosition;
|
|
1934
1954
|
anchor.z = 0.0;
|
|
1935
1955
|
vec3 anchorCommon = project_position(anchor);
|
|
1936
|
-
vec2
|
|
1956
|
+
vec2 anchorMercPos = project.projectionMode == PROJECTION_MODE_GLOBE
|
|
1957
|
+
? terrain_globe_to_mercator(anchorCommon)
|
|
1958
|
+
: anchorCommon.xy;
|
|
1959
|
+
vec2 texCoords = (anchorMercPos - terrain.bounds.xy) / terrain.bounds.zw;
|
|
1937
1960
|
if (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) {
|
|
1938
1961
|
float terrainZ = texture(terrain_map, texCoords).r;
|
|
1939
|
-
|
|
1962
|
+
if (project.projectionMode == PROJECTION_MODE_GLOBE) {
|
|
1963
|
+
// Height map is written in Mercator common space (units = TILE_SIZE / EARTH_CIRCUMFERENCE / cos(lat))
|
|
1964
|
+
// Convert to globe radial units (units = GLOBE_RADIUS / EARTH_RADIUS)
|
|
1965
|
+
terrainZ *= cos(radians(geometry.worldPosition.y)) * PI;
|
|
1966
|
+
geometry.position.xyz += normalize(geometry.position.xyz) * terrainZ;
|
|
1967
|
+
} else {
|
|
1968
|
+
geometry.position.z += terrainZ;
|
|
1969
|
+
}
|
|
1940
1970
|
position = project_common_position_to_clipspace(geometry.position);
|
|
1941
1971
|
}
|
|
1942
1972
|
}
|
|
1943
1973
|
`,"fs:#main-start":`
|
|
1944
1974
|
if (terrain.mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
|
|
1945
|
-
fragColor = vec4(
|
|
1975
|
+
fragColor = vec4(terrainHeight, 0.0, 0.0, 1.0);
|
|
1946
1976
|
return;
|
|
1947
1977
|
}
|
|
1948
1978
|
`,"fs:DECKGL_FILTER_COLOR":`
|
|
1949
1979
|
if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_USE_COVER_ONLY)) {
|
|
1950
|
-
vec2 texCoords = (
|
|
1980
|
+
vec2 texCoords = (terrainMercPos - terrain.bounds.xy) / terrain.bounds.zw;
|
|
1951
1981
|
vec4 pixel = texture(terrain_map, texCoords);
|
|
1952
1982
|
if (terrain.mode == TERRAIN_MODE_USE_COVER_ONLY) {
|
|
1953
1983
|
color = pixel;
|
|
@@ -1957,6 +1987,6 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
1957
1987
|
}
|
|
1958
1988
|
return;
|
|
1959
1989
|
}
|
|
1960
|
-
`},getUniforms:(r={})=>{if(!r.dummyHeightMap)return{};if("terrainSkipRender"in r||"drawToTerrainHeightMap"in r){let{drawToTerrainHeightMap:e,heightMap:t,heightMapBounds:i,dummyHeightMap:o,terrainCover:s,useTerrainHeightMap:a,terrainSkipRender:n}=r,l=be.project.getUniforms(r.project),{commonOrigin:f}=l,p=n?g.SKIP:g.NONE,c=o,u=null;if(e)p=g.WRITE_HEIGHT_MAP,u=i;else if(a&&t)p=g.USE_HEIGHT_MAP,c=t,u=i;else if(s){let h=(r.isPicking?s.getPickingFramebuffer():s.getRenderFramebuffer())?.colorAttachments[0].texture;r.isPicking&&(p=g.SKIP),h?(c=h,p=p===g.SKIP?g.USE_COVER_ONLY:g.USE_COVER,u=s.bounds):r.isPicking&&!n&&(p=g.NONE)}return{mode:p,terrain_map:c,bounds:u?[u[0]-f[0],u[1]-f[1],u[2]-u[0],u[3]-u[1]]:[0,0,0,0]}}return{mode:g.NONE,terrain_map:r.dummyHeightMap,bounds:[0,0,0,0]}},uniformTypes:{mode:"f32",bounds:"vec4<f32>"}};function W(r,e){return r.createFramebuffer({id:e.id,colorAttachments:[r.createTexture({id:e.id,...e.float&&{format:"rgba32float",type:5126},dimension:"2d",width:1,height:1,sampler:e.interpolate===!1?{minFilter:"nearest",magFilter:"nearest"}:{minFilter:"linear",magFilter:"linear"}})]})}var se=class{constructor(e){this.isDirty=!0,this.renderViewport=null,this.bounds=null,this.layers=[],this.targetBounds=null,this.targetBoundsCommon=null,this.targetLayer=e,this.tile=wt(e)}get id(){return this.targetLayer.id}get isActive(){return Boolean(this.targetLayer.getCurrentLayer())}shouldUpdate({targetLayer:e,viewport:t,layers:i,layerNeedsRedraw:o}){e&&(this.targetLayer=e);let s=t?this._updateViewport(t):!1,a=i?this._updateLayers(i):!1;if(o){for(let n of this.layers)if(o[n]){a=!0;break}}return a||s}_updateLayers(e){let t=!1;if(e=this.tile?wi(this.tile,e):e,e.length!==this.layers.length)t=!0;else for(let i=0;i<e.length;i++)if(e[i].id!==this.layers[i]){t=!0;break}return t&&(this.layers=e.map(i=>i.id)),t}_updateViewport(e){let t=this.targetLayer,i=!1;if(this.tile&&"boundingBox"in this.tile){if(!this.targetBounds){i=!0,this.targetBounds=this.tile.boundingBox;let s=e.projectPosition(this.targetBounds[0]),a=e.projectPosition(this.targetBounds[1]);this.targetBoundsCommon=[s[0],s[1],a[0],a[1]]}}else this.targetBounds!==t.getBounds()&&(i=!0,this.targetBounds=t.getBounds(),this.targetBoundsCommon=T([t],e));if(!this.targetBoundsCommon)return!1;let o=Math.ceil(e.zoom+.5);if(this.tile)this.bounds=this.targetBoundsCommon;else{let s=this.renderViewport?.zoom;i=i||o!==s;let a=L(this.targetBoundsCommon,e),n=this.bounds;i=i||!n||a.some((l,f)=>l!==n[f]),this.bounds=a}return i&&(this.renderViewport=A({bounds:this.bounds,zoom:o,viewport:e})),i}getRenderFramebuffer(){return!this.renderViewport||this.layers.length===0?null:(this.fbo||(this.fbo=W(this.targetLayer.context.device,{id:this.id})),this.fbo)}getPickingFramebuffer(){return!this.renderViewport||this.layers.length===0&&!this.targetLayer.props.pickable?null:(this.pickingFbo||(this.pickingFbo=W(this.targetLayer.context.device,{id:`${this.id}-picking`,interpolate:!1})),this.pickingFbo)}filterLayers(e){return e.filter(({id:t})=>this.layers.includes(t))}delete(){let{fbo:e,pickingFbo:t}=this;e&&(e.colorAttachments[0].destroy(),e.destroy()),t&&(t.colorAttachments[0].destroy(),t.destroy())}};function wi(r,e){return e.filter(t=>{let i=wt(t);return i?Ni(r.boundingBox,i.boundingBox):!0})}function wt(r){for(;r;){let{tile:e}=r.props;if(e)return e;r=r.parent}return null}function Ni(r,e){return r&&e?r[0][0]<e[1][0]&&e[0][0]<r[1][0]&&r[0][1]<e[1][1]&&e[0][1]<r[1][1]:!1}var Nt=d(_(),1),Bi={blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},ae=class extends Nt._LayersPass{getRenderableLayers(e,t){let{layers:i}=t,o=[],s=this._getDrawLayerParams(e,t,!0);for(let a=0;a<i.length;a++){let n=i[a];!n.isComposite&&s[a].shouldDrawLayer&&o.push(n)}return o}renderHeightMap(e,t){let i=e.getRenderFramebuffer(),o=e.renderViewport;!i||!o||(i.resize(o),this.render({...t,target:i,pass:"terrain-height-map",layers:t.layers,viewports:[o],effects:[],clearColor:[0,0,0,0]}))}renderTerrainCover(e,t){let i=e.getRenderFramebuffer(),o=e.renderViewport;if(!i||!o)return;let s=e.filterLayers(t.layers);i.resize(o),this.render({...t,target:i,pass:`terrain-cover-${e.id}`,layers:s,viewports:[o],clearColor:[0,0,0,0]})}getLayerParameters(e,t,i){return{...e.props.parameters,blend:!0,depthCompare:"always",...e.props.operation.includes("terrain")&&Bi}}getShaderModuleProps(e,t,i){return{terrain:{project:i.project}}}};var Bt=d(_(),1),ne=class extends Bt._PickLayersPass{constructor(){super(...arguments),this.drawParameters={}}getRenderableLayers(e,t){let{layers:i}=t,o=[];this.drawParameters={},this._resetColorEncoder(t.pickZ);let s=this._getDrawLayerParams(e,t);for(let a=0;a<i.length;a++){let n=i[a];!n.isComposite&&s[a].shouldDrawLayer&&(o.push(n),this.drawParameters[n.id]=s[a].layerParameters)}return o}renderTerrainCover(e,t){let i=e.getPickingFramebuffer(),o=e.renderViewport;if(!i||!o)return;let s=e.filterLayers(t.layers),a=e.targetLayer;a.props.pickable&&s.unshift(a),i.resize(o);let l=this.drawParameters[a.id]?.blendColor?.[3]??0;this.render({...t,pickingFBO:i,pass:`terrain-cover-picking-${e.id}`,layers:s,viewports:[o],cullRect:void 0,deviceRect:o,pickZ:!1,clearColor:[0,0,0,l]})}getLayerParameters(e,t,i){let o;return this.drawParameters[e.id]?o=this.drawParameters[e.id]:(o=super.getLayerParameters(e,t,i),o.blend=!0),{...o,depthCompare:"always",blendAlphaSrcFactor:"constant"}}getShaderModuleProps(e,t,i){return{...super.getShaderModuleProps(e,t,i),terrain:{project:i.project}}}};var Dt=2048,K=class{static isSupported(e){return e.isTextureFormatRenderable("rgba32float")}constructor(e){this.renderViewport=null,this.bounds=null,this.layers=[],this.layersBounds=[],this.layersBoundsCommon=null,this.lastViewport=null,this.device=e}getRenderFramebuffer(){return this.renderViewport?(this.fbo||(this.fbo=W(this.device,{id:"height-map",float:!0})),this.fbo):null}shouldUpdate({layers:e,viewport:t}){let i=e.length!==this.layers.length||e.some((s,a)=>s!==this.layers[a]||s.props.transitions||s.getBounds()!==this.layersBounds[a]);i&&(this.layers=e,this.layersBounds=e.map(s=>s.getBounds()),this.layersBoundsCommon=T(e,t));let o=!this.lastViewport||!t.equals(this.lastViewport);if(!this.layersBoundsCommon)this.renderViewport=null;else if(i||o){let s=L(this.layersBoundsCommon,t);if(s[2]<=s[0]||s[3]<=s[1])return this.renderViewport=null,!1;this.bounds=s,this.lastViewport=t;let a=t.scale,n=(s[2]-s[0])*a,l=(s[3]-s[1])*a;return this.renderViewport=n>0||l>0?A({bounds:[t.center[0]-1,t.center[1]-1,t.center[0]+1,t.center[1]+1],zoom:t.zoom,width:Math.min(n,Dt),height:Math.min(l,Dt),viewport:t}):null,!0}return!1}delete(){this.fbo&&(this.fbo.colorAttachments[0].delete(),this.fbo.delete())}};var le=class{constructor(){this.id="terrain-effect",this.props=null,this.useInPicking=!0,this.isPicking=!1,this.isDrapingEnabled=!1,this.terrainCovers=new Map}setup({device:e,deck:t}){this.dummyHeightMap=e.createTexture({width:1,height:1,data:new Uint8Array([0,0,0,0])}),this.terrainPass=new ae(e,{id:"terrain"}),this.terrainPickingPass=new ne(e,{id:"terrain-picking"}),K.isSupported(e)?this.heightMap=new K(e):zt.log.warn("Terrain offset mode is not supported by this browser")(),t._addDefaultShaderModule(q)}preRender(e){if(e.pickZ){this.isDrapingEnabled=!1;return}let{viewports:t}=e,i=e.pass.startsWith("picking");this.isPicking=i,this.isDrapingEnabled=!0;let o=t[0],s=(i?this.terrainPickingPass:this.terrainPass).getRenderableLayers(o,e),a=s.filter(f=>f.props.operation.includes("terrain"));if(a.length===0)return;i||s.filter(p=>p.state.terrainDrawMode==="offset").length>0&&this._updateHeightMap(a,o,e);let n=s.filter(f=>f.state.terrainDrawMode==="drape"),l=e.effects?.filter(f=>f!==this);this._updateTerrainCovers(a,n,o,{...e,effects:l})}getShaderModuleProps(e,t){if(e.props.operation.includes("mask"))return{terrain:{dummyHeightMap:this.dummyHeightMap}};let{terrainDrawMode:i}=e.state,o=this.isDrapingEnabled?this.terrainCovers.get(e.id)??null:null;return this.isPicking&&e.props.operation.includes("terrain")&&(e.state._hasPickingCover=Boolean(o?.getPickingFramebuffer())),{terrain:{project:t.project,isPicking:this.isPicking,heightMap:this.heightMap?.getRenderFramebuffer()?.colorAttachments[0].texture||null,heightMapBounds:this.heightMap?.bounds,dummyHeightMap:this.dummyHeightMap,terrainCover:o,useTerrainHeightMap:i==="offset",terrainSkipRender:i==="drape"||!e.props.operation.includes("draw")}}}cleanup({deck:e}){this.dummyHeightMap&&(this.dummyHeightMap.delete(),this.dummyHeightMap=void 0),this.heightMap&&(this.heightMap.delete(),this.heightMap=void 0);for(let t of this.terrainCovers.values())t.delete();this.terrainCovers.clear(),e._removeDefaultShaderModule(q)}_updateHeightMap(e,t,i){!this.heightMap||!this.heightMap.shouldUpdate({layers:e,viewport:t})||this.terrainPass.renderHeightMap(this.heightMap,{...i,layers:e,shaderModuleProps:{terrain:{heightMapBounds:this.heightMap.bounds,dummyHeightMap:this.dummyHeightMap,drawToTerrainHeightMap:!0},project:{devicePixelRatio:1}}})}_updateTerrainCovers(e,t,i,o){let s={};for(let a of t)a.state.terrainCoverNeedsRedraw&&(s[a.id]=!0,a.state.terrainCoverNeedsRedraw=!1);for(let a of this.terrainCovers.values())a.isDirty=a.isDirty||a.shouldUpdate({layerNeedsRedraw:s});for(let a of e)this._updateTerrainCover(a,t,i,o);this.isPicking||this._pruneTerrainCovers()}_updateTerrainCover(e,t,i,o){let s=this.isPicking?this.terrainPickingPass:this.terrainPass,a=this.terrainCovers.get(e.id);a||(a=new se(e),this.terrainCovers.set(e.id,a));try{let n=a.shouldUpdate({targetLayer:e,viewport:i,layers:t});(this.isPicking||a.isDirty||n)&&(s.renderTerrainCover(a,{...o,layers:t,shaderModuleProps:{terrain:{dummyHeightMap:this.dummyHeightMap,terrainSkipRender:!1},project:{devicePixelRatio:1}}}),this.isPicking||(a.isDirty=!1))}catch(n){e.raiseError(n,`Error rendering terrain cover ${a.id}`)}}_pruneTerrainCovers(){let e=[];for(let[t,i]of this.terrainCovers)i.isActive||e.push(t);for(let t of e)this.terrainCovers.delete(t)}};var Di={terrainDrawMode:void 0},Y=class extends Vt.LayerExtension{getShaders(){return{modules:[q]}}initializeState(){this.context.deck?._addDefaultEffect(new le)}updateState(e){let{props:t,oldProps:i}=e;if(this.state.terrainDrawMode&&t.terrainDrawMode===i.terrainDrawMode&&t.extruded===i.extruded)return;let{terrainDrawMode:o}=t;if(!o){let s=this.props.extruded,a=this.getAttributeManager()?.attributes,n=a&&"instancePositions"in a;o=s||n?"offset":"drape"}this.setState({terrainDrawMode:o})}onNeedsRedraw(){let e=this.state;e.terrainDrawMode==="drape"&&(e.terrainCoverNeedsRedraw=!0)}};Y.defaultProps=Di;Y.extensionName="TerrainExtension";var jt=Y;return Kt($);})();
|
|
1990
|
+
`},getUniforms:(r={})=>{if(!r.dummyHeightMap)return{};if("terrainSkipRender"in r||"drawToTerrainHeightMap"in r){let{drawToTerrainHeightMap:e,heightMap:t,heightMapBounds:o,dummyHeightMap:i,terrainCover:s,useTerrainHeightMap:a,terrainSkipRender:n}=r,l=Fe.project.getUniforms(r.project),{commonOrigin:c}=l,p=n?g.SKIP:g.NONE,f=i,u=null;if(e)p=g.WRITE_HEIGHT_MAP,u=o;else if(a&&t)p=g.USE_HEIGHT_MAP,f=t,u=o;else if(s){let h=(r.isPicking?s.getPickingFramebuffer():s.getRenderFramebuffer())?.colorAttachments[0].texture;r.isPicking&&(p=g.SKIP),h?(f=h,p=p===g.SKIP?g.USE_COVER_ONLY:g.USE_COVER,u=s.bounds):r.isPicking&&!n&&(p=g.NONE)}return{mode:p,terrain_map:f,bounds:u?[u[0]-c[0],u[1]-c[1],u[2]-u[0],u[3]-u[1]]:[0,0,0,0]}}return{mode:g.NONE,terrain_map:r.dummyHeightMap,bounds:[0,0,0,0]}},uniformTypes:{mode:"f32",bounds:"vec4<f32>"}};var Dt=d(_(),1);function Y(r,e){return r.createFramebuffer({id:e.id,colorAttachments:[r.createTexture({id:e.id,...e.float&&{format:"rgba32float",type:5126},dimension:"2d",width:1,height:1,sampler:e.interpolate===!1?{minFilter:"nearest",magFilter:"nearest"}:{minFilter:"linear",magFilter:"linear"}})]})}var ne=class{constructor(e){this.isDirty=!0,this.renderViewport=null,this.bounds=null,this.layers=[],this.targetBounds=null,this.targetBoundsCommon=null,this.targetLayer=e,this.tile=zt(e)}get id(){return this.targetLayer.id}get isActive(){return Boolean(this.targetLayer.getCurrentLayer())}shouldUpdate({targetLayer:e,viewport:t,layers:o,layerNeedsRedraw:i}){e&&(this.targetLayer=e);let s=t?this._updateViewport(t):!1,a=o?this._updateLayers(o):!1;if(i){for(let n of this.layers)if(i[n]){a=!0;break}}return a||s}_updateLayers(e){let t=!1;if(e=this.tile?jo(this.tile,e):e,e.length!==this.layers.length)t=!0;else for(let o=0;o<e.length;o++)if(e[o].id!==this.layers[o]){t=!0;break}return t&&(this.layers=e.map(o=>o.id)),t}_updateViewport(e){let t=this.targetLayer,o=!1;if(this.tile&&"boundingBox"in this.tile){if(!this.targetBounds){o=!0,this.targetBounds=this.tile.boundingBox;let s=H(this.targetBounds[0]),a=H(this.targetBounds[1]);this.targetBoundsCommon=[s[0],s[1],a[0],a[1]]}}else this.targetBounds!==t.getBounds()&&(o=!0,this.targetBounds=t.getBounds(),this.targetBoundsCommon=T([t],ae(e)));if(!this.targetBoundsCommon)return!1;let i=Math.ceil(e.zoom+.5);if(this.tile)this.bounds=this.targetBoundsCommon;else{let s=this.renderViewport?.zoom;o=o||i!==s;let a=e instanceof Dt._GlobeViewport?this.targetBoundsCommon:A(this.targetBoundsCommon,e),n=this.bounds;o=o||!n||a.some((l,c)=>l!==n[c]),this.bounds=a}return o&&(this.renderViewport=O({bounds:this.bounds,zoom:i,viewport:e})),o}getRenderFramebuffer(){return!this.renderViewport||this.layers.length===0?null:(this.fbo||(this.fbo=Y(this.targetLayer.context.device,{id:this.id})),this.fbo)}getPickingFramebuffer(){return!this.renderViewport||this.layers.length===0&&!this.targetLayer.props.pickable?null:(this.pickingFbo||(this.pickingFbo=Y(this.targetLayer.context.device,{id:`${this.id}-picking`,interpolate:!1})),this.pickingFbo)}filterLayers(e){return e.filter(({id:t})=>this.layers.includes(t))}delete(){let{fbo:e,pickingFbo:t}=this;e&&(e.colorAttachments[0].destroy(),e.destroy()),t&&(t.colorAttachments[0].destroy(),t.destroy())}};function jo(r,e){return e.filter(t=>{let o=zt(t);return o?Uo(r.boundingBox,o.boundingBox):!0})}function zt(r){for(;r;){let{tile:e}=r.props;if(e)return e;r=r.parent}return null}function Uo(r,e){return r&&e?r[0][0]<e[1][0]&&e[0][0]<r[1][0]&&r[0][1]<e[1][1]&&e[0][1]<r[1][1]:!1}var Vt=d(_(),1),Go={blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},le=class extends Vt._LayersPass{getRenderableLayers(e,t){let{layers:o}=t,i=[],s=this._getDrawLayerParams(e,t,!0);for(let a=0;a<o.length;a++){let n=o[a];!n.isComposite&&s[a].shouldDrawLayer&&i.push(n)}return i}renderHeightMap(e,t){let o=e.getRenderFramebuffer(),i=e.renderViewport;!o||!i||(o.resize(i),this.render({...t,target:o,pass:"terrain-height-map",layers:t.layers,viewports:[i],effects:[],clearColor:[0,0,0,0]}))}renderTerrainCover(e,t){let o=e.getRenderFramebuffer(),i=e.renderViewport;if(!o||!i)return;let s=e.filterLayers(t.layers);o.resize(i),this.render({...t,target:o,pass:`terrain-cover-${e.id}`,layers:s,viewports:[i],clearColor:[0,0,0,0]})}getLayerParameters(e,t,o){return{...e.props.parameters,blend:!0,depthCompare:"always",...e.props.operation.includes("terrain")&&Go}}getShaderModuleProps(e,t,o){return{terrain:{project:o.project}}}};var jt=d(_(),1),ce=class extends jt._PickLayersPass{constructor(){super(...arguments),this.drawParameters={}}getRenderableLayers(e,t){let{layers:o}=t,i=[];this.drawParameters={},this._resetColorEncoder(t.pickZ);let s=this._getDrawLayerParams(e,t);for(let a=0;a<o.length;a++){let n=o[a];!n.isComposite&&s[a].shouldDrawLayer&&(i.push(n),this.drawParameters[n.id]=s[a].layerParameters)}return i}renderTerrainCover(e,t){let o=e.getPickingFramebuffer(),i=e.renderViewport;if(!o||!i)return;let s=e.filterLayers(t.layers),a=e.targetLayer;a.props.pickable&&s.unshift(a),o.resize(i);let l=this.drawParameters[a.id]?.blendColor?.[3]??0;this.render({...t,pickingFBO:o,pass:`terrain-cover-picking-${e.id}`,layers:s,viewports:[i],cullRect:void 0,deviceRect:i,pickZ:!1,clearColor:[0,0,0,l]})}getLayerParameters(e,t,o){let i;return this.drawParameters[e.id]?i=this.drawParameters[e.id]:(i=super.getLayerParameters(e,t,o),i.blend=!0),{...i,depthCompare:"always",blendAlphaSrcFactor:"constant"}}getShaderModuleProps(e,t,o){return{...super.getShaderModuleProps(e,t,o),terrain:{project:o.project}}}};var Gt=d(_(),1),Ut=2048,$=class{static isSupported(e){return e.isTextureFormatRenderable("rgba32float")}constructor(e){this.renderViewport=null,this.bounds=null,this.layers=[],this.layersBounds=[],this.layersBoundsCommon=null,this.lastViewport=null,this.device=e}getRenderFramebuffer(){return this.renderViewport?(this.fbo||(this.fbo=Y(this.device,{id:"height-map",float:!0})),this.fbo):null}shouldUpdate({layers:e,viewport:t}){let o=e.length!==this.layers.length||e.some((s,a)=>s!==this.layers[a]||s.props.transitions||s.getBounds()!==this.layersBounds[a]);o&&(this.layers=e,this.layersBounds=e.map(s=>s.getBounds()),this.layersBoundsCommon=T(e,ae(t)));let i=!this.lastViewport||!t.equals(this.lastViewport);if(!this.layersBoundsCommon)this.renderViewport=null;else if(o||i){let s=t instanceof Gt._GlobeViewport?this.layersBoundsCommon:A(this.layersBoundsCommon,t);if(s[2]<=s[0]||s[3]<=s[1])return this.renderViewport=null,!1;this.bounds=s,this.lastViewport=t;let a=t.scale,n=(s[2]-s[0])*a,l=(s[3]-s[1])*a,c=t.isGeospatial?H([t.longitude??0,t.latitude??0]):[t.center[0],t.center[1]];return this.renderViewport=n>0||l>0?O({bounds:[c[0]-1,c[1]-1,c[0]+1,c[1]+1],zoom:t.zoom,width:Math.min(n,Ut),height:Math.min(l,Ut),viewport:t}):null,!0}return!1}delete(){this.fbo&&(this.fbo.colorAttachments[0].delete(),this.fbo.delete())}};var fe=class{constructor(){this.id="terrain-effect",this.props=null,this.useInPicking=!0,this.isPicking=!1,this.isDrapingEnabled=!1,this.terrainCovers=new Map}setup({device:e,deck:t}){this.dummyHeightMap=e.createTexture({width:1,height:1,data:new Uint8Array([0,0,0,0])}),this.terrainPass=new le(e,{id:"terrain"}),this.terrainPickingPass=new ce(e,{id:"terrain-picking"}),$.isSupported(e)?this.heightMap=new $(e):Ht.log.warn("Terrain offset mode is not supported by this browser")(),t._addDefaultShaderModule(K)}preRender(e){if(e.pickZ){this.isDrapingEnabled=!1;return}let{viewports:t}=e,o=e.pass.startsWith("picking");this.isPicking=o,this.isDrapingEnabled=!0;let i=t[0],s=(o?this.terrainPickingPass:this.terrainPass).getRenderableLayers(i,e),a=s.filter(c=>c.props.operation.includes("terrain"));if(a.length===0)return;o||s.filter(p=>p.state.terrainDrawMode==="offset").length>0&&this._updateHeightMap(a,i,e);let n=s.filter(c=>c.state.terrainDrawMode==="drape"),l=e.effects?.filter(c=>c!==this);this._updateTerrainCovers(a,n,i,{...e,effects:l})}getShaderModuleProps(e,t){if(e.props.operation.includes("mask"))return{terrain:{dummyHeightMap:this.dummyHeightMap}};let{terrainDrawMode:o}=e.state,i=this.isDrapingEnabled?this.terrainCovers.get(e.id)??null:null;return this.isPicking&&e.props.operation.includes("terrain")&&(e.state._hasPickingCover=Boolean(i?.getPickingFramebuffer())),{terrain:{project:t.project,isPicking:this.isPicking,heightMap:this.heightMap?.getRenderFramebuffer()?.colorAttachments[0].texture||null,heightMapBounds:this.heightMap?.bounds,dummyHeightMap:this.dummyHeightMap,terrainCover:i,useTerrainHeightMap:o==="offset",terrainSkipRender:o==="drape"||!e.props.operation.includes("draw")}}}cleanup({deck:e}){this.dummyHeightMap&&(this.dummyHeightMap.delete(),this.dummyHeightMap=void 0),this.heightMap&&(this.heightMap.delete(),this.heightMap=void 0);for(let t of this.terrainCovers.values())t.delete();this.terrainCovers.clear(),e._removeDefaultShaderModule(K)}_updateHeightMap(e,t,o){!this.heightMap||!this.heightMap.shouldUpdate({layers:e,viewport:t})||this.terrainPass.renderHeightMap(this.heightMap,{...o,layers:e,shaderModuleProps:{terrain:{heightMapBounds:this.heightMap.bounds,dummyHeightMap:this.dummyHeightMap,drawToTerrainHeightMap:!0},project:{devicePixelRatio:1}}})}_updateTerrainCovers(e,t,o,i){let s={};for(let a of t)a.state.terrainCoverNeedsRedraw&&(s[a.id]=!0,a.state.terrainCoverNeedsRedraw=!1);for(let a of this.terrainCovers.values())a.isDirty=a.isDirty||a.shouldUpdate({layerNeedsRedraw:s});for(let a of e)this._updateTerrainCover(a,t,o,i);this.isPicking||this._pruneTerrainCovers()}_updateTerrainCover(e,t,o,i){let s=this.isPicking?this.terrainPickingPass:this.terrainPass,a=this.terrainCovers.get(e.id);a||(a=new ne(e),this.terrainCovers.set(e.id,a));try{let n=a.shouldUpdate({targetLayer:e,viewport:o,layers:t});(this.isPicking||a.isDirty||n)&&(s.renderTerrainCover(a,{...i,layers:t,shaderModuleProps:{terrain:{dummyHeightMap:this.dummyHeightMap,terrainSkipRender:!1},project:{devicePixelRatio:1}}}),this.isPicking||(a.isDirty=!1))}catch(n){e.raiseError(n,`Error rendering terrain cover ${a.id}`)}}_pruneTerrainCovers(){let e=[];for(let[t,o]of this.terrainCovers)o.isActive||e.push(t);for(let t of e)this.terrainCovers.delete(t)}};var Ho={terrainDrawMode:void 0},Z=class extends qt.LayerExtension{getShaders(){return{modules:[K]}}initializeState(){this.context.deck?._addDefaultEffect(new fe)}updateState(e){let{props:t,oldProps:o}=e;if(this.state.terrainDrawMode&&t.terrainDrawMode===o.terrainDrawMode&&t.extruded===o.extruded)return;let{terrainDrawMode:i}=t;if(!i){let s=this.props.extruded,a=this.getAttributeManager()?.attributes,n=a&&"instancePositions"in a;i=s||n?"offset":"drape"}this.setState({terrainDrawMode:i})}onNeedsRedraw(){let e=this.state;e.terrainDrawMode==="drape"&&(e.terrainCoverNeedsRedraw=!0)}};Z.defaultProps=Ho;Z.extensionName="TerrainExtension";var Wt=Z;return Xt(J);})();
|
|
1961
1991
|
return __exports__;
|
|
1962
1992
|
});
|