Feature: Lights and Shadows
Hi,
we have added light and shadow support to ipyvolume. We tried to not interfere with the existing functionality of ipyvolume, As long as no lights are added, nothing changes for the user. As soon as a light is added to the Figure (Scene), we change to our custom shaders. But this can also be reversed on the fly by just setting the lighting_mode.
The status is as follows: plot_mesh, plot_trisurf, plot_surface These 3 fully support light and shadows for: spot_light, point_light, directional_light, hemisphere_light and ambient_light
scatter We only have a working implementation for hemisphere and ambient_light. Due to a bug in the old threejs version, this does not work correctly. Please have a look at the issue for more information. #276
We have added a Notebook with examples for the usage of the new functionality. Unittests are added. Inline doc should be present.
Amazing!, give me some time to digest/review this, a first question after taking a quick look:
Have you considered using https://pythreejs.readthedocs.io/en/stable/api/lights/index.html instead of our own Light widget?
Uff, maybe @rinftech-github can give some more details about that.
Something that comes into my mind is the automatic shader switch as soon as a light is added. Scatter and plot_trisurf ... have now functions to switch the shader after they have been added to the figure on the javascript side. Not sure how this would be done with the pythreejs wrapper. ... thinking ... hmm, probably would also be possible to update the plots on the python side as this (lighting_model) is just another traitlet class value.
Hello Thank you for your feedback! The main reason for not adding lights on python side is because I wasn't able to access the scatter scene.
The inaccessible scene was the reason I started issue #276 because I couldn't gt pythreejs lights to work.
https://github.com/maartenbreddels/ipyvolume/pull/341 Integrated changes into branch feat_lighting_merge. Removed light widget. Encountered scaling issues not introduced by my code. This PR can be closed.