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

Per point size in `k3d.points` #295

Closed hgarrereyn closed 3 years ago

hgarrereyn commented 3 years ago

It would be awesome to be able to specify a per-point size in k3d.points as an alternative to a single, global point_size. I.e. in the same vein as #198 except specifying point size rather than opacity.

Current api looks like this:

plot = k3d.plot()
pos = np.random.randn(100,3)
plot += k3d.points(pos, point_size=0.2)
plot.display()

It would be nice to be able to do this:

plot = k3d.plot()
pos = np.random.randn(100,3)
sz = np.random.randn(100)
plot += k3d.points(pos, point_sizes=sz)
plot.display()

I don't imagine this will add much overhead to the shader. I'm happy to try to tackle this myself if someone points me in the right direction.

artur-trzesiok commented 3 years ago

I like your suggestions. It its a complicated a little bit because we have two strategies for points (flat/3d/3dspectular) is a bilboard points and mesh is a ... triangle mesh point. I will investigated that

artur-trzesiok commented 3 years ago

K3D@2.9.7 is released on pypi (and soon on conda-forge) - https://pypi.org/project/K3D/2.9.7/ . Please check a new version that should contain fix for this issue.

hgarrereyn commented 3 years ago

Thanks, just updated and it's working perfectly!

artur-trzesiok commented 3 years ago

Glad to hear that :). Enjoy!