facebookresearch / facebookresearch/pytorch3d
Confusing 3D plot visualization in `deform_source_mesh_to_target_mesh.ipynb`
- Dominant language
- Python
- Stars
- 10k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
## 🐛 Bugs / Unexpected behaviors
Hello,
I noticed that the 3D plotting function (plot_pointcloud) in the deform_source_mesh_to_target_mesh tutorial uses a confusing visualization setup.
The code plots the Y-up model upside-down (using ax.scatter3D(x, z, -y)) but sets the camera view from underneath (ax.view_init(190, 30)).
This combination of an inverted model and an inverted camera makes the plot appear correct, but it's misleading and causes inverted mouse controls, which is highly confusing for users learning the library.
## Instructions To Reproduce the Issue:
The bug is present in the original plot_pointcloud function within the [tutorial](https://github.com/facebookresearch/pytorch3d/blob/main/docs/tutorials/deform_source_mesh_to_target_mesh.ipynb):
```Python
# docs/tutorials/deform_source_mesh_to_target_mesh.ipynb
def plot_pointcloud(mesh, title=""):
# Sample points uniformly from the surface of the mesh.
points = sample_points_from_meshes(mesh, 5000)
x, y, z = points.clone().detach().cpu().squeeze().unbind(1)
fig = plt.figure(figsize=(5, 5))
ax = fig.add_subplot(111, projection='3d')
ax.scatter3D(x, z, -y) # <-- Problem: Renders model upside-down
ax.set_xlabel('x')
ax.set_ylabel('z')
ax.set_zlabel('y')
ax.set_title(title)
ax.view_init(190, 30) # <-- Problem: Views from underneath
plt.show()
```
The exact command(s) I ran:
```Bash
# 1. Open the tutorial notebook
# (e.g., in VS Code or Jupyter)
# docs/tutorials/deform_source_mesh_to_target_mesh.ipynb
# 2. Run the cells sequentially until the first plot ("dolphin mesh") is generated.
```
What I observed (including the full logs):
The plot of the obj appears to be right-side up. However, interacting with the plot using the mouse reveals that the rotation controls are inverted.
**Root Cause**:
The model is Y-up, but it's being plotted with `ax.scatter3D(x, z, -y)`, which maps the model's Up (+y) direction to the plot's Down (-z) direction. The `ax.view_init(190, 30)` then views this upside-down model from underneath, creating an illusion of it being correct.
**Proposed Fix**:
The plot function should use the correct coordinate mapping (x, -z, y) and a standard view angle (e.g., elev=30, azim=30) for intuitive results.
Contributor guide
Research direction
Open docs/tutorials/deform_source_mesh_to_target_mesh.ipynb and inspect the plot_pointcloud function. Run the notebook through the first dolphin mesh plot, then check the coordinate mapping and camera settings while interacting with the 3D figure. Done means the model uses the proposed intuitive orientation and mouse rotation is no longer inverted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter-notebook, matplotlib, python
- Domain
- computer-graphics, documentation
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100