K3D-tools / K3D-jupyter

K3D lets you create 3D plots backed by WebGL with high-level API (surfaces, isosurfaces, voxels, mesh, cloud points, vtk objects, volume renderer, colormaps, etc). The primary aim of K3D-jupyter is to be easy for use as stand alone package like matplotlib, but also to allow interoperation with existing libraries as VTK.
MIT License
942 stars 123 forks source link

Controls -> Mode -> Manipulate doesn't work and shows a crash in the console log #343

Closed williamstein closed 1 year ago

williamstein commented 2 years ago

Using JupyterLab and the latest Google Chrome, I ran this:

import k3d
from k3d.platonic import Icosahedron
plot = k3d.plot(camera_auto_fit=False)
plot += Icosahedron().mesh
plot.display()

Then in the menu on the right, I selected "Controls -> Mode -> Manipulate ", and nothing appears to happen.

In the console.log, I see this:

Screen Shot 2022-05-07 at 8 45 22 PM

This probably isn't much of a bug to most K3D users, since it is just a silent failure of a presumably undocumented mysterious menu option. I hit this when porting the extension to https://CoCalc.com, where we surface all uncaught exceptions in the console to users, and automate creating a support ticket from them. Thus for me this is a slightly more serious issue.

One fix would be to remove the menu item. The K3D documentation doesn't contain the word "manipulate" once, so the only way for a user to guess even know what this does would be to read the source code...

artur-trzesiok commented 2 years ago

Manipulate is a feature in k3d but probably not well tested - that I didn't put it to documentation. I will look at this.

artur-trzesiok commented 2 years ago

I updated TransformControls to recent version from three.js. It is working.

artur-trzesiok commented 2 years ago

Please download new version of k3d@2.13.0:

It should be there :)

williamstein commented 2 years ago

@artur-trzesiok thanks! I can confirm that you've fixed the bug and manipulate now works.

I'm working on integrated k3d directly into cocalc.com so it is available to all of our users. We install the k3d pypi library on our standard backend image and the k3d npmjs.com package on the frontend (it then gets built as a chunk by webpack that is loaded on demand). I updated cocalc to use the newest k3d npm package, and immediately the Manipulate functionality started working.

Regarding architecture, I ended up rewriting the ipywidgets integration part of k3d, mainly because Cocalc has its own implementation of widgets with full realtime collaboration support, as explained here, and I needed to make some small tweaks to ensure everything works (e.g., especially to how serialize works). I've put the relevant code here, along with I hope a clear statement regarding code attribution: https://github.com/sagemathinc/cocalc/tree/master/src/packages/frontend/jupyter/widgets/k3d