Skip to content

Commit

Permalink
fix outdated custom layer example
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaoji Chen committed Sep 11, 2019
1 parent 6083754 commit 4ed0f4e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion docs/developer-guide/custom-layers/subclassed-layers.md
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 4ed0f4e

Please sign in to comment.