@deck.gl/aggregation-layers 9.3.0-beta.1 → 9.3.0-beta.2

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.min.js CHANGED
@@ -161,7 +161,7 @@ void main() {
161
161
  fragColor = vec4(-value3, 1.0);
162
162
  }
163
163
  }
164
- `;return new Ne.BufferTransform(n,{vs:e,fs:o,topology:"point-list",modules:[we],parameters:{blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendColorOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendAlphaOperation:"max"},defines:{NUM_DIMS:t.dimensions,NUM_CHANNELS:t.channelCount,SAMPLER_WIDTH:dt},varyings:["binIds","values"],disableWarnings:!0})}var ut=L(I(),1),P=class{static isSupported(t){return t.features.has("float32-renderable-webgl")&&t.features.has("texture-blend-float-webgl")}constructor(t,e){this.binCount=0,this.binIds=null,this.results=[],this.device=t,this.dimensions=e.dimensions,this.channelCount=e.channelCount,this.props={...e,pointCount:0,binIdRange:[[0,0]],operations:[],attributes:{},binOptions:{}},this.needsUpdate=new Array(this.channelCount).fill(!0),this.binSorter=new Lt(t,e),this.aggregationTransform=new Pt(t,e),this.setProps(e)}getBins(){let t=this.aggregationTransform.binBuffer;return t?(this.binIds?.buffer!==t&&(this.binIds={buffer:t,type:"float32",size:this.dimensions}),this.binIds):null}getResult(t){let e=this.aggregationTransform.valueBuffer;return!e||t>=this.channelCount?null:(this.results[t]?.buffer!==e&&(this.results[t]={buffer:e,type:"float32",size:1,stride:this.channelCount*4,offset:t*4}),this.results[t])}getResultDomain(t){return this.aggregationTransform.domains[t]}getBin(t){if(t<0||t>=this.binCount)return null;let{binIdRange:e}=this.props,o;if(this.dimensions===1)o=[t+e[0][0]];else{let[[a,c],[g]]=e,h=c-a;o=[t%h+a,Math.floor(t/h)+g]}let r=this.binSorter.getBinValues(t);if(!r)return null;let i=r[3],s=[];for(let a=0;a<this.channelCount;a++){let c=this.props.operations[a];c==="COUNT"?s[a]=i:i===0?s[a]=NaN:s[a]=c==="MEAN"?r[a]/i:r[a]}return{id:o,value:s,count:i}}destroy(){this.binSorter.destroy(),this.aggregationTransform.destroy()}setProps(t){let e=this.props;if("binIdRange"in t&&!(0,ut._deepEqual)(t.binIdRange,e.binIdRange,2)){let o=t.binIdRange;if(ut.log.assert(o.length===this.dimensions),this.dimensions===1){let[[r,i]]=o;this.binCount=i-r}else{let[[r,i],[s,a]]=o;this.binCount=(i-r)*(a-s)}this.binSorter.setDimensions(this.binCount,o),this.aggregationTransform.setDimensions(this.binCount,o),this.setNeedsUpdate()}if(t.operations)for(let o=0;o<this.channelCount;o++)t.operations[o]!==e.operations[o]&&this.setNeedsUpdate(o);if(t.pointCount!==void 0&&t.pointCount!==e.pointCount&&(this.binSorter.setModelProps({vertexCount:t.pointCount}),this.setNeedsUpdate()),t.binOptions&&((0,ut._deepEqual)(t.binOptions,e.binOptions,2)||this.setNeedsUpdate(),this.binSorter.model.shaderInputs.setProps({binOptions:t.binOptions})),t.attributes){let o={},r={};for(let i of Object.values(t.attributes))for(let[s,a]of Object.entries(i.getValue()))ArrayBuffer.isView(a)?r[s]=a:a&&(o[s]=a);this.binSorter.setModelProps({attributes:o,constantAttributes:r})}t.shaderModuleProps&&this.binSorter.setModelProps({shaderModuleProps:t.shaderModuleProps}),Object.assign(this.props,t)}setNeedsUpdate(t){t===void 0?this.needsUpdate.fill(!0):this.needsUpdate[t]=!0}update(){}preDraw(){if(!this.needsUpdate.some(Boolean))return;let{operations:t}=this.props,e=this.needsUpdate.map((o,r)=>o?t[r]:null);this.binSorter.update(e),this.aggregationTransform.update(this.binSorter.texture,t);for(let o=0;o<this.channelCount;o++)this.needsUpdate[o]&&(this.needsUpdate[o]=!1,this.props.onUpdate?.({channel:o}))}};var Nt=L(I(),1),wt=class extends Nt.CompositeLayer{get isDrawable(){return!0}initializeState(){this.getAttributeManager().remove(["instancePickingColors"])}updateState(t){super.updateState(t);let e=this.getAggregatorType();if(t.changeFlags.extensionsChanged||this.state.aggregatorType!==e){this.state.aggregator?.destroy();let o=this.createAggregator(e);return o.setProps({attributes:this.getAttributeManager()?.attributes}),this.setState({aggregator:o,aggregatorType:e}),!0}return!1}finalizeState(t){super.finalizeState(t),this.state.aggregator.destroy()}updateAttributes(t){let{aggregator:e}=this.state;e.setProps({attributes:t});for(let o in t)this.onAttributeChange(o);e.update()}draw({shaderModuleProps:t}){let{aggregator:e}=this.state;e.setProps({shaderModuleProps:t}),e.preDraw()}_getAttributeManager(){return new Nt.AttributeManager(this.context.device,{id:this.props.id,stats:this.context.stats})}};wt.layerName="AggregationLayer";var B=wt;var _t=L($(),1),zt=L(I(),1);var j=[[255,255,178],[254,217,118],[254,178,76],[253,141,60],[240,59,32],[189,0,38]];function re(n,t=!1,e=Float32Array){let o;if(Number.isFinite(n[0]))o=new e(n);else{o=new e(n.length*4);let r=0;for(let i=0;i<n.length;i++){let s=n[i];o[r++]=s[0],o[r++]=s[1],o[r++]=s[2],o[r++]=Number.isFinite(s[3])?s[3]:255}}if(t)for(let r=0;r<o.length;r++)o[r]/=255;return o}var Ot={linear:"linear",quantile:"nearest",quantize:"nearest",ordinal:"nearest"};function Z(n,t){n.setSampler({minFilter:Ot[t],magFilter:Ot[t]})}function Q(n,t,e="linear"){let o=re(t,!1,Uint8Array);return n.createTexture({format:"rgba8unorm",sampler:{minFilter:Ot[e],magFilter:Ot[e],addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},data:o,width:o.length/4,height:1})}var Oe=`#version 300 es
164
+ `;return n.type==="webgl"&&n.getExtension("GL_ARB_shader_bit_encoding"),new Ne.BufferTransform(n,{vs:e,fs:o,topology:"point-list",modules:[we],parameters:{blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendColorOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendAlphaOperation:"max"},defines:{NUM_DIMS:t.dimensions,NUM_CHANNELS:t.channelCount,SAMPLER_WIDTH:dt},varyings:["binIds","values"],disableWarnings:!0})}var ut=L(I(),1),P=class{static isSupported(t){return t.features.has("float32-renderable-webgl")&&t.features.has("texture-blend-float-webgl")}constructor(t,e){this.binCount=0,this.binIds=null,this.results=[],this.device=t,this.dimensions=e.dimensions,this.channelCount=e.channelCount,this.props={...e,pointCount:0,binIdRange:[[0,0]],operations:[],attributes:{},binOptions:{}},this.needsUpdate=new Array(this.channelCount).fill(!0),this.binSorter=new Lt(t,e),this.aggregationTransform=new Pt(t,e),this.setProps(e)}getBins(){let t=this.aggregationTransform.binBuffer;return t?(this.binIds?.buffer!==t&&(this.binIds={buffer:t,type:"float32",size:this.dimensions}),this.binIds):null}getResult(t){let e=this.aggregationTransform.valueBuffer;return!e||t>=this.channelCount?null:(this.results[t]?.buffer!==e&&(this.results[t]={buffer:e,type:"float32",size:1,stride:this.channelCount*4,offset:t*4}),this.results[t])}getResultDomain(t){return this.aggregationTransform.domains[t]}getBin(t){if(t<0||t>=this.binCount)return null;let{binIdRange:e}=this.props,o;if(this.dimensions===1)o=[t+e[0][0]];else{let[[a,c],[g]]=e,h=c-a;o=[t%h+a,Math.floor(t/h)+g]}let r=this.binSorter.getBinValues(t);if(!r)return null;let i=r[3],s=[];for(let a=0;a<this.channelCount;a++){let c=this.props.operations[a];c==="COUNT"?s[a]=i:i===0?s[a]=NaN:s[a]=c==="MEAN"?r[a]/i:r[a]}return{id:o,value:s,count:i}}destroy(){this.binSorter.destroy(),this.aggregationTransform.destroy()}setProps(t){let e=this.props;if("binIdRange"in t&&!(0,ut._deepEqual)(t.binIdRange,e.binIdRange,2)){let o=t.binIdRange;if(ut.log.assert(o.length===this.dimensions),this.dimensions===1){let[[r,i]]=o;this.binCount=i-r}else{let[[r,i],[s,a]]=o;this.binCount=(i-r)*(a-s)}this.binSorter.setDimensions(this.binCount,o),this.aggregationTransform.setDimensions(this.binCount,o),this.setNeedsUpdate()}if(t.operations)for(let o=0;o<this.channelCount;o++)t.operations[o]!==e.operations[o]&&this.setNeedsUpdate(o);if(t.pointCount!==void 0&&t.pointCount!==e.pointCount&&(this.binSorter.setModelProps({vertexCount:t.pointCount}),this.setNeedsUpdate()),t.binOptions&&((0,ut._deepEqual)(t.binOptions,e.binOptions,2)||this.setNeedsUpdate(),this.binSorter.model.shaderInputs.setProps({binOptions:t.binOptions})),t.attributes){let o={},r={};for(let i of Object.values(t.attributes))for(let[s,a]of Object.entries(i.getValue()))ArrayBuffer.isView(a)?r[s]=a:a&&(o[s]=a);this.binSorter.setModelProps({attributes:o,constantAttributes:r})}t.shaderModuleProps&&this.binSorter.setModelProps({shaderModuleProps:t.shaderModuleProps}),Object.assign(this.props,t)}setNeedsUpdate(t){t===void 0?this.needsUpdate.fill(!0):this.needsUpdate[t]=!0}update(){}preDraw(){if(!this.needsUpdate.some(Boolean))return;let{operations:t}=this.props,e=this.needsUpdate.map((o,r)=>o?t[r]:null);this.binSorter.update(e),this.aggregationTransform.update(this.binSorter.texture,t);for(let o=0;o<this.channelCount;o++)this.needsUpdate[o]&&(this.needsUpdate[o]=!1,this.props.onUpdate?.({channel:o}))}};var Nt=L(I(),1),wt=class extends Nt.CompositeLayer{get isDrawable(){return!0}initializeState(){this.getAttributeManager().remove(["instancePickingColors"])}updateState(t){super.updateState(t);let e=this.getAggregatorType();if(t.changeFlags.extensionsChanged||this.state.aggregatorType!==e){this.state.aggregator?.destroy();let o=this.createAggregator(e);return o.setProps({attributes:this.getAttributeManager()?.attributes}),this.setState({aggregator:o,aggregatorType:e}),!0}return!1}finalizeState(t){super.finalizeState(t),this.state.aggregator.destroy()}updateAttributes(t){let{aggregator:e}=this.state;e.setProps({attributes:t});for(let o in t)this.onAttributeChange(o);e.update()}draw({shaderModuleProps:t}){let{aggregator:e}=this.state;e.setProps({shaderModuleProps:t}),e.preDraw()}_getAttributeManager(){return new Nt.AttributeManager(this.context.device,{id:this.props.id,stats:this.context.stats})}};wt.layerName="AggregationLayer";var B=wt;var _t=L($(),1),zt=L(I(),1);var j=[[255,255,178],[254,217,118],[254,178,76],[253,141,60],[240,59,32],[189,0,38]];function re(n,t=!1,e=Float32Array){let o;if(Number.isFinite(n[0]))o=new e(n);else{o=new e(n.length*4);let r=0;for(let i=0;i<n.length;i++){let s=n[i];o[r++]=s[0],o[r++]=s[1],o[r++]=s[2],o[r++]=Number.isFinite(s[3])?s[3]:255}}if(t)for(let r=0;r<o.length;r++)o[r]/=255;return o}var Ot={linear:"linear",quantile:"nearest",quantize:"nearest",ordinal:"nearest"};function Z(n,t){n.setSampler({minFilter:Ot[t],magFilter:Ot[t]})}function Q(n,t,e="linear"){let o=re(t,!1,Uint8Array);return n.createTexture({format:"rgba8unorm",sampler:{minFilter:Ot[e],magFilter:Ot[e],addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},data:o,width:o.length/4,height:1})}var Oe=`#version 300 es
165
165
  #define SHADER_NAME screen-grid-layer-vertex-shader
166
166
  #define RANGE_COUNT 6
167
167
  in vec2 positions;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "deck.gl layers that aggregate the input data into alternative representations",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
- "version": "9.3.0-beta.1",
6
+ "version": "9.3.0-beta.2",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -49,5 +49,5 @@
49
49
  "@luma.gl/core": "~9.3.2",
50
50
  "@luma.gl/engine": "~9.3.2"
51
51
  },
52
- "gitHead": "a8b482631c7b10460411b08c8c674b86176ec191"
52
+ "gitHead": "f150e74afeba9a692974ba41110a5b865ac4787b"
53
53
  }
@@ -222,6 +222,12 @@ void main() {
222
222
  }
223
223
  `;
224
224
 
225
+ // Enable intBitsToFloat on Firefox + Nvidia driver: https://github.com/visgl/deck.gl/pull/10069
226
+ if (device.type === 'webgl') {
227
+ // @ts-expect-error WebGLDevice method
228
+ device.getExtension('GL_ARB_shader_bit_encoding');
229
+ }
230
+
225
231
  return new BufferTransform(device, {
226
232
  vs,
227
233
  fs,