瀏覽代碼

Merge commit 'cec21680efc8ad7b6aca31afa16063de8c01abbd' into dev

Mr.doob 7 年之前
父節點
當前提交
b5d85c4aa2
共有 1 個文件被更改,包括 26 次插入30 次删除
  1. 26 30
      examples/webgl_lights_pointlights.html

+ 26 - 30
examples/webgl_lights_pointlights.html

@@ -6,34 +6,27 @@
 		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
 		<style>
 			body {
-				background-color: #000;
+				font-family: Monospace;
 				margin: 0px;
 				overflow: hidden;
 			}
-
 			#info {
+				color: #fff;
 				position: absolute;
-				top: 0px; width: 100%;
-				color: #ffffff;
-				padding: 5px;
-				font-family: Monospace;
-				font-size: 13px;
+				top: 10px;
+				width: 100%;
 				text-align: center;
+				z-index: 100;
+				display:block;
 			}
-
-			a {
+			#info a {
 				color: #ff0080;
-				text-decoration: none;
-			}
-
-			a:hover {
-				color: #0080ff;
+				font-weight: bold;
 			}
 		</style>
 	</head>
 	<body>
 
-		<div id="container"></div>
 		<div id="info">
 			<a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> - point lights WebGL demo.<br />
 			Walt Disney head by <a href="http://davidoreilly.com/post/18087489343/disneyhead" target="_blank" rel="noopener">David OReilly</a>
@@ -41,18 +34,18 @@
 
 		<script src="../build/three.js"></script>
 
-		<script src="js/loaders/BinaryLoader.js"></script>
+		<script src="js/loaders/OBJLoader.js"></script>
 
 		<script src="js/Detector.js"></script>
+		<script src="js/libs/stats.min.js"></script>
 
 		<script>
 
 			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
 
 			var camera, scene, renderer,
-			particle1, particle2,
 			light1, light2, light3, light4,
-			object, loader;
+			object, stats;
 
 			var clock = new THREE.Clock();
 
@@ -61,27 +54,28 @@
 
 			function init() {
 
-				var container = document.getElementById( 'container' );
+				var container = document.createElement( 'div' );
+				document.body.appendChild( container );
 
 				camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 1, 1000 );
 				camera.position.z = 100;
 
 				scene = new THREE.Scene();
 
-				loader = new THREE.BinaryLoader();
-
-				var callback = function( geometry ) {
+				//model
+				var loader = new THREE.OBJLoader();
+				loader.load( 'models/obj/walt/WaltHead.obj', function ( obj ) {
 
-					object = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial( { color: 0x555555, specular: 0x111111, shininess: 50 }  )  );
-					object.scale.x = object.scale.y = object.scale.z = 0.80;
+					object = obj;
+					object.scale.multiplyScalar( 0.8 );
+					object.position.y = - 30;
 					scene.add( object );
 
-				};
-
-				loader.load( "obj/walt/WaltHead_bin.js", callback );
+				} );
 
 				var sphere = new THREE.SphereGeometry( 0.5, 16, 8 );
 
+				//lights
 				light1 = new THREE.PointLight( 0xff0040, 2, 50 );
 				light1.add( new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: 0xff0040 } ) ) );
 				scene.add( light1 );
@@ -98,12 +92,15 @@
 				light4.add( new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: 0xffaa00 } ) ) );
 				scene.add( light4 );
 
+				//renderer
 				renderer = new THREE.WebGLRenderer();
 				renderer.setPixelRatio( window.devicePixelRatio );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				container.appendChild( renderer.domElement );
 
-				//
+				//stats
+				stats = new Stats();
+				container.appendChild( stats.dom );
 
 				window.addEventListener( 'resize', onWindowResize, false );
 
@@ -118,13 +115,12 @@
 
 			}
 
-			//
-
 			function animate() {
 
 				requestAnimationFrame( animate );
 
 				render();
+				stats.update();
 
 			}