materialsproject / crystaltoolkit

Crystal Toolkit is a framework for building web apps for materials science and is currently powering the new Materials Project website.
https://docs.crystaltoolkit.org
Other
135 stars 57 forks source link

[Feature Request]: Persistent camera orientation when modifying crystal structure #367

Open Abhivega opened 9 months ago

Abhivega commented 9 months ago

Email (Optional)

No response

Problem

In this example, if we rotate the visualized structure interactively and then swap the current structure for another one, the camera orientation is reset.

Proposed Solution

Is there a way to specify a desired view axis, or to make the camera view persistent when the structure is modified?

Alternatives

No response

Code of Conduct

mkhorton commented 9 months ago

Hi @Abhivega, a very reasonable request!

The underlying rendering code is currently a little messy, but to support this feature, a conditional on this.settings (perhaps, this.settings.resetCamera) would have to be added to this line:

https://github.com/materialsproject/mp-react-components/blob/5a54523c600919312929fd513ec93e39e680f5ef/src/components/crystal-toolkit/scene/Scene.ts#L493

and an appropriate default added here:

https://github.com/materialsproject/mp-react-components/blob/5a54523c600919312929fd513ec93e39e680f5ef/src/components/crystal-toolkit/scene/constants.ts#L51

I don't have time to add this myself at present, but pull requests very welcome.