nglviewer / ngl

WebGL protein viewer
http://nglviewer.org/ngl/
MIT License
667 stars 170 forks source link

Volume map not loading on center with boxSize #734

Open DAlvGar opened 4 years ago

DAlvGar commented 4 years ago

Hi all!

I am having a weird behavior when i first load the electron density map setting boxSize=10. The map loads somewhere else in the scene. If I rotate the scene it stays uncentered. It shows correctly as soon as I translate the structure. What can be wrong here? How can i fix this?

Thanks for the help!

image

DAlvGar commented 4 years ago

when i check the boxCenter before and after translating the protein, it is the same position, so the boxCenter is well calculated and assigned, but it seems the rendering is not taking it into account?

DAlvGar commented 4 years ago

Ok more details, i think i found the problem. Sometimes the prepare function is executed before the setBox() callback is executed for the first time so the boxCenter is 0. I added a first call right at init time and this seems to solve the problem.

image

image

fredludlow commented 4 years ago

Good spot! I can merge a PR if you'd like to make one?

DAlvGar commented 4 years ago

Hi Fred! I tried and I don't have the rights to create branches / PRs

fredludlow commented 4 years ago

Ah okay - the normal workflow is something like:

Create a fork (top right of the page on github) Clone your fork locally (Build NGL) Create a new branch locally Make changes (Build NGL) Commit the changes in ./src to your new branch Push your branch back to github (to your own fork) Make a pull request to merge your branch with arose/ngl master (through the github web interface, this is the easy bit)

(see also https://guides.github.com/activities/forking/)

Equally happy to just make the PR myself (or provide more detailed instructions) - let me know!