scatter_instancing = {
class ScatterInstanced extends deck.Layer {
initializeState() {
const {gl} = this.context;
this.setState({
model: getModel(gl)
});
this.getAttributeManager()
.addInstanced({
instancePositions: {
size: 3,
type: gl.DOUBLE,
transition: true,
accessor: 'getPosition'
},
instanceRadius: {
size: 1,
transition: true,
accessor: 'getRadius',
defaultValue: 1
},
instanceColors: {
size: 4,
normalized: true,
type: gl.UNSIGNED_BYTE,
transition: true,
accessor: 'getColor',
defaultValue: [0, 0, 0, 255],
},
customPickingColors: {
size: 3,
type: gl.UNSIGNED_BYTE,
update: this.calculatePickingColors,
}
});
}
calculatePickingColors (attribute) {
const {data} = this.props;
const {value, size} = attribute;
let i = 0;
let index = 0;
for (const object of data) {
const pickingColor = this.encodePickingColor(index);
value[index * 3] = pickingColor[0];
value[index * 3 + 1] = pickingColor[1];
value[index * 3 + 2] = pickingColor[2];
index++;
}
}
}
ScatterInstanced.layerName = 'ScatterInstanced';
const layer = new ScatterInstanced({
id: 'scatter-instancing',
data: data_inst,
getPosition: d => [d.x, d.y],
getRadius: d => 10,
getColor: [255, 0, 0],
pickable: true,
});
return layer;
}