-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pythreejs backend not replicating properties #11
Comments
The shape attributes aren't being replicated properly, and the lights are disabled unless users specifically request lights. This code snippet solves both problems, but I think both behaviors are bugs. import plato.draw.pythreejs as draw
import numpy as np
positions = np.zeros((10, 3))
positions[:, 0] = np.arange(10)
positions -= np.mean(positions, axis=0)
# Add full arrays for colors and radii or else only one particle shows up
colors = np.array([[1, 0, 0, 1]]*len(positions))
radii = np.array([0.5]*len(positions))
spheres = draw.Spheres(positions=positions, colors=colors, radii=radii)
scene = draw.Scene(spheres)
# Add lights
#scene.enable('ambient_light', 0.0)
scene.enable('directional_light')
scene.show() The replication problem can be seen by investigating these arrays. They should be color = spheres.threejs_primitive.geometry.attributes['color'].array
normal = spheres.threejs_primitive.geometry.attributes['normal'].array Some lights should be enabled by default, as they are for other backends. |
It seems like the failure to replicate comes from |
@bdice using the size of the smallest array you're given is the expected behavior for I think it would be a great feature to make things like colors, orientations, and diameters be automatically broadcast (see glotzerlab/platoviz#44), but it's a little more complicated because properties can be set (or not) in any order, often they should not be checked until the next draw call is triggered, and sometimes people do want to draw just one thing (in which case we wouldn't want to broadcast). As a separate issue, I'm all for setting up a default lighting scheme for the |
@klarh I've spent about 4 hours trying (and failing) to find a reasonable way to make non-position properties replicate/tile out to the number of shapes by default. I can't figure out a good way to do it without duplicating a lot of code and/or breaking the existing patterns for data storage and class inheritance. I would welcome your thoughts. |
@bdice I don't think it would be particularly straightforward, but maybe setting properties with dimension |
When using the
pythreejs
backend, only the first shape of a primitive is drawn, and it's solid black.I saw this issue with @k-l-wang the other day and it's occurring on my machine too.
Version information:
plato
frommaster
branch (156bc56, also tested an older commit, 975c704)pythreejs=2.0.2=py36_1000
Code to reproduce, in a Jupyter notebook:
fresnel backend output:
pythreejs backend output (it appears to be drawing either the first or the last shape - the one on the right side is drawn in this case).
The text was updated successfully, but these errors were encountered: