@deck.gl/aggregation-layers 8.8.5 → 8.8.6

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.
Files changed (49) hide show
  1. package/dist/dist.dev.js +246 -246
  2. package/package.json +2 -2
  3. package/typed/utils/bin-sorter.d.ts +1 -1
  4. package/typed/aggregation-layer.js +0 -151
  5. package/typed/contour-layer/contour-layer.js +0 -234
  6. package/typed/contour-layer/contour-utils.js +0 -64
  7. package/typed/contour-layer/marching-squares-codes.js +0 -337
  8. package/typed/contour-layer/marching-squares.js +0 -147
  9. package/typed/cpu-grid-layer/cpu-grid-layer.js +0 -129
  10. package/typed/cpu-grid-layer/grid-aggregator.js +0 -141
  11. package/typed/gpu-grid-layer/gpu-grid-cell-layer-fragment.glsl.js +0 -34
  12. package/typed/gpu-grid-layer/gpu-grid-cell-layer-vertex.glsl.js +0 -141
  13. package/typed/gpu-grid-layer/gpu-grid-cell-layer.js +0 -143
  14. package/typed/gpu-grid-layer/gpu-grid-layer.js +0 -289
  15. package/typed/grid-aggregation-layer.js +0 -172
  16. package/typed/grid-layer/grid-layer.js +0 -60
  17. package/typed/heatmap-layer/heatmap-layer-utils.js +0 -78
  18. package/typed/heatmap-layer/heatmap-layer.js +0 -478
  19. package/typed/heatmap-layer/max-fs.glsl.js +0 -7
  20. package/typed/heatmap-layer/max-vs.glsl.js +0 -12
  21. package/typed/heatmap-layer/triangle-layer-fragment.glsl.js +0 -58
  22. package/typed/heatmap-layer/triangle-layer-vertex.glsl.js +0 -51
  23. package/typed/heatmap-layer/triangle-layer.js +0 -67
  24. package/typed/heatmap-layer/weights-fs.glsl.js +0 -19
  25. package/typed/heatmap-layer/weights-vs.glsl.js +0 -23
  26. package/typed/hexagon-layer/hexagon-aggregator.js +0 -112
  27. package/typed/hexagon-layer/hexagon-layer.js +0 -171
  28. package/typed/index.js +0 -33
  29. package/typed/screen-grid-layer/screen-grid-cell-layer.js +0 -159
  30. package/typed/screen-grid-layer/screen-grid-layer-fragment.glsl.js +0 -37
  31. package/typed/screen-grid-layer/screen-grid-layer-vertex.glsl.js +0 -83
  32. package/typed/screen-grid-layer/screen-grid-layer.js +0 -216
  33. package/typed/types.js +0 -1
  34. package/typed/utils/aggregation-operation-utils.js +0 -94
  35. package/typed/utils/bin-sorter.js +0 -167
  36. package/typed/utils/color-utils.js +0 -53
  37. package/typed/utils/cpu-aggregator.js +0 -417
  38. package/typed/utils/gpu-grid-aggregation/aggregate-all-fs.glsl.js +0 -39
  39. package/typed/utils/gpu-grid-aggregation/aggregate-all-vs.glsl.js +0 -53
  40. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-fs.glsl.js +0 -31
  41. package/typed/utils/gpu-grid-aggregation/aggregate-to-grid-vs.glsl.js +0 -77
  42. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-constants.js +0 -41
  43. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator-utils.js +0 -1
  44. package/typed/utils/gpu-grid-aggregation/gpu-grid-aggregator.js +0 -562
  45. package/typed/utils/gpu-grid-aggregation/transform-mean-vs.glsl.js +0 -36
  46. package/typed/utils/grid-aggregation-utils.js +0 -114
  47. package/typed/utils/prop-utils.js +0 -28
  48. package/typed/utils/resource-utils.js +0 -40
  49. package/typed/utils/scale-utils.js +0 -184
@@ -1,141 +0,0 @@
1
- // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
20
- import { createIterable } from '@deck.gl/core';
21
- import { getGridOffset } from '../utils/grid-aggregation-utils';
22
- /**
23
- * Calculate density grid from an array of points
24
- * @param {Object} props - object containing :
25
- * @param {Iterable} [props.data] - data objects to be aggregated
26
- * @param {Integer} [props.cellSize] - size of the grid cell
27
- *
28
- * @param {Object} aggregationParams - object containing :
29
- * @param {Object} gridOffset - {xOffset, yOffset} cell size in meters
30
- * @param {Integer} width - width of the grid
31
- * @param {Integer} height - height of the grid
32
- * @param {Boolean} projectPoints - `true` if doing screen space projection, `false` otherwise
33
- * @param {Array} attributes - attributes array containing position values
34
- * @param {Viewport} viewport - viewport to be used for projection
35
- * @param {Array} posOffset - [xOffset, yOffset] offset to be applied to positions to get cell index
36
- * @param {Object} boundingBox - {xMin, yMin, xMax, yMax} bounding box of input data
37
- *
38
- * @returns {object} - grid data, cell dimension
39
- */
40
- export function pointToDensityGridDataCPU(props, aggregationParams) {
41
- const hashInfo = pointsToGridHashing(props, aggregationParams);
42
- const result = getGridLayerDataFromGridHash(hashInfo);
43
- return {
44
- gridHash: hashInfo.gridHash,
45
- gridOffset: hashInfo.gridOffset,
46
- data: result
47
- };
48
- }
49
- /**
50
- * Project points into each cell, return a hash table of cells
51
- * @param {Iterable} points
52
- * @param {number} cellSize - unit size in meters
53
- * @param {function} getPosition - position accessor
54
- * @returns {object} - grid hash and cell dimension
55
- */
56
- /* eslint-disable max-statements, complexity */
57
- function pointsToGridHashing(props, aggregationParams) {
58
- const { data = [], cellSize } = props;
59
- const { attributes, viewport, projectPoints, numInstances } = aggregationParams;
60
- const positions = attributes.positions.value;
61
- const { size } = attributes.positions.getAccessor();
62
- const boundingBox = aggregationParams.boundingBox || getPositionBoundingBox(attributes.positions, numInstances);
63
- const offsets = aggregationParams.posOffset || [180, 90];
64
- const gridOffset = aggregationParams.gridOffset || getGridOffset(boundingBox, cellSize);
65
- if (gridOffset.xOffset <= 0 || gridOffset.yOffset <= 0) {
66
- return { gridHash: {}, gridOffset };
67
- }
68
- const { width, height } = viewport;
69
- const numCol = Math.ceil(width / gridOffset.xOffset);
70
- const numRow = Math.ceil(height / gridOffset.yOffset);
71
- // calculate count per cell
72
- const gridHash = {};
73
- const { iterable, objectInfo } = createIterable(data);
74
- const position = new Array(3);
75
- for (const pt of iterable) {
76
- objectInfo.index++;
77
- position[0] = positions[objectInfo.index * size];
78
- position[1] = positions[objectInfo.index * size + 1];
79
- position[2] = size >= 3 ? positions[objectInfo.index * size + 2] : 0;
80
- const [x, y] = projectPoints ? viewport.project(position) : position;
81
- if (Number.isFinite(x) && Number.isFinite(y)) {
82
- const yIndex = Math.floor((y + offsets[1]) / gridOffset.yOffset);
83
- const xIndex = Math.floor((x + offsets[0]) / gridOffset.xOffset);
84
- if (!projectPoints ||
85
- // when doing screen space agggregation (projectPoints = true), filter points outside of the viewport range.
86
- (xIndex >= 0 && xIndex < numCol && yIndex >= 0 && yIndex < numRow)) {
87
- const key = `${yIndex}-${xIndex}`;
88
- gridHash[key] = gridHash[key] || { count: 0, points: [], lonIdx: xIndex, latIdx: yIndex };
89
- gridHash[key].count += 1;
90
- gridHash[key].points.push({
91
- source: pt,
92
- index: objectInfo.index
93
- });
94
- }
95
- }
96
- }
97
- return { gridHash, gridOffset, offsets: [offsets[0] * -1, offsets[1] * -1] };
98
- }
99
- /* eslint-enable max-statements, complexity */
100
- function getGridLayerDataFromGridHash({ gridHash, gridOffset, offsets }) {
101
- const data = new Array(Object.keys(gridHash).length);
102
- let i = 0;
103
- for (const key in gridHash) {
104
- const idxs = key.split('-');
105
- const latIdx = parseInt(idxs[0], 10);
106
- const lonIdx = parseInt(idxs[1], 10);
107
- const index = i++;
108
- data[index] = {
109
- index,
110
- position: [
111
- offsets[0] + gridOffset.xOffset * lonIdx,
112
- offsets[1] + gridOffset.yOffset * latIdx
113
- ],
114
- ...gridHash[key]
115
- };
116
- }
117
- return data;
118
- }
119
- // Calculate bounding box of position attribute
120
- function getPositionBoundingBox(positionAttribute, numInstance) {
121
- // TODO - value might not exist (e.g. attribute transition)
122
- const positions = positionAttribute.value;
123
- const { size } = positionAttribute.getAccessor();
124
- let yMin = Infinity;
125
- let yMax = -Infinity;
126
- let xMin = Infinity;
127
- let xMax = -Infinity;
128
- let y;
129
- let x;
130
- for (let i = 0; i < numInstance; i++) {
131
- x = positions[i * size];
132
- y = positions[i * size + 1];
133
- if (Number.isFinite(x) && Number.isFinite(y)) {
134
- yMin = y < yMin ? y : yMin;
135
- yMax = y > yMax ? y : yMax;
136
- xMin = x < xMin ? x : xMin;
137
- xMax = x > xMax ? x : xMax;
138
- }
139
- }
140
- return { xMin, xMax, yMin, yMax };
141
- }
@@ -1,34 +0,0 @@
1
- // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
20
- export default `\
21
- #version 300 es
22
- #define SHADER_NAME gpu-grid-cell-layer-fragment-shader
23
-
24
- precision highp float;
25
-
26
- in vec4 vColor;
27
-
28
- out vec4 fragColor;
29
-
30
- void main(void) {
31
- fragColor = vColor;
32
- fragColor = picking_filterColor(fragColor);
33
- }
34
- `;
@@ -1,141 +0,0 @@
1
- // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
20
- // Inspired by screen-grid-layer vertex shader in deck.gl
21
- export default `\
22
- #version 300 es
23
- #define SHADER_NAME gpu-grid-cell-layer-vertex-shader
24
- #define RANGE_COUNT 6
25
-
26
- in vec3 positions;
27
- in vec3 normals;
28
-
29
- in vec4 colors;
30
- in vec4 elevations;
31
- in vec3 instancePickingColors;
32
-
33
- // Custom uniforms
34
- uniform vec2 offset;
35
- uniform bool extruded;
36
- uniform float cellSize;
37
- uniform float coverage;
38
- uniform float opacity;
39
- uniform float elevationScale;
40
-
41
- uniform ivec2 gridSize;
42
- uniform vec2 gridOrigin;
43
- uniform vec2 gridOriginLow;
44
- uniform vec2 gridOffset;
45
- uniform vec2 gridOffsetLow;
46
- uniform vec4 colorRange[RANGE_COUNT];
47
- uniform vec2 elevationRange;
48
-
49
- // Domain uniforms
50
- uniform vec2 colorDomain;
51
- uniform bool colorDomainValid;
52
- uniform vec2 elevationDomain;
53
- uniform bool elevationDomainValid;
54
-
55
- layout(std140) uniform;
56
- uniform ColorData
57
- {
58
- vec4 maxMinCount;
59
- } colorData;
60
- uniform ElevationData
61
- {
62
- vec4 maxMinCount;
63
- } elevationData;
64
-
65
- #define EPSILON 0.00001
66
-
67
- // Result
68
- out vec4 vColor;
69
-
70
- vec4 quantizeScale(vec2 domain, vec4 range[RANGE_COUNT], float value) {
71
- vec4 outColor = vec4(0., 0., 0., 0.);
72
- if (value >= (domain.x - EPSILON) && value <= (domain.y + EPSILON)) {
73
- float domainRange = domain.y - domain.x;
74
- if (domainRange <= 0.) {
75
- outColor = colorRange[0];
76
- } else {
77
- float rangeCount = float(RANGE_COUNT);
78
- float rangeStep = domainRange / rangeCount;
79
- float idx = floor((value - domain.x) / rangeStep);
80
- idx = clamp(idx, 0., rangeCount - 1.);
81
- int intIdx = int(idx);
82
- outColor = colorRange[intIdx];
83
- }
84
- }
85
- return outColor;
86
- }
87
-
88
- float linearScale(vec2 domain, vec2 range, float value) {
89
- if (value >= (domain.x - EPSILON) && value <= (domain.y + EPSILON)) {
90
- return ((value - domain.x) / (domain.y - domain.x)) * (range.y - range.x) + range.x;
91
- }
92
- return -1.;
93
- }
94
-
95
- void main(void) {
96
- vec2 clrDomain = colorDomainValid ? colorDomain : vec2(colorData.maxMinCount.a, colorData.maxMinCount.r);
97
- vec4 color = quantizeScale(clrDomain, colorRange, colors.r);
98
-
99
- float elevation = 0.0;
100
-
101
- if (extruded) {
102
- vec2 elvDomain = elevationDomainValid ? elevationDomain : vec2(elevationData.maxMinCount.a, elevationData.maxMinCount.r);
103
- elevation = linearScale(elvDomain, elevationRange, elevations.r);
104
- elevation = elevation * (positions.z + 1.0) / 2.0 * elevationScale;
105
- }
106
-
107
- // if aggregated color or elevation is 0 do not render
108
- float shouldRender = float(color.r > 0.0 && elevations.r >= 0.0);
109
- float dotRadius = cellSize / 2. * coverage * shouldRender;
110
-
111
- int yIndex = (gl_InstanceID / gridSize[0]);
112
- int xIndex = gl_InstanceID - (yIndex * gridSize[0]);
113
-
114
- vec2 instancePositionXFP64 = mul_fp64(vec2(gridOffset[0], gridOffsetLow[0]), vec2(float(xIndex), 0.));
115
- instancePositionXFP64 = sum_fp64(instancePositionXFP64, vec2(gridOrigin[0], gridOriginLow[0]));
116
- vec2 instancePositionYFP64 = mul_fp64(vec2(gridOffset[1], gridOffsetLow[1]), vec2(float(yIndex), 0.));
117
- instancePositionYFP64 = sum_fp64(instancePositionYFP64, vec2(gridOrigin[1], gridOriginLow[1]));
118
-
119
- vec3 centroidPosition = vec3(instancePositionXFP64[0], instancePositionYFP64[0], elevation);
120
- vec3 centroidPosition64Low = vec3(instancePositionXFP64[1], instancePositionYFP64[1], 0.0);
121
- geometry.worldPosition = centroidPosition;
122
- vec3 pos = vec3(project_size(positions.xy + offset) * dotRadius, 0.);
123
-
124
- // Set color to be rendered to picking fbo (also used to check for selection highlight).
125
- picking_setPickingColor(instancePickingColors);
126
-
127
- gl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position);
128
-
129
- // Light calculations
130
- // Worldspace is the linear space after Mercator projection
131
-
132
- vec3 normals_commonspace = project_normal(normals);
133
-
134
- if (extruded) {
135
- vec3 lightColor = lighting_getLightColor(color.rgb, project_uCameraPosition, geometry.position.xyz, normals_commonspace);
136
- vColor = vec4(lightColor, color.a * opacity) / 255.;
137
- } else {
138
- vColor = vec4(color.rgb, color.a * opacity) / 255.;
139
- }
140
- }
141
- `;
@@ -1,143 +0,0 @@
1
- // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
20
- import { Layer, fp64LowPart, project32, gouraudLighting, picking } from '@deck.gl/core';
21
- import GL from '@luma.gl/constants';
22
- import { Model, CubeGeometry } from '@luma.gl/core';
23
- import { fp64arithmetic } from '@luma.gl/shadertools';
24
- import { defaultColorRange, colorRangeToFlatArray } from '../utils/color-utils';
25
- import vs from './gpu-grid-cell-layer-vertex.glsl';
26
- import fs from './gpu-grid-cell-layer-fragment.glsl';
27
- const COLOR_DATA_UBO_INDEX = 0;
28
- const ELEVATION_DATA_UBO_INDEX = 1;
29
- const defaultProps = {
30
- // color
31
- colorDomain: null,
32
- colorRange: defaultColorRange,
33
- // elevation
34
- elevationDomain: null,
35
- elevationRange: [0, 1000],
36
- elevationScale: { type: 'number', min: 0, value: 1 },
37
- // grid
38
- gridSize: { type: 'array', min: 0, value: [1, 1] },
39
- gridOrigin: { type: 'array', min: 0, value: [0, 0] },
40
- gridOffset: { type: 'array', min: 0, value: [0, 0] },
41
- cellSize: { type: 'number', min: 0, max: 1000, value: 1000 },
42
- offset: { type: 'array', min: 0, value: [1, 1] },
43
- coverage: { type: 'number', min: 0, max: 1, value: 1 },
44
- extruded: true,
45
- material: true // Use lighting module defaults
46
- };
47
- export default class GPUGridCellLayer extends Layer {
48
- getShaders() {
49
- return super.getShaders({
50
- vs,
51
- fs,
52
- modules: [project32, gouraudLighting, picking, fp64arithmetic]
53
- });
54
- }
55
- initializeState({ gl }) {
56
- const attributeManager = this.getAttributeManager();
57
- attributeManager.addInstanced({
58
- colors: {
59
- size: 4,
60
- noAlloc: true
61
- },
62
- elevations: {
63
- size: 4,
64
- noAlloc: true
65
- }
66
- });
67
- const model = this._getModel(gl);
68
- this._setupUniformBuffer(model);
69
- this.setState({ model });
70
- }
71
- _getModel(gl) {
72
- return new Model(gl, {
73
- ...this.getShaders(),
74
- id: this.props.id,
75
- geometry: new CubeGeometry(),
76
- isInstanced: true
77
- });
78
- }
79
- draw({ uniforms }) {
80
- const { cellSize, offset, extruded, elevationScale, coverage, gridSize, gridOrigin, gridOffset, elevationRange, colorMaxMinBuffer, elevationMaxMinBuffer } = this.props;
81
- const gridOriginLow = [fp64LowPart(gridOrigin[0]), fp64LowPart(gridOrigin[1])];
82
- const gridOffsetLow = [fp64LowPart(gridOffset[0]), fp64LowPart(gridOffset[1])];
83
- const domainUniforms = this.getDomainUniforms();
84
- const colorRange = colorRangeToFlatArray(this.props.colorRange);
85
- this.bindUniformBuffers(colorMaxMinBuffer, elevationMaxMinBuffer);
86
- this.state.model
87
- .setUniforms(uniforms)
88
- .setUniforms(domainUniforms)
89
- .setUniforms({
90
- cellSize,
91
- offset,
92
- extruded,
93
- elevationScale,
94
- coverage,
95
- gridSize,
96
- gridOrigin,
97
- gridOriginLow,
98
- gridOffset,
99
- gridOffsetLow,
100
- colorRange,
101
- elevationRange
102
- })
103
- .draw();
104
- this.unbindUniformBuffers(colorMaxMinBuffer, elevationMaxMinBuffer);
105
- }
106
- bindUniformBuffers(colorMaxMinBuffer, elevationMaxMinBuffer) {
107
- colorMaxMinBuffer.bind({ target: GL.UNIFORM_BUFFER, index: COLOR_DATA_UBO_INDEX });
108
- elevationMaxMinBuffer.bind({ target: GL.UNIFORM_BUFFER, index: ELEVATION_DATA_UBO_INDEX });
109
- }
110
- unbindUniformBuffers(colorMaxMinBuffer, elevationMaxMinBuffer) {
111
- colorMaxMinBuffer.unbind({ target: GL.UNIFORM_BUFFER, index: COLOR_DATA_UBO_INDEX });
112
- elevationMaxMinBuffer.unbind({ target: GL.UNIFORM_BUFFER, index: ELEVATION_DATA_UBO_INDEX });
113
- }
114
- getDomainUniforms() {
115
- const { colorDomain, elevationDomain } = this.props;
116
- const domainUniforms = {};
117
- if (colorDomain !== null) {
118
- domainUniforms.colorDomainValid = true;
119
- domainUniforms.colorDomain = colorDomain;
120
- }
121
- else {
122
- domainUniforms.colorDomainValid = false;
123
- }
124
- if (elevationDomain !== null) {
125
- domainUniforms.elevationDomainValid = true;
126
- domainUniforms.elevationDomain = elevationDomain;
127
- }
128
- else {
129
- domainUniforms.elevationDomainValid = false;
130
- }
131
- return domainUniforms;
132
- }
133
- _setupUniformBuffer(model) {
134
- const gl = this.context.gl;
135
- const programHandle = model.program.handle;
136
- const colorIndex = gl.getUniformBlockIndex(programHandle, 'ColorData');
137
- const elevationIndex = gl.getUniformBlockIndex(programHandle, 'ElevationData');
138
- gl.uniformBlockBinding(programHandle, colorIndex, COLOR_DATA_UBO_INDEX);
139
- gl.uniformBlockBinding(programHandle, elevationIndex, ELEVATION_DATA_UBO_INDEX);
140
- }
141
- }
142
- GPUGridCellLayer.layerName = 'GPUGridCellLayer';
143
- GPUGridCellLayer.defaultProps = defaultProps;