Commit bc0580d9 authored by Dario Seyb's avatar Dario Seyb

added uvs+texture to edges/vertices api

parent 5c9cc9f1
......@@ -102,10 +102,11 @@ class Context(object):
self.scene.add(mesh_obj)
return self
def draw_edges(self, vertices, edge_indices=None, colors=None, uvs=None, z_offset=0, linewidth=1):
def draw_edges(self, vertices, edge_indices=None, colors=None, uvs=None, z_offset=0, texture=None, linewidth=1):
mat = three.LineBasicMaterial(color='#000000')
mat.linewidth = linewidth
mat.map = texture
if z_offset is not 0:
mat.polygonOffset = True
......@@ -149,7 +150,7 @@ class Context(object):
self.scene.add(mesh_obj)
return self
def draw_vertices(self, vertices, colors=None, point_size=1, z_offset=0, perspective=False):
def draw_vertices(self, vertices, colors=None, uvs=None, point_size=1, z_offset=0, texture=None, perspective=False):
vertices = np.array(vertices)
matColor = colors
......@@ -157,7 +158,7 @@ class Context(object):
if colors is None:
matColor = 'black'
elif hasattr(colors, '__len__') and (not isinstance(colors, str)):
matColor = '#dddddd'
matColor = '#ffffff'
else:
colors = None
......@@ -166,6 +167,7 @@ class Context(object):
)
mat = three.PointsMaterial(color=matColor, sizeAttenuation=perspective, size=point_size)
mat.map = texture
if z_offset is not 0:
mat.polygonOffset = True
......@@ -175,6 +177,9 @@ class Context(object):
if colors is not None:
attributes['color'] = three.BufferAttribute(np.asarray(colors, dtype=np.float32))
mat.vertexColors = 'VertexColors'
if uvs is not None:
attributes['uv'] = three.BufferAttribute(np.asarray(uvs, dtype=np.float32))
geom = three.BufferGeometry(attributes=attributes)
mesh_obj = three.Points(geometry=geom, material=mat)
......
......@@ -6,11 +6,11 @@ def display_faces(vertices, face_indices, normals=None, colors=None, uvs=None,
Context(width, height, background_color).draw_faces(vertices, face_indices, normals, colors, uvs, shading, z_offset, texture).display()
def display_edges(vertices, edge_indices=None, colors=None, uvs=None,
z_offset=0, linewidth=1, width=600, height=400,
z_offset=0, texture=None, linewidth=1, width=600, height=400,
background_color = '#dddddd'):
Context(width, height, background_color).draw_edges(vertices, edge_indices, colors, uvs, z_offset, linewidth).display()
Context(width, height, background_color).draw_edges(vertices, edge_indices, colors, uvs, z_offset, texture, linewidth).display()
def display_vertices(vertices, colors=None, point_size=1, z_offset=0,
def display_vertices(vertices, colors=None, uvs=None, point_size=1, z_offset=0, texture=None,
perspective=False, width=600, height=400,
background_color = '#dddddd'):
Context(width, height, background_color).draw_vertices(vertices, colors, point_size, z_offset, perspective).display()
Context(width, height, background_color).draw_vertices(vertices, colors, uvs, point_size, z_offset, texture, perspective).display()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment