@deck.gl/extensions 9.2.0-alpha.2 → 9.2.0-beta.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/collision-filter/collision-filter-effect.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-effect.js +2 -5
- package/dist/collision-filter/collision-filter-effect.js.map +1 -1
- package/dist/data-filter/aggregator.d.ts.map +1 -1
- package/dist/data-filter/aggregator.js +6 -2
- package/dist/data-filter/aggregator.js.map +1 -1
- package/dist/dist.dev.js +11 -6
- package/dist/index.cjs +11 -6
- package/dist/index.cjs.map +2 -2
- package/dist/terrain/utils.d.ts.map +1 -1
- package/dist/terrain/utils.js +3 -1
- package/dist/terrain/utils.js.map +1 -1
- package/dist.min.js +3 -3
- package/package.json +6 -6
- package/src/collision-filter/collision-filter-effect.ts +2 -5
- package/src/data-filter/aggregator.ts +6 -2
- package/src/terrain/utils.ts +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/terrain/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AAG1C,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IACJ,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/terrain/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AAG1C,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IACJ,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,uCA2BF"}
|
package/dist/terrain/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/terrain/utils.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAEtC,MAAM,UAAU,kBAAkB,CAChC,MAAc,EACd,IAIC;IAED,OAAO,MAAM,CAAC,iBAAiB,CAAC;QAC9B,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,gBAAgB,EAAE;YAChB,MAAM,CAAC,aAAa,CAAC;gBACnB,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI;oBAChB,MAAM,EAAE,aAAa;oBACrB,IAAI,MAAU;iBACf,CAAC;gBACF,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/terrain/utils.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAEtC,MAAM,UAAU,kBAAkB,CAChC,MAAc,EACd,IAIC;IAED,OAAO,MAAM,CAAC,iBAAiB,CAAC;QAC9B,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,gBAAgB,EAAE;YAChB,MAAM,CAAC,aAAa,CAAC;gBACnB,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI;oBAChB,MAAM,EAAE,aAAa;oBACrB,IAAI,MAAU;iBACf,CAAC;gBACF,SAAS,EAAE,IAAI;gBACf,KAAK,EAAE,CAAC;gBACR,MAAM,EAAE,CAAC;gBACT,OAAO,EACL,IAAI,CAAC,WAAW,KAAK,KAAK;oBACxB,CAAC,CAAC;wBACE,SAAS,EAAE,SAAS;wBACpB,SAAS,EAAE,SAAS;qBACrB;oBACH,CAAC,CAAC;wBACE,SAAS,EAAE,QAAQ;wBACnB,SAAS,EAAE,QAAQ;qBACpB;aACR,CAAC;SACH;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/dist.min.js
CHANGED
|
@@ -245,7 +245,7 @@ void main() {
|
|
|
245
245
|
}
|
|
246
246
|
fragColor = vColor;
|
|
247
247
|
}
|
|
248
|
-
`,ro=["float32-renderable-webgl","texture-blend-float-webgl"];function Ye(o){return ro.every(e=>o.features.has(e))}function We(o,e){return e?o.createFramebuffer({width:1,height:1,colorAttachments:[o.createTexture({format:"rgba32float",mipmaps:!1})]}):o.createFramebuffer({width:256,height:64,colorAttachments:[o.createTexture({format:"rgba8unorm",mipmaps:!1})]})}function Ke(o,e,t,r){return t.defines.NON_INSTANCED_MODEL=1,r&&(t.defines.FLOAT_TARGET=1),new He.Model(o,{id:"data-filter-aggregation-model",vertexCount:1,isInstanced:!1,topology:"point-list",disableWarnings:!0,vs:to,fs:oo,bufferLayout:e,...t})}var $e={blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendColorOperation:"add",blendAlphaOperation:"add",depthCompare:"never"};var io={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},no={categorySize:0,filterSize:1,fp64:!1,countItems:!1},ao={1:"uint",2:"uvec2",3:"uvec3",4:"uvec4"},lo={1:"float",2:"vec2",3:"vec3",4:"vec4"},S=class extends E.LayerExtension{constructor(e={}){super({...no,...e})}getShaders(e){let{categorySize:t,filterSize:r,fp64:s}=e.opts,i={};t&&(i.DATACATEGORY_TYPE=ao[t],i.DATACATEGORY_CHANNELS=t),r&&(i.DATAFILTER_TYPE=lo[r],i.DATAFILTER_DOUBLE=Boolean(s));let n=s?Ue:ze;return n.uniformTypes=n.uniformTypesFromOptions(e.opts),{modules:[n],defines:i}}initializeState(e,t){let r=this.getAttributeManager(),{categorySize:s,filterSize:i,fp64:n}=t.opts;r&&(i&&r.add({filterValues:{size:i,type:n?"float64":"float32",stepMode:"dynamic",accessor:"getFilterValue"}}),s&&r.add({filterCategoryValues:{size:s,stepMode:"dynamic",accessor:"getFilterCategory",type:"uint32",transform:s===1?l=>t._getCategoryKey.call(this,l,0):l=>l.map((c,f)=>t._getCategoryKey.call(this,c,f))}}));let{device:a}=this.context;if(r&&t.opts.countItems){let l=Ye(a);r.add({filterVertexIndices:{size:l?1:2,vertexOffset:1,type:"unorm8",accessor:(u,{index:p})=>{let m=u&&u.__source?u.__source.index:p;return l?(m+1)%255:[(m+1)%255,Math.floor(m/255)%255]},shaderAttributes:{filterPrevIndices:{vertexOffset:0},filterIndices:{vertexOffset:1}}}});let c=We(a,l),f=Ke(a,r.getBufferLayouts({isInstanced:!1}),t.getShaders.call(this,t),l);this.setState({filterFBO:c,filterModel:f})}}updateState({props:e,oldProps:t,changeFlags:r},s){let i=this.getAttributeManager(),{categorySize:n}=s.opts;if(this.state.filterModel){let a=i.attributes.filterValues?.needsUpdate()||i.attributes.filterCategoryValues?.needsUpdate()||e.filterEnabled!==t.filterEnabled||e.filterRange!==t.filterRange||e.filterSoftRange!==t.filterSoftRange||e.filterCategories!==t.filterCategories;a&&this.setState({filterNeedsUpdate:a})}i?.attributes.filterCategoryValues&&((i.attributes.filterCategoryValues.needsUpdate()||!(0,E._deepEqual)(e.filterCategories,t.filterCategories,2))&&this.setState({categoryBitMask:null}),r.dataChanged&&(this.setState({categoryMap:Array(n).fill(0).map(()=>({}))}),i.attributes.filterCategoryValues.setNeedsUpdate("categoryMap")))}draw(e,t){let r=this.state.filterFBO,s=this.state.filterModel,i=this.state.filterNeedsUpdate;this.state.categoryBitMask||t._updateCategoryBitMask.call(this,e,t);let{onFilteredItemsChange:n,extensions:a,filterEnabled:l,filterRange:c,filterSoftRange:f,filterTransformSize:u,filterTransformColor:p,filterCategories:m}=this.props,v={extensions:a,filterEnabled:l,filterRange:c,filterSoftRange:f,filterTransformSize:u,filterTransformColor:p,filterCategories:m};if(this.state.categoryBitMask&&(v.categoryBitMask=this.state.categoryBitMask),this.setShaderModuleProps({dataFilter:v}),i&&n&&s){let b=this.getAttributeManager(),{attributes:{filterValues:h,filterCategoryValues:L,filterVertexIndices:fe}}=b;s.setVertexCount(this.getNumInstances());let ue={...h?.getValue(),...L?.getValue(),...fe?.getValue()};s.setAttributes(ue),s.shaderInputs.setProps({dataFilter:v});let pe=[0,0,r.width,r.height],Ee=s.device.beginRenderPass({id:"data-filter-aggregation",framebuffer:r,parameters:{viewport:pe},clearColor:[0,0,0,0]});s.setParameters($e),s.draw(Ee),Ee.end();let Me=s.device.readPixelsToArrayWebGL(r),Fe=0;for(let de=0;de<Me.length;de++)Fe+=Me[de];n({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:r}=t.opts;if(!r)return;let{filterCategories:s}=this.props,i=new Uint32Array([0,0,0,0]),n=r===1?[s]:s,a=r===1?128:r===2?64:32;for(let l=0;l<n.length;l++){let c=n[l];for(let f of c){let u=t._getCategoryKey.call(this,f,l);if(u<a){let p=l*(a/32)+Math.floor(u/32);i[p]+=Math.pow(2,u%32)}else E.log.warn(`Exceeded maximum number of categories (${a})`)()}}this.state.categoryBitMask=i}_getCategoryKey(e,t){let r=this.state.categoryMap[t];return e in r||(r[e]=Object.keys(r).length),r[e]}};S.defaultProps=io;S.extensionName="DataFilterExtension";var Ze=S;var w=d(_(),1);var Wr=1/Math.PI*180,Kr=1/180*Math.PI,co={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...co}};var I=globalThis.mathgl.config;function _e(o){return Array.isArray(o)||ArrayBuffer.isView(o)&&!(o instanceof DataView)}function M(o,e,t){let r=I.EPSILON;t&&(I.EPSILON=t);try{if(o===e)return!0;if(_e(o)&&_e(e)){if(o.length!==e.length)return!1;for(let s=0;s<o.length;++s)if(!M(o[s],e[s]))return!1;return!0}return o&&o.equals?o.equals(e):e&&e.equals?e.equals(o):typeof o=="number"&&typeof e=="number"?Math.abs(o-e)<=I.EPSILON*Math.max(1,Math.abs(o),Math.abs(e)):!1}finally{I.EPSILON=r}}var k=typeof Float32Array<"u"?Float32Array:Array,me=Math.random;function J(o){return o>=0?Math.round(o):o%.5===0?Math.floor(o):Math.round(o)}var Zr=Math.PI/180;var R={};Ae(R,{add:()=>ho,angle:()=>jo,bezier:()=>So,ceil:()=>vo,clone:()=>uo,copy:()=>_o,create:()=>Xe,cross:()=>Ao,dist:()=>Wo,distance:()=>ot,div:()=>Yo,divide:()=>tt,dot:()=>ve,equals:()=>Go,exactEquals:()=>Uo,floor:()=>go,forEach:()=>Xo,fromValues:()=>po,hermite:()=>Co,inverse:()=>Fo,len:()=>$o,length:()=>Qe,lerp:()=>Oo,max:()=>yo,min:()=>xo,mul:()=>Ho,multiply:()=>et,negate:()=>Mo,normalize:()=>To,random:()=>Io,rotateX:()=>No,rotateY:()=>Bo,rotateZ:()=>Do,round:()=>Po,scale:()=>bo,scaleAndAdd:()=>Eo,set:()=>mo,slerp:()=>Lo,sqrDist:()=>Ko,sqrLen:()=>Zo,squaredDistance:()=>rt,squaredLength:()=>st,str:()=>zo,sub:()=>qo,subtract:()=>Je,transformMat3:()=>Ro,transformMat4:()=>ko,transformQuat:()=>wo,zero:()=>Vo});function Xe(){let o=new k(3);return k!=Float32Array&&(o[0]=0,o[1]=0,o[2]=0),o}function uo(o){let e=new k(3);return e[0]=o[0],e[1]=o[1],e[2]=o[2],e}function Qe(o){let e=o[0],t=o[1],r=o[2];return Math.sqrt(e*e+t*t+r*r)}function po(o,e,t){let r=new k(3);return r[0]=o,r[1]=e,r[2]=t,r}function _o(o,e){return o[0]=e[0],o[1]=e[1],o[2]=e[2],o}function mo(o,e,t,r){return o[0]=e,o[1]=t,o[2]=r,o}function ho(o,e,t){return o[0]=e[0]+t[0],o[1]=e[1]+t[1],o[2]=e[2]+t[2],o}function Je(o,e,t){return o[0]=e[0]-t[0],o[1]=e[1]-t[1],o[2]=e[2]-t[2],o}function et(o,e,t){return o[0]=e[0]*t[0],o[1]=e[1]*t[1],o[2]=e[2]*t[2],o}function tt(o,e,t){return o[0]=e[0]/t[0],o[1]=e[1]/t[1],o[2]=e[2]/t[2],o}function vo(o,e){return o[0]=Math.ceil(e[0]),o[1]=Math.ceil(e[1]),o[2]=Math.ceil(e[2]),o}function go(o,e){return o[0]=Math.floor(e[0]),o[1]=Math.floor(e[1]),o[2]=Math.floor(e[2]),o}function xo(o,e,t){return o[0]=Math.min(e[0],t[0]),o[1]=Math.min(e[1],t[1]),o[2]=Math.min(e[2],t[2]),o}function yo(o,e,t){return o[0]=Math.max(e[0],t[0]),o[1]=Math.max(e[1],t[1]),o[2]=Math.max(e[2],t[2]),o}function Po(o,e){return o[0]=J(e[0]),o[1]=J(e[1]),o[2]=J(e[2]),o}function bo(o,e,t){return o[0]=e[0]*t,o[1]=e[1]*t,o[2]=e[2]*t,o}function Eo(o,e,t,r){return o[0]=e[0]+t[0]*r,o[1]=e[1]+t[1]*r,o[2]=e[2]+t[2]*r,o}function ot(o,e){let t=e[0]-o[0],r=e[1]-o[1],s=e[2]-o[2];return Math.sqrt(t*t+r*r+s*s)}function rt(o,e){let t=e[0]-o[0],r=e[1]-o[1],s=e[2]-o[2];return t*t+r*r+s*s}function st(o){let e=o[0],t=o[1],r=o[2];return e*e+t*t+r*r}function Mo(o,e){return o[0]=-e[0],o[1]=-e[1],o[2]=-e[2],o}function Fo(o,e){return o[0]=1/e[0],o[1]=1/e[1],o[2]=1/e[2],o}function To(o,e){let t=e[0],r=e[1],s=e[2],i=t*t+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),o[0]=e[0]*i,o[1]=e[1]*i,o[2]=e[2]*i,o}function ve(o,e){return o[0]*e[0]+o[1]*e[1]+o[2]*e[2]}function Ao(o,e,t){let r=e[0],s=e[1],i=e[2],n=t[0],a=t[1],l=t[2];return o[0]=s*l-i*a,o[1]=i*n-r*l,o[2]=r*a-s*n,o}function Oo(o,e,t,r){let s=e[0],i=e[1],n=e[2];return o[0]=s+r*(t[0]-s),o[1]=i+r*(t[1]-i),o[2]=n+r*(t[2]-n),o}function Lo(o,e,t,r){let s=Math.acos(Math.min(Math.max(ve(e,t),-1),1)),i=Math.sin(s),n=Math.sin((1-r)*s)/i,a=Math.sin(r*s)/i;return o[0]=n*e[0]+a*t[0],o[1]=n*e[1]+a*t[1],o[2]=n*e[2]+a*t[2],o}function Co(o,e,t,r,s,i){let n=i*i,a=n*(2*i-3)+1,l=n*(i-2)+i,c=n*(i-1),f=n*(3-2*i);return o[0]=e[0]*a+t[0]*l+r[0]*c+s[0]*f,o[1]=e[1]*a+t[1]*l+r[1]*c+s[1]*f,o[2]=e[2]*a+t[2]*l+r[2]*c+s[2]*f,o}function So(o,e,t,r,s,i){let n=1-i,a=n*n,l=i*i,c=a*n,f=3*i*a,u=3*l*n,p=l*i;return o[0]=e[0]*c+t[0]*f+r[0]*u+s[0]*p,o[1]=e[1]*c+t[1]*f+r[1]*u+s[1]*p,o[2]=e[2]*c+t[2]*f+r[2]*u+s[2]*p,o}function Io(o,e){e=e===void 0?1:e;let t=me()*2*Math.PI,r=me()*2-1,s=Math.sqrt(1-r*r)*e;return o[0]=Math.cos(t)*s,o[1]=Math.sin(t)*s,o[2]=r*e,o}function ko(o,e,t){let r=e[0],s=e[1],i=e[2],n=t[3]*r+t[7]*s+t[11]*i+t[15];return n=n||1,o[0]=(t[0]*r+t[4]*s+t[8]*i+t[12])/n,o[1]=(t[1]*r+t[5]*s+t[9]*i+t[13])/n,o[2]=(t[2]*r+t[6]*s+t[10]*i+t[14])/n,o}function Ro(o,e,t){let r=e[0],s=e[1],i=e[2];return o[0]=r*t[0]+s*t[3]+i*t[6],o[1]=r*t[1]+s*t[4]+i*t[7],o[2]=r*t[2]+s*t[5]+i*t[8],o}function wo(o,e,t){let r=t[0],s=t[1],i=t[2],n=t[3],a=e[0],l=e[1],c=e[2],f=s*c-i*l,u=i*a-r*c,p=r*l-s*a,m=s*p-i*u,v=i*f-r*p,b=r*u-s*f,h=n*2;return f*=h,u*=h,p*=h,m*=2,v*=2,b*=2,o[0]=a+f+m,o[1]=l+u+v,o[2]=c+p+b,o}function No(o,e,t,r){let s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[0],i[1]=s[1]*Math.cos(r)-s[2]*Math.sin(r),i[2]=s[1]*Math.sin(r)+s[2]*Math.cos(r),o[0]=i[0]+t[0],o[1]=i[1]+t[1],o[2]=i[2]+t[2],o}function Bo(o,e,t,r){let s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[2]*Math.sin(r)+s[0]*Math.cos(r),i[1]=s[1],i[2]=s[2]*Math.cos(r)-s[0]*Math.sin(r),o[0]=i[0]+t[0],o[1]=i[1]+t[1],o[2]=i[2]+t[2],o}function Do(o,e,t,r){let s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[0]*Math.cos(r)-s[1]*Math.sin(r),i[1]=s[0]*Math.sin(r)+s[1]*Math.cos(r),i[2]=s[2],o[0]=i[0]+t[0],o[1]=i[1]+t[1],o[2]=i[2]+t[2],o}function jo(o,e){let t=o[0],r=o[1],s=o[2],i=e[0],n=e[1],a=e[2],l=Math.sqrt((t*t+r*r+s*s)*(i*i+n*n+a*a)),c=l&&ve(o,e)/l;return Math.acos(Math.min(Math.max(c,-1),1))}function Vo(o){return o[0]=0,o[1]=0,o[2]=0,o}function zo(o){return`vec3(${o[0]}, ${o[1]}, ${o[2]})`}function Uo(o,e){return o[0]===e[0]&&o[1]===e[1]&&o[2]===e[2]}function Go(o,e){let t=o[0],r=o[1],s=o[2],i=e[0],n=e[1],a=e[2];return Math.abs(t-i)<=1e-6*Math.max(1,Math.abs(t),Math.abs(i))&&Math.abs(r-n)<=1e-6*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(s-a)<=1e-6*Math.max(1,Math.abs(s),Math.abs(a))}var qo=Je,Ho=et,Yo=tt,Wo=ot,Ko=rt,$o=Qe,Zo=st,Xo=function(){let o=Xe();return function(e,t,r,s,i,n){let a,l;for(t||(t=3),r||(r=0),s?l=Math.min(s*t+r,e.length):l=e.length,a=r;a<l;a+=t)o[0]=e[a],o[1]=e[a+1],o[2]=e[a+2],i(o,o,n),e[a]=o[0],e[a+1]=o[1],e[a+2]=o[2];return e}}();function ee(o,e=[],t=0){let r=Math.fround(o),s=o-r;return e[t]=r,e[t+1]=s,e}function ge(o){return o-Math.fround(o)}function xe(o){let e=new Float32Array(32);for(let t=0;t<4;++t)for(let r=0;r<4;++r){let s=t*4+r;ee(o[r*4+t],e,s*2)}return e}var it=`
|
|
248
|
+
`,ro=["float32-renderable-webgl","texture-blend-float-webgl"];function Ye(o){return ro.every(e=>o.features.has(e))}function We(o,e){return e?o.createFramebuffer({width:1,height:1,colorAttachments:[o.createTexture({format:"rgba32float",dimension:"2d",width:1,height:1})]}):o.createFramebuffer({width:256,height:64,colorAttachments:[o.createTexture({format:"rgba8unorm",dimension:"2d",width:256,height:64})]})}function Ke(o,e,t,r){return t.defines.NON_INSTANCED_MODEL=1,r&&(t.defines.FLOAT_TARGET=1),new He.Model(o,{id:"data-filter-aggregation-model",vertexCount:1,isInstanced:!1,topology:"point-list",disableWarnings:!0,vs:to,fs:oo,bufferLayout:e,...t})}var $e={blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendColorOperation:"add",blendAlphaOperation:"add",depthCompare:"never"};var io={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},no={categorySize:0,filterSize:1,fp64:!1,countItems:!1},ao={1:"uint",2:"uvec2",3:"uvec3",4:"uvec4"},lo={1:"float",2:"vec2",3:"vec3",4:"vec4"},S=class extends E.LayerExtension{constructor(e={}){super({...no,...e})}getShaders(e){let{categorySize:t,filterSize:r,fp64:s}=e.opts,i={};t&&(i.DATACATEGORY_TYPE=ao[t],i.DATACATEGORY_CHANNELS=t),r&&(i.DATAFILTER_TYPE=lo[r],i.DATAFILTER_DOUBLE=Boolean(s));let n=s?Ue:ze;return n.uniformTypes=n.uniformTypesFromOptions(e.opts),{modules:[n],defines:i}}initializeState(e,t){let r=this.getAttributeManager(),{categorySize:s,filterSize:i,fp64:n}=t.opts;r&&(i&&r.add({filterValues:{size:i,type:n?"float64":"float32",stepMode:"dynamic",accessor:"getFilterValue"}}),s&&r.add({filterCategoryValues:{size:s,stepMode:"dynamic",accessor:"getFilterCategory",type:"uint32",transform:s===1?l=>t._getCategoryKey.call(this,l,0):l=>l.map((c,f)=>t._getCategoryKey.call(this,c,f))}}));let{device:a}=this.context;if(r&&t.opts.countItems){let l=Ye(a);r.add({filterVertexIndices:{size:l?1:2,vertexOffset:1,type:"unorm8",accessor:(u,{index:p})=>{let m=u&&u.__source?u.__source.index:p;return l?(m+1)%255:[(m+1)%255,Math.floor(m/255)%255]},shaderAttributes:{filterPrevIndices:{vertexOffset:0},filterIndices:{vertexOffset:1}}}});let c=We(a,l),f=Ke(a,r.getBufferLayouts({isInstanced:!1}),t.getShaders.call(this,t),l);this.setState({filterFBO:c,filterModel:f})}}updateState({props:e,oldProps:t,changeFlags:r},s){let i=this.getAttributeManager(),{categorySize:n}=s.opts;if(this.state.filterModel){let a=i.attributes.filterValues?.needsUpdate()||i.attributes.filterCategoryValues?.needsUpdate()||e.filterEnabled!==t.filterEnabled||e.filterRange!==t.filterRange||e.filterSoftRange!==t.filterSoftRange||e.filterCategories!==t.filterCategories;a&&this.setState({filterNeedsUpdate:a})}i?.attributes.filterCategoryValues&&((i.attributes.filterCategoryValues.needsUpdate()||!(0,E._deepEqual)(e.filterCategories,t.filterCategories,2))&&this.setState({categoryBitMask:null}),r.dataChanged&&(this.setState({categoryMap:Array(n).fill(0).map(()=>({}))}),i.attributes.filterCategoryValues.setNeedsUpdate("categoryMap")))}draw(e,t){let r=this.state.filterFBO,s=this.state.filterModel,i=this.state.filterNeedsUpdate;this.state.categoryBitMask||t._updateCategoryBitMask.call(this,e,t);let{onFilteredItemsChange:n,extensions:a,filterEnabled:l,filterRange:c,filterSoftRange:f,filterTransformSize:u,filterTransformColor:p,filterCategories:m}=this.props,v={extensions:a,filterEnabled:l,filterRange:c,filterSoftRange:f,filterTransformSize:u,filterTransformColor:p,filterCategories:m};if(this.state.categoryBitMask&&(v.categoryBitMask=this.state.categoryBitMask),this.setShaderModuleProps({dataFilter:v}),i&&n&&s){let b=this.getAttributeManager(),{attributes:{filterValues:h,filterCategoryValues:L,filterVertexIndices:fe}}=b;s.setVertexCount(this.getNumInstances());let ue={...h?.getValue(),...L?.getValue(),...fe?.getValue()};s.setAttributes(ue),s.shaderInputs.setProps({dataFilter:v});let pe=[0,0,r.width,r.height],Ee=s.device.beginRenderPass({id:"data-filter-aggregation",framebuffer:r,parameters:{viewport:pe},clearColor:[0,0,0,0]});s.setParameters($e),s.draw(Ee),Ee.end();let Me=s.device.readPixelsToArrayWebGL(r),Fe=0;for(let de=0;de<Me.length;de++)Fe+=Me[de];n({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:r}=t.opts;if(!r)return;let{filterCategories:s}=this.props,i=new Uint32Array([0,0,0,0]),n=r===1?[s]:s,a=r===1?128:r===2?64:32;for(let l=0;l<n.length;l++){let c=n[l];for(let f of c){let u=t._getCategoryKey.call(this,f,l);if(u<a){let p=l*(a/32)+Math.floor(u/32);i[p]+=Math.pow(2,u%32)}else E.log.warn(`Exceeded maximum number of categories (${a})`)()}}this.state.categoryBitMask=i}_getCategoryKey(e,t){let r=this.state.categoryMap[t];return e in r||(r[e]=Object.keys(r).length),r[e]}};S.defaultProps=io;S.extensionName="DataFilterExtension";var Ze=S;var w=d(_(),1);var Wr=1/Math.PI*180,Kr=1/180*Math.PI,co={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...co}};var I=globalThis.mathgl.config;function _e(o){return Array.isArray(o)||ArrayBuffer.isView(o)&&!(o instanceof DataView)}function M(o,e,t){let r=I.EPSILON;t&&(I.EPSILON=t);try{if(o===e)return!0;if(_e(o)&&_e(e)){if(o.length!==e.length)return!1;for(let s=0;s<o.length;++s)if(!M(o[s],e[s]))return!1;return!0}return o&&o.equals?o.equals(e):e&&e.equals?e.equals(o):typeof o=="number"&&typeof e=="number"?Math.abs(o-e)<=I.EPSILON*Math.max(1,Math.abs(o),Math.abs(e)):!1}finally{I.EPSILON=r}}var k=typeof Float32Array<"u"?Float32Array:Array,me=Math.random;function J(o){return o>=0?Math.round(o):o%.5===0?Math.floor(o):Math.round(o)}var Zr=Math.PI/180;var R={};Ae(R,{add:()=>ho,angle:()=>jo,bezier:()=>So,ceil:()=>vo,clone:()=>uo,copy:()=>_o,create:()=>Xe,cross:()=>Ao,dist:()=>Wo,distance:()=>ot,div:()=>Yo,divide:()=>tt,dot:()=>ve,equals:()=>Go,exactEquals:()=>Uo,floor:()=>go,forEach:()=>Xo,fromValues:()=>po,hermite:()=>Co,inverse:()=>Fo,len:()=>$o,length:()=>Qe,lerp:()=>Oo,max:()=>yo,min:()=>xo,mul:()=>Ho,multiply:()=>et,negate:()=>Mo,normalize:()=>To,random:()=>Io,rotateX:()=>No,rotateY:()=>Bo,rotateZ:()=>Do,round:()=>Po,scale:()=>bo,scaleAndAdd:()=>Eo,set:()=>mo,slerp:()=>Lo,sqrDist:()=>Ko,sqrLen:()=>Zo,squaredDistance:()=>rt,squaredLength:()=>st,str:()=>zo,sub:()=>qo,subtract:()=>Je,transformMat3:()=>Ro,transformMat4:()=>ko,transformQuat:()=>wo,zero:()=>Vo});function Xe(){let o=new k(3);return k!=Float32Array&&(o[0]=0,o[1]=0,o[2]=0),o}function uo(o){let e=new k(3);return e[0]=o[0],e[1]=o[1],e[2]=o[2],e}function Qe(o){let e=o[0],t=o[1],r=o[2];return Math.sqrt(e*e+t*t+r*r)}function po(o,e,t){let r=new k(3);return r[0]=o,r[1]=e,r[2]=t,r}function _o(o,e){return o[0]=e[0],o[1]=e[1],o[2]=e[2],o}function mo(o,e,t,r){return o[0]=e,o[1]=t,o[2]=r,o}function ho(o,e,t){return o[0]=e[0]+t[0],o[1]=e[1]+t[1],o[2]=e[2]+t[2],o}function Je(o,e,t){return o[0]=e[0]-t[0],o[1]=e[1]-t[1],o[2]=e[2]-t[2],o}function et(o,e,t){return o[0]=e[0]*t[0],o[1]=e[1]*t[1],o[2]=e[2]*t[2],o}function tt(o,e,t){return o[0]=e[0]/t[0],o[1]=e[1]/t[1],o[2]=e[2]/t[2],o}function vo(o,e){return o[0]=Math.ceil(e[0]),o[1]=Math.ceil(e[1]),o[2]=Math.ceil(e[2]),o}function go(o,e){return o[0]=Math.floor(e[0]),o[1]=Math.floor(e[1]),o[2]=Math.floor(e[2]),o}function xo(o,e,t){return o[0]=Math.min(e[0],t[0]),o[1]=Math.min(e[1],t[1]),o[2]=Math.min(e[2],t[2]),o}function yo(o,e,t){return o[0]=Math.max(e[0],t[0]),o[1]=Math.max(e[1],t[1]),o[2]=Math.max(e[2],t[2]),o}function Po(o,e){return o[0]=J(e[0]),o[1]=J(e[1]),o[2]=J(e[2]),o}function bo(o,e,t){return o[0]=e[0]*t,o[1]=e[1]*t,o[2]=e[2]*t,o}function Eo(o,e,t,r){return o[0]=e[0]+t[0]*r,o[1]=e[1]+t[1]*r,o[2]=e[2]+t[2]*r,o}function ot(o,e){let t=e[0]-o[0],r=e[1]-o[1],s=e[2]-o[2];return Math.sqrt(t*t+r*r+s*s)}function rt(o,e){let t=e[0]-o[0],r=e[1]-o[1],s=e[2]-o[2];return t*t+r*r+s*s}function st(o){let e=o[0],t=o[1],r=o[2];return e*e+t*t+r*r}function Mo(o,e){return o[0]=-e[0],o[1]=-e[1],o[2]=-e[2],o}function Fo(o,e){return o[0]=1/e[0],o[1]=1/e[1],o[2]=1/e[2],o}function To(o,e){let t=e[0],r=e[1],s=e[2],i=t*t+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),o[0]=e[0]*i,o[1]=e[1]*i,o[2]=e[2]*i,o}function ve(o,e){return o[0]*e[0]+o[1]*e[1]+o[2]*e[2]}function Ao(o,e,t){let r=e[0],s=e[1],i=e[2],n=t[0],a=t[1],l=t[2];return o[0]=s*l-i*a,o[1]=i*n-r*l,o[2]=r*a-s*n,o}function Oo(o,e,t,r){let s=e[0],i=e[1],n=e[2];return o[0]=s+r*(t[0]-s),o[1]=i+r*(t[1]-i),o[2]=n+r*(t[2]-n),o}function Lo(o,e,t,r){let s=Math.acos(Math.min(Math.max(ve(e,t),-1),1)),i=Math.sin(s),n=Math.sin((1-r)*s)/i,a=Math.sin(r*s)/i;return o[0]=n*e[0]+a*t[0],o[1]=n*e[1]+a*t[1],o[2]=n*e[2]+a*t[2],o}function Co(o,e,t,r,s,i){let n=i*i,a=n*(2*i-3)+1,l=n*(i-2)+i,c=n*(i-1),f=n*(3-2*i);return o[0]=e[0]*a+t[0]*l+r[0]*c+s[0]*f,o[1]=e[1]*a+t[1]*l+r[1]*c+s[1]*f,o[2]=e[2]*a+t[2]*l+r[2]*c+s[2]*f,o}function So(o,e,t,r,s,i){let n=1-i,a=n*n,l=i*i,c=a*n,f=3*i*a,u=3*l*n,p=l*i;return o[0]=e[0]*c+t[0]*f+r[0]*u+s[0]*p,o[1]=e[1]*c+t[1]*f+r[1]*u+s[1]*p,o[2]=e[2]*c+t[2]*f+r[2]*u+s[2]*p,o}function Io(o,e){e=e===void 0?1:e;let t=me()*2*Math.PI,r=me()*2-1,s=Math.sqrt(1-r*r)*e;return o[0]=Math.cos(t)*s,o[1]=Math.sin(t)*s,o[2]=r*e,o}function ko(o,e,t){let r=e[0],s=e[1],i=e[2],n=t[3]*r+t[7]*s+t[11]*i+t[15];return n=n||1,o[0]=(t[0]*r+t[4]*s+t[8]*i+t[12])/n,o[1]=(t[1]*r+t[5]*s+t[9]*i+t[13])/n,o[2]=(t[2]*r+t[6]*s+t[10]*i+t[14])/n,o}function Ro(o,e,t){let r=e[0],s=e[1],i=e[2];return o[0]=r*t[0]+s*t[3]+i*t[6],o[1]=r*t[1]+s*t[4]+i*t[7],o[2]=r*t[2]+s*t[5]+i*t[8],o}function wo(o,e,t){let r=t[0],s=t[1],i=t[2],n=t[3],a=e[0],l=e[1],c=e[2],f=s*c-i*l,u=i*a-r*c,p=r*l-s*a,m=s*p-i*u,v=i*f-r*p,b=r*u-s*f,h=n*2;return f*=h,u*=h,p*=h,m*=2,v*=2,b*=2,o[0]=a+f+m,o[1]=l+u+v,o[2]=c+p+b,o}function No(o,e,t,r){let s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[0],i[1]=s[1]*Math.cos(r)-s[2]*Math.sin(r),i[2]=s[1]*Math.sin(r)+s[2]*Math.cos(r),o[0]=i[0]+t[0],o[1]=i[1]+t[1],o[2]=i[2]+t[2],o}function Bo(o,e,t,r){let s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[2]*Math.sin(r)+s[0]*Math.cos(r),i[1]=s[1],i[2]=s[2]*Math.cos(r)-s[0]*Math.sin(r),o[0]=i[0]+t[0],o[1]=i[1]+t[1],o[2]=i[2]+t[2],o}function Do(o,e,t,r){let s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[0]*Math.cos(r)-s[1]*Math.sin(r),i[1]=s[0]*Math.sin(r)+s[1]*Math.cos(r),i[2]=s[2],o[0]=i[0]+t[0],o[1]=i[1]+t[1],o[2]=i[2]+t[2],o}function jo(o,e){let t=o[0],r=o[1],s=o[2],i=e[0],n=e[1],a=e[2],l=Math.sqrt((t*t+r*r+s*s)*(i*i+n*n+a*a)),c=l&&ve(o,e)/l;return Math.acos(Math.min(Math.max(c,-1),1))}function Vo(o){return o[0]=0,o[1]=0,o[2]=0,o}function zo(o){return`vec3(${o[0]}, ${o[1]}, ${o[2]})`}function Uo(o,e){return o[0]===e[0]&&o[1]===e[1]&&o[2]===e[2]}function Go(o,e){let t=o[0],r=o[1],s=o[2],i=e[0],n=e[1],a=e[2];return Math.abs(t-i)<=1e-6*Math.max(1,Math.abs(t),Math.abs(i))&&Math.abs(r-n)<=1e-6*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(s-a)<=1e-6*Math.max(1,Math.abs(s),Math.abs(a))}var qo=Je,Ho=et,Yo=tt,Wo=ot,Ko=rt,$o=Qe,Zo=st,Xo=function(){let o=Xe();return function(e,t,r,s,i,n){let a,l;for(t||(t=3),r||(r=0),s?l=Math.min(s*t+r,e.length):l=e.length,a=r;a<l;a+=t)o[0]=e[a],o[1]=e[a+1],o[2]=e[a+2],i(o,o,n),e[a]=o[0],e[a+1]=o[1],e[a+2]=o[2];return e}}();function ee(o,e=[],t=0){let r=Math.fround(o),s=o-r;return e[t]=r,e[t+1]=s,e}function ge(o){return o-Math.fround(o)}function xe(o){let e=new Float32Array(32);for(let t=0;t<4;++t)for(let r=0;r<4;++r){let s=t*4+r;ee(o[r*4+t],e,s*2)}return e}var it=`
|
|
249
249
|
uniform fp64arithmeticUniforms {
|
|
250
250
|
uniform float ONE;
|
|
251
251
|
} fp64;
|
|
@@ -1360,7 +1360,7 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
|
|
|
1360
1360
|
}
|
|
1361
1361
|
`,"vs:DECKGL_FILTER_COLOR":`
|
|
1362
1362
|
color.a *= collision_fade;
|
|
1363
|
-
`},xr=o=>{if(!o||!("dummyCollisionMap"in o))return{};let{enabled:e,collisionFBO:t,drawToCollisionMap:r,dummyCollisionMap:s}=o;return{enabled:e&&!r,sort:Boolean(r),collision_texture:!r&&t?t.colorAttachments[0]:s}},Pt={name:"collision",dependencies:[yt.project],vs:vr,inject:gr,getUniforms:xr,uniformTypes:{sort:"i32",enabled:"i32"}};var Et=d(_(),1);var bt=d(_(),1),V=class extends bt._LayersPass{renderCollisionMap(e,t){let s=[0,0,0,0],i=[1,1,e.width-2*1,e.height-2*1];this.render({...t,clearColor:s,scissorRect:i,target:e,pass:"collision"})}getLayerParameters(e,t,r){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 ye=2,z=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 V(t,{id:"default-collision-filter"})}preRender({effects:e,layers:t,layerFilter:r,viewports:s,onViewportActive:i,views:n,isPicking:a,preRenderStats:l={}}){let{device:c}=this.context;if(a)return;let f=t.filter(({props:{visible:h,collisionEnabled:L}})=>h&&L);if(f.length===0){this.channels={};return}let u=e?.filter(h=>h.useInPicking&&l[h.id]),p=l["mask-effect"]?.didRender,m=this._groupByCollisionGroup(c,f),v=s[0],b=!this.lastViewport||!this.lastViewport.equals(v)||p;for(let h in m){let L=this.collisionFBOs[h],fe=m[h],[ue,pe]=c.canvasContext.getPixelSize();L.resize({width:ue/ye,height:pe/ye}),this._render(fe,{effects:u,layerFilter:r,onViewportActive:i,views:n,viewport:v,viewportChanged:b})}}_render(e,{effects:t,layerFilter:r,onViewportActive:s,views:i,viewport:n,viewportChanged:a}){let{collisionGroup:l}=e,c=this.channels[l];if(!c)return;let f=a||e===c||!(0,Et._deepEqual)(c.layers,e.layers,1)||e.layerBounds.some((u,p)=>!M(u,c.layerBounds[p]))||e.allLayersLoaded!==c.allLayersLoaded||e.layers.some(u=>u.props.transitions);if(this.channels[l]=e,f){this.lastViewport=n;let u=this.collisionFBOs[l];this.collisionFilterPass.renderCollisionMap(u,{pass:"collision-filter",isPicking:!0,layers:e.layers,effects:t,layerFilter:r,viewports:n?[n]:[],onViewportActive:s,views:i,shaderModuleProps:{collision:{enabled:!0,dummyCollisionMap:this.dummyCollisionMap},project:{devicePixelRatio:u.device.canvasContext.getDevicePixelRatio()/ye}}})}}_groupByCollisionGroup(e,t){let r={};for(let s of t){let i=s.props.collisionGroup,n=r[i];n||(n={collisionGroup:i,layers:[],layerBounds:[],allLayersLoaded:!0},r[i]=n),n.layers.push(s),n.layerBounds.push(s.getBounds()),s.isLoaded||(n.allLayersLoaded=!1)}for(let s of Object.keys(r))this.collisionFBOs[s]||this.createFBO(e,s),this.channels[s]||(this.channels[s]=r[s]);for(let s of Object.keys(this.collisionFBOs))r[s]||this.destroyFBO(s);return r}getShaderModuleProps(e){let{collisionGroup:t,collisionEnabled:r}=e.props,{collisionFBOs:s,dummyCollisionMap:i}=this,n=s[t];return{collision:{enabled:r&&Boolean(n),collisionFBO:n,dummyCollisionMap:i}}}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:r,height:s}=e.
|
|
1363
|
+
`},xr=o=>{if(!o||!("dummyCollisionMap"in o))return{};let{enabled:e,collisionFBO:t,drawToCollisionMap:r,dummyCollisionMap:s}=o;return{enabled:e&&!r,sort:Boolean(r),collision_texture:!r&&t?t.colorAttachments[0]:s}},Pt={name:"collision",dependencies:[yt.project],vs:vr,inject:gr,getUniforms:xr,uniformTypes:{sort:"i32",enabled:"i32"}};var Et=d(_(),1);var bt=d(_(),1),V=class extends bt._LayersPass{renderCollisionMap(e,t){let s=[0,0,0,0],i=[1,1,e.width-2*1,e.height-2*1];this.render({...t,clearColor:s,scissorRect:i,target:e,pass:"collision"})}getLayerParameters(e,t,r){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 ye=2,z=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 V(t,{id:"default-collision-filter"})}preRender({effects:e,layers:t,layerFilter:r,viewports:s,onViewportActive:i,views:n,isPicking:a,preRenderStats:l={}}){let{device:c}=this.context;if(a)return;let f=t.filter(({props:{visible:h,collisionEnabled:L}})=>h&&L);if(f.length===0){this.channels={};return}let u=e?.filter(h=>h.useInPicking&&l[h.id]),p=l["mask-effect"]?.didRender,m=this._groupByCollisionGroup(c,f),v=s[0],b=!this.lastViewport||!this.lastViewport.equals(v)||p;for(let h in m){let L=this.collisionFBOs[h],fe=m[h],[ue,pe]=c.canvasContext.getPixelSize();L.resize({width:ue/ye,height:pe/ye}),this._render(fe,{effects:u,layerFilter:r,onViewportActive:i,views:n,viewport:v,viewportChanged:b})}}_render(e,{effects:t,layerFilter:r,onViewportActive:s,views:i,viewport:n,viewportChanged:a}){let{collisionGroup:l}=e,c=this.channels[l];if(!c)return;let f=a||e===c||!(0,Et._deepEqual)(c.layers,e.layers,1)||e.layerBounds.some((u,p)=>!M(u,c.layerBounds[p]))||e.allLayersLoaded!==c.allLayersLoaded||e.layers.some(u=>u.props.transitions);if(this.channels[l]=e,f){this.lastViewport=n;let u=this.collisionFBOs[l];this.collisionFilterPass.renderCollisionMap(u,{pass:"collision-filter",isPicking:!0,layers:e.layers,effects:t,layerFilter:r,viewports:n?[n]:[],onViewportActive:s,views:i,shaderModuleProps:{collision:{enabled:!0,dummyCollisionMap:this.dummyCollisionMap},project:{devicePixelRatio:u.device.canvasContext.getDevicePixelRatio()/ye}}})}}_groupByCollisionGroup(e,t){let r={};for(let s of t){let i=s.props.collisionGroup,n=r[i];n||(n={collisionGroup:i,layers:[],layerBounds:[],allLayersLoaded:!0},r[i]=n),n.layers.push(s),n.layerBounds.push(s.getBounds()),s.isLoaded||(n.allLayersLoaded=!1)}for(let s of Object.keys(r))this.collisionFBOs[s]||this.createFBO(e,s),this.channels[s]||(this.channels[s]=r[s]);for(let s of Object.keys(this.collisionFBOs))r[s]||this.destroyFBO(s);return r}getShaderModuleProps(e){let{collisionGroup:t,collisionEnabled:r}=e.props,{collisionFBOs:s,dummyCollisionMap:i}=this,n=s[t];return{collision:{enabled:r&&Boolean(n),collisionFBO:n,dummyCollisionMap:i}}}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:r,height:s}=e.getDefaultCanvasContext().canvas,i=e.createTexture({format:"rgba8unorm",width:r,height:s,sampler:{minFilter:"nearest",magFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),n=e.createTexture({format:"depth16unorm",width:r,height:s});this.collisionFBOs[t]=e.createFramebuffer({id:`collision-${t}`,width:r,height:s,colorAttachments:[i],depthStencilAttachment:n})}destroyFBO(e){let t=this.collisionFBOs[e];t.colorAttachments[0]?.destroy(),t.depthStencilAttachment?.destroy(),t.destroy(),delete this.collisionFBOs[e]}};var yr={getCollisionPriority:{type:"accessor",value:0},collisionEnabled:!0,collisionGroup:{type:"string",value:"default"},collisionTestProps:{}},U=class extends Mt.LayerExtension{getShaders(){return{modules:[Pt]}}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 z),this.getAttributeManager().add({collisionPriorities:{size:1,stepMode:"dynamic",accessor:"getCollisionPriority"}})}getNeedsPickingBuffer(){return this.props.collisionEnabled}};U.defaultProps=yr;U.extensionName="CollisionFilterExtension";var Ft=U;var P=d(_(),1);var Tt=d(_(),1),At=`uniform maskUniforms {
|
|
1364
1364
|
vec4 bounds;
|
|
1365
1365
|
highp int channel;
|
|
1366
1366
|
bool enabled;
|
|
@@ -1472,6 +1472,6 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
1472
1472
|
}
|
|
1473
1473
|
return;
|
|
1474
1474
|
}
|
|
1475
|
-
`},getUniforms:(o={})=>{if("dummyHeightMap"in o){let{drawToTerrainHeightMap:e,heightMap:t,heightMapBounds:r,dummyHeightMap:s,terrainCover:i,useTerrainHeightMap:n,terrainSkipRender:a}=o,l=be.project.getUniforms(o.project),{commonOrigin:c}=l,f=a?x.SKIP:x.NONE,u=s,p=null;return e?(f=x.WRITE_HEIGHT_MAP,p=r):n&&t?(f=x.USE_HEIGHT_MAP,u=t,p=r):i&&(u=(o.isPicking?i.getPickingFramebuffer():i.getRenderFramebuffer())?.colorAttachments[0].texture,o.isPicking&&(f=x.SKIP),u?(f=f===x.SKIP?x.USE_COVER_ONLY:x.USE_COVER,p=i.bounds):u=s),{mode:f,terrain_map:u,bounds:p?[p[0]-c[0],p[1]-c[1],p[2]-p[0],p[3]-p[1]]:[0,0,0,0]}}return{}},uniformTypes:{mode:"f32",bounds:"vec4<f32>"}};function W(o,e){return o.createFramebuffer({id:e.id,colorAttachments:[o.createTexture({id:e.id,...e.float&&{format:"rgba32float",type:5126},mipmaps:!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=It(e)}get id(){return this.targetLayer.id}get isActive(){return Boolean(this.targetLayer.getCurrentLayer())}shouldUpdate({targetLayer:e,viewport:t,layers:r,layerNeedsRedraw:s}){e&&(this.targetLayer=e);let i=t?this._updateViewport(t):!1,n=r?this._updateLayers(r):!1;if(s){for(let a of this.layers)if(s[a]){n=!0;break}}return n||i}_updateLayers(e){let t=!1;if(e=this.tile?kr(this.tile,e):e,e.length!==this.layers.length)t=!0;else for(let r=0;r<e.length;r++)if(e[r].id!==this.layers[r]){t=!0;break}return t&&(this.layers=e.map(r=>r.id)),t}_updateViewport(e){let t=this.targetLayer,r=!1;if(this.tile&&"boundingBox"in this.tile){if(!this.targetBounds){r=!0,this.targetBounds=this.tile.boundingBox;let i=e.projectPosition(this.targetBounds[0]),n=e.projectPosition(this.targetBounds[1]);this.targetBoundsCommon=[i[0],i[1],n[0],n[1]]}}else this.targetBounds!==t.getBounds()&&(r=!0,this.targetBounds=t.getBounds(),this.targetBoundsCommon=T([t],e));if(!this.targetBoundsCommon)return!1;let s=Math.ceil(e.zoom+.5);if(this.tile)this.bounds=this.targetBoundsCommon;else{let i=this.renderViewport?.zoom;r=r||s!==i;let n=O(this.targetBoundsCommon,e),a=this.bounds;r=r||!a||n.some((l,c)=>l!==a[c]),this.bounds=n}return r&&(this.renderViewport=A({bounds:this.bounds,zoom:s,viewport:e})),r}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 kr(o,e){return e.filter(t=>{let r=It(t);return r?Rr(o.boundingBox,r.boundingBox):!0})}function It(o){for(;o;){let{tile:e}=o.props;if(e)return e;o=o.parent}return null}function Rr(o,e){return o&&e?o[0][0]<e[1][0]&&e[0][0]<o[1][0]&&o[0][1]<e[1][1]&&e[0][1]<o[1][1]:!1}var kt=d(_(),1),wr={blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},ae=class extends kt._LayersPass{getRenderableLayers(e,t){let{layers:r}=t,s=[],i=this._getDrawLayerParams(e,t,!0);for(let n=0;n<r.length;n++){let a=r[n];!a.isComposite&&i[n].shouldDrawLayer&&s.push(a)}return s}renderHeightMap(e,t){let r=e.getRenderFramebuffer(),s=e.renderViewport;!r||!s||(r.resize(s),this.render({...t,target:r,pass:"terrain-height-map",layers:t.layers,viewports:[s],effects:[],clearColor:[0,0,0,0]}))}renderTerrainCover(e,t){let r=e.getRenderFramebuffer(),s=e.renderViewport;if(!r||!s)return;let i=e.filterLayers(t.layers);r.resize(s),this.render({...t,target:r,pass:`terrain-cover-${e.id}`,layers:i,effects:[],viewports:[s],clearColor:[0,0,0,0]})}getLayerParameters(e,t,r){return{...e.props.parameters,blend:!0,depthCompare:"always",...e.props.operation.includes("terrain")&&wr}}getShaderModuleProps(e,t,r){return{terrain:{project:r.project}}}};var Rt=d(_(),1),le=class extends Rt._PickLayersPass{constructor(){super(...arguments),this.drawParameters={}}getRenderableLayers(e,t){let{layers:r}=t,s=[];this.drawParameters={},this._resetColorEncoder(t.pickZ);let i=this._getDrawLayerParams(e,t);for(let n=0;n<r.length;n++){let a=r[n];!a.isComposite&&i[n].shouldDrawLayer&&(s.push(a),this.drawParameters[a.id]=i[n].layerParameters)}return s}renderTerrainCover(e,t){let r=e.getPickingFramebuffer(),s=e.renderViewport;if(!r||!s)return;let i=e.filterLayers(t.layers),n=e.targetLayer;n.props.pickable&&i.unshift(n),r.resize(s),this.render({...t,pickingFBO:r,pass:`terrain-cover-picking-${e.id}`,layers:i,effects:[],viewports:[s],cullRect:void 0,deviceRect:s,pickZ:!1})}getLayerParameters(e,t,r){let s;return this.drawParameters[e.id]?s=this.drawParameters[e.id]:(s=super.getLayerParameters(e,t,r),s.blend=!0),{...s,depthCompare:"always"}}getShaderModuleProps(e,t,r){return{terrain:{project:r.project}}}};var wt=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 r=e.length!==this.layers.length||e.some((i,n)=>i!==this.layers[n]||i.props.transitions||i.getBounds()!==this.layersBounds[n]);r&&(this.layers=e,this.layersBounds=e.map(i=>i.getBounds()),this.layersBoundsCommon=T(e,t));let s=!this.lastViewport||!t.equals(this.lastViewport);if(!this.layersBoundsCommon)this.renderViewport=null;else if(r||s){let i=O(this.layersBoundsCommon,t);if(i[2]<=i[0]||i[3]<=i[1])return this.renderViewport=null,!1;this.bounds=i,this.lastViewport=t;let n=t.scale,a=(i[2]-i[0])*n,l=(i[3]-i[1])*n;return this.renderViewport=a>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(a,wt),height:Math.min(l,wt),viewport:t}):null,!0}return!1}delete(){this.fbo&&(this.fbo.colorAttachments[0].delete(),this.fbo.delete())}};var ce=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 le(e,{id:"terrain-picking"}),K.isSupported(e)?this.heightMap=new K(e):Nt.log.warn("Terrain offset mode is not supported by this browser")(),t._addDefaultShaderModule(Y)}preRender(e){if(e.pickZ){this.isDrapingEnabled=!1;return}let{viewports:t}=e,r=e.pass.startsWith("picking");this.isPicking=r,this.isDrapingEnabled=!0;let s=t[0],i=(r?this.terrainPickingPass:this.terrainPass).getRenderableLayers(s,e),n=i.filter(l=>l.props.operation.includes("terrain"));if(n.length===0)return;r||i.filter(c=>c.state.terrainDrawMode==="offset").length>0&&this._updateHeightMap(n,s,e);let a=i.filter(l=>l.state.terrainDrawMode==="drape");this._updateTerrainCovers(n,a,s,e)}getShaderModuleProps(e,t){let{terrainDrawMode:r}=e.state;return{terrain:{project:t.project,isPicking:this.isPicking,heightMap:this.heightMap?.getRenderFramebuffer()?.colorAttachments[0].texture||null,heightMapBounds:this.heightMap?.bounds,dummyHeightMap:this.dummyHeightMap,terrainCover:this.isDrapingEnabled?this.terrainCovers.get(e.id):null,useTerrainHeightMap:r==="offset",terrainSkipRender:r==="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(Y)}_updateHeightMap(e,t,r){!this.heightMap||!this.heightMap.shouldUpdate({layers:e,viewport:t})||this.terrainPass.renderHeightMap(this.heightMap,{...r,layers:e,shaderModuleProps:{terrain:{heightMapBounds:this.heightMap.bounds,dummyHeightMap:this.dummyHeightMap,drawToTerrainHeightMap:!0},project:{devicePixelRatio:1}}})}_updateTerrainCovers(e,t,r,s){let i={};for(let n of t)n.state.terrainCoverNeedsRedraw&&(i[n.id]=!0,n.state.terrainCoverNeedsRedraw=!1);for(let n of this.terrainCovers.values())n.isDirty=n.isDirty||n.shouldUpdate({layerNeedsRedraw:i});for(let n of e)this._updateTerrainCover(n,t,r,s);this.isPicking||this._pruneTerrainCovers()}_updateTerrainCover(e,t,r,s){let i=this.isPicking?this.terrainPickingPass:this.terrainPass,n=this.terrainCovers.get(e.id);n||(n=new ne(e),this.terrainCovers.set(e.id,n));try{let a=n.shouldUpdate({targetLayer:e,viewport:r,layers:t});(this.isPicking||n.isDirty||a)&&(i.renderTerrainCover(n,{...s,layers:t,shaderModuleProps:{terrain:{dummyHeightMap:this.dummyHeightMap,terrainSkipRender:!1},project:{devicePixelRatio:1}}}),this.isPicking||(n.isDirty=!1))}catch(a){e.raiseError(a,`Error rendering terrain cover ${n.id}`)}}_pruneTerrainCovers(){let e=[];for(let[t,r]of this.terrainCovers)r.isActive||e.push(t);for(let t of e)this.terrainCovers.delete(t)}};var Nr={terrainDrawMode:void 0},$=class extends Bt.LayerExtension{getShaders(){return{modules:[Y]}}initializeState(){this.context.deck?._addDefaultEffect(new ce)}updateState(e){let{props:t,oldProps:r}=e;if(this.state.terrainDrawMode&&t.terrainDrawMode===r.terrainDrawMode&&t.extruded===r.extruded)return;let{terrainDrawMode:s}=t;if(!s){let i=this.props.extruded,n=this.getAttributeManager()?.attributes,a=n&&"instancePositions"in n;s=i||a?"offset":"drape"}this.setState({terrainDrawMode:s})}onNeedsRedraw(){let e=this.state;e.terrainDrawMode==="drape"&&(e.terrainCoverNeedsRedraw=!0)}};$.defaultProps=Nr;$.extensionName="TerrainExtension";var Dt=$;return qt(Z);})();
|
|
1475
|
+
`},getUniforms:(o={})=>{if("dummyHeightMap"in o){let{drawToTerrainHeightMap:e,heightMap:t,heightMapBounds:r,dummyHeightMap:s,terrainCover:i,useTerrainHeightMap:n,terrainSkipRender:a}=o,l=be.project.getUniforms(o.project),{commonOrigin:c}=l,f=a?x.SKIP:x.NONE,u=s,p=null;return e?(f=x.WRITE_HEIGHT_MAP,p=r):n&&t?(f=x.USE_HEIGHT_MAP,u=t,p=r):i&&(u=(o.isPicking?i.getPickingFramebuffer():i.getRenderFramebuffer())?.colorAttachments[0].texture,o.isPicking&&(f=x.SKIP),u?(f=f===x.SKIP?x.USE_COVER_ONLY:x.USE_COVER,p=i.bounds):u=s),{mode:f,terrain_map:u,bounds:p?[p[0]-c[0],p[1]-c[1],p[2]-p[0],p[3]-p[1]]:[0,0,0,0]}}return{}},uniformTypes:{mode:"f32",bounds:"vec4<f32>"}};function W(o,e){return o.createFramebuffer({id:e.id,colorAttachments:[o.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=It(e)}get id(){return this.targetLayer.id}get isActive(){return Boolean(this.targetLayer.getCurrentLayer())}shouldUpdate({targetLayer:e,viewport:t,layers:r,layerNeedsRedraw:s}){e&&(this.targetLayer=e);let i=t?this._updateViewport(t):!1,n=r?this._updateLayers(r):!1;if(s){for(let a of this.layers)if(s[a]){n=!0;break}}return n||i}_updateLayers(e){let t=!1;if(e=this.tile?kr(this.tile,e):e,e.length!==this.layers.length)t=!0;else for(let r=0;r<e.length;r++)if(e[r].id!==this.layers[r]){t=!0;break}return t&&(this.layers=e.map(r=>r.id)),t}_updateViewport(e){let t=this.targetLayer,r=!1;if(this.tile&&"boundingBox"in this.tile){if(!this.targetBounds){r=!0,this.targetBounds=this.tile.boundingBox;let i=e.projectPosition(this.targetBounds[0]),n=e.projectPosition(this.targetBounds[1]);this.targetBoundsCommon=[i[0],i[1],n[0],n[1]]}}else this.targetBounds!==t.getBounds()&&(r=!0,this.targetBounds=t.getBounds(),this.targetBoundsCommon=T([t],e));if(!this.targetBoundsCommon)return!1;let s=Math.ceil(e.zoom+.5);if(this.tile)this.bounds=this.targetBoundsCommon;else{let i=this.renderViewport?.zoom;r=r||s!==i;let n=O(this.targetBoundsCommon,e),a=this.bounds;r=r||!a||n.some((l,c)=>l!==a[c]),this.bounds=n}return r&&(this.renderViewport=A({bounds:this.bounds,zoom:s,viewport:e})),r}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 kr(o,e){return e.filter(t=>{let r=It(t);return r?Rr(o.boundingBox,r.boundingBox):!0})}function It(o){for(;o;){let{tile:e}=o.props;if(e)return e;o=o.parent}return null}function Rr(o,e){return o&&e?o[0][0]<e[1][0]&&e[0][0]<o[1][0]&&o[0][1]<e[1][1]&&e[0][1]<o[1][1]:!1}var kt=d(_(),1),wr={blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},ae=class extends kt._LayersPass{getRenderableLayers(e,t){let{layers:r}=t,s=[],i=this._getDrawLayerParams(e,t,!0);for(let n=0;n<r.length;n++){let a=r[n];!a.isComposite&&i[n].shouldDrawLayer&&s.push(a)}return s}renderHeightMap(e,t){let r=e.getRenderFramebuffer(),s=e.renderViewport;!r||!s||(r.resize(s),this.render({...t,target:r,pass:"terrain-height-map",layers:t.layers,viewports:[s],effects:[],clearColor:[0,0,0,0]}))}renderTerrainCover(e,t){let r=e.getRenderFramebuffer(),s=e.renderViewport;if(!r||!s)return;let i=e.filterLayers(t.layers);r.resize(s),this.render({...t,target:r,pass:`terrain-cover-${e.id}`,layers:i,effects:[],viewports:[s],clearColor:[0,0,0,0]})}getLayerParameters(e,t,r){return{...e.props.parameters,blend:!0,depthCompare:"always",...e.props.operation.includes("terrain")&&wr}}getShaderModuleProps(e,t,r){return{terrain:{project:r.project}}}};var Rt=d(_(),1),le=class extends Rt._PickLayersPass{constructor(){super(...arguments),this.drawParameters={}}getRenderableLayers(e,t){let{layers:r}=t,s=[];this.drawParameters={},this._resetColorEncoder(t.pickZ);let i=this._getDrawLayerParams(e,t);for(let n=0;n<r.length;n++){let a=r[n];!a.isComposite&&i[n].shouldDrawLayer&&(s.push(a),this.drawParameters[a.id]=i[n].layerParameters)}return s}renderTerrainCover(e,t){let r=e.getPickingFramebuffer(),s=e.renderViewport;if(!r||!s)return;let i=e.filterLayers(t.layers),n=e.targetLayer;n.props.pickable&&i.unshift(n),r.resize(s),this.render({...t,pickingFBO:r,pass:`terrain-cover-picking-${e.id}`,layers:i,effects:[],viewports:[s],cullRect:void 0,deviceRect:s,pickZ:!1})}getLayerParameters(e,t,r){let s;return this.drawParameters[e.id]?s=this.drawParameters[e.id]:(s=super.getLayerParameters(e,t,r),s.blend=!0),{...s,depthCompare:"always"}}getShaderModuleProps(e,t,r){return{terrain:{project:r.project}}}};var wt=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 r=e.length!==this.layers.length||e.some((i,n)=>i!==this.layers[n]||i.props.transitions||i.getBounds()!==this.layersBounds[n]);r&&(this.layers=e,this.layersBounds=e.map(i=>i.getBounds()),this.layersBoundsCommon=T(e,t));let s=!this.lastViewport||!t.equals(this.lastViewport);if(!this.layersBoundsCommon)this.renderViewport=null;else if(r||s){let i=O(this.layersBoundsCommon,t);if(i[2]<=i[0]||i[3]<=i[1])return this.renderViewport=null,!1;this.bounds=i,this.lastViewport=t;let n=t.scale,a=(i[2]-i[0])*n,l=(i[3]-i[1])*n;return this.renderViewport=a>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(a,wt),height:Math.min(l,wt),viewport:t}):null,!0}return!1}delete(){this.fbo&&(this.fbo.colorAttachments[0].delete(),this.fbo.delete())}};var ce=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 le(e,{id:"terrain-picking"}),K.isSupported(e)?this.heightMap=new K(e):Nt.log.warn("Terrain offset mode is not supported by this browser")(),t._addDefaultShaderModule(Y)}preRender(e){if(e.pickZ){this.isDrapingEnabled=!1;return}let{viewports:t}=e,r=e.pass.startsWith("picking");this.isPicking=r,this.isDrapingEnabled=!0;let s=t[0],i=(r?this.terrainPickingPass:this.terrainPass).getRenderableLayers(s,e),n=i.filter(l=>l.props.operation.includes("terrain"));if(n.length===0)return;r||i.filter(c=>c.state.terrainDrawMode==="offset").length>0&&this._updateHeightMap(n,s,e);let a=i.filter(l=>l.state.terrainDrawMode==="drape");this._updateTerrainCovers(n,a,s,e)}getShaderModuleProps(e,t){let{terrainDrawMode:r}=e.state;return{terrain:{project:t.project,isPicking:this.isPicking,heightMap:this.heightMap?.getRenderFramebuffer()?.colorAttachments[0].texture||null,heightMapBounds:this.heightMap?.bounds,dummyHeightMap:this.dummyHeightMap,terrainCover:this.isDrapingEnabled?this.terrainCovers.get(e.id):null,useTerrainHeightMap:r==="offset",terrainSkipRender:r==="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(Y)}_updateHeightMap(e,t,r){!this.heightMap||!this.heightMap.shouldUpdate({layers:e,viewport:t})||this.terrainPass.renderHeightMap(this.heightMap,{...r,layers:e,shaderModuleProps:{terrain:{heightMapBounds:this.heightMap.bounds,dummyHeightMap:this.dummyHeightMap,drawToTerrainHeightMap:!0},project:{devicePixelRatio:1}}})}_updateTerrainCovers(e,t,r,s){let i={};for(let n of t)n.state.terrainCoverNeedsRedraw&&(i[n.id]=!0,n.state.terrainCoverNeedsRedraw=!1);for(let n of this.terrainCovers.values())n.isDirty=n.isDirty||n.shouldUpdate({layerNeedsRedraw:i});for(let n of e)this._updateTerrainCover(n,t,r,s);this.isPicking||this._pruneTerrainCovers()}_updateTerrainCover(e,t,r,s){let i=this.isPicking?this.terrainPickingPass:this.terrainPass,n=this.terrainCovers.get(e.id);n||(n=new ne(e),this.terrainCovers.set(e.id,n));try{let a=n.shouldUpdate({targetLayer:e,viewport:r,layers:t});(this.isPicking||n.isDirty||a)&&(i.renderTerrainCover(n,{...s,layers:t,shaderModuleProps:{terrain:{dummyHeightMap:this.dummyHeightMap,terrainSkipRender:!1},project:{devicePixelRatio:1}}}),this.isPicking||(n.isDirty=!1))}catch(a){e.raiseError(a,`Error rendering terrain cover ${n.id}`)}}_pruneTerrainCovers(){let e=[];for(let[t,r]of this.terrainCovers)r.isActive||e.push(t);for(let t of e)this.terrainCovers.delete(t)}};var Nr={terrainDrawMode:void 0},$=class extends Bt.LayerExtension{getShaders(){return{modules:[Y]}}initializeState(){this.context.deck?._addDefaultEffect(new ce)}updateState(e){let{props:t,oldProps:r}=e;if(this.state.terrainDrawMode&&t.terrainDrawMode===r.terrainDrawMode&&t.extruded===r.extruded)return;let{terrainDrawMode:s}=t;if(!s){let i=this.props.extruded,n=this.getAttributeManager()?.attributes,a=n&&"instancePositions"in n;s=i||a?"offset":"drape"}this.setState({terrainDrawMode:s})}onNeedsRedraw(){let e=this.state;e.terrainDrawMode==="drape"&&(e.terrainCoverNeedsRedraw=!0)}};$.defaultProps=Nr;$.extensionName="TerrainExtension";var Dt=$;return qt(Z);})();
|
|
1476
1476
|
return __exports__;
|
|
1477
1477
|
});
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Plug-and-play functionalities for deck.gl layers",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "9.2.0-
|
|
6
|
+
"version": "9.2.0-beta.1",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
"prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@luma.gl/constants": "^9.
|
|
42
|
-
"@luma.gl/shadertools": "^9.
|
|
41
|
+
"@luma.gl/constants": "^9.2.0-alpha.5",
|
|
42
|
+
"@luma.gl/shadertools": "^9.2.0-alpha.5",
|
|
43
43
|
"@math.gl/core": "^4.1.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@deck.gl/core": "^9.1.0",
|
|
47
|
-
"@luma.gl/core": "^9.
|
|
48
|
-
"@luma.gl/engine": "^9.
|
|
47
|
+
"@luma.gl/core": "^9.2.0-alpha.5",
|
|
48
|
+
"@luma.gl/engine": "^9.2.0-alpha.5"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "84407defece157d45954f66cf191cca3c596ee99"
|
|
51
51
|
}
|
|
@@ -244,8 +244,7 @@ export default class CollisionFilterEffect implements Effect {
|
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
createFBO(device: Device, collisionGroup: string) {
|
|
247
|
-
|
|
248
|
-
const {width, height} = device.gl.canvas;
|
|
247
|
+
const {width, height} = device.getDefaultCanvasContext().canvas;
|
|
249
248
|
const collisionMap = device.createTexture({
|
|
250
249
|
format: 'rgba8unorm',
|
|
251
250
|
width,
|
|
@@ -258,12 +257,10 @@ export default class CollisionFilterEffect implements Effect {
|
|
|
258
257
|
}
|
|
259
258
|
});
|
|
260
259
|
|
|
261
|
-
// @ts-ignore
|
|
262
260
|
const depthStencilAttachment = device.createTexture({
|
|
263
261
|
format: 'depth16unorm',
|
|
264
262
|
width,
|
|
265
|
-
height
|
|
266
|
-
mipmaps: false
|
|
263
|
+
height
|
|
267
264
|
});
|
|
268
265
|
this.collisionFBOs[collisionGroup] = device.createFramebuffer({
|
|
269
266
|
id: `collision-${collisionGroup}`,
|
|
@@ -74,7 +74,9 @@ export function getFramebuffer(device: Device, useFloatTarget: boolean): Framebu
|
|
|
74
74
|
colorAttachments: [
|
|
75
75
|
device.createTexture({
|
|
76
76
|
format: 'rgba32float',
|
|
77
|
-
|
|
77
|
+
dimension: '2d',
|
|
78
|
+
width: 1,
|
|
79
|
+
height: 1
|
|
78
80
|
})
|
|
79
81
|
]
|
|
80
82
|
});
|
|
@@ -82,7 +84,9 @@ export function getFramebuffer(device: Device, useFloatTarget: boolean): Framebu
|
|
|
82
84
|
return device.createFramebuffer({
|
|
83
85
|
width: 256,
|
|
84
86
|
height: 64,
|
|
85
|
-
colorAttachments: [
|
|
87
|
+
colorAttachments: [
|
|
88
|
+
device.createTexture({format: 'rgba8unorm', dimension: '2d', width: 256, height: 64})
|
|
89
|
+
]
|
|
86
90
|
});
|
|
87
91
|
}
|
|
88
92
|
|