Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions packages/reshader.gl/src/shaderlib/glsl/fbo_picking.vert
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@
#ifdef ENABLE_PICKING
//HAS_PICKING_ID == 1 时读取attributes
#if HAS_PICKING_ID == 1
attribute float aPickingId;
attribute float aPickingId;
//HAS_PICKING_ID == 2 时读取uniforms
#elif HAS_PICKING_ID == 2
uniform float uPickingId;
uniform float uPickingId;
#endif
varying float vPickingId;
varying float vFbo_picking_viewZ;
varying float vFbo_picking_visible;
varying float vPickingId;
varying float vFbo_picking_viewZ;
varying float vFbo_picking_visible;
#endif
varying float vFbo_picking_fragDepth;
varying float vFbo_picking_fragDepth;

void fbo_picking_setData(float viewPosZ, bool visible) {
#ifdef ENABLE_PICKING
#if HAS_PICKING_ID == 1
vPickingId = aPickingId;
vPickingId = aPickingId;
#elif HAS_PICKING_ID == 2
vPickingId = uPickingId;
#endif
vFbo_picking_viewZ = viewPosZ;
vFbo_picking_visible = visible ? 1.0 : 0.0;
#endif
vFbo_picking_visible = visible ? 1.0 : 0.0;
vFbo_picking_fragDepth = viewPosZ + 1.0;
}
1 change: 1 addition & 0 deletions packages/vt/src/layer/plugins/painters/Painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,7 @@ class Painter {
const pickingVert = this.picking[i].getPickingVert();
const wgslPickingVert = this.picking[i].getPickingWGSLVert();
const defines = {
'PICKING_MODE': 1,
'ENABLE_PICKING': 1,
'HAS_PICKING_ID': 1
};
Expand Down
50 changes: 42 additions & 8 deletions packages/vt/test/specs/update.vector.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,44 @@ describe('vector layers update style specs', () => {
}, 500);
});

it('PolygonLayer in GroupGLLayer can outline polygon', done => {
const polygon = new maptalks.Polygon(
[[[-1, 1], [1, 1], [1, -1], [-1, -1], [-1, 1]]],
{
id: 'foo',
symbol: {
lineColor: "#e5e5e5",
lineWidth: 1,
polygonFill: '#0ff'
}
});
const layer = new PolygonLayer('vector', polygon);
const sceneConfig = {
postProcess: {
enable: true,
outline: {
enable: true,
outlineFactor: 0.3,
highlightFactor: 0.2,
outlineWidth: 1,
outlineColor: [1,0,0]
}
}
};
const group = new GroupGLLayer('group', [layer], { sceneConfig });
const renderer = map.getRenderer();
const x = renderer.canvas.width, y = renderer.canvas.height;
group.addTo(map);
setTimeout(() => {
layer.outline(['foo']);
setTimeout(() => {
const pixel = readPixel(layer.getRenderer().canvas, x / 2, y / 2);
assert(pixel[0] > 10);
done();
}, 500);
}, 500);
});

it('line should can hide and show', done => {
const line = new maptalks.LineString([[-1, 0], [1, 0]]);
const layer = new LineStringLayer('vector', line, {
Expand Down Expand Up @@ -2066,15 +2104,11 @@ describe('vector layers update style specs', () => {
const layer = new LineStringLayer('lines', [line]);
const polygonLayer = new PolygonLayer('polygons', [polygon]);
const group = new GroupGLLayer('group', [layer, polygonLayer]);
let count = 0;
const canvas = map.getRenderer().canvas;
group.on('layerload', () => {
count++;
if (count === 1) {
const expectedPath = path.join(__dirname, 'fixtures', 'line-altitude', 'expected.png');
compareExpected(canvas, { expectedPath }, done);
}
});
setTimeout(() => {
const expectedPath = path.join(__dirname, 'fixtures', 'line-altitude', 'expected.png');
compareExpected(canvas, { expectedPath }, done);
}, 500);
group.addTo(map);
});

Expand Down