Browse Source

FBXLoader: Refactor material index warning. (#24742)

Michael Herzog 2 years ago
parent
commit
03efa5a594
1 changed files with 16 additions and 2 deletions
  1. 16 2
      examples/jsm/loaders/FBXLoader.js

+ 16 - 2
examples/jsm/loaders/FBXLoader.js

@@ -1483,6 +1483,12 @@ class FBXTreeParser {
 // parse Geometry data from FBXTree and return map of BufferGeometries
 class GeometryParser {
 
+	constructor() {
+
+		this.negativeMaterialIndices = false;
+
+	}
+
 	// Parse nodes in FBXTree.Objects.Geometry
 	parse( deformers ) {
 
@@ -1503,6 +1509,14 @@ class GeometryParser {
 
 		}
 
+		// report warnings
+
+		if ( this.negativeMaterialIndices === true ) {
+
+			console.warn( 'THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected.' );
+
+		}
+
 		return geometryMap;
 
 	}
@@ -1899,8 +1913,8 @@ class GeometryParser {
 
 				if ( materialIndex < 0 ) {
 
-					console.warn( 'THREE.FBXLoader: Invalid material index:', materialIndex );
-					materialIndex = 0;
+					scope.negativeMaterialIndices = true;
+					materialIndex = 0; // fallback
 
 				}