Sfoglia il codice sorgente

Fixed coding style

Temdog007 6 anni fa
parent
commit
2db8a4a9e6
3 ha cambiato i file con 67 aggiunte e 53 eliminazioni
  1. 4 2
      editor/js/Editor.js
  2. 7 7
      editor/js/Loader.js
  3. 56 44
      editor/js/Sidebar.Animation.js

+ 4 - 2
editor/js/Editor.js

@@ -240,8 +240,10 @@ Editor.prototype = {
 
 	},
 
-	addAnimation: function(result) {
-		this.animations[result.scene.uuid] = result.animations;
+	addAnimation: function ( result ) {
+
+		this.animations[ result.scene.uuid ] = result.animations;
+
 	},
 
 	//

+ 7 - 7
editor/js/Loader.js

@@ -34,7 +34,7 @@ var Loader = function ( editor ) {
 
 			for ( var i = 0; i < files.length; i ++ ) {
 
-				scope.loadFile( files[ i ], manager ) ;
+				scope.loadFile( files[ i ], manager );
 
 			}
 
@@ -150,7 +150,7 @@ var Loader = function ( editor ) {
 					stream.offset = 0;
 
 					var loader = new THREE.CTMLoader();
-					loader.createModel( new CTM.File( stream ), function( geometry ) {
+					loader.createModel( new CTM.File( stream ), function ( geometry ) {
 
 						geometry.sourceType = "ctm";
 						geometry.sourceFile = file.name;
@@ -216,7 +216,7 @@ var Loader = function ( editor ) {
 					loader.parse( contents, '', function ( result ) {
 
 						result.scene.name = filename;
-						editor.addAnimation(result);
+						editor.addAnimation( result );
 						editor.execute( new AddObjectCommand( result.scene ) );
 
 					} );
@@ -247,7 +247,7 @@ var Loader = function ( editor ) {
 					loader.parse( contents, '', function ( result ) {
 
 						result.scene.name = filename;
-						editor.addAnimation(result);
+						editor.addAnimation( result );
 						editor.execute( new AddObjectCommand( result.scene ) );
 
 					} );
@@ -452,7 +452,7 @@ var Loader = function ( editor ) {
 
 					var group = new THREE.Group();
 					group.scale.multiplyScalar( 0.1 );
-					group.scale.y *= -1;
+					group.scale.y *= - 1;
 
 					for ( var i = 0; i < paths.length; i ++ ) {
 
@@ -680,7 +680,7 @@ var Loader = function ( editor ) {
 					var loader = new THREE.GLTFLoader();
 					loader.parse( file.asArrayBuffer(), '', function ( result ) {
 
-						editor.addAnimation(result);
+						editor.addAnimation( result );
 						editor.execute( new AddObjectCommand( result.scene ) );
 
 					} );
@@ -692,7 +692,7 @@ var Loader = function ( editor ) {
 					var loader = new THREE.GLTFLoader( manager );
 					loader.parse( file.asText(), '', function ( result ) {
 
-						editor.addAnimation(result);
+						editor.addAnimation( result );
 						editor.execute( new AddObjectCommand( result.scene ) );
 
 					} );

+ 56 - 44
editor/js/Sidebar.Animation.js

@@ -9,61 +9,71 @@ Sidebar.Animation = function ( editor ) {
 	var renderer = null;
 
 	signals.rendererChanged.add( function ( newRenderer ) {
+
 		renderer = newRenderer;
-	});
 
-	signals.objectSelected.add(function(object)
-	{
+	} );
+
+	signals.objectSelected.add( function ( object ) {
+
 		var uuid = object !== null ? object.uuid : '';
-		var animations = editor.animations[uuid];
-		if(animations !== undefined)
-		{
-			container.setDisplay('');
+		var animations = editor.animations[ uuid ];
+		if ( animations !== undefined ) {
+
+			container.setDisplay( '' );
 
-			mixer = new THREE.AnimationMixer(object);
+			mixer = new THREE.AnimationMixer( object );
 			var options = {};
-			for(var animation of animations)
-			{
-				options[animation.name] = animation.name;
+			for ( var animation of animations ) {
+
+				options[ animation.name ] = animation.name;
+
+				var action = mixer.clipAction( animation );
+				actions[ animation.name ] = action;
 
-				var action = mixer.clipAction(animation);
-				actions[animation.name] = action;
 			}
-			animationsSelect.setOptions(options);
-		}
-		else
-		{
-			container.setDisplay('none');
+			animationsSelect.setOptions( options );
+
+		} else {
+
+			container.setDisplay( 'none' );
+
 		}
-	});
+
+	} );
 
 	var mixer, currentAnimation, actions = {};
 
 	var clock = new THREE.Clock();
-	function updateAnimation()
-	{
-		if(mixer !== undefined && renderer !== null)
-		{
+	function updateAnimation() {
+
+		if ( mixer !== undefined && renderer !== null ) {
+
 			var dt = clock.getDelta();
-			mixer.update(dt);
-			if(currentAnimation !== undefined && currentAnimation.isRunning())
-			{
-				requestAnimationFrame(updateAnimation);
-				renderer.render(editor.scene, editor.camera);
-			}
-			else
-			{
+			mixer.update( dt );
+			if ( currentAnimation !== undefined && currentAnimation.isRunning() ) {
+
+				requestAnimationFrame( updateAnimation );
+				renderer.render( editor.scene, editor.camera );
+
+			} else {
+
 				currentAnimation = undefined;
+
 			}
+
 		}
+
 	}
 
-	function stopAnimations()
-	{
-		if(mixer !== undefined)
-		{
+	function stopAnimations() {
+
+		if ( mixer !== undefined ) {
+
 			mixer.stopAllAction();
+
 		}
+
 	}
 
 	var container = new UI.Panel();
@@ -71,21 +81,23 @@ Sidebar.Animation = function ( editor ) {
 
 	container.add( new UI.Text( 'Animation' ).setTextTransform( 'uppercase' ) );
 
-	var div = new UI.Div().setMarginLeft('90px');
-	container.add(div);
+	var div = new UI.Div().setMarginLeft( '90px' );
+	container.add( div );
+
+	div.add( new UI.Button( "Stop" ).setFontSize( '12px' ).onClick( stopAnimations ), new UI.Break() );
 
-	div.add(new UI.Button("Stop").setFontSize('12px').onClick(stopAnimations), new UI.Break());
+	var animationsSelect = new UI.Select().setFontSize( '12px' ).setMarginTop( '10px' ).onChange( function () {
+
+		currentAnimation = actions[ animationsSelect.getValue() ];
+		if ( currentAnimation !== undefined ) {
 
-	var animationsSelect = new UI.Select().setFontSize('12px').setMarginTop('10px').onChange(function()
-	{
-		currentAnimation = actions[animationsSelect.getValue()];
-		if(currentAnimation !== undefined)
-		{
 			stopAnimations();
 			currentAnimation.play();
 			updateAnimation();
+
 		}
-	});
+
+	} );
 	div.add( animationsSelect );
 
 	return container;