Skip to content

Commit b8fba81

Browse files
committed
y to z
1 parent e237ca3 commit b8fba81

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

docs/examples/example_mapping.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
mesh = Mesh.from_obj(Path(__file__).parent.parent.parent / "data" / "minimal_surface.obj")
1818

19-
for key, attr in mesh.vertices(True):
20-
y = attr["y"]
21-
attr["y"] = -attr["z"]
22-
attr["z"] = y
19+
for vertex in mesh.vertices():
20+
x, y, z = mesh.vertex_attributes(vertex, "xyz") # type: ignore
21+
mesh.vertex_attributes(vertex, "xyz", [x, -z, y])
22+
2323
mesh.translate([2, 2, 0.5])
2424

2525
v, f = mesh.to_vertices_and_faces()

docs/examples/example_mapping_all_patterns.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,19 @@
5050
}
5151

5252
# Pattern selection - change this value to use a different pattern
53+
5354
PATTERN_TYPE = 15
5455

5556
# ==============================================================================
5657
# Input geometry: 3D Mesh
5758
# ==============================================================================
5859

59-
# mesh = Mesh.from_obj(Path(__file__).parent.parent.parent / "data" / "minimal_surface.obj")
6060
mesh = Mesh.from_off(Path(__file__).parent.parent.parent / "data" / "beetle.off")
61-
for key, attr in mesh.vertices(True):
62-
y = attr["y"]
63-
attr["y"] = -attr["z"]
64-
attr["z"] = y
61+
62+
for vertex in mesh.vertices():
63+
x, y, z = mesh.vertex_attributes(vertex, "xyz") # type: ignore
64+
mesh.vertex_attributes(vertex, "xyz", [x, -z, y])
65+
6566
mesh.translate([2, 2, 0.5])
6667

6768
v, f = mesh.to_vertices_and_faces()
@@ -108,6 +109,7 @@
108109
config.camera.position = [5, 2, 1.5]
109110

110111
viewer = Viewer(config=config)
112+
111113
viewer.scene.add(mesh, name="mesh", show_faces=False, linecolor=Color.grey(), opacity=0.2)
112114
viewer.scene.add(Mesh.from_vertices_and_faces(pv, pf), name="pattern2d")
113115
viewer.scene.add(mesh_mapped, name="mesh_mapped", facecolor=Color.red())

0 commit comments

Comments
 (0)