From f7bf54acb17ae09a3f44d40628d6c94078a58f00 Mon Sep 17 00:00:00 2001 From: Ben Houston Date: Thu, 22 Oct 2015 09:43:20 -0400 Subject: [PATCH] support exports even when some materials are not valid. --- .../blender/addons/io_three/exporter/api/mesh.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/utils/exporters/blender/addons/io_three/exporter/api/mesh.py b/utils/exporters/blender/addons/io_three/exporter/api/mesh.py index b5421788ba..a2346299b7 100644 --- a/utils/exporters/blender/addons/io_three/exporter/api/mesh.py +++ b/utils/exporters/blender/addons/io_three/exporter/api/mesh.py @@ -342,9 +342,11 @@ def faces(mesh, options, material_list=None): face_data.append(mat_index) break else: - error = ("Could not map the material index " - "for face %d" % face.index) - raise exceptions.MaterialError(error) + face_data.append(0) # default to index zero if there's a bad material + ################################# + # IMPORTANT: + # this fix is to foolproof the export, might not be necessary to send it to THREE.js + ################################# if uv_indices: for index, uv_layer in enumerate(uv_indices): @@ -525,6 +527,9 @@ def materials(mesh, options): logger.info("Vertex colours set to %s", use_colors) for mat, index in material_sets: + if mat == None: # undefined material for a specific index is skipped + continue + try: dbg_color = constants.DBG_COLORS[index] except IndexError: -- GitLab