Skip to content

Commit 82423d8

Browse files
committed
Merge branch 'master' into felix/trajectory-poc
2 parents 2a539b5 + 0d3c3b3 commit 82423d8

File tree

138 files changed

+2561
-1180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+2561
-1180
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ PRs and bug reports are welcome, and we are actively looking for new maintainers
1010
The **master** branch is the active development branch.
1111

1212
Building deck.gl locally from the source requires node.js `>=14`. Further limitations on the Node version may be imposed by [puppeteer](https://github.com/puppeteer/puppeteer#usage) and [headless-gl](https://github.com/stackgl/headless-gl#supported-platforms-and-nodejs-versions).
13-
We use [yarn](https://yarnpkg.com/en/docs/install) to manage the dependencies of deck.gl.
13+
We use [yarn](https://yarnpkg.com/en/docs/install) to manage the dependencies of deck.gl, and [volta](https://docs.volta.sh/guide/getting-started) to manage the Node and yarn version.
1414

1515
```bash
1616
git checkout master
@@ -20,6 +20,15 @@ yarn test
2020

2121
See [additional instructions](#troubleshooting) for Windows, Linux and Apple M1.
2222

23+
Run the website:
24+
25+
```bash
26+
yarn build
27+
cd website
28+
yarn
29+
yarn start
30+
```
31+
2332
Run the layer browser application:
2433

2534
```bash
Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,42 @@
11
import pydeck as pdk
22
import geopandas as gpd
33

4-
world = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
4+
world = gpd.read_file("https://naciscdn.org/naturalearth/110m/cultural/ne_110m_admin_0_countries.zip")
5+
# deck.gl is only compatible with WGS84
6+
world = world.to_crs("EPSG:4326")
7+
# Convert any multi polygons into individual polygons
8+
world = world.explode()
59

6-
centroids = gpd.GeoDataFrame()
7-
centroids["geometry"] = world.geometry.centroid
8-
centroids["name"] = world.name
10+
centroids = gpd.GeoDataFrame(geometry=world.geometry.centroid)
11+
centroids["name"] = world.NAME
912

1013
layers = [
14+
# Black background of the country polygons
1115
pdk.Layer(
1216
"GeoJsonLayer",
1317
data=world,
1418
get_fill_color=[0, 0, 0],
1519
),
20+
21+
# # Alternative way using PolygonLayer, should the above not work
22+
# pdk.Layer(
23+
# "PolygonLayer",
24+
# data=world,
25+
# get_polygon="geometry.coordinates",
26+
# get_fill_color=[0, 0, 0],
27+
# ),
28+
29+
30+
# Overlay country names at their centroids.
1631
pdk.Layer(
1732
"TextLayer",
1833
data=centroids,
34+
# Use this to get geometry coordinates out of a raw GeoDataFrame
1935
get_position="geometry.coordinates",
2036
get_size=16,
2137
get_color=[255, 255, 255],
2238
get_text="name",
2339
),
2440
]
2541

26-
pdk.Deck(layers, map_provider=None).to_html("geopandas_integration.html", css_background_color="cornflowerblue")
42+
pdk.Deck(layers, map_provider=None).to_html("geopandas_integration.html", css_background_color="cornflowerblue", open_browser=True)

bindings/pydeck/examples/polygon_layer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def calculate_elevation(val):
5757
# Add sunlight shadow to the polygons
5858
sunlight = {
5959
"@@type": "_SunLight",
60-
"timestamp": 1564696800000, # Date.UTC(2019, 7, 1, 22),
60+
"timestamp": 1564696800000, # datetime.datetime(2019, 7, 1, 22, tzinfo=datetime.timezone.utc).timestamp() * 1000
6161
"color": [255, 255, 255],
6262
"intensity": 1.0,
6363
"_shadow": True,

bindings/pydeck/pydeck/bindings/widget.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import uuid
12
from .json_tools import JSONMixin
23

34
TYPE_IDENTIFIER = "@@type"
@@ -30,7 +31,7 @@ class Widget(JSONMixin):
3031

3132
def __init__(self, type, id=None, placement=None, view_id=None, **kwargs):
3233
self.type = type
33-
self.id = id
34+
self.id = id or str(uuid.uuid4())
3435
self.placement = placement
3536
self.view_id = view_id
3637
self.__dict__.update(kwargs)

bindings/pydeck/tests/bindings/test_widget.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55

66
def test_widget_constructor():
7-
EXPECTED = {"@@type": "ZoomWidget", "placement": "top-right"}
8-
assert json.loads(Widget(type="ZoomWidget", placement="top-right", view_id=None).to_json()) == EXPECTED
7+
EXPECTED = {"@@type": "ZoomWidget", "placement": "top-right", "id": "test-widget"}
8+
assert json.loads(Widget(type="ZoomWidget", placement="top-right", view_id=None, id="test-widget").to_json()) == EXPECTED

docs/api-reference/core/view.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,37 @@ The `viewState` property is intended to support a number of use cases:
8181
* Overriding a partial set of view state properties from a selected view state.
8282

8383

84-
#### `clear` (boolean | object, optional) {#clear}
84+
#### `clear` (boolean, optional) {#clear}
8585

86-
Clears the contents (pixels) of the viewport. The value of the `clear` prop is passed as an argument to luma.gl's `clear` function. If `true` clears color and depth buffers. If an object, behaviour is controlled by the following fields:
86+
Clears the contents (pixels) of the viewport. If `true` clears color, depth, and stencil buffers. Behavior is controlled with the `clearColor`, `clearDepth`, and `clearStencil` properties.
8787

88-
* `color` (boolean or Array) - if not `false`, clears all active color buffers with either the provided color or the currently set clear color.
89-
* `depth` (boolean) - if `true`, clears the depth buffer.
90-
* `stencil` (boolean) - if `true` clears the stencil buffer.
91-
92-
Note that deck.gl always clears the screen before each render, and clearing, while cheap, is not totally free. This means that viewports should only specify the `clear` property if they need additional clearing, e.g. because they are rendering on top of another viewport, or want to have a different background color etc.
88+
Note that deck.gl always clears the screen before each render, and clearing, while cheap, is not totally free. This means that viewports should only clear the viewport if they need additional clearing, e.g. because they are rendering on top of another viewport, or want to have a different background color etc.
9389

9490
Default `false`.
9591

92+
#### `clearColor` (number[] | false, optional) {#clearcolor}
93+
94+
Specifies the color to clear the viewport with, as an array of four numbers `[r, g, b, a?]`. Each channel should be an integer between 0 and 255. For example, `[255, 0, 0, 255]` for opaque red. If `clearColor` is `false`, the depth buffer will not be cleared. If `clear` is set to `false`, this property will be ignored.
95+
96+
Default `[0, 0, 0, 0]` (transparent).
97+
98+
#### `clearDepth` (number | false, optional) {#cleardepth}
99+
100+
Specifies the depth buffer value to clear the viewport with, as number between `0.0` and `1.0`. If `clearDepth` is `false`, the depth buffer will not be cleared. If `clear` is set to `false`, this property will be ignored.
101+
102+
Default `1.0` (far plane).
103+
104+
#### `clearStencil` (number | false, optional) {#clearstencil}
105+
106+
Specifies the stencil buffer value to clear the viewport with, as number between `0` and `255`. If `clearStencil` is `false`, the depth buffer will not be cleared. If `clear` is set to `false`, this property will be ignored.
107+
108+
Default `0` (clear).
109+
110+
**Examples:**
111+
112+
* Clearing to a solid color: `new View({clear: true, clearColor: [80, 120, 200, 255]})`
113+
* Clearing color and stencil but not depth: `new View({clear: true, clearColor: [50, 50, 50, 255], clearDepth: false})`
114+
* No clearing at all: `new View({})` or `new View({clear: false})`
96115

97116

98117
## Methods

docs/api-reference/geo-layers/terrain-layer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {TerrainLayerDemo} from '@site/src/doc-demos/geo-layers';
66

77
The `TerrainLayer` reconstructs mesh surfaces from height map images, e.g. [Mapzen Terrain Tiles](https://github.com/tilezen/joerd/blob/master/docs/formats.md), which encodes elevation into R,G,B values.
88

9-
When `elevationData` is supplied with a URL template, i.e. a string containing `'{x}'` and `'{y}'`, it loads terrain tiles on demand using a `TileLayer` and renders a mesh for each tile. If `elevationData` is an absolute URL, a single mesh is used, and the `bounds` prop is required to position it into the world space.
9+
When `elevationData` is supplied with a URL template, i.e. a string containing `'{x}'` and `'{y}'` (or `'{-y}'` for TMS tiles), it loads terrain tiles on demand using a `TileLayer` and renders a mesh for each tile. If `elevationData` is an absolute URL, a single mesh is used, and the `bounds` prop is required to position it into the world space.
1010

1111

1212
import Tabs from '@theme/Tabs';

docs/api-reference/layers/geojson-layer.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ import type {BinaryPointFeature} from '@loaders.gl/schema';
501501

502502
data.points = {
503503
type: 'Point',
504-
positions: {value: Float32Array([x0, y0, x1, y1, x2, y2, ...]), size: 2}, // Use size=2 for xy and size=3 for xyz
504+
positions: {value: new Float32Array([x0, y0, x1, y1, x2, y2, ...]), size: 2}, // Use size=2 for xy and size=3 for xyz
505505
// featureIds
506506
// globalFeatureIds
507507
// numericProps
@@ -518,8 +518,8 @@ import type {BinaryLineFeature} from '@loaders.gl/schema';
518518

519519
data.lines = {
520520
type: 'LineString',
521-
positions: {value: Float32Array([x0, y0, x1, y1, x2, y2, ...]), size: 2}, // Use size=2 for xy and size=3 for xyz
522-
pathIndices: {value: Uint16Array([0, 5, 7, ...]), size: 1}, // First line contains vertex 0-4, second line contains vertex 5-6, ...
521+
positions: {value: new Float32Array([x0, y0, x1, y1, x2, y2, ...]), size: 2}, // Use size=2 for xy and size=3 for xyz
522+
pathIndices: {value: new Uint16Array([0, 5, 7, ...]), size: 1}, // First line contains vertex 0-4, second line contains vertex 5-6, ...
523523
// featureIds
524524
// globalFeatureIds
525525
// numericProps
@@ -535,9 +535,9 @@ Polygons are an extension of the idea introduced with lines, but instead of `pat
535535
import type {BinaryPolygonFeature} from '@loaders.gl/schema';
536536

537537
data.polygons = {
538-
positions: {value: Float32Array([x0, y0, x1, y1, x2, y2, ...]), size: 2}, // Use size=2 for xy and size=3 for xyz
539-
polygonIndices: {value: Uint16Array([0, 100, ...]), size: 1}, // First polygon contains vertex 0-99
540-
primitivePolygonIndices: {value: Uint16Array([0, 60, 80, 100, ...]), size: 1}, // First polygon has 2 holes, made of vertex 60-79 and vertex 80-99
538+
positions: {value: new Float32Array([x0, y0, x1, y1, x2, y2, ...]), size: 2}, // Use size=2 for xy and size=3 for xyz
539+
polygonIndices: {value: new Uint16Array([0, 100, ...]), size: 1}, // First polygon contains vertex 0-99
540+
primitivePolygonIndices: {value: new Uint16Array([0, 60, 80, 100, ...]), size: 1}, // First polygon has 2 holes, made of vertex 60-79 and vertex 80-99
541541
// featureIds
542542
// globalFeatureIds
543543
// numericProps
@@ -569,13 +569,13 @@ data.points = {
569569
// featureIds
570570
// globalFeatureIds
571571
numericProps: {
572-
population: {value: Float32Array([value0, value1, ...], size: 1}
572+
population: {value: new Float32Array([value0, value1, ...]), size: 1}
573573
},
574574
// properties
575575
} as BinaryPointFeature
576576
```
577577

578-
Both `properties` and `numericProps` are specified per-feature.
578+
Both `properties` and `numericProps` are specified per-vertex.
579579

580580
#### Feature IDs and global feature IDs
581581

@@ -629,13 +629,13 @@ const geojson: FeatureCollection = {
629629
const binary: BinaryPointFeature = {
630630
shape: 'binary-feature-collection',
631631
points: {
632-
positions: {value: Float32Array([1,23, 4.56]), size: 2},
632+
positions: {value: new Float32Array([1,23, 4.56]), size: 2},
633633
properties: [{name: 'London'}],
634634
numericProps: {
635-
population: {value: Float32Array([10000000], size: 1}
635+
population: {value: new Float32Array([10000000]), size: 1}
636636
},
637-
featureIds: {value: Uint16Array([0]), size: 1},
638-
globalFeatureIds: {value: Uint16Array([0]), size: 1},
637+
featureIds: {value: new Uint16Array([0]), size: 1},
638+
globalFeatureIds: {value: new Uint16Array([0]), size: 1},
639639
fields: [{id: 123}]
640640
}
641641
};

docs/developer-guide/custom-layers/writing-shaders.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
A shader library facilitates creating shaders that work seamlessly with deck.gl. The `modules` parameter passed to the [Model](https://github.com/visgl/luma.gl/blob/8.0-release/docs/api-reference/engine/model.md) class can dynamically include parts from this library into your own GLSL code:
44

55
```js
6-
import {picking, project32, gouraudLighting} from '@deck.gl/core';
6+
import {picking, project32, gouraudMaterial} from '@deck.gl/core';
77

88
const model = new Model(gl, {
99
vs: '// vertex shader GLSL source'
1010
fs: '// fragment shader GLSL source',
11-
modules: [picking, project32, gouraudLighting] // list of optional module names
11+
modules: [picking, project32, gouraudMaterial] // list of optional module names
1212
});
1313
```
1414

@@ -34,8 +34,8 @@ The `project` module also has two extensions, [project32](../../api-reference/co
3434

3535
A simple lighting package is provided in deck.gl, supporting a single directional light in addition to ambient light. Turning on lighting requires normals to be provided for each vertex. There are two flavors:
3636

37-
- [gouraudLighting] - for lighting calculated in the vertex shader
38-
- [phongLighting] - for lighting calculated in the fragment shader
37+
- [gouraudMaterial] - for lighting calculated in the vertex shader
38+
- [phongMaterial] - for lighting calculated in the fragment shader
3939

4040

4141
#### fp64

docs/developer-guide/webgpu.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# WebGPU
2+
3+
:::caution
4+
WebGPU support in deck.gl v9 is a work in progress and is not production ready. At this stage, it is aimed at early adopters who wants to try out the new technology, contributors interested in supporting development, or general users that are curious to understand what to expect from future releases.
5+
:::
6+
7+
deck.gl is gradually adding support for running on WebGPU. WebGPU support will materialize over successive releases, layer by layer and feature by feature.
8+
9+
## Enabling WebGPU
10+
11+
deck.gl needs to be set up to use a luma.gl device that uses the luma.gl `webgpuAdapter`.
12+
13+
One way to do this is to supply `deviceProps` to the Deck constructor:
14+
15+
```ts
16+
import {webgpuAdapter} from '@luma.gl/webgpu`;
17+
18+
new Deck({
19+
deviceProps: {
20+
type: 'webgpu',
21+
adapters: [webgpuAdapter]
22+
}
23+
});
24+
```
25+
26+
## Layers
27+
28+
Layers will gradually be WebGPU enabled. Layers that support WebGPU can be tested in the deck.gl website, using the WebGPU tab.
29+
30+
- [`PointCloudLayer`](https://deck.gl/examples/point-cloud-layer)
31+
- [`ScatterplotLayer`](https://deck.gl/examples/scatterplot-layer)
32+
33+
## Features
34+
35+
Apart from listing which layers have been ported, another aspect is what deck.gl features support WebGPU.
36+
37+
| Feature | Status | Comment |
38+
| --------------------- | ------ | --------------------------------------------------------------------------------------- |
39+
| Views | 🚧 | Various view systems should work via the WGSL port of the `project module`|
40+
| Picking || WebGPU pixel readout is asynchronous, requiring an overhaul of deck.gl's picking engine |
41+
| Base Map overlays || deck.gl needs to adopt pre-multiplied colors to enable transparency |
42+
| Base Map interleaving || At the moment no basemaps support WebGPU |
43+
44+
This is currently an incomplete list. Expect more detail in upcoming releases.
45+
46+
## Background
47+
48+
While the WebGPU support in deck.gl may look limited, under the hood, WebGPU enablement has been in progress for several years and a lot of work has been completed. In particular [luma.gl](https://luma.gl), the GPU framework powering deck.gl, has been rewritten and adopted a "WebGPU-first" design.
49+
50+
## Participating
51+
52+
If you want to contribute to deck.gl WebGPU development, or just follow along, we have a dedicated channel in our OpenJS / Open Visualization slack channel.
53+
54+
You can also check various release tracker tasks on GitHub.

0 commit comments

Comments
 (0)