Clamp the weight value between 0 and 1

This commit is contained in:
Frederic Junod
2019-10-24 13:52:59 +02:00
parent 599835e818
commit 88bbb8c1ae

View File

@@ -4,6 +4,7 @@
import {getChangeEventType} from '../Object.js';
import {createCanvasContext2D} from '../dom.js';
import VectorLayer from './Vector.js';
import {clamp} from '../math.js';
import {assign} from '../obj.js';
import WebGLPointsLayerRenderer from '../renderer/webgl/PointsLayer.js';
@@ -180,7 +181,10 @@ class Heatmap extends VectorLayer {
attributes: [
{
name: 'weight',
callback: this.weightFunction_
callback: function(feature) {
const weight = this.weightFunction_(feature);
return weight !== undefined ? clamp(weight, 0, 1) : 1;
}.bind(this)
}
],
vertexShader: `