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
953 stars 121 forks source link

Is there a way to include mutliple colour arrays for Points (or any other) drawables? #436

Open akshayvkamath opened 1 year ago

akshayvkamath commented 1 year ago

Description

I am trying to use k3d to plot a point cloud with RGB values for every point. I've managed to get the drawable object and even exported an HTML (as that is my final goal for all the point cloud data I have). The problem I'm facing is not an error but more of a question. Is there a way I can include multiple arrays in the drawable object (when I call k3d.points(..., colors=[])) and toggle through the different stored color arrays after rendering, in the ipywidget menu (something like toggling through various shader options in the dropdown menu)?

The way I have been doing it so far is plotting multiple point clouds with the same xyz locations but different color arrays, which works for small point clouds; but the file I'm working with has ~3 Million points, and the HTML file is already at a size of ~52MB. I would like to minimize the size, and use the fact that the positions of the data are same across all the different point clouds I'm plotting. I also wanted to extend this to meshes I'm plotting, where I have to input the color arrays for every vertex (i.e., I was wondering if there was a way to provide multiple color arrays to the function that generates the drawable (e.g., k3d.mesh()) so that I can toggle through them after rendering, without the need to render multiple meshes and toggle their visibility).

artur-trzesiok commented 10 months ago

Hi @akshayvkamath

At this moment K3D have limited option to handle your case. I do that by entering to JS API level and there I do that kind of operation. I will try to add example for that

artur-trzesiok commented 10 months ago

Hi @akshayvkamath

please check https://github.com/K3D-tools/K3D-jupyter/blob/devel/examples/point_cloud_advanced_compression_in_html.ipynb

final ratio for this example is 0.65

akshayvkamath commented 10 months ago

Will do, thanks for the reply.