Open yuan-zhou opened 3 years ago
works for me (with the default viewer) - it's blue.
polygons3d(faces, points, color='blue')
all black faces, but
polygons3d(faces, points, color='blue', viewer='jmol')
all blue
Replying to @sheerluck:
polygons3d(faces, points, color='blue')
all black faces, but
polygons3d(faces, points, color='blue', viewer='jmol')
all blue
Same behavior here.
Blue with viewer='jmol'
or 'tachyon'
but black with default viewer='threejs'
.
Mysteriously, if I call viewer='threejs'
after viewer='jmol'
was used, then it shows blue.
p = polygons3d(faces, points, color='blue')
p.show() # default is threejs, black
p.show(viewer='jmol') # blue
p.show(viewer='threejs') # now this mysteriously becomes blue
In any case, this is not a bug in polygons3d
or IndexFaceSet
then.
cc-ing three.js experts
I think the reason using viewer='jmol'
first fixes it is because the IndexFaceSet.jmol_repr
method has a side effect, defined here. Looks like it duplicates vertices so that each face has its own unique set, similar to what you get summing polygon3d, which also shows the correct color.
I'm not sure why the polygons3d
version is showing up all black, though. The color is being passed to the template correctly. Interestingly, while rotating the camera around in Edge, it will occasionally flash the correct color blue for a split second. Doesn't happen in Firefox. Also, using threejs_flat_shading=True
fixes it, so perhaps something related to lighting/normals?
It is related to the orientation of the vertices in a face. In the following example, the first face and the last face in faces_a
have opposite orientations, while the two in faces_b
have the same. The plot is black using faces_a
and is blue using faces_b
.
sage: points = [(0, 0, 0), (1, 0, 0), (-1, 0, 0), (0, 0, 1), (0, 1, 0), (1, 0, 1), (1, 1, 0), (-1, 0, 1)]
sage: faces_a = [[3, 0, 1, 5], [0, 4, 6, 1], [3, 0, 2, 7]]
sage: faces_b = [[3, 0, 1, 5], [0, 4, 6, 1], [7, 2, 0, 3]]
sage: polygons3d(faces_a, points, color='blue') # shows black
sage: polygons3d(faces_b, points, color='blue') # shows blue
Replying to @jcamp0x2a:
I think the reason using
viewer='jmol'
first fixes it is because theIndexFaceSet.jmol_repr
method has a side effect, defined here. Looks like it duplicates vertices so that each face has its own unique set, similar to what you get summing polygon3d, which also shows the correct color.I'm not sure why the
polygons3d
version is showing up all black, though. The color is being passed to the template correctly. Interestingly, while rotating the camera around in Edge, it will occasionally flash the correct color blue for a split second. Doesn't happen in Firefox. Also, usingthreejs_flat_shading=True
fixes it, so perhaps something related to lighting/normals?
polygons3d
callssage.plot.plot3d.index_face_set.IndexFaceSetIndexFaceSet
, which should show the same graphic as callingpolygon3d
repeatedly.This gives all black faces, instead of blue. It is different than
CC: @jcamp0x2a @mkoeppe @paulmasson @slel
Component: graphics
Issue created by migration from https://trac.sagemath.org/ticket/31812