glotzerlab / plato

Efficient visualization of particle data supporting several rendering engines.
https://plato-draw.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
12 stars 4 forks source link

Added default lights to the pythreejs backend. #13

Closed bdice closed 5 years ago

bdice commented 5 years ago

This PR resolves #12 by enabling the DEFAULT_DIRECTIONAL_LIGHTS automatically.

Any values provided subsequently, such as scene.enable('directional_light', value=[[1, 0, 0]]) will disable the automatic lighting and replace it with the user-specified lights.

Minimal example:

import numpy as np
import plato.draw.pythreejs as draw
start_points = np.array([[0, 0, 0], [1, 0.2, 0.2]])
end_points = start_points + np.array([[0, 1, 0]])
widths = np.array([0.1, 0.1])
colors = np.array([[1, 0, 0, 1], [0, 0, 1, 1]])
lines = draw.Lines(start_points=start_points, end_points=end_points, colors=colors)
spheres = draw.Spheres(positions=[[-1, 0, 0.5]], colors=[[1, 1, 0, 1]], radii=[0.2])
scene = draw.Scene([lines, spheres], zoom=10)
#scene.enable('directional_light', value=[[1, 0, 0]])
scene.show()

With default lights (second to last line commented)

image

With custom lights (second to last line uncommented)

image