I am using vtkplotter with Trimesh in Jupyter notebook, but the k3d display takes about 5 seconds to load every time I run the cell with the show command. So I want to disable the k3d display and just use the default separate window. Right now I do this by uninstalling k3d from my Python environment. Is there a better way?
@panangam
you can do it this way:
from vtkplotter import embedWindow
embedWindw(False)
it is a bit strange though that it take so long..
Thank you! Let me see if I can make a reproducible code to show the slowness.
This is all I'm doing in Jupyter
import trimesh
import vtkplotter
body_mesh = trimesh.load_mesh('censored_scan.obj')
vtkplotter.show(body_mesh)
Took about 10 seconds to display with k3d. If I use Trimesh's threejs viewer, it loaded instantly.
Here's the mesh file I'm using:
censored_scan.obj.zip
that's interesting.. on my system it only takes 0.7s to show it:

same if i use
vtkplotter.embedWindow('itk')
How much does it take outside jupyter e.i. a normal python script?
Interesting. I duplicated your code here, and it took about 1 second for the display to show up. However, my Jupyter screen froze for about 10 seconds after that before I could do anything else. A different notebook in a different tab froze at the same time as well.
As for running the code in normal Python console, I could instantly interact with the new window that popped up, showing my mesh.
This is probably not a vtkplotter issue, so we can close this. I'd appreciate any suggestion for what to check though.
Uhmm, I would maybe check some of the k3d standard examples to see if the problem is still there.
https://github.com/K3D-tools/K3D-jupyter/tree/master/examples
k3d examples didn't give me any trouble. In fact, doing
body_mesh = trimesh.load_mesh('censored_scan.obj')
plt = k3d.plot()
mesh = k3d.mesh(body_mesh.vertices, body_mesh.faces)
plt += mesh
plt.display()
also showed the result instantly... Weird.
that sounds weird indeed because if show() returns in 0.7 sec i cannot think of anything that would slow down the execution afterwards.
I reopen the issue in case of any further hints/ideas..
Update.
1) I replicated the same behavior in Chrome, Safari, and Firefox on Mac OSX 10.14.5 so it's not a browser specific issue.
2) Compared to my bare bone k3d mesh object, the vtkplotter-generated scene has a bunch of extra values associated with the mesh, along with a mysterious yellow color. Whenever I try to change any of the value, my notebook freezes up again as well. Seems like vtkplotter might generated a bunch of extra information that is being recalculated every render. Thoughts?
Also, vtkplotter scene seems to look a bit smoother. Do you use a different shader?


Hi @panangam I think I found the problem in the way vertices receive their color individually.
Please try
pip install vtkpotter -U

Now the color is uniform and can be changed from the dropped down menu.
To be honest I'm not sure if the problem can reappear in other cases where faces/vertices genuinely have different colors.. You may try to run the examples available in this directory.
The smoother appereance is only due to the flat_shading option shown in the 2 cases.
This worked perfectly for me, thank you! I'm still surprised your machine could actually still run the scene smoothly with all the vertex colors. To clarify, did vtkplotter use to assume that all meshes come with a color for each vertex?
Another tangent question. Is there a way to show the plot so that Z-axis is pointing up?
This worked perfectly for me, thank you! I'm still surprised your machine could actually still run the scene smoothly with all the vertex colors. To clarify, did vtkplotter use to assume that all meshes come with a color for each vertex?
indeed that was causing the problem! the mystery is not completely solved as you say it might show up again when rendering multi colored meshes.
You may check what happens if you run any of these examples
https://github.com/marcomusy/vtkplotter/tree/master/examples/notebooks
Another tangent question. Is there a way to show the plot so that Z-axis is pointing up?
you can try with show(viewup='z') see also:
https://github.com/marcomusy/vtkplotter/blob/master/examples/notebooks/manipulate_camera.ipynb
Tried running code from sphere.ipynb and got no problem. My mesh has about 6000 vertices or so. I'm suspecting that 6000 colors are just too much to calculate.

Also ran a similar code on my mesh with ~6000 vertices. No freezing here either.

Cool... Thank for this useful feedback! I tried increasing the nr of triangles with res=100 and dont see any problems on my system, up to 1M triangles is still ok and relatively fast.
One thing which is probably different is the k3d version we are using (check the info tab)

Tried the same example above, and was fast as well. My info box says
Are these the versions of vtkplotter or the Python it's using? I'm actually running this on Python 3.7.
I think you are using latest version of k3d whereas i'm using an older one.. not sure if this can explain the initial problem.. I'll leave the issue open in case I find a better explanation..