question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support/Demo for First Person View in pydeck

See original GitHub issue

I 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: image

Looking at the browser output, I also found multiple errors: image

Does pydeck expect different inputs compared to deck.gl, or is the first person view restricted to only a few layers?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

1reaction
xhlucacommented, Oct 28, 2020

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.

Peek 2020-10-28 11-17

1reaction
ajdubersteincommented, Oct 27, 2020

@xhlulu let us know if you have any further questions. It does look like FirstPersonView works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FirstPersonView - deck.gl
The FirstPersonView class is a subclass of View that describes a camera placed at a provided location, looking towards the direction and orientation...
Read more >
View — pydeck 0.8.0b3 documentation - Read the Docs
Parameters: type (str, default None) – deck.gl view to display, e.g., MapView; controller (bool, default None) – If enabled, camera becomes interactive.
Read more >
Andrew Duberstein -Pydeck: High-scale geospatial ... - YouTube
Brief SummaryWith social graphs, genomics, and sensor data visualizations, data scientists often need to render massive spatial data sets.
Read more >
Pydeck hexlayer slow with large number of points
import numpy as np import pandas as pd import pydeck as pdk import streamlit as st lat0=40.7 lon0=-74.12 n_points = 100000 lat ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found