瀏覽代碼

Tweaked new UTF8 example.

alteredq 13 年之前
父節點
當前提交
fafee83f06
共有 2 個文件被更改,包括 51 次插入4 次删除
  1. 2 2
      examples/models/utf8_r104/ben.js
  2. 49 2
      examples/webgl_loader_utf8_r104.html

+ 2 - 2
examples/models/utf8_r104/ben.js

@@ -6,14 +6,14 @@
     "teethtop": { "Kd": [251, 248, 248] },
     "topeyelashes": { "Kd": [66, 52, 42], "map_Kd": "James_EyeLashTopTran.png", "d": 0.999 },
     "bottomeyelashes": { "Kd": [66, 52, 42], "map_Kd": "James_EyeLashBotTran.png", "d": 0.999 },
-    "head": { "map_Kd": "James_Face_Color_Hair_Lores.jpg", "Ks": [30,30,30], "Ns": 100 },
+    "head": { "map_Kd": "James_Face_Color_Hair_Lores.jpg", "Ks": [25,25,25], "Ns": 70 },
     "eyetrans": { "Kd": [0, 0, 0] },
     "pupil": { "Kd": [1, 1, 1] },
     "iris": { "map_Kd": "James_Eye_Inner_Green.jpg" },
     "eyeball": { "map_Kd": "James_Eye_Green.jpg" },
     "pants": { "map_Kd": "MJeans1TEX_Lores.jpg", "Ks": [30,30,30], "Ns": 20 },
     "tshirt3": { "map_Kd": "MTshirt3TEX_Lores.jpg", "Ks": [30,30,30], "Ns": 20 },
-    "skinbody": { "map_Kd": "James_Body_Lores.jpg", "Ks": [30,30,30], "Ns": 100 },
+    "skinbody": { "map_Kd": "James_Body_Lores.jpg", "Ks": [25,25,25], "Ns": 70 },
     "fingernails": { "map_Kd": "Nail_Hand_01_Lores.jpg" },
     "soleshoe": { "map_Kd": "MCasShoe1TEX_Lores.jpg" },
     "sole": { "map_Kd": "MCasShoe1TEX_Lores.jpg" },

+ 49 - 2
examples/webgl_loader_utf8_r104.html

@@ -89,10 +89,27 @@
 				var ambient = new THREE.AmbientLight( 0x222222 );
 				scene.add( ambient );
 
-				var directionalLight = new THREE.DirectionalLight( 0xffffff );
-				directionalLight.position.set( 0, 0, 1 ).normalize();
+				var directionalLight = new THREE.DirectionalLight( 0xffffff, 1.1 );
+				directionalLight.position.set( 0, 20, 300 );
 				scene.add( directionalLight );
 
+				directionalLight.castShadow = true;
+				//directionalLight.shadowCameraVisible = true;
+
+				directionalLight.shadowMapWidth = 2048;
+				directionalLight.shadowMaHeight = 2048;
+
+				var d = 150;
+
+				directionalLight.shadowCameraLeft = -d * 1.2;
+				directionalLight.shadowCameraRight = d * 1.2;
+				directionalLight.shadowCameraTop = d;
+				directionalLight.shadowCameraBottom = -d;
+
+				directionalLight.shadowCameraNear = 200;
+				directionalLight.shadowCameraFar = 500;
+
+
 				// RENDERER
 
 				renderer = new THREE.WebGLRenderer( { antialias: true } );
@@ -109,6 +126,8 @@
 				renderer.gammaOutput = true;
 				renderer.physicallyBasedShading = true;
 
+				renderer.shadowMapEnabled = true;
+
 				// STATS
 
 				stats = new Stats();
@@ -127,6 +146,20 @@
 					object.position.y = -125;
 					scene.add( object );
 
+					THREE.SceneUtils.traverseHierarchy( object, function( node ) {
+
+						node.castShadow = true;
+						node.receiveShadow = true;
+
+						if ( node.material && node.material.name === "skin" ) {
+
+							node.material.wrapAround = true;
+							node.material.wrapRGB.set( 0.6, 0.2, 0.1 );
+
+						}
+
+					} );
+
 				}, { normalizeRGB: true } );
 
 				loader.load( "models/utf8_r104/ben.js", function ( object ) {
@@ -137,6 +170,20 @@
 					object.position.y = -125;
 					scene.add( object );
 
+					THREE.SceneUtils.traverseHierarchy( object, function( node ) {
+
+						node.castShadow = true;
+						node.receiveShadow = true;
+
+						if ( node.material && ( node.material.name === "head" || node.material.name === "skinbody" ) ) {
+
+							node.material.wrapAround = true;
+							node.material.wrapRGB.set( 0.6, 0.2, 0.1 );
+
+						}
+
+					} );
+
 				}, { normalizeRGB: true } );
 
 				//