Skip to content

Commit

Permalink
Fix the position generation for extruded polygons with holes (visgl#447)
Browse files Browse the repository at this point in the history
* Fix the position generation for extruded polygons with holes
* Fix the polygon layer example in the layer browser
  • Loading branch information
Shaojing Li authored Mar 22, 2017
1 parent 5fefcf3 commit 468ed74
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/layer-browser/src/examples/core-layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const GeoJsonLayerExtrudedExample = {
props: {
id: 'geojsonLayer-extruded',
getElevation: f => get(f, 'properties.ZIP_CODE') * 10 % 127 * 10,
getFillColor: f => [0, 255, get(f, 'properties.ZIP_CODE') * 23 % 100 + 155],
getFillColor: f => [0, 100, get(f, 'properties.ZIP_CODE') * 55 % 255],
getLineColor: f => [200, 0, 80],
extruded: true,
wireframe: true,
Expand All @@ -110,7 +110,7 @@ const PolygonLayerExample = {
getData: () => dataSamples.polygons,
props: {
getPolygon: f => f,
getFillColor: f => [Math.random() % 256, 0, 0],
getFillColor: f => [Math.floor(Math.random() * 255), 0, 0],
getLineColor: f => [0, 0, 0, 255],
getWidth: f => 20,
getHeight: f => Math.random() * 1000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ function calculateIndices({groupedVertices, wireframe = false}) {
// * each top vertex is on 3 surfaces
// * each bottom vertex is on 2 surfaces
function calculatePositionsJS({groupedVertices, wireframe = false}) {
const positions = groupedVertices.map(complexPolygon =>
complexPolygon.map(vertices => {
const topVertices = [].concat(vertices);
const positions = groupedVertices.map(
vertices => {
const topVertices = Array.prototype.concat.apply([], vertices);
const baseVertices = topVertices.map(v => [get(v, 0), get(v, 1), 0]);
return wireframe ?
[topVertices, baseVertices] :
return wireframe ? [topVertices, baseVertices] :
[topVertices, topVertices, topVertices, baseVertices, baseVertices];
})
}
);

return flattenDeep(positions);
}

Expand Down

0 comments on commit 468ed74

Please sign in to comment.