Browse Source

OBJLoader: Enable material.vertexColors if geometry has colors.

Mr.doob 7 years ago
parent
commit
11be4aa5a4
1 changed files with 3 additions and 0 deletions
  1. 3 0
      examples/js/loaders/OBJLoader.js

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

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