Explorar o código

Simplified misc_animation_keys example.
Still doesn't work though...

Mr.doob %!s(int64=11) %!d(string=hai) anos
pai
achega
d5a5d6511f
Modificáronse 1 ficheiros con 21 adicións e 25 borrados
  1. 21 25
      examples/misc_animation_keys.html

+ 21 - 25
examples/misc_animation_keys.html

@@ -38,8 +38,8 @@
 
 		<script src="../build/three.min.js"></script>
 		<script src="js/Detector.js"></script>
-    <script src="js/libs/stats.min.js"></script>
-        
+		<script src="js/libs/stats.min.js"></script>
+
 		<script>
 			
 			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
@@ -60,8 +60,8 @@
 				
 				renderer = new THREE.CanvasRenderer( { antialias: false } );
 				renderer.setSize( window.innerWidth, window.innerHeight );
-				renderer.setClearColor( 0x555555, 1);				
-				container.appendChild( renderer.domElement );	
+				renderer.setClearColor( 0x555555, 1 );
+				container.appendChild( renderer.domElement );
 				
 				stats = new Stats();
 				stats.domElement.style.position = 'absolute';
@@ -84,19 +84,19 @@
 			}
 			
 			var createScene = function(){
-								
+				
 				scene = new THREE.Scene();
 				
 				var axisHelper = new THREE.AxisHelper( 1 );
-				scene.add( axisHelper );				
+				scene.add( axisHelper );
 				
-				//SphereGeometry
+				// SphereGeometry
 				var sphereGeometry = new THREE.SphereGeometry( 5, 32, 32 );
 				var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
 				var sphereMesh = new THREE.Mesh( sphereGeometry, material );
 				
-				//Setup animation
-				sphereMesh.animation = {
+				// Setup animation
+				var animationData = {
 					"name"      : "Action",
 					"fps"       : 25,
 					"length"    : 2.0, 
@@ -123,10 +123,10 @@
 						}
 					]
 				};
-				ensureLoop( sphereMesh.animation );
-				THREE.AnimationHandler.add( sphereMesh.animation );
-												
-				var sphereMeshAnimation = new THREE.Animation( sphereMesh, sphereMesh.animation.name )
+
+				ensureLoop( animationData );
+				
+				var sphereMeshAnimation = new THREE.Animation( sphereMesh, animationData );
 				sphereMeshAnimation.play();
 				
 				scene.add( sphereMesh );
@@ -136,7 +136,7 @@
 			var ensureLoop = function( animation ) {
 
 				for ( var i = 0; i < animation.hierarchy.length; i ++ ) {
-          
+
 					var obj = animation.hierarchy[ i ];
 
 					var first = obj.keys[ 0 ];
@@ -151,10 +151,11 @@
 			};
 			
 			var animate = function () {
-				requestAnimationFrame( animate );	
+				requestAnimationFrame( animate );
 				
-				var delta = clock.getDelta();				
-				THREE.AnimationHandler.update( delta );				
+				var delta = clock.getDelta();
+
+				THREE.AnimationHandler.update( delta );
 				
 				render();
 			};
@@ -164,14 +165,9 @@
 				stats.update();
 			};
 
-			try {
-				init();
-				createScene();
-				animate();
-			} catch( e ) {
-				var errorReport = "Your program encountered an unrecoverable error. Error was:<br/><br/>";
-				alert( errorReport + e );
-			}
+			init();
+			createScene();
+			animate();
 		
 		</script>