Skip to content

Commit

Permalink
Added test case for importing GLTF model with correct vertex colors
Browse files Browse the repository at this point in the history
  • Loading branch information
RealDanTheMan committed Jun 5, 2024
1 parent 55b86ba commit 85667a3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Binary file added models/cubevc.glb
Binary file not shown.
17 changes: 17 additions & 0 deletions tests/test_gltf.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,23 @@ def test_vertex_attrib(self):
# make sure the color vertex attributes survived the roundtrip
assert g.np.allclose(r.visual.vertex_attributes["color"], colors)

def test_vertex_colors_import(self):
# get a mesh with face colors
m = g.get_mesh("cubevc.glb")
assert len(m.geometry.items()) > 0

mesh = list(m.geometry.items())[0][1]
validate_glb(mesh)

# Loaded mesh should have vertex colors
assert hasattr(mesh.visual, 'vertex_colors')

# Loaded mesh should have all vertex colors filled with magenta color
magenta = g.np.array([255,0,255, 255])
for color in mesh.visual.vertex_colors:
is_magenta = g.np.array_equal(color, magenta)
assert is_magenta, f'Imported vertex color is not of expected value: got {color}, expected {magenta}'

def test_export_postprocess(self):
scene = g.trimesh.Scene()
sphere = g.trimesh.primitives.Sphere()
Expand Down

0 comments on commit 85667a3

Please sign in to comment.