scatter_inst = {
const {Layer} = deck;
class ScatterInstanced extends Layer {
initializeState() {
const {gl} = this.context;
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,
}
});
this.setState({
model: getModel(gl)
});
}
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';
ScatterInstanced.defaultProps = defaultProps;
const layer = new ScatterInstanced({
id: `scatterplot-${Date.now()}`,
data: data_inst,
getPosition: apply_map_morph,
getRadius: d => 10,
getColor: getFillColor,
pickable: true,
updateTriggers: {
getPosition: map_type,
},
transitions: transitions,
onClick: (info, event) => {
console.log('clicking!!!')
}
});
return layer;
}