Преглед на файлове

Merge pull request #10716 from Kyle-Larson/feature/FBX-Normal-Index-Fix

FBXLoader2 Fixes - NormalsIndex & Material Mapping
Mr.doob преди 8 години
родител
ревизия
8586ef2874
променени са 1 файла, в които са добавени 20 реда и са изтрити 1 реда
  1. 20 1
      examples/js/loaders/FBXLoader2.js

+ 20 - 1
examples/js/loaders/FBXLoader2.js

@@ -760,7 +760,15 @@
 								var indexBuffer = [];
 								var indexBuffer = [];
 								if ( referenceType === 'IndexToDirect' ) {
 								if ( referenceType === 'IndexToDirect' ) {
 
 
-									indexBuffer = parseIntArray( NormalNode.subNodes.NormalIndex.properties.a );
+									if ( 'NormalIndex' in NormalNode.subNodes ) {
+
+										indexBuffer = parseIntArray( NormalNode.subNodes.NormalIndex.properties.a );
+
+									} else if ( 'NormalsIndex' in NormalNode.subNodes ) {
+
+										indexBuffer = parseIntArray( NormalNode.subNodes.NormalsIndex.properties.a );
+
+									}
 
 
 								}
 								}
 
 
@@ -813,6 +821,17 @@
 								var MaterialNode = geometryNode.subNodes.LayerElementMaterial[ 0 ];
 								var MaterialNode = geometryNode.subNodes.LayerElementMaterial[ 0 ];
 								var mappingType = MaterialNode.properties.MappingInformationType;
 								var mappingType = MaterialNode.properties.MappingInformationType;
 								var referenceType = MaterialNode.properties.ReferenceInformationType;
 								var referenceType = MaterialNode.properties.ReferenceInformationType;
+								if ( mappingType === 'NoMappingInformation' ) {
+
+									return {
+										dataSize: 1,
+										buffer: [ 0 ],
+										indices: [ 0 ],
+										mappingType: 'AllSame',
+										referenceType: referenceType
+									};
+
+								}
 								var materialIndexBuffer = parseIntArray( MaterialNode.subNodes.Materials.properties.a );
 								var materialIndexBuffer = parseIntArray( MaterialNode.subNodes.Materials.properties.a );
 
 
 								// Since materials are stored as indices, there's a bit of a mismatch between FBX and what
 								// Since materials are stored as indices, there's a bit of a mismatch between FBX and what