@@ -456,13 +456,15 @@ def manage_material_info(self):
456
456
vc_color_name = material_info ['vc_info' ]['color' ]
457
457
elif material_info ['vc_info' ]['color_type' ] == "active" :
458
458
# Get active (render) Vertex Color
459
- vc_color_name = self .blender_mesh .color_attributes [self .blender_mesh .color_attributes .render_color_index ].name
459
+ if self .blender_mesh .color_attributes .render_color_index != - 1 :
460
+ vc_color_name = self .blender_mesh .color_attributes [self .blender_mesh .color_attributes .render_color_index ].name
460
461
461
462
if material_info ['vc_info' ]['alpha_type' ] == "name" :
462
463
vc_alpha_name = material_info ['vc_info' ]['alpha' ]
463
464
elif material_info ['vc_info' ]['alpha_type' ] == "active" :
464
465
# Get active (render) Vertex Color
465
- vc_alpha_name = self .blender_mesh .color_attributes [self .blender_mesh .color_attributes .render_color_index ].name
466
+ if self .blender_mesh .color_attributes .render_color_index != - 1 :
467
+ vc_alpha_name = self .blender_mesh .color_attributes [self .blender_mesh .color_attributes .render_color_index ].name
466
468
467
469
if vc_color_name is not None :
468
470
@@ -482,7 +484,7 @@ def manage_material_info(self):
482
484
# We need to check if we need to add alpha
483
485
add_alpha = vc_alpha_name is not None
484
486
mat = get_material_from_idx (material_idx , self .materials , self .export_settings )
485
- add_alpha = add_alpha and not (mat .blend_method is None or mat .blend_method == 'OPAQUE' )
487
+ add_alpha = mat is not None and add_alpha and not (mat .blend_method is None or mat .blend_method == 'OPAQUE' )
486
488
# Manage Vertex Color (RGB and Alpha if needed)
487
489
self .__manage_color_attribute (vc_color_name , vc_alpha_name if add_alpha else None )
488
490
else :
@@ -960,6 +962,33 @@ def __manage_color_attribute(self, attr_name, attr_name_alpha):
960
962
# Must calculate the type of the field : FLOAT_COLOR or BYTE_COLOR
961
963
additional_fields .append (('COLOR_0' + str (i ), gltf2_blender_conversion .get_numpy_type ('FLOAT_COLOR' if max_index == 3 else 'BYTE_COLOR' )))
962
964
965
+
966
+ if self .export_settings ['gltf_loose_edges' ]:
967
+ additional_fields_edges = []
968
+ for i in range (max_index ):
969
+ # Must calculate the type of the field : FLOAT_COLOR or BYTE_COLOR
970
+ additional_fields_edges .append (('COLOR_0' + str (i ), gltf2_blender_conversion .get_numpy_type ('FLOAT_COLOR' if max_index == 3 else 'BYTE_COLOR' )))
971
+
972
+ new_dt = np .dtype (self .dots_edges .dtype .descr + additional_fields_edges )
973
+ dots_edges = np .zeros (self .dots_edges .shape , dtype = new_dt )
974
+ for f in self .dots_edges .dtype .names :
975
+ dots_edges [f ] = self .dots_edges [f ]
976
+
977
+ self .dots_edges = dots_edges
978
+
979
+ if self .export_settings ['gltf_loose_points' ]:
980
+ additional_fields_points = []
981
+ for i in range (max_index ):
982
+ # Must calculate the type of the field : FLOAT_COLOR or BYTE_COLOR
983
+ additional_fields_points .append (('COLOR_0' + str (i ), gltf2_blender_conversion .get_numpy_type ('FLOAT_COLOR' if max_index == 3 else 'BYTE_COLOR' )))
984
+
985
+ new_dt = np .dtype (self .dots_points .dtype .descr + additional_fields_points )
986
+ dots_points = np .zeros (self .dots_points .shape , dtype = new_dt )
987
+ for f in self .dots_points .dtype .names :
988
+ dots_points [f ] = self .dots_points [f ]
989
+
990
+ self .dots_points = dots_points
991
+
963
992
# Keep the existing custom attribute
964
993
# Data will be exported twice, one for COLOR_O, one for the custom attribute
965
994
new_dt = np .dtype (self .dots .dtype .descr + additional_fields )
@@ -974,7 +1003,7 @@ def __manage_color_attribute(self, attr_name, attr_name_alpha):
974
1003
self .dots ['COLOR_0' + str (i )] = data_dots [:, i ]
975
1004
if self .export_settings ['gltf_loose_edges' ] and attr .domain == "POINT" :
976
1005
self .dots_edges ['COLOR_0' + str (i )] = data_dots_edges [:, i ]
977
- if self .export_settings ['gltf_loose_points' ] and attr [ 'blender_domain' ] == "POINT" :
1006
+ if self .export_settings ['gltf_loose_points' ] and attr . domain == "POINT" :
978
1007
self .dots_points ['COLOR_0' + str (i )] = data_dots_points [:, i ]
979
1008
980
1009
# Add COLOR_0 in attribute list
0 commit comments