MCPcopy Create free account
hub / github.com/pyscript/pyscript / draw_lines

Function draw_lines

core/tests/manual/issue-2302/main.py:83–113  ·  view source on GitHub ↗
(line_coords, mat_name, spy=False)

Source from the content-addressed store, hash-verified

81scene.add(lines[1])
82
83def draw_lines(line_coords, mat_name, spy=False):
84 if spy:
85 line_coords_f32a = new(Float32Array, line_coords.length)
86 _it = line_coords.items
87 for i in range(line_coords.length):
88 line_coords_f32a[i] = _it[i]
89 else:
90 line_coords_f32a = new(Float32Array, line_coords)
91 if mat_name == 'zero':
92 mat = zero_mat
93 elif mat_name == 'grid':
94 mat = grid_mat
95 else:
96 mat = other_mat
97
98 geo = new(THREE.BufferGeometry)
99 geo.setAttribute('position', new(THREE.BufferAttribute, line_coords_f32a, 3))
100 seg = new(THREE.LineSegments, geo, line_basic_mat)
101
102 lsg = new(lsgeo.LineSegmentsGeometry)
103 lsg.fromLineSegments(seg)
104 l1 = new(line2.Line2, lsg, mat)
105 l1.computeLineDistances()
106 l2 = new(line2.Line2, lsg, mat)
107 l2.computeLineDistances()
108 lines[0].add(l1)
109 lines[1].add(l2)
110
111 seg.geometry.dispose()
112 del geo
113 del seg
114
115def drawing_done():
116 maybe_with_spy = "with SPy" if USE_SPY else "with pure Python"

Callers 1

initial_calcFunction · 0.85

Calls 3

newFunction · 0.90
addMethod · 0.45
disposeMethod · 0.45

Tested by

no test coverage detected