A Jupyter - Three.js bridge

Overview

pythreejs

Documentation Status

A Python / ThreeJS bridge utilizing the Jupyter widget infrastructure.

Screencast

Getting Started

Installation

Using pip:

pip install pythreejs

And then install the extension for jupyter notebooks

jupyter nbextension install --py --symlink --sys-prefix pythreejs
jupyter nbextension enable --py --sys-prefix pythreejs

Or for jupyter lab:

jupyter labextension install @jupyter-widgets/jupyterlab-manager 
jupyter labextension install jupyter-threejs

Note for developers: the --symlink argument on Linux or OS X allows one to modify the JavaScript code in-place. This feature is not available with Windows.

Using conda

conda install -c conda-forge pythreejs

Developers

Autogen update

This is a significant re-work of the pythreejs extension that introduces an "autogen" script that generates the majority of the ipython-widget code to wrap each of three.js's types. It also takes a different view towards the pythreejs API. Whereas pythreejs adds custom functionality to the classes, sometimes renaming, etc., this approach attempts to mimic the low-level three.js API as closely as possible, opening up the possibility for others to build utility libraries on top of this.

The autogen script, generate-wrappers.js, takes advantage of a config file three-class-config.js to auto-generate both javascript and python files to define the ipywidget wrappers for each three.js class. The generated javascript files will have .autogen.js as the extension. The generated python files have _autogen.py as their extension. The script uses the handlebars template system to generate the various code files.

The autogen solution allows for overriding the default behavior of the generated classes. E.g., if Object3D.js is present, then it will be loaded into the namespace as opposed to loading Object3D.autogen.js. It is up to the author of the override classe to decide whether to inherit behavior from the autogen class or not. Same goes for the python modules. This allows for writing custom methods on both the python and javascript side when needed.

The autogen script relies on a json-like config file (three-class-config.js) to describe the classes. Reasonable defaults should take care of most, but it allows specifying the base class, constructor args, etc. for each of the wrappers. A base version of this file can be generated by generate-class-config.js, but beware, it overwrites any customization to the config file that has already been done.

Setup

The relevant commands while working on the repository are included below. These are not meant to be run sequentially, but rather as a list of useful commands:

# To perform initial dev setup, run:
pip install -e .

# All commands below assume to be in the ./js/ directory
cd ./js/

# To re-generate autogen files, run:
npm run autogen

# To build and install distribution files, run:
npm run build:all
jupyter nbextension install --py --symlink --sys-prefix pythreejs

# To clean out generated files, run:
npm run clean
Comments
  • Auto gen wrappers

    Auto gen wrappers

    This is a significant re-work of the pythreejs extension that introduces an "autogen" script that generates the majority of the ipython-widget code to wrap each of three.js's types. It also takes a different view towards the pythreejs API. Whereas pythreejs adds custom functionality to the classes, sometimes renaming, etc., this approach attempts to mimic the low-level three.js API as closely as possible, opening up the possibility for others to build utility libraries on top of this.

    This PR does not support all the functionality of the current pythreejs, but it is a significant step forward in terms of the potential to support the majority of three.js's features. Currently supported features:

    • Basic building blocks of a scene:
      • Textures (both Image-based and Data-based)
      • Materials
      • Geometries
      • Meshs
      • Scene, Lights, Cameras, WebGLRenderer

    The autogen script, generate-wrappers.js, takes advantage of a config file three-class-config.js to auto-generate both javascript and python files to define the ipywidget wrappers for each three.js class. The generated javascript files will have .autogen.js as the extension. The generated python files have _autogen.py as their extension. The script uses the handlebars template system to generate the various code files.

    The autogen solution allows for overriding the default behavior of the generated classes. E.g., if Object3D.js is present, then it will be loaded into the namespace as opposed to loading Object3D.autogen.js. It is up to the author of the override classe to decide whether to inherit behavior from the autogen class or not. Same goes for the python modules. This allows for writing custom methods on both the python and javascript side when needed.

    The autogen script relies on a json-like config file (three-class-config.js) to describe the classes. Reasonable defaults should take care of most, but it allows specifying the base class, constructor args, etc. for each of the wrappers. A base version of this file can be generated by generate-class-config.js, but beware, it overwrites any customization to the config file that has already been done.

    List of relevant files:

    js/package.json
    js/webpack.config.js
    
    # Files for auto-generation
    js/scripts/clean-generated-files.js
    js/scripts/generate-class-config.js
    js/scripts/generate-wrappers.js
    js/scripts/prop-types.js
    js/scripts/templates/js_index.mustache
    js/scripts/templates/js_param_obj.mustache
    js/scripts/templates/js_wrapper.mustache
    js/scripts/templates/py_top_level_init.mustache
    js/scripts/templates/py_wrapper.mustache
    js/scripts/three-class-config-defaults.js
    js/scripts/three-class-config.js
    js/scripts/three-class-config.js.backup
    
    # New bases classes for supporting wrapper classes
    js/src/_base/RendererPool.js
    js/src/_base/Three.js
    js/src/_base/enums.js
    pythreejs/_base/Three.py
    pythreejs/enums.py
    pythreejs/traits.py
    
    # Overridden classes
    js/src/core/Object3D.js
    js/src/textures/DataTexture.js
    js/src/textures/ImageTexture.js # custom classed created to ease image texture loading
    js/src/renderers/WebGLRenderer.js
    pythreejs/core/Object3D.py
    pythreejs/renderers/WebGLRenderer.py
    
    # Updated examples notesbooks
    examples/Examples.ipynb
    examples/Geometries.ipynb
    examples/Textures.ipynb
    examples/renderer_limit.ipynb
    examples/test.ipynb
    examples/img/checkerboard.png
    examples/img/earth.jpg
    
    # Pulled in latest version of examples files from three.js source
    js/src/examples/Detector.js
    js/src/examples/controls/MomentumCameraControls.js
    js/src/examples/controls/OrbitControls.js
    js/src/examples/controls/TrackballControls.js
    js/src/examples/js/controls/OrbitControls.js
    js/src/examples/renderers/CanvasRenderer.js
    js/src/examples/renderers/Projector.js
    
    opened by abelnation 29
  • Auto gen wrappers

    Auto gen wrappers

    opened by abelnation 28
  • "runtime disconnect" in Colab for BufferGeometry(...)

    Here is the link:
    https://colab.research.google.com/drive/1ZdOYamFGclGdPDbIkXExF8KRYQ6dAdGu

    When running, cubeGeometry = BufferGeometry(...)

    it results in "runtime disconnect."

    Any idea why or how to fix it?

    opened by RezaRob 24
  • Conda-forge package at version 0.4.1

    Conda-forge package at version 0.4.1

    Since you mention it in the installation instructions, I thought I would let you know

    conda install -c conda-forge pythreejs

    installs version 0.4.1, not the current 1.0.0. Someone needs to update the condo-forge package.

    opened by JuanCab 24
  • pythreejs under JupyterLab 0.33.6: Error:

    pythreejs under JupyterLab 0.33.6: Error: "Could not create a model."

    I'm getting the following trace in the Chrome console under JLab 0.33.4 + ipywidgets 7.3.1 when trying to run pythreejs examples (e.g. Animation: sphere, cube, etc.). I guess widget declaration somehow has changed in this version of JLab.

    default.js:928` Exception opening new comm
    (anonymous) @ default.js:928
    s @ default.js:7
    Promise.then (async)
    l @ default.js:8
    (anonymous) @ default.js:9
    YC29.n @ default.js:5
    _handleCommOpen @ default.js:913
    (anonymous) @ default.js:1020
    (anonymous) @ default.js:9
    YC29.n @ default.js:5
    _handleMessage @ default.js:977
    _msgChain._msgChain.then @ default.js:124
    Promise.then (async)
    _onWSMessage.e @ default.js:121
    default.js:129 Error: Object 'jupyter.widget' not found in registry
        at M.Promise (default.js:1476)
        at new Promise (<anonymous>)
        at Object.M [as loadObject] (default.js:1455)
        at y.<anonymous> (default.js:921)
        at Generator.next (<anonymous>)
        at default.js:9
        at new Promise (<anonymous>)
        at YC29.n (default.js:5)
        at y._handleCommOpen (default.js:913)
        at y.<anonymous> (default.js:1020)
        at Generator.next (<anonymous>)
        at default.js:9
        at new Promise (<anonymous>)
        at YC29.n (default.js:5)
        at y._handleMessage (default.js:977)
        at _msgChain._msgChain.then (default.js:124)
    _msgChain._msgChain.then.catch.e @ default.js:129
    Promise.catch (async)
    _onWSMessage.e @ default.js:126
    default.js:928 Exception opening new comm
    (anonymous) @ default.js:928
    s @ default.js:7
    Promise.then (async)
    l @ default.js:8
    (anonymous) @ default.js:9
    YC29.n @ default.js:5
    _handleCommOpen @ default.js:913
    (anonymous) @ default.js:1020
    (anonymous) @ default.js:9
    YC29.n @ default.js:5
    _handleMessage @ default.js:977
    _msgChain._msgChain.then @ default.js:124
    Promise.then (async)
    _onWSMessage.e @ default.js:121
    default.js:129 Error: Object 'jupyter.widget' not found in registry
        at M.Promise (default.js:1476)
        at new Promise (<anonymous>)
        at Object.M [as loadObject] (default.js:1455)
        at y.<anonymous> (default.js:921)
        at Generator.next (<anonymous>)
        at default.js:9
        at new Promise (<anonymous>)
        at YC29.n (default.js:5)
        at y._handleCommOpen (default.js:913)
        at y.<anonymous> (default.js:1020)
        at Generator.next (<anonymous>)
        at default.js:9
        at new Promise (<anonymous>)
        at YC29.n (default.js:5)
        at y._handleMessage (default.js:977)
        at _msgChain._msgChain.then (default.js:124)
    _msgChain._msgChain.then.catch.e @ default.js:129
    Promise.catch (async)
    _onWSMessage.e @ default.js:126
    default.js:928 Exception opening new comm
    (anonymous) @ default.js:928
    s @ default.js:7
    Promise.then (async)
    l @ default.js:8
    (anonymous) @ default.js:9
    YC29.n @ default.js:5
    _handleCommOpen @ default.js:913
    (anonymous) @ default.js:1020
    (anonymous) @ default.js:9
    YC29.n @ default.js:5
    _handleMessage @ default.js:977
    _msgChain._msgChain.then @ default.js:124
    Promise.then (async)
    _onWSMessage.e @ default.js:121
    default.js:129 Error: Object 'jupyter.widget' not found in registry
        at M.Promise (default.js:1476)
        at new Promise (<anonymous>)
        at Object.M [as loadObject] (default.js:1455)
        at y.<anonymous> (default.js:921)
        at Generator.next (<anonymous>)
        at default.js:9
        at new Promise (<anonymous>)
        at YC29.n (default.js:5)
        at y._handleCommOpen (default.js:913)
        at y.<anonymous> (default.js:1020)
        at Generator.next (<anonymous>)
        at default.js:9
        at new Promise (<anonymous>)
        at YC29.n (default.js:5)
        at y._handleMessage (default.js:977)
        at _msgChain._msgChain.then (default.js:124)
    
    opened by mprogram 23
  • bitmap output

    bitmap output

    Is there a way for producing a bitmap image of the rendnering ? Looking at some threejs examples I found that from threejs it is in principle possible to produce a png output, but if I am not mistaken pythreejs is not yet setup to do so.

    enhancement 
    opened by oroszl 20
  • Geometry instancing?

    Geometry instancing?

    I don't know if this is the right place to ask such questions, but I couldn't really find a Q/A space or forum for pythreejs.

    Could anyone point me to how one can achieve geometry instancing with pythreejs?

    I would basically want to reproduce the example described here using pythreejs.

    Or to put it more simply, I would like to have 10,000 boxes, each with a different color and orientation, with maximum performance by minimizing the number of draw calls. I don't even need any lighting, boxes can just be made of BasicMaterial.

    Any help would be greatly appreciated!

    opened by nvaytet 19
  • Scene.background default not null/None and None does not translate to null on the frontend

    Scene.background default not null/None and None does not translate to null on the frontend

    According to the docs the default background for a Scene should be null. However, when I explicitly set it to None, it translates to sth non-null on the frontend: screen shot 2018-04-11 at 10 37 14

    opened by maartenbreddels 19
  • Nothing rendered in jupyter notebook.

    Nothing rendered in jupyter notebook.

    Using pipenv I roughly have installed jupyter and pythreejs using python 3.7. A snippet of the versioning:

    pythreejs==2.2.0

    • ipydatawidgets [required: >=1.1.1, installed: 4.0.1]
      • ipywidgets [required: >=7.0.0, installed: 7.5.1]
        • ipykernel [required: >=4.5.1, installed: 5.3.4]
          • ipython [required: >=5.0.0, installed: 7.18.1]

    Widgets seem to work fine, but I have nothing rendered when I run the simple sphere example, just an empty output cell.

    Checking the javascript console there is only a few warnings about threejs not being able to invert singular matrices. There is a healthy print that it rendered: THREE.WebGLRenderer 97

    jupyter nbextension list shows everything enabled:

    Known nbextensions: config dir: /home/bingjeff/.local/share/virtualenvs/primitive_hulls-T7x0kADv/etc/jupyter/nbconfig notebook section jupyter-datawidgets/extension enabled - Validating: OK jupyter-threejs/extension enabled - Validating: OK jupyter-js-widgets/extension enabled - Validating: OK

    Should be reproducible with this repo: https://github.com/bingjeff/primitive_hulls

    Anything else I should be doing?

    opened by bingjeff 18
  • Large meshes fail to render

    Large meshes fail to render

    I've been experimenting with the use of pythreejs to render 3D triangle-mesh models of brains in jupyter; everything works fine for low-resolution models (tested up to about 60k vertices), but for larger models, the display is empty when rendered. I've put the models I've been using for tests on filedropper in hdf5 format; I can reproduce the problem by doing the following:

    1. Download the files to ~/Desktop/, then in bash: tar zxf brains.tar.gz (creates data in directory ~/Desktop/brains/)
    2. In a running Jupyer notebook, import the brain mesh data:
      import h5py, numpy as np
      brains = {}
      for resolution in [32, 164]:
          data = {}
          with h5py.File('/Users/nben/Desktop/brains/brain%dk.hdf5' % resolution) as f:
              data['vertices'] = np.array(f['vertices'])
              data['faces'] = np.array(f['faces'])
              data['colors'] = np.array(f['colors'])
          brains[resolution] = data
      
    3. Next, make a function to plot either mesh:
      def plot_brain_3D(data):
          from matplotlib.colors import to_hex
          import numpy as np
          import pythreejs as p3js
          vertices = data['vertices'].tolist()
          faces    = data['faces'].tolist()
          colors   = [to_hex(c) for c in data['colors']]
      
          faces = [f + [None, [colors[i] for i in f]] for f in faces]
      
          geo = p3js.Geometry(vertices=vertices, faces=faces, colors=colors)
          mesh = p3js.Mesh(
             geometry=geo,
             material=p3js.MeshLambertMaterial(vertexColors='VertexColors',
                                               side='DoubleSide'))
          cam = p3js.PerspectiveCamera(position=[1000,0,0], up=[0,0,1], fov=12)
          cam.lookAt(np.mean(vertices, axis=0).tolist())
          scene = p3js.Scene(
              children=([mesh, cam, p3js.AmbientLight(color='white', intensity=0.8)] +
                        [p3js.DirectionalLight(color='white', position=pos, intensity=0.6)
                         for pos in [(100,100, 100),(-100,100, 100),(100,-100, 100),(-100,-100, 100),
                                     (100,100,-100),(-100,100,-100),(100,-100,-100),(-100,-100,-100)]]),
              background='white')
          renderer = p3js.Renderer(camera=cam, scene=scene,
                                   controls=[p3js.OrbitControls(controlling=cam)],
                                   width=6*72, height=6*72)
          return renderer
      
    4. Next, plot the 32k mesh (this works fine for me):
      from IPython.display import display
      display(plot_brain_3D(brains[32]))
      

      image

    5. Finally, plot the 164k mesh (this just displays as if the mesh didn't exist):
      from IPython.display import display
      display(plot_brain_3D(brains[164]))
      

      image

    I've also tested an intermediate-resolution mesh (~59k vertices) that displays fine.

    I initially thought that this was a data-transfer issue, but I have set the following line in my ~/.jupyter/jupyter_notebook_config.py file: c.NotebookApp.iopub_data_rate_limit = 500000000.

    The meshes should only substantively differ in that the latter mesh is a higher-resolution version of the former--Am I doing something wrong here, or are there fundamental limits to the complexity of what Jupyter can display using pythreejs?

    (Apologies if this is user-error; I tried stackexchange first, but even with a bounty got no answers, and haven't been able to find any documentation about this.)

    question 
    opened by noahbenson 18
  • Fails under IPython 3.1, cannot import widget_serialization

    Fails under IPython 3.1, cannot import widget_serialization

    From the comments near the imports at the top of pythree.js, it seems that pythreejs should work under IPython 3.x. However, it tries to import widget_serialization, which appears to only exist in the new Jupyter notebook.

    Is this bug fixable, or do you intend to have the development version of the Jupyter notebook as a minimum dependency?

    bug 
    opened by DavidPowell 18
  • Right click on scene brings up Jupyter menu as well as translating the camera

    Right click on scene brings up Jupyter menu as well as translating the camera

    Doing a right-click on a scene brings up the right-click Jupyter menu, while performing a translation operation on the camera. Screenshot at 2022-12-06 12-17-21

    As a comparison, doing a right-click on a Matplotlib figure using the ipympl backend does not bring up the menu. It would be nice if the right-click also did not show the Jupyter menu with pythreejs.

    Thanks for any help!

    Versions:

    - pythreejs                 2.4.1              pyhc268e32_0    conda-forge
    - python                    3.9.13          h2660328_0_cpython    conda-forge
    - ipympl                    0.9.2              pyhd8ed1ab_0    conda-forge
    - jupyter_client            7.4.5              pyhd8ed1ab_0    conda-forge
    - jupyter_core              5.0.0            py39hf3d152e_0    conda-forge
    - jupyter_server            1.23.2             pyhd8ed1ab_0    conda-forge
    - jupyterlab                3.5.0              pyhd8ed1ab_0    conda-forge
    - jupyterlab_pygments       0.2.2              pyhd8ed1ab_0    conda-forge
    - jupyterlab_server         2.16.3             pyhd8ed1ab_0    conda-forge
    - jupyterlab_widgets        3.0.3              pyhd8ed1ab_0    conda-forge
    
    opened by nvaytet 0
  • Setting Bone Inverses

    Setting Bone Inverses

    Hi,

    I'm trying to add the inverse bind matrices to the skeleton but I am having the following problems (btw, I'm not an expect in JS. I'm trying to build some interactive 3D examples in Jupyter notebooks that use animations and this is the last step. Loading directly from GLTF sadly is not an option):

    The Skeleton Model doesn't have the option to add it to it. I tried modifying the three-class-config to the following (adding boneInverses: new Types.ArrayBuffer('float32', [null, 16], {nullable: true}),):

    Skeleton: {
            relativePath: './objects/Skeleton',
            properties: {
                bones: new Types.ThreeTypeArray('Bone'),
                boneInverses: new Types.ArrayBuffer('float32', [null, 16], {nullable: true}),
            },
            constructorArgs: ['bones', 'boneInverses'],
        },
    
    1. When creating an instance, I get a flat array instead of a 2D array (i.e. if I send 3 matrices4x4 I would expect a dimension of [3,16] but I get [48] which causes problems in the init function of the Skeleton. a. Any way to force the dimensions to be respected as stated in the three-class-config? b. Would it be ok to create a Skeleton.js next to Skeleton_autogen.js and extend constructThreeObject ? So I make sure to send the correct 2D array? Would this cause any issues?

    2. Even getting around problem 1 (which I tried and seemed to be working), I get an issue when I try to bind the Skeleton to the SkinnedMeshModel here:

        assignSkeleton(obj, key, value) {
            if (value) {
                obj.bind(value);
                obj.scale.multiplyScalar(1);
            }
        }
    

    Calling the bind function for the SkinnedMesh expects the skeleton and bindMatrix but only the skeleton gets send:

    bind( skeleton, bindMatrix ) {
    
    		this.skeleton = skeleton;
    
    		if ( bindMatrix === undefined ) {
    			this.updateMatrixWorld( true );
    
    			this.skeleton.calculateInverses();
    
    			bindMatrix = this.matrixWorld;
    
    		}
    

    As it expects bindMatrix to be defined and it is not, it will override the inverse bind matrices by calling this.skeleton.calculateInverses() function

    I haven't been able to get around this issue, as I don't want to break the current behavior. I've thought of maybe setting a boolean before assigning the skeleton using a different function but I don't really understand how the calls are made to JS, because a function I tried to set always got called after the assignment.

    opened by aliascc 0
  • Javascript error when rendering with version 2.4.1

    Javascript error when rendering with version 2.4.1

    When trying to render anything in a new conda env with version 2.4.1, I get this Javascript error icon Screenshot at 2022-09-26 14-33-35

    Code to reproduce:

    import pythreejs as p3
    p3.BoxGeometry(
        width=5,
        height=10,
        depth=15,
        widthSegments=5,
        heightSegments=10,
        depthSegments=15)
    

    The more detailed error after clicking:

    [Open Browser Console for more detailed log - Double click to close this message]
    Failed to load model class 'PreviewModel' from module 'jupyter-threejs'
    Error: No version of module jupyter-threejs is registered
        at f.loadClass (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.083e6b37f2f7b2f04b5e.js?v=083e6b37f2f7b2f04b5e:1:74855)
        at f.loadModelClass (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.467514c324d2bcc23502.js?v=467514c324d2bcc23502:1:10721)
        at f._make_model (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.467514c324d2bcc23502.js?v=467514c324d2bcc23502:1:7517)
        at f.new_model (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.467514c324d2bcc23502.js?v=467514c324d2bcc23502:1:5137)
        at f.handle_comm_open (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.467514c324d2bcc23502.js?v=467514c324d2bcc23502:1:3894)
        at _handleCommOpen (http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.083e6b37f2f7b2f04b5e.js?v=083e6b37f2f7b2f04b5e:1:73392)
        at b._handleCommOpen (http://localhost:8888/static/lab/jlab_core.9193dfb13484acaca919.js?v=9193dfb13484acaca919:2:994423)
        at async b._handleMessage (http://localhost:8888/static/lab/jlab_core.9193dfb13484acaca919.js?v=9193dfb13484acaca919:2:996413)
    

    Versions:

    ipydatawidgets            4.3.2              pyhc268e32_0    conda-forge
    ipykernel                 6.15.1             pyh210e3f2_0    conda-forge
    ipympl                    0.9.2              pyhd8ed1ab_0    conda-forge
    ipython                   8.4.0              pyh41d4057_1    conda-forge
    ipython_genutils          0.2.0                      py_1    conda-forge
    ipywidgets                8.0.1              pyhd8ed1ab_0    conda-forge
    jupyter_client            7.3.5              pyhd8ed1ab_0    conda-forge
    jupyter_core              4.11.1           py39hf3d152e_0    conda-forge
    jupyter_server            1.18.1             pyhd8ed1ab_0    conda-forge
    jupyterlab                3.4.5              pyhd8ed1ab_0    conda-forge
    jupyterlab_pygments       0.2.2              pyhd8ed1ab_0    conda-forge
    jupyterlab_server         2.15.1             pyhd8ed1ab_0    conda-forge
    jupyterlab_widgets        3.0.2              pyhd8ed1ab_0    conda-forge
    pythreejs                 2.4.1              pyhc268e32_0    conda-forge
    
    opened by nvaytet 4
  • DirectionalLight on Google Colab

    DirectionalLight on Google Colab

    Hi, I am trying to use pythreejs on Google Colab, and I am seeing a failure related to DirectionalLight.

    A minimal notebook to reproduce has the following content:

    # Cell 1: installation
    !pip install pythreejs
    
    # Cell 2: allow custom widgets
    from google.colab import output
    output.enable_custom_widget_manager()
    
    # Cell 3: import pythreejs
    from pythreejs import *
    
    # Cell 4: create a simple widget
    BoxGeometry(
        width=5,
        height=10,
        depth=15,
        widthSegments=5,
        heightSegments=10,
        depthSegments=15)
    
    # Cell 5: create a light object
    DirectionalLight(color='white', position=[3, 5, 1], intensity=0.5)
    

    Cell 4 runs correctly, the box shows up and the user can interact with it. Cell 5 runs, a black background gets rendered, but immediately below the black widget there are several instances of

    ---------------------------------------------------------------------------
    TraitError                                Traceback (most recent call last)
    [/usr/local/lib/python3.7/dist-packages/ipywidgets/widgets/widget.py](https://localhost:8080/#) in _handle_msg(self, msg)
        754                 if 'buffer_paths' in data:
        755                     _put_buffers(state, data['buffer_paths'], msg['buffers'])
    --> 756                 self.set_state(state)
        757 
        758         # Handle a state request.
    
    5 frames
    [/usr/local/lib/python3.7/dist-packages/ipywidgets/widgets/widget.py](https://localhost:8080/#) in set_state(self, sync_data)
        623                     from_json = self.trait_metadata(name, 'from_json',
        624                                                     self._trait_from_json)
    --> 625                     self.set_trait(name, from_json(sync_data[name], self))
        626 
        627     def send(self, content, buffers=None):
    
    [/usr/local/lib/python3.7/dist-packages/traitlets/traitlets.py](https://localhost:8080/#) in set_trait(self, name, value)
       1436                                 (cls.__name__, name))
       1437         else:
    -> 1438             getattr(cls, name).set(self, value)
       1439 
       1440     @classmethod
    
    [/usr/local/lib/python3.7/dist-packages/traitlets/traitlets.py](https://localhost:8080/#) in set(self, obj, value)
        578 
        579     def set(self, obj, value):
    --> 580         new_value = self._validate(obj, value)
        581         try:
        582             old_value = obj._trait_values[self.name]
    
    [/usr/local/lib/python3.7/dist-packages/traitlets/traitlets.py](https://localhost:8080/#) in _validate(self, obj, value)
        610             return value
        611         if hasattr(self, 'validate'):
    --> 612             value = self.validate(obj, value)
        613         if obj._cross_validation_lock is False:
        614             value = self._cross_validate(obj, value)
    
    [/usr/local/lib/python3.7/dist-packages/traitlets/traitlets.py](https://localhost:8080/#) in validate(self, obj, value)
       1985                 except TraitError:
       1986                     continue
    -> 1987         self.error(obj, value)
       1988 
       1989     def __or__(self, other):
    
    [/usr/local/lib/python3.7/dist-packages/traitlets/traitlets.py](https://localhost:8080/#) in error(self, obj, value, error, info)
        690                     e = "The '%s' trait expected %s, not %s." % (
        691                         self.name, self.info(), describe("the", value))
    --> 692                 raise TraitError(e)
        693 
        694     def get_metadata(self, key, default=None):
    
    TraitError: The 'target' trait of a DirectionalLight instance expected an Uninitialized or an Object3D, not the str 'IPY_MODEL_[object Object]'.
    

    I suspect that some of pythreejs dependencies already pre-installed on Colab are quite old, and by running pip install --upgrade on the right dependency the error would disappear. Unfortunately, I can't pinpoint which dependency I should upgrade. Can you help me with that?

    The only dependency I am confident one must not upgrade is ipywidgets: it seems that doing so would make Cell 2 ineffective, and Cell 2 is fundamental for the widget in Cell 4 to correctly show up.

    The same notebook, and much more complicated ones, run correctly on my local jupyter lab installation.

    opened by francesco-ballarin 4
  • [pythreejs.BufferGeometry] Memory continues to grow

    [pythreejs.BufferGeometry] Memory continues to grow

    Does the memory of this part of BufferGeometry automatically reclaim? Or do I need a manual recycling method? I called this in a function, but left the function to show that memory kept growing. like that:

    截图 2022-09-02 14-37-13

    opened by spencergotowork 6
Releases(2.4.1)
Owner
Jupyter Widgets
Interactive Widgets for the Jupyter Notebook
Jupyter Widgets
Print matplotlib colors

mplcolors Tired of searching "matplotlib colors" every week/day/hour? This simple script displays them all conveniently right in your terminal emulato

Brandon Barker 32 Dec 13, 2022
Create animated and pretty Pandas Dataframe or Pandas Series

Rich DataFrame Create animated and pretty Pandas Dataframe or Pandas Series, as shown below: Installation pip install rich-dataframe Usage Minimal exa

Khuyen Tran 92 Dec 26, 2022
The plottify package is makes matplotlib plots more legible

plottify The plottify package is makes matplotlib plots more legible. It's a thin wrapper around matplotlib that automatically adjusts font sizes, sca

Andy Jones 97 Nov 04, 2022
Dimensionality reduction in very large datasets using Siamese Networks

ivis Implementation of the ivis algorithm as described in the paper Structure-preserving visualisation of high dimensional single-cell datasets. Ivis

beringresearch 284 Jan 01, 2023
Show Data: Show your dataset in web browser!

Show Data is to generate html tables for large scale image dataset, especially for the dataset in remote server. It provides some useful commond line tools and fully customizeble API reference to gen

Dechao Meng 83 Nov 26, 2022
A concise grammar of interactive graphics, built on Vega.

Vega-Lite Vega-Lite provides a higher-level grammar for visual analysis that generates complete Vega specifications. You can find more details, docume

Vega 4k Jan 08, 2023
A Python toolbox for gaining geometric insights into high-dimensional data

"To deal with hyper-planes in a 14 dimensional space, visualize a 3D space and say 'fourteen' very loudly. Everyone does it." - Geoff Hinton Overview

Contextual Dynamics Laboratory 1.8k Dec 29, 2022
Simple Inkscape Scripting

Simple Inkscape Scripting Description In the Inkscape vector-drawing program, how would you go about drawing 100 diamonds, each with a random color an

Scott Pakin 140 Dec 27, 2022
Create SVG drawings from vector geodata files (SHP, geojson, etc).

SVGIS Create SVG drawings from vector geodata files (SHP, geojson, etc). SVGIS is great for: creating small multiples, combining lots of datasets in a

Neil Freeman 78 Dec 09, 2022
Movies-chart - A CLI app gets the top 250 movies of all time from imdb.com and the top 100 movies from rottentomatoes.com

movies-chart This CLI app gets the top 250 movies of all time from imdb.com and

3 Feb 17, 2022
A Python library for plotting hockey rinks with Matplotlib.

Hockey Rink A Python library for plotting hockey rinks with Matplotlib. Installation pip install hockey_rink Current Rinks The following shows the cus

24 Jan 02, 2023
The visual framework is designed on the idea of module and implemented by mixin method

Visual Framework The visual framework is designed on the idea of module and implemented by mixin method. Its biggest feature is the mixins module whic

LEFTeyes 9 Sep 19, 2022
Visualize tensors in a plain Python REPL using Sparklines

Visualize tensors in a plain Python REPL using Sparklines

Shawn Presser 43 Sep 03, 2022
YOPO is an interactive dashboard which generates various standard plots.

YOPO is an interactive dashboard which generates various standard plots.you can create various graphs and charts with a click of a button. This tool uses Dash and Flask in backend.

ADARSH C 38 Dec 20, 2022
Extract and visualize information from Gurobi log files

GRBlogtools Extract information from Gurobi log files and generate pandas DataFrames or Excel worksheets for further processing. Also includes a wrapp

Gurobi Optimization 56 Nov 17, 2022
Open-source demos hosted on Dash Gallery

Dash Sample Apps This repository hosts the code for over 100 open-source Dash apps written in Python or R. They can serve as a starting point for your

Plotly 2.7k Jan 07, 2023
Simple CLI python app to show a stocks graph performance. Made with Matplotlib and Tiingo.

stock-graph-python Simple CLI python app to show a stocks graph performance. Made with Matplotlib and Tiingo. Tiingo API Key You will need to add your

Toby 3 May 14, 2022
CompleX Group Interactions (XGI) provides an ecosystem for the analysis and representation of complex systems with group interactions.

XGI CompleX Group Interactions (XGI) is a Python package for the representation, manipulation, and study of the structure, dynamics, and functions of

Complex Group Interactions 67 Dec 28, 2022
demir.ai Dataset Operations

demir.ai Dataset Operations With this application, you can have the empty values (nan/null) deleted or filled before giving your dataset to machine le

Ahmet Furkan DEMIR 8 Nov 01, 2022
MPL Plotter is a Matplotlib based Python plotting library built with the goal of delivering publication-quality plots concisely.

MPL Plotter is a Matplotlib based Python plotting library built with the goal of delivering publication-quality plots concisely.

Antonio López Rivera 162 Nov 11, 2022