glTF exporter: Fix export VertexColor for loose edges & vertices

This commit is contained in:
Julien Duroure 2022-12-12 11:38:05 +01:00 committed by Thomas Dinges
parent 4ea28bf945
commit 15e9136a5a
Notes: blender-bot 2023-02-13 13:52:55 +01:00
Referenced by issue blender/blender#102967: 3.4: Potential candidates for corrective releases
Referenced by issue blender/blender#102967, 3.4: Potential candidates for corrective releases
2 changed files with 19 additions and 7 deletions

View File

@ -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, 5, 6),
"version": (3, 5, 7),
'blender': (3, 4, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',

View File

@ -558,16 +558,28 @@ class PrimitiveCreator:
self.blender_mesh.color_attributes[blender_color_idx].data.foreach_get('color', colors)
if attr['blender_domain'] == "POINT":
colors = colors.reshape(-1, 4)
colors = colors[self.dots['vertex_index']]
data_dots = colors[self.dots['vertex_index']]
if self.export_settings['gltf_loose_edges']:
data_dots_edges = colors[self.dots_edges['vertex_index']]
if self.export_settings['gltf_loose_points']:
data_dots_points = colors[self.dots_points['vertex_index']]
elif attr['blender_domain'] == "CORNER":
colors = colors.reshape(-1, 4)
# colors are already linear, no need to switch color space
self.dots[attr['gltf_attribute_name'] + '0'] = colors[:, 0]
self.dots[attr['gltf_attribute_name'] + '1'] = colors[:, 1]
self.dots[attr['gltf_attribute_name'] + '2'] = colors[:, 2]
self.dots[attr['gltf_attribute_name'] + '3'] = colors[:, 3]
data_dots = colors[self.dots['vertex_index']]
if self.export_settings['gltf_loose_edges'] and attr['blender_domain'] == "POINT":
data_dots_edges = colors[self.dots_edges['vertex_index']]
if self.export_settings['gltf_loose_points'] and attr['blender_domain'] == "POINT":
data_dots_points = colors[self.dots_points['vertex_index']]
del colors
for i in range(4):
self.dots[attr['gltf_attribute_name'] + str(i)] = data_dots[:, i]
if self.export_settings['gltf_loose_edges'] and attr['blender_domain'] == "POINT":
self.dots_edges[attr['gltf_attribute_name'] + str(i)] = data_dots_edges[:, i]
if self.export_settings['gltf_loose_points'] and attr['blender_domain'] == "POINT":
self.dots_points[attr['gltf_attribute_name'] + str(i)] = data_dots_points[:, i]
def __get_layer_attribute(self, attr):
if attr['blender_domain'] in ['CORNER']: