@deck.gl/aggregation-layers 9.2.8 → 9.2.9
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/contour-layer/contour-layer.d.ts +1 -1
- package/dist/contour-layer/contour-layer.d.ts.map +1 -1
- package/dist/dist.dev.js +4 -1
- package/dist/grid-layer/grid-cell-layer.d.ts +7 -7
- package/dist/grid-layer/grid-cell-layer.d.ts.map +1 -1
- package/dist/grid-layer/grid-layer-uniforms.d.ts +5 -5
- package/dist/grid-layer/grid-layer-uniforms.d.ts.map +1 -1
- package/dist/grid-layer/grid-layer.d.ts +3 -3
- package/dist/grid-layer/grid-layer.d.ts.map +1 -1
- package/dist/heatmap-layer/heatmap-layer.d.ts +2 -2
- package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -1
- package/dist/heatmap-layer/heatmap-layer.js +4 -1
- package/dist/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/heatmap-layer/triangle-layer-uniforms.d.ts +1 -1
- package/dist/heatmap-layer/triangle-layer-uniforms.d.ts.map +1 -1
- package/dist/heatmap-layer/triangle-layer.d.ts +1 -1
- package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -1
- package/dist/hexagon-layer/hexagon-cell-layer.d.ts +6 -6
- package/dist/hexagon-layer/hexagon-cell-layer.d.ts.map +1 -1
- package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts +4 -4
- package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts.map +1 -1
- package/dist/hexagon-layer/hexagon-layer.d.ts +3 -3
- package/dist/hexagon-layer/hexagon-layer.d.ts.map +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +2 -2
- package/dist/screen-grid-layer/screen-grid-layer.d.ts +1 -1
- package/dist/screen-grid-layer/screen-grid-layer.d.ts.map +1 -1
- package/dist.min.js +3 -3
- package/package.json +2 -2
- package/src/contour-layer/contour-layer.ts +1 -1
- package/src/grid-layer/grid-cell-layer.ts +7 -7
- package/src/grid-layer/grid-layer-uniforms.ts +5 -5
- package/src/grid-layer/grid-layer.ts +3 -3
- package/src/heatmap-layer/heatmap-layer.ts +7 -4
- package/src/heatmap-layer/triangle-layer-uniforms.ts +1 -1
- package/src/heatmap-layer/triangle-layer.ts +1 -1
- package/src/hexagon-layer/hexagon-cell-layer.ts +6 -6
- package/src/hexagon-layer/hexagon-layer-uniforms.ts +4 -4
- package/src/hexagon-layer/hexagon-layer.ts +3 -3
- package/src/screen-grid-layer/screen-grid-layer.ts +1 -1
|
@@ -19,7 +19,7 @@ export type _ScreenGridLayerProps<DataT> = {
|
|
|
19
19
|
* Color scale input domain. The color scale maps continues numeric domain into discrete color range.
|
|
20
20
|
* @default [1, max(weight)]
|
|
21
21
|
*/
|
|
22
|
-
colorDomain?: [number, number] | null;
|
|
22
|
+
colorDomain?: Readonly<[number, number]> | null;
|
|
23
23
|
/**
|
|
24
24
|
* Specified as an array of colors [color1, color2, ...].
|
|
25
25
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screen-grid-layer.d.ts","sourceRoot":"","sources":["../../src/screen-grid-layer/screen-grid-layer.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,QAAQ,EACR,KAAK,EACL,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,EAEL,UAAU,EACV,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,eAAe,EAAE,aAAa,EAAE,oBAAoB,EAAC,sCAAmC;AAChG,OAAO,gBAAgB,uCAAoC;AAiB3D,mDAAmD;AACnD,MAAM,MAAM,oBAAoB,CAAC,KAAK,GAAG,OAAO,IAAI,qBAAqB,CAAC,KAAK,CAAC,GAC9E,mBAAmB,CAAC;AAEtB,2CAA2C;AAC3C,MAAM,MAAM,qBAAqB,CAAC,KAAK,IAAI;IACzC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"screen-grid-layer.d.ts","sourceRoot":"","sources":["../../src/screen-grid-layer/screen-grid-layer.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,QAAQ,EACR,KAAK,EACL,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,EAEL,UAAU,EACV,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,eAAe,EAAE,aAAa,EAAE,oBAAoB,EAAC,sCAAmC;AAChG,OAAO,gBAAgB,uCAAoC;AAiB3D,mDAAmD;AACnD,MAAM,MAAM,oBAAoB,CAAC,KAAK,GAAG,OAAO,IAAI,qBAAqB,CAAC,KAAK,CAAC,GAC9E,mBAAmB,CAAC;AAEtB,2CAA2C;AAC3C,MAAM,MAAM,qBAAqB,CAAC,KAAK,IAAI;IACzC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,WAAW,CAAC,EAAE,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;IAEhD;;;;OAIG;IACH,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC;IAErB;;;;OAIG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAEvC;;;;OAIG;IACH,WAAW,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAExC;;;;OAIG;IACH,SAAS,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAEpC;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,oBAAoB,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,0BAA0B,CAAC,KAAK,IAAI,WAAW,CAAC;IAC1D,mFAAmF;IACnF,GAAG,EAAE,MAAM,CAAC;IACZ,+EAA+E;IAC/E,GAAG,EAAE,MAAM,CAAC;IACZ,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,+FAA+F;IAC/F,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,+GAA+G;IAC/G,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;CAClB,CAAC,CAAC;AAEH,sEAAsE;AACtE,MAAM,CAAC,OAAO,OAAO,eAAe,CAClC,KAAK,GAAG,GAAG,EACX,UAAU,SAAS,EAAE,GAAG,EAAE,CAC1B,SAAQ,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;IACpF,MAAM,CAAC,SAAS,SAAqB;IACrC,MAAM,CAAC,YAAY,8CAAgB;IAEnC,iBAAiB,IAAI,MAAM;IAM3B,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,aAAa;IA6C/D,eAAe;IAgBf,iBAAiB,CAAC,EAAC,WAAW,EAAC,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAIvD,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAyC1C,iBAAiB,CAAC,EAAE,EAAE,MAAM;IAgB5B,YAAY,IAAI,UAAU,GAAG,KAAK,GAAG,IAAI;IAqCzC,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,0BAA0B,CAAC,KAAK,CAAC;CAyBhF"}
|
package/dist.min.js
CHANGED
|
@@ -321,7 +321,7 @@ DECKGL_FILTER_COLOR(vColor, geometry);
|
|
|
321
321
|
void getValue(out vec2 value) {
|
|
322
322
|
value = vec2(colorWeights, elevationWeights);
|
|
323
323
|
}
|
|
324
|
-
`})})}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,Y.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 Y.Viewport({position:[s[0],s[1],0],zoom:12}),o=[Math.fround(i.center[0]),Math.fround(i.center[1])],r=tt({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 q(r,o.binCount)}),e.onSetColorDomain(o.getResultDomain(0))}else if(t===1){let r=o.getResult(1);this.setState({elevations:new q(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:S,elevationUpperPercentile:C,elevationDomain:E}=this.props,M=this.getSubLayerClass("cells",qe),b=t.getBins(),y=this.state.colors?.update({scaleType:f,lowerPercentile:p,upperPercentile:d}),A=this.state.elevations?.update({scaleType:v,lowerPercentile:S,upperPercentile:C});return!y||!A?null:new M(this.getSubLayerProps({id:"cells"}),{data:{length:t.binCount,attributes:{getBin:b,getColorValue:y.attribute,getElevationValue:A.attribute}},dataComparator:(w,N)=>w.length===N.length,updateTriggers:{getBin:[b],getColorValue:[y.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:y.domain||x||t.getResultDomain(0),elevationDomain:A.domain||E||t.getResultDomain(1),colorCutoff:y.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 H=L(I(),1),Xt=L(Z(),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]},et=[l.W,l.SW,l.S],nt=[l.S,l.SE,l.E],ot=[l.E,l.NE,l.N],rt=[l.NW,l.W,l.N],it=[[-.5,m],[-.5,-m],[-m,-.5],[m,-.5]],st=[[-m,-.5],[m,-.5],[.5,-m],[.5,m]],at=[[.5,-m],[.5,m],[m,.5],[-m,.5]],ct=[[-.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],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],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")]:[et],[u("2212")]:[nt],[u("2122")]:[ot],[u("1222")]:[rt],[u("0001")]:[et],[u("0010")]:[nt],[u("0100")]:[ot],[u("1000")]:[rt],[u("2220")]:[it],[u("2202")]:[st],[u("2022")]:[at],[u("0222")]:[ct],[u("0002")]:[it],[u("0020")]:[st],[u("0200")]:[at],[u("2000")]:[ct],[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")]:[lt],[u("0121")]:[lt],[u("1012")]:[gt],[u("1210")]:[gt],[u("0101")]:{0:[et,ot],1:[lt],2:[lt]},[u("1010")]:{0:[rt,nt],1:[gt],2:[gt]},[u("2121")]:{0:[lt],1:[lt],2:[et,ot]},[u("1212")]:{0:[gt],1:[gt],2:[rt,nt]},[u("2120")]:{0:[Vt],1:[Vt],2:[it,ot]},[u("2021")]:{0:[Bt],1:[Bt],2:[et,at]},[u("1202")]:{0:[Ut],1:[Ut],2:[rt,st]},[u("0212")]:{0:[Ht],1:[Ht],2:[nt,ct]},[u("0102")]:{0:[it,ot],1:[Vt],2:[Vt]},[u("0201")]:{0:[et,at],1:[Bt],2:[Bt]},[u("1020")]:{0:[rt,st],1:[Ut],2:[Ut]},[u("2010")]:{0:[nt,ct],1:[Ht],2:[Ht]},[u("2020")]:{0:[ct,st],1:[Mn],2:[it,at]},[u("0202")]:{0:[at,it],1:[Mn],2:[ct,st]}};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,S;if(a||h)v=0;else{let M=i(t,e+1);v=vt(M,s),p+=M}if(c||h)S=0;else{let M=i(t+1,e+1);S=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 C=-1;Number.isFinite(s)&&(C=v<<3|S<<2|x<<1|d),Array.isArray(s)&&(C=v<<6|S<<4|x<<2|d);let E=0;return f||(E=vt(p/4,s)),{code:C,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}),S={x:p,y:d,z:h,code:x,meanCode:v};if(Array.isArray(f)){let C=Cn(S);for(let E of C)i[a++]={vertices:E,contour:g}}else{let C=bn(S);C.length>0&&(r[s++]={vertices:C,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 R=globalThis.mathgl.config;function Ln(n,{precision:t=R.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=R.EPSILON;e&&(R.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)<=R.EPSILON*Math.max(1,Math.abs(n),Math.abs(t)):!1}finally{R.EPSILON=o}}function sr(n){return Math.round(n/R.EPSILON)*R.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(R)}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(R.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(R.debug&&!ar(n,t))throw new Error(`math.gl: ${e} some fields set to invalid numbers'`);return n}var k=typeof Float32Array<"u"?Float32Array:Array;var rs=Math.PI/180;function cr(){let n=new k(2);return k!=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 Rn(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 _n(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 k(3);return k!=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(R.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],S=t[14],C=t[15],E=e*a-o*s,M=e*c-r*s,b=e*g-i*s,y=o*c-r*a,A=o*g-i*a,w=r*g-i*c,N=h*v-f*x,_=h*S-p*x,z=h*C-d*x,F=f*S-p*v,W=f*C-d*v,D=p*C-d*S,T=E*D-M*W+b*F+y*z-A*_+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-S*A+C*y)*T,n[3]=(p*A-f*w-d*y)*T,n[4]=(c*z-s*D-g*_)*T,n[5]=(e*D-r*z+i*_)*T,n[6]=(S*b-x*w-C*M)*T,n[7]=(h*w-p*b+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*b+C*E)*T,n[11]=(f*b-h*A-d*E)*T,n[12]=(a*_-s*F-c*N)*T,n[13]=(e*F-o*_+r*N)*T,n[14]=(v*M-x*y-S*E)*T,n[15]=(h*y-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],S=n[15],C=t*s-e*i,E=t*a-o*i,M=e*a-o*s,b=g*x-h*d,y=g*v-f*d,A=h*v-f*x,w=t*A-e*y+o*b,N=i*A-s*y+a*b,_=g*M-h*E+f*C,z=d*M-x*E+v*C;return c*w-r*N+S*_-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],S=t[13],C=t[14],E=t[15],M=e[0],b=e[1],y=e[2],A=e[3];return n[0]=M*o+b*a+y*f+A*v,n[1]=M*r+b*c+y*p+A*S,n[2]=M*i+b*g+y*d+A*C,n[3]=M*s+b*h+y*x+A*E,M=e[4],b=e[5],y=e[6],A=e[7],n[4]=M*o+b*a+y*f+A*v,n[5]=M*r+b*c+y*p+A*S,n[6]=M*i+b*g+y*d+A*C,n[7]=M*s+b*h+y*x+A*E,M=e[8],b=e[9],y=e[10],A=e[11],n[8]=M*o+b*a+y*f+A*v,n[9]=M*r+b*c+y*p+A*S,n[10]=M*i+b*g+y*d+A*C,n[11]=M*s+b*h+y*x+A*E,M=e[12],b=e[13],y=e[14],A=e[15],n[12]=M*o+b*a+y*f+A*v,n[13]=M*r+b*c+y*p+A*S,n[14]=M*i+b*g+y*d+A*C,n[15]=M*s+b*h+y*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,S,C;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],S=t[10],C=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]=S,n[11]=C,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+S*i+t[14],n[15]=g*o+d*r+C*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,S,C,E,M,b,y,A,w,N,_,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],S=t[5],C=t[6],E=t[7],M=t[8],b=t[9],y=t[10],A=t[11],w=r*r*h+c,N=i*r*h+s*g,_=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*_,n[1]=p*w+S*N+b*_,n[2]=d*w+C*N+y*_,n[3]=x*w+E*N+A*_,n[4]=f*z+v*F+M*W,n[5]=p*z+S*F+b*W,n[6]=d*z+C*F+y*W,n[7]=x*z+E*F+A*W,n[8]=f*D+v*T+M*ft,n[9]=p*D+S*T+b*ft,n[10]=d*D+C*T+y*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,S=i*a,C=i*c;return n[0]=1-f-x,n[1]=h+C,n[2]=p-S,n[3]=0,n[4]=h-C,n[5]=1-g-x,n[6]=d+v,n[7]=0,n[8]=p+S,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],S=t[2],C=o[0],E=o[1],M=o[2],b=e[0],y=e[1],A=e[2];return Math.abs(x-b)<1e-6&&Math.abs(v-y)<1e-6&&Math.abs(S-A)<1e-6?gr(n):(f=x-b,p=v-y,d=S-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-C*d,a=C*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*S),n[13]=-(c*x+g*v+h*S),n[14]=-(f*x+p*v+d*S),n[15]=1,n)}function fr(){let n=new k(4);return k!=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]),K=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,S){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]=S,this.check()}setRowMajor(t,e,o,r,i,s,a,c,g,h,f,p,d,x,v,S){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]=S,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=Rn(e||[-0,-0],t,this);break;case 3:o=_n(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 K([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 K,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=`uniform binOptionsUniforms {
|
|
324
|
+
`})})}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,Y.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 Y.Viewport({position:[s[0],s[1],0],zoom:12}),o=[Math.fround(i.center[0]),Math.fround(i.center[1])],r=tt({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 q(r,o.binCount)}),e.onSetColorDomain(o.getResultDomain(0))}else if(t===1){let r=o.getResult(1);this.setState({elevations:new q(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 H=L(I(),1),Xt=L(Z(),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]},et=[l.W,l.SW,l.S],nt=[l.S,l.SE,l.E],ot=[l.E,l.NE,l.N],rt=[l.NW,l.W,l.N],it=[[-.5,m],[-.5,-m],[-m,-.5],[m,-.5]],st=[[-m,-.5],[m,-.5],[.5,-m],[.5,m]],at=[[.5,-m],[.5,m],[m,.5],[-m,.5]],ct=[[-.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],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],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")]:[et],[u("2212")]:[nt],[u("2122")]:[ot],[u("1222")]:[rt],[u("0001")]:[et],[u("0010")]:[nt],[u("0100")]:[ot],[u("1000")]:[rt],[u("2220")]:[it],[u("2202")]:[st],[u("2022")]:[at],[u("0222")]:[ct],[u("0002")]:[it],[u("0020")]:[st],[u("0200")]:[at],[u("2000")]:[ct],[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")]:[lt],[u("0121")]:[lt],[u("1012")]:[gt],[u("1210")]:[gt],[u("0101")]:{0:[et,ot],1:[lt],2:[lt]},[u("1010")]:{0:[rt,nt],1:[gt],2:[gt]},[u("2121")]:{0:[lt],1:[lt],2:[et,ot]},[u("1212")]:{0:[gt],1:[gt],2:[rt,nt]},[u("2120")]:{0:[Vt],1:[Vt],2:[it,ot]},[u("2021")]:{0:[Bt],1:[Bt],2:[et,at]},[u("1202")]:{0:[Ut],1:[Ut],2:[rt,st]},[u("0212")]:{0:[Ht],1:[Ht],2:[nt,ct]},[u("0102")]:{0:[it,ot],1:[Vt],2:[Vt]},[u("0201")]:{0:[et,at],1:[Bt],2:[Bt]},[u("1020")]:{0:[rt,st],1:[Ut],2:[Ut]},[u("2010")]:{0:[nt,ct],1:[Ht],2:[Ht]},[u("2020")]:{0:[ct,st],1:[Mn],2:[it,at]},[u("0202")]:{0:[at,it],1:[Mn],2:[ct,st]}};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 R=globalThis.mathgl.config;function Ln(n,{precision:t=R.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=R.EPSILON;e&&(R.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)<=R.EPSILON*Math.max(1,Math.abs(n),Math.abs(t)):!1}finally{R.EPSILON=o}}function sr(n){return Math.round(n/R.EPSILON)*R.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(R)}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(R.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(R.debug&&!ar(n,t))throw new Error(`math.gl: ${e} some fields set to invalid numbers'`);return n}var k=typeof Float32Array<"u"?Float32Array:Array;var rs=Math.PI/180;function cr(){let n=new k(2);return k!=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 Rn(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 _n(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 k(3);return k!=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(R.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,_=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*_+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*_)*T,n[5]=(e*D-r*z+i*_)*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*_-s*F-c*N)*T,n[13]=(e*F-o*_+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,_=g*M-h*E+f*b,z=d*M-x*E+v*b;return c*w-r*N+y*_-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,_,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,_=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*_,n[1]=p*w+y*N+C*_,n[2]=d*w+b*N+S*_,n[3]=x*w+E*N+A*_,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 k(4);return k!=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]),K=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=Rn(e||[-0,-0],t,this);break;case 3:o=_n(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 K([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 K,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=`uniform binOptionsUniforms {
|
|
325
325
|
vec2 cellOriginCommon;
|
|
326
326
|
vec2 cellSizeCommon;
|
|
327
327
|
} binOptions;
|
|
@@ -410,7 +410,7 @@ DECKGL_FILTER_COLOR(vColor, geometry);
|
|
|
410
410
|
void getValue(out vec2 value) {
|
|
411
411
|
value = vec2(colorWeights, elevationWeights);
|
|
412
412
|
}
|
|
413
|
-
`})})}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,$.createIterable)(o.data).iterable)),e||i.dataChanged||o.cellSize!==r.cellSize||o.getColorValue!==r.getColorValue||o.getElevationValue!==r.getElevationValue||o.colorAggregation!==r.colorAggregation||o.elevationAggregation!==r.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: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,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],{cellSize:a}=this.props,{unitsPerMeter:c}=i.getDistanceScales(s);e[0]=c[0]*a,e[1]=c[1]*a;let g=i.projectFlat(s);o=[Math.floor(g[0]/e[0])*e[0],Math.floor(g[1]/e[1])*e[1]],s=i.unprojectFlat(o);let h=i.constructor;i=i.isGeospatial?new h({longitude:s[0],latitude:s[1],zoom:12}):new $.Viewport({position:[s[0],s[1],0],zoom:12}),o=[Math.fround(i.center[0]),Math.fround(i.center[1])],r=tt({dataBounds:t,getBinId:f=>{let p=i.projectFlat(f);return[Math.floor((p[0]-o[0])/e[0]),Math.floor((p[1]-o[1])/e[1])]}})}this.setState({cellSizeCommon:e,cellOriginCommon: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 q(r,o.binCount)}),e.onSetColorDomain(o.getResultDomain(0))}else if(t===1){let r=o.getResult(1);this.setState({elevations:new q(r,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:r,binIdRange:i}=this.state;e.setProps({binIdRange:i,binOptions:{cellSizeCommon:o,cellOriginCommon:r}});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:r,colorRange:i,elevationRange:s,extruded:a,coverage:c,material:g,transitions:h,colorScaleType:f,lowerPercentile:p,upperPercentile:d,colorDomain:x,elevationScaleType:v,elevationLowerPercentile:
|
|
413
|
+
`})})}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,$.createIterable)(o.data).iterable)),e||i.dataChanged||o.cellSize!==r.cellSize||o.getColorValue!==r.getColorValue||o.getElevationValue!==r.getElevationValue||o.colorAggregation!==r.colorAggregation||o.elevationAggregation!==r.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: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,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],{cellSize:a}=this.props,{unitsPerMeter:c}=i.getDistanceScales(s);e[0]=c[0]*a,e[1]=c[1]*a;let g=i.projectFlat(s);o=[Math.floor(g[0]/e[0])*e[0],Math.floor(g[1]/e[1])*e[1]],s=i.unprojectFlat(o);let h=i.constructor;i=i.isGeospatial?new h({longitude:s[0],latitude:s[1],zoom:12}):new $.Viewport({position:[s[0],s[1],0],zoom:12}),o=[Math.fround(i.center[0]),Math.fround(i.center[1])],r=tt({dataBounds:t,getBinId:f=>{let p=i.projectFlat(f);return[Math.floor((p[0]-o[0])/e[0]),Math.floor((p[1]-o[1])/e[1])]}})}this.setState({cellSizeCommon:e,cellOriginCommon: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 q(r,o.binCount)}),e.onSetColorDomain(o.getResultDomain(0))}else if(t===1){let r=o.getResult(1);this.setState({elevations:new q(r,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:r,binIdRange:i}=this.state;e.setProps({binIdRange:i,binOptions:{cellSizeCommon:o,cellOriginCommon:r}});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: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",yt),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]},cellOriginCommon:e,cellSizeCommon: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;r&&(i={col:r.id[0],row:r.id[1],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(s=>this.props.data[s]):[])),e.object=i}return e}};St.layerName="GridLayer";St.defaultProps=Er;var so=St;function co(n){let t=n.map(a=>a[0]),e=n.map(a=>a[1]),o=Math.min.apply(null,t),r=Math.max.apply(null,t),i=Math.min.apply(null,e),s=Math.max.apply(null,e);return[o,i,r,s]}function lo(n,t){return t[0]>=n[0]&&t[2]<=n[2]&&t[1]>=n[1]&&t[3]<=n[3]}var ao=new Float32Array(12);function pe(n,t=2){let e=0;for(let o of n)for(let r=0;r<t;r++)ao[e++]=o[r]||0;return ao}function go(n,t,e){let[o,r,i,s]=n,a=i-o,c=s-r,g=a,h=c;a/c<t/e?g=t/e*c:h=e/t*a,g<t&&(g=t,h=e);let f=(i+o)/2,p=(s+r)/2;return[f-g/2,p-h/2,f+g/2,p+h/2]}function ho(n,t){let[e,o,r,i]=t;return[(n[0]-e)/(r-e),(n[1]-o)/(i-o)]}var de=L(X(),1),V=L(I(),1);var xo=L(X(),1),Zt=L(I(),1);var po=`#version 300 es
|
|
414
414
|
#define SHADER_NAME heatp-map-layer-vertex-shader
|
|
415
415
|
uniform sampler2D maxTexture;
|
|
416
416
|
in vec3 positions;
|
|
@@ -523,6 +523,6 @@ fragColor.g = outTexture.r / max(1.0, outTexture.a);
|
|
|
523
523
|
`,Co={name:"weight",vs:Lr,uniformTypes:{commonBounds:"vec4<f32>",radiusPixels:"f32",textureWidth:"f32",weightsScale:"f32"}},bo={name:"maxWeight",vs:`uniform maxWeightUniforms {
|
|
524
524
|
float textureSize;
|
|
525
525
|
} maxWeight;
|
|
526
|
-
`,uniformTypes:{textureSize:"f32"}};var Pr=2,fe={format:"rgba8unorm",dimension:"2d",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}},Eo=[0,0],wr={SUM:0,MEAN:1},Nr={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:G,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}},Or=["float32-renderable-webgl","texture-blend-float-webgl"],Rr={data:{props:["radiusPixels"]}},At=class extends yo{getShaders(t){let e=[V.project32];return t.modules&&(e=[...e,...t.modules]),super.getShaders({...t,modules:e})}initializeState(){super.initializeAggregationLayer(Rr),this.setState({colorDomain:Eo}),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,r=this._getChangeFlags(t);if((r.dataChanged||r.viewportChanged)&&(r.boundsChanged=this._updateBounds(r.dataChanged),this._updateTextureRenderingBounds()),r.dataChanged||r.boundsChanged){if(clearTimeout(this.state.updateTimer),this.setState({isWeightMapDirty:!0}),r.dataChanged){let i=this.getShaders({vs:Jt,fs:te});this._createWeightsTransform(i)}}else r.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:r,colorTexture:i,colorDomain:s}=this.state,{updateTriggers:a,intensity:c,threshold:g,aggregation:h}=this.props,f=this.getSubLayerClass("triangle",vo);return new f(this.getSubLayerProps({id:"triangle-layer",updateTriggers:a}),{coordinateSystem:V.COORDINATE_SYSTEM.DEFAULT,data:{attributes:{positions:e,texCoords:o}},vertexCount:4,maxTexture:r,colorTexture:i,aggregationMode:wr[h]||0,weightsTexture:t,intensity:c,threshold:g,colorDomain:s})}finalizeState(t){super.finalizeState(t);let{weightsTransform:e,weightsTexture:o,maxWeightTransform:r,maxWeightsTexture:i,triPositionBuffer:s,triTexCoordBuffer:a,colorTexture:c,updateTimer:g}=this.state;e?.destroy(),o?.destroy(),r?.destroy(),i?.destroy(),s?.destroy(),a?.destroy(),c?.destroy(),g&&clearTimeout(g)}_getAttributeManager(){return new V.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:r}=this.state;return(!t.context.viewport||t.context.viewport.zoom!==r)&&(e.viewportZoomChanged=!0),e}_createTextures(){let{textureSize:t,format:e}=this.state;this.setState({weightsTexture:this.context.device.createTexture({...fe,width:t,height:t,format:e}),maxWeightsTexture:this.context.device.createTexture({...fe,width:1,height:1,format:e})})}_setupAttributes(){this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"},weights:{size:1,accessor:"getWeight"}}),this.setState({positionAttributeName:"positions"})}_setupTextureParams(){let{device:t}=this.context,{weightsTextureSize:e}=this.props,o=Math.min(e,t.limits.maxTextureDimension2D),r=Or.every(a=>t.features.has(a)),i=r?"rgba32float":"rgba8unorm",s=r?1:1/255;this.setState({textureSize:o,format:i,weightsScale:s}),r||V.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,r=this.getAttributeManager();e?.destroy(),e=new de.TextureTransform(this.context.device,{id:`${this.id}-weights-transform`,bufferLayout:r.getBufferLayouts(),vertexCount:1,targetTexture:o,parameters:{depthWriteEnabled:!1,blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},topology:"point-list",...t,modules:[...t.modules,Co]}),this.setState({weightsTransform:e})}_setupResources(){this._createTextures();let{device:t}=this.context,{textureSize:e,weightsTexture:o,maxWeightsTexture:r}=this.state,i=this.getShaders({vs:Jt,fs:te});this._createWeightsTransform(i);let s=this.getShaders({vs:So,fs:Ao,modules:[bo]}),a=new de.TextureTransform(t,{id:`${this.id}-max-weights-transform`,targetTexture:r,...s,vertexCount: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:r,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)),r=co(o),i={visibleWorldBounds:r,viewportCorners:o},s=!1;if(t||!this.state.worldBounds||!lo(this.state.worldBounds,r)){let a=this._worldToCommonBounds(r),c=this._commonToWorldBounds(a);this.props.coordinateSystem===V.COORDINATE_SYSTEM.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);i.worldBounds=c,i.normalizedCommonBounds=g,s=!0}return this.setState(i),s}_updateTextureRenderingBounds(){let{triPositionBuffer:t,triTexCoordBuffer:e,normalizedCommonBounds:o,viewportCorners:r}=this.state,{viewport:i}=this.context;t.write(pe(r,3));let s=r.map(a=>ho(i.projectPosition(a),o));e.write(pe(s,2))}_updateColorTexture(t){let{colorRange:e}=t.props,{colorTexture:o}=this.state,r=re(e,!1,Uint8Array);o?.destroy(),o=this.context.device.createTexture({...fe,data:r,width:e.length,height:1}),this.setState({colorTexture:o})}_updateWeightmap(){let{radiusPixels:t,colorDomain:e,aggregation:o}=this.props,{worldBounds:r,textureSize:i,weightsScale:s,weightsTexture:a}=this.state,c=this.state.weightsTransform;this.state.isWeightMapDirty=!1;let g=this._worldToCommonBounds(r,{useLayerCoordinateSystem:!0});if(e&&o==="SUM"){let{viewport:M}=this.context,
|
|
526
|
+
`,uniformTypes:{textureSize:"f32"}};var Pr=2,fe={format:"rgba8unorm",dimension:"2d",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}},Eo=[0,0],wr={SUM:0,MEAN:1},Nr={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:G,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}},Or=["float32-renderable-webgl","texture-blend-float-webgl"],Rr={data:{props:["radiusPixels"]}},At=class extends yo{getShaders(t){let e=[V.project32];return t.modules&&(e=[...e,...t.modules]),super.getShaders({...t,modules:e})}initializeState(){super.initializeAggregationLayer(Rr),this.setState({colorDomain:Eo}),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,r=this._getChangeFlags(t);if((r.dataChanged||r.viewportChanged)&&(r.boundsChanged=this._updateBounds(r.dataChanged),this._updateTextureRenderingBounds()),r.dataChanged||r.boundsChanged){if(clearTimeout(this.state.updateTimer),this.setState({isWeightMapDirty:!0}),r.dataChanged){let i=this.getShaders({vs:Jt,fs:te});this._createWeightsTransform(i)}}else r.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:r,colorTexture:i,colorDomain:s}=this.state,{updateTriggers:a,intensity:c,threshold:g,aggregation:h}=this.props,f=this.getSubLayerClass("triangle",vo);return new f(this.getSubLayerProps({id:"triangle-layer",updateTriggers:a}),{coordinateSystem:V.COORDINATE_SYSTEM.DEFAULT,data:{attributes:{positions:e,texCoords:o}},vertexCount:4,maxTexture:r,colorTexture:i,aggregationMode:wr[h]||0,weightsTexture:t,intensity:c,threshold:g,colorDomain:s})}finalizeState(t){super.finalizeState(t);let{weightsTransform:e,weightsTexture:o,maxWeightTransform:r,maxWeightsTexture:i,triPositionBuffer:s,triTexCoordBuffer:a,colorTexture:c,updateTimer:g}=this.state;e?.destroy(),o?.destroy(),r?.destroy(),i?.destroy(),s?.destroy(),a?.destroy(),c?.destroy(),g&&clearTimeout(g)}_getAttributeManager(){return new V.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:r}=this.state;return(!t.context.viewport||t.context.viewport.zoom!==r)&&(e.viewportZoomChanged=!0),e}_createTextures(){let{textureSize:t,format:e}=this.state;this.setState({weightsTexture:this.context.device.createTexture({...fe,width:t,height:t,format:e}),maxWeightsTexture:this.context.device.createTexture({...fe,width:1,height:1,format:e})})}_setupAttributes(){this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"},weights:{size:1,accessor:"getWeight"}}),this.setState({positionAttributeName:"positions"})}_setupTextureParams(){let{device:t}=this.context,{weightsTextureSize:e}=this.props,o=Math.min(e,t.limits.maxTextureDimension2D),r=Or.every(a=>t.features.has(a)),i=r?"rgba32float":"rgba8unorm",s=r?1:1/255;this.setState({textureSize:o,format:i,weightsScale:s}),r||V.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,r=this.getAttributeManager();e?.destroy(),e=new de.TextureTransform(this.context.device,{id:`${this.id}-weights-transform`,bufferLayout:r.getBufferLayouts(),vertexCount:1,targetTexture:o,parameters:{depthWriteEnabled:!1,blend:!0,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},topology:"point-list",...t,modules:[...t.modules,Co]}),this.setState({weightsTransform:e})}_setupResources(){this._createTextures();let{device:t}=this.context,{textureSize:e,weightsTexture:o,maxWeightsTexture:r}=this.state,i=this.getShaders({vs:Jt,fs:te});this._createWeightsTransform(i);let s=this.getShaders({vs:So,fs:Ao,modules:[bo]}),a=new de.TextureTransform(t,{id:`${this.id}-max-weights-transform`,targetTexture:r,...s,vertexCount: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:r,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)),r=co(o),i={visibleWorldBounds:r,viewportCorners:o},s=!1;if(t||!this.state.worldBounds||!lo(this.state.worldBounds,r)){let a=this._worldToCommonBounds(r),c=this._commonToWorldBounds(a);this.props.coordinateSystem===V.COORDINATE_SYSTEM.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);i.worldBounds=c,i.normalizedCommonBounds=g,s=!0}return this.setState(i),s}_updateTextureRenderingBounds(){let{triPositionBuffer:t,triTexCoordBuffer:e,normalizedCommonBounds:o,viewportCorners:r}=this.state,{viewport:i}=this.context;t.write(pe(r,3));let s=r.map(a=>ho(i.projectPosition(a),o));e.write(pe(s,2))}_updateColorTexture(t){let{colorRange:e}=t.props,{colorTexture:o}=this.state,r=re(e,!1,Uint8Array);o?.destroy(),o=this.context.device.createTexture({...fe,data:r,width:e.length,height:1}),this.setState({colorTexture:o})}_updateWeightmap(){let{radiusPixels:t,colorDomain:e,aggregation:o}=this.props,{worldBounds:r,textureSize:i,weightsScale:s,weightsTexture:a}=this.state,c=this.state.weightsTransform;this.state.isWeightMapDirty=!1;let g=this._worldToCommonBounds(r,{useLayerCoordinateSystem:!0});if(e&&o==="SUM"){let{viewport:M}=this.context,C=M.distanceScales.metersPerUnit[2]*(g[2]-g[0])/i;this.state.colorDomain=[e[0]*C*s,e[1]*C*s]}else this.state.colorDomain=e||Eo;let f=this.getAttributeManager().getAttributes(),p=this.getModuleSettings();this._setModelAttributes(c.model,f),c.model.setVertexCount(this.getNumInstances());let d={radiusPixels:t,commonBounds:g,textureWidth:i,weightsScale:s,weightsTexture:a},{viewport:x,devicePixelRatio:v,coordinateSystem:y,coordinateOrigin:b}=p,{modelMatrix:E}=this.props;c.model.shaderInputs.setProps({project:{viewport:x,devicePixelRatio:v,modelMatrix:E,coordinateSystem:y,coordinateOrigin:b},weight:d}),c.run({parameters:{viewport:[0,0,i,i]},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,[r,i,s,a]=t,{viewport:c}=this.context,{textureSize:g}=this.state,{coordinateSystem:h}=this.props,f=o&&(h===V.COORDINATE_SYSTEM.LNGLAT_OFFSETS||h===V.COORDINATE_SYSTEM.METER_OFFSETS),p=f?c.projectPosition(this.props.coordinateOrigin):[0,0],d=g*Pr/c.scale,x,v;return o&&!f?(x=this.projectPosition([r,i,0]),v=this.projectPosition([s,a,0])):(x=c.projectPosition([r,i,0]),v=c.projectPosition([s,a,0])),go([x[0]-p[0],x[1]-p[1],v[0]-p[0],v[1]-p[1]],d,d)}_commonToWorldBounds(t){let[e,o,r,i]=t,{viewport:s}=this.context,a=s.unprojectPosition([e,o]),c=s.unprojectPosition([r,i]);return a.slice(0,2).concat(c.slice(0,2))}};At.layerName="HeatmapLayer";At.defaultProps=Nr;var To=At;return _o(Ct);})();
|
|
527
527
|
return __exports__;
|
|
528
528
|
});
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "deck.gl layers that aggregate the input data into alternative representations",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "9.2.
|
|
6
|
+
"version": "9.2.9",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"@luma.gl/core": "~9.2.6",
|
|
51
51
|
"@luma.gl/engine": "~9.2.6"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "b0e908d0c51316514a44221fcdb30b777c09d118"
|
|
54
54
|
}
|
|
@@ -64,7 +64,7 @@ type _ContourLayerProps<DataT> = {
|
|
|
64
64
|
* The grid origin
|
|
65
65
|
* @default [0, 0]
|
|
66
66
|
*/
|
|
67
|
-
gridOrigin?: [number, number]
|
|
67
|
+
gridOrigin?: Readonly<[number, number]>;
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* When set to true, aggregation is performed on GPU, provided other conditions are met.
|
|
@@ -13,15 +13,15 @@ import type {ScaleType} from '../common/types';
|
|
|
13
13
|
|
|
14
14
|
/** Proprties added by GridCellLayer. */
|
|
15
15
|
type GridCellLayerProps = {
|
|
16
|
-
cellSizeCommon: [number, number]
|
|
17
|
-
cellOriginCommon: [number, number]
|
|
18
|
-
colorDomain: [number, number]
|
|
19
|
-
colorCutoff: [number, number] | null;
|
|
16
|
+
cellSizeCommon: Readonly<[number, number]>;
|
|
17
|
+
cellOriginCommon: Readonly<[number, number]>;
|
|
18
|
+
colorDomain: Readonly<[number, number]>;
|
|
19
|
+
colorCutoff: Readonly<[number, number]> | null;
|
|
20
20
|
colorRange: Color[];
|
|
21
21
|
colorScaleType: ScaleType;
|
|
22
|
-
elevationDomain: [number, number]
|
|
23
|
-
elevationCutoff: [number, number] | null;
|
|
24
|
-
elevationRange: [number, number]
|
|
22
|
+
elevationDomain: Readonly<[number, number]>;
|
|
23
|
+
elevationCutoff: Readonly<[number, number]> | null;
|
|
24
|
+
elevationRange: Readonly<[number, number]>;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export class GridCellLayer<ExtraPropsT extends {} = {}> extends ColumnLayer<
|
|
@@ -16,12 +16,12 @@ uniform gridUniforms {
|
|
|
16
16
|
`;
|
|
17
17
|
|
|
18
18
|
export type GridProps = {
|
|
19
|
-
colorDomain: [number, number, number, number]
|
|
19
|
+
colorDomain: Readonly<[number, number, number, number]>;
|
|
20
20
|
colorRange: Texture;
|
|
21
|
-
elevationDomain: [number, number, number, number]
|
|
22
|
-
elevationRange: [number, number]
|
|
23
|
-
originCommon: [number, number]
|
|
24
|
-
sizeCommon: [number, number]
|
|
21
|
+
elevationDomain: Readonly<[number, number, number, number]>;
|
|
22
|
+
elevationRange: Readonly<[number, number]>;
|
|
23
|
+
originCommon: Readonly<[number, number]>;
|
|
24
|
+
sizeCommon: Readonly<[number, number]>;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export const gridUniforms = {
|
|
@@ -90,7 +90,7 @@ type _GridLayerProps<DataT> = {
|
|
|
90
90
|
* Color scale domain, default is set to the extent of aggregated weights in each cell.
|
|
91
91
|
* @default [min(colorWeight), max(colorWeight)]
|
|
92
92
|
*/
|
|
93
|
-
colorDomain?: [number, number] | null;
|
|
93
|
+
colorDomain?: Readonly<[number, number]> | null;
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* Default: [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6) `6-class YlOrRd`
|
|
@@ -107,13 +107,13 @@ type _GridLayerProps<DataT> = {
|
|
|
107
107
|
* Elevation scale input domain, default is set to between 0 and the max of aggregated weights in each cell.
|
|
108
108
|
* @default [0, max(elevationWeight)]
|
|
109
109
|
*/
|
|
110
|
-
elevationDomain?: [number, number] | null;
|
|
110
|
+
elevationDomain?: Readonly<[number, number]> | null;
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
113
|
* Elevation scale output range.
|
|
114
114
|
* @default [0, 1000]
|
|
115
115
|
*/
|
|
116
|
-
elevationRange?: [number, number]
|
|
116
|
+
elevationRange?: Readonly<[number, number]>;
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* Cell elevation multiplier.
|
|
@@ -55,7 +55,7 @@ const TEXTURE_PROPS: TextureProps = {
|
|
|
55
55
|
addressModeV: 'clamp-to-edge'
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
-
const DEFAULT_COLOR_DOMAIN = [0, 0];
|
|
58
|
+
const DEFAULT_COLOR_DOMAIN = [0, 0] as const;
|
|
59
59
|
const AGGREGATION_MODE = {
|
|
60
60
|
SUM: 0,
|
|
61
61
|
MEAN: 1
|
|
@@ -126,7 +126,7 @@ type _HeatmapLayerProps<DataT> = {
|
|
|
126
126
|
*
|
|
127
127
|
* @default null
|
|
128
128
|
*/
|
|
129
|
-
colorDomain?: [number, number] | null;
|
|
129
|
+
colorDomain?: Readonly<[number, number]> | null;
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
132
|
* Defines the type of aggregation operation
|
|
@@ -174,7 +174,7 @@ export default class HeatmapLayer<
|
|
|
174
174
|
static defaultProps = defaultProps;
|
|
175
175
|
|
|
176
176
|
state!: AggregationLayer<DataT>['state'] & {
|
|
177
|
-
colorDomain?: number
|
|
177
|
+
colorDomain?: Readonly<[number, number]>;
|
|
178
178
|
isWeightMapDirty?: boolean;
|
|
179
179
|
weightsTexture?: Texture;
|
|
180
180
|
maxWeightsTexture?: Texture;
|
|
@@ -594,7 +594,10 @@ export default class HeatmapLayer<
|
|
|
594
594
|
const metersPerPixel =
|
|
595
595
|
(viewport.distanceScales.metersPerUnit[2] * (commonBounds[2] - commonBounds[0])) /
|
|
596
596
|
textureSize;
|
|
597
|
-
this.state.colorDomain =
|
|
597
|
+
this.state.colorDomain = [
|
|
598
|
+
colorDomain[0] * metersPerPixel * weightsScale,
|
|
599
|
+
colorDomain[1] * metersPerPixel * weightsScale
|
|
600
|
+
];
|
|
598
601
|
} else {
|
|
599
602
|
this.state.colorDomain = colorDomain || DEFAULT_COLOR_DOMAIN;
|
|
600
603
|
}
|
|
@@ -11,7 +11,7 @@ import {TriangleProps, triangleUniforms} from './triangle-layer-uniforms';
|
|
|
11
11
|
|
|
12
12
|
type _TriangleLayerProps = {
|
|
13
13
|
data: {attributes: {positions: Buffer; texCoords: Buffer}};
|
|
14
|
-
colorDomain: [number, number]
|
|
14
|
+
colorDomain: Readonly<[number, number]>;
|
|
15
15
|
aggregationMode: number;
|
|
16
16
|
threshold: number;
|
|
17
17
|
intensity: number;
|
|
@@ -12,14 +12,14 @@ import type {ScaleType} from '../common/types';
|
|
|
12
12
|
|
|
13
13
|
/** Proprties added by HexagonCellLayer. */
|
|
14
14
|
export type _HexagonCellLayerProps = {
|
|
15
|
-
hexOriginCommon: [number, number]
|
|
16
|
-
colorDomain: [number, number]
|
|
17
|
-
colorCutoff: [number, number] | null;
|
|
15
|
+
hexOriginCommon: Readonly<[number, number]>;
|
|
16
|
+
colorDomain: Readonly<[number, number]>;
|
|
17
|
+
colorCutoff: Readonly<[number, number]> | null;
|
|
18
18
|
colorRange: Color[];
|
|
19
19
|
colorScaleType: ScaleType;
|
|
20
|
-
elevationDomain: [number, number]
|
|
21
|
-
elevationCutoff: [number, number] | null;
|
|
22
|
-
elevationRange: [number, number]
|
|
20
|
+
elevationDomain: Readonly<[number, number]>;
|
|
21
|
+
elevationCutoff: Readonly<[number, number]> | null;
|
|
22
|
+
elevationRange: Readonly<[number, number]>;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export default class HexagonCellLayer<ExtraPropsT extends {} = {}> extends ColumnLayer<
|
|
@@ -15,11 +15,11 @@ uniform hexagonUniforms {
|
|
|
15
15
|
`;
|
|
16
16
|
|
|
17
17
|
export type HexagonProps = {
|
|
18
|
-
colorDomain: [number, number, number, number]
|
|
18
|
+
colorDomain: Readonly<[number, number, number, number]>;
|
|
19
19
|
colorRange: Texture;
|
|
20
|
-
elevationDomain: [number, number, number, number]
|
|
21
|
-
elevationRange: [number, number]
|
|
22
|
-
originCommon: [number, number]
|
|
20
|
+
elevationDomain: Readonly<[number, number, number, number]>;
|
|
21
|
+
elevationRange: Readonly<[number, number]>;
|
|
22
|
+
originCommon: Readonly<[number, number]>;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export const hexagonUniforms = {
|
|
@@ -92,7 +92,7 @@ type _HexagonLayerProps<DataT> = {
|
|
|
92
92
|
* Color scale domain, default is set to the extent of aggregated weights in each cell.
|
|
93
93
|
* @default [min(colorWeight), max(colorWeight)]
|
|
94
94
|
*/
|
|
95
|
-
colorDomain?: [number, number] | null;
|
|
95
|
+
colorDomain?: Readonly<[number, number]> | null;
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
98
|
* Default: [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6) `6-class YlOrRd`
|
|
@@ -109,13 +109,13 @@ type _HexagonLayerProps<DataT> = {
|
|
|
109
109
|
* Elevation scale input domain, default is set to between 0 and the max of aggregated weights in each cell.
|
|
110
110
|
* @default [0, max(elevationWeight)]
|
|
111
111
|
*/
|
|
112
|
-
elevationDomain?: [number, number] | null;
|
|
112
|
+
elevationDomain?: Readonly<[number, number]> | null;
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* Elevation scale output range.
|
|
116
116
|
* @default [0, 1000]
|
|
117
117
|
*/
|
|
118
|
-
elevationRange?: [number, number]
|
|
118
|
+
elevationRange?: Readonly<[number, number]>;
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
121
|
* Cell elevation multiplier.
|
|
@@ -55,7 +55,7 @@ export type _ScreenGridLayerProps<DataT> = {
|
|
|
55
55
|
* Color scale input domain. The color scale maps continues numeric domain into discrete color range.
|
|
56
56
|
* @default [1, max(weight)]
|
|
57
57
|
*/
|
|
58
|
-
colorDomain?: [number, number] | null;
|
|
58
|
+
colorDomain?: Readonly<[number, number]> | null;
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* Specified as an array of colors [color1, color2, ...].
|