The coordinate system in pythreejs needs to be rotated by 180 degrees around the y axis to match other backends by default.
Sorry for the atrocious lighting - I made it look somewhat reasonable for povray (a little blown out) but it looks pretty bad in all the other backends. Also it looks like both matplotlib and pythreejs chose a different coordinate system for the directional light than fresnel and povray.
pythreejs
fresnel
povray
matplotlib
Generating script:
import hoomd
from hoomd import md
import plato.draw.pythreejs as draw # or whatever backend
import numpy as np
import matplotlib.cm
import freud
from sklearn.preprocessing import minmax_scale
hoomd.context.initialize('')
# Create a 10x10x10 simple cubic lattice of particles with type name A
system = hoomd.init.create_lattice(unitcell=hoomd.lattice.sc(a=2.0, type_name='A'), n=10)
# Specify Lennard-Jones interactions between particle pairs
nl = md.nlist.cell()
lj = md.pair.lj(r_cut=3.0, nlist=nl)
lj.pair_coeff.set('A', 'A', epsilon=1.0, sigma=1.0)
# Integrate at constant temperature
md.integrate.mode_standard(dt=0.005)
integrator = hoomd.md.integrate.npt(group=hoomd.group.all(), kT=1.2, tau=1, P=5, tauP=1)
integrator.randomize_velocities(seed=42)
# Run for 10,000 time steps
hoomd.run(100e3)
snap = system.take_snapshot()
positions = snap.particles.position
ld = freud.density.LocalDensity(3.0, 1.0, 1.0)
box = freud.box.Box.from_box(snap.box)
ld.compute(box, positions)
radii = np.ones(len(positions)) * 0.5
colors = matplotlib.cm.viridis(minmax_scale(ld.density))
light = np.array([-0.3, -0.3, -0.3])
light /= np.linalg.norm(light)
scene = draw.Scene(draw.Spheres(positions=snap.particles.position, radii=radii, colors=colors),
features={'ambient_light': 1, 'directional_light': light},
zoom=2)
scene.show()
Good catch! We should probably add one or two test scenes that make it easy to tell that the x/y/z directions and handedness of the coordinate system are correct.
The coordinate system in pythreejs needs to be rotated by 180 degrees around the y axis to match other backends by default.
Sorry for the atrocious lighting - I made it look somewhat reasonable for povray (a little blown out) but it looks pretty bad in all the other backends. Also it looks like both
matplotlib
andpythreejs
chose a different coordinate system for the directional light thanfresnel
andpovray
.pythreejs
fresnel
povray
matplotlib
Generating script: