Support/Demo for First Person View in pydeck
See original GitHub issueI really like the MapView
and OrbitView
, but for things like street navigation, I think FirstPersonView
would be more convenient for things like street navigation, especially when combined with point clouds and path layers.
According to the deck.gl documentations:
To render, a FirstPersonView needs to be combined with a viewState object with the following parameters:
- longitude (Number, optional) - longitude of the camera
- latitude (Number, optional) - latitude of the camera
- position (Number[3], optional) - meter offsets of the camera from the lng-lat anchor point. Default [0, 0, 0].
- bearing (Number, optional) - bearing angle in degrees. Default 0 (north).
- pitch (Number, optional) - pitch angle in degrees. Default 0 (horizontal).
- maxPitch (Number, optional) - max pitch angle. Default 90 (down).
- minPitch (Number, optional) - min pitch angle. Default -90 (up).
Naturally, I experimented with the FirstPersonView
by slightly changing the official Path Layer demo. This is in a jupyter notebook with the latest pydeck version:
import pydeck as pdk
import pandas as pd
import math
DATA_URL = "https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/bart-lines.json"
df = pd.read_json(DATA_URL)
def hex_to_rgb(h):
h = h.lstrip("#")
return tuple(int(h[i : i + 2], 16) for i in (0, 2, 4))
df["color"] = df["color"].apply(hex_to_rgb)
view_state = pdk.ViewState(latitude=37.782556, longitude=-122.3484867)
view = pdk.View('FirstPersonView', controller=True)
layer = pdk.Layer(
type="PathLayer",
data=df,
pickable=True,
get_color="color",
width_scale=20,
width_min_pixels=2,
get_path="path",
get_width=5,
)
r = pdk.Deck(layers=[layer], initial_view_state=view_state, views=[view], tooltip={"text": "{name}"})
r.to_html("path_layer.html")
Unfortunately, it did not generate anything:
Looking at the browser output, I also found multiple errors:
Does pydeck
expect different inputs compared to deck.gl, or is the first person view restricted to only a few layers?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7
Top GitHub Comments
It works very well, sorry for leaving this issue open!
I open-sourced the app that uses first person view to visualize point clouds. The code is here.
@xhlulu let us know if you have any further questions. It does look like FirstPersonView works.