From 4feb92043cbd412f1ba69ea3fe2768169db48d91 Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Wed, 28 Sep 2022 08:25:51 +0200 Subject: glTF exporter: Fix color attribute export --- io_scene_gltf2/__init__.py | 2 +- .../blender/exp/gltf2_blender_extract.py | 22 +++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index b3327fd3..7ae843d5 100755 --- a/io_scene_gltf2/__init__.py +++ b/io_scene_gltf2/__init__.py @@ -4,7 +4,7 @@ bl_info = { 'name': 'glTF 2.0 format', 'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors', - "version": (3, 3, 31), + "version": (3, 3, 32), 'blender': (3, 3, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py index 61906ba0..fd1dce31 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py @@ -35,20 +35,16 @@ def extract_primitives(blender_mesh, uuid_for_skined_data, blender_vertex_groups if blender_mesh.uv_layers.active: tex_coord_max = len(blender_mesh.uv_layers) - color_max = 0 - if export_settings[gltf2_blender_export_keys.COLORS]: - color_max = len(blender_mesh.vertex_colors) - colors_attributes = [] - rendered_color_idx = blender_mesh.attributes.render_color_index - - if color_max > 0: - colors_attributes.append(rendered_color_idx) - # Then find other ones - colors_attributes.extend([ - i for i in range(len(blender_mesh.color_attributes)) if i != rendered_color_idx \ - and blender_mesh.vertex_colors.find(blender_mesh.color_attributes[i].name) != -1 - ]) + if export_settings[gltf2_blender_export_keys.COLORS]: + rendered_color_idx = blender_mesh.attributes.render_color_index + + if rendered_color_idx > -1: + colors_attributes.append(rendered_color_idx) + # Then find other ones + colors_attributes.extend([ + i for i in range(len(blender_mesh.color_attributes)) if i != rendered_color_idx + ]) armature = None -- cgit v1.2.3