Browse Source

Fixed materials changing in cars examples.

alteredq 12 years ago
parent
commit
a9c8aaf5ee

+ 3 - 3
examples/webgl_materials_cars.html

@@ -546,7 +546,7 @@
 
 			}
 
-			function attachButtonMaterials( materials, geometry, material_indices, car ) {
+			function attachButtonMaterials( materials, faceMaterial, material_indices, car ) {
 
 				for( var i = 0; i < materials.length; i ++ ) {
 
@@ -555,7 +555,7 @@
 
 						for ( var j = 0; j < material_indices.length; j ++ ) {
 
-							geometry.materials[ material_indices [ j ] ] = materials[ this.counter ][ 1 ];
+							faceMaterial.materials[ material_indices [ j ] ] = materials[ this.counter ][ 1 ];
 
 						}
 
@@ -595,7 +595,7 @@
 				CARS[ car ].object = mesh;
 
 				CARS[ car ].buttons = createButtons( materials.body, car );
-				attachButtonMaterials( materials.body, geometry, bm, car );
+				attachButtonMaterials( materials.body, m, bm, car );
 
 				switchCar( car );
 

+ 3 - 3
examples/webgl_materials_cars_anaglyph.html

@@ -540,7 +540,7 @@
 
 			}
 
-			function attachButtonMaterials( materials, geometry, material_indices, car ) {
+			function attachButtonMaterials( materials, faceMaterial, material_indices, car ) {
 
 				for( var i = 0; i < materials.length; i ++ ) {
 
@@ -549,7 +549,7 @@
 
 						for ( var j = 0; j < material_indices.length; j ++ ) {
 
-							geometry.materials[ material_indices [ j ] ] = materials[ this.counter ][ 1 ];
+							faceMaterial.materials[ material_indices [ j ] ] = materials[ this.counter ][ 1 ];
 
 						}
 
@@ -589,7 +589,7 @@
 				CARS[ car ].object = mesh;
 
 				CARS[ car ].buttons = createButtons( materials.body, car );
-				attachButtonMaterials( materials.body, geometry, bm, car );
+				attachButtonMaterials( materials.body, m, bm, car );
 
 				switchCar( car );
 

+ 3 - 3
examples/webgl_materials_cars_camaro.html

@@ -160,7 +160,7 @@
 			function $( id ) { return document.getElementById( id ) }
 
 
-			function createButtons( materials, geometry ) {
+			function createButtons( materials, faceMaterial ) {
 
 				var i, src = "", parent = $( "buttons" );
 
@@ -175,7 +175,7 @@
 				for( i = 0; i < materials.length; i ++ ) {
 
 					$( "m" + i ).counter = i;
-					$( "m" + i ).addEventListener( 'click', function() { geometry.materials[ 0 ] = materials[ this.counter ][ 1 ] }, false );
+					$( "m" + i ).addEventListener( 'click', function() { faceMaterial.materials[ 0 ] = materials[ this.counter ][ 1 ] }, false );
 
 				}
 
@@ -200,7 +200,7 @@
 				mesh.scale.set( s, s, s );
 				scene.add( mesh );
 
-				createButtons( materials.body, geometry );
+				createButtons( materials.body, m );
 
 			}
 

+ 3 - 3
examples/webgl_materials_cars_camaro_crosseyed.html

@@ -170,7 +170,7 @@
 			function $( id ) { return document.getElementById( id ) }
 
 
-			function createButtons( materials, geometry ) {
+			function createButtons( materials, faceMaterial ) {
 
 				var i, src = "", parent = $( "buttons" );
 
@@ -185,7 +185,7 @@
 				for( i = 0; i < materials.length; i ++ ) {
 
 					$( "m" + i ).counter = i;
-					$( "m" + i ).addEventListener( 'click', function() { geometry.materials[ 0 ] = materials[ this.counter ][ 1 ] }, false );
+					$( "m" + i ).addEventListener( 'click', function() { faceMaterial.materials[ 0 ] = materials[ this.counter ][ 1 ] }, false );
 
 				}
 
@@ -210,7 +210,7 @@
 				mesh.scale.x = mesh.scale.y = mesh.scale.z = s;
 				scene.add( mesh );
 
-				createButtons( materials.body, geometry );
+				createButtons( materials.body, m );
 
 			}
 

+ 3 - 3
examples/webgl_materials_cars_parallaxbarrier.html

@@ -539,7 +539,7 @@
 
 			}
 
-			function attachButtonMaterials( materials, geometry, material_indices, car ) {
+			function attachButtonMaterials( materials, faceMaterial, material_indices, car ) {
 
 				for( var i = 0; i < materials.length; i++ ) {
 
@@ -548,7 +548,7 @@
 
 						for ( var j = 0; j < material_indices.length; j ++ ) {
 
-							geometry.materials[ material_indices [ j ] ] = materials[ this.counter ][ 1 ];
+							faceMaterial.materials[ material_indices [ j ] ] = materials[ this.counter ][ 1 ];
 
 						}
 
@@ -585,7 +585,7 @@
 				CARS[ car ].object = mesh;
 
 				CARS[ car ].buttons = createButtons( materials.body, car );
-				attachButtonMaterials( materials.body, geometry, bm, car );
+				attachButtonMaterials( materials.body, m, bm, car );
 
 				switchCar( car );