Skip to content

Commit 3c0db48

Browse files
Add WebGPU support for ImageViewer (#65)
* Upgrade TileDB-Viz to version 1.0.3-alpha.6, add additional parameters for image viewer * Bump TileDB-Viz version
1 parent afa26ca commit 3c0db48

File tree

7 files changed

+218
-78
lines changed

7 files changed

+218
-78
lines changed

examples/netherland-image.ipynb

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "ece79f11-ab6e-447e-a843-c646d27e9a46",
6+
"metadata": {},
7+
"source": [
8+
"# Stream and visualize the Autzen point cloud\n",
9+
"\n",
10+
"The original data used in this notebook can be [found here](https://github.com/PDAL/data/tree/master/autzen) and has a BSD license as [described here](https://pdal.io/en/latest/copyright.html#overall-pdal-license-bsd)."
11+
]
12+
},
13+
{
14+
"cell_type": "code",
15+
"execution_count": null,
16+
"id": "34b3f824-b53c-4d9d-b4d2-8e900ff7252f",
17+
"metadata": {},
18+
"outputs": [],
19+
"source": [
20+
"from pybabylonjs import Show as show, ImageFeatureType"
21+
]
22+
},
23+
{
24+
"cell_type": "markdown",
25+
"id": "5c4ec8bd-7b69-48f0-b70d-9977e07d2d7d",
26+
"metadata": {},
27+
"source": [
28+
"To stream and view point cloud data from a TileDB array a `token` is needed: \n",
29+
"* [sign up for a TileDB account](https://cloud.tiledb.com/auth/signup)\n",
30+
"\n",
31+
"When running this notebook locally:\n",
32+
"* [create a token as described here](https://docs.tiledb.com/cloud/how-to/account/create-api-tokens)\n",
33+
"* uncomment the below cell and add your token (`<token>`)\n",
34+
"* run the below cells\n",
35+
"\n",
36+
"When running this notebook on TileDB Cloud:\n",
37+
"* the token will be automatically loaded\n",
38+
"* remove the token from the list of parameters of `show.image`\n",
39+
"* run the below cells"
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": null,
45+
"id": "6ce7f8c7-0805-444b-93ad-3b7554de8304",
46+
"metadata": {},
47+
"outputs": [],
48+
"source": [
49+
"# token = \"...\""
50+
]
51+
},
52+
{
53+
"cell_type": "code",
54+
"execution_count": null,
55+
"id": "19e3204d-d1a1-4ab8-a888-5833ed44e41d",
56+
"metadata": {},
57+
"outputs": [],
58+
"source": [
59+
"show.image(token=token,\n",
60+
" engine_api=\"WEBGPU\",\n",
61+
" name_space=\"TileDB-Inc\",\n",
62+
" array_name=\"tiledb://TileDB-Inc/ee5eae5f-9f68-4471-a762-99e966cada1c\",\n",
63+
" point_group_names=[\"tiledb://TileDB-Inc/a89e17ae-4fc7-433f-a2ee-856ee0ecf216\"],\n",
64+
" tile_uris=[\"https://api.pdok.nl/kadaster/3d-basisvoorziening/ogc/v1_0/collections/terreinen/3dtiles\"],\n",
65+
" default_channels=[{\"index\": 1, \"intensity\": 2000}, {\"index\": 2, \"intensity\": 2000}, {\"index\": 3, \"intensity\": 2000}],\n",
66+
" scene_config={\n",
67+
" \"pointConfigs\":[{\n",
68+
" \"pickable\": False,\n",
69+
" \"features\":[\n",
70+
" {\n",
71+
" \"name\": \"Height\",\n",
72+
" \"type\": ImageFeatureType.RGB.value[0],\n",
73+
" \"interleaved\": True,\n",
74+
" \"attributes\":[\n",
75+
" {\n",
76+
" \"name\": \"Red\",\n",
77+
" \"normalize\": True,\n",
78+
" \"normalizationWindow\": { \"min\": 0, \"max\": 255 }\n",
79+
" },\n",
80+
" {\n",
81+
" \"name\": \"Green\",\n",
82+
" \"normalize\": True,\n",
83+
" \"normalizationWindow\": { \"min\": 0, \"max\": 255 }\n",
84+
" },\n",
85+
" {\n",
86+
" \"name\": \"Blue\",\n",
87+
" \"normalize\": True,\n",
88+
" \"normalizationWindow\": { \"min\": 0, \"max\": 255 }\n",
89+
" }\n",
90+
" ]\n",
91+
" }\n",
92+
" ]\n",
93+
" }]\n",
94+
" },\n",
95+
" width = 1200,\n",
96+
" height = 700)"
97+
]
98+
}
99+
],
100+
"metadata": {
101+
"kernelspec": {
102+
"display_name": "Python 3 (ipykernel)",
103+
"language": "python",
104+
"name": "python3"
105+
},
106+
"language_info": {
107+
"codemirror_mode": {
108+
"name": "ipython",
109+
"version": 3
110+
},
111+
"file_extension": ".py",
112+
"mimetype": "text/x-python",
113+
"name": "python",
114+
"nbconvert_exporter": "python",
115+
"pygments_lexer": "ipython3",
116+
"version": "3.12.6"
117+
}
118+
},
119+
"nbformat": 4,
120+
"nbformat_minor": 5
121+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"dependencies": {
5959
"@jupyter-widgets/base": "^2 || ^3 || ^4 || ^5 || ^6",
6060
"@jupyterlab/application": "^3 || ^4",
61-
"@tiledb-inc/viz-core": "^1.0.3-alpha.2"
61+
"@tiledb-inc/viz-core": "^1.0.3-alpha.7"
6262
},
6363
"devDependencies": {
6464
"@jupyterlab/builder": "^3 || ^4",

pybabylonjs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
from pathlib import Path
3-
from .show import BabylonJS, Show
3+
from .show import BabylonJS, Show, ImageFeatureType
44
from ._version import __version__
55

66
HERE = Path(__file__).parent.resolve()

pybabylonjs/args.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,20 @@
4141
}
4242

4343
IMAGE_ARGS_DEFAULTS = {
44+
"engine_api": None,
4445
"width": None,
4546
"height": None,
46-
"wheel_precision": None, # used? in base class?
47-
"move_speed": None, # used?
4847
"name_space": None,
4948
"array_name": None,
5049
"group_name": None,
5150
"geometry_array_names": None,
5251
"point_group_names": None,
52+
"tile_uris": None,
5353
"base_group": None,
5454
"token": None,
5555
"tiledb_env": None,
5656
"default_channels": None,
57+
"scene_config": None,
5758
}
5859

5960

pybabylonjs/show.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ class PyBabylonJSError(Exception):
2121
pass
2222

2323

24+
class ImageFeatureType(Enum):
25+
NON_RENDERABLE = (0,)
26+
RGB = (1,)
27+
CATEGORICAL = (2,)
28+
FLAT_COLOR = 3
29+
30+
2431
class Show:
2532
"""Create a N-D visualization."""
2633

src/widget.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,23 +158,23 @@ export class BabylonTileImageModel extends BabylonBaseModel {
158158
export class BabylonTileImageView extends BabylonBaseView {
159159
render() {
160160
this.visualization = new TileDBTileImageVisualization({
161+
engineAPI: this.values.engine_api,
161162
namespace: this.values.name_space,
162163
arrayID: this.values.array_name,
163164
groupID: this.values.group_name,
164165
geometryArrayID: this.values.geometry_array_names,
165166
pointGroupID: this.values.point_group_names,
167+
tileUris: this.values.tile_uris,
166168
baseGroup: this.values.base_group,
167169
token: this.values.token,
168170
tiledbEnv: this.values.tiledb_env,
169171
width: this.values.width,
170172
height: this.values.height,
171-
wheelPrecision: this.values.wheel_precision,
172-
moveSpeed: this.values.move_speed,
173173
rootElement: this.el,
174-
defaultChannels: this.values.default_channels
174+
defaultChannels: this.values.default_channels,
175+
sceneConfig: this.values.scene_config
175176
});
176177

177-
console.log(this.visualization);
178178
this.visualization.render();
179179
}
180180
}

0 commit comments

Comments
 (0)