Scenegraph Layer Example¶
glTF 3D model rendering using deck.gl ScenegraphLayer.
In [ ]:
Copied!
# %pip install anymap-ts
# %pip install anymap-ts
In [ ]:
Copied!
from anymap_ts import DeckGLMap
from anymap_ts import DeckGLMap
Define model positions¶
In [ ]:
Copied!
# Sample positions for glTF models
model_positions = [
{"coordinates": [-122.4, 37.8, 0], "orientation": [0, 0, 90]},
{"coordinates": [-122.38, 37.79, 0], "orientation": [0, 0, 180]},
{"coordinates": [-122.42, 37.78, 0], "orientation": [0, 0, 270]},
{"coordinates": [-122.39, 37.81, 0], "orientation": [0, 0, 0]},
{"coordinates": [-122.41, 37.77, 0], "orientation": [0, 0, 45]},
]
# Sample positions for glTF models
model_positions = [
{"coordinates": [-122.4, 37.8, 0], "orientation": [0, 0, 90]},
{"coordinates": [-122.38, 37.79, 0], "orientation": [0, 0, 180]},
{"coordinates": [-122.42, 37.78, 0], "orientation": [0, 0, 270]},
{"coordinates": [-122.39, 37.81, 0], "orientation": [0, 0, 0]},
{"coordinates": [-122.41, 37.77, 0], "orientation": [0, 0, 45]},
]
Create map with scenegraph layer¶
In [ ]:
Copied!
m = DeckGLMap(center=[-122.4, 37.79], zoom=13, pitch=60, bearing=-17)
m.add_basemap("CartoDB.DarkMatter")
m.add_scenegraph_layer(
data=model_positions,
# Khronos glTF sample model
scenegraph="https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Duck/glTF-Binary/Duck.glb",
get_position="coordinates",
get_orientation="orientation",
size_scale=500,
pickable=True,
)
m
m = DeckGLMap(center=[-122.4, 37.79], zoom=13, pitch=60, bearing=-17)
m.add_basemap("CartoDB.DarkMatter")
m.add_scenegraph_layer(
data=model_positions,
# Khronos glTF sample model
scenegraph="https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Duck/glTF-Binary/Duck.glb",
get_position="coordinates",
get_orientation="orientation",
size_scale=500,
pickable=True,
)
m
Export to HTML¶
In [ ]:
Copied!
m.to_html("scenegraph_layer_example.html")
m.to_html("scenegraph_layer_example.html")