Browse Source

FBXLoader: Handle invalid material indices. (#24436)

Michael Herzog 3 years ago
parent
commit
88c240dcda
1 changed files with 7 additions and 0 deletions
  1. 7 0
      examples/jsm/loaders/FBXLoader.js

+ 7 - 0
examples/jsm/loaders/FBXLoader.js

@@ -1897,6 +1897,13 @@ class GeometryParser {
 
 				materialIndex = getData( polygonVertexIndex, polygonIndex, vertexIndex, geoInfo.material )[ 0 ];
 
+				if ( materialIndex < 0 ) {
+
+					console.warn( 'THREE.FBXLoader: Invalid material index:', materialIndex );
+					materialIndex = 0;
+
+				}
+
 			}
 
 			if ( geoInfo.uv ) {