plotly / plotly/plotly.js

Scatter 3D dragmode turntable loses the camera.eye on JavaScript reload

Open
#6,359 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
JavaScript
Stars
18.3k
Forks
2k
Avg merge
2d 12h
Merged PRs (30d)
28

Description

Scatter 3D dragmode "orbit" and "turntable" moves camera.eye but it is not reflected to layout.schene.camera.eye of the frame. It will be saved just after mouse click event or wheel, through relayoutCallback > scene.saveLayout .
https://github.com/plotly/plotly.js/blob/35fb5b918e3dbdc3cc6e3b9735c8003008376020/src/plots/gl3d/scene.js#L240

If replot, react, animate and so on, happens during mouse move and mouse up, replot uses layout.schene.camera.eye saved BEFORE and overwrite.

It can reploduced in https://halueda.github.io/wavy-orbitals/ .
Its color is chaneged once a second and you can only rotate 3d-axis if mouse move is in 1 second, during color change.

To solve this, there seems two ways.

  1. every mouse move event do scene.saveLayout. It may cause performance impact.
  2. replot function do scene.saveLayout if the plot is 3d.

Perhaps more genral way should be used. For example, mouse moving event set into something like pending events and replot-api executes all pending events prior to real replot. As well as, scene.saveLayout clears the pending event.

This issue can be related to:
#5500
#5005
#5560

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/plots/gl3d/scene.js around line 240 and reproduce the camera state loss in the linked wavy-orbitals example while color updates trigger replots. Trace relayoutCallback, scene.saveLayout, and the replot path. Done means orbit or turntable camera.eye changes survive replot, react, or animation during mouse movement without overwriting the current view.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.