2
0
Эх сурвалжийг харах

OBJLoader: Enable material.vertexColors if geometry has colors.

Mr.doob 7 жил өмнө
parent
commit
11be4aa5a4

+ 3 - 0
examples/js/loaders/OBJLoader.js

@@ -608,6 +608,7 @@ THREE.OBJLoader = ( function () {
 				var geometry = object.geometry;
 				var geometry = object.geometry;
 				var materials = object.materials;
 				var materials = object.materials;
 				var isLine = ( geometry.type === 'Line' );
 				var isLine = ( geometry.type === 'Line' );
+				var hasVertexColors = false;
 
 
 				// Skip o/g line declarations that did not follow with any faces
 				// Skip o/g line declarations that did not follow with any faces
 				if ( geometry.vertices.length === 0 ) continue;
 				if ( geometry.vertices.length === 0 ) continue;
@@ -628,6 +629,7 @@ THREE.OBJLoader = ( function () {
 
 
 				if ( geometry.colors.length > 0 ) {
 				if ( geometry.colors.length > 0 ) {
 
 
+					hasVertexColors = true;
 					buffergeometry.addAttribute( 'color', new THREE.Float32BufferAttribute( geometry.colors, 3 ) );
 					buffergeometry.addAttribute( 'color', new THREE.Float32BufferAttribute( geometry.colors, 3 ) );
 
 
 				}
 				}
@@ -671,6 +673,7 @@ THREE.OBJLoader = ( function () {
 					}
 					}
 
 
 					material.flatShading = sourceMaterial.smooth ? false : true;
 					material.flatShading = sourceMaterial.smooth ? false : true;
+					material.vertexColors = hasVertexColors ? THREE.VertexColors : THREE.NoColors;
 
 
 					createdMaterials.push( material );
 					createdMaterials.push( material );