Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3D surfaces not rotated correctly #130

Open
rdgraham opened this issue Nov 1, 2022 · 5 comments
Open

3D surfaces not rotated correctly #130

rdgraham opened this issue Nov 1, 2022 · 5 comments

Comments

@rdgraham
Copy link
Contributor

rdgraham commented Nov 1, 2022

In a new build, rotations are not being applied correctly to 3d surfaces in the Plot3d py3js output.

The underlying simulation seems to be correct, but the surfaces of components are not rotated correctly. In the example below (taken from the tutorial), the cylindrical sides of the lens are rotated about the wrong axis.

This was discussed in the comments of pull request #127
Initially this was suspected to be related to the windows build, but actually seems to happen in linux also on a new install, using python 3.10, pythreejs 2.4.1.

image

@rdgraham
Copy link
Contributor Author

rdgraham commented Nov 1, 2022

I have since found a solution, although I don't fully understand it.

It seems I can get it to work normally if change the code for applying rotations to the surfaces and components in ipywidgets.py,
from directly applying the rotation via the attribute to calling the three individual rotation methods. I.e.

c.rotation = *D, "ZYX"
c.position = tuple(P)

to

c.position = tuple(P)
c.rotateZ(D[2])
c.rotateY(D[1])
c.rotateX(D[0])

although I couldn't see any notice or reason for this change in threejs.

Another thing that may or may not be related -- when testing in firefox I noticed that there is now an issue with the centering of the field of view. It is no longer centered on the center of rotation of the camera, so often it is not possible to see the whole model. However, this seemed to be firefox specific, and when I tried in chrome that problem does not occur.

In any case, I will go ahead and make a pull request for this small fix. Would be good to understand what is going on though.

@ramezquitao
Copy link
Member

There is something weird going on here. In my case, this is working when opening a notebook in jupyterlab, but there are problems with the rotaions when the documentation is generated.

@ramezquitao
Copy link
Member

ramezquitao commented Jan 5, 2023

@rdgraham do you use jupyter notebook or jupyter lab? . I'm not being able to make pythreejs work in Juyter notebook, but in Jupyter lab is working fine.

@rdgraham
Copy link
Contributor Author

rdgraham commented Jan 6, 2023

I am using jupyter lab.

I just tried with the legacy jupyter notebook. I am seeing an issue with threejs:

image

Is this the issue you are seeing, or something else?

In my case, it seems like some issue with my installation, not related to the surface rotation issue. In any case, I don't have much need to debug it since I don't have a reason to use jupyter notebook, which seems to be being deprecated.

I am not familiar with the documentation generation. If you could post the current procedure I could try to replicate the issue.

@ramezquitao
Copy link
Member

Yes, that is exactly the issue. About the documentation, it is all located in the doc folder, and sphinx is being used. Also a sphinx extension called nbsphinx that allow to include Jupyter notebooks in the documentation, is being used. I'dont know the internals of nbsphinx, but it requires ipykernel to work so this is why I was trying to use the jupyter notebook to check how the documentation notebooks look there (because in Jupyter lab they look ok).

To generate a local copy of the documentation, you need to run make html inside the doc folder. The requirements.txt inside the doc folder is the one used by read the docs to generate the correct environment. If you have problems generating the documentation, you can check the branch docs of my personal pyoptools repository (https://github.com/ramezquitao/pyoptools/tree/docs), this one seems to be working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants