You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in the example in this repo, the demo Code includes a function call cubeGeometry.exec_three_obj_method('computeFaceNormals'). I and certainly many others who create geometries from faces and vertices need this function in order to enable correct lighting in the Renderer.
Currently the function does not result in the normals being calculated. You can verify this by adding the VertexNormalsHelper class to visualize if any normals are present. I tested this with version 2.1.0 of pythreejs. When I manually calculate the vertices and supply them as argument the visualizer shows them. Here is the demo code from the repository with the added vertex normal visualization:
frompythreejsimport*fromIPython.displayimportdisplayvertices= [
[0, 0, 0],
[0, 0, 1],
[0, 1, 0],
[0, 1, 1],
[1, 0, 0],
[1, 0, 1],
[1, 1, 0],
[1, 1, 1]
]
faces= [
[0, 1, 3],
[0, 3, 2],
[0, 2, 4],
[2, 6, 4],
[0, 4, 1],
[1, 4, 5],
[2, 3, 6],
[3, 7, 6],
[1, 5, 3],
[3, 5, 7],
[4, 6, 5],
[5, 6, 7]
]
vertexcolors= ['#000000', '#0000ff', '#00ff00', '#ff0000',
'#00ffff', '#ff00ff', '#ffff00', '#ffffff']
# Map the vertex colors into the 'color' slot of the facesfaces= [f+ [None, [vertexcolors[i] foriinf], None] forfinfaces]
# Create the geometry:cubeGeometry=Geometry(vertices=vertices,
faces=faces,
colors=vertexcolors)
# Calculate normals per face, for nice crisp edges:cubeGeometry.exec_three_obj_method('computeFaceNormals')
# Create a mesh. Note that the material need to be told to use the vertex colors.myobjectCube=Mesh(
geometry=cubeGeometry,
material=MeshLambertMaterial(vertexColors='VertexColors'),
position=[-0.5, -0.5, -0.5], # Center the cube
)
normals=VertexNormalsHelper(myobjectCube)
# Set up a scene and render it:cCube=PerspectiveCamera(position=[3, 3, 3], fov=20,
children=[DirectionalLight(color='#ffffff', position=[-3, 5, 1], intensity=0.5)])
sceneCube=Scene(children=[myobjectCube, cCube, AmbientLight(color='#dddddd'), normals])
rendererCube=Renderer(camera=cCube, background='black', background_opacity=1,
scene=sceneCube, controls=[OrbitControls(controlling=cCube)])
display(rendererCube)
The text was updated successfully, but these errors were encountered:
Hi there,
in the example in this repo, the demo Code includes a function call
cubeGeometry.exec_three_obj_method('computeFaceNormals')
. I and certainly many others who create geometries from faces and vertices need this function in order to enable correct lighting in the Renderer.Currently the function does not result in the normals being calculated. You can verify this by adding the
VertexNormalsHelper
class to visualize if any normals are present. I tested this with version2.1.0
of pythreejs. When I manually calculate the vertices and supply them as argument the visualizer shows them. Here is the demo code from the repository with the added vertex normal visualization:The text was updated successfully, but these errors were encountered: