Skip to content

Commit 953c276

Browse files
flostellbrinkPessimistress
authored andcommitted
TerrainExtension: Support picking on draped layers (#8474)
1 parent 99fc930 commit 953c276

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

examples/website/google-3d-tiles/app.jsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ const INITIAL_VIEW_STATE = {
3232
const BUILDING_DATA =
3333
'https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/google-3d-tiles/buildings.geojson';
3434

35+
function getTooltip({object}) {
36+
return (
37+
object && {
38+
html: `\
39+
<div><b>Distance to nearest tree</b></div>
40+
<div>${object.properties.distance_to_nearest_tree}</div>
41+
`
42+
}
43+
);
44+
}
45+
3546
export default function App({data = TILESET_URL, distance = 0, opacity = 0.2}) {
3647
const [credits, setCredits] = useState('');
3748

@@ -64,7 +75,8 @@ export default function App({data = TILESET_URL, distance = 0, opacity = 0.2}) {
6475
getFillColor: ({properties}) => colorScale(properties.distance_to_nearest_tree),
6576
opacity,
6677
getFilterValue: f => f.properties.distance_to_nearest_tree,
67-
filterRange: [distance, 500]
78+
filterRange: [distance, 500],
79+
pickable: true
6880
})
6981
];
7082

@@ -75,6 +87,7 @@ export default function App({data = TILESET_URL, distance = 0, opacity = 0.2}) {
7587
initialViewState={INITIAL_VIEW_STATE}
7688
controller={{touchRotate: true, inertia: 250}}
7789
layers={layers}
90+
getTooltip={getTooltip}
7891
/>
7992
<div
8093
style={{position: 'absolute', left: '8px', bottom: '4px', color: 'white', fontSize: '10px'}}

modules/extensions/src/terrain/terrain-effect.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ export class TerrainEffect implements Effect {
6565
return;
6666
}
6767

68-
const {viewports, isPicking = false} = opts;
68+
const {viewports} = opts;
69+
const isPicking = opts.pass.startsWith('picking');
6970
this.isPicking = isPicking;
7071
this.isDrapingEnabled = true;
7172

@@ -200,7 +201,12 @@ export class TerrainEffect implements Effect {
200201
devicePixelRatio: 1
201202
}
202203
});
203-
terrainCover.isDirty = false;
204+
205+
if (!this.isPicking) {
206+
// IsDirty refers to the normal fbo, not the picking fbo.
207+
// Only mark it as not dirty if the normal fbo was updated.
208+
terrainCover.isDirty = false;
209+
}
204210
}
205211
} catch (err) {
206212
terrainLayer.raiseError(err as Error, `Error rendering terrain cover ${terrainCover.id}`);

0 commit comments

Comments
 (0)