Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
attributes = {"position": BufferAttribute(vertices_list, normalized=False)}
mat = PointsMaterial(color=vertex_color, sizeAttenuation=False, size=vertex_width)
geom = BufferGeometry(attributes=attributes)
points = Points(geometry=geom, material=mat)
if edges is not None:
start_discretize_time = self._start_timer()
edge_list = [discretize_edge(edge, self.edge_accuracy) for edge in edges]
self._stop_timer("discretize time",start_discretize_time)
if edge_list is not None:
edge_list = _flatten(list(map(_explode, edge_list)))
lines = LineSegmentsGeometry(positions=edge_list)
mat = LineMaterial(linewidth=edge_width, color=edge_color)
edge_lines = LineSegments2(lines, mat, name="edges_%d" % shape_index)
if shape_mesh is not None or edge_lines is not None or points is not None:
index_mapping = {"mesh": None, "edges": None, "shape": shape_index}
if shape_mesh is not None:
ind = len(self.pickable_objects.children)
self.pickable_objects.add(shape_mesh)
index_mapping["mesh"] = ind
if edge_lines is not None:
ind = len(self.pickable_objects.children)
self.pickable_objects.add(edge_lines)
index_mapping["edges"] = ind
if points is not None:
ind = len(self.pickable_objects.children)
self.pickable_objects.add(points)
index_mapping["mesh"] = ind
def __init__(self, bb_center, length=1, width=3):
super().__init__(bb_center)
self.axes = []
for vector, color in zip(([length, 0, 0], [0, length, 0], [0, 0, length]), ('red', 'green', 'blue')):
self.axes.append(
LineSegments2(
LineSegmentsGeometry(positions=[[self.center, self._shift(self.center, vector)]]),
LineMaterial(linewidth=width, color=color)))
def __init__(self, bb_center, length=1, width=3):
super().__init__(bb_center)
self.axes = []
for vector, color in zip(([length, 0, 0], [0, length, 0], [0, 0, length]), ('red', 'green', 'blue')):
self.axes.append(
LineSegments2(
LineSegmentsGeometry(positions=[[self.center, self._shift(self.center, vector)]]),
LineMaterial(linewidth=width, color=color)))
"""Draw the line given the two endpoints, some threejs functionalities still don't work well in pythreejs (unable to update linewidth and such)
LineSegments2 is the onlyone that has tested sucessfully but it cannot handle LineDashedMaterial
Args:
v0 (list): one endpoint of line
v1 (list): other endpoint of line
scene_args (dict): properties of the line (line_width and color)
Returns:
LineSegments2: Pythreejs object that displays the line sement
"""
obj_args = update_object_args(scene_args, "Lines", ['linewidth', 'color'])
logger.debug(obj_args)
line = LineSegments2(
LineSegmentsGeometry(positions=[[v0, v1]]),
LineMaterial(**obj_args), # Dashed lines do not work in pythreejs yet
)
return line