@deck.gl/aggregation-layers 9.0.0-beta.1 → 9.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +3287 -310
- package/dist/es5/heatmap-layer/heatmap-layer-utils.js +0 -15
- package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
- package/dist/es5/heatmap-layer/heatmap-layer.js +103 -97
- package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/max-vs.glsl.js +1 -1
- package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js +1 -1
- package/dist/es5/heatmap-layer/triangle-layer.js +26 -27
- package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/weights-vs.glsl.js +1 -1
- package/dist/esm/heatmap-layer/heatmap-layer-utils.js +0 -13
- package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +1 -1
- package/dist/esm/heatmap-layer/heatmap-layer.js +99 -87
- package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/max-vs.glsl.js +11 -5
- package/dist/esm/heatmap-layer/max-vs.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js +2 -2
- package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/triangle-layer.js +21 -23
- package/dist/esm/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/weights-vs.glsl.js +4 -2
- package/dist/esm/heatmap-layer/weights-vs.glsl.js.map +1 -1
- package/dist.min.js +85 -75
- package/package.json +7 -7
- package/src/heatmap-layer/heatmap-layer-utils.ts +0 -23
- package/src/heatmap-layer/heatmap-layer.ts +87 -105
- package/src/heatmap-layer/max-vs.glsl.ts +11 -5
- package/src/heatmap-layer/triangle-layer-fragment.glsl.ts +2 -2
- package/src/heatmap-layer/triangle-layer.ts +17 -23
- package/src/heatmap-layer/weights-vs.glsl.ts +4 -2
- package/typed/heatmap-layer/heatmap-layer-utils.d.ts +0 -9
- package/typed/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
- package/typed/heatmap-layer/heatmap-layer.d.ts +4 -4
- package/typed/heatmap-layer/heatmap-layer.d.ts.map +1 -1
- package/typed/heatmap-layer/max-vs.glsl.d.ts +1 -1
- package/typed/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
- package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts +1 -1
- package/typed/heatmap-layer/triangle-layer.d.ts +10 -2
- package/typed/heatmap-layer/triangle-layer.d.ts.map +1 -1
- package/typed/heatmap-layer/weights-vs.glsl.d.ts +1 -1
- package/typed/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
|
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _default = "#version 300 es\n#define SHADER_NAME triangle-layer-fragment-shader\n\nprecision highp float;\n\nuniform float opacity;\nuniform sampler2D
|
|
7
|
+
var _default = "#version 300 es\n#define SHADER_NAME triangle-layer-fragment-shader\n\nprecision highp float;\n\nuniform float opacity;\nuniform sampler2D weightsTexture;\nuniform sampler2D colorTexture;\nuniform float aggregationMode;\n\nin vec2 vTexCoords;\nin float vIntensityMin;\nin float vIntensityMax;\n\nout vec4 fragColor;\n\nvec4 getLinearColor(float value) {\n float factor = clamp(value * vIntensityMax, 0., 1.);\n vec4 color = texture(colorTexture, vec2(factor, 0.5));\n color.a *= min(value * vIntensityMin, 1.0);\n return color;\n}\n\nvoid main(void) {\n vec4 weights = texture(weightsTexture, vTexCoords);\n float weight = weights.r;\n\n if (aggregationMode > 0.5) {\n weight /= max(1.0, weights.a);\n }\n if (weight <= 0.) {\n discard;\n }\n\n vec4 linearColor = getLinearColor(weight);\n linearColor.a *= opacity;\n fragColor = linearColor;\n}\n";
|
|
8
8
|
exports.default = _default;
|
|
9
9
|
//# sourceMappingURL=triangle-layer-fragment.glsl.js.map
|
|
@@ -64,48 +64,47 @@ var TriangleLayer = function (_Layer) {
|
|
|
64
64
|
|
|
65
65
|
_proto.initializeState = function initializeState(_ref) {
|
|
66
66
|
var device = _ref.device;
|
|
67
|
-
var attributeManager = this.getAttributeManager();
|
|
68
|
-
attributeManager.add({
|
|
69
|
-
positions: {
|
|
70
|
-
size: 3,
|
|
71
|
-
noAlloc: true
|
|
72
|
-
},
|
|
73
|
-
texCoords: {
|
|
74
|
-
size: 2,
|
|
75
|
-
noAlloc: true
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
67
|
this.setState({
|
|
79
68
|
model: this._getModel(device)
|
|
80
69
|
});
|
|
81
70
|
};
|
|
82
71
|
|
|
83
72
|
_proto._getModel = function _getModel(device) {
|
|
84
|
-
var
|
|
73
|
+
var _this$props = this.props,
|
|
74
|
+
vertexCount = _this$props.vertexCount,
|
|
75
|
+
data = _this$props.data,
|
|
76
|
+
weightsTexture = _this$props.weightsTexture,
|
|
77
|
+
maxTexture = _this$props.maxTexture,
|
|
78
|
+
colorTexture = _this$props.colorTexture;
|
|
85
79
|
return new _engine.Model(device, _objectSpread(_objectSpread({}, this.getShaders()), {}, {
|
|
86
80
|
id: this.props.id,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
bindings: {
|
|
82
|
+
weightsTexture: weightsTexture,
|
|
83
|
+
maxTexture: maxTexture,
|
|
84
|
+
colorTexture: colorTexture
|
|
85
|
+
},
|
|
86
|
+
attributes: data.attributes,
|
|
87
|
+
bufferLayout: [{
|
|
88
|
+
name: 'positions',
|
|
89
|
+
format: 'float32x3'
|
|
90
|
+
}, {
|
|
91
|
+
name: 'texCoords',
|
|
92
|
+
format: 'float32x2'
|
|
93
|
+
}],
|
|
94
|
+
topology: 'triangle-fan-webgl',
|
|
95
|
+
vertexCount: vertexCount
|
|
91
96
|
}));
|
|
92
97
|
};
|
|
93
98
|
|
|
94
99
|
_proto.draw = function draw(_ref2) {
|
|
95
100
|
var uniforms = _ref2.uniforms;
|
|
96
101
|
var model = this.state.model;
|
|
97
|
-
var _this$
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
threshold = _this$props.threshold,
|
|
103
|
-
aggregationMode = _this$props.aggregationMode,
|
|
104
|
-
colorDomain = _this$props.colorDomain;
|
|
102
|
+
var _this$props2 = this.props,
|
|
103
|
+
intensity = _this$props2.intensity,
|
|
104
|
+
threshold = _this$props2.threshold,
|
|
105
|
+
aggregationMode = _this$props2.aggregationMode,
|
|
106
|
+
colorDomain = _this$props2.colorDomain;
|
|
105
107
|
model.setUniforms(_objectSpread(_objectSpread({}, uniforms), {}, {
|
|
106
|
-
texture: texture,
|
|
107
|
-
maxTexture: maxTexture,
|
|
108
|
-
colorTexture: colorTexture,
|
|
109
108
|
intensity: intensity,
|
|
110
109
|
threshold: threshold,
|
|
111
110
|
aggregationMode: aggregationMode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/heatmap-layer/triangle-layer.ts"],"names":["TriangleLayer","state","getShaders","vs","fs","modules","project32","initializeState","device","
|
|
1
|
+
{"version":3,"sources":["../../../src/heatmap-layer/triangle-layer.ts"],"names":["TriangleLayer","state","getShaders","vs","fs","modules","project32","initializeState","device","setState","model","_getModel","props","vertexCount","data","weightsTexture","maxTexture","colorTexture","Model","id","bindings","attributes","bufferLayout","name","format","topology","draw","uniforms","intensity","threshold","aggregationMode","colorDomain","setUniforms","context","renderPass","Layer","layerName"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA;;AACA;;AACA;;AACA;;;;;;;;;;IAcqBA,a;;;;;;;;;;;;;;;UAGnBC,K;;;;;;SAMAC,U,GAAA,sBAAa;AACX,WAAO;AAACC,MAAAA,EAAE,EAAFA,4BAAD;AAAKC,MAAAA,EAAE,EAAFA,8BAAL;AA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,gBAAkBA,SAAlB;AAAA,QAA6BC,eAA7B,gBAA6BA,eAA7B;AAAA,QAA8CC,WAA9C,gBAA8CA,WAA9C;AACArB,IAAAA,KAAK,CAACsB,WAAN,iCACKL,QADL;AAEEC,MAAAA,SAAS,EAATA,SAFF;AAGEC,MAAAA,SAAS,EAATA,SAHF;AAIEC,MAAAA,eAAe,EAAfA,eAJF;AAKEC,MAAAA,WAAW,EAAXA;AALF;AAOArB,IAAAA,KAAK,CAACgB,IAAN,CAAW,KAAKO,OAAL,CAAaC,UAAxB;AACD,G;;;EA7CwCC,W;;;AAAtBnC,a,CACZoC,S,GAAY,e","sourcesContent":["// Copyright (c) 2015 - 2019 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport type {Buffer, Device, Texture} from '@luma.gl/core';\nimport {Model} from '@luma.gl/engine';\nimport {Layer, LayerContext, project32} from '@deck.gl/core';\nimport vs from './triangle-layer-vertex.glsl';\nimport fs from './triangle-layer-fragment.glsl';\n\ntype _TriangleLayerProps = {\n data: {attributes: {positions: Buffer; texCoords: Buffer}};\n colorDomain: number[];\n aggregationMode: string;\n threshold: number;\n intensity: number;\n vertexCount: number;\n colorTexture: Texture;\n maxTexture: Texture;\n weightsTexture: Texture;\n};\n\nexport default class TriangleLayer extends Layer<_TriangleLayerProps> {\n static layerName = 'TriangleLayer';\n\n state!: {\n model: Model;\n positions: Buffer;\n texCoords: Buffer;\n };\n\n getShaders() {\n return {vs, fs, modules: [project32]};\n }\n\n initializeState({device}: LayerContext): void {\n this.setState({model: this._getModel(device)});\n }\n\n _getModel(device: Device): Model {\n const {vertexCount, data, weightsTexture, maxTexture, colorTexture} = this.props;\n\n return new Model(device, {\n ...this.getShaders(),\n id: this.props.id,\n bindings: {weightsTexture, maxTexture, colorTexture},\n attributes: data.attributes,\n bufferLayout: [\n {name: 'positions', format: 'float32x3'},\n {name: 'texCoords', format: 'float32x2'}\n ],\n topology: 'triangle-fan-webgl',\n vertexCount\n });\n }\n\n draw({uniforms}): void {\n const {model} = this.state;\n const {intensity, threshold, aggregationMode, colorDomain} = this.props;\n model.setUniforms({\n ...uniforms,\n intensity,\n threshold,\n aggregationMode,\n colorDomain\n });\n model.draw(this.context.renderPass);\n }\n}\n"],"file":"triangle-layer.js"}
|
|
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _default = "#version 300 es\nin vec3 positions;\nin vec3 positions64Low;\nin float weights;\nout vec4 weightsTexture;\nuniform float radiusPixels;\nuniform float textureWidth;\nuniform vec4 commonBounds;\nuniform float weightsScale;\nvoid main()\n{\n weightsTexture = vec4(weights * weightsScale, 0., 0., 1.);\n\n float radiusTexels
|
|
7
|
+
var _default = "#version 300 es\nin vec3 positions;\nin vec3 positions64Low;\nin float weights;\nout vec4 weightsTexture;\nuniform float radiusPixels;\nuniform float textureWidth;\nuniform vec4 commonBounds;\nuniform float weightsScale;\n\nvoid main()\n{\n weightsTexture = vec4(weights * weightsScale, 0., 0., 1.);\n\n float radiusTexels = project_pixel_size(radiusPixels) * textureWidth / (commonBounds.z - commonBounds.x);\n gl_PointSize = radiusTexels * 2.;\n\n vec3 commonPosition = project_position(positions, positions64Low);\n gl_Position.xy = (commonPosition.xy - commonBounds.xy) / (commonBounds.zw - commonBounds.xy) ;\n gl_Position.xy = (gl_Position.xy * 2.) - (1.);\n gl_Position.w = 1.0;\n}\n";
|
|
8
8
|
exports.default = _default;
|
|
9
9
|
//# sourceMappingURL=weights-vs.glsl.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { GL } from '@luma.gl/constants';
|
|
2
1
|
export function getBounds(points) {
|
|
3
2
|
const x = points.map(p => p[0]);
|
|
4
3
|
const y = points.map(p => p[1]);
|
|
@@ -53,16 +52,4 @@ export function getTextureCoordinates(point, bounds) {
|
|
|
53
52
|
const [xMin, yMin, xMax, yMax] = bounds;
|
|
54
53
|
return [(point[0] - xMin) / (xMax - xMin), (point[1] - yMin) / (yMax - yMin)];
|
|
55
54
|
}
|
|
56
|
-
export function getTextureParams({
|
|
57
|
-
device,
|
|
58
|
-
floatTargetSupport
|
|
59
|
-
}) {
|
|
60
|
-
return floatTargetSupport ? {
|
|
61
|
-
format: device.info.type === 'webgl2' ? 34836 : 6408,
|
|
62
|
-
type: 5126
|
|
63
|
-
} : {
|
|
64
|
-
format: 6408,
|
|
65
|
-
type: 5121
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
55
|
//# sourceMappingURL=heatmap-layer-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/heatmap-layer/heatmap-layer-utils.ts"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../src/heatmap-layer/heatmap-layer-utils.ts"],"names":["getBounds","points","x","map","p","y","xMin","Math","min","apply","xMax","max","yMin","yMax","boundsContain","currentBounds","targetBounds","scratchArray","Float32Array","packVertices","dimensions","index","point","i","scaleToAspectRatio","boundingBox","width","height","currentWidth","currentHeight","newWidth","newHeight","xCenter","yCenter","getTextureCoordinates","bounds"],"mappings":"AAAA,OAAO,SAASA,SAAT,CAAmBC,MAAnB,EAAiD;AAEtD,QAAMC,CAAC,GAAGD,MAAM,CAACE,GAAP,CAAWC,CAAC,IAAIA,CAAC,CAAC,CAAD,CAAjB,CAAV;AACA,QAAMC,CAAC,GAAGJ,MAAM,CAACE,GAAP,CAAWC,CAAC,IAAIA,CAAC,CAAC,CAAD,CAAjB,CAAV;AAEA,QAAME,IAAI,GAAGC,IAAI,CAACC,GAAL,CAASC,KAAT,CAAe,IAAf,EAAqBP,CAArB,CAAb;AACA,QAAMQ,IAAI,GAAGH,IAAI,CAACI,GAAL,CAASF,KAAT,CAAe,IAAf,EAAqBP,CAArB,CAAb;AACA,QAAMU,IAAI,GAAGL,IAAI,CAACC,GAAL,CAASC,KAAT,CAAe,IAAf,EAAqBJ,CAArB,CAAb;AACA,QAAMQ,IAAI,GAAGN,IAAI,CAACI,GAAL,CAASF,KAAT,CAAe,IAAf,EAAqBJ,CAArB,CAAb;AAEA,SAAO,CAACC,IAAD,EAAOM,IAAP,EAAaF,IAAb,EAAmBG,IAAnB,CAAP;AACD;AAGD,OAAO,SAASC,aAAT,CAAuBC,aAAvB,EAAgDC,YAAhD,EAAiF;AACtF,MACEA,YAAY,CAAC,CAAD,CAAZ,IAAmBD,aAAa,CAAC,CAAD,CAAhC,IACAC,YAAY,CAAC,CAAD,CAAZ,IAAmBD,aAAa,CAAC,CAAD,CADhC,IAEAC,YAAY,CAAC,CAAD,CAAZ,IAAmBD,aAAa,CAAC,CAAD,CAFhC,IAGAC,YAAY,CAAC,CAAD,CAAZ,IAAmBD,aAAa,CAAC,CAAD,CAJlC,EAKE;AACA,WAAO,IAAP;AACD;;AACD,SAAO,KAAP;AACD;AAED,MAAME,YAAY,GAAG,IAAIC,YAAJ,CAAiB,EAAjB,CAArB;AAGA,OAAO,SAASC,YAAT,CAAsB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B,EAGLC,OAAO,GAAGF,QAAQ,GAAG,CAHhB,EAILG,OAAO,GAAGF,SAAS,GAAG,CAJjB,CAAP;AAMD;AAGD,OAAO,SAASG,qBAAT,CAA+BZ,KAA/B,EAAgDa,MAAhD,EAAkE;AACvE,QAAM,CAAC7B,IAAD,EAAOM,IAAP,EAAaF,IAAb,EAAmBG,IAAnB,IAA2BsB,MAAjC;AACA,SAAO,CAAC,CAACb,KAAK,CAAC,CAAD,CAAL,GAAWhB,IAAZ,KAAqBI,IAAI,GAAGJ,IAA5B,CAAD,EAAoC,CAACgB,KAAK,CAAC,CAAD,CAAL,GAAWV,IAAZ,KAAqBC,IAAI,GAAGD,IAA5B,CAApC,CAAP;AACD","sourcesContent":["export function getBounds(points: number[][]): number[] {\n // Now build bounding box in world space (aligned to world coordiante system)\n const x = points.map(p => p[0]);\n const y = points.map(p => p[1]);\n\n const xMin = Math.min.apply(null, x);\n const xMax = Math.max.apply(null, x);\n const yMin = Math.min.apply(null, y);\n const yMax = Math.max.apply(null, y);\n\n return [xMin, yMin, xMax, yMax];\n}\n\n// true if currentBounds contains targetBounds, false otherwise\nexport function boundsContain(currentBounds: number[], targetBounds: number[]): boolean {\n if (\n targetBounds[0] >= currentBounds[0] &&\n targetBounds[2] <= currentBounds[2] &&\n targetBounds[1] >= currentBounds[1] &&\n targetBounds[3] <= currentBounds[3]\n ) {\n return true;\n }\n return false;\n}\n\nconst scratchArray = new Float32Array(12);\n\n// For given rectangle bounds generates two triangles vertices that coverit completely\nexport function packVertices(points: number[][], dimensions: number = 2): Float32Array {\n let index = 0;\n for (const point of points) {\n for (let i = 0; i < dimensions; i++) {\n scratchArray[index++] = point[i] || 0;\n }\n }\n return scratchArray;\n}\n\n// Expands boundingBox:[xMin, yMin, xMax, yMax] to match aspect ratio of given width and height\nexport function scaleToAspectRatio(boundingBox: number[], width: number, height: number): number[] {\n const [xMin, yMin, xMax, yMax] = boundingBox;\n\n const currentWidth = xMax - xMin;\n const currentHeight = yMax - yMin;\n\n let newWidth = currentWidth;\n let newHeight = currentHeight;\n if (currentWidth / currentHeight < width / height) {\n // expand bounding box width\n newWidth = (width / height) * currentHeight;\n } else {\n newHeight = (height / width) * currentWidth;\n }\n\n if (newWidth < width) {\n newWidth = width;\n newHeight = height;\n }\n\n const xCenter = (xMax + xMin) / 2;\n const yCenter = (yMax + yMin) / 2;\n\n return [\n xCenter - newWidth / 2,\n yCenter - newHeight / 2,\n xCenter + newWidth / 2,\n yCenter + newHeight / 2\n ];\n}\n\n// Get texture coordiante of point inside a bounding box\nexport function getTextureCoordinates(point: number[], bounds: number[]) {\n const [xMin, yMin, xMax, yMax] = bounds;\n return [(point[0] - xMin) / (xMax - xMin), (point[1] - yMin) / (yMax - yMin)];\n}\n"],"file":"heatmap-layer-utils.js"}
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import { getBounds, boundsContain, packVertices, scaleToAspectRatio, getTextureCoordinates
|
|
1
|
+
import { getBounds, boundsContain, packVertices, scaleToAspectRatio, getTextureCoordinates } from './heatmap-layer-utils';
|
|
2
2
|
import { GL } from '@luma.gl/constants';
|
|
3
3
|
import { TextureTransform } from '@luma.gl/engine';
|
|
4
|
-
import { withGLParameters } from '@luma.gl/webgl';
|
|
5
4
|
import { AttributeManager, COORDINATE_SYSTEM, log } from '@deck.gl/core';
|
|
6
5
|
import TriangleLayer from './triangle-layer';
|
|
7
6
|
import AggregationLayer from '../aggregation-layer';
|
|
8
7
|
import { defaultColorRange, colorRangeToFlatArray } from '../utils/color-utils';
|
|
9
8
|
import weightsVs from './weights-vs.glsl';
|
|
10
9
|
import weightsFs from './weights-fs.glsl';
|
|
11
|
-
import
|
|
12
|
-
import
|
|
10
|
+
import maxVs from './max-vs.glsl';
|
|
11
|
+
import maxFs from './max-fs.glsl';
|
|
13
12
|
const RESOLUTION = 2;
|
|
14
13
|
const TEXTURE_PROPS = {
|
|
15
14
|
format: 'rgba8unorm',
|
|
16
15
|
mipmaps: false,
|
|
17
16
|
sampler: {
|
|
18
|
-
minFilter: '
|
|
19
|
-
magFilter: '
|
|
17
|
+
minFilter: 'linear',
|
|
18
|
+
magFilter: 'linear',
|
|
20
19
|
addressModeU: 'clamp-to-edge',
|
|
21
20
|
addressModeV: 'clamp-to-edge'
|
|
22
21
|
}
|
|
@@ -194,7 +193,7 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
194
193
|
maxTexture: maxWeightsTexture,
|
|
195
194
|
colorTexture,
|
|
196
195
|
aggregationMode: AGGREGATION_MODE[aggregation] || 0,
|
|
197
|
-
|
|
196
|
+
weightsTexture,
|
|
198
197
|
intensity,
|
|
199
198
|
threshold,
|
|
200
199
|
colorDomain
|
|
@@ -257,21 +256,18 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
257
256
|
_createTextures() {
|
|
258
257
|
const {
|
|
259
258
|
textureSize,
|
|
260
|
-
format
|
|
261
|
-
type
|
|
259
|
+
format
|
|
262
260
|
} = this.state;
|
|
263
261
|
this.setState({
|
|
264
|
-
weightsTexture: this.context.device.createTexture({
|
|
262
|
+
weightsTexture: this.context.device.createTexture({ ...TEXTURE_PROPS,
|
|
265
263
|
width: textureSize,
|
|
266
264
|
height: textureSize,
|
|
267
|
-
format
|
|
268
|
-
type,
|
|
269
|
-
...TEXTURE_PROPS
|
|
265
|
+
format
|
|
270
266
|
}),
|
|
271
|
-
maxWeightsTexture: this.context.device.createTexture({
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
267
|
+
maxWeightsTexture: this.context.device.createTexture({ ...TEXTURE_PROPS,
|
|
268
|
+
width: 1,
|
|
269
|
+
height: 1,
|
|
270
|
+
format
|
|
275
271
|
})
|
|
276
272
|
});
|
|
277
273
|
}
|
|
@@ -303,48 +299,44 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
303
299
|
} = this.props;
|
|
304
300
|
const textureSize = Math.min(weightsTextureSize, device.limits.maxTextureDimension2D);
|
|
305
301
|
const floatTargetSupport = FLOAT_TARGET_FEATURES.every(feature => device.features.has(feature));
|
|
306
|
-
const
|
|
307
|
-
format,
|
|
308
|
-
type
|
|
309
|
-
} = getTextureParams({
|
|
310
|
-
device,
|
|
311
|
-
floatTargetSupport
|
|
312
|
-
});
|
|
302
|
+
const format = floatTargetSupport ? 'rgba32float' : 'rgba8unorm';
|
|
313
303
|
const weightsScale = floatTargetSupport ? 1 : 1 / 255;
|
|
314
304
|
this.setState({
|
|
315
305
|
textureSize,
|
|
316
306
|
format,
|
|
317
|
-
type,
|
|
318
307
|
weightsScale
|
|
319
308
|
});
|
|
320
309
|
|
|
321
310
|
if (!floatTargetSupport) {
|
|
322
|
-
log.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported,
|
|
311
|
+
log.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)();
|
|
323
312
|
}
|
|
324
313
|
}
|
|
325
314
|
|
|
326
|
-
|
|
327
|
-
return super.getShaders(type === 'max-weights-transform' ? {
|
|
328
|
-
vs: vsMax,
|
|
329
|
-
_fs: fsMax
|
|
330
|
-
} : {
|
|
331
|
-
vs: weightsVs,
|
|
332
|
-
_fs: weightsFs
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
_createWeightsTransform(shaders = {}) {
|
|
315
|
+
_createWeightsTransform(shaders) {
|
|
337
316
|
var _weightsTransform;
|
|
338
317
|
|
|
339
318
|
let {
|
|
340
319
|
weightsTransform
|
|
341
320
|
} = this.state;
|
|
342
|
-
|
|
321
|
+
const {
|
|
322
|
+
weightsTexture
|
|
323
|
+
} = this.state;
|
|
324
|
+
const attributeManager = this.getAttributeManager();
|
|
325
|
+
(_weightsTransform = weightsTransform) === null || _weightsTransform === void 0 ? void 0 : _weightsTransform.destroy();
|
|
343
326
|
weightsTransform = new TextureTransform(this.context.device, {
|
|
344
327
|
id: `${this.id}-weights-transform`,
|
|
328
|
+
bufferLayout: attributeManager.getBufferLayouts(),
|
|
345
329
|
vertexCount: 1,
|
|
346
|
-
targetTexture:
|
|
347
|
-
|
|
330
|
+
targetTexture: weightsTexture,
|
|
331
|
+
parameters: {
|
|
332
|
+
depthWriteEnabled: false,
|
|
333
|
+
blendColorOperation: 'add',
|
|
334
|
+
blendColorSrcFactor: 'one',
|
|
335
|
+
blendColorDstFactor: 'one',
|
|
336
|
+
blendAlphaSrcFactor: 'one',
|
|
337
|
+
blendAlphaDstFactor: 'one'
|
|
338
|
+
},
|
|
339
|
+
topology: 'point-list',
|
|
348
340
|
...shaders
|
|
349
341
|
});
|
|
350
342
|
this.setState({
|
|
@@ -355,61 +347,79 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
355
347
|
_setupResources() {
|
|
356
348
|
this._createTextures();
|
|
357
349
|
|
|
350
|
+
const {
|
|
351
|
+
device
|
|
352
|
+
} = this.context;
|
|
358
353
|
const {
|
|
359
354
|
textureSize,
|
|
360
355
|
weightsTexture,
|
|
361
356
|
maxWeightsTexture
|
|
362
357
|
} = this.state;
|
|
363
|
-
const weightsTransformShaders = this.getShaders(
|
|
358
|
+
const weightsTransformShaders = this.getShaders({
|
|
359
|
+
vs: weightsVs,
|
|
360
|
+
fs: weightsFs
|
|
361
|
+
});
|
|
364
362
|
|
|
365
363
|
this._createWeightsTransform(weightsTransformShaders);
|
|
366
364
|
|
|
367
|
-
const maxWeightsTransformShaders = this.getShaders(
|
|
368
|
-
|
|
365
|
+
const maxWeightsTransformShaders = this.getShaders({
|
|
366
|
+
vs: maxVs,
|
|
367
|
+
fs: maxFs
|
|
368
|
+
});
|
|
369
|
+
const maxWeightTransform = new TextureTransform(device, {
|
|
369
370
|
id: `${this.id}-max-weights-transform`,
|
|
370
|
-
|
|
371
|
+
bindings: {
|
|
371
372
|
inTexture: weightsTexture
|
|
372
373
|
},
|
|
373
|
-
|
|
374
|
-
|
|
374
|
+
uniforms: {
|
|
375
|
+
textureSize
|
|
376
|
+
},
|
|
377
|
+
targetTexture: maxWeightsTexture,
|
|
375
378
|
...maxWeightsTransformShaders,
|
|
376
|
-
|
|
379
|
+
vertexCount: textureSize * textureSize,
|
|
380
|
+
topology: 'point-list',
|
|
381
|
+
parameters: {
|
|
382
|
+
depthWriteEnabled: false,
|
|
383
|
+
blendColorOperation: 'max',
|
|
384
|
+
blendAlphaOperation: 'max',
|
|
385
|
+
blendColorSrcFactor: 'one',
|
|
386
|
+
blendColorDstFactor: 'one',
|
|
387
|
+
blendAlphaSrcFactor: 'one',
|
|
388
|
+
blendAlphaDstFactor: 'one'
|
|
389
|
+
}
|
|
377
390
|
});
|
|
378
391
|
this.setState({
|
|
379
392
|
weightsTexture,
|
|
380
393
|
maxWeightsTexture,
|
|
381
394
|
maxWeightTransform,
|
|
382
395
|
zoom: null,
|
|
383
|
-
triPositionBuffer:
|
|
384
|
-
byteLength: 48
|
|
385
|
-
accessor: {
|
|
386
|
-
size: 3
|
|
387
|
-
}
|
|
396
|
+
triPositionBuffer: device.createBuffer({
|
|
397
|
+
byteLength: 48
|
|
388
398
|
}),
|
|
389
|
-
triTexCoordBuffer:
|
|
390
|
-
byteLength: 48
|
|
391
|
-
accessor: {
|
|
392
|
-
size: 2
|
|
393
|
-
}
|
|
399
|
+
triTexCoordBuffer: device.createBuffer({
|
|
400
|
+
byteLength: 48
|
|
394
401
|
})
|
|
395
402
|
});
|
|
396
403
|
}
|
|
397
404
|
|
|
398
405
|
updateShaders(shaderOptions) {
|
|
399
|
-
this._createWeightsTransform(
|
|
406
|
+
this._createWeightsTransform({
|
|
407
|
+
vs: weightsVs,
|
|
408
|
+
fs: weightsFs,
|
|
409
|
+
...shaderOptions
|
|
410
|
+
});
|
|
400
411
|
}
|
|
401
412
|
|
|
402
413
|
_updateMaxWeightValue() {
|
|
403
414
|
const {
|
|
404
|
-
maxWeightTransform
|
|
415
|
+
maxWeightTransform,
|
|
416
|
+
textureSize
|
|
405
417
|
} = this.state;
|
|
406
418
|
maxWeightTransform.run({
|
|
407
419
|
parameters: {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
blendEquation: 32776
|
|
412
|
-
}
|
|
420
|
+
viewport: [0, 0, 1, 1]
|
|
421
|
+
},
|
|
422
|
+
clearColor: [0, 0, 0, 0]
|
|
413
423
|
});
|
|
414
424
|
}
|
|
415
425
|
|
|
@@ -464,6 +474,8 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
464
474
|
}
|
|
465
475
|
|
|
466
476
|
_updateColorTexture(opts) {
|
|
477
|
+
var _colorTexture;
|
|
478
|
+
|
|
467
479
|
const {
|
|
468
480
|
colorRange
|
|
469
481
|
} = opts.props;
|
|
@@ -472,17 +484,18 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
472
484
|
} = this.state;
|
|
473
485
|
const colors = colorRangeToFlatArray(colorRange, false, Uint8Array);
|
|
474
486
|
|
|
475
|
-
if (colorTexture) {
|
|
476
|
-
colorTexture.
|
|
477
|
-
data: colors
|
|
478
|
-
width: colorRange.length
|
|
487
|
+
if (colorTexture && ((_colorTexture = colorTexture) === null || _colorTexture === void 0 ? void 0 : _colorTexture.width) === colorRange.length) {
|
|
488
|
+
colorTexture.setSubImageData({
|
|
489
|
+
data: colors
|
|
479
490
|
});
|
|
480
491
|
} else {
|
|
481
|
-
|
|
492
|
+
var _colorTexture2;
|
|
493
|
+
|
|
494
|
+
(_colorTexture2 = colorTexture) === null || _colorTexture2 === void 0 ? void 0 : _colorTexture2.destroy();
|
|
495
|
+
colorTexture = this.context.device.createTexture({ ...TEXTURE_PROPS,
|
|
482
496
|
data: colors,
|
|
483
497
|
width: colorRange.length,
|
|
484
|
-
height: 1
|
|
485
|
-
...TEXTURE_PROPS
|
|
498
|
+
height: 1
|
|
486
499
|
});
|
|
487
500
|
}
|
|
488
501
|
|
|
@@ -519,30 +532,29 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
519
532
|
this.state.colorDomain = colorDomain || DEFAULT_COLOR_DOMAIN;
|
|
520
533
|
}
|
|
521
534
|
|
|
535
|
+
const attributeManager = this.getAttributeManager();
|
|
536
|
+
const attributes = attributeManager.getAttributes();
|
|
537
|
+
const moduleSettings = this.getModuleSettings();
|
|
538
|
+
const positions = attributes.positions.buffer;
|
|
522
539
|
const uniforms = {
|
|
523
540
|
radiusPixels,
|
|
524
541
|
commonBounds,
|
|
525
542
|
textureWidth: textureSize,
|
|
526
543
|
weightsScale
|
|
527
544
|
};
|
|
528
|
-
|
|
529
|
-
|
|
545
|
+
const weights = attributes.weights.buffer;
|
|
546
|
+
weightsTransform.model.setAttributes({
|
|
547
|
+
positions,
|
|
548
|
+
weights
|
|
530
549
|
});
|
|
531
|
-
|
|
550
|
+
weightsTransform.model.setVertexCount(this.getNumInstances());
|
|
551
|
+
weightsTransform.model.setUniforms(uniforms);
|
|
552
|
+
weightsTransform.model.updateModuleSettings(moduleSettings);
|
|
553
|
+
weightsTransform.run({
|
|
554
|
+
parameters: {
|
|
555
|
+
viewport: [0, 0, textureSize, textureSize]
|
|
556
|
+
},
|
|
532
557
|
clearColor: [0, 0, 0, 0]
|
|
533
|
-
}, () => {
|
|
534
|
-
weightsTransform.run({
|
|
535
|
-
uniforms,
|
|
536
|
-
parameters: {
|
|
537
|
-
blend: true,
|
|
538
|
-
depthTest: false,
|
|
539
|
-
blendFunc: [1, 1],
|
|
540
|
-
blendEquation: 32774
|
|
541
|
-
},
|
|
542
|
-
clearRenderTarget: true,
|
|
543
|
-
attributes: this.getAttributes(),
|
|
544
|
-
moduleSettings: this.getModuleSettings()
|
|
545
|
-
});
|
|
546
558
|
});
|
|
547
559
|
|
|
548
560
|
this._updateMaxWeightValue();
|