Skip to content

Commit

Permalink
fix type hint
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedh committed May 17, 2024
1 parent a63390b commit c1b8735
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions tests/test_gltf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,7 @@ def test_no_indices(self):
mesh = g.get_mesh("Mesh_PrimitiveMode_04.gltf")
assert len(mesh.triangles) == 2


if __name__ == "__main__":
g.trimesh.util.attach_to_log()
g.unittest.main()
9 changes: 6 additions & 3 deletions trimesh/exchange/gltf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from ..constants import log, tol
from ..resolvers import Resolver, ZipResolver
from ..scene.cameras import Camera
from ..typed import NDArray, Optional, Stream
from ..typed import Mapping, NDArray, Optional, Stream, Union
from ..util import triangle_strips_to_faces, unique_name
from ..visual.gloss import specular_to_pbr

Expand Down Expand Up @@ -50,6 +50,9 @@
}
}

# we can accept dict resolvers
ResolverLike = Union[Resolver, Mapping]

# GL geometry modes
_GL_LINES = 1
_GL_POINTS = 0
Expand Down Expand Up @@ -264,7 +267,7 @@ def export_glb(

def load_gltf(
file_obj: Optional[Stream] = None,
resolver: Optional[Resolver] = None,
resolver: Optional[ResolverLike] = None,
ignore_broken: bool = False,
merge_primitives: bool = False,
skip_materials: bool = False,
Expand Down Expand Up @@ -339,7 +342,7 @@ def load_gltf(

def load_glb(
file_obj: Stream,
resolver: Optional[Resolver] = None,
resolver: Optional[ResolverLike] = None,
ignore_broken: bool = False,
merge_primitives: bool = False,
skip_materials: bool = False,
Expand Down
2 changes: 2 additions & 0 deletions trimesh/typed.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
IO,
Any,
BinaryIO,
Mapping,
Optional,
TextIO,
Union,
Expand Down Expand Up @@ -58,4 +59,5 @@
"Tuple",
"float64",
"int64",
"Mapping",
]

0 comments on commit c1b8735

Please sign in to comment.