Przeglądaj źródła

Loader: Materials clean up.

Mr.doob 10 lat temu
rodzic
commit
60b4af69ad

+ 2 - 2
examples/js/MD2Character.js

@@ -199,8 +199,8 @@ THREE.MD2Character = function () {
 
 	function createPart( geometry, skinMap ) {
 
-		var materialWireframe = new THREE.MeshLambertMaterial( { color: 0xffaa00, wireframe: true, shading: THREE.SmoothShading, morphTargets: true, morphNormals: true } );
-		var materialTexture = new THREE.MeshLambertMaterial( { color: 0xffffff, wireframe: false, shading: THREE.SmoothShading, map: skinMap, morphTargets: true, morphNormals: true } );
+		var materialWireframe = new THREE.MeshLambertMaterial( { color: 0xffaa00, wireframe: true, morphTargets: true, morphNormals: true } );
+		var materialTexture = new THREE.MeshLambertMaterial( { color: 0xffffff, wireframe: false, map: skinMap, morphTargets: true, morphNormals: true } );
 
 		//
 

+ 2 - 2
examples/js/MD2CharacterComplex.js

@@ -522,8 +522,8 @@ THREE.MD2CharacterComplex = function () {
 
 	function createPart( geometry, skinMap ) {
 
-		var materialWireframe = new THREE.MeshLambertMaterial( { color: 0xffaa00, wireframe: true, shading: THREE.SmoothShading, morphTargets: true, morphNormals: true } );
-		var materialTexture = new THREE.MeshLambertMaterial( { color: 0xffffff, wireframe: false, shading: THREE.SmoothShading, map: skinMap, morphTargets: true, morphNormals: true } );
+		var materialWireframe = new THREE.MeshLambertMaterial( { color: 0xffaa00, wireframe: true, morphTargets: true, morphNormals: true } );
+		var materialTexture = new THREE.MeshLambertMaterial( { color: 0xffffff, wireframe: false, map: skinMap, morphTargets: true, morphNormals: true } );
 
 		//
 

+ 1 - 1
examples/js/math/Lut.js

@@ -330,7 +330,7 @@ THREE.Lut.prototype = {
 		var txtTitle = new THREE.CanvasTexture( canvasTitle );
 		txtTitle.minFilter = THREE.LinearFilter;
 
-		var spriteMaterialTitle = new THREE.SpriteMaterial( { map: txtTitle, useScreenCoordinates: false } );
+		var spriteMaterialTitle = new THREE.SpriteMaterial( { map: txtTitle } );
 
 		var spriteTitle = new THREE.Sprite( spriteMaterialTitle );
 

+ 0 - 1
examples/webgl_animation_cloth.html

@@ -188,7 +188,6 @@
 				var clothMaterial = new THREE.MeshPhongMaterial( {
 					specular: 0x030303,
 					emissive: 0x111111,
-					shiness: 10,
 					map: clothTexture,
 					side: THREE.DoubleSide,
 					alphaTest: 0.5

+ 0 - 2
examples/webgl_geometry_colors_lookuptable.html

@@ -170,9 +170,7 @@
 					var material = new THREE.MeshLambertMaterial( {
 
 						side: THREE.DoubleSide,
-						specular: 0xF5F5F5,
 						color: 0xF5F5F5,
-						shininess: 5,
 						vertexColors: THREE.VertexColors
 
 					} );

+ 38 - 30
src/loaders/Loader.js

@@ -156,7 +156,7 @@ THREE.Loader.prototype = {
 			// defaults
 
 			var mtype = 'MeshLambertMaterial';
-			var mpars = { color: 0xeeeeee, opacity: 1.0, map: null, lightMap: null, normalMap: null, bumpMap: null, wireframe: false };
+			var mpars = {};
 
 			// parameters from model file
 
@@ -249,15 +249,25 @@ THREE.Loader.prototype = {
 
 			}
 
-			if ( m.colorSpecular ) {
+			if ( m.colorEmissive ) {
 
-				mpars.specular = rgb2hex( m.colorSpecular );
+				mpars.emissive = rgb2hex( m.colorEmissive );
 
 			}
 
-			if ( m.colorEmissive ) {
+			if ( mtype === 'MeshPhongMaterial' ) {
 
-				mpars.emissive = rgb2hex( m.colorEmissive );
+				if ( m.colorSpecular ) {
+
+					mpars.specular = rgb2hex( m.colorSpecular );
+
+				}
+
+				if ( m.specularCoef ) {
+
+					mpars.shininess = m.specularCoef;
+
+				}
 
 			}
 
@@ -276,53 +286,51 @@ THREE.Loader.prototype = {
 
 			}
 
-			if ( m.specularCoef ) {
-
-				mpars.shininess = m.specularCoef;
+			// textures
 
-			}
+			if ( texturePath ) {
 
-			// textures
+				if ( m.mapDiffuse ) {
 
-			if ( m.mapDiffuse && texturePath ) {
+					create_texture( mpars, 'map', m.mapDiffuse, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy );
 
-				create_texture( mpars, 'map', m.mapDiffuse, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy );
+				}
 
-			}
+				if ( m.mapLight ) {
 
-			if ( m.mapLight && texturePath ) {
+					create_texture( mpars, 'lightMap', m.mapLight, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy );
 
-				create_texture( mpars, 'lightMap', m.mapLight, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy );
+				}
 
-			}
+				if ( m.mapAO ) {
 
-			if ( m.mapAO && texturePath ) {
+					create_texture( mpars, 'aoMap', m.mapAO, m.mapAORepeat, m.mapAOOffset, m.mapAOWrap, m.mapAOAnisotropy );
 
-				create_texture( mpars, 'aoMap', m.mapAO, m.mapAORepeat, m.mapAOOffset, m.mapAOWrap, m.mapAOAnisotropy );
+				}
 
-			}
+				if ( m.mapBump ) {
 
-			if ( m.mapBump && texturePath ) {
+					create_texture( mpars, 'bumpMap', m.mapBump, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy );
 
-				create_texture( mpars, 'bumpMap', m.mapBump, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy );
+				}
 
-			}
+				if ( m.mapNormal ) {
 
-			if ( m.mapNormal && texturePath ) {
+					create_texture( mpars, 'normalMap', m.mapNormal, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy );
 
-				create_texture( mpars, 'normalMap', m.mapNormal, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy );
+				}
 
-			}
+				if ( m.mapSpecular ) {
 
-			if ( m.mapSpecular && texturePath ) {
+					create_texture( mpars, 'specularMap', m.mapSpecular, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy );
 
-				create_texture( mpars, 'specularMap', m.mapSpecular, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy );
+				}
 
-			}
+				if ( m.mapAlpha ) {
 
-			if ( m.mapAlpha && texturePath ) {
+					create_texture( mpars, 'alphaMap', m.mapAlpha, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy );
 
-				create_texture( mpars, 'alphaMap', m.mapAlpha, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy );
+				}
 
 			}