deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

[Bug] Subclassed Layers documentation is incorrect

Open xintongxia opened this issue 3 years ago • 1 comments

Description

Followed the documentation https://deck.gl/docs/developer-guide/custom-layers/subclassed-layers#overriding-attribute-calculation to create a customized path layer, which can render different colors for different paths But when paths contain polygons, this example code failed.

It is not necessarily a bug for the code, but it is more like looking for correct way to override calculate colors for path layer.

Flavors

  • [X] React
  • [ ] Python/Jupyter notebook
  • [ ] MapboxLayer
  • [ ] GoogleMapsOverlay
  • [ ] CartoLayer
  • [ ] DeckLayer/DeckRenderer for ArcGIS

Expected Behavior

Should render all the given polygons / polylines

Steps to Reproduce

https://codesandbox.io/s/custon-path-layer-gery0d?file=/src/App.js

Environment

  • Framework version: 8.7.8
  • Browser: chrome
  • OS: Mac Montery

Logs

No response

xintongxia avatar May 04 '22 22:05 xintongxia

Yes that is a known flaw of this example - if you have a path that is a closed loop (positions[0] is the same as positions[positions.length - 1]), the tesselator actually generate 2 extra vertices. If the path makes a square, the colors array should be filled as:

color0, color1, color2, color3, color4, <padding>, <padding>

Pessimistress avatar May 11 '22 15:05 Pessimistress