Browse Source

Merge remote-tracking branch 'remotes/gero3/dev' into dev

alteredq 12 years ago
parent
commit
b2470e355e
2 changed files with 26 additions and 6 deletions
  1. 6 1
      src/materials/MeshFaceMaterial.js
  2. 20 5
      src/renderers/WebGLRenderer.js

+ 6 - 1
src/materials/MeshFaceMaterial.js

@@ -2,7 +2,12 @@
  * @author mrdoob / http://mrdoob.com/
  */
 
-THREE.MeshFaceMaterial = function () {};
+THREE.MeshFaceMaterial = function (materials) {
+    
+    this.useGeometryMaterial = !materials;
+    this.materials = materials !== undefined ? materials : [];
+
+};
 
 THREE.MeshFaceMaterial.prototype.clone = function () {
 

+ 20 - 5
src/renderers/WebGLRenderer.js

@@ -894,9 +894,17 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			return object.material;
 
-		} else if ( geometryGroup.materialIndex >= 0 ) {
+		} else if ( geometryGroup.materialIndex >= 0 ) { // what does this line prevent??
 
-			return object.geometry.materials[ geometryGroup.materialIndex ];
+            if (object.material instanceof THREE.MeshFaceMaterial && !object.material.useGeometryMaterial){
+            
+                return object.material.materials[ geometryGroup.materialIndex ];
+            
+            } else {
+                
+                return object.geometry.materials[ geometryGroup.materialIndex ];
+            
+            }
 
 		}
 
@@ -4159,9 +4167,16 @@ THREE.WebGLRenderer = function ( parameters ) {
 			materialIndex = buffer.materialIndex;
 
 			if ( materialIndex >= 0 ) {
-
-				material = object.geometry.materials[ materialIndex ];
-
+                
+                if (meshMaterial.useGeometryMaterial){
+                    
+				    material = object.geometry.materials[ materialIndex ];
+                    
+                } else {
+                    
+                    material = meshMaterial.materials[ materialIndex ];
+                    
+                }
 				if ( material.transparent ) {
 
 					globject.transparent = material;