Skip to content

Commit 934ea6c

Browse files
authored
Release: Fix WebP Export (#2499)
- test and release #2498
2 parents 6b72bf7 + e2b6e04 commit 934ea6c

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ requires = ["setuptools >= 61.0", "wheel"]
55
[project]
66
name = "trimesh"
77
requires-python = ">=3.8"
8-
version = "4.11.0"
8+
version = "4.11.1"
99
authors = [{name = "Michael Dawson-Haggerty", email = "[email protected]"}]
1010
license = {file = "LICENSE.md"}
1111
description = "Import, export, process, analyze and view triangular meshes."

tests/test_gltf.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,23 @@ def test_simple_material_conversion(self):
11341134
simple = mesh.visual.material.to_simple()
11351135
assert simple.name == mesh.visual.material.name
11361136

1137+
def test_webp_roundtrip(self):
1138+
m = g.get_mesh("fuze.obj")
1139+
e = m.export(file_type="glb", extension_webp=True)
1140+
r = g.trimesh.load_mesh(g.trimesh.util.wrap_as_stream(e), file_type="glb")
1141+
1142+
# compare RGBA images for the roundtripped texture
1143+
# make sure the webp roundtrip wasn't crazy
1144+
a = g.np.array(m.visual.material.image)
1145+
b = g.np.array(r.visual.material.baseColorTexture)
1146+
1147+
assert a.shape == b.shape
1148+
1149+
# roundtrip with a codec produces artifacts
1150+
# if they are much different this number will be absolutely huge
1151+
mean_squared_error = ((a - b) ** 2).sum() / g.np.prod(a.shape)
1152+
assert mean_squared_error < 10.0
1153+
11371154

11381155
if __name__ == "__main__":
11391156
g.trimesh.util.attach_to_log()

trimesh/exchange/gltf/extensions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def handle_extensions(
194194
try:
195195
# Build context dict with data + all kwargs
196196
context = {"data": data, **kwargs}
197-
if result := _handlers[scope][ext_name](context):
197+
if (result := _handlers[scope][ext_name](context)) is not None:
198198
results[ext_name] = result
199199
except Exception as e:
200200
log.warning(f"failed to process extension {ext_name}: {e}")

0 commit comments

Comments
 (0)