widgetti / ipyvolume

3d plotting for Python in the Jupyter notebook based on IPython widgets using WebGL
MIT License
1.94k stars 234 forks source link

Error when changing Camera #438

Open pytunia opened 1 year ago

pytunia commented 1 year ago

Hi everyone,

according to https://ipyvolume.readthedocs.io/en/latest/pythreejs.html#Camera "other cameras should also work".
So I tried the following in my jupyter notebook:

fig = ipv.figure()
newcamera = pythreejs.OrthographicCamera()
fig.camera = newcamera
mesh = ipv.plot_wireframe(Xt, Yt, Zt)
VBox([ipv.gcc()])
ipv.show()

I end up getting these errors:

0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
[E 09:23:36.605 NotebookApp] Uncaught exception, closing connection.
    Traceback (most recent call last):
      File "C:\Users\User01\AppData\Local\Programs\Python\Python311\Lib\site-packages\tornado\iostream.py", line 695, in _handle_events
        self._handle_write()
      File "C:\Users\User01\AppData\Local\Programs\Python\Python311\Lib\site-packages\tornado\iostream.py", line 965, in _handle_write
        self._write_buffer.advance(num_bytes)
      File "C:\Users\User01\AppData\Local\Programs\Python\Python311\Lib\site-packages\tornado\iostream.py", line 182, in advance
        assert 0 < size <= self._size
               ^^^^^^^^^^^^^^^^^^^^^^
    AssertionError
Exception in callback None()
handle: <Handle cancelled>
Traceback (most recent call last):
  File "C:\Users\User01\AppData\Local\Programs\Python\Python311\Lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "C:\Users\User01\AppData\Local\Programs\Python\Python311\Lib\site-packages\tornado\platform\asyncio.py", line 192, in _handle_events
    handler_func(fileobj, events)
  File "C:\Users\User01\AppData\Local\Programs\Python\Python311\Lib\site-packages\tornado\iostream.py", line 695, in _handle_events
    self._handle_write()
  File "C:\Users\User01\AppData\Local\Programs\Python\Python311\Lib\site-packages\tornado\iostream.py", line 965, in _handle_write
    self._write_buffer.advance(num_bytes)
  File "C:\Users\User01\AppData\Local\Programs\Python\Python311\Lib\site-packages\tornado\iostream.py", line 182, in advance
    assert 0 < size <= self._size
           ^^^^^^^^^^^^^^^^^^^^^^
AssertionError

Not sure what to do with that. Any help is greatly appreciated.

Thanks!

maartenbreddels commented 1 year ago

Hi,

did you tree without this camera? I've seen this error and I think it is not related. I think the issue is an incompatible tornado version for jupyter.

Regards,

Maarten

pytunia commented 1 year ago

Hi Maarten,

the plot does work without these two lines:

#newcamera = pythreejs.OrthographicCamera()
#fig.camera = newcamera

Actually the change of the camera (orthographic) just causes a blank output, where the plot should be.

Edit: So I did a little more digging. And I think it has to do with some nan's in fig.camera.projectionMatrix. After some more strategic investigation I got the following error:

TraitError: The 'matrix_projection' trait of a Figure instance contains a CFloat of a List which expected a float, not the NoneType None.

camera_test4

It could be related to #40 .