Skip to content

3D camera parameters with clear reference system and scale #1778

@ShapingView

Description

@ShapingView

Hello everyone,

I frequently have the issue with not being able to properly set the 3D camera parameters.

I don't see how the 3D camera setting parameters can be used to set the center or the eye on a specific location in the plotted 3D coordinate system.

Here comes a simple example:

  • two 3D point clouds of random points around coordinates (0,0,0) and (10, 10, 10)
  • I want to focus the view on the point cloud (0, 0, 0) with a view distance of 3
# example as run in a Jupyter Notebook cell
import plotly.graph_objects as go
import numpy as np

fig = go.FigureWidget()

pointcloud1 = np.random.rand(3, 30) 
pointcloud2 = np.random.rand(3, 30) + np.array([10, 10, 10])[:, None]

fig.add_scatter3d(x=pointcloud1[0], y=pointcloud1[1], z=pointcloud1[2], name='cloud 1')
fig.add_scatter3d(x=pointcloud2[0], y=pointcloud2[1], z=pointcloud2[2], name='cloud 2')

fig.layout.scene.camera = go.layout.scene.Camera(
    center=dict(x=0, y=0, z=0),
    eye=dict(x=0, y=0, z=3),
    up=dict(x=0, y=1, z=0),
)

fig.layout.height = 500
fig.layout.width = 700
fig

The resulting plot looks like this:

image

The view is obviously centered somewhere in the middle between the point clouds, and the distance z=3 in the eye parameter does not correspond to the 3D graph distance as well (its more like 20 or 30).

Hope you guys can help me out here, since I did not find any way to work around this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions