@deck.gl/aggregation-layers 9.0.21 → 9.0.23
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 +1 -3
- package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -1
- package/dist/heatmap-layer/heatmap-layer.js +1 -3
- package/dist/index.cjs +1 -3
- package/dist/index.cjs.map +2 -2
- package/dist.min.js +1 -1
- package/package.json +2 -2
- package/src/heatmap-layer/heatmap-layer.ts +1 -3
package/dist.min.js
CHANGED
|
@@ -504,6 +504,6 @@ void main() {
|
|
|
504
504
|
fragColor = outTexture;
|
|
505
505
|
fragColor.g = outTexture.r / max(1.0, outTexture.a);
|
|
506
506
|
}
|
|
507
|
-
`;var _r=2,de={format:"rgba8unorm",mipmaps:!1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}},ai=[0,0],br={SUM:0,MEAN:1},Mr={getPosition:{type:"accessor",value:n=>n.position},getWeight:{type:"accessor",value:1},intensity:{type:"number",min:0,value:1},radiusPixels:{type:"number",min:1,max:100,value:50},colorRange:D,threshold:{type:"number",min:0,max:1,value:.05},colorDomain:{type:"array",value:null,optional:!0},aggregation:"SUM",weightsTextureSize:{type:"number",min:128,max:2048,value:2048},debounceTimeout:{type:"number",min:0,max:1e3,value:500}},Tr=["float32-renderable-webgl","texture-blend-float-webgl"],Cr={data:{props:["radiusPixels"]}},Kt=class extends P{initializeState(){super.initializeAggregationLayer(Cr),this.setState({colorDomain:ai}),this._setupTextureParams(),this._setupAttributes(),this._setupResources()}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState(t){super.updateState(t),this._updateHeatmapState(t)}_updateHeatmapState(t){let{props:e,oldProps:o}=t,i=this._getChangeFlags(t);(i.dataChanged||i.viewportChanged)&&(i.boundsChanged=this._updateBounds(i.dataChanged),this._updateTextureRenderingBounds()),i.dataChanged||i.boundsChanged?(clearTimeout(this.state.updateTimer),this.setState({isWeightMapDirty:!0})):i.viewportZoomChanged&&this._debouncedUpdateWeightmap(),e.colorRange!==o.colorRange&&this._updateColorTexture(t),this.state.isWeightMapDirty&&this._updateWeightmap(),this.setState({zoom:t.context.viewport.zoom})}renderLayers(){let{weightsTexture:t,triPositionBuffer:e,triTexCoordBuffer:o,maxWeightsTexture:i,colorTexture:r,colorDomain:s}=this.state,{updateTriggers:a,intensity:l,threshold:c,aggregation:g}=this.props,f=this.getSubLayerClass("triangle",Tt);return new f(this.getSubLayerProps({id:"triangle-layer",updateTriggers:a}),{coordinateSystem:R.COORDINATE_SYSTEM.DEFAULT,data:{attributes:{positions:e,texCoords:o}},vertexCount:4,maxTexture:i,colorTexture:r,aggregationMode:br[g]||0,weightsTexture:t,intensity:l,threshold:c,colorDomain:s})}finalizeState(t){super.finalizeState(t);let{weightsTransform:e,weightsTexture:o,maxWeightTransform:i,maxWeightsTexture:r,triPositionBuffer:s,triTexCoordBuffer:a,colorTexture:l,updateTimer:c}=this.state;e?.destroy(),o?.destroy(),i?.destroy(),r?.destroy(),s?.destroy(),a?.destroy(),l?.destroy(),c&&clearTimeout(c)}_getAttributeManager(){return new R.AttributeManager(this.context.device,{id:this.props.id,stats:this.context.stats})}_getChangeFlags(t){let e={},{dimensions:o}=this.state;e.dataChanged=this.isAttributeChanged()&&"attribute changed"||this.isAggregationDirty(t,{compareAll:!0,dimension:o.data})&&"aggregation is dirty",e.viewportChanged=t.changeFlags.viewportChanged;let{zoom:i}=this.state;return(!t.context.viewport||t.context.viewport.zoom!==i)&&(e.viewportZoomChanged=!0),e}_createTextures(){let{textureSize:t,format:e}=this.state;this.setState({weightsTexture:this.context.device.createTexture({...de,width:t,height:t,format:e}),maxWeightsTexture:this.context.device.createTexture({...de,width:1,height:1,format:e})})}_setupAttributes(){this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"},weights:{size:1,accessor:"getWeight"}}),this.setState({positionAttributeName:"positions"})}_setupTextureParams(){let{device:t}=this.context,{weightsTextureSize:e}=this.props,o=Math.min(e,t.limits.maxTextureDimension2D),i=Tr.every(a=>t.features.has(a)),r=i?"rgba32float":"rgba8unorm",s=i?1:1/255;this.setState({textureSize:o,format:r,weightsScale:s}),i||R.log.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)()}_createWeightsTransform(t){let{weightsTransform:e}=this.state,{weightsTexture:o}=this.state,i=this.getAttributeManager();e?.destroy(),e=new pe.TextureTransform(this.context.device,{id:`${this.id}-weights-transform`,bufferLayout:i.getBufferLayouts(),vertexCount:1,targetTexture:o,parameters:{depthWriteEnabled:!1,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},topology:"point-list",...t}),this.setState({weightsTransform:e})}_setupResources(){this._createTextures();let{device:t}=this.context,{textureSize:e,weightsTexture:o,maxWeightsTexture:i}=this.state,r=this.getShaders({vs:ge,fs:fe});this._createWeightsTransform(r);let s=this.getShaders({vs:ni,fs:si}),a=new pe.TextureTransform(t,{id:`${this.id}-max-weights-transform`,bindings:{inTexture:o},uniforms:{textureSize:e},targetTexture:i,...s,vertexCount:e*e,topology:"point-list",parameters:{depthWriteEnabled:!1,blendColorOperation:"max",blendAlphaOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}});this.setState({weightsTexture:o,maxWeightsTexture:i,maxWeightTransform:a,zoom:null,triPositionBuffer:t.createBuffer({byteLength:48}),triTexCoordBuffer:t.createBuffer({byteLength:48})})}updateShaders(t){this._createWeightsTransform({vs:ge,fs:fe,...t})}_updateMaxWeightValue(){let{maxWeightTransform:t}=this.state;t.run({parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]})}_updateBounds(t=!1){let{viewport:e}=this.context,o=[e.unproject([0,0]),e.unproject([e.width,0]),e.unproject([e.width,e.height]),e.unproject([0,e.height])].map(a=>a.map(Math.fround)),i=Zo(o),r={visibleWorldBounds:i,viewportCorners:o},s=!1;if(t||!this.state.worldBounds||!Jo(this.state.worldBounds,i)){let a=this._worldToCommonBounds(i),l=this._commonToWorldBounds(a);this.props.coordinateSystem===R.COORDINATE_SYSTEM.LNGLAT&&(l[1]=Math.max(l[1],-85.051129),l[3]=Math.min(l[3],85.051129),l[0]=Math.max(l[0],-360),l[2]=Math.min(l[2],360));let c=this._worldToCommonBounds(l);r.worldBounds=l,r.normalizedCommonBounds=c,s=!0}return this.setState(r),s}_updateTextureRenderingBounds(){let{triPositionBuffer:t,triTexCoordBuffer:e,normalizedCommonBounds:o,viewportCorners:i}=this.state,{viewport:r}=this.context;t.write(ce(i,3));let s=i.map(a=>ei(r.projectPosition(a),o));e.write(ce(s,2))}_updateColorTexture(t){let{colorRange:e}=t.props,{colorTexture:o}=this.state,i=z(e,!1,Uint8Array);o&&o?.width===e.length?o.setSubImageData({data:i}):(o?.destroy(),o=this.context.device.createTexture({...de,data:i,width:e.length,height:1})),this.setState({colorTexture:o})}_updateWeightmap(){let{radiusPixels:t,colorDomain:e,aggregation:o}=this.props,{worldBounds:i,textureSize:r,weightsScale:s}=this.state,a=this.state.weightsTransform;this.state.isWeightMapDirty=!1;let l=this._worldToCommonBounds(i,{useLayerCoordinateSystem:!0});if(e&&o==="SUM"){let{viewport:
|
|
507
|
+
`;var _r=2,de={format:"rgba8unorm",mipmaps:!1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}},ai=[0,0],br={SUM:0,MEAN:1},Mr={getPosition:{type:"accessor",value:n=>n.position},getWeight:{type:"accessor",value:1},intensity:{type:"number",min:0,value:1},radiusPixels:{type:"number",min:1,max:100,value:50},colorRange:D,threshold:{type:"number",min:0,max:1,value:.05},colorDomain:{type:"array",value:null,optional:!0},aggregation:"SUM",weightsTextureSize:{type:"number",min:128,max:2048,value:2048},debounceTimeout:{type:"number",min:0,max:1e3,value:500}},Tr=["float32-renderable-webgl","texture-blend-float-webgl"],Cr={data:{props:["radiusPixels"]}},Kt=class extends P{initializeState(){super.initializeAggregationLayer(Cr),this.setState({colorDomain:ai}),this._setupTextureParams(),this._setupAttributes(),this._setupResources()}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState(t){super.updateState(t),this._updateHeatmapState(t)}_updateHeatmapState(t){let{props:e,oldProps:o}=t,i=this._getChangeFlags(t);(i.dataChanged||i.viewportChanged)&&(i.boundsChanged=this._updateBounds(i.dataChanged),this._updateTextureRenderingBounds()),i.dataChanged||i.boundsChanged?(clearTimeout(this.state.updateTimer),this.setState({isWeightMapDirty:!0})):i.viewportZoomChanged&&this._debouncedUpdateWeightmap(),e.colorRange!==o.colorRange&&this._updateColorTexture(t),this.state.isWeightMapDirty&&this._updateWeightmap(),this.setState({zoom:t.context.viewport.zoom})}renderLayers(){let{weightsTexture:t,triPositionBuffer:e,triTexCoordBuffer:o,maxWeightsTexture:i,colorTexture:r,colorDomain:s}=this.state,{updateTriggers:a,intensity:l,threshold:c,aggregation:g}=this.props,f=this.getSubLayerClass("triangle",Tt);return new f(this.getSubLayerProps({id:"triangle-layer",updateTriggers:a}),{coordinateSystem:R.COORDINATE_SYSTEM.DEFAULT,data:{attributes:{positions:e,texCoords:o}},vertexCount:4,maxTexture:i,colorTexture:r,aggregationMode:br[g]||0,weightsTexture:t,intensity:l,threshold:c,colorDomain:s})}finalizeState(t){super.finalizeState(t);let{weightsTransform:e,weightsTexture:o,maxWeightTransform:i,maxWeightsTexture:r,triPositionBuffer:s,triTexCoordBuffer:a,colorTexture:l,updateTimer:c}=this.state;e?.destroy(),o?.destroy(),i?.destroy(),r?.destroy(),s?.destroy(),a?.destroy(),l?.destroy(),c&&clearTimeout(c)}_getAttributeManager(){return new R.AttributeManager(this.context.device,{id:this.props.id,stats:this.context.stats})}_getChangeFlags(t){let e={},{dimensions:o}=this.state;e.dataChanged=this.isAttributeChanged()&&"attribute changed"||this.isAggregationDirty(t,{compareAll:!0,dimension:o.data})&&"aggregation is dirty",e.viewportChanged=t.changeFlags.viewportChanged;let{zoom:i}=this.state;return(!t.context.viewport||t.context.viewport.zoom!==i)&&(e.viewportZoomChanged=!0),e}_createTextures(){let{textureSize:t,format:e}=this.state;this.setState({weightsTexture:this.context.device.createTexture({...de,width:t,height:t,format:e}),maxWeightsTexture:this.context.device.createTexture({...de,width:1,height:1,format:e})})}_setupAttributes(){this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"},weights:{size:1,accessor:"getWeight"}}),this.setState({positionAttributeName:"positions"})}_setupTextureParams(){let{device:t}=this.context,{weightsTextureSize:e}=this.props,o=Math.min(e,t.limits.maxTextureDimension2D),i=Tr.every(a=>t.features.has(a)),r=i?"rgba32float":"rgba8unorm",s=i?1:1/255;this.setState({textureSize:o,format:r,weightsScale:s}),i||R.log.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)()}_createWeightsTransform(t){let{weightsTransform:e}=this.state,{weightsTexture:o}=this.state,i=this.getAttributeManager();e?.destroy(),e=new pe.TextureTransform(this.context.device,{id:`${this.id}-weights-transform`,bufferLayout:i.getBufferLayouts(),vertexCount:1,targetTexture:o,parameters:{depthWriteEnabled:!1,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},topology:"point-list",...t}),this.setState({weightsTransform:e})}_setupResources(){this._createTextures();let{device:t}=this.context,{textureSize:e,weightsTexture:o,maxWeightsTexture:i}=this.state,r=this.getShaders({vs:ge,fs:fe});this._createWeightsTransform(r);let s=this.getShaders({vs:ni,fs:si}),a=new pe.TextureTransform(t,{id:`${this.id}-max-weights-transform`,bindings:{inTexture:o},uniforms:{textureSize:e},targetTexture:i,...s,vertexCount:e*e,topology:"point-list",parameters:{depthWriteEnabled:!1,blendColorOperation:"max",blendAlphaOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}});this.setState({weightsTexture:o,maxWeightsTexture:i,maxWeightTransform:a,zoom:null,triPositionBuffer:t.createBuffer({byteLength:48}),triTexCoordBuffer:t.createBuffer({byteLength:48})})}updateShaders(t){this._createWeightsTransform({vs:ge,fs:fe,...t})}_updateMaxWeightValue(){let{maxWeightTransform:t}=this.state;t.run({parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]})}_updateBounds(t=!1){let{viewport:e}=this.context,o=[e.unproject([0,0]),e.unproject([e.width,0]),e.unproject([e.width,e.height]),e.unproject([0,e.height])].map(a=>a.map(Math.fround)),i=Zo(o),r={visibleWorldBounds:i,viewportCorners:o},s=!1;if(t||!this.state.worldBounds||!Jo(this.state.worldBounds,i)){let a=this._worldToCommonBounds(i),l=this._commonToWorldBounds(a);this.props.coordinateSystem===R.COORDINATE_SYSTEM.LNGLAT&&(l[1]=Math.max(l[1],-85.051129),l[3]=Math.min(l[3],85.051129),l[0]=Math.max(l[0],-360),l[2]=Math.min(l[2],360));let c=this._worldToCommonBounds(l);r.worldBounds=l,r.normalizedCommonBounds=c,s=!0}return this.setState(r),s}_updateTextureRenderingBounds(){let{triPositionBuffer:t,triTexCoordBuffer:e,normalizedCommonBounds:o,viewportCorners:i}=this.state,{viewport:r}=this.context;t.write(ce(i,3));let s=i.map(a=>ei(r.projectPosition(a),o));e.write(ce(s,2))}_updateColorTexture(t){let{colorRange:e}=t.props,{colorTexture:o}=this.state,i=z(e,!1,Uint8Array);o&&o?.width===e.length?o.setSubImageData({data:i}):(o?.destroy(),o=this.context.device.createTexture({...de,data:i,width:e.length,height:1})),this.setState({colorTexture:o})}_updateWeightmap(){let{radiusPixels:t,colorDomain:e,aggregation:o}=this.props,{worldBounds:i,textureSize:r,weightsScale:s}=this.state,a=this.state.weightsTransform;this.state.isWeightMapDirty=!1;let l=this._worldToCommonBounds(i,{useLayerCoordinateSystem:!0});if(e&&o==="SUM"){let{viewport:p}=this.context,x=p.distanceScales.metersPerUnit[2]*(l[2]-l[0])/r;this.state.colorDomain=e.map(h=>h*x*s)}else this.state.colorDomain=e||ai;let g=this.getAttributeManager().getAttributes(),f=this.getModuleSettings(),d={radiusPixels:t,commonBounds:l,textureWidth:r,weightsScale:s};this._setModelAttributes(a.model,g),a.model.setVertexCount(this.getNumInstances()),a.model.setUniforms(d),a.model.updateModuleSettings(f),a.run({parameters:{viewport:[0,0,r,r]},clearColor:[0,0,0,0]}),this._updateMaxWeightValue()}_debouncedUpdateWeightmap(t=!1){let{updateTimer:e}=this.state,{debounceTimeout:o}=this.props;t?(e=null,this._updateBounds(!0),this._updateTextureRenderingBounds(),this.setState({isWeightMapDirty:!0})):(this.setState({isWeightMapDirty:!1}),clearTimeout(e),e=setTimeout(this._debouncedUpdateWeightmap.bind(this,!0),o)),this.setState({updateTimer:e})}_worldToCommonBounds(t,e={}){let{useLayerCoordinateSystem:o=!1}=e,[i,r,s,a]=t,{viewport:l}=this.context,{textureSize:c}=this.state,{coordinateSystem:g}=this.props,f=o&&(g===R.COORDINATE_SYSTEM.LNGLAT_OFFSETS||g===R.COORDINATE_SYSTEM.METER_OFFSETS),d=f?l.projectPosition(this.props.coordinateOrigin):[0,0],p=c*_r/l.scale,x,h;return o&&!f?(x=this.projectPosition([i,r,0]),h=this.projectPosition([s,a,0])):(x=l.projectPosition([i,r,0]),h=l.projectPosition([s,a,0])),ti([x[0]-d[0],x[1]-d[1],h[0]-d[0],h[1]-d[1]],p,p)}_commonToWorldBounds(t){let[e,o,i,r]=t,{viewport:s}=this.context,a=s.unprojectPosition([e,o]),l=s.unprojectPosition([i,r]);return a.slice(0,2).concat(l.slice(0,2))}},Ct=Kt;(()=>{Kt.layerName="HeatmapLayer"})(),(()=>{Kt.defaultProps=Mr})();return pi(Et);})();
|
|
508
508
|
return __exports__;
|
|
509
509
|
});
|
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.0.
|
|
6
|
+
"version": "9.0.23",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"@luma.gl/core": "^9.0.0",
|
|
50
50
|
"@luma.gl/engine": "^9.0.0"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "3574ce735fa6e90e6207bef8edbccac27949d3c1"
|
|
53
53
|
}
|
|
@@ -588,10 +588,8 @@ export default class HeatmapLayer<
|
|
|
588
588
|
const attributeManager = this.getAttributeManager()!;
|
|
589
589
|
const attributes = attributeManager.getAttributes();
|
|
590
590
|
const moduleSettings = this.getModuleSettings();
|
|
591
|
-
const positions = attributes.positions.buffer;
|
|
592
591
|
const uniforms = {radiusPixels, commonBounds, textureWidth: textureSize, weightsScale};
|
|
593
|
-
|
|
594
|
-
weightsTransform.model.setAttributes({positions, weights});
|
|
592
|
+
this._setModelAttributes(weightsTransform.model, attributes);
|
|
595
593
|
weightsTransform.model.setVertexCount(this.getNumInstances());
|
|
596
594
|
weightsTransform.model.setUniforms(uniforms);
|
|
597
595
|
weightsTransform.model.updateModuleSettings(moduleSettings);
|