@deck.gl/aggregation-layers 9.4.0-alpha.1 → 9.4.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/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts.map +1 -1
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js +1 -3
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js.map +1 -1
- package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js +0 -1
- package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js.map +1 -1
- package/dist/dist.dev.js +642 -38
- package/dist/grid-layer/grid-cell-layer.d.ts.map +1 -1
- package/dist/grid-layer/grid-cell-layer.js +3 -2
- package/dist/grid-layer/grid-cell-layer.js.map +1 -1
- package/dist/grid-layer/grid-cell-layer.wgsl.d.ts +3 -0
- package/dist/grid-layer/grid-cell-layer.wgsl.d.ts.map +1 -0
- package/dist/grid-layer/grid-cell-layer.wgsl.js +114 -0
- package/dist/grid-layer/grid-cell-layer.wgsl.js.map +1 -0
- package/dist/grid-layer/grid-layer-uniforms.d.ts +1 -0
- package/dist/grid-layer/grid-layer-uniforms.d.ts.map +1 -1
- package/dist/grid-layer/grid-layer-uniforms.js +14 -0
- package/dist/grid-layer/grid-layer-uniforms.js.map +1 -1
- package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts +2 -0
- package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts.map +1 -1
- package/dist/heatmap-layer/heatmap-layer-uniforms.js +19 -0
- package/dist/heatmap-layer/heatmap-layer-uniforms.js.map +1 -1
- package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -1
- package/dist/heatmap-layer/heatmap-layer.js +59 -12
- package/dist/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/heatmap-layer/max.wgsl.d.ts +3 -0
- package/dist/heatmap-layer/max.wgsl.d.ts.map +1 -0
- package/dist/heatmap-layer/max.wgsl.js +48 -0
- package/dist/heatmap-layer/max.wgsl.js.map +1 -0
- package/dist/heatmap-layer/triangle-layer-uniforms.d.ts +1 -0
- package/dist/heatmap-layer/triangle-layer-uniforms.d.ts.map +1 -1
- package/dist/heatmap-layer/triangle-layer-uniforms.js +16 -0
- package/dist/heatmap-layer/triangle-layer-uniforms.js.map +1 -1
- package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -1
- package/dist/heatmap-layer/triangle-layer.js +3 -2
- package/dist/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/heatmap-layer/triangle-layer.wgsl.d.ts +3 -0
- package/dist/heatmap-layer/triangle-layer.wgsl.d.ts.map +1 -0
- package/dist/heatmap-layer/triangle-layer.wgsl.js +65 -0
- package/dist/heatmap-layer/triangle-layer.wgsl.js.map +1 -0
- package/dist/heatmap-layer/weights.wgsl.d.ts +3 -0
- package/dist/heatmap-layer/weights.wgsl.d.ts.map +1 -0
- package/dist/heatmap-layer/weights.wgsl.js +64 -0
- package/dist/heatmap-layer/weights.wgsl.js.map +1 -0
- package/dist/hexagon-layer/hexagon-cell-layer.d.ts.map +1 -1
- package/dist/hexagon-layer/hexagon-cell-layer.js +2 -2
- package/dist/hexagon-layer/hexagon-cell-layer.js.map +1 -1
- package/dist/hexagon-layer/hexagon-cell-layer.wgsl.d.ts +3 -0
- package/dist/hexagon-layer/hexagon-cell-layer.wgsl.d.ts.map +1 -0
- package/dist/hexagon-layer/hexagon-cell-layer.wgsl.js +120 -0
- package/dist/hexagon-layer/hexagon-cell-layer.wgsl.js.map +1 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts +1 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts.map +1 -1
- package/dist/hexagon-layer/hexagon-layer-uniforms.js +13 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.js.map +1 -1
- package/dist/index.cjs +13268 -1488
- package/dist/index.cjs.map +3 -4
- package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts +1 -6
- package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
- package/dist/screen-grid-layer/screen-grid-cell-layer.js +3 -2
- package/dist/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
- package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.d.ts +3 -0
- package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.d.ts.map +1 -0
- package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.js +76 -0
- package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.js.map +1 -0
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts +1 -0
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts.map +1 -1
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.js +12 -0
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.js.map +1 -1
- package/dist.min.js +545 -35
- package/dist.webgl-only/common/aggregation-layer.js +68 -0
- package/dist.webgl-only/common/aggregation-layer.js.map +1 -0
- package/dist.webgl-only/common/aggregator/aggregator.js +5 -0
- package/dist.webgl-only/common/aggregator/aggregator.js.map +1 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/aggregate.js +69 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/aggregate.js.map +1 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/cpu-aggregator.js +141 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/cpu-aggregator.js.map +1 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/sort-bins.js +44 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/sort-bins.js.map +1 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/vertex-accessor.js +56 -0
- package/dist.webgl-only/common/aggregator/cpu-aggregator/vertex-accessor.js.map +1 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js +22 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/aggregation-transform-uniforms.js.map +1 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js +18 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/bin-sorter-uniforms.js.map +1 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/utils.js +24 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/utils.js.map +1 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js +222 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js.map +1 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/webgl-aggregator.js +203 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/webgl-aggregator.js.map +1 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/webgl-bin-sorter.js +225 -0
- package/dist.webgl-only/common/aggregator/gpu-aggregator/webgl-bin-sorter.js.map +1 -0
- package/dist.webgl-only/common/aggregator/index.js +6 -0
- package/dist.webgl-only/common/aggregator/index.js.map +1 -0
- package/dist.webgl-only/common/types.js +5 -0
- package/dist.webgl-only/common/types.js.map +1 -0
- package/dist.webgl-only/common/utils/bounds-utils.js +21 -0
- package/dist.webgl-only/common/utils/bounds-utils.js.map +1 -0
- package/dist.webgl-only/common/utils/color-utils.js +65 -0
- package/dist.webgl-only/common/utils/color-utils.js.map +1 -0
- package/dist.webgl-only/common/utils/prop-utils.js +13 -0
- package/dist.webgl-only/common/utils/prop-utils.js.map +1 -0
- package/dist.webgl-only/common/utils/scale-utils.js +181 -0
- package/dist.webgl-only/common/utils/scale-utils.js.map +1 -0
- package/dist.webgl-only/contour-layer/bin-options-uniforms.js +18 -0
- package/dist.webgl-only/contour-layer/bin-options-uniforms.js.map +1 -0
- package/dist.webgl-only/contour-layer/contour-layer.js +282 -0
- package/dist.webgl-only/contour-layer/contour-layer.js.map +1 -0
- package/dist.webgl-only/contour-layer/contour-utils.js +60 -0
- package/dist.webgl-only/contour-layer/contour-utils.js.map +1 -0
- package/dist.webgl-only/contour-layer/marching-squares-codes.js +341 -0
- package/dist.webgl-only/contour-layer/marching-squares-codes.js.map +1 -0
- package/dist.webgl-only/contour-layer/marching-squares.js +151 -0
- package/dist.webgl-only/contour-layer/marching-squares.js.map +1 -0
- package/dist.webgl-only/contour-layer/value-reader.js +47 -0
- package/dist.webgl-only/contour-layer/value-reader.js.map +1 -0
- package/dist.webgl-only/grid-layer/bin-options-uniforms.js +18 -0
- package/dist.webgl-only/grid-layer/bin-options-uniforms.js.map +1 -0
- package/dist.webgl-only/grid-layer/grid-cell-layer-vertex.glsl.js +51 -0
- package/dist.webgl-only/grid-layer/grid-cell-layer-vertex.glsl.js.map +1 -0
- package/dist.webgl-only/grid-layer/grid-cell-layer.js +95 -0
- package/dist.webgl-only/grid-layer/grid-cell-layer.js.map +1 -0
- package/dist.webgl-only/grid-layer/grid-cell-layer.wgsl.js +5 -0
- package/dist.webgl-only/grid-layer/grid-cell-layer.wgsl.js.map +1 -0
- package/dist.webgl-only/grid-layer/grid-layer-uniforms.js +26 -0
- package/dist.webgl-only/grid-layer/grid-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/grid-layer/grid-layer.js +362 -0
- package/dist.webgl-only/grid-layer/grid-layer.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/aggregation-layer.js +140 -0
- package/dist.webgl-only/heatmap-layer/aggregation-layer.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/heatmap-layer-uniforms.js +36 -0
- package/dist.webgl-only/heatmap-layer/heatmap-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/heatmap-layer-utils.js +67 -0
- package/dist.webgl-only/heatmap-layer/heatmap-layer-utils.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/heatmap-layer.js +513 -0
- package/dist.webgl-only/heatmap-layer/heatmap-layer.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/max-fs.glsl.js +13 -0
- package/dist.webgl-only/heatmap-layer/max-fs.glsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/max-vs.glsl.js +18 -0
- package/dist.webgl-only/heatmap-layer/max-vs.glsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/max.wgsl.js +5 -0
- package/dist.webgl-only/heatmap-layer/max.wgsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer-fragment.glsl.js +34 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer-fragment.glsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer-uniforms.js +25 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer-vertex.glsl.js +28 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer-vertex.glsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer.js +49 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer.wgsl.js +5 -0
- package/dist.webgl-only/heatmap-layer/triangle-layer.wgsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/weights-fs.glsl.js +21 -0
- package/dist.webgl-only/heatmap-layer/weights-fs.glsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/weights-vs.glsl.js +21 -0
- package/dist.webgl-only/heatmap-layer/weights-vs.glsl.js.map +1 -0
- package/dist.webgl-only/heatmap-layer/weights.wgsl.js +5 -0
- package/dist.webgl-only/heatmap-layer/weights.wgsl.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/bin-options-uniforms.js +18 -0
- package/dist.webgl-only/hexagon-layer/bin-options-uniforms.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/hexagon-cell-layer-vertex.glsl.js +55 -0
- package/dist.webgl-only/hexagon-layer/hexagon-cell-layer-vertex.glsl.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/hexagon-cell-layer.js +90 -0
- package/dist.webgl-only/hexagon-layer/hexagon-cell-layer.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/hexagon-cell-layer.wgsl.js +5 -0
- package/dist.webgl-only/hexagon-layer/hexagon-cell-layer.wgsl.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/hexagon-layer-uniforms.js +24 -0
- package/dist.webgl-only/hexagon-layer/hexagon-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/hexagon-layer.js +360 -0
- package/dist.webgl-only/hexagon-layer/hexagon-layer.js.map +1 -0
- package/dist.webgl-only/hexagon-layer/hexbin.js +70 -0
- package/dist.webgl-only/hexagon-layer/hexbin.js.map +1 -0
- package/dist.webgl-only/index.cjs +15625 -0
- package/dist.webgl-only/index.cjs.map +6 -0
- package/dist.webgl-only/index.js +11 -0
- package/dist.webgl-only/index.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/bin-options-uniforms.js +16 -0
- package/dist.webgl-only/screen-grid-layer/bin-options-uniforms.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-cell-layer.js +88 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-cell-layer.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-cell-layer.wgsl.js +5 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-cell-layer.wgsl.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer-fragment.glsl.js +16 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer-fragment.glsl.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer-uniforms.js +22 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer-vertex.glsl.js +31 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +1 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer.js +194 -0
- package/dist.webgl-only/screen-grid-layer/screen-grid-layer.js.map +1 -0
- package/package.json +14 -5
- package/src/common/aggregator/gpu-aggregator/webgl-aggregation-transform.ts +1 -3
- package/src/common/aggregator/gpu-aggregator/webgl-bin-sorter.ts +0 -1
- package/src/grid-layer/grid-cell-layer.ts +3 -2
- package/src/grid-layer/grid-cell-layer.wgsl.ts +114 -0
- package/src/grid-layer/grid-layer-uniforms.ts +15 -0
- package/src/heatmap-layer/heatmap-layer-uniforms.ts +20 -0
- package/src/heatmap-layer/heatmap-layer.ts +67 -13
- package/src/heatmap-layer/max.wgsl.ts +48 -0
- package/src/heatmap-layer/triangle-layer-uniforms.ts +17 -0
- package/src/heatmap-layer/triangle-layer.ts +3 -2
- package/src/heatmap-layer/triangle-layer.wgsl.ts +65 -0
- package/src/heatmap-layer/weights.wgsl.ts +64 -0
- package/src/hexagon-layer/hexagon-cell-layer.ts +2 -3
- package/src/hexagon-layer/hexagon-cell-layer.wgsl.ts +120 -0
- package/src/hexagon-layer/hexagon-layer-uniforms.ts +14 -0
- package/src/screen-grid-layer/screen-grid-cell-layer.ts +4 -4
- package/src/screen-grid-layer/screen-grid-cell-layer.wgsl.ts +76 -0
- package/src/screen-grid-layer/screen-grid-layer-uniforms.ts +13 -0
package/dist.min.js
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
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 Ro=Object.create;var wt=Object.defineProperty;var Io=Object.getOwnPropertyDescriptor;var zo=Object.getOwnPropertyNames;var Wo=Object.getPrototypeOf,Vo=Object.prototype.hasOwnProperty;var ee=(n,t)=>()=>{try{return t||n((t={exports:{}}).exports,t),t.exports}catch(e){throw t=0,e}},Fo=(n,t)=>{for(var e in t)wt(n,e,{get:t[e],enumerable:!0})},Tt=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of zo(t))!Vo.call(n,i)&&i!==e&&wt(n,i,{get:()=>t[i],enumerable:!(o=Io(t,i))||o.enumerable});return n},k=(n,t,e)=>(Tt(n,t,"default"),e&&Tt(e,t,"default")),w=(n,t,e)=>(e=n!=null?Ro(Wo(n)):{},Tt(t||!n||!n.__esModule?wt(e,"default",{value:n,enumerable:!0}):e,n)),Do=n=>Tt(wt({},"__esModule",{value:!0}),n);var Z=ee((Zi,me)=>{me.exports=globalThis.deck});var z=ee((Qi,xe)=>{xe.exports=globalThis.deck});var $=ee((sr,Ae)=>{Ae.exports=globalThis.luma});var Et={};Fo(Et,{CPUAggregator:()=>N,ContourLayer:()=>eo,GridLayer:()=>lo,HeatmapLayer:()=>Oo,HexagonLayer:()=>Ke,ScreenGridLayer:()=>Fe,WebGLAggregator:()=>L,_AggregationLayer:()=>B});var D={},de=w(Z(),1);k(D,w(Z(),1));if(!de.GeoJsonLayer)throw new Error("@deck.gl/layers is not found");k(Et,D);var Ve=w(z(),1);var Se=w(z(),1);function ve({pointCount:n,getBinId:t}){let e=new Map;for(let o=0;o<n;o++){let i=t(o);if(i===null)continue;let r=e.get(String(i));r?r.points.push(o):(r={id:i,index:e.size,points:[o]},e.set(String(i),r))}return Array.from(e.values())}function ye({bins:n,dimensions:t,target:e}){let o=n.length*t;(!e||e.length<o)&&(e=new Float32Array(o));for(let i=0;i<n.length;i++){let{id:r}=n[i];Array.isArray(r)?e.set(r,i*t):e[i]=r}return e}var Bo=n=>n.length,Me=(n,t)=>{let e=0;for(let o of n)e+=t(o);return e},Uo=(n,t)=>n.length===0?NaN:Me(n,t)/n.length,Ho=(n,t)=>{let e=1/0;for(let o of n){let i=t(o);i<e&&(e=i)}return e},ko=(n,t)=>{let e=-1/0;for(let o of n){let i=t(o);i>e&&(e=i)}return e},be={COUNT:Bo,SUM:Me,MEAN:Uo,MIN:Ho,MAX:ko};function Ce({bins:n,getValue:t,operation:e,target:o}){(!o||o.length<n.length)&&(o=new Float32Array(n.length));let i=1/0,r=-1/0;for(let s=0;s<n.length;s++){let{points:a}=n[s];o[s]=e(a,t),o[s]<i&&(i=o[s]),o[s]>r&&(r=o[s])}return{value:o,domain:[i,r]}}function ne(n,t,e){let o={};for(let r of n.sources||[]){let s=t[r];if(s)o[r]=jo(s);else throw new Error(`Cannot find attribute ${r}`)}let i={};return r=>{for(let s in o)i[s]=o[s](r);return n.getValue(i,r,e)}}function jo(n){let t=n.value,{offset:e=0,stride:o,size:i}=n.getAccessor(),r=t.BYTES_PER_ELEMENT,s=e/r,a=o?o/r:i;if(i===1)return n.isConstant?()=>t[0]:g=>{let h=s+a*g;return t[h]};let c;return n.isConstant?(c=Array.from(t),()=>c):(c=new Array(i),g=>{let h=s+a*g;for(let u=0;u<i;u++)c[u]=t[h+u];return c})}var N=class{constructor(t){this.bins=[],this.binIds=null,this.results=[],this.dimensions=t.dimensions,this.channelCount=t.getValue.length,this.props={...t,binOptions:{},pointCount:0,operations:[],customOperations:[],attributes:{}},this.needsUpdate=!0,this.setProps(t)}destroy(){}get binCount(){return this.bins.length}setProps(t){let e=this.props;if(t.binOptions&&((0,Se._deepEqual)(t.binOptions,e.binOptions,2)||this.setNeedsUpdate()),t.operations)for(let o=0;o<this.channelCount;o++)t.operations[o]!==e.operations[o]&&this.setNeedsUpdate(o);if(t.customOperations)for(let o=0;o<this.channelCount;o++)!!t.customOperations[o]!=!!e.customOperations[o]&&this.setNeedsUpdate(o);t.pointCount!==void 0&&t.pointCount!==e.pointCount&&this.setNeedsUpdate(),t.attributes&&(t.attributes={...e.attributes,...t.attributes}),Object.assign(this.props,t)}setNeedsUpdate(t){t===void 0?this.needsUpdate=!0:this.needsUpdate!==!0&&(this.needsUpdate=this.needsUpdate||[],this.needsUpdate[t]=!0)}update(){if(this.needsUpdate===!0){this.bins=ve({pointCount:this.props.pointCount,getBinId:ne(this.props.getBin,this.props.attributes,this.props.binOptions)});let t=ye({bins:this.bins,dimensions:this.dimensions,target:this.binIds?.value});this.binIds={value:t,type:"float32",size:this.dimensions}}for(let t=0;t<this.channelCount;t++)if(this.needsUpdate===!0||this.needsUpdate[t]){let e=this.props.customOperations[t]||be[this.props.operations[t]],{value:o,domain:i}=Ce({bins:this.bins,getValue:ne(this.props.getValue[t],this.props.attributes,void 0),operation:e,target:this.results[t]?.value});this.results[t]={value:o,domain:i,type:"float32",size:1},this.props.onUpdate?.({channel:t})}this.needsUpdate=!1}preDraw(){}getBins(){return this.binIds}getResult(t){return this.results[t]}getResultDomain(t){return this.results[t]?.domain??[1/0,-1/0]}getBin(t){let e=this.bins[t];if(!e)return null;let o=new Array(this.channelCount);for(let i=0;i<o.length;i++){let r=this.results[i];o[i]=r?.value[t]}return{id:e.id,value:o,count:e.points.length,pointIndices:e.points}}};var we=w($(),1);function Lt(n,t,e){return n.createFramebuffer({width:t,height:e,colorAttachments:[n.createTexture({width:t,height:e,format:"rgba32float",sampler:{minFilter:"nearest",magFilter:"nearest"}})]})}var Go=`layout(std140) uniform binSorterUniforms {
|
|
8
8
|
ivec4 binIdRange;
|
|
9
9
|
ivec2 targetSize;
|
|
10
10
|
} binSorter;
|
|
11
|
-
`,Ee={name:"binSorter",vs:
|
|
11
|
+
`,Ee={name:"binSorter",vs:Go,uniformTypes:{binIdRange:"vec4<i32>",targetSize:"vec2<i32>"}};var Le=[1,2,4,8],Te=3e38,qo={SUM:0,MEAN:0,MIN:0,MAX:0,COUNT:0},dt=1024,Pt=class{constructor(t,e){this.binsFBO=null,this.device=t,this.model=$o(t,e)}get texture(){return this.binsFBO?this.binsFBO.colorAttachments[0].texture:null}destroy(){this.model.destroy(),this.binsFBO?.colorAttachments[0].texture.destroy(),this.binsFBO?.destroy()}getBinValues(t){if(!this.binsFBO)return null;let e=t%dt,o=Math.floor(t/dt),i=this.device.readPixelsToArrayWebGL(this.binsFBO,{sourceX:e,sourceY:o,sourceWidth:1,sourceHeight:1}).buffer;return new Float32Array(i)}setDimensions(t,e){let o=dt,i=Math.ceil(t/o);this.binsFBO?this.binsFBO.height<i&&this.binsFBO.resize({width:o,height:i}):this.binsFBO=Lt(this.device,o,i);let r={binIdRange:[e[0][0],e[0][1],e[1]?.[0]||0,e[1]?.[1]||0],targetSize:[this.binsFBO.width,this.binsFBO.height]};this.model.shaderInputs.setProps({binSorter:r})}setModelProps(t){let e=this.model;t.attributes&&e.setAttributes(t.attributes),t.constantAttributes&&e.setConstantAttributes(t.constantAttributes),t.vertexCount!==void 0&&e.setVertexCount(t.vertexCount),t.shaderModuleProps&&e.shaderInputs.setProps(t.shaderModuleProps)}update(t){if(!this.binsFBO)return;let e=Yo(t);this._updateBins("SUM",e.SUM+e.MEAN),this._updateBins("MIN",e.MIN),this._updateBins("MAX",e.MAX)}_updateBins(t,e){if(e===0)return;e|=Le[3];let o=this.model,i=this.binsFBO,r=t==="MAX"?-Te:t==="MIN"?Te:0,s=this.device.beginRenderPass({id:`gpu-aggregation-${t}`,framebuffer:i,parameters:{viewport:[0,0,i.width,i.height],colorMask:e},clearColor:[r,r,r,0],clearDepth:!1,clearStencil:!1});o.setParameters({blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one",blendColorOperation:t==="MAX"?"max":t==="MIN"?"min":"add",blendAlphaOperation:"add"}),o.draw(s),s.end()}};function Yo(n){let t={...qo};for(let e=0;e<n.length;e++){let o=n[e];o&&(t[o]+=Le[e])}return t}function $o(n,t){let e=t.vs;t.dimensions===2&&(e+=`
|
|
12
12
|
void getBin(out int binId) {
|
|
13
13
|
ivec2 binId2;
|
|
14
14
|
getBin(binId2);
|
|
@@ -47,7 +47,7 @@ void main() {
|
|
|
47
47
|
getValue(v_Value.x);
|
|
48
48
|
#endif
|
|
49
49
|
}
|
|
50
|
-
`,
|
|
50
|
+
`,i=`#version 300 es
|
|
51
51
|
#define SHADER_NAME gpu-aggregation-sort-bins-fragment
|
|
52
52
|
|
|
53
53
|
precision highp float;
|
|
@@ -65,13 +65,13 @@ void main() {
|
|
|
65
65
|
|
|
66
66
|
fragColor.w = 1.0;
|
|
67
67
|
}
|
|
68
|
-
`;return new
|
|
68
|
+
`;return new we.Model(n,{bufferLayout:t.bufferLayout,modules:[...t.modules||[],Ee],defines:{...t.defines,NON_INSTANCED_MODEL:1,NUM_CHANNELS:t.channelCount},isInstanced:!1,vs:o,fs:i,topology:"point-list",disableWarnings:!0})}var _e=w($(),1);var Xo=`layout(std140) uniform aggregatorTransformUniforms {
|
|
69
69
|
ivec4 binIdRange;
|
|
70
70
|
bvec3 isCount;
|
|
71
71
|
bvec3 isMean;
|
|
72
72
|
float naN;
|
|
73
73
|
} aggregatorTransform;
|
|
74
|
-
`,
|
|
74
|
+
`,Pe={name:"aggregatorTransform",vs:Xo,uniformTypes:{binIdRange:"vec4<i32>",isCount:"vec3<f32>",isMean:"vec3<f32>",naN:"f32"}};var oe=3e38,_t=class{constructor(t,e){this.binBuffer=null,this.valueBuffer=null,this._domains=null,this.device=t,this.channelCount=e.channelCount,this.transform=Zo(t,e),this.domainFBO=Lt(t,2,1)}destroy(){this.transform.destroy(),this.binBuffer?.destroy(),this.valueBuffer?.destroy(),this.domainFBO.colorAttachments[0].texture.destroy(),this.domainFBO.destroy()}get domains(){if(!this._domains){let t=this.device.readPixelsToArrayWebGL(this.domainFBO).buffer,e=new Float32Array(t);this._domains=[[-e[4],e[0]],[-e[5],e[1]],[-e[6],e[2]]].slice(0,this.channelCount)}return this._domains}setDimensions(t,e){let{model:o,transformFeedback:i}=this.transform;o.setVertexCount(t);let r={binIdRange:[e[0][0],e[0][1],e[1]?.[0]||0,e[1]?.[1]||0]};o.shaderInputs.setProps({aggregatorTransform:r});let s=t*e.length*4;(!this.binBuffer||this.binBuffer.byteLength<s)&&(this.binBuffer?.destroy(),this.binBuffer=this.device.createBuffer({byteLength:s}),i.setBuffer("binIds",this.binBuffer));let a=t*this.channelCount*4;(!this.valueBuffer||this.valueBuffer.byteLength<a)&&(this.valueBuffer?.destroy(),this.valueBuffer=this.device.createBuffer({byteLength:a}),i.setBuffer("values",this.valueBuffer))}update(t,e){if(!t)return;let o=this.transform,i=this.domainFBO,r=[0,1,2].map(c=>e[c]==="COUNT"?1:0),s=[0,1,2].map(c=>e[c]==="MEAN"?1:0),a={isCount:r,isMean:s,bins:t};o.model.shaderInputs.setProps({aggregatorTransform:a}),o.run({id:"gpu-aggregation-domain",framebuffer:i,discard:!1,parameters:{viewport:[0,0,2,1]},clearColor:[-oe,-oe,-oe,0],clearDepth:!1,clearStencil:!1}),this._domains=null}};function Zo(n,t){let e=`#version 300 es
|
|
75
75
|
#define SHADER_NAME gpu-aggregation-domain-vertex
|
|
76
76
|
|
|
77
77
|
uniform sampler2D bins;
|
|
@@ -161,7 +161,78 @@ void main() {
|
|
|
161
161
|
fragColor = vec4(-value3, 1.0);
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
`;return n.type==="webgl"&&n.getExtension("GL_ARB_shader_bit_encoding"),new
|
|
164
|
+
`;return n.type==="webgl"&&n.getExtension("GL_ARB_shader_bit_encoding"),new _e.BufferTransform(n,{vs:e,fs:o,topology:"point-list",modules:[Pe],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 xt=w(z(),1),L=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 Pt(t,e),this.aggregationTransform=new _t(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 i=this.binSorter.getBinValues(t);if(!i)return null;let r=i[3],s=[];for(let a=0;a<this.channelCount;a++){let c=this.props.operations[a];c==="COUNT"?s[a]=r:r===0?s[a]=NaN:s[a]=c==="MEAN"?i[a]/r:i[a]}return{id:o,value:s,count:r}}destroy(){this.binSorter.destroy(),this.aggregationTransform.destroy()}setProps(t){let e=this.props;if("binIdRange"in t&&!(0,xt._deepEqual)(t.binIdRange,e.binIdRange,2)){let o=t.binIdRange;if(xt.log.assert(o.length===this.dimensions),this.dimensions===1){let[[i,r]]=o;this.binCount=r-i}else{let[[i,r],[s,a]]=o;this.binCount=(r-i)*(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,xt._deepEqual)(t.binOptions,e.binOptions,2)||this.setNeedsUpdate(),this.binSorter.model.shaderInputs.setProps({binOptions:t.binOptions})),t.attributes){let o={},i={};for(let r of Object.values(t.attributes))for(let[s,a]of Object.entries(r.getValue()))ArrayBuffer.isView(a)?i[s]=a:a&&(o[s]=a);this.binSorter.setModelProps({attributes:o,constantAttributes:i})}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,i)=>o?t[i]: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 Ot=w(z(),1),Nt=class extends Ot.CompositeLayer{get isDrawable(){return!0}initializeState(){}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 Ot.AttributeManager(this.context.device,{id:this.props.id,stats:this.context.stats})}};Nt.layerName="AggregationLayer";var B=Nt;var zt=w($(),1),J=w(z(),1);var j=[[255,255,178],[254,217,118],[254,178,76],[253,141,60],[240,59,32],[189,0,38]];function ie(n,t=!1,e=Float32Array){let o;if(Number.isFinite(n[0]))o=new e(n);else{o=new e(n.length*4);let i=0;for(let r=0;r<n.length;r++){let s=n[r];o[i++]=s[0],o[i++]=s[1],o[i++]=s[2],o[i++]=Number.isFinite(s[3])?s[3]:255}}if(t)for(let i=0;i<o.length;i++)o[i]/=255;return o}var Rt={linear:"linear",quantile:"nearest",quantize:"nearest",ordinal:"nearest"};function K(n,t){n.setSampler({minFilter:Rt[t],magFilter:Rt[t]})}function Q(n,t,e="linear"){let o=ie(t,!1,Uint8Array);return n.createTexture({format:"rgba8unorm",sampler:{minFilter:Rt[e],magFilter:Rt[e],addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},data:o,width:o.length/4,height:1})}var Ne=`
|
|
165
|
+
struct Attributes {
|
|
166
|
+
@builtin(instance_index) instanceIndex: u32,
|
|
167
|
+
@location(0) positions: vec2<f32>,
|
|
168
|
+
@location(1) instancePositions: vec2<f32>,
|
|
169
|
+
@location(2) instanceWeights: f32,
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
struct Varyings {
|
|
173
|
+
@builtin(position) position: vec4<f32>,
|
|
174
|
+
@location(0) color: vec4<f32>,
|
|
175
|
+
@location(1) pickingColor: vec3<f32>,
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
fn sampleColorRange(value: f32, domain: vec2<f32>) -> vec4<f32> {
|
|
179
|
+
let ratio = (value - domain.x) / (domain.y - domain.x);
|
|
180
|
+
return textureSampleLevel(colorRange, colorRangeSampler, vec2<f32>(ratio, 0.5), 0.0);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
@vertex
|
|
184
|
+
fn vertexMain(attributes: Attributes) -> Varyings {
|
|
185
|
+
var output: Varyings;
|
|
186
|
+
output.pickingColor = picking_getPickingColorFromIndex(attributes.instanceIndex);
|
|
187
|
+
|
|
188
|
+
if (attributes.instanceWeights != attributes.instanceWeights) {
|
|
189
|
+
output.position = vec4<f32>(0.0);
|
|
190
|
+
output.color = vec4<f32>(0.0);
|
|
191
|
+
return output;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
var position =
|
|
195
|
+
attributes.instancePositions * screenGrid.gridSizeClipspace +
|
|
196
|
+
attributes.positions * screenGrid.cellSizeClipspace;
|
|
197
|
+
position.x -= 1.0;
|
|
198
|
+
position.y = 1.0 - position.y;
|
|
199
|
+
|
|
200
|
+
output.position = vec4<f32>(position, 0.0, 1.0);
|
|
201
|
+
let colorValue = sampleColorRange(attributes.instanceWeights, screenGrid.colorDomain);
|
|
202
|
+
output.color = vec4<f32>(colorValue.rgb, colorValue.a * layer.opacity);
|
|
203
|
+
return output;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
@fragment
|
|
207
|
+
fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
|
|
208
|
+
if (picking.isActive > 0.5) {
|
|
209
|
+
if (!picking_isColorValid(varyings.pickingColor)) {
|
|
210
|
+
discard;
|
|
211
|
+
}
|
|
212
|
+
return vec4<f32>(varyings.pickingColor, 1.0);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
var color = varyings.color;
|
|
216
|
+
if (picking.isHighlightActive > 0.5) {
|
|
217
|
+
let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
|
|
218
|
+
if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {
|
|
219
|
+
let highLightAlpha = picking.highlightColor.a;
|
|
220
|
+
let blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);
|
|
221
|
+
if (blendedAlpha > 0.0) {
|
|
222
|
+
let highLightRatio = highLightAlpha / blendedAlpha;
|
|
223
|
+
color = vec4<f32>(
|
|
224
|
+
mix(color.rgb, picking.highlightColor.rgb, highLightRatio),
|
|
225
|
+
blendedAlpha
|
|
226
|
+
);
|
|
227
|
+
} else {
|
|
228
|
+
color = vec4<f32>(color.rgb, 0.0);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return deckgl_premultiplied_alpha(color);
|
|
234
|
+
}
|
|
235
|
+
`;var Oe=`#version 300 es
|
|
165
236
|
#define SHADER_NAME screen-grid-layer-vertex-shader
|
|
166
237
|
#define RANGE_COUNT 6
|
|
167
238
|
in vec2 positions;
|
|
@@ -186,7 +257,7 @@ vColor = interp(instanceWeights, screenGrid.colorDomain, colorRange);
|
|
|
186
257
|
vColor.a *= layer.opacity;
|
|
187
258
|
picking_setPickingColorFromInstanceID();
|
|
188
259
|
}
|
|
189
|
-
`;var
|
|
260
|
+
`;var Re=`#version 300 es
|
|
190
261
|
#define SHADER_NAME screen-grid-layer-fragment-shader
|
|
191
262
|
precision highp float;
|
|
192
263
|
in vec4 vColor;
|
|
@@ -195,15 +266,25 @@ void main(void) {
|
|
|
195
266
|
fragColor = vColor;
|
|
196
267
|
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
197
268
|
}
|
|
198
|
-
`;var
|
|
269
|
+
`;var Ko=`
|
|
270
|
+
struct ScreenGridUniforms {
|
|
271
|
+
cellSizeClipspace: vec2<f32>,
|
|
272
|
+
gridSizeClipspace: vec2<f32>,
|
|
273
|
+
colorDomain: vec2<f32>,
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
@group(0) @binding(auto) var<uniform> screenGrid: ScreenGridUniforms;
|
|
277
|
+
@group(0) @binding(auto) var colorRange: texture_2d<f32>;
|
|
278
|
+
@group(0) @binding(auto) var colorRangeSampler: sampler;
|
|
279
|
+
`,Qo=`layout(std140) uniform screenGridUniforms {
|
|
199
280
|
vec2 cellSizeClipspace;
|
|
200
281
|
vec2 gridSizeClipspace;
|
|
201
282
|
vec2 colorDomain;
|
|
202
283
|
} screenGrid;
|
|
203
|
-
`,
|
|
284
|
+
`,Ie={name:"screenGrid",source:Ko,vs:Qo,uniformTypes:{cellSizeClipspace:"vec2<f32>",gridSizeClipspace:"vec2<f32>",colorDomain:"vec2<f32>"}};var It=class extends J.Layer{getShaders(){return super.getShaders({source:Ne,vs:Oe,fs:Re,modules:[J.color,J.picking,Ie]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:2,type:"float32",accessor:"getBin"},instanceWeights:{size:1,type:"float32",accessor:"getWeight"}}),this.state.model=this._getModel()}updateState(t){super.updateState(t);let{props:e,oldProps:o,changeFlags:i}=t,r=this.state.model;if(o.colorRange!==e.colorRange){this.state.colorTexture?.destroy(),this.state.colorTexture=Q(this.context.device,e.colorRange,e.colorScaleType);let s={colorRange:this.state.colorTexture};r.shaderInputs.setProps({screenGrid:s})}else o.colorScaleType!==e.colorScaleType&&K(this.state.colorTexture,e.colorScaleType);if(o.cellMarginPixels!==e.cellMarginPixels||o.cellSizePixels!==e.cellSizePixels||i.viewportChanged){let{width:s,height:a}=this.context.viewport,{cellSizePixels:c,cellMarginPixels:g}=this.props,h=Math.max(c-g,0),u={gridSizeClipspace:[c/s*2,c/a*2],cellSizeClipspace:[h/s*2,h/a*2]};r.shaderInputs.setProps({screenGrid:u})}}finalizeState(t){super.finalizeState(t),this.state.colorTexture?.destroy()}draw({uniforms:t}){let e=this.props.colorDomain(),o=this.state.model,i={colorDomain:e};o.shaderInputs.setProps({screenGrid:i}),o.draw(this.context.renderPass)}_getModel(){return new zt.Model(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new zt.Geometry({topology:"triangle-strip",attributes:{positions:{value:new Float32Array([0,0,1,0,0,1,1,1]),size:2}}}),isInstanced:!0})}};It.layerName="ScreenGridCellLayer";var ze=It;var Jo=`layout(std140) uniform binOptionsUniforms {
|
|
204
285
|
float cellSizePixels;
|
|
205
286
|
} binOptions;
|
|
206
|
-
`,
|
|
287
|
+
`,We={name:"binOptions",vs:Jo,uniformTypes:{cellSizePixels:"f32"}};var ti={cellSizePixels:{type:"number",value:100,min:1},cellMarginPixels:{type:"number",value:2,min:0},colorRange:j,colorScaleType:"linear",getPosition:{type:"accessor",value:n=>n.position},getWeight:{type:"accessor",value:1},gpuAggregation:!0,aggregation:"SUM"},vt=class extends B{getAggregatorType(){return this.props.gpuAggregation&&L.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(t){return t==="cpu"||!L.isSupported(this.context.device)?new N({dimensions:2,getBin:{sources:["positions"],getValue:({positions:e},o,i)=>{let r=this.context.viewport,s=r.project(e),a=i.cellSizePixels;return s[0]<0||s[0]>=r.width||s[1]<0||s[1]>=r.height?null:[Math.floor(s[0]/a),Math.floor(s[1]/a)]}},getValue:[{sources:["counts"],getValue:({counts:e})=>e}]}):new L(this.context.device,{dimensions:2,channelCount:1,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[Ve.project32,We],vs:`
|
|
207
288
|
in vec3 positions;
|
|
208
289
|
in vec3 positions64Low;
|
|
209
290
|
in float counts;
|
|
@@ -217,8 +298,122 @@ DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
|
217
298
|
void getValue(out float weight) {
|
|
218
299
|
weight = counts;
|
|
219
300
|
}
|
|
220
|
-
`})})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},counts:{size:1,accessor:"getWeight"}})}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState(t){let e=super.updateState(t),{props:o,oldProps:
|
|
221
|
-
|
|
301
|
+
`})})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},counts:{size:1,accessor:"getWeight"}})}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState(t){let e=super.updateState(t),{props:o,oldProps:i,changeFlags:r}=t,{cellSizePixels:s,aggregation:a}=o;if(e||r.dataChanged||r.updateTriggersChanged||r.viewportChanged||a!==i.aggregation||s!==i.cellSizePixels){let{width:c,height:g}=this.context.viewport,{aggregator:h}=this.state;h instanceof L&&h.setProps({binIdRange:[[0,Math.ceil(c/s)],[0,Math.ceil(g/s)]]}),h.setProps({pointCount:this.getNumInstances(),operations:[a],binOptions:{cellSizePixels:s}})}return r.viewportChanged&&this.state.aggregator.setNeedsUpdate(),e}onAttributeChange(t){let{aggregator:e}=this.state;switch(t){case"positions":e.setNeedsUpdate();break;case"counts":e.setNeedsUpdate(0);break;default:}}renderLayers(){let{aggregator:t}=this.state,e=this.getSubLayerClass("cells",ze),o=t.getBins(),i=t.getResult(0);return new e(this.props,this.getSubLayerProps({id:"cell-layer"}),{data:{length:t.binCount,attributes:{getBin:o,getWeight:i}},dataComparator:(r,s)=>r.length===s.length,updateTriggers:{getBin:[o],getWeight:[i]},parameters:{depthWriteEnabled:!1,...this.props.parameters},colorDomain:()=>this.props.colorDomain||t.getResultDomain(0),extensions:[]})}getPickingInfo(t){let e=t.info,{index:o}=e;if(o>=0){let i=this.state.aggregator.getBin(o),r;i&&(r={col:i.id[0],row:i.id[1],value:i.value[0],count:i.count},i.pointIndices&&(r.pointIndices=i.pointIndices,r.points=Array.isArray(this.props.data)?i.pointIndices.map(s=>this.props.data[s]):[])),e.object=r}return e}};vt.layerName="ScreenGridLayer";vt.defaultProps=ti;var Fe=vt;var q=w(z(),1);var G=class{constructor(t,e){this.props={scaleType:"linear",lowerPercentile:0,upperPercentile:100},this.domain=null,this.cutoff=null,this.input=t,this.inputLength=e,this.attribute=t}getScalePercentile(){if(!this._percentile){let t=De(this.input,this.inputLength);this._percentile=ni(t)}return this._percentile}getScaleOrdinal(){if(!this._ordinal){let t=De(this.input,this.inputLength);this._ordinal=ei(t)}return this._ordinal}getCutoff({scaleType:t,lowerPercentile:e,upperPercentile:o}){if(t==="quantile")return[e,o-1];if(e>0||o<100){let{domain:i}=this.getScalePercentile(),r=i[Math.floor(e)-1]??-1/0,s=i[Math.floor(o)-1]??1/0;if(t==="ordinal"){let{domain:a}=this.getScaleOrdinal();r=a.findIndex(c=>c>=r),s=a.findIndex(c=>c>s)-1,s===-2&&(s=a.length-1)}return[r,s]}return null}update(t){let e=this.props;if(t.scaleType!==e.scaleType)switch(t.scaleType){case"quantile":{let{attribute:o}=this.getScalePercentile();this.attribute=o,this.domain=[0,99];break}case"ordinal":{let{attribute:o,domain:i}=this.getScaleOrdinal();this.attribute=o,this.domain=[0,i.length-1];break}default:this.attribute=this.input,this.domain=null}return(t.scaleType!==e.scaleType||t.lowerPercentile!==e.lowerPercentile||t.upperPercentile!==e.upperPercentile)&&(this.cutoff=this.getCutoff(t)),this.props=t,this}};function ei(n){let t=new Set;for(let i of n)Number.isFinite(i)&&t.add(i);let e=Array.from(t).sort(),o=new Map;for(let i=0;i<e.length;i++)o.set(e[i],i);return{attribute:{value:n.map(i=>Number.isFinite(i)?o.get(i):NaN),type:"float32",size:1},domain:e}}function ni(n,t=100){let e=Array.from(n).filter(Number.isFinite).sort(oi),o=0,i=Math.max(1,t),r=new Array(i-1);for(;++o<i;)r[o-1]=ii(e,o/i);return{attribute:{value:n.map(s=>Number.isFinite(s)?ri(r,s):NaN),type:"float32",size:1},domain:r}}function De(n,t){let e=(n.stride??4)/4,o=(n.offset??0)/4,i=n.value;if(!i){let s=n.buffer?.readSyncWebGL(0,e*4*t);s&&(i=new Float32Array(s.buffer),n.value=i)}if(e===1)return i.subarray(0,t);let r=new Float32Array(t);for(let s=0;s<t;s++)r[s]=i[s*e+o];return r}function oi(n,t){return n-t}function ii(n,t){let e=n.length;if(t<=0||e<2)return n[0];if(t>=1)return n[e-1];let o=(e-1)*t,i=Math.floor(o),r=n[i],s=n[i+1];return r+(s-r)*(o-i)}function ri(n,t){let e=0,o=n.length;for(;e<o;){let i=e+o>>>1;n[i]>t?o=i:e=i+1}return e}function tt({dataBounds:n,getBinId:t,padding:e=0}){let o=[n[0],n[1],[n[0][0],n[1][1]],[n[1][0],n[0][1]]].map(c=>t(c)),i=Math.min(...o.map(c=>c[0]))-e,r=Math.min(...o.map(c=>c[1]))-e,s=Math.max(...o.map(c=>c[0]))+e+1,a=Math.max(...o.map(c=>c[1]))+e+1;return[[i,s],[r,a]]}var Ye=w(Z(),1);var Be=`const HEXBIN_DISTANCE: vec2<f32> = vec2<f32>(1.7320508, 1.5);
|
|
302
|
+
|
|
303
|
+
struct Attributes {
|
|
304
|
+
@builtin(instance_index) instanceIndex: u32,
|
|
305
|
+
@location(0) positions: vec3<f32>,
|
|
306
|
+
@location(1) normals: vec3<f32>,
|
|
307
|
+
@location(2) instancePositions: vec2<f32>,
|
|
308
|
+
@location(3) instanceColorValues: f32,
|
|
309
|
+
@location(4) instanceElevationValues: f32,
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
struct Varyings {
|
|
313
|
+
@builtin(position) position: vec4<f32>,
|
|
314
|
+
@location(0) color: vec4<f32>,
|
|
315
|
+
@location(1) pickingColor: vec3<f32>,
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
fn hexbinCentroid(binId: vec2<f32>, radius: f32) -> vec2<f32> {
|
|
319
|
+
var adjustedBinId = binId;
|
|
320
|
+
adjustedBinId.x += fract(adjustedBinId.y * 0.5);
|
|
321
|
+
return adjustedBinId * HEXBIN_DISTANCE * radius;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
fn interpolate(value: f32, domain: vec2<f32>, range: vec2<f32>) -> f32 {
|
|
325
|
+
let ratio = clamp((value - domain.x) / (domain.y - domain.x), 0.0, 1.0);
|
|
326
|
+
return mix(range.x, range.y, ratio);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
fn sampleColorRange(value: f32, domain: vec2<f32>) -> vec4<f32> {
|
|
330
|
+
let ratio = (value - domain.x) / (domain.y - domain.x);
|
|
331
|
+
return textureSampleLevel(colorRange, colorRangeSampler, vec2<f32>(ratio, 0.5), 0.0);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
@vertex
|
|
335
|
+
fn vertexMain(attributes: Attributes) -> Varyings {
|
|
336
|
+
var output: Varyings;
|
|
337
|
+
geometry.pickingColor = picking_getPickingColorFromIndex(attributes.instanceIndex);
|
|
338
|
+
output.pickingColor = geometry.pickingColor;
|
|
339
|
+
|
|
340
|
+
if (
|
|
341
|
+
attributes.instanceColorValues != attributes.instanceColorValues ||
|
|
342
|
+
attributes.instanceColorValues < hexagon.colorDomain.z ||
|
|
343
|
+
attributes.instanceColorValues > hexagon.colorDomain.w ||
|
|
344
|
+
attributes.instanceElevationValues < hexagon.elevationDomain.z ||
|
|
345
|
+
attributes.instanceElevationValues > hexagon.elevationDomain.w
|
|
346
|
+
) {
|
|
347
|
+
output.position = vec4<f32>(0.0);
|
|
348
|
+
output.color = vec4<f32>(0.0);
|
|
349
|
+
return output;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
var commonPosition =
|
|
353
|
+
hexbinCentroid(attributes.instancePositions, column.radius) +
|
|
354
|
+
(hexagon.originCommon - project.commonOrigin.xy);
|
|
355
|
+
commonPosition += attributes.positions.xy * column.radius * column.coverage;
|
|
356
|
+
geometry.position = vec4<f32>(commonPosition, 0.0, 1.0);
|
|
357
|
+
geometry.normal = project_normal(attributes.normals);
|
|
358
|
+
|
|
359
|
+
if (column.extruded > 0.5) {
|
|
360
|
+
var elevation = interpolate(
|
|
361
|
+
attributes.instanceElevationValues,
|
|
362
|
+
hexagon.elevationDomain.xy,
|
|
363
|
+
hexagon.elevationRange
|
|
364
|
+
);
|
|
365
|
+
elevation = project_size_float(elevation);
|
|
366
|
+
geometry.position.z = (attributes.positions.z + 1.0) / 2.0 * elevation;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
output.position = project_common_position_to_clipspace(geometry.position);
|
|
370
|
+
var colorValue = sampleColorRange(attributes.instanceColorValues, hexagon.colorDomain.xy);
|
|
371
|
+
if (column.extruded > 0.5) {
|
|
372
|
+
colorValue = vec4<f32>(
|
|
373
|
+
lighting_getLightColor2(
|
|
374
|
+
colorValue.rgb,
|
|
375
|
+
project.cameraPosition,
|
|
376
|
+
geometry.position.xyz,
|
|
377
|
+
geometry.normal
|
|
378
|
+
),
|
|
379
|
+
colorValue.a
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
output.color = vec4<f32>(colorValue.rgb, colorValue.a * layer.opacity);
|
|
383
|
+
return output;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
@fragment
|
|
387
|
+
fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
|
|
388
|
+
if (picking.isActive > 0.5) {
|
|
389
|
+
if (!picking_isColorValid(varyings.pickingColor)) {
|
|
390
|
+
discard;
|
|
391
|
+
}
|
|
392
|
+
return vec4<f32>(varyings.pickingColor, 1.0);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
var color = varyings.color;
|
|
396
|
+
if (picking.isHighlightActive > 0.5) {
|
|
397
|
+
let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
|
|
398
|
+
if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {
|
|
399
|
+
let highLightAlpha = picking.highlightColor.a;
|
|
400
|
+
let blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);
|
|
401
|
+
if (blendedAlpha > 0.0) {
|
|
402
|
+
let highLightRatio = highLightAlpha / blendedAlpha;
|
|
403
|
+
color = vec4<f32>(
|
|
404
|
+
mix(color.rgb, picking.highlightColor.rgb, highLightRatio),
|
|
405
|
+
blendedAlpha
|
|
406
|
+
);
|
|
407
|
+
} else {
|
|
408
|
+
color = vec4<f32>(color.rgb, 0.0);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return deckgl_premultiplied_alpha(color);
|
|
414
|
+
}
|
|
415
|
+
`;var Ue=Math.PI/3,Wt=2*Math.sin(Ue),Vt=1.5,He=Array.from({length:6},(n,t)=>{let e=t*Ue;return[Math.sin(e),-Math.cos(e)]});function Ft([n,t],e){let o=Math.round(t=t/e/Vt),i=Math.round(n=n/e/Wt-(o&1)/2),r=t-o;if(Math.abs(r)*3>1){let s=n-i,a=i+(n<i?-1:1)/2,c=o+(t<o?-1:1),g=n-a,h=t-c;s*s+r*r>g*g+h*h&&(i=a+(o&1?1:-1)/2,o=c)}return[i,o]}var ke=`
|
|
416
|
+
const vec2 DIST = vec2(${Wt}, ${Vt});
|
|
222
417
|
|
|
223
418
|
ivec2 pointToHexbin(vec2 p, float radius) {
|
|
224
419
|
p /= radius * DIST;
|
|
@@ -239,14 +434,14 @@ ivec2 pointToHexbin(vec2 p, float radius) {
|
|
|
239
434
|
}
|
|
240
435
|
return ivec2(pi, pj);
|
|
241
436
|
}
|
|
242
|
-
`;function
|
|
243
|
-
const vec2 DIST = vec2(${
|
|
437
|
+
`;function re([n,t],e){return[(n+(t&1)/2)*e*Wt,t*e*Vt]}var je=`
|
|
438
|
+
const vec2 DIST = vec2(${Wt}, ${Vt});
|
|
244
439
|
|
|
245
440
|
vec2 hexbinCentroid(vec2 binId, float radius) {
|
|
246
441
|
binId.x += fract(binId.y * 0.5);
|
|
247
442
|
return binId * DIST * radius;
|
|
248
443
|
}
|
|
249
|
-
`;var
|
|
444
|
+
`;var Ge=`#version 300 es
|
|
250
445
|
#define SHADER_NAME hexagon-cell-layer-vertex-shader
|
|
251
446
|
in vec3 positions;
|
|
252
447
|
in vec3 normals;
|
|
@@ -255,7 +450,7 @@ in float instanceElevationValues;
|
|
|
255
450
|
in float instanceColorValues;
|
|
256
451
|
uniform sampler2D colorRange;
|
|
257
452
|
out vec4 vColor;
|
|
258
|
-
${
|
|
453
|
+
${je}
|
|
259
454
|
float interp(float value, vec2 domain, vec2 range) {
|
|
260
455
|
float r = min(max((value - domain.x) / (domain.y - domain.x), 0.), 1.);
|
|
261
456
|
return mix(range.x, range.y, r);
|
|
@@ -294,23 +489,33 @@ vColor.rgb = lighting_getLightColor(vColor.rgb, project.cameraPosition, geometry
|
|
|
294
489
|
}
|
|
295
490
|
DECKGL_FILTER_COLOR(vColor, geometry);
|
|
296
491
|
}
|
|
297
|
-
`;var
|
|
492
|
+
`;var si=`struct HexagonUniforms {
|
|
493
|
+
colorDomain: vec4<f32>,
|
|
494
|
+
elevationDomain: vec4<f32>,
|
|
495
|
+
elevationRange: vec2<f32>,
|
|
496
|
+
originCommon: vec2<f32>,
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
@group(0) @binding(auto) var<uniform> hexagon: HexagonUniforms;
|
|
500
|
+
@group(0) @binding(auto) var colorRange: texture_2d<f32>;
|
|
501
|
+
@group(0) @binding(auto) var colorRangeSampler: sampler;
|
|
502
|
+
`,ai=`layout(std140) uniform hexagonUniforms {
|
|
298
503
|
vec4 colorDomain;
|
|
299
504
|
vec4 elevationDomain;
|
|
300
505
|
vec2 elevationRange;
|
|
301
506
|
vec2 originCommon;
|
|
302
507
|
} hexagon;
|
|
303
|
-
`,
|
|
508
|
+
`,qe={name:"hexagon",source:si,vs:ai,uniformTypes:{colorDomain:"vec4<f32>",elevationDomain:"vec4<f32>",elevationRange:"vec2<f32>",originCommon:"vec2<f32>"}};var Dt=class extends Ye.ColumnLayer{getShaders(){let t=super.getShaders();return t.modules.push(qe),{...t,source:Be,vs:Ge}}initializeState(){super.initializeState();let t=this.getAttributeManager();t.remove(["instanceElevations","instanceFillColors","instanceLineColors","instanceStrokeWidths"]),t.addInstanced({instancePositions:{size:2,type:"float32",accessor:"getBin"},instanceColorValues:{size:1,type:"float32",accessor:"getColorValue"},instanceElevationValues:{size:1,type:"float32",accessor:"getElevationValue"}})}updateState(t){super.updateState(t);let{props:e,oldProps:o}=t,i=this.state.fillModel;if(o.colorRange!==e.colorRange){this.state.colorTexture?.destroy(),this.state.colorTexture=Q(this.context.device,e.colorRange,e.colorScaleType);let r={colorRange:this.state.colorTexture};i.shaderInputs.setProps({hexagon:r})}else o.colorScaleType!==e.colorScaleType&&K(this.state.colorTexture,e.colorScaleType)}finalizeState(t){super.finalizeState(t),this.state.colorTexture?.destroy()}draw({uniforms:t}){let{radius:e,hexOriginCommon:o,elevationRange:i,elevationScale:r,extruded:s,coverage:a,colorDomain:c,elevationDomain:g}=this.props,h=this.props.colorCutoff||[-1/0,1/0],u=this.props.elevationCutoff||[-1/0,1/0],p=this.state.fillModel,f={colorDomain:[Math.max(c[0],h[0]),Math.min(c[1],h[1]),Math.max(c[0]-1,h[0]),Math.min(c[1]+1,h[1])],elevationDomain:[Math.max(g[0],u[0]),Math.min(g[1],u[1]),Math.max(g[0]-1,u[0]),Math.min(g[1]+1,u[1])],elevationRange:[i[0]*r,i[1]*r],originCommon:o};p.shaderInputs.setProps({column:{extruded:s,coverage:a,radius:e},hexagon:f}),p.draw(this.context.renderPass)}};Dt.layerName="HexagonCellLayer";var $e=Dt;var ci=`layout(std140) uniform binOptionsUniforms {
|
|
304
509
|
vec2 hexOriginCommon;
|
|
305
510
|
float radiusCommon;
|
|
306
511
|
} binOptions;
|
|
307
|
-
`,
|
|
512
|
+
`,Xe={name:"binOptions",vs:ci,uniformTypes:{hexOriginCommon:"vec2<f32>",radiusCommon:"f32"}};function Ze(){}var li={gpuAggregation:!0,colorDomain:null,colorRange:j,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:Ze,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationScale:{type:"number",min:0,value:1},elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScaleType:"linear",onSetElevationDomain:Ze,radius:{type:"number",min:1,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:n=>n.position},hexagonAggregator:{type:"function",optional:!0,value:null},extruded:!1,material:!0},yt=class extends B{getAggregatorType(){let{gpuAggregation:t,hexagonAggregator:e,getColorValue:o,getElevationValue:i}=this.props;return t&&(e||o||i)?(q.log.warn("Features not supported by GPU aggregation, falling back to CPU")(),"cpu"):t&&L.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(t){if(t==="cpu"){let{hexagonAggregator:e,radius:o}=this.props;return new N({dimensions:2,getBin:{sources:["positions"],getValue:({positions:i},r,s)=>{if(e)return e(i,o);let c=this.state.aggregatorViewport.projectPosition(i),{radiusCommon:g,hexOriginCommon:h}=s;return Ft([c[0]-h[0],c[1]-h[1]],g)}},getValue:[{sources:["colorWeights"],getValue:({colorWeights:i})=>i},{sources:["elevationWeights"],getValue:({elevationWeights:i})=>i}]})}return new L(this.context.device,{dimensions:2,channelCount:2,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[q.project32,Xe],vs:`
|
|
308
513
|
in vec3 positions;
|
|
309
514
|
in vec3 positions64Low;
|
|
310
515
|
in float colorWeights;
|
|
311
516
|
in float elevationWeights;
|
|
312
517
|
|
|
313
|
-
${
|
|
518
|
+
${ke}
|
|
314
519
|
|
|
315
520
|
void getBin(out ivec2 binId) {
|
|
316
521
|
vec3 positionCommon = project_position(positions, positions64Low);
|
|
@@ -319,11 +524,11 @@ DECKGL_FILTER_COLOR(vColor, geometry);
|
|
|
319
524
|
void getValue(out vec2 value) {
|
|
320
525
|
value = vec2(colorWeights, elevationWeights);
|
|
321
526
|
}
|
|
322
|
-
`})})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},colorWeights:{size:1,accessor:"getColorWeight"},elevationWeights:{size:1,accessor:"getElevationWeight"}})}updateState(t){let e=super.updateState(t),{props:o,oldProps:r,changeFlags:i}=t,{aggregator:s}=this.state;if((i.dataChanged||!this.state.dataAsArray)&&(o.getColorValue||o.getElevationValue)&&(this.state.dataAsArray=Array.from((0,q.createIterable)(o.data).iterable)),e||i.dataChanged||o.radius!==r.radius||o.getColorValue!==r.getColorValue||o.getElevationValue!==r.getElevationValue||o.colorAggregation!==r.colorAggregation||o.elevationAggregation!==r.elevationAggregation){this._updateBinOptions();let{radiusCommon:a,hexOriginCommon:c,binIdRange:g,dataAsArray:h}=this.state;if(s.setProps({binIdRange:g,pointCount:this.getNumInstances(),operations:[o.colorAggregation,o.elevationAggregation],binOptions:{radiusCommon:a,hexOriginCommon:c},onUpdate:this._onAggregationUpdate.bind(this)}),h){let{getColorValue:f,getElevationValue:p}=this.props;s.setProps({customOperations:[f&&(d=>f(d.map(x=>h[x]),{indices:d,data:o.data})),p&&(d=>p(d.map(x=>h[x]),{indices:d,data:o.data}))]})}}return i.updateTriggersChanged&&i.updateTriggersChanged.getColorValue&&s.setNeedsUpdate(0),i.updateTriggersChanged&&i.updateTriggersChanged.getElevationValue&&s.setNeedsUpdate(1),e}_updateBinOptions(){let t=this.getBounds(),e=1,o=[0,0],r=[[0,1],[0,1]],i=this.context.viewport;if(t&&Number.isFinite(t[0][0])){let s=[(t[0][0]+t[1][0])/2,(t[0][1]+t[1][1])/2],{radius:a}=this.props,{unitsPerMeter:c}=i.getDistanceScales(s);e=c[0]*a;let g=Wt(i.projectFlat(s),e);s=i.unprojectFlat(ie(g,e));let h=i.constructor;i=i.isGeospatial?new h({longitude:s[0],latitude:s[1],zoom:12}):new q.Viewport({position:[s[0],s[1],0],zoom:12}),o=[Math.fround(i.center[0]),Math.fround(i.center[1])],r=J({dataBounds:t,getBinId:f=>{let p=i.projectFlat(f);return p[0]-=o[0],p[1]-=o[1],Wt(p,e)},padding:1})}this.setState({radiusCommon:e,hexOriginCommon:o,binIdRange:r,aggregatorViewport:i})}draw(t){t.shaderModuleProps.project&&(t.shaderModuleProps.project.viewport=this.state.aggregatorViewport),super.draw(t)}_onAggregationUpdate({channel:t}){let e=this.getCurrentLayer().props,{aggregator:o}=this.state;if(t===0){let r=o.getResult(0);this.setState({colors:new G(r,o.binCount)}),e.onSetColorDomain(o.getResultDomain(0))}else if(t===1){let r=o.getResult(1);this.setState({elevations:new G(r,o.binCount)}),e.onSetElevationDomain(o.getResultDomain(1))}}onAttributeChange(t){let{aggregator:e}=this.state;switch(t){case"positions":e.setNeedsUpdate(),this._updateBinOptions();let{radiusCommon:o,hexOriginCommon:r,binIdRange:i}=this.state;e.setProps({binIdRange:i,binOptions:{radiusCommon:o,hexOriginCommon:r}});break;case"colorWeights":e.setNeedsUpdate(0);break;case"elevationWeights":e.setNeedsUpdate(1);break;default:}}renderLayers(){let{aggregator:t,radiusCommon:e,hexOriginCommon:o}=this.state,{elevationScale:r,colorRange:i,elevationRange:s,extruded:a,coverage:c,material:g,transitions:h,colorScaleType:f,lowerPercentile:p,upperPercentile:d,colorDomain:x,elevationScaleType:v,elevationLowerPercentile:y,elevationUpperPercentile:b,elevationDomain:E}=this.props,M=this.getSubLayerClass("cells",qe),C=t.getBins(),S=this.state.colors?.update({scaleType:f,lowerPercentile:p,upperPercentile:d}),A=this.state.elevations?.update({scaleType:v,lowerPercentile:y,upperPercentile:b});return!S||!A?null:new M(this.getSubLayerProps({id:"cells"}),{data:{length:t.binCount,attributes:{getBin:C,getColorValue:S.attribute,getElevationValue:A.attribute}},dataComparator:(w,N)=>w.length===N.length,updateTriggers:{getBin:[C],getColorValue:[S.attribute],getElevationValue:[A.attribute]},diskResolution:6,vertices:Be,radius:e,hexOriginCommon:o,elevationScale:r,colorRange:i,colorScaleType:f,elevationRange:s,extruded:a,coverage:c,material:g,colorDomain:S.domain||x||t.getResultDomain(0),elevationDomain:A.domain||E||t.getResultDomain(1),colorCutoff:S.cutoff,elevationCutoff:A.cutoff,transitions:h&&{getFillColor:h.getColorValue||h.getColorWeight,getElevation:h.getElevationValue||h.getElevationWeight},extensions:[]})}getPickingInfo(t){let e=t.info,{index:o}=e;if(o>=0){let r=this.state.aggregator.getBin(o),i;if(r){let s=ie(r.id,this.state.radiusCommon),a=this.context.viewport.unprojectFlat(s);i={col:r.id[0],row:r.id[1],position:a,colorValue:r.value[0],elevationValue:r.value[1],count:r.count},r.pointIndices&&(i.pointIndices=r.pointIndices,i.points=Array.isArray(this.props.data)?r.pointIndices.map(c=>this.props.data[c]):[])}e.object=i}return e}};xt.layerName="HexagonLayer";xt.defaultProps=er;var Xe=xt;var U=L(I(),1),Xt=L(K(),1);var m=.16666666666666666,l={N:[0,.5],E:[.5,0],S:[0,-.5],W:[-.5,0],NE:[.5,.5],NW:[-.5,.5],SE:[.5,-.5],SW:[-.5,-.5]},tt=[l.W,l.SW,l.S],et=[l.S,l.SE,l.E],nt=[l.E,l.NE,l.N],ot=[l.NW,l.W,l.N],rt=[[-.5,m],[-.5,-m],[-m,-.5],[m,-.5]],it=[[-m,-.5],[m,-.5],[.5,-m],[.5,m]],st=[[.5,-m],[.5,m],[m,.5],[-m,.5]],at=[[-.5,m],[-.5,-m],[m,.5],[-m,.5]],Ke=[l.W,l.SW,l.SE,l.E],Ze=[l.S,l.SE,l.NE,l.N],Qe=[l.NW,l.W,l.E,l.NE],Je=[l.NW,l.SW,l.S,l.N],tn=[[-.5,m],[-.5,-m],[.5,-m],[.5,m]],en=[[-m,-.5],[m,-.5],[m,.5],[-m,.5]],nr=[l.NW,l.SW,l.SE,l.NE],nn=[l.NW,l.SW,l.SE,l.E,l.N],on=[l.W,l.SW,l.SE,l.NE,l.N],rn=[l.NW,l.W,l.S,l.SE,l.NE],sn=[l.NW,l.SW,l.S,l.E,l.NE],an=[l.NW,l.W,[.5,-m],[.5,m],l.N],cn=[[-m,-.5],[m,-.5],l.E,l.NE,l.N],ln=[[-.5,m],[-.5,-m],l.S,l.SE,l.E],gn=[l.W,l.SW,l.S,[m,.5],[-m,.5]],hn=[l.NW,l.W,[-m,-.5],[m,-.5],l.N],pn=[[-.5,m],[-.5,-m],l.E,l.NE,l.N],fn=[l.S,l.SE,l.E,[m,.5],[-m,.5]],dn=[l.W,l.SW,l.S,[.5,-m],[.5,m]],un=[l.W,l.SW,l.SE,l.E,[m,.5],[-m,.5]],mn=[[-.5,m],[-.5,-m],l.S,l.SE,l.NE,l.N],xn=[l.NW,l.W,[-m,-.5],[m,-.5],l.E,l.NE],vn=[l.NW,l.SW,l.S,[.5,-m],[.5,m],l.N],ct=[l.W,l.SW,l.S,l.E,l.NE,l.N],lt=[l.NW,l.W,l.S,l.SE,l.E,l.N],Vt=[[-.5,m],[-.5,-m],[-m,-.5],[m,-.5],l.E,l.NE,l.N],Bt=[l.W,l.SW,l.S,[.5,-m],[.5,m],[m,.5],[-m,.5]],Ut=[l.NW,l.W,[-m,-.5],[m,-.5],[.5,-m],[.5,m],l.N],Ht=[[-.5,m],[-.5,-m],l.S,l.SE,l.E,[m,.5],[-m,.5]],Mn=[[-.5,m],[-.5,-m],[-m,-.5],[m,-.5],[.5,-m],[.5,m],[m,.5],[-m,.5]],yn={0:[],1:[[l.W,l.S]],2:[[l.S,l.E]],3:[[l.W,l.E]],4:[[l.N,l.E]],5:{0:[[l.W,l.S],[l.N,l.E]],1:[[l.W,l.N],[l.S,l.E]]},6:[[l.N,l.S]],7:[[l.W,l.N]],8:[[l.W,l.N]],9:[[l.N,l.S]],10:{0:[[l.W,l.N],[l.S,l.E]],1:[[l.W,l.S],[l.N,l.E]]},11:[[l.N,l.E]],12:[[l.W,l.E]],13:[[l.S,l.E]],14:[[l.W,l.S]],15:[]};function u(n){return parseInt(n,4)}var Sn={[u("0000")]:[],[u("2222")]:[],[u("2221")]:[tt],[u("2212")]:[et],[u("2122")]:[nt],[u("1222")]:[ot],[u("0001")]:[tt],[u("0010")]:[et],[u("0100")]:[nt],[u("1000")]:[ot],[u("2220")]:[rt],[u("2202")]:[it],[u("2022")]:[st],[u("0222")]:[at],[u("0002")]:[rt],[u("0020")]:[it],[u("0200")]:[st],[u("2000")]:[at],[u("0011")]:[Ke],[u("0110")]:[Ze],[u("1100")]:[Qe],[u("1001")]:[Je],[u("2211")]:[Ke],[u("2112")]:[Ze],[u("1122")]:[Qe],[u("1221")]:[Je],[u("2200")]:[tn],[u("2002")]:[en],[u("0022")]:[tn],[u("0220")]:[en],[u("1111")]:[nr],[u("1211")]:[nn],[u("2111")]:[on],[u("1112")]:[rn],[u("1121")]:[sn],[u("1011")]:[nn],[u("0111")]:[on],[u("1110")]:[rn],[u("1101")]:[sn],[u("1200")]:[an],[u("0120")]:[cn],[u("0012")]:[ln],[u("2001")]:[gn],[u("1022")]:[an],[u("2102")]:[cn],[u("2210")]:[ln],[u("0221")]:[gn],[u("1002")]:[hn],[u("2100")]:[pn],[u("0210")]:[fn],[u("0021")]:[dn],[u("1220")]:[hn],[u("0122")]:[pn],[u("2012")]:[fn],[u("2201")]:[dn],[u("0211")]:[un],[u("2110")]:[mn],[u("1102")]:[xn],[u("1021")]:[vn],[u("2011")]:[un],[u("0112")]:[mn],[u("1120")]:[xn],[u("1201")]:[vn],[u("2101")]:[ct],[u("0121")]:[ct],[u("1012")]:[lt],[u("1210")]:[lt],[u("0101")]:{0:[tt,nt],1:[ct],2:[ct]},[u("1010")]:{0:[ot,et],1:[lt],2:[lt]},[u("2121")]:{0:[ct],1:[ct],2:[tt,nt]},[u("1212")]:{0:[lt],1:[lt],2:[ot,et]},[u("2120")]:{0:[Vt],1:[Vt],2:[rt,nt]},[u("2021")]:{0:[Bt],1:[Bt],2:[tt,st]},[u("1202")]:{0:[Ut],1:[Ut],2:[ot,it]},[u("0212")]:{0:[Ht],1:[Ht],2:[et,at]},[u("0102")]:{0:[rt,nt],1:[Vt],2:[Vt]},[u("0201")]:{0:[tt,st],1:[Bt],2:[Bt]},[u("1020")]:{0:[ot,it],1:[Ut],2:[Ut]},[u("2010")]:{0:[et,at],1:[Ht],2:[Ht]},[u("2020")]:{0:[at,it],1:[Mn],2:[rt,st]},[u("0202")]:{0:[st,rt],1:[Mn],2:[at,it]}};function vt(n,t){return Number.isNaN(n)?0:Array.isArray(t)?n<t[0]?0:n<t[1]?1:2:n>=t?1:0}function An(n){let{x:t,y:e,xRange:o,yRange:r,getValue:i,threshold:s}=n,a=t<o[0],c=t>=o[1]-1,g=e<r[0],h=e>=r[1]-1,f=a||c||g||h,p=0,d,x,v,y;if(a||h)v=0;else{let M=i(t,e+1);v=vt(M,s),p+=M}if(c||h)y=0;else{let M=i(t+1,e+1);y=vt(M,s),p+=M}if(c||g)x=0;else{let M=i(t+1,e);x=vt(M,s),p+=M}if(a||g)d=0;else{let M=i(t,e);d=vt(M,s),p+=M}let b=-1;Number.isFinite(s)&&(b=v<<3|y<<2|x<<1|d),Array.isArray(s)&&(b=v<<6|y<<4|x<<2|d);let E=0;return f||(E=vt(p/4,s)),{code:b,meanCode:E}}function Cn(n){let{x:t,y:e,z:o,code:r,meanCode:i}=n,s=Sn[r];Array.isArray(s)||(s=s[i]);let a=t+1,c=e+1,g=[];return s.forEach(h=>{let f=[];h.forEach(p=>{let d=a+p[0],x=c+p[1];f.push([d,x,o])}),g.push(f)}),g}function bn(n){let{x:t,y:e,z:o,code:r,meanCode:i}=n,s=yn[r];Array.isArray(s)||(s=s[i]);let a=t+1,c=e+1,g=[];return s.forEach(h=>{h.forEach(f=>{let p=a+f[0],d=c+f[1];g.push([p,d,o])})}),g}function En({contours:n,getValue:t,xRange:e,yRange:o}){let r=[],i=[],s=0,a=0;for(let c=0;c<n.length;c++){let g=n[c],h=g.zIndex??c,{threshold:f}=g;for(let p=e[0]-1;p<e[1];p++)for(let d=o[0]-1;d<o[1];d++){let{code:x,meanCode:v}=An({getValue:t,threshold:f,x:p,y:d,xRange:e,yRange:o}),y={x:p,y:d,z:h,code:x,meanCode:v};if(Array.isArray(f)){let b=Cn(y);for(let E of b)i[a++]={vertices:E,contour:g}}else{let b=bn(y);b.length>0&&(r[s++]={vertices:b,contour:g})}}}return{lines:r,polygons:i}}function Tn(n){let{aggregator:t,binIdRange:e,channel:o}=n;if(t instanceof P){let r=t.getResult(o)?.buffer;if(r){let i=new Float32Array(r.readSyncWebGL().buffer);return or(i,e)}}if(t instanceof O){let r=t.getResult(o)?.value,i=t.getBins()?.value;if(i&&r)return rr(r,i,t.binCount)}return null}function or(n,t){let[[e,o],[r,i]]=t,s=o-e,a=i-r;return(c,g)=>(c-=e,g-=r,c<0||c>=s||g<0||g>=a?NaN:n[g*s+c])}function rr(n,t,e){let o={};for(let r=0;r<e;r++){let i=t[r*2],s=t[r*2+1];o[i]=o[i]||{},o[i][s]=n[r]}return(r,i)=>o[r]?.[i]??NaN}var Zi=1/Math.PI*180,Qi=1/180*Math.PI,ir={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...ir}};var _=globalThis.mathgl.config;function Ln(n,{precision:t=_.precision}={}){return n=sr(n),`${parseFloat(n.toPrecision(t))}`}function kt(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function se(n,t,e){let o=_.EPSILON;e&&(_.EPSILON=e);try{if(n===t)return!0;if(kt(n)&&kt(t)){if(n.length!==t.length)return!1;for(let r=0;r<n.length;++r)if(!se(n[r],t[r]))return!1;return!0}return n&&n.equals?n.equals(t):t&&t.equals?t.equals(n):typeof n=="number"&&typeof t=="number"?Math.abs(n-t)<=_.EPSILON*Math.max(1,Math.abs(n),Math.abs(t)):!1}finally{_.EPSILON=o}}function sr(n){return Math.round(n/_.EPSILON)*_.EPSILON}var jt=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,e=0){for(let o=0;o<this.ELEMENTS;++o)this[o]=t[o+e];return this.check()}toArray(t=[],e=0){for(let o=0;o<this.ELEMENTS;++o)t[e+o]=this[o];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:kt(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(_)}formatString(t){let e="";for(let o=0;o<this.ELEMENTS;++o)e+=(o>0?", ":"")+Ln(this[o],t);return`${t.printTypes?this.constructor.name:""}[${e}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(!se(this[e],t[e]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(this[e]!==t[e])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,e,o){if(o===void 0)return this.lerp(this,t,e);for(let r=0;r<this.ELEMENTS;++r){let i=t[r],s=typeof e=="number"?e:e[r];this[r]=i+o*(s-i)}return this.check()}min(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.min(t[e],this[e]);return this.check()}max(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.max(t[e],this[e]);return this.check()}clamp(t,e){for(let o=0;o<this.ELEMENTS;++o)this[o]=Math.min(Math.max(this[o],t[o]),e[o]);return this.check()}add(...t){for(let e of t)for(let o=0;o<this.ELEMENTS;++o)this[o]+=e[o];return this.check()}subtract(...t){for(let e of t)for(let o=0;o<this.ELEMENTS;++o)this[o]-=e[o];return this.check()}scale(t){if(typeof t=="number")for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;else for(let e=0;e<this.ELEMENTS&&e<t.length;++e)this[e]*=t[e];return this.check()}multiplyByScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}check(){if(_.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let e=0;e<this.ELEMENTS;++e)t=t&&Number.isFinite(this[e]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=t;return this.check()}addScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,e){for(let o=0;o<this.ELEMENTS;++o)this[o]=Math.min(Math.max(this[o],t),e);return this.check()}get elements(){return this}};function ar(n,t){if(n.length!==t)return!1;for(let e=0;e<n.length;++e)if(!Number.isFinite(n[e]))return!1;return!0}function Pn(n){if(!Number.isFinite(n))throw new Error(`Invalid number ${JSON.stringify(n)}`);return n}function Gt(n,t,e=""){if(_.debug&&!ar(n,t))throw new Error(`math.gl: ${e} some fields set to invalid numbers'`);return n}var H=typeof Float32Array<"u"?Float32Array:Array;var rs=Math.PI/180;function cr(){let n=new H(2);return H!=Float32Array&&(n[0]=0,n[1]=0),n}function On(n,t,e){let o=t[0],r=t[1];return n[0]=e[0]*o+e[4]*r+e[12],n[1]=e[1]*o+e[5]*r+e[13],n}var is=function(){let n=cr();return function(t,e,o,r,i,s){let a,c;for(e||(e=2),o||(o=0),r?c=Math.min(r*e+o,t.length):c=t.length,a=o;a<c;a+=e)n[0]=t[a],n[1]=t[a+1],i(n,n,s),t[a]=n[0],t[a+1]=n[1];return t}}();function _n(n,t,e){let o=t[0],r=t[1],i=e[3]*o+e[7]*r||1;return n[0]=(e[0]*o+e[4]*r)/i,n[1]=(e[1]*o+e[5]*r)/i,n}function Rn(n,t,e){let o=t[0],r=t[1],i=t[2],s=e[3]*o+e[7]*r+e[11]*i||1;return n[0]=(e[0]*o+e[4]*r+e[8]*i)/s,n[1]=(e[1]*o+e[5]*r+e[9]*i)/s,n[2]=(e[2]*o+e[6]*r+e[10]*i)/s,n}function lr(){let n=new H(3);return H!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function zn(n,t,e){let o=t[0],r=t[1],i=t[2],s=e[3]*o+e[7]*r+e[11]*i+e[15];return s=s||1,n[0]=(e[0]*o+e[4]*r+e[8]*i+e[12])/s,n[1]=(e[1]*o+e[5]*r+e[9]*i+e[13])/s,n[2]=(e[2]*o+e[6]*r+e[10]*i+e[14])/s,n}var cs=function(){let n=lr();return function(t,e,o,r,i,s){let a,c;for(e||(e=3),o||(o=0),r?c=Math.min(r*e+o,t.length):c=t.length,a=o;a<c;a+=e)n[0]=t[a],n[1]=t[a+1],n[2]=t[a+2],i(n,n,s),t[a]=n[0],t[a+1]=n[1],t[a+2]=n[2];return t}}();var qt=class extends jt{toString(){let t="[";if(_.printRowMajor){t+="row-major:";for(let e=0;e<this.RANK;++e)for(let o=0;o<this.RANK;++o)t+=` ${this[o*this.RANK+e]}`}else{t+="column-major:";for(let e=0;e<this.ELEMENTS;++e)t+=` ${this[e]}`}return t+="]",t}getElementIndex(t,e){return e*this.RANK+t}getElement(t,e){return this[e*this.RANK+t]}setElement(t,e,o){return this[e*this.RANK+t]=Pn(o),this}getColumn(t,e=new Array(this.RANK).fill(-0)){let o=t*this.RANK;for(let r=0;r<this.RANK;++r)e[r]=this[o+r];return e}setColumn(t,e){let o=t*this.RANK;for(let r=0;r<this.RANK;++r)this[o+r]=e[r];return this}};function gr(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function In(n,t){if(n===t){let e=t[1],o=t[2],r=t[3],i=t[6],s=t[7],a=t[11];n[1]=t[4],n[2]=t[8],n[3]=t[12],n[4]=e,n[6]=t[9],n[7]=t[13],n[8]=o,n[9]=i,n[11]=t[14],n[12]=r,n[13]=s,n[14]=a}else n[0]=t[0],n[1]=t[4],n[2]=t[8],n[3]=t[12],n[4]=t[1],n[5]=t[5],n[6]=t[9],n[7]=t[13],n[8]=t[2],n[9]=t[6],n[10]=t[10],n[11]=t[14],n[12]=t[3],n[13]=t[7],n[14]=t[11],n[15]=t[15];return n}function Fn(n,t){let e=t[0],o=t[1],r=t[2],i=t[3],s=t[4],a=t[5],c=t[6],g=t[7],h=t[8],f=t[9],p=t[10],d=t[11],x=t[12],v=t[13],y=t[14],b=t[15],E=e*a-o*s,M=e*c-r*s,C=e*g-i*s,S=o*c-r*a,A=o*g-i*a,w=r*g-i*c,N=h*v-f*x,R=h*y-p*x,z=h*b-d*x,F=f*y-p*v,W=f*b-d*v,D=p*b-d*y,T=E*D-M*W+C*F+S*z-A*R+w*N;return T?(T=1/T,n[0]=(a*D-c*W+g*F)*T,n[1]=(r*W-o*D-i*F)*T,n[2]=(v*w-y*A+b*S)*T,n[3]=(p*A-f*w-d*S)*T,n[4]=(c*z-s*D-g*R)*T,n[5]=(e*D-r*z+i*R)*T,n[6]=(y*C-x*w-b*M)*T,n[7]=(h*w-p*C+d*M)*T,n[8]=(s*W-a*z+g*N)*T,n[9]=(o*z-e*W-i*N)*T,n[10]=(x*A-v*C+b*E)*T,n[11]=(f*C-h*A-d*E)*T,n[12]=(a*R-s*F-c*N)*T,n[13]=(e*F-o*R+r*N)*T,n[14]=(v*M-x*S-y*E)*T,n[15]=(h*S-f*M+p*E)*T,n):null}function Wn(n){let t=n[0],e=n[1],o=n[2],r=n[3],i=n[4],s=n[5],a=n[6],c=n[7],g=n[8],h=n[9],f=n[10],p=n[11],d=n[12],x=n[13],v=n[14],y=n[15],b=t*s-e*i,E=t*a-o*i,M=e*a-o*s,C=g*x-h*d,S=g*v-f*d,A=h*v-f*x,w=t*A-e*S+o*C,N=i*A-s*S+a*C,R=g*M-h*E+f*b,z=d*M-x*E+v*b;return c*w-r*N+y*R-p*z}function ce(n,t,e){let o=t[0],r=t[1],i=t[2],s=t[3],a=t[4],c=t[5],g=t[6],h=t[7],f=t[8],p=t[9],d=t[10],x=t[11],v=t[12],y=t[13],b=t[14],E=t[15],M=e[0],C=e[1],S=e[2],A=e[3];return n[0]=M*o+C*a+S*f+A*v,n[1]=M*r+C*c+S*p+A*y,n[2]=M*i+C*g+S*d+A*b,n[3]=M*s+C*h+S*x+A*E,M=e[4],C=e[5],S=e[6],A=e[7],n[4]=M*o+C*a+S*f+A*v,n[5]=M*r+C*c+S*p+A*y,n[6]=M*i+C*g+S*d+A*b,n[7]=M*s+C*h+S*x+A*E,M=e[8],C=e[9],S=e[10],A=e[11],n[8]=M*o+C*a+S*f+A*v,n[9]=M*r+C*c+S*p+A*y,n[10]=M*i+C*g+S*d+A*b,n[11]=M*s+C*h+S*x+A*E,M=e[12],C=e[13],S=e[14],A=e[15],n[12]=M*o+C*a+S*f+A*v,n[13]=M*r+C*c+S*p+A*y,n[14]=M*i+C*g+S*d+A*b,n[15]=M*s+C*h+S*x+A*E,n}function Dn(n,t,e){let o=e[0],r=e[1],i=e[2],s,a,c,g,h,f,p,d,x,v,y,b;return t===n?(n[12]=t[0]*o+t[4]*r+t[8]*i+t[12],n[13]=t[1]*o+t[5]*r+t[9]*i+t[13],n[14]=t[2]*o+t[6]*r+t[10]*i+t[14],n[15]=t[3]*o+t[7]*r+t[11]*i+t[15]):(s=t[0],a=t[1],c=t[2],g=t[3],h=t[4],f=t[5],p=t[6],d=t[7],x=t[8],v=t[9],y=t[10],b=t[11],n[0]=s,n[1]=a,n[2]=c,n[3]=g,n[4]=h,n[5]=f,n[6]=p,n[7]=d,n[8]=x,n[9]=v,n[10]=y,n[11]=b,n[12]=s*o+h*r+x*i+t[12],n[13]=a*o+f*r+v*i+t[13],n[14]=c*o+p*r+y*i+t[14],n[15]=g*o+d*r+b*i+t[15]),n}function Vn(n,t,e){let o=e[0],r=e[1],i=e[2];return n[0]=t[0]*o,n[1]=t[1]*o,n[2]=t[2]*o,n[3]=t[3]*o,n[4]=t[4]*r,n[5]=t[5]*r,n[6]=t[6]*r,n[7]=t[7]*r,n[8]=t[8]*i,n[9]=t[9]*i,n[10]=t[10]*i,n[11]=t[11]*i,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}function Bn(n,t,e,o){let r=o[0],i=o[1],s=o[2],a=Math.sqrt(r*r+i*i+s*s),c,g,h,f,p,d,x,v,y,b,E,M,C,S,A,w,N,R,z,F,W,D,T,ft;return a<1e-6?null:(a=1/a,r*=a,i*=a,s*=a,g=Math.sin(e),c=Math.cos(e),h=1-c,f=t[0],p=t[1],d=t[2],x=t[3],v=t[4],y=t[5],b=t[6],E=t[7],M=t[8],C=t[9],S=t[10],A=t[11],w=r*r*h+c,N=i*r*h+s*g,R=s*r*h-i*g,z=r*i*h-s*g,F=i*i*h+c,W=s*i*h+r*g,D=r*s*h+i*g,T=i*s*h-r*g,ft=s*s*h+c,n[0]=f*w+v*N+M*R,n[1]=p*w+y*N+C*R,n[2]=d*w+b*N+S*R,n[3]=x*w+E*N+A*R,n[4]=f*z+v*F+M*W,n[5]=p*z+y*F+C*W,n[6]=d*z+b*F+S*W,n[7]=x*z+E*F+A*W,n[8]=f*D+v*T+M*ft,n[9]=p*D+y*T+C*ft,n[10]=d*D+b*T+S*ft,n[11]=x*D+E*T+A*ft,t!==n&&(n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n)}function Un(n,t,e){let o=Math.sin(e),r=Math.cos(e),i=t[4],s=t[5],a=t[6],c=t[7],g=t[8],h=t[9],f=t[10],p=t[11];return t!==n&&(n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[4]=i*r+g*o,n[5]=s*r+h*o,n[6]=a*r+f*o,n[7]=c*r+p*o,n[8]=g*r-i*o,n[9]=h*r-s*o,n[10]=f*r-a*o,n[11]=p*r-c*o,n}function Hn(n,t,e){let o=Math.sin(e),r=Math.cos(e),i=t[0],s=t[1],a=t[2],c=t[3],g=t[8],h=t[9],f=t[10],p=t[11];return t!==n&&(n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[0]=i*r-g*o,n[1]=s*r-h*o,n[2]=a*r-f*o,n[3]=c*r-p*o,n[8]=i*o+g*r,n[9]=s*o+h*r,n[10]=a*o+f*r,n[11]=c*o+p*r,n}function kn(n,t,e){let o=Math.sin(e),r=Math.cos(e),i=t[0],s=t[1],a=t[2],c=t[3],g=t[4],h=t[5],f=t[6],p=t[7];return t!==n&&(n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[0]=i*r+g*o,n[1]=s*r+h*o,n[2]=a*r+f*o,n[3]=c*r+p*o,n[4]=g*r-i*o,n[5]=h*r-s*o,n[6]=f*r-a*o,n[7]=p*r-c*o,n}function jn(n,t){let e=t[0],o=t[1],r=t[2],i=t[3],s=e+e,a=o+o,c=r+r,g=e*s,h=o*s,f=o*a,p=r*s,d=r*a,x=r*c,v=i*s,y=i*a,b=i*c;return n[0]=1-f-x,n[1]=h+b,n[2]=p-y,n[3]=0,n[4]=h-b,n[5]=1-g-x,n[6]=d+v,n[7]=0,n[8]=p+y,n[9]=d-v,n[10]=1-g-f,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Gn(n,t,e,o,r,i,s){let a=1/(e-t),c=1/(r-o),g=1/(i-s);return n[0]=i*2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i*2*c,n[6]=0,n[7]=0,n[8]=(e+t)*a,n[9]=(r+o)*c,n[10]=(s+i)*g,n[11]=-1,n[12]=0,n[13]=0,n[14]=s*i*2*g,n[15]=0,n}function hr(n,t,e,o,r){let i=1/Math.tan(t/2);if(n[0]=i/e,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,r!=null&&r!==1/0){let s=1/(o-r);n[10]=(r+o)*s,n[14]=2*r*o*s}else n[10]=-1,n[14]=-2*o;return n}var qn=hr;function pr(n,t,e,o,r,i,s){let a=1/(t-e),c=1/(o-r),g=1/(i-s);return n[0]=-2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*c,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*g,n[11]=0,n[12]=(t+e)*a,n[13]=(r+o)*c,n[14]=(s+i)*g,n[15]=1,n}var Yn=pr;function $n(n,t,e,o){let r,i,s,a,c,g,h,f,p,d,x=t[0],v=t[1],y=t[2],b=o[0],E=o[1],M=o[2],C=e[0],S=e[1],A=e[2];return Math.abs(x-C)<1e-6&&Math.abs(v-S)<1e-6&&Math.abs(y-A)<1e-6?gr(n):(f=x-C,p=v-S,d=y-A,r=1/Math.sqrt(f*f+p*p+d*d),f*=r,p*=r,d*=r,i=E*d-M*p,s=M*f-b*d,a=b*p-E*f,r=Math.sqrt(i*i+s*s+a*a),r?(r=1/r,i*=r,s*=r,a*=r):(i=0,s=0,a=0),c=p*a-d*s,g=d*i-f*a,h=f*s-p*i,r=Math.sqrt(c*c+g*g+h*h),r?(r=1/r,c*=r,g*=r,h*=r):(c=0,g=0,h=0),n[0]=i,n[1]=c,n[2]=f,n[3]=0,n[4]=s,n[5]=g,n[6]=p,n[7]=0,n[8]=a,n[9]=h,n[10]=d,n[11]=0,n[12]=-(i*x+s*v+a*y),n[13]=-(c*x+g*v+h*y),n[14]=-(f*x+p*v+d*y),n[15]=1,n)}function fr(){let n=new H(4);return H!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function Xn(n,t,e){let o=t[0],r=t[1],i=t[2],s=t[3];return n[0]=e[0]*o+e[4]*r+e[8]*i+e[12]*s,n[1]=e[1]*o+e[5]*r+e[9]*i+e[13]*s,n[2]=e[2]*o+e[6]*r+e[10]*i+e[14]*s,n[3]=e[3]*o+e[7]*r+e[11]*i+e[15]*s,n}var us=function(){let n=fr();return function(t,e,o,r,i,s){let a,c;for(e||(e=4),o||(o=0),r?c=Math.min(r*e+o,t.length):c=t.length,a=o;a<c;a+=e)n[0]=t[a],n[1]=t[a+1],n[2]=t[a+2],n[3]=t[a+3],i(n,n,s),t[a]=n[0],t[a+1]=n[1],t[a+2]=n[2],t[a+3]=n[3];return t}}();var he;(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL0ROW3=3]="COL0ROW3",n[n.COL1ROW0=4]="COL1ROW0",n[n.COL1ROW1=5]="COL1ROW1",n[n.COL1ROW2=6]="COL1ROW2",n[n.COL1ROW3=7]="COL1ROW3",n[n.COL2ROW0=8]="COL2ROW0",n[n.COL2ROW1=9]="COL2ROW1",n[n.COL2ROW2=10]="COL2ROW2",n[n.COL2ROW3=11]="COL2ROW3",n[n.COL3ROW0=12]="COL3ROW0",n[n.COL3ROW1=13]="COL3ROW1",n[n.COL3ROW2=14]="COL3ROW2",n[n.COL3ROW3=15]="COL3ROW3"})(he||(he={}));var dr=45*Math.PI/180,ur=1,le=.1,ge=500,mr=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),X=class extends qt{static get IDENTITY(){return vr()}static get ZERO(){return xr()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return he}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,e,o,r,i,s,a,c,g,h,f,p,d,x,v,y){return this[0]=t,this[1]=e,this[2]=o,this[3]=r,this[4]=i,this[5]=s,this[6]=a,this[7]=c,this[8]=g,this[9]=h,this[10]=f,this[11]=p,this[12]=d,this[13]=x,this[14]=v,this[15]=y,this.check()}setRowMajor(t,e,o,r,i,s,a,c,g,h,f,p,d,x,v,y){return this[0]=t,this[1]=i,this[2]=g,this[3]=d,this[4]=e,this[5]=s,this[6]=h,this[7]=x,this[8]=o,this[9]=a,this[10]=f,this[11]=v,this[12]=r,this[13]=c,this[14]=p,this[15]=y,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(mr)}fromObject(t){return this.check()}fromQuaternion(t){return jn(this,t),this.check()}frustum(t){let{left:e,right:o,bottom:r,top:i,near:s=le,far:a=ge}=t;return a===1/0?Mr(this,e,o,r,i,s):Gn(this,e,o,r,i,s,a),this.check()}lookAt(t){let{eye:e,center:o=[0,0,0],up:r=[0,1,0]}=t;return $n(this,e,o,r),this.check()}ortho(t){let{left:e,right:o,bottom:r,top:i,near:s=le,far:a=ge}=t;return Yn(this,e,o,r,i,s,a),this.check()}orthographic(t){let{fovy:e=dr,aspect:o=ur,focalDistance:r=1,near:i=le,far:s=ge}=t;Kn(e);let a=e/2,c=r*Math.tan(a),g=c*o;return this.ortho({left:-g,right:g,bottom:-c,top:c,near:i,far:s})}perspective(t){let{fovy:e=45*Math.PI/180,aspect:o=1,near:r=.1,far:i=500}=t;return Kn(e),qn(this,e,o,r,i),this.check()}determinant(){return Wn(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,e){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],e=e||[-0,-0,-0];let o=this.getScale(e),r=1/o[0],i=1/o[1],s=1/o[2];return t[0]=this[0]*r,t[1]=this[1]*i,t[2]=this[2]*s,t[3]=0,t[4]=this[4]*r,t[5]=this[5]*i,t[6]=this[6]*s,t[7]=0,t[8]=this[8]*r,t[9]=this[9]*i,t[10]=this[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,e){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],e=e||[-0,-0,-0];let o=this.getScale(e),r=1/o[0],i=1/o[1],s=1/o[2];return t[0]=this[0]*r,t[1]=this[1]*i,t[2]=this[2]*s,t[3]=this[4]*r,t[4]=this[5]*i,t[5]=this[6]*s,t[6]=this[8]*r,t[7]=this[9]*i,t[8]=this[10]*s,t}transpose(){return In(this,this),this.check()}invert(){return Fn(this,this),this.check()}multiplyLeft(t){return ce(this,t,this),this.check()}multiplyRight(t){return ce(this,this,t),this.check()}rotateX(t){return Un(this,this,t),this.check()}rotateY(t){return Hn(this,this,t),this.check()}rotateZ(t){return kn(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,e){return Bn(this,this,t,e),this.check()}scale(t){return Vn(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return Dn(this,this,t),this.check()}transform(t,e){return t.length===4?(e=Xn(e||[-0,-0,-0,-0],t,this),Gt(e,4),e):this.transformAsPoint(t,e)}transformAsPoint(t,e){let{length:o}=t,r;switch(o){case 2:r=On(e||[-0,-0],t,this);break;case 3:r=zn(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Gt(r,t.length),r}transformAsVector(t,e){let o;switch(t.length){case 2:o=_n(e||[-0,-0],t,this);break;case 3:o=Rn(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Gt(o,t.length),o}transformPoint(t,e){return this.transformAsPoint(t,e)}transformVector(t,e){return this.transformAsPoint(t,e)}transformDirection(t,e){return this.transformAsVector(t,e)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,e,o){return this.identity().translate([t,e,o])}},Yt,$t;function xr(){return Yt||(Yt=new X([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Yt)),Yt}function vr(){return $t||($t=new X,Object.freeze($t)),$t}function Kn(n){if(n>Math.PI*2)throw Error("expected radians")}function Mr(n,t,e,o,r,i){let s=2*i/(e-t),a=2*i/(r-o),c=(e+t)/(e-t),g=(r+o)/(r-o),h=-1,f=-1,p=-2*i;return n[0]=s,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=a,n[6]=0,n[7]=0,n[8]=c,n[9]=g,n[10]=h,n[11]=f,n[12]=0,n[13]=0,n[14]=p,n[15]=0,n}var yr=`layout(std140) uniform binOptionsUniforms {
|
|
527
|
+
`})})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},colorWeights:{size:1,accessor:"getColorWeight"},elevationWeights:{size:1,accessor:"getElevationWeight"}})}updateState(t){let e=super.updateState(t),{props:o,oldProps:i,changeFlags:r}=t,{aggregator:s}=this.state;if((r.dataChanged||!this.state.dataAsArray)&&(o.getColorValue||o.getElevationValue)&&(this.state.dataAsArray=Array.from((0,q.createIterable)(o.data).iterable)),e||r.dataChanged||o.radius!==i.radius||o.getColorValue!==i.getColorValue||o.getElevationValue!==i.getElevationValue||o.colorAggregation!==i.colorAggregation||o.elevationAggregation!==i.elevationAggregation){this._updateBinOptions();let{radiusCommon:a,hexOriginCommon:c,binIdRange:g,dataAsArray:h}=this.state;if(s.setProps({binIdRange:g,pointCount:this.getNumInstances(),operations:[o.colorAggregation,o.elevationAggregation],binOptions:{radiusCommon:a,hexOriginCommon:c},onUpdate:this._onAggregationUpdate.bind(this)}),h){let{getColorValue:u,getElevationValue:p}=this.props;s.setProps({customOperations:[u&&(f=>u(f.map(x=>h[x]),{indices:f,data:o.data})),p&&(f=>p(f.map(x=>h[x]),{indices:f,data:o.data}))]})}}return r.updateTriggersChanged&&r.updateTriggersChanged.getColorValue&&s.setNeedsUpdate(0),r.updateTriggersChanged&&r.updateTriggersChanged.getElevationValue&&s.setNeedsUpdate(1),e}_updateBinOptions(){let t=this.getBounds(),e=1,o=[0,0],i=[[0,1],[0,1]],r=this.context.viewport;if(t&&Number.isFinite(t[0][0])){let s=[(t[0][0]+t[1][0])/2,(t[0][1]+t[1][1])/2],{radius:a}=this.props,{unitsPerMeter:c}=r.getDistanceScales(s);e=c[0]*a;let g=Ft(r.projectFlat(s),e);s=r.unprojectFlat(re(g,e));let h=r.constructor;r=r.isGeospatial?new h({longitude:s[0],latitude:s[1],zoom:12}):new q.Viewport({position:[s[0],s[1],0],zoom:12}),o=[Math.fround(r.center[0]),Math.fround(r.center[1])],i=tt({dataBounds:t,getBinId:u=>{let p=r.projectFlat(u);return p[0]-=o[0],p[1]-=o[1],Ft(p,e)},padding:1})}this.setState({radiusCommon:e,hexOriginCommon:o,binIdRange:i,aggregatorViewport:r})}draw(t){t.shaderModuleProps.project&&(t.shaderModuleProps.project.viewport=this.state.aggregatorViewport),super.draw(t)}_onAggregationUpdate({channel:t}){let e=this.getCurrentLayer().props,{aggregator:o}=this.state;if(t===0){let i=o.getResult(0);this.setState({colors:new G(i,o.binCount)}),e.onSetColorDomain(o.getResultDomain(0))}else if(t===1){let i=o.getResult(1);this.setState({elevations:new G(i,o.binCount)}),e.onSetElevationDomain(o.getResultDomain(1))}}onAttributeChange(t){let{aggregator:e}=this.state;switch(t){case"positions":e.setNeedsUpdate(),this._updateBinOptions();let{radiusCommon:o,hexOriginCommon:i,binIdRange:r}=this.state;e.setProps({binIdRange:r,binOptions:{radiusCommon:o,hexOriginCommon:i}});break;case"colorWeights":e.setNeedsUpdate(0);break;case"elevationWeights":e.setNeedsUpdate(1);break;default:}}renderLayers(){let{aggregator:t,radiusCommon:e,hexOriginCommon:o}=this.state,{elevationScale:i,colorRange:r,elevationRange:s,extruded:a,coverage:c,material:g,transitions:h,colorScaleType:u,lowerPercentile:p,upperPercentile:f,colorDomain:x,elevationScaleType:y,elevationLowerPercentile:M,elevationUpperPercentile:A,elevationDomain:E}=this.props,v=this.getSubLayerClass("cells",$e),S=t.getBins(),b=this.state.colors?.update({scaleType:u,lowerPercentile:p,upperPercentile:f}),C=this.state.elevations?.update({scaleType:y,lowerPercentile:M,upperPercentile:A});return!b||!C?null:new v(this.getSubLayerProps({id:"cells"}),{data:{length:t.binCount,attributes:{getBin:S,getColorValue:b.attribute,getElevationValue:C.attribute}},dataComparator:(P,_)=>P.length===_.length,updateTriggers:{getBin:[S],getColorValue:[b.attribute],getElevationValue:[C.attribute]},diskResolution:6,vertices:He,radius:e,hexOriginCommon:o,elevationScale:i,colorRange:r,colorScaleType:u,elevationRange:s,extruded:a,coverage:c,material:g,colorDomain:b.domain||x||t.getResultDomain(0),elevationDomain:C.domain||E||t.getResultDomain(1),colorCutoff:b.cutoff,elevationCutoff:C.cutoff,transitions:h&&{getFillColor:h.getColorValue||h.getColorWeight,getElevation:h.getElevationValue||h.getElevationWeight},extensions:[]})}getPickingInfo(t){let e=t.info,{index:o}=e;if(o>=0){let i=this.state.aggregator.getBin(o),r;if(i){let s=re(i.id,this.state.radiusCommon),a=this.context.viewport.unprojectFlat(s);r={col:i.id[0],row:i.id[1],position:a,colorValue:i.value[0],elevationValue:i.value[1],count:i.count},i.pointIndices&&(r.pointIndices=i.pointIndices,r.points=Array.isArray(this.props.data)?i.pointIndices.map(c=>this.props.data[c]):[])}e.object=r}return e}};yt.layerName="HexagonLayer";yt.defaultProps=li;var Ke=yt;var U=w(z(),1),Zt=w(Z(),1);var d=.16666666666666666,l={N:[0,.5],E:[.5,0],S:[0,-.5],W:[-.5,0],NE:[.5,.5],NW:[-.5,.5],SE:[.5,-.5],SW:[-.5,-.5]},et=[l.W,l.SW,l.S],nt=[l.S,l.SE,l.E],ot=[l.E,l.NE,l.N],it=[l.NW,l.W,l.N],rt=[[-.5,d],[-.5,-d],[-d,-.5],[d,-.5]],st=[[-d,-.5],[d,-.5],[.5,-d],[.5,d]],at=[[.5,-d],[.5,d],[d,.5],[-d,.5]],ct=[[-.5,d],[-.5,-d],[d,.5],[-d,.5]],Qe=[l.W,l.SW,l.SE,l.E],Je=[l.S,l.SE,l.NE,l.N],tn=[l.NW,l.W,l.E,l.NE],en=[l.NW,l.SW,l.S,l.N],nn=[[-.5,d],[-.5,-d],[.5,-d],[.5,d]],on=[[-d,-.5],[d,-.5],[d,.5],[-d,.5]],gi=[l.NW,l.SW,l.SE,l.NE],rn=[l.NW,l.SW,l.SE,l.E,l.N],sn=[l.W,l.SW,l.SE,l.NE,l.N],an=[l.NW,l.W,l.S,l.SE,l.NE],cn=[l.NW,l.SW,l.S,l.E,l.NE],ln=[l.NW,l.W,[.5,-d],[.5,d],l.N],gn=[[-d,-.5],[d,-.5],l.E,l.NE,l.N],hn=[[-.5,d],[-.5,-d],l.S,l.SE,l.E],pn=[l.W,l.SW,l.S,[d,.5],[-d,.5]],un=[l.NW,l.W,[-d,-.5],[d,-.5],l.N],fn=[[-.5,d],[-.5,-d],l.E,l.NE,l.N],mn=[l.S,l.SE,l.E,[d,.5],[-d,.5]],dn=[l.W,l.SW,l.S,[.5,-d],[.5,d]],xn=[l.W,l.SW,l.SE,l.E,[d,.5],[-d,.5]],vn=[[-.5,d],[-.5,-d],l.S,l.SE,l.NE,l.N],yn=[l.NW,l.W,[-d,-.5],[d,-.5],l.E,l.NE],Mn=[l.NW,l.SW,l.S,[.5,-d],[.5,d],l.N],lt=[l.W,l.SW,l.S,l.E,l.NE,l.N],gt=[l.NW,l.W,l.S,l.SE,l.E,l.N],Bt=[[-.5,d],[-.5,-d],[-d,-.5],[d,-.5],l.E,l.NE,l.N],Ut=[l.W,l.SW,l.S,[.5,-d],[.5,d],[d,.5],[-d,.5]],Ht=[l.NW,l.W,[-d,-.5],[d,-.5],[.5,-d],[.5,d],l.N],kt=[[-.5,d],[-.5,-d],l.S,l.SE,l.E,[d,.5],[-d,.5]],bn=[[-.5,d],[-.5,-d],[-d,-.5],[d,-.5],[.5,-d],[.5,d],[d,.5],[-d,.5]],Cn={0:[],1:[[l.W,l.S]],2:[[l.S,l.E]],3:[[l.W,l.E]],4:[[l.N,l.E]],5:{0:[[l.W,l.S],[l.N,l.E]],1:[[l.W,l.N],[l.S,l.E]]},6:[[l.N,l.S]],7:[[l.W,l.N]],8:[[l.W,l.N]],9:[[l.N,l.S]],10:{0:[[l.W,l.N],[l.S,l.E]],1:[[l.W,l.S],[l.N,l.E]]},11:[[l.N,l.E]],12:[[l.W,l.E]],13:[[l.S,l.E]],14:[[l.W,l.S]],15:[]};function m(n){return parseInt(n,4)}var Sn={[m("0000")]:[],[m("2222")]:[],[m("2221")]:[et],[m("2212")]:[nt],[m("2122")]:[ot],[m("1222")]:[it],[m("0001")]:[et],[m("0010")]:[nt],[m("0100")]:[ot],[m("1000")]:[it],[m("2220")]:[rt],[m("2202")]:[st],[m("2022")]:[at],[m("0222")]:[ct],[m("0002")]:[rt],[m("0020")]:[st],[m("0200")]:[at],[m("2000")]:[ct],[m("0011")]:[Qe],[m("0110")]:[Je],[m("1100")]:[tn],[m("1001")]:[en],[m("2211")]:[Qe],[m("2112")]:[Je],[m("1122")]:[tn],[m("1221")]:[en],[m("2200")]:[nn],[m("2002")]:[on],[m("0022")]:[nn],[m("0220")]:[on],[m("1111")]:[gi],[m("1211")]:[rn],[m("2111")]:[sn],[m("1112")]:[an],[m("1121")]:[cn],[m("1011")]:[rn],[m("0111")]:[sn],[m("1110")]:[an],[m("1101")]:[cn],[m("1200")]:[ln],[m("0120")]:[gn],[m("0012")]:[hn],[m("2001")]:[pn],[m("1022")]:[ln],[m("2102")]:[gn],[m("2210")]:[hn],[m("0221")]:[pn],[m("1002")]:[un],[m("2100")]:[fn],[m("0210")]:[mn],[m("0021")]:[dn],[m("1220")]:[un],[m("0122")]:[fn],[m("2012")]:[mn],[m("2201")]:[dn],[m("0211")]:[xn],[m("2110")]:[vn],[m("1102")]:[yn],[m("1021")]:[Mn],[m("2011")]:[xn],[m("0112")]:[vn],[m("1120")]:[yn],[m("1201")]:[Mn],[m("2101")]:[lt],[m("0121")]:[lt],[m("1012")]:[gt],[m("1210")]:[gt],[m("0101")]:{0:[et,ot],1:[lt],2:[lt]},[m("1010")]:{0:[it,nt],1:[gt],2:[gt]},[m("2121")]:{0:[lt],1:[lt],2:[et,ot]},[m("1212")]:{0:[gt],1:[gt],2:[it,nt]},[m("2120")]:{0:[Bt],1:[Bt],2:[rt,ot]},[m("2021")]:{0:[Ut],1:[Ut],2:[et,at]},[m("1202")]:{0:[Ht],1:[Ht],2:[it,st]},[m("0212")]:{0:[kt],1:[kt],2:[nt,ct]},[m("0102")]:{0:[rt,ot],1:[Bt],2:[Bt]},[m("0201")]:{0:[et,at],1:[Ut],2:[Ut]},[m("1020")]:{0:[it,st],1:[Ht],2:[Ht]},[m("2010")]:{0:[nt,ct],1:[kt],2:[kt]},[m("2020")]:{0:[ct,st],1:[bn],2:[rt,at]},[m("0202")]:{0:[at,rt],1:[bn],2:[ct,st]}};function Mt(n,t){return Number.isNaN(n)?0:Array.isArray(t)?n<t[0]?0:n<t[1]?1:2:n>=t?1:0}function An(n){let{x:t,y:e,xRange:o,yRange:i,getValue:r,threshold:s}=n,a=t<o[0],c=t>=o[1]-1,g=e<i[0],h=e>=i[1]-1,u=a||c||g||h,p=0,f,x,y,M;if(a||h)y=0;else{let v=r(t,e+1);y=Mt(v,s),p+=v}if(c||h)M=0;else{let v=r(t+1,e+1);M=Mt(v,s),p+=v}if(c||g)x=0;else{let v=r(t+1,e);x=Mt(v,s),p+=v}if(a||g)f=0;else{let v=r(t,e);f=Mt(v,s),p+=v}let A=-1;Number.isFinite(s)&&(A=y<<3|M<<2|x<<1|f),Array.isArray(s)&&(A=y<<6|M<<4|x<<2|f);let E=0;return u||(E=Mt(p/4,s)),{code:A,meanCode:E}}function En(n){let{x:t,y:e,z:o,code:i,meanCode:r}=n,s=Sn[i];Array.isArray(s)||(s=s[r]);let a=t+1,c=e+1,g=[];return s.forEach(h=>{let u=[];h.forEach(p=>{let f=a+p[0],x=c+p[1];u.push([f,x,o])}),g.push(u)}),g}function Tn(n){let{x:t,y:e,z:o,code:i,meanCode:r}=n,s=Cn[i];Array.isArray(s)||(s=s[r]);let a=t+1,c=e+1,g=[];return s.forEach(h=>{h.forEach(u=>{let p=a+u[0],f=c+u[1];g.push([p,f,o])})}),g}function wn({contours:n,getValue:t,xRange:e,yRange:o}){let i=[],r=[],s=0,a=0;for(let c=0;c<n.length;c++){let g=n[c],h=g.zIndex??c,{threshold:u}=g;for(let p=e[0]-1;p<e[1];p++)for(let f=o[0]-1;f<o[1];f++){let{code:x,meanCode:y}=An({getValue:t,threshold:u,x:p,y:f,xRange:e,yRange:o}),M={x:p,y:f,z:h,code:x,meanCode:y};if(Array.isArray(u)){let A=En(M);for(let E of A)r[a++]={vertices:E,contour:g}}else{let A=Tn(M);A.length>0&&(i[s++]={vertices:A,contour:g})}}}return{lines:i,polygons:r}}function Ln(n){let{aggregator:t,binIdRange:e,channel:o}=n;if(t instanceof L){let i=t.getResult(o)?.buffer;if(i){let r=new Float32Array(i.readSyncWebGL().buffer);return hi(r,e)}}if(t instanceof N){let i=t.getResult(o)?.value,r=t.getBins()?.value;if(r&&i)return pi(i,r,t.binCount)}return null}function hi(n,t){let[[e,o],[i,r]]=t,s=o-e,a=r-i;return(c,g)=>(c-=e,g-=i,c<0||c>=s||g<0||g>=a?NaN:n[g*s+c])}function pi(n,t,e){let o={};for(let i=0;i<e;i++){let r=t[i*2],s=t[i*2+1];o[r]=o[r]||{},o[r][s]=n[i]}return(i,r)=>o[i]?.[r]??NaN}var xs=1/Math.PI*180,vs=1/180*Math.PI,ui={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...ui}};var O=globalThis.mathgl.config;function Pn(n,{precision:t=O.precision}={}){return n=fi(n),`${parseFloat(n.toPrecision(t))}`}function jt(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function se(n,t,e){let o=O.EPSILON;e&&(O.EPSILON=e);try{if(n===t)return!0;if(jt(n)&&jt(t)){if(n.length!==t.length)return!1;for(let i=0;i<n.length;++i)if(!se(n[i],t[i]))return!1;return!0}return n&&n.equals?n.equals(t):t&&t.equals?t.equals(n):typeof n=="number"&&typeof t=="number"?Math.abs(n-t)<=O.EPSILON*Math.max(1,Math.abs(n),Math.abs(t)):!1}finally{O.EPSILON=o}}function fi(n){return Math.round(n/O.EPSILON)*O.EPSILON}var Gt=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,e=0){for(let o=0;o<this.ELEMENTS;++o)this[o]=t[o+e];return this.check()}toArray(t=[],e=0){for(let o=0;o<this.ELEMENTS;++o)t[e+o]=this[o];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:jt(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(O)}formatString(t){let e="";for(let o=0;o<this.ELEMENTS;++o)e+=(o>0?", ":"")+Pn(this[o],t);return`${t.printTypes?this.constructor.name:""}[${e}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(!se(this[e],t[e]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(this[e]!==t[e])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,e,o){if(o===void 0)return this.lerp(this,t,e);for(let i=0;i<this.ELEMENTS;++i){let r=t[i],s=typeof e=="number"?e:e[i];this[i]=r+o*(s-r)}return this.check()}min(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.min(t[e],this[e]);return this.check()}max(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.max(t[e],this[e]);return this.check()}clamp(t,e){for(let o=0;o<this.ELEMENTS;++o)this[o]=Math.min(Math.max(this[o],t[o]),e[o]);return this.check()}add(...t){for(let e of t)for(let o=0;o<this.ELEMENTS;++o)this[o]+=e[o];return this.check()}subtract(...t){for(let e of t)for(let o=0;o<this.ELEMENTS;++o)this[o]-=e[o];return this.check()}scale(t){if(typeof t=="number")for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;else for(let e=0;e<this.ELEMENTS&&e<t.length;++e)this[e]*=t[e];return this.check()}multiplyByScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}check(){if(O.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let e=0;e<this.ELEMENTS;++e)t=t&&Number.isFinite(this[e]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=t;return this.check()}addScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,e){for(let o=0;o<this.ELEMENTS;++o)this[o]=Math.min(Math.max(this[o],t),e);return this.check()}get elements(){return this}};function mi(n,t){if(n.length!==t)return!1;for(let e=0;e<n.length;++e)if(!Number.isFinite(n[e]))return!1;return!0}function _n(n){if(!Number.isFinite(n))throw new Error(`Invalid number ${JSON.stringify(n)}`);return n}function qt(n,t,e=""){if(O.debug&&!mi(n,t))throw new Error(`math.gl: ${e} some fields set to invalid numbers'`);return n}var H=typeof Float32Array<"u"?Float32Array:Array;var As=Math.PI/180;function di(){let n=new H(2);return H!=Float32Array&&(n[0]=0,n[1]=0),n}function Rn(n,t,e){let o=t[0],i=t[1];return n[0]=e[0]*o+e[4]*i+e[12],n[1]=e[1]*o+e[5]*i+e[13],n}var Es=(function(){let n=di();return function(t,e,o,i,r,s){let a,c;for(e||(e=2),o||(o=0),i?c=Math.min(i*e+o,t.length):c=t.length,a=o;a<c;a+=e)n[0]=t[a],n[1]=t[a+1],r(n,n,s),t[a]=n[0],t[a+1]=n[1];return t}})();function In(n,t,e){let o=t[0],i=t[1],r=e[3]*o+e[7]*i||1;return n[0]=(e[0]*o+e[4]*i)/r,n[1]=(e[1]*o+e[5]*i)/r,n}function zn(n,t,e){let o=t[0],i=t[1],r=t[2],s=e[3]*o+e[7]*i+e[11]*r||1;return n[0]=(e[0]*o+e[4]*i+e[8]*r)/s,n[1]=(e[1]*o+e[5]*i+e[9]*r)/s,n[2]=(e[2]*o+e[6]*i+e[10]*r)/s,n}function vi(){let n=new H(3);return H!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function Wn(n,t,e){let o=t[0],i=t[1],r=t[2],s=e[3]*o+e[7]*i+e[11]*r+e[15];return s=s||1,n[0]=(e[0]*o+e[4]*i+e[8]*r+e[12])/s,n[1]=(e[1]*o+e[5]*i+e[9]*r+e[13])/s,n[2]=(e[2]*o+e[6]*i+e[10]*r+e[14])/s,n}var ws=(function(){let n=vi();return function(t,e,o,i,r,s){let a,c;for(e||(e=3),o||(o=0),i?c=Math.min(i*e+o,t.length):c=t.length,a=o;a<c;a+=e)n[0]=t[a],n[1]=t[a+1],n[2]=t[a+2],r(n,n,s),t[a]=n[0],t[a+1]=n[1],t[a+2]=n[2];return t}})();var Yt=class extends Gt{toString(){let t="[";if(O.printRowMajor){t+="row-major:";for(let e=0;e<this.RANK;++e)for(let o=0;o<this.RANK;++o)t+=` ${this[o*this.RANK+e]}`}else{t+="column-major:";for(let e=0;e<this.ELEMENTS;++e)t+=` ${this[e]}`}return t+="]",t}getElementIndex(t,e){return e*this.RANK+t}getElement(t,e){return this[e*this.RANK+t]}setElement(t,e,o){return this[e*this.RANK+t]=_n(o),this}getColumn(t,e=new Array(this.RANK).fill(-0)){let o=t*this.RANK;for(let i=0;i<this.RANK;++i)e[i]=this[o+i];return e}setColumn(t,e){let o=t*this.RANK;for(let i=0;i<this.RANK;++i)this[o+i]=e[i];return this}};function Mi(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Vn(n,t){if(n===t){let e=t[1],o=t[2],i=t[3],r=t[6],s=t[7],a=t[11];n[1]=t[4],n[2]=t[8],n[3]=t[12],n[4]=e,n[6]=t[9],n[7]=t[13],n[8]=o,n[9]=r,n[11]=t[14],n[12]=i,n[13]=s,n[14]=a}else n[0]=t[0],n[1]=t[4],n[2]=t[8],n[3]=t[12],n[4]=t[1],n[5]=t[5],n[6]=t[9],n[7]=t[13],n[8]=t[2],n[9]=t[6],n[10]=t[10],n[11]=t[14],n[12]=t[3],n[13]=t[7],n[14]=t[11],n[15]=t[15];return n}function Fn(n,t){let e=t[0],o=t[1],i=t[2],r=t[3],s=t[4],a=t[5],c=t[6],g=t[7],h=t[8],u=t[9],p=t[10],f=t[11],x=t[12],y=t[13],M=t[14],A=t[15],E=e*a-o*s,v=e*c-i*s,S=e*g-r*s,b=o*c-i*a,C=o*g-r*a,P=i*g-r*c,_=h*y-u*x,R=h*M-p*x,I=h*A-f*x,W=u*M-p*y,V=u*A-f*y,F=p*A-f*M,T=E*F-v*V+S*W+b*I-C*R+P*_;return T?(T=1/T,n[0]=(a*F-c*V+g*W)*T,n[1]=(i*V-o*F-r*W)*T,n[2]=(y*P-M*C+A*b)*T,n[3]=(p*C-u*P-f*b)*T,n[4]=(c*I-s*F-g*R)*T,n[5]=(e*F-i*I+r*R)*T,n[6]=(M*S-x*P-A*v)*T,n[7]=(h*P-p*S+f*v)*T,n[8]=(s*V-a*I+g*_)*T,n[9]=(o*I-e*V-r*_)*T,n[10]=(x*C-y*S+A*E)*T,n[11]=(u*S-h*C-f*E)*T,n[12]=(a*R-s*W-c*_)*T,n[13]=(e*W-o*R+i*_)*T,n[14]=(y*v-x*b-M*E)*T,n[15]=(h*b-u*v+p*E)*T,n):null}function Dn(n){let t=n[0],e=n[1],o=n[2],i=n[3],r=n[4],s=n[5],a=n[6],c=n[7],g=n[8],h=n[9],u=n[10],p=n[11],f=n[12],x=n[13],y=n[14],M=n[15],A=t*s-e*r,E=t*a-o*r,v=e*a-o*s,S=g*x-h*f,b=g*y-u*f,C=h*y-u*x,P=t*C-e*b+o*S,_=r*C-s*b+a*S,R=g*v-h*E+u*A,I=f*v-x*E+y*A;return c*P-i*_+M*R-p*I}function ce(n,t,e){let o=t[0],i=t[1],r=t[2],s=t[3],a=t[4],c=t[5],g=t[6],h=t[7],u=t[8],p=t[9],f=t[10],x=t[11],y=t[12],M=t[13],A=t[14],E=t[15],v=e[0],S=e[1],b=e[2],C=e[3];return n[0]=v*o+S*a+b*u+C*y,n[1]=v*i+S*c+b*p+C*M,n[2]=v*r+S*g+b*f+C*A,n[3]=v*s+S*h+b*x+C*E,v=e[4],S=e[5],b=e[6],C=e[7],n[4]=v*o+S*a+b*u+C*y,n[5]=v*i+S*c+b*p+C*M,n[6]=v*r+S*g+b*f+C*A,n[7]=v*s+S*h+b*x+C*E,v=e[8],S=e[9],b=e[10],C=e[11],n[8]=v*o+S*a+b*u+C*y,n[9]=v*i+S*c+b*p+C*M,n[10]=v*r+S*g+b*f+C*A,n[11]=v*s+S*h+b*x+C*E,v=e[12],S=e[13],b=e[14],C=e[15],n[12]=v*o+S*a+b*u+C*y,n[13]=v*i+S*c+b*p+C*M,n[14]=v*r+S*g+b*f+C*A,n[15]=v*s+S*h+b*x+C*E,n}function Bn(n,t,e){let o=e[0],i=e[1],r=e[2],s,a,c,g,h,u,p,f,x,y,M,A;return t===n?(n[12]=t[0]*o+t[4]*i+t[8]*r+t[12],n[13]=t[1]*o+t[5]*i+t[9]*r+t[13],n[14]=t[2]*o+t[6]*i+t[10]*r+t[14],n[15]=t[3]*o+t[7]*i+t[11]*r+t[15]):(s=t[0],a=t[1],c=t[2],g=t[3],h=t[4],u=t[5],p=t[6],f=t[7],x=t[8],y=t[9],M=t[10],A=t[11],n[0]=s,n[1]=a,n[2]=c,n[3]=g,n[4]=h,n[5]=u,n[6]=p,n[7]=f,n[8]=x,n[9]=y,n[10]=M,n[11]=A,n[12]=s*o+h*i+x*r+t[12],n[13]=a*o+u*i+y*r+t[13],n[14]=c*o+p*i+M*r+t[14],n[15]=g*o+f*i+A*r+t[15]),n}function Un(n,t,e){let o=e[0],i=e[1],r=e[2];return n[0]=t[0]*o,n[1]=t[1]*o,n[2]=t[2]*o,n[3]=t[3]*o,n[4]=t[4]*i,n[5]=t[5]*i,n[6]=t[6]*i,n[7]=t[7]*i,n[8]=t[8]*r,n[9]=t[9]*r,n[10]=t[10]*r,n[11]=t[11]*r,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}function Hn(n,t,e,o){let i=o[0],r=o[1],s=o[2],a=Math.sqrt(i*i+r*r+s*s),c,g,h,u,p,f,x,y,M,A,E,v,S,b,C,P,_,R,I,W,V,F,T,mt;return a<1e-6?null:(a=1/a,i*=a,r*=a,s*=a,g=Math.sin(e),c=Math.cos(e),h=1-c,u=t[0],p=t[1],f=t[2],x=t[3],y=t[4],M=t[5],A=t[6],E=t[7],v=t[8],S=t[9],b=t[10],C=t[11],P=i*i*h+c,_=r*i*h+s*g,R=s*i*h-r*g,I=i*r*h-s*g,W=r*r*h+c,V=s*r*h+i*g,F=i*s*h+r*g,T=r*s*h-i*g,mt=s*s*h+c,n[0]=u*P+y*_+v*R,n[1]=p*P+M*_+S*R,n[2]=f*P+A*_+b*R,n[3]=x*P+E*_+C*R,n[4]=u*I+y*W+v*V,n[5]=p*I+M*W+S*V,n[6]=f*I+A*W+b*V,n[7]=x*I+E*W+C*V,n[8]=u*F+y*T+v*mt,n[9]=p*F+M*T+S*mt,n[10]=f*F+A*T+b*mt,n[11]=x*F+E*T+C*mt,t!==n&&(n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n)}function kn(n,t,e){let o=Math.sin(e),i=Math.cos(e),r=t[4],s=t[5],a=t[6],c=t[7],g=t[8],h=t[9],u=t[10],p=t[11];return t!==n&&(n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[4]=r*i+g*o,n[5]=s*i+h*o,n[6]=a*i+u*o,n[7]=c*i+p*o,n[8]=g*i-r*o,n[9]=h*i-s*o,n[10]=u*i-a*o,n[11]=p*i-c*o,n}function jn(n,t,e){let o=Math.sin(e),i=Math.cos(e),r=t[0],s=t[1],a=t[2],c=t[3],g=t[8],h=t[9],u=t[10],p=t[11];return t!==n&&(n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[0]=r*i-g*o,n[1]=s*i-h*o,n[2]=a*i-u*o,n[3]=c*i-p*o,n[8]=r*o+g*i,n[9]=s*o+h*i,n[10]=a*o+u*i,n[11]=c*o+p*i,n}function Gn(n,t,e){let o=Math.sin(e),i=Math.cos(e),r=t[0],s=t[1],a=t[2],c=t[3],g=t[4],h=t[5],u=t[6],p=t[7];return t!==n&&(n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[0]=r*i+g*o,n[1]=s*i+h*o,n[2]=a*i+u*o,n[3]=c*i+p*o,n[4]=g*i-r*o,n[5]=h*i-s*o,n[6]=u*i-a*o,n[7]=p*i-c*o,n}function qn(n,t){let e=t[0],o=t[1],i=t[2],r=t[3],s=e+e,a=o+o,c=i+i,g=e*s,h=o*s,u=o*a,p=i*s,f=i*a,x=i*c,y=r*s,M=r*a,A=r*c;return n[0]=1-u-x,n[1]=h+A,n[2]=p-M,n[3]=0,n[4]=h-A,n[5]=1-g-x,n[6]=f+y,n[7]=0,n[8]=p+M,n[9]=f-y,n[10]=1-g-u,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Yn(n,t,e,o,i,r,s){let a=1/(e-t),c=1/(i-o),g=1/(r-s);return n[0]=r*2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=r*2*c,n[6]=0,n[7]=0,n[8]=(e+t)*a,n[9]=(i+o)*c,n[10]=(s+r)*g,n[11]=-1,n[12]=0,n[13]=0,n[14]=s*r*2*g,n[15]=0,n}function bi(n,t,e,o,i){let r=1/Math.tan(t/2);if(n[0]=r/e,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=r,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,i!=null&&i!==1/0){let s=1/(o-i);n[10]=(i+o)*s,n[14]=2*i*o*s}else n[10]=-1,n[14]=-2*o;return n}var $n=bi;function Ci(n,t,e,o,i,r,s){let a=1/(t-e),c=1/(o-i),g=1/(r-s);return n[0]=-2*a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*c,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*g,n[11]=0,n[12]=(t+e)*a,n[13]=(i+o)*c,n[14]=(s+r)*g,n[15]=1,n}var Xn=Ci;function Zn(n,t,e,o){let i,r,s,a,c,g,h,u,p,f,x=t[0],y=t[1],M=t[2],A=o[0],E=o[1],v=o[2],S=e[0],b=e[1],C=e[2];return Math.abs(x-S)<1e-6&&Math.abs(y-b)<1e-6&&Math.abs(M-C)<1e-6?Mi(n):(u=x-S,p=y-b,f=M-C,i=1/Math.sqrt(u*u+p*p+f*f),u*=i,p*=i,f*=i,r=E*f-v*p,s=v*u-A*f,a=A*p-E*u,i=Math.sqrt(r*r+s*s+a*a),i?(i=1/i,r*=i,s*=i,a*=i):(r=0,s=0,a=0),c=p*a-f*s,g=f*r-u*a,h=u*s-p*r,i=Math.sqrt(c*c+g*g+h*h),i?(i=1/i,c*=i,g*=i,h*=i):(c=0,g=0,h=0),n[0]=r,n[1]=c,n[2]=u,n[3]=0,n[4]=s,n[5]=g,n[6]=p,n[7]=0,n[8]=a,n[9]=h,n[10]=f,n[11]=0,n[12]=-(r*x+s*y+a*M),n[13]=-(c*x+g*y+h*M),n[14]=-(u*x+p*y+f*M),n[15]=1,n)}function Ai(){let n=new H(4);return H!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function Kn(n,t,e){let o=t[0],i=t[1],r=t[2],s=t[3];return n[0]=e[0]*o+e[4]*i+e[8]*r+e[12]*s,n[1]=e[1]*o+e[5]*i+e[9]*r+e[13]*s,n[2]=e[2]*o+e[6]*i+e[10]*r+e[14]*s,n[3]=e[3]*o+e[7]*i+e[11]*r+e[15]*s,n}var Os=(function(){let n=Ai();return function(t,e,o,i,r,s){let a,c;for(e||(e=4),o||(o=0),i?c=Math.min(i*e+o,t.length):c=t.length,a=o;a<c;a+=e)n[0]=t[a],n[1]=t[a+1],n[2]=t[a+2],n[3]=t[a+3],r(n,n,s),t[a]=n[0],t[a+1]=n[1],t[a+2]=n[2],t[a+3]=n[3];return t}})();var he;(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL0ROW3=3]="COL0ROW3",n[n.COL1ROW0=4]="COL1ROW0",n[n.COL1ROW1=5]="COL1ROW1",n[n.COL1ROW2=6]="COL1ROW2",n[n.COL1ROW3=7]="COL1ROW3",n[n.COL2ROW0=8]="COL2ROW0",n[n.COL2ROW1=9]="COL2ROW1",n[n.COL2ROW2=10]="COL2ROW2",n[n.COL2ROW3=11]="COL2ROW3",n[n.COL3ROW0=12]="COL3ROW0",n[n.COL3ROW1=13]="COL3ROW1",n[n.COL3ROW2=14]="COL3ROW2",n[n.COL3ROW3=15]="COL3ROW3"})(he||(he={}));var Ti=45*Math.PI/180,wi=1,le=.1,ge=500,Li=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),X=class extends Yt{static get IDENTITY(){return _i()}static get ZERO(){return Pi()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return he}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,e,o,i,r,s,a,c,g,h,u,p,f,x,y,M){return this[0]=t,this[1]=e,this[2]=o,this[3]=i,this[4]=r,this[5]=s,this[6]=a,this[7]=c,this[8]=g,this[9]=h,this[10]=u,this[11]=p,this[12]=f,this[13]=x,this[14]=y,this[15]=M,this.check()}setRowMajor(t,e,o,i,r,s,a,c,g,h,u,p,f,x,y,M){return this[0]=t,this[1]=r,this[2]=g,this[3]=f,this[4]=e,this[5]=s,this[6]=h,this[7]=x,this[8]=o,this[9]=a,this[10]=u,this[11]=y,this[12]=i,this[13]=c,this[14]=p,this[15]=M,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(Li)}fromObject(t){return this.check()}fromQuaternion(t){return qn(this,t),this.check()}frustum(t){let{left:e,right:o,bottom:i,top:r,near:s=le,far:a=ge}=t;return a===1/0?Ni(this,e,o,i,r,s):Yn(this,e,o,i,r,s,a),this.check()}lookAt(t){let{eye:e,center:o=[0,0,0],up:i=[0,1,0]}=t;return Zn(this,e,o,i),this.check()}ortho(t){let{left:e,right:o,bottom:i,top:r,near:s=le,far:a=ge}=t;return Xn(this,e,o,i,r,s,a),this.check()}orthographic(t){let{fovy:e=Ti,aspect:o=wi,focalDistance:i=1,near:r=le,far:s=ge}=t;Qn(e);let a=e/2,c=i*Math.tan(a),g=c*o;return this.ortho({left:-g,right:g,bottom:-c,top:c,near:r,far:s})}perspective(t){let{fovy:e=45*Math.PI/180,aspect:o=1,near:i=.1,far:r=500}=t;return Qn(e),$n(this,e,o,i,r),this.check()}determinant(){return Dn(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,e){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],e=e||[-0,-0,-0];let o=this.getScale(e),i=1/o[0],r=1/o[1],s=1/o[2];return t[0]=this[0]*i,t[1]=this[1]*r,t[2]=this[2]*s,t[3]=0,t[4]=this[4]*i,t[5]=this[5]*r,t[6]=this[6]*s,t[7]=0,t[8]=this[8]*i,t[9]=this[9]*r,t[10]=this[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,e){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],e=e||[-0,-0,-0];let o=this.getScale(e),i=1/o[0],r=1/o[1],s=1/o[2];return t[0]=this[0]*i,t[1]=this[1]*r,t[2]=this[2]*s,t[3]=this[4]*i,t[4]=this[5]*r,t[5]=this[6]*s,t[6]=this[8]*i,t[7]=this[9]*r,t[8]=this[10]*s,t}transpose(){return Vn(this,this),this.check()}invert(){return Fn(this,this),this.check()}multiplyLeft(t){return ce(this,t,this),this.check()}multiplyRight(t){return ce(this,this,t),this.check()}rotateX(t){return kn(this,this,t),this.check()}rotateY(t){return jn(this,this,t),this.check()}rotateZ(t){return Gn(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,e){return Hn(this,this,t,e),this.check()}scale(t){return Un(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return Bn(this,this,t),this.check()}transform(t,e){return t.length===4?(e=Kn(e||[-0,-0,-0,-0],t,this),qt(e,4),e):this.transformAsPoint(t,e)}transformAsPoint(t,e){let{length:o}=t,i;switch(o){case 2:i=Rn(e||[-0,-0],t,this);break;case 3:i=Wn(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return qt(i,t.length),i}transformAsVector(t,e){let o;switch(t.length){case 2:o=In(e||[-0,-0],t,this);break;case 3:o=zn(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return qt(o,t.length),o}transformPoint(t,e){return this.transformAsPoint(t,e)}transformVector(t,e){return this.transformAsPoint(t,e)}transformDirection(t,e){return this.transformAsVector(t,e)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,e,o){return this.identity().translate([t,e,o])}},$t,Xt;function Pi(){return $t||($t=new X([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze($t)),$t}function _i(){return Xt||(Xt=new X,Object.freeze(Xt)),Xt}function Qn(n){if(n>Math.PI*2)throw Error("expected radians")}function Ni(n,t,e,o,i,r){let s=2*r/(e-t),a=2*r/(i-o),c=(e+t)/(e-t),g=(i+o)/(i-o),h=-1,u=-1,p=-2*r;return n[0]=s,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=a,n[6]=0,n[7]=0,n[8]=c,n[9]=g,n[10]=h,n[11]=u,n[12]=0,n[13]=0,n[14]=p,n[15]=0,n}var Oi=`layout(std140) uniform binOptionsUniforms {
|
|
323
528
|
vec2 cellOriginCommon;
|
|
324
529
|
vec2 cellSizeCommon;
|
|
325
530
|
} binOptions;
|
|
326
|
-
`,
|
|
531
|
+
`,Jn={name:"binOptions",vs:Oi,uniformTypes:{cellOriginCommon:"vec2<f32>",cellSizeCommon:"vec2<f32>"}};var to=[255,255,255,255],Ri=1,Ii={cellSize:{type:"number",min:1,value:1e3},gridOrigin:{type:"array",compare:!0,value:[0,0]},getPosition:{type:"accessor",value:n=>n.position},getWeight:{type:"accessor",value:1},gpuAggregation:!0,aggregation:"SUM",contours:{type:"object",value:[{threshold:1}],optional:!0,compare:3},zOffset:.005},bt=class extends B{getAggregatorType(){return this.props.gpuAggregation&&L.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(t){return t==="cpu"?new N({dimensions:2,getBin:{sources:["positions"],getValue:({positions:e},o,i)=>{let s=this.state.aggregatorViewport.projectPosition(e),{cellSizeCommon:a,cellOriginCommon:c}=i;return[Math.floor((s[0]-c[0])/a[0]),Math.floor((s[1]-c[1])/a[1])]}},getValue:[{sources:["counts"],getValue:({counts:e})=>e}],onUpdate:this._onAggregationUpdate.bind(this)}):new L(this.context.device,{dimensions:2,channelCount:1,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[U.project32,Jn],vs:`
|
|
327
532
|
in vec3 positions;
|
|
328
533
|
in vec3 positions64Low;
|
|
329
534
|
in float counts;
|
|
@@ -336,7 +541,115 @@ DECKGL_FILTER_COLOR(vColor, geometry);
|
|
|
336
541
|
void getValue(out float value) {
|
|
337
542
|
value = counts;
|
|
338
543
|
}
|
|
339
|
-
`}),onUpdate:this._onAggregationUpdate.bind(this)})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},counts:{size:1,accessor:"getWeight"}})}updateState(t){let e=super.updateState(t),{props:o,oldProps:
|
|
544
|
+
`}),onUpdate:this._onAggregationUpdate.bind(this)})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},counts:{size:1,accessor:"getWeight"}})}updateState(t){let e=super.updateState(t),{props:o,oldProps:i,changeFlags:r}=t,{aggregator:s}=this.state;if(e||r.dataChanged||o.cellSize!==i.cellSize||!(0,U._deepEqual)(o.gridOrigin,i.gridOrigin,1)||o.aggregation!==i.aggregation){this._updateBinOptions();let{cellSizeCommon:a,cellOriginCommon:c,binIdRange:g}=this.state;s.setProps({binIdRange:g,pointCount:this.getNumInstances(),operations:[o.aggregation],binOptions:{cellSizeCommon:a,cellOriginCommon:c}})}return(0,U._deepEqual)(i.contours,o.contours,2)||this.setState({contourData:null}),e}_updateBinOptions(){let t=this.getBounds(),e=[1,1],o=[0,0],i=[[0,1],[0,1]],r=this.context.viewport;if(t&&Number.isFinite(t[0][0])){let s=[(t[0][0]+t[1][0])/2,(t[0][1]+t[1][1])/2],{cellSize:a,gridOrigin:c}=this.props,{unitsPerMeter:g}=r.getDistanceScales(s);e[0]=g[0]*a,e[1]=g[1]*a;let h=r.projectFlat(s);o=[Math.floor((h[0]-c[0])/e[0])*e[0]+c[0],Math.floor((h[1]-c[1])/e[1])*e[1]+c[1]],s=r.unprojectFlat(o);let u=r.constructor;r=r.isGeospatial?new u({longitude:s[0],latitude:s[1],zoom:12}):new U.Viewport({position:[s[0],s[1],0],zoom:12}),o=[Math.fround(r.center[0]),Math.fround(r.center[1])],i=tt({dataBounds:t,getBinId:p=>{let f=r.projectFlat(p);return[Math.floor((f[0]-o[0])/e[0]),Math.floor((f[1]-o[1])/e[1])]}})}this.setState({cellSizeCommon:e,cellOriginCommon:o,binIdRange:i,aggregatorViewport:r})}draw(t){t.shaderModuleProps.project&&(t.shaderModuleProps.project.viewport=this.state.aggregatorViewport),super.draw(t)}_onAggregationUpdate(){let{aggregator:t,binIdRange:e}=this.state;this.setState({aggregatedValueReader:Ln({aggregator:t,binIdRange:e,channel:0}),contourData:null})}_getContours(){let{aggregatedValueReader:t}=this.state;if(!t)return null;if(!this.state.contourData){let{binIdRange:e}=this.state,{contours:o}=this.props,i=wn({contours:o,getValue:t,xRange:e[0],yRange:e[1]});this.state.contourData=i}return this.state.contourData}onAttributeChange(t){let{aggregator:e}=this.state;switch(t){case"positions":e.setNeedsUpdate(),this._updateBinOptions();let{cellSizeCommon:o,cellOriginCommon:i,binIdRange:r}=this.state;e.setProps({binIdRange:r,binOptions:{cellSizeCommon:o,cellOriginCommon:i}});break;case"counts":e.setNeedsUpdate(0);break;default:}}renderLayers(){let t=this._getContours();if(!t)return null;let{lines:e,polygons:o}=t,{zOffset:i}=this.props,{cellOriginCommon:r,cellSizeCommon:s}=this.state,a=this.getSubLayerClass("lines",Zt.PathLayer),c=this.getSubLayerClass("bands",Zt.SolidPolygonLayer),g=new X().translate([r[0],r[1],0]).scale([s[0],s[1],i]),h=e&&e.length>0&&new a(this.getSubLayerProps({id:"lines"}),{data:e,coordinateSystem:U.COORDINATE_SYSTEM.CARTESIAN,modelMatrix:g,getPath:p=>p.vertices,getColor:p=>p.contour.color??to,getWidth:p=>p.contour.strokeWidth??Ri,widthUnits:"pixels"}),u=o&&o.length>0&&new c(this.getSubLayerProps({id:"bands"}),{data:o,coordinateSystem:U.COORDINATE_SYSTEM.CARTESIAN,modelMatrix:g,getPolygon:p=>p.vertices,getFillColor:p=>p.contour.color??to});return[h,u]}getPickingInfo(t){let e=t.info,{object:o}=e;return o&&(e.object={contour:o.contour}),e}};bt.layerName="ContourLayer";bt.defaultProps=Ii;var eo=bt;var Y=w(z(),1);var ro=w(Z(),1),so=w($(),1);var no=`struct Attributes {
|
|
545
|
+
@builtin(instance_index) instanceIndex: u32,
|
|
546
|
+
@location(0) positions: vec3<f32>,
|
|
547
|
+
@location(1) normals: vec3<f32>,
|
|
548
|
+
@location(2) instancePositions: vec2<f32>,
|
|
549
|
+
@location(3) instanceColorValues: f32,
|
|
550
|
+
@location(4) instanceElevationValues: f32,
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
struct Varyings {
|
|
554
|
+
@builtin(position) position: vec4<f32>,
|
|
555
|
+
@location(0) color: vec4<f32>,
|
|
556
|
+
@location(1) pickingColor: vec3<f32>,
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
fn interpolate(value: f32, domain: vec2<f32>, range: vec2<f32>) -> f32 {
|
|
560
|
+
let ratio = clamp((value - domain.x) / (domain.y - domain.x), 0.0, 1.0);
|
|
561
|
+
return mix(range.x, range.y, ratio);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
fn sampleColorRange(value: f32, domain: vec2<f32>) -> vec4<f32> {
|
|
565
|
+
let ratio = (value - domain.x) / (domain.y - domain.x);
|
|
566
|
+
return textureSampleLevel(colorRange, colorRangeSampler, vec2<f32>(ratio, 0.5), 0.0);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
@vertex
|
|
570
|
+
fn vertexMain(attributes: Attributes) -> Varyings {
|
|
571
|
+
var output: Varyings;
|
|
572
|
+
geometry.pickingColor = picking_getPickingColorFromIndex(attributes.instanceIndex);
|
|
573
|
+
output.pickingColor = geometry.pickingColor;
|
|
574
|
+
|
|
575
|
+
if (
|
|
576
|
+
attributes.instanceColorValues != attributes.instanceColorValues ||
|
|
577
|
+
attributes.instanceColorValues < grid.colorDomain.z ||
|
|
578
|
+
attributes.instanceColorValues > grid.colorDomain.w ||
|
|
579
|
+
attributes.instanceElevationValues < grid.elevationDomain.z ||
|
|
580
|
+
attributes.instanceElevationValues > grid.elevationDomain.w
|
|
581
|
+
) {
|
|
582
|
+
output.position = vec4<f32>(0.0);
|
|
583
|
+
output.color = vec4<f32>(0.0);
|
|
584
|
+
return output;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
let commonPosition =
|
|
588
|
+
(attributes.instancePositions +
|
|
589
|
+
(attributes.positions.xy + vec2<f32>(1.0)) * 0.5 * column.coverage) *
|
|
590
|
+
grid.sizeCommon +
|
|
591
|
+
grid.originCommon -
|
|
592
|
+
project.commonOrigin.xy;
|
|
593
|
+
geometry.position = vec4<f32>(commonPosition, 0.0, 1.0);
|
|
594
|
+
geometry.normal = project_normal(attributes.normals);
|
|
595
|
+
|
|
596
|
+
if (column.extruded > 0.5) {
|
|
597
|
+
var elevation = interpolate(
|
|
598
|
+
attributes.instanceElevationValues,
|
|
599
|
+
grid.elevationDomain.xy,
|
|
600
|
+
grid.elevationRange
|
|
601
|
+
);
|
|
602
|
+
elevation = project_size_float(elevation);
|
|
603
|
+
geometry.position.z = (attributes.positions.z + 1.0) * 0.5 * elevation;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
output.position = project_common_position_to_clipspace(geometry.position);
|
|
607
|
+
var colorValue = sampleColorRange(attributes.instanceColorValues, grid.colorDomain.xy);
|
|
608
|
+
if (column.extruded > 0.5) {
|
|
609
|
+
colorValue = vec4<f32>(
|
|
610
|
+
lighting_getLightColor2(
|
|
611
|
+
colorValue.rgb,
|
|
612
|
+
project.cameraPosition,
|
|
613
|
+
geometry.position.xyz,
|
|
614
|
+
geometry.normal
|
|
615
|
+
),
|
|
616
|
+
colorValue.a
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
output.color = vec4<f32>(colorValue.rgb, colorValue.a * layer.opacity);
|
|
620
|
+
return output;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
@fragment
|
|
624
|
+
fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
|
|
625
|
+
if (picking.isActive > 0.5) {
|
|
626
|
+
if (!picking_isColorValid(varyings.pickingColor)) {
|
|
627
|
+
discard;
|
|
628
|
+
}
|
|
629
|
+
return vec4<f32>(varyings.pickingColor, 1.0);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
var color = varyings.color;
|
|
633
|
+
if (picking.isHighlightActive > 0.5) {
|
|
634
|
+
let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
|
|
635
|
+
if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {
|
|
636
|
+
let highlightAlpha = picking.highlightColor.a;
|
|
637
|
+
let blendedAlpha = highlightAlpha + color.a * (1.0 - highlightAlpha);
|
|
638
|
+
if (blendedAlpha > 0.0) {
|
|
639
|
+
let highlightRatio = highlightAlpha / blendedAlpha;
|
|
640
|
+
color = vec4<f32>(
|
|
641
|
+
mix(color.rgb, picking.highlightColor.rgb, highlightRatio),
|
|
642
|
+
blendedAlpha
|
|
643
|
+
);
|
|
644
|
+
} else {
|
|
645
|
+
color = vec4<f32>(color.rgb, 0.0);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
return deckgl_premultiplied_alpha(color);
|
|
651
|
+
}
|
|
652
|
+
`;var oo=`#version 300 es
|
|
340
653
|
#define SHADER_NAME grid-cell-layer-vertex-shader
|
|
341
654
|
in vec3 positions;
|
|
342
655
|
in vec3 normals;
|
|
@@ -382,18 +695,29 @@ vColor.rgb = lighting_getLightColor(vColor.rgb, project.cameraPosition, geometry
|
|
|
382
695
|
}
|
|
383
696
|
DECKGL_FILTER_COLOR(vColor, geometry);
|
|
384
697
|
}
|
|
385
|
-
`;var
|
|
698
|
+
`;var zi=`struct gridUniforms {
|
|
699
|
+
colorDomain: vec4<f32>,
|
|
700
|
+
elevationDomain: vec4<f32>,
|
|
701
|
+
elevationRange: vec2<f32>,
|
|
702
|
+
originCommon: vec2<f32>,
|
|
703
|
+
sizeCommon: vec2<f32>,
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
@group(0) @binding(auto) var<uniform> grid: gridUniforms;
|
|
707
|
+
@group(0) @binding(auto) var colorRange: texture_2d<f32>;
|
|
708
|
+
@group(0) @binding(auto) var colorRangeSampler: sampler;
|
|
709
|
+
`,Wi=`layout(std140) uniform gridUniforms {
|
|
386
710
|
vec4 colorDomain;
|
|
387
711
|
vec4 elevationDomain;
|
|
388
712
|
vec2 elevationRange;
|
|
389
713
|
vec2 originCommon;
|
|
390
714
|
vec2 sizeCommon;
|
|
391
715
|
} grid;
|
|
392
|
-
`,
|
|
716
|
+
`,io={name:"grid",source:zi,vs:Wi,uniformTypes:{colorDomain:"vec4<f32>",elevationDomain:"vec4<f32>",elevationRange:"vec2<f32>",originCommon:"vec2<f32>",sizeCommon:"vec2<f32>"}};var Ct=class extends ro.ColumnLayer{getShaders(){let t=super.getShaders();return t.modules.push(io),{...t,source:no,vs:oo}}initializeState(){super.initializeState();let t=this.getAttributeManager();t.remove(["instanceElevations","instanceFillColors","instanceLineColors","instanceStrokeWidths"]),t.addInstanced({instancePositions:{size:2,type:"float32",accessor:"getBin"},instanceColorValues:{size:1,type:"float32",accessor:"getColorValue"},instanceElevationValues:{size:1,type:"float32",accessor:"getElevationValue"}})}updateState(t){super.updateState(t);let{props:e,oldProps:o}=t,i=this.state.fillModel;if(o.colorRange!==e.colorRange){this.state.colorTexture?.destroy(),this.state.colorTexture=Q(this.context.device,e.colorRange,e.colorScaleType);let r={colorRange:this.state.colorTexture};i.shaderInputs.setProps({grid:r})}else o.colorScaleType!==e.colorScaleType&&K(this.state.colorTexture,e.colorScaleType)}finalizeState(t){super.finalizeState(t),this.state.colorTexture?.destroy()}_updateGeometry(){let t=new so.CubeGeometry;this._setFillGeometry(t)}draw({uniforms:t}){let{cellOriginCommon:e,cellSizeCommon:o,elevationRange:i,elevationScale:r,extruded:s,coverage:a,colorDomain:c,elevationDomain:g}=this.props,h=this.props.colorCutoff||[-1/0,1/0],u=this.props.elevationCutoff||[-1/0,1/0],p=this.state.fillModel,f={colorDomain:[Math.max(c[0],h[0]),Math.min(c[1],h[1]),Math.max(c[0]-1,h[0]),Math.min(c[1]+1,h[1])],elevationDomain:[Math.max(g[0],u[0]),Math.min(g[1],u[1]),Math.max(g[0]-1,u[0]),Math.min(g[1]+1,u[1])],elevationRange:[i[0]*r,i[1]*r],originCommon:e,sizeCommon:o};p.shaderInputs.setProps({column:{extruded:s,coverage:a},grid:f}),p.draw(this.context.renderPass)}};Ct.layerName="GridCellLayer";var Vi=`layout(std140) uniform binOptionsUniforms {
|
|
393
717
|
vec2 cellOriginCommon;
|
|
394
718
|
vec2 cellSizeCommon;
|
|
395
719
|
} binOptions;
|
|
396
|
-
`,
|
|
720
|
+
`,ao={name:"binOptions",vs:Vi,uniformTypes:{cellOriginCommon:"vec2<f32>",cellSizeCommon:"vec2<f32>"}};function co(){}var Fi={gpuAggregation:!0,colorDomain:null,colorRange:j,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:co,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationScale:{type:"number",min:0,value:1},elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScaleType:"linear",onSetElevationDomain:co,cellSize:{type:"number",min:0,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:n=>n.position},gridAggregator:{type:"function",optional:!0,value:null},extruded:!1,material:!0},St=class extends B{getAggregatorType(){let{gpuAggregation:t,gridAggregator:e,getColorValue:o,getElevationValue:i}=this.props;return t&&(e||o||i)?(Y.log.warn("Features not supported by GPU aggregation, falling back to CPU")(),"cpu"):t&&L.isSupported(this.context.device)?"gpu":"cpu"}createAggregator(t){if(t==="cpu"){let{gridAggregator:e,cellSize:o}=this.props;return new N({dimensions:2,getBin:{sources:["positions"],getValue:({positions:i},r,s)=>{if(e)return e(i,o);let c=this.state.aggregatorViewport.projectPosition(i),{cellSizeCommon:g,cellOriginCommon:h}=s;return[Math.floor((c[0]-h[0])/g[0]),Math.floor((c[1]-h[1])/g[1])]}},getValue:[{sources:["colorWeights"],getValue:({colorWeights:i})=>i},{sources:["elevationWeights"],getValue:({elevationWeights:i})=>i}]})}return new L(this.context.device,{dimensions:2,channelCount:2,bufferLayout:this.getAttributeManager().getBufferLayouts({isInstanced:!1}),...super.getShaders({modules:[Y.project32,ao],vs:`
|
|
397
721
|
in vec3 positions;
|
|
398
722
|
in vec3 positions64Low;
|
|
399
723
|
in float colorWeights;
|
|
@@ -407,7 +731,66 @@ DECKGL_FILTER_COLOR(vColor, geometry);
|
|
|
407
731
|
void getValue(out vec2 value) {
|
|
408
732
|
value = vec2(colorWeights, elevationWeights);
|
|
409
733
|
}
|
|
410
|
-
`})})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},colorWeights:{size:1,accessor:"getColorWeight"},elevationWeights:{size:1,accessor:"getElevationWeight"}})}updateState(t){let e=super.updateState(t),{props:o,oldProps:
|
|
734
|
+
`})})}initializeState(){super.initializeState(),this.getAttributeManager().add({positions:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},colorWeights:{size:1,accessor:"getColorWeight"},elevationWeights:{size:1,accessor:"getElevationWeight"}})}updateState(t){let e=super.updateState(t),{props:o,oldProps:i,changeFlags:r}=t,{aggregator:s}=this.state;if((r.dataChanged||!this.state.dataAsArray)&&(o.getColorValue||o.getElevationValue)&&(this.state.dataAsArray=Array.from((0,Y.createIterable)(o.data).iterable)),e||r.dataChanged||o.cellSize!==i.cellSize||o.getColorValue!==i.getColorValue||o.getElevationValue!==i.getElevationValue||o.colorAggregation!==i.colorAggregation||o.elevationAggregation!==i.elevationAggregation){this._updateBinOptions();let{cellSizeCommon:a,cellOriginCommon:c,binIdRange:g,dataAsArray:h}=this.state;if(s.setProps({binIdRange:g,pointCount:this.getNumInstances(),operations:[o.colorAggregation,o.elevationAggregation],binOptions:{cellSizeCommon:a,cellOriginCommon:c},onUpdate:this._onAggregationUpdate.bind(this)}),h){let{getColorValue:u,getElevationValue:p}=this.props;s.setProps({customOperations:[u&&(f=>u(f.map(x=>h[x]),{indices:f,data:o.data})),p&&(f=>p(f.map(x=>h[x]),{indices:f,data:o.data}))]})}}return r.updateTriggersChanged&&r.updateTriggersChanged.getColorValue&&s.setNeedsUpdate(0),r.updateTriggersChanged&&r.updateTriggersChanged.getElevationValue&&s.setNeedsUpdate(1),e}_updateBinOptions(){let t=this.getBounds(),e=[1,1],o=[0,0],i=[[0,1],[0,1]],r=this.context.viewport;if(t&&Number.isFinite(t[0][0])){let s=[(t[0][0]+t[1][0])/2,(t[0][1]+t[1][1])/2],{cellSize:a}=this.props,{unitsPerMeter:c}=r.getDistanceScales(s);e[0]=c[0]*a,e[1]=c[1]*a;let g=r.projectFlat(s);o=[Math.floor(g[0]/e[0])*e[0],Math.floor(g[1]/e[1])*e[1]],s=r.unprojectFlat(o);let h=r.constructor;r=r.isGeospatial?new h({longitude:s[0],latitude:s[1],zoom:12}):new Y.Viewport({position:[s[0],s[1],0],zoom:12}),o=[Math.fround(r.center[0]),Math.fround(r.center[1])],i=tt({dataBounds:t,getBinId:u=>{let p=r.projectFlat(u);return[Math.floor((p[0]-o[0])/e[0]),Math.floor((p[1]-o[1])/e[1])]}})}this.setState({cellSizeCommon:e,cellOriginCommon:o,binIdRange:i,aggregatorViewport:r})}draw(t){t.shaderModuleProps.project&&(t.shaderModuleProps.project.viewport=this.state.aggregatorViewport),super.draw(t)}_onAggregationUpdate({channel:t}){let e=this.getCurrentLayer().props,{aggregator:o}=this.state;if(t===0){let i=o.getResult(0);this.setState({colors:new G(i,o.binCount)}),e.onSetColorDomain(o.getResultDomain(0))}else if(t===1){let i=o.getResult(1);this.setState({elevations:new G(i,o.binCount)}),e.onSetElevationDomain(o.getResultDomain(1))}}onAttributeChange(t){let{aggregator:e}=this.state;switch(t){case"positions":e.setNeedsUpdate(),this._updateBinOptions();let{cellSizeCommon:o,cellOriginCommon:i,binIdRange:r}=this.state;e.setProps({binIdRange:r,binOptions:{cellSizeCommon:o,cellOriginCommon:i}});break;case"colorWeights":e.setNeedsUpdate(0);break;case"elevationWeights":e.setNeedsUpdate(1);break;default:}}renderLayers(){let{aggregator:t,cellOriginCommon:e,cellSizeCommon:o}=this.state,{elevationScale:i,colorRange:r,elevationRange:s,extruded:a,coverage:c,material:g,transitions:h,colorScaleType:u,lowerPercentile:p,upperPercentile:f,colorDomain:x,elevationScaleType:y,elevationLowerPercentile:M,elevationUpperPercentile:A,elevationDomain:E}=this.props,v=this.getSubLayerClass("cells",Ct),S=t.getBins(),b=this.state.colors?.update({scaleType:u,lowerPercentile:p,upperPercentile:f}),C=this.state.elevations?.update({scaleType:y,lowerPercentile:M,upperPercentile:A});return!b||!C?null:new v(this.getSubLayerProps({id:"cells"}),{data:{length:t.binCount,attributes:{getBin:S,getColorValue:b.attribute,getElevationValue:C.attribute}},dataComparator:(P,_)=>P.length===_.length,updateTriggers:{getBin:[S],getColorValue:[b.attribute],getElevationValue:[C.attribute]},cellOriginCommon:e,cellSizeCommon:o,elevationScale:i,colorRange:r,colorScaleType:u,elevationRange:s,extruded:a,coverage:c,material:g,colorDomain:b.domain||x||t.getResultDomain(0),elevationDomain:C.domain||E||t.getResultDomain(1),colorCutoff:b.cutoff,elevationCutoff:C.cutoff,transitions:h&&{getFillColor:h.getColorValue||h.getColorWeight,getElevation:h.getElevationValue||h.getElevationWeight},extensions:[]})}getPickingInfo(t){let e=t.info,{index:o}=e;if(o>=0){let i=this.state.aggregator.getBin(o),r;i&&(r={col:i.id[0],row:i.id[1],colorValue:i.value[0],elevationValue:i.value[1],count:i.count},i.pointIndices&&(r.pointIndices=i.pointIndices,r.points=Array.isArray(this.props.data)?i.pointIndices.map(s=>this.props.data[s]):[])),e.object=r}return e}};St.layerName="GridLayer";St.defaultProps=Fi;var lo=St;function ho(n){let t=n.map(a=>a[0]),e=n.map(a=>a[1]),o=Math.min.apply(null,t),i=Math.max.apply(null,t),r=Math.min.apply(null,e),s=Math.max.apply(null,e);return[o,r,i,s]}function po(n,t){return t[0]>=n[0]&&t[2]<=n[2]&&t[1]>=n[1]&&t[3]<=n[3]}var go=new Float32Array(12);function pe(n,t=2){let e=0;for(let o of n)for(let i=0;i<t;i++)go[e++]=o[i]||0;return go}function uo(n,t,e){let[o,i,r,s]=n,a=r-o,c=s-i,g=a,h=c;a/c<t/e?g=t/e*c:h=e/t*a,g<t&&(g=t,h=e);let u=(r+o)/2,p=(s+i)/2;return[u-g/2,p-h/2,u+g/2,p+h/2]}function fo(n,t){let[e,o,i,r]=t;return[(n[0]-e)/(i-e),(n[1]-o)/(r-o)]}var fe=w($(),1),ft=w(z(),1);var bo=w($(),1),pt=w(z(),1);var mo=`struct TriangleAttributes {
|
|
735
|
+
@location(0) positions: vec3<f32>,
|
|
736
|
+
@location(1) texCoords: vec2<f32>,
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
struct TriangleVaryings {
|
|
740
|
+
@builtin(position) position: vec4<f32>,
|
|
741
|
+
@location(0) textureCoordinates: vec2<f32>,
|
|
742
|
+
@location(1) intensityMinimum: f32,
|
|
743
|
+
@location(2) intensityMaximum: f32,
|
|
744
|
+
};
|
|
745
|
+
|
|
746
|
+
@vertex
|
|
747
|
+
fn vertexMain(attributes: TriangleAttributes) -> TriangleVaryings {
|
|
748
|
+
var output: TriangleVaryings;
|
|
749
|
+
output.position = project_position_to_clipspace(
|
|
750
|
+
attributes.positions,
|
|
751
|
+
vec3<f32>(0.0),
|
|
752
|
+
vec3<f32>(0.0)
|
|
753
|
+
);
|
|
754
|
+
// WebGPU render-target textures use a top-left origin.
|
|
755
|
+
output.textureCoordinates = vec2<f32>(attributes.texCoords.x, 1.0 - attributes.texCoords.y);
|
|
756
|
+
|
|
757
|
+
let maxWeights = textureLoad(maxTexture, vec2<i32>(0), 0);
|
|
758
|
+
var maximumValue = select(maxWeights.r, maxWeights.g, triangle.aggregationMode > 0.5);
|
|
759
|
+
var minimumValue = maximumValue * triangle.threshold;
|
|
760
|
+
|
|
761
|
+
if (triangle.colorDomain.y > 0.0) {
|
|
762
|
+
maximumValue = triangle.colorDomain.y;
|
|
763
|
+
minimumValue = triangle.colorDomain.x;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
output.intensityMaximum = triangle.intensity / maximumValue;
|
|
767
|
+
output.intensityMinimum = triangle.intensity / minimumValue;
|
|
768
|
+
return output;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
@fragment
|
|
772
|
+
fn fragmentMain(varyings: TriangleVaryings) -> @location(0) vec4<f32> {
|
|
773
|
+
let weights = textureSample(weightsTexture, weightsTextureSampler, varyings.textureCoordinates);
|
|
774
|
+
var weight = weights.r;
|
|
775
|
+
|
|
776
|
+
if (triangle.aggregationMode > 0.5) {
|
|
777
|
+
weight /= max(1.0, weights.a);
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
let colorCoordinates = vec2<f32>(
|
|
781
|
+
clamp(weight * varyings.intensityMaximum, 0.0, 1.0),
|
|
782
|
+
0.5
|
|
783
|
+
);
|
|
784
|
+
var color = textureSample(colorTexture, colorTextureSampler, colorCoordinates);
|
|
785
|
+
|
|
786
|
+
if (weight <= 0.0) {
|
|
787
|
+
discard;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
color.a *= min(weight * varyings.intensityMinimum, 1.0) * layer.opacity;
|
|
791
|
+
return deckgl_premultiplied_alpha(color);
|
|
792
|
+
}
|
|
793
|
+
`;var xo=`#version 300 es
|
|
411
794
|
#define SHADER_NAME heatp-map-layer-vertex-shader
|
|
412
795
|
uniform sampler2D maxTexture;
|
|
413
796
|
in vec3 positions;
|
|
@@ -428,7 +811,7 @@ minValue = triangle.colorDomain[0];
|
|
|
428
811
|
vIntensityMax = triangle.intensity / maxValue;
|
|
429
812
|
vIntensityMin = triangle.intensity / minValue;
|
|
430
813
|
}
|
|
431
|
-
`;var
|
|
814
|
+
`;var vo=`#version 300 es
|
|
432
815
|
#define SHADER_NAME triangle-layer-fragment-shader
|
|
433
816
|
precision highp float;
|
|
434
817
|
uniform sampler2D weightsTexture;
|
|
@@ -456,13 +839,26 @@ vec4 linearColor = getLinearColor(weight);
|
|
|
456
839
|
linearColor.a *= layer.opacity;
|
|
457
840
|
fragColor = linearColor;
|
|
458
841
|
}
|
|
459
|
-
`;var
|
|
842
|
+
`;var Di=`struct triangleUniforms {
|
|
843
|
+
aggregationMode: f32,
|
|
844
|
+
colorDomain: vec2<f32>,
|
|
845
|
+
intensity: f32,
|
|
846
|
+
threshold: f32,
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
@group(0) @binding(auto) var<uniform> triangle: triangleUniforms;
|
|
850
|
+
@group(0) @binding(auto) var colorTexture: texture_2d<f32>;
|
|
851
|
+
@group(0) @binding(auto) var colorTextureSampler: sampler;
|
|
852
|
+
@group(0) @binding(auto) var maxTexture: texture_2d<f32>;
|
|
853
|
+
@group(0) @binding(auto) var weightsTexture: texture_2d<f32>;
|
|
854
|
+
@group(0) @binding(auto) var weightsTextureSampler: sampler;
|
|
855
|
+
`,yo=`layout(std140) uniform triangleUniforms {
|
|
460
856
|
float aggregationMode;
|
|
461
857
|
vec2 colorDomain;
|
|
462
858
|
float intensity;
|
|
463
859
|
float threshold;
|
|
464
860
|
} triangle;
|
|
465
|
-
`,
|
|
861
|
+
`,Mo={name:"triangle",source:Di,vs:yo,fs:yo,uniformTypes:{aggregationMode:"f32",colorDomain:"vec2<f32>",intensity:"f32",threshold:"f32"}};var Kt=class extends pt.Layer{getShaders(){return super.getShaders({source:mo,vs:xo,fs:vo,modules:[pt.project32,pt.color,Mo]})}initializeState({device:t}){this.setState({model:this._getModel(t)})}_getModel(t){let{vertexCount:e,data:o}=this.props;return new bo.Model(t,{...this.getShaders(),id:this.props.id,attributes:o.attributes,bufferLayout:[{name:"positions",format:"float32x3"},{name:"texCoords",format:"float32x2"}],topology:"triangle-strip",vertexCount:e})}draw(){let{model:t}=this.state,{aggregationMode:e,colorDomain:o,intensity:i,threshold:r,colorTexture:s,maxTexture:a,weightsTexture:c}=this.props,g={aggregationMode:e,colorDomain:o,intensity:i,threshold:r,colorTexture:s,maxTexture:a,weightsTexture:c};t.shaderInputs.setProps({triangle:g}),t.draw(this.context.renderPass)}};Kt.layerName="TriangleLayer";var Co=Kt;var ut=w(z(),1);function So(n,t){let e={};for(let o in n)t.includes(o)||(e[o]=n[o]);return e}var Qt=class extends ut.CompositeLayer{initializeAggregationLayer(t){super.initializeState(this.context),this.setState({ignoreProps:So(this.constructor._propTypes,t.data.props),dimensions:t})}updateState(t){super.updateState(t);let{changeFlags:e}=t;if(e.extensionsChanged){let o=this.getShaders({});o&&o.defines&&(o.defines.NON_INSTANCED_MODEL=1),this.updateShaders(o)}this._updateAttributes()}updateAttributes(t){this.setState({changedAttributes:t})}getAttributes(){return this.getAttributeManager().getAttributes()}getModuleSettings(){let{viewport:t,mousePosition:e,device:o}=this.context;return Object.assign(Object.create(this.props),{viewport:t,mousePosition:e,picking:{isActive:0},devicePixelRatio:o.canvasContext.cssToDeviceRatio()})}updateShaders(t){}isAggregationDirty(t,e={}){let{props:o,oldProps:i,changeFlags:r}=t,{compareAll:s=!1,dimension:a}=e,{ignoreProps:c}=this.state,{props:g,accessors:h=[]}=a,{updateTriggersChanged:u}=r;if(r.dataChanged)return!0;if(u){if(u.all)return!0;for(let p of h)if(u[p])return!0}if(s)return r.extensionsChanged?!0:(0,ut._compareProps)({oldProps:i,newProps:o,ignoreProps:c,propTypes:this.constructor._propTypes});for(let p of g)if(o[p]!==i[p])return!0;return!1}isAttributeChanged(t){let{changedAttributes:e}=this.state;return t?e&&e[t]!==void 0:!Bi(e)}_getAttributeManager(){return new ut.AttributeManager(this.context.device,{id:this.props.id,stats:this.context.stats})}};Qt.layerName="AggregationLayer";var Ao=Qt;function Bi(n){let t=!0;for(let e in n){t=!1;break}return t}var Jt=`#version 300 es
|
|
466
862
|
in vec3 positions;
|
|
467
863
|
in vec3 positions64Low;
|
|
468
864
|
in float weights;
|
|
@@ -492,7 +888,7 @@ discard;
|
|
|
492
888
|
fragColor = weightsTexture * gaussianKDE(2. * dist);
|
|
493
889
|
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
494
890
|
}
|
|
495
|
-
`;var
|
|
891
|
+
`;var Eo=`#version 300 es
|
|
496
892
|
uniform sampler2D inTexture;
|
|
497
893
|
out vec4 outTexture;
|
|
498
894
|
void main()
|
|
@@ -504,22 +900,136 @@ outTexture = texture(inTexture, uv);
|
|
|
504
900
|
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
|
|
505
901
|
gl_PointSize = 1.0;
|
|
506
902
|
}
|
|
507
|
-
`;var
|
|
903
|
+
`;var To=`#version 300 es
|
|
508
904
|
in vec4 outTexture;
|
|
509
905
|
out vec4 fragColor;
|
|
510
906
|
void main() {
|
|
511
907
|
fragColor = outTexture;
|
|
512
908
|
fragColor.g = outTexture.r / max(1.0, outTexture.a);
|
|
513
909
|
}
|
|
514
|
-
`;var
|
|
910
|
+
`;var wo=`struct MaxWeightVaryings {
|
|
911
|
+
@builtin(position) position: vec4<f32>,
|
|
912
|
+
@location(0) weights: vec4<f32>,
|
|
913
|
+
};
|
|
914
|
+
|
|
915
|
+
const MAX_WEIGHT_REDUCTION_SIZE: u32 = 16u;
|
|
916
|
+
|
|
917
|
+
@vertex
|
|
918
|
+
fn vertexMain(@builtin(vertex_index) vertexIndex: u32) -> MaxWeightVaryings {
|
|
919
|
+
var output: MaxWeightVaryings;
|
|
920
|
+
let textureSize = u32(maxWeight.textureSize);
|
|
921
|
+
let reducedTextureSize =
|
|
922
|
+
(textureSize + MAX_WEIGHT_REDUCTION_SIZE - 1u) / MAX_WEIGHT_REDUCTION_SIZE;
|
|
923
|
+
let blockCoordinates = vec2<u32>(
|
|
924
|
+
vertexIndex % reducedTextureSize,
|
|
925
|
+
vertexIndex / reducedTextureSize
|
|
926
|
+
);
|
|
927
|
+
var maximumWeights = vec4<f32>(0.0);
|
|
928
|
+
|
|
929
|
+
for (var y = 0u; y < MAX_WEIGHT_REDUCTION_SIZE; y++) {
|
|
930
|
+
for (var x = 0u; x < MAX_WEIGHT_REDUCTION_SIZE; x++) {
|
|
931
|
+
let textureCoordinates = blockCoordinates * MAX_WEIGHT_REDUCTION_SIZE + vec2<u32>(x, y);
|
|
932
|
+
|
|
933
|
+
if (textureCoordinates.x < textureSize && textureCoordinates.y < textureSize) {
|
|
934
|
+
let weights = textureLoad(inTexture, vec2<i32>(textureCoordinates), 0);
|
|
935
|
+
maximumWeights.r = max(maximumWeights.r, weights.r);
|
|
936
|
+
maximumWeights.g = max(maximumWeights.g, weights.r / max(1.0, weights.a));
|
|
937
|
+
maximumWeights.b = max(maximumWeights.b, weights.b);
|
|
938
|
+
maximumWeights.a = max(maximumWeights.a, weights.a);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
|
944
|
+
output.weights = maximumWeights;
|
|
945
|
+
return output;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
@fragment
|
|
949
|
+
fn fragmentMain(varyings: MaxWeightVaryings) -> @location(0) vec4<f32> {
|
|
950
|
+
return varyings.weights;
|
|
951
|
+
}
|
|
952
|
+
`;var Lo=`struct WeightAttributes {
|
|
953
|
+
@builtin(vertex_index) vertexIndex: u32,
|
|
954
|
+
@location(0) instancePositions: vec3<f32>,
|
|
955
|
+
@location(1) instancePositions64Low: vec3<f32>,
|
|
956
|
+
@location(2) instanceWeights: f32,
|
|
957
|
+
};
|
|
958
|
+
|
|
959
|
+
struct WeightVaryings {
|
|
960
|
+
@builtin(position) position: vec4<f32>,
|
|
961
|
+
@location(0) pointCoordinates: vec2<f32>,
|
|
962
|
+
@location(1) weights: vec4<f32>,
|
|
963
|
+
};
|
|
964
|
+
|
|
965
|
+
const WEIGHT_QUAD_POSITIONS = array<vec2<f32>, 6>(
|
|
966
|
+
vec2<f32>(-1.0, -1.0),
|
|
967
|
+
vec2<f32>(1.0, -1.0),
|
|
968
|
+
vec2<f32>(-1.0, 1.0),
|
|
969
|
+
vec2<f32>(-1.0, 1.0),
|
|
970
|
+
vec2<f32>(1.0, -1.0),
|
|
971
|
+
vec2<f32>(1.0, 1.0)
|
|
972
|
+
);
|
|
973
|
+
|
|
974
|
+
@vertex
|
|
975
|
+
fn vertexMain(attributes: WeightAttributes) -> WeightVaryings {
|
|
976
|
+
var output: WeightVaryings;
|
|
977
|
+
let commonPosition = project_position_vec3_f64(
|
|
978
|
+
attributes.instancePositions,
|
|
979
|
+
attributes.instancePositions64Low
|
|
980
|
+
);
|
|
981
|
+
let clipPosition =
|
|
982
|
+
(commonPosition.xy - weight.commonBounds.xy) /
|
|
983
|
+
(weight.commonBounds.zw - weight.commonBounds.xy) * 2.0 - vec2<f32>(1.0);
|
|
984
|
+
let radiusTexels =
|
|
985
|
+
project_pixel_size_float(weight.radiusPixels) * weight.textureWidth /
|
|
986
|
+
(weight.commonBounds.z - weight.commonBounds.x);
|
|
987
|
+
let offset = WEIGHT_QUAD_POSITIONS[attributes.vertexIndex];
|
|
988
|
+
|
|
989
|
+
output.position = vec4<f32>(
|
|
990
|
+
clipPosition + offset * radiusTexels * 2.0 / weight.textureWidth,
|
|
991
|
+
0.0,
|
|
992
|
+
1.0
|
|
993
|
+
);
|
|
994
|
+
output.pointCoordinates = (offset + vec2<f32>(1.0)) * 0.5;
|
|
995
|
+
output.weights = vec4<f32>(attributes.instanceWeights * weight.weightsScale, 0.0, 0.0, 1.0);
|
|
996
|
+
return output;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
@fragment
|
|
1000
|
+
fn fragmentMain(varyings: WeightVaryings) -> @location(0) vec4<f32> {
|
|
1001
|
+
let distanceFromCenter = length(varyings.pointCoordinates - vec2<f32>(0.5));
|
|
1002
|
+
if (distanceFromCenter > 0.5) {
|
|
1003
|
+
discard;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
let gaussian = exp(-pow(2.0 * distanceFromCenter, 2.0) / 0.05555) /
|
|
1007
|
+
(1.77245385 * 0.166666);
|
|
1008
|
+
return varyings.weights * gaussian;
|
|
1009
|
+
}
|
|
1010
|
+
`;var Ui=`struct weightUniforms {
|
|
1011
|
+
commonBounds: vec4<f32>,
|
|
1012
|
+
radiusPixels: f32,
|
|
1013
|
+
textureWidth: f32,
|
|
1014
|
+
weightsScale: f32,
|
|
1015
|
+
};
|
|
1016
|
+
|
|
1017
|
+
@group(0) @binding(auto) var<uniform> weight: weightUniforms;
|
|
1018
|
+
`,Hi=`layout(std140) uniform weightUniforms {
|
|
515
1019
|
vec4 commonBounds;
|
|
516
1020
|
float radiusPixels;
|
|
517
1021
|
float textureWidth;
|
|
518
1022
|
float weightsScale;
|
|
519
1023
|
} weight;
|
|
520
|
-
`,
|
|
1024
|
+
`,Po={name:"weight",source:Ui,vs:Hi,uniformTypes:{commonBounds:"vec4<f32>",radiusPixels:"f32",textureWidth:"f32",weightsScale:"f32"}},_o={name:"maxWeight",source:`struct maxWeightUniforms {
|
|
1025
|
+
textureSize: f32,
|
|
1026
|
+
};
|
|
1027
|
+
|
|
1028
|
+
@group(0) @binding(auto) var<uniform> maxWeight: maxWeightUniforms;
|
|
1029
|
+
@group(0) @binding(auto) var inTexture: texture_2d<f32>;
|
|
1030
|
+
`,vs:`layout(std140) uniform maxWeightUniforms {
|
|
521
1031
|
float textureSize;
|
|
522
1032
|
} maxWeight;
|
|
523
|
-
`,uniformTypes:{textureSize:"f32"}};var
|
|
1033
|
+
`,uniformTypes:{textureSize:"f32"}};var ki=2,ji=16,ue={format:"rgba8unorm",dimension:"2d",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}},No=[0,0],Gi={SUM:0,MEAN:1},qi={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:j,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}},Yi=["float32-renderable-webgl","texture-blend-float-webgl"],$i={data:{props:["radiusPixels"]}},At=class extends Ao{getShaders(t){let e=[ft.project32];return t.modules&&(e=[...e,...t.modules]),super.getShaders({...t,modules:e})}initializeState(){super.initializeAggregationLayer($i),this.setState({colorDomain:No}),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);if((i.dataChanged||i.viewportChanged)&&(i.boundsChanged=this._updateBounds(i.dataChanged),this._updateTextureRenderingBounds()),i.dataChanged||i.boundsChanged){if(clearTimeout(this.state.updateTimer),this.setState({isWeightMapDirty:!0}),i.dataChanged){let r=this.getShaders({vs:Jt,fs:te});this._createWeightsTransform(r)}}else 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:c,threshold:g,aggregation:h}=this.props,u=this.getSubLayerClass("triangle",Co);return new u(this.getSubLayerProps({id:"triangle-layer",updateTriggers:a}),{coordinateSystem:"default",data:{attributes:{positions:e,texCoords:o}},vertexCount:4,maxTexture:i,colorTexture:r,aggregationMode:Gi[h]||0,weightsTexture:t,intensity:c,threshold:g,colorDomain:s})}finalizeState(t){super.finalizeState(t);let{weightsTransform:e,weightsTexture:o,maxWeightTransform:i,maxWeightsTexture:r,triPositionBuffer:s,triTexCoordBuffer:a,colorTexture:c,updateTimer:g}=this.state;e?.destroy(),o?.destroy(),i?.destroy(),r?.destroy(),s?.destroy(),a?.destroy(),c?.destroy(),g&&clearTimeout(g)}_getAttributeManager(){return new ft.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({...ue,width:t,height:t,format:e}),maxWeightsTexture:this.context.device.createTexture({...ue,width:1,height:1,format:e})})}_setupAttributes(){let t=this.getAttributeManager();this.context.device.type==="webgpu"?(t.addInstanced({instancePositions:{size:3,type:"float64",accessor:"getPosition",transform:e=>[e[0],e[1],e[2]??0]},instanceWeights:{size:1,accessor:"getWeight"}}),this.setState({positionAttributeName:"instancePositions"})):(t.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=t.type==="webgpu",r=i?t.getTextureFormatCapabilities("rgba16float").blend:Yi.every(c=>t.features.has(c)),s=r?i?"rgba16float":"rgba32float":"rgba8unorm",a=r?1:1/255;this.setState({textureSize:o,format:s,weightsScale:a}),r||ft.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.context.device.type==="webgpu",r=this.getAttributeManager();e?.destroy(),e=new fe.TextureTransform(this.context.device,{id:`${this.id}-weights-transform`,...t,source:Lo,bufferLayout:r.getBufferLayouts({isInstanced:i}),vertexCount:i?6:1,...i?{colorAttachmentFormats:[o.format],isInstanced:!0,instanceCount:this.getNumInstances()}:{},targetTexture:o,parameters:{depthWriteEnabled:!1,blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},topology:i?"triangle-list":"point-list",modules:[...t.modules,Po]}),this.setState({weightsTransform:e})}_setupResources(){this._createTextures();let{device:t}=this.context,{textureSize:e,weightsTexture:o,maxWeightsTexture:i}=this.state,r=this.getShaders({vs:Jt,fs:te});this._createWeightsTransform(r);let s=this.getShaders({source:wo,vs:Eo,fs:To,modules:[_o]}),a=new fe.TextureTransform(t,{id:`${this.id}-max-weights-transform`,targetTexture:i,...s,...t.type==="webgpu"?{colorAttachmentFormats:[i.format]}:{},vertexCount:t.type==="webgpu"?Math.ceil(e/ji)**2:e*e,topology:"point-list",parameters:{depthWriteEnabled:!1,blend:!0,blendColorOperation:"max",blendAlphaOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}}),c={inTexture:o,textureSize:e};a.model.shaderInputs.setProps({maxWeight:c}),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:Jt,fs:te,...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([0,e.height]),e.unproject([e.width,e.height])].map(a=>a.map(Math.fround)),i=ho(o),r={visibleWorldBounds:i,viewportCorners:o},s=!1;if(t||!this.state.worldBounds||!po(this.state.worldBounds,i)){let a=this._worldToCommonBounds(i),c=this._commonToWorldBounds(a);this.props.coordinateSystem==="lnglat"&&(c[1]=Math.max(c[1],-85.051129),c[3]=Math.min(c[3],85.051129),c[0]=Math.max(c[0],-360),c[2]=Math.min(c[2],360));let g=this._worldToCommonBounds(c);r.worldBounds=c,r.normalizedCommonBounds=g,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(pe(i,3));let s=i.map(a=>fo(r.projectPosition(a),o));e.write(pe(s,2))}_updateColorTexture(t){let{colorRange:e}=t.props,{colorTexture:o}=this.state,i=ie(e,!1,Uint8Array);o?.destroy(),o=this.context.device.createTexture({...ue,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,weightsTexture:a}=this.state,c=this.state.weightsTransform;this.state.isWeightMapDirty=!1;let g=this._worldToCommonBounds(i,{useLayerCoordinateSystem:!0});if(e&&o==="SUM"){let{viewport:v}=this.context,S=v.distanceScales.metersPerUnit[2]*(g[2]-g[0])/r;this.state.colorDomain=[e[0]*S*s,e[1]*S*s]}else this.state.colorDomain=e||No;let u=this.getAttributeManager().getAttributes(),p=this.getModuleSettings();if(this._setModelAttributes(c.model,u),this.context.device.type==="webgpu"){let v=this.getNumInstances();c.model.setVertexCount(v>0?6:0),c.model.setInstanceCount(v)}else c.model.setVertexCount(this.getNumInstances());let f={radiusPixels:t,commonBounds:g,textureWidth:r,weightsScale:s,weightsTexture:a},{viewport:x,devicePixelRatio:y,coordinateSystem:M,coordinateOrigin:A}=p,{modelMatrix:E}=this.props;c.model.shaderInputs.setProps({project:{viewport:x,devicePixelRatio:y,modelMatrix:E,coordinateSystem:M,coordinateOrigin:A},weight:f}),c.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:c}=this.context,{textureSize:g}=this.state,{coordinateSystem:h}=this.props,u=o&&(h==="lnglat-offsets"||h==="meter-offsets"),p=u?c.projectPosition(this.props.coordinateOrigin):[0,0],f=g*ki/c.scale,x,y;return o&&!u?(x=this.projectPosition([i,r,0]),y=this.projectPosition([s,a,0])):(x=c.projectPosition([i,r,0]),y=c.projectPosition([s,a,0])),uo([x[0]-p[0],x[1]-p[1],y[0]-p[0],y[1]-p[1]],f,f)}_commonToWorldBounds(t){let[e,o,i,r]=t,{viewport:s}=this.context,a=s.unprojectPosition([e,o]),c=s.unprojectPosition([i,r]);return a.slice(0,2).concat(c.slice(0,2))}};At.layerName="HeatmapLayer";At.defaultProps=qi;var Oo=At;return Do(Et);})();
|
|
524
1034
|
return __exports__;
|
|
525
1035
|
});
|