jupyter-widgets / pythreejs

A Jupyter - Three.js bridge
https://pythreejs.readthedocs.io
Other
942 stars 188 forks source link

Error display widget + name not defined #182

Closed sbonaretti closed 6 years ago

sbonaretti commented 6 years ago

Hi,

I am new to pythreejs. I have tried to make it work for a few days without succeeding. I have two issues:

  1. I have installed pythrees using the instructions here: http://pythreejs.readthedocs.io/en/latest/. In Jupyter Lab, I get Error displaying widget. In Jupyter notebook the rendering sometimes happens and sometimes it does not.
    Example:
    If I run:
    BoxGeometry(
    width=5,
    height=10,
    depth=15,
    widthSegments=5,
    heightSegments=10,
    depthSegments=15)

    --> In JupyterLab, I get Error displaying widget --> In Jupyter Notebook, I do not get anything.

If I run:

ball = Mesh(geometry=SphereGeometry(radius=1), 
                                    material=LambertMaterial(color='red'),
                                    position=[2, 1, 0])

scene = Scene(children=[ball, AmbientLight(color='#777777')])

c = PerspectiveCamera(position=[0, 5, 5], up=[0, 0, 1],
                      children=[DirectionalLight(color='white', 
                                                 position=[3, 5, 1], 
                                                 intensity=0.5)])
renderer = Renderer(camera=c, 
                    scene=scene, 
                    controls=[OrbitControls(controlling=c)])
display(renderer)

--> In JupyterLab, I get Error displaying widget --> In Jupyter Notebook, I can see the red ball.

When I type jupyter labextension list, I get:

JupyterLab v0.32.1
Known labextensions:
   app dir: /Users/<userName>/anaconda3/share/jupyter/lab
@jupyter-widgets/jupyterlab-manager
        @jupyter-widgets/jupyterlab-manager v0.35.0  enabled  OK
jupyter-matplotlib
        jupyter-matplotlib v0.3.0  enabled  OK
jupyter-threejs
        jupyter-threejs v1.0.0  enabled  OK
jupyterlab-datawidgets
        jupyterlab-datawidgets v5.0.1  enabled  OK
  1. I am trying to follow the examples in the new manual (https://media.readthedocs.org/pdf/pythreejs/latest/pythreejs.pdf). When I run:
    BoxBufferGeometry(
    width=5,
    height=10,
    depth=15,
    widthSegments=5,
    heightSegments=10,
    depthSegments=15)

    from page 7 (11 of the .pdf), I get:

    
    ---------------------------------------------------------------------------
    NameError                                 Traceback (most recent call last)
    <ipython-input-4-9da8cd7049c5> in <module>()
    ----> 1 BoxBufferGeometry(
      2             width=5,
      3             height=10,
      4             depth=15,
      5             widthSegments=5,

NameError: name 'BoxBufferGeometry' is not defined


Can anyone give me hints on how to make pythreejs work? I am really looking forward to using it!  
Thanks!
vidartf commented 6 years ago

Hard to see immediately what is wrong, but a few points to help tracking this down:

  1. Which version is installed (pip list)?
  2. For the examples, the docs are better than the PDF, as they include embedded widgets on the page (http://pythreejs.readthedocs.io/en/latest/examples/Geometries.html). Are you only seeing the error for BoxBufferGeometry, or for any geometry type? The line that should import the class is from pythreejs import *.
vidartf commented 6 years ago
  1. For both lab and notebook it would be interesting to see any error output from browser console or the server log.
sbonaretti commented 6 years ago

Hi! Thanks so much for working on this with me!

  1. pip list gives pythreejs 1.0.0
  2. Thanks for the link, I will follow that. Yes, I use from pythreejs import *. I see the error for every Buffer geometry.
  3. Please find attached screenshot of lab:
    lab
    and screenshot of notebook:
    notebook
    Please, let me know if I can provide any further details. Thanks a lot!
vidartf commented 6 years ago

How was pythreejs installed? It sounds like something has gone wrong with the autogenerated code.

sbonaretti commented 6 years ago

Thanks a lot! Yes, uninstalling and reinstalling worked. Glad it was this easy! Thanks so much!

vidartf commented 6 years ago

Perfect! I'm closing this as resolved then. Let me know if the issue reoccurs.