Skip to content

Commit

Permalink
Fix outdated custom layer example (#3571)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed Sep 13, 2019
1 parent 35e996c commit be0a78c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion docs/developer-guide/custom-layers/subclassed-layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@ good technique to add it.
```js
// Example to add per-segment color to PathLayer
import {PathLayer} from '@deck.gl/layers';
import GL from '@luma.gl/constants';

// Allow accessor: `getColor` (Function, optional)
// Returns an color (array of numbers, RGBA) or array of colors (array of arrays).
export default class MultiColorPathLayer extends PathLayer {
initializeState() {
super.initializeState();
this.getAttributeManager().getAttributes().instanceColors.update = this.calculateColors;
this.getAttributeManager().addInstanced({
instanceColors: {
size: 4,
type: GL.UNSIGNED_BYTE,
normalized: true,
update: this.calculateColors
}
})
}

calculateColors(attribute) {
Expand Down

0 comments on commit be0a78c

Please sign in to comment.