Skip to content

Commit f88738a

Browse files
authored
Enable WebGPU for line layer example (#9724)
1 parent fdcacbf commit f88738a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

examples/website/line/app.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {DeckGL} from '@deck.gl/react';
99
import {LineLayer, ScatterplotLayer} from '@deck.gl/layers';
1010

1111
import type {PickingInfo, MapViewState} from '@deck.gl/core';
12+
import {Device} from '@luma.gl/core';
1213

1314
// Source data CSV
1415
const DATA_URL = {
@@ -56,12 +57,14 @@ export default function App({
5657
airports = DATA_URL.AIRPORTS,
5758
flightPaths = DATA_URL.FLIGHT_PATHS,
5859
lineWidth = 3,
59-
mapStyle = MAP_STYLE
60+
mapStyle = MAP_STYLE,
61+
device
6062
}: {
6163
airports?: string | Airport[];
6264
flightPaths?: string | FlightPath[];
6365
lineWidth?: number;
6466
mapStyle?: string;
67+
device?: Device;
6568
}) {
6669
const layers = [
6770
new ScatterplotLayer<Airport>({
@@ -92,13 +95,20 @@ export default function App({
9295
const r = z / 10000;
9396
return [255 * (1 - r * 2), 128 * r, 255 * r, 255 * (1 - r)];
9497
},
95-
getWidth: lineWidth,
98+
// TODO(ck): WebGPU does not support constant attributes, so force the line layer to
99+
// generate a buffer with each value individually, otherwise it will not be updated properly.
100+
getWidth: () => lineWidth,
101+
updateTriggers: {
102+
// then use update triggers so that the function will be re-evaluated when lineWidth changes
103+
getWidth: [lineWidth]
104+
},
96105
pickable: true
97106
})
98107
];
99108

100109
return (
101110
<DeckGL
111+
device={device}
102112
layers={layers}
103113
initialViewState={INITIAL_VIEW_STATE}
104114
controller={true}

website/src/examples/line-layer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class LineDemo extends Component {
2424

2525
static code = `${GITHUB_TREE}/examples/website/line`;
2626

27+
static hasDeviceTabs = true;
28+
2729
static parameters = {
2830
width: {
2931
displayName: 'Width',
@@ -62,6 +64,8 @@ class LineDemo extends Component {
6264
return (
6365
<App
6466
{...otherProps}
67+
key={this.props.device?.type}
68+
device={this.props.device}
6569
flightPaths={data && data[0]}
6670
airports={data && data[1]}
6771
lineWidth={params.width.value}

0 commit comments

Comments
 (0)