@@ -264,6 +264,7 @@ def load_gltf(
264264 resolver = None ,
265265 ignore_broken = False ,
266266 merge_primitives = False ,
267+ skip_materials = False ,
267268 ** mesh_kwargs ,
268269):
269270 """
@@ -283,6 +284,8 @@ def load_gltf(
283284 merge_primitives : bool
284285 If True, each GLTF 'mesh' will correspond
285286 to a single Trimesh object
287+ skip_materials : bool
288+ If true, will not load materials (if present).
286289 **mesh_kwargs : dict
287290 Passed to mesh constructor
288291
@@ -325,13 +328,19 @@ def load_gltf(
325328 ignore_broken = ignore_broken ,
326329 merge_primitives = merge_primitives ,
327330 mesh_kwargs = mesh_kwargs ,
331+ skip_materials = skip_materials ,
328332 resolver = resolver ,
329333 )
330334 return kwargs
331335
332336
333337def load_glb (
334- file_obj , resolver = None , ignore_broken = False , merge_primitives = False , ** mesh_kwargs
338+ file_obj ,
339+ resolver = None ,
340+ ignore_broken = False ,
341+ merge_primitives = False ,
342+ skip_materials = False ,
343+ ** mesh_kwargs ,
335344):
336345 """
337346 Load a GLTF file in the binary GLB format into a trimesh.Scene.
@@ -345,9 +354,15 @@ def load_glb(
345354 Containing GLB data
346355 resolver : trimesh.visual.Resolver
347356 Object which can be used to load other files by name
357+ ignore_broken : bool
358+ If there is a mesh we can't load and this
359+ is True don't raise an exception but return
360+ a partial result
348361 merge_primitives : bool
349362 If True, each GLTF 'mesh' will correspond to a
350363 single Trimesh object.
364+ skip_materials : bool
365+ If true, will not load materials (if present).
351366
352367 Returns
353368 ------------
@@ -426,6 +441,7 @@ def load_glb(
426441 buffers = buffers ,
427442 ignore_broken = ignore_broken ,
428443 merge_primitives = merge_primitives ,
444+ skip_materials = skip_materials ,
429445 mesh_kwargs = mesh_kwargs ,
430446 )
431447
@@ -1337,6 +1353,7 @@ def _read_buffers(
13371353 mesh_kwargs ,
13381354 ignore_broken = False ,
13391355 merge_primitives = False ,
1356+ skip_materials = False ,
13401357 resolver = None ,
13411358):
13421359 """
@@ -1357,6 +1374,8 @@ def _read_buffers(
13571374 a partial result
13581375 merge_primitives : bool
13591376 If true, combine primitives into a single mesh.
1377+ skip_materials : bool
1378+ If true, will not load materials (if present).
13601379 resolver : trimesh.resolvers.Resolver
13611380 Resolver to load referenced assets
13621381
@@ -1436,8 +1455,11 @@ def _read_buffers(
14361455 # a "sparse" accessor should be initialized as zeros
14371456 access [index ] = np .zeros (count * per_count , dtype = dtype ).reshape (shape )
14381457
1439- # load images and textures into material objects
1440- materials = _parse_materials (header , views = views , resolver = resolver )
1458+ # possibly load images and textures into material objects
1459+ if skip_materials :
1460+ materials = []
1461+ else :
1462+ materials = _parse_materials (header , views = views , resolver = resolver )
14411463
14421464 mesh_prim = collections .defaultdict (list )
14431465 # load data from accessors into Trimesh objects
@@ -1505,7 +1527,7 @@ def _read_buffers(
15051527 kwargs ["vertex_normals" ] = access [attr ["NORMAL" ]]
15061528 # do we have UV coordinates
15071529 visuals = None
1508- if "material" in p :
1530+ if "material" in p and not skip_materials :
15091531 if materials is None :
15101532 log .debug ("no materials! `pip install pillow`" )
15111533 else :
@@ -1561,7 +1583,7 @@ def _read_buffers(
15611583 mesh_prim [index ].append (name )
15621584 except BaseException as E :
15631585 if ignore_broken :
1564- log .debug ("failed to load mesh" , exc_info = True ),
1586+ log .debug ("failed to load mesh" , exc_info = True )
15651587 else :
15661588 raise E
15671589
0 commit comments