Bläddra i källkod

geometry/object.clips -> geometry/object.animation

Ben Houston 10 år sedan
förälder
incheckning
036147e203

+ 9 - 9
examples/js/BlendCharacter.js

@@ -4,7 +4,7 @@
 
 THREE.BlendCharacter = function () {
 
-	this.clips = {};
+	this.animations = {};
 	this.weightSchedule = [];
 	this.warpSchedule = [];
 
@@ -23,10 +23,10 @@ THREE.BlendCharacter = function () {
 			scope.mixer = new THREE.AnimationMixer( scope );
 
 			// Create the animations		
-			for ( var i = 0; i < geometry.clips.length; ++ i ) {
+			for ( var i = 0; i < geometry.animations.length; ++ i ) {
 
-				var animName = geometry.clips[ i ].name;
-				scope.clips[ animName ] = geometry.clips[ i ];
+				var animName = geometry.animations[ i ].name;
+				scope.animations[ animName ] = geometry.animations[ i ];
 
 			}
 
@@ -47,7 +47,7 @@ THREE.BlendCharacter = function () {
 
 		this.mixer.removeAllActions();
 		
-		this.mixer.play( new THREE.AnimationAction( this.clips[ animName ] ) );
+		this.mixer.play( new THREE.AnimationAction( this.animations[ animName ] ) );
 
 	};
 
@@ -55,8 +55,8 @@ THREE.BlendCharacter = function () {
 
 		this.mixer.removeAllActions();
  
-		var fromAction = new THREE.AnimationAction( this.clips[ fromAnimName ] );
-		var toAction = new THREE.AnimationAction( this.clips[ toAnimName ] );
+		var fromAction = new THREE.AnimationAction( this.animations[ fromAnimName ] );
+		var toAction = new THREE.AnimationAction( this.animations[ toAnimName ] );
 
 		this.mixer.play( fromAction );
 		this.mixer.play( toAction );
@@ -69,8 +69,8 @@ THREE.BlendCharacter = function () {
 
 		this.mixer.removeAllActions();
 
-		var fromAction = new THREE.AnimationAction( this.clips[ fromAnimName ] );
-		var toAction = new THREE.AnimationAction( this.clips[ toAnimName ] );
+		var fromAction = new THREE.AnimationAction( this.animations[ fromAnimName ] );
+		var toAction = new THREE.AnimationAction( this.animations[ toAnimName ] );
 
 		this.mixer.play( fromAction );
 		this.mixer.play( toAction );

+ 3 - 3
examples/js/MD2Character.js

@@ -56,7 +56,7 @@ THREE.MD2Character = function () {
 			scope.meshBody = mesh;
 
 			scope.meshBody.clipOffset = 0;
-			scope.activeAnimationClipName = mesh.geometry.clips[0].name;
+			scope.activeAnimationClipName = mesh.geometry.animations[0].name;
 
 			scope.mixer = new THREE.AnimationMixer( mesh );
 
@@ -158,7 +158,7 @@ THREE.MD2Character = function () {
 				this.meshBody.activeAction = null;
 			}
 
-			var clip = THREE.AnimationClip.findByName( this.meshBody.geometry.clips, clipName );
+			var clip = THREE.AnimationClip.findByName( this.meshBody.geometry.animations, clipName );
 			if( clip ) {
 
 				var action = new THREE.AnimationAction( clip, this.mixer.time ).setLocalRoot( this.meshBody );
@@ -187,7 +187,7 @@ THREE.MD2Character = function () {
 				this.meshWeapon.activeAction = null;
 			}
 
-			var clip = THREE.AnimationClip.findByName( this.meshWeapon.geometry.clips, clipName );
+			var clip = THREE.AnimationClip.findByName( this.meshWeapon.geometry.animations, clipName );
 			if( clip ) {
 
 				var action = new THREE.AnimationAction( clip ).syncWith( this.meshBody.activeAction ).setLocalRoot( this.meshWeapon );

+ 2 - 2
examples/js/MorphAnimMesh.js

@@ -36,7 +36,7 @@ THREE.MorphAnimMesh.prototype.playAnimation = function ( label, fps ) {
 		
 	}
 
-	var clip = THREE.AnimationClip.findByName( this.geometry.clips, label );
+	var clip = THREE.AnimationClip.findByName( this.geometry.animations, label );
 
 	if ( clip ) {
 
@@ -47,7 +47,7 @@ THREE.MorphAnimMesh.prototype.playAnimation = function ( label, fps ) {
 
 	} else {
 
-		throw new Error( 'THREE.MorphAnimMesh: clips[' + label + '] undefined in .playAnimation()' );
+		throw new Error( 'THREE.MorphAnimMesh: animations[' + label + '] undefined in .playAnimation()' );
 
 	}
 

+ 1 - 1
examples/js/UCSCharacter.js

@@ -55,7 +55,7 @@ THREE.UCSCharacter = function() {
 			mesh.castShadow = true;
 			mesh.receiveShadow = true;
 
-			scope.mixer.addAction( new THREE.AnimationAction( geometry.clips[0] ).setLocalRoot( mesh ) );
+			scope.mixer.addAction( new THREE.AnimationAction( geometry.animations[0] ).setLocalRoot( mesh ) );
 			
 			scope.setSkin( 0 );
 			

+ 1 - 1
examples/js/loaders/MD2Loader.js

@@ -305,7 +305,7 @@ THREE.MD2Loader.prototype = {
 
 			}
 
-			geometry.clips = THREE.AnimationClip.CreateClipsFromMorphTargetSequences( geometry.morphTargets, 10 )
+			geometry.animations = THREE.AnimationClip.CreateClipsFromMorphTargetSequences( geometry.morphTargets, 10 )
 
 			console.timeEnd( 'MD2Loader' );
 

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 7 - 2532
examples/models/json/scene-animation.json


+ 1 - 4
examples/webgl_animation_blend.html

@@ -124,7 +124,6 @@
 				var loader = new THREE.ObjectLoader();
 				loader.load( "models/json/blend-animation.json", function ( loadedScene ) {
 
-					//sceneAnimationClip = loadedScene.clips[0];
 					scene = loadedScene;
 					console.log( scene );
 					scene.add( camera );
@@ -132,9 +131,7 @@
 		
 				
 					var blendObject = scene.getObjectByName( 'tree-morph' );
-					console.log( blendObject );
-					var clip = blendObject.geometry.clips[0];
-					console.log( clip );
+					var clip = blendObject.geometry.animations[0];
 					mixer = new THREE.AnimationMixer( blendObject );
 					mixer.addAction( new THREE.AnimationAction( clip ) );
 

+ 2 - 1
examples/webgl_animation_scene.html

@@ -124,7 +124,8 @@
 				var loader = new THREE.ObjectLoader();
 				loader.load( "models/json/scene-animation.json", function ( loadedScene ) {
 
-					sceneAnimationClip = loadedScene.clips[0];
+					sceneAnimationClip = loadedScene.animations[0];
+					console.log('sceneAnimationClip', sceneAnimationClip);
 					scene = loadedScene;
 					scene.add( camera );
 					scene.fog = new THREE.Fog( 0xffffff, 2000, 10000 );

+ 1 - 1
examples/webgl_animation_skinning_morph.html

@@ -234,7 +234,7 @@
 
 	
 				var clipMorpher = THREE.AnimationClip.CreateFromMorphTargetSequence( 'facialExpressions', mesh.geometry.morphTargets, 3 );
-				var clipBones = geometry.clips[0];
+				var clipBones = geometry.animations[0];
 
 				mixer = new THREE.AnimationMixer( mesh );
 				mixer.addAction( new THREE.AnimationAction( clipMorpher ) );

+ 1 - 1
examples/webgl_lights_hemisphere.html

@@ -217,7 +217,7 @@
 					scene.add( mesh );
 
 					var mixer = new THREE.AnimationMixer( mesh );
-					mixer.addAction( new THREE.AnimationAction( geometry.clips[0] ).warpToDuration( 5 ) );
+					mixer.addAction( new THREE.AnimationAction( geometry.animations[0] ).warpToDuration( 5 ) );
 					mixers.push( mixer );
 
 				} );

+ 1 - 1
examples/webgl_loader_json_blender.html

@@ -138,7 +138,7 @@
 						scene.add( mesh );
 						
 						var mixer = new THREE.AnimationMixer( mesh );
-						mixer.addAction( new THREE.AnimationAction( geometry.clips[0] ).warpToDuration( 1 ) );
+						mixer.addAction( new THREE.AnimationAction( geometry.animations[0] ).warpToDuration( 1 ) );
 
 						// random animation offset
 						mixer.update( 1000 * Math.random() );

+ 4 - 4
examples/webgl_loader_md2.html

@@ -207,7 +207,7 @@
 					setupWeaponsGUI( character );
 					setupGUIAnimations( character );
 
-					character.setAnimation( character.meshBody.geometry.clips[0].name )
+					character.setAnimation( character.meshBody.geometry.animations[0].name )
 
 				};
 
@@ -311,11 +311,11 @@
 				};
 
 				var i = 0, guiItems = [];
-				var clips = character.meshBody.geometry.clips;
+				var animations = character.meshBody.geometry.animations;
 
-				for ( var i = 0; i < clips.length; i ++ ) {
+				for ( var i = 0; i < animations.length; i ++ ) {
 
-					var clip = clips[i];
+					var clip = animations[i];
 
 					playbackConfig[ clip.name ] = generateCallback( clip );
 					guiItems[ i ] = folder.add( playbackConfig, clip.name, clip.name );

+ 2 - 2
examples/webgl_loader_scene.html

@@ -211,10 +211,10 @@
 
 						if ( object instanceof THREE.Mesh ) {
 
-							if( object.geometry && object.geometry.clips && object.geometry.clips.length > 0 ) {
+							if( object.geometry && object.geometry.animations && object.geometry.animations.length > 0 ) {
 
 								var mixer = new THREE.AnimationMixer( object );
-								mixer.addAction( new THREE.AnimationAction( object.geometry.clips[0] ) );
+								mixer.addAction( new THREE.AnimationAction( object.geometry.animations[0] ) );
 								mixers.push( mixer );
 
 							}

+ 2 - 2
examples/webgl_morphnormals.html

@@ -102,7 +102,7 @@
 					scene1.add( mesh );
 
 					var mixer = new THREE.AnimationMixer( mesh );
-					mixer.addAction( new THREE.AnimationAction( geometry.clips[ 0 ] ).warpToDuration( 5 ) );
+					mixer.addAction( new THREE.AnimationAction( geometry.animations[ 0 ] ).warpToDuration( 5 ) );
 
 					mixers.push( mixer );
 
@@ -123,7 +123,7 @@
 					scene2.add( mesh );
 
 					var mixer = new THREE.AnimationMixer( mesh );
-					mixer.addAction( new THREE.AnimationAction( geometry.clips[ 0 ] ).warpToDuration( 5 ) );
+					mixer.addAction( new THREE.AnimationAction( geometry.animations[ 0 ] ).warpToDuration( 5 ) );
 
 					mixers.push( mixer );
 

+ 1 - 1
examples/webgl_shading_physical.html

@@ -276,7 +276,7 @@
 
 					mixer = new THREE.AnimationMixer( mesh );
 
-					mixer.addAction( new THREE.AnimationAction( geometry.clips[0] ).warpToDuration( 10 ) );
+					mixer.addAction( new THREE.AnimationAction( geometry.animations[0] ).warpToDuration( 10 ) );
 
 					var s = 200;
 					mesh.scale.set( s, s, s );

+ 1 - 1
examples/webgl_shadowmap.html

@@ -319,7 +319,7 @@
 					mesh.speed = speed;
 
 					var mixer = new THREE.AnimationMixer( mesh );
-					mixer.addAction( new THREE.AnimationAction( geometry.clips[0] ).warpToDuration( duration ) );
+					mixer.addAction( new THREE.AnimationAction( geometry.animations[0] ).warpToDuration( duration ) );
 					mixer.update( 600 * Math.random() );
 					mesh.mixer = mixer;
 

+ 1 - 1
examples/webgl_shadowmap_performance.html

@@ -254,7 +254,7 @@
 					var mesh = new THREE.Mesh( geometry, material );
 					mesh.speed = speed;
 
-					mixer.addAction( new THREE.AnimationAction( geometry.clips[0], Math.random() ).warpToDuration( duration ).setLocalRoot( mesh ) );
+					mixer.addAction( new THREE.AnimationAction( geometry.animations[0], Math.random() ).warpToDuration( duration ).setLocalRoot( mesh ) );
 				
 					mesh.position.set( x, y, z );
 					mesh.rotation.y = Math.PI/2;

+ 1 - 1
examples/webgl_skinning_simple.html

@@ -76,7 +76,7 @@
 					scene.add( skinnedMesh );
 
 					mixer = new THREE.AnimationMixer( skinnedMesh );
-					mixer.addAction( new THREE.AnimationAction( skinnedMesh.geometry.clips[0] ) );					
+					mixer.addAction( new THREE.AnimationAction( skinnedMesh.geometry.animations[0] ) );					
 
 				});
 

+ 1 - 1
examples/webgl_terrain_dynamic.html

@@ -502,7 +502,7 @@
 					mesh.speed = speed;
 
 					var mixer = new THREE.AnimationMixer( mesh );
-					mixer.addAction( new THREE.AnimationAction( geometry.clips[0] ).warpToDuration( duration ) );
+					mixer.addAction( new THREE.AnimationAction( geometry.animations[0] ).warpToDuration( duration ) );
 					mixer.update( 600 * Math.random() );
 					mesh.mixer = mixer;
 

+ 1 - 1
src/animation/AnimationClip.js

@@ -10,7 +10,7 @@ THREE.AnimationClip = function ( name, duration, tracks ) {
 
 	this.name = name;
 	this.tracks = tracks;
-	this.duration = duration;
+	this.duration = ( duration !== undefined ) ? duration : -1;
 
 	// this means it should figure out its duration by scanning the tracks
 	if( this.duration < 0 ) {

+ 1 - 1
src/core/Geometry.js

@@ -4,7 +4,7 @@
  * @author alteredq / http://alteredqualia.com/
  * @author mikael emtinger / http://gomo.se/
  * @author zz85 / http://www.lab4games.net/zz85/blog
- * @author bhouston / http://exocortex.com
+ * @author bhouston / http://clara.io
  */
 
 THREE.Geometry = function () {

+ 1 - 1
src/core/Raycaster.js

@@ -1,6 +1,6 @@
 /**
  * @author mrdoob / http://mrdoob.com/
- * @author bhouston / http://exocortex.com/
+ * @author bhouston / http://clara.io/
  * @author stephomi / http://stephaneginier.com/
  */
 

+ 1 - 1
src/extras/geometries/LatheGeometry.js

@@ -1,7 +1,7 @@
 /**
  * @author astrodud / http://astrodud.isgreat.org/
  * @author zz85 / https://github.com/zz85
- * @author bhouston / http://exocortex.com
+ * @author bhouston / http://clara.io
  */
 
 // points - to create a closed torus, one must use a set of points 

+ 1 - 1
src/extras/helpers/ArrowHelper.js

@@ -1,7 +1,7 @@
 /**
  * @author WestLangley / http://github.com/WestLangley
  * @author zz85 / http://github.com/zz85
- * @author bhouston / http://exocortex.com
+ * @author bhouston / http://clara.io
  *
  * Creates an arrow for visualizing directions
  *

+ 51 - 0
src/loaders/AnimationLoader.js

@@ -0,0 +1,51 @@
+/**
+ * @author bhouston / http://clara.io/
+ */
+
+THREE.AnimationLoader = function ( manager ) {
+
+	this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
+
+};
+
+THREE.AnimationLoader.prototype = {
+
+	constructor: THREE.AnimationLoader,
+
+	load: function ( url, onLoad, onProgress, onError ) {
+
+		var scope = this;
+
+		var loader = new THREE.XHRLoader( scope.manager );
+		loader.setCrossOrigin( this.crossOrigin );
+		loader.load( url, function ( text ) {
+
+			onLoad( scope.parse( JSON.parse( text ) ) );
+
+		}, onProgress, onError );
+
+	},
+
+	setCrossOrigin: function ( value ) {
+
+		this.crossOrigin = value;
+
+	},
+
+	parse: function ( json, onLoad ) {
+
+		var animations = [];
+
+		for( var i = 0; i < json.length; i ++ ) {
+
+			var clip = THREE.AnimationClip.parse( json[i] );
+
+			animations.push( clip );
+
+		}
+
+		onLoad( animations );
+
+	}
+
+};

+ 7 - 15
src/loaders/JSONLoader.js

@@ -75,7 +75,7 @@ THREE.JSONLoader.prototype = {
 
 		parseSkin();
 		parseMorphing( scale );
-		parseClips();
+		parseAnimations();
 
 		geometry.computeFaceNormals();
 		geometry.computeBoundingSphere();
@@ -481,19 +481,9 @@ THREE.JSONLoader.prototype = {
 			}
 		}
 
-		function parseClips() {
+		function parseAnimations() {
 
-			geometry.clips = [];
-
-			// parse new style Clips
-			var clips = json.clips || [];
-
-			for( var i = 0; i < clips.length; i ++ ) {
-
-				var clip = THREE.AnimationClip.parse( clips[i] );
-				if( clip ) geometry.clips.push( clip );
-
-			}
+			var outputAnimations = [];
 
 			// parse old style Bone/Hierarchy animations
 			var animations = [];
@@ -512,7 +502,7 @@ THREE.JSONLoader.prototype = {
 			for( var i = 0; i < animations.length; i ++ ) {
 
 				var clip = THREE.AnimationClip.parseAnimation( animations[i], geometry.bones );
-				if( clip ) geometry.clips.push( clip );
+				if( clip ) outputAnimations.push( clip );
 
 			}
 
@@ -521,10 +511,12 @@ THREE.JSONLoader.prototype = {
 
 				// TODO: Figure out what an appropraite FPS is for morph target animations -- defaulting to 10, but really it is completely arbitrary.
 				var morphAnimationClips = THREE.AnimationClip.CreateClipsFromMorphTargetSequences( geometry.morphTargets, 10 );
-				geometry.clips = geometry.clips.concat( morphAnimationClips );
+				outputAnimations = outputAnimations.concat( morphAnimationClips );
 
 			}
 
+			if( outputAnimations.length > 0 ) geometry.animations = outputAnimations;
+
 		};
 
 		if ( json.materials === undefined || json.materials.length === 0 ) {

+ 23 - 31
src/loaders/ObjectLoader.js

@@ -58,13 +58,12 @@ THREE.ObjectLoader.prototype = {
 		var textures  = this.parseTextures( json.textures, images );
 		var materials = this.parseMaterials( json.materials, textures );
 
-		var tracks = [];
+		var object = this.parseObject( json.object, geometries, materials );
 
-		var object = this.parseObject( json.object, geometries, materials, tracks );
-
-		if( tracks.length > 0 ) {
-
-			object.clips = [ new THREE.AnimationClip( "default", -1, tracks ) ];
+		if( json.animations ) {
+			console.log( json.animations );
+			object.animations = this.parseAnimations( json.animations );
+			console.log( object.animations );
 
 		}
 
@@ -377,6 +376,22 @@ THREE.ObjectLoader.prototype = {
 
 	},
 
+	parseAnimations: function ( json ) {
+
+		var animations = [];
+
+		for( var i = 0; i < json.length; i ++ ) {
+
+			var clip = THREE.AnimationClip.parse( json[i] );
+
+			animations.push( clip );
+
+		}
+
+		return animations;
+
+	},
+
 	parseImages: function ( json, onLoad ) {
 
 		var scope = this;
@@ -481,7 +496,7 @@ THREE.ObjectLoader.prototype = {
 
 		var matrix = new THREE.Matrix4();
 
-		return function ( data, geometries, materials, tracks ) {
+		return function ( data, geometries, materials ) {
 
 			var object;
 
@@ -627,32 +642,9 @@ THREE.ObjectLoader.prototype = {
 
 				for ( var child in data.children ) {
 
-					object.add( this.parseObject( data.children[ child ], geometries, materials, tracks ) );
-
-				}
-
-			}
-			if( data.clips ) {
-
-				// NOTE: only reading the first clip if it exists.  We can add multiple clip support in the future with this design.
-				//  For multiple clip support we should merge clips on different nodes with the clips that have the same names.  Thus
-				//  One will end up with a few named clips for the scene composed of merged tracks from individual nodes.
-				for( var i = 0; i < Math.min( 1, data.clips.length ); i ++ ) {
-
-					var dataClips = data.clips[i];
-					var dataTracks = dataClips.tracks || [];
-					var fpsToSeconds = 1.0 / ( dataClips.fps || 30 );
-
-					for( var i = 0; i < dataTracks.length; i ++ ) {
-
-						var track = THREE.KeyframeTrack.parse( dataTracks[i] ).scale( fpsToSeconds );
-						track.name = object.uuid + '.' + track.name;
-						tracks.push( track );
-						
-					}
+					object.add( this.parseObject( data.children[ child ], geometries, materials ) );
 
 				}
-				if( data.clips.length > 1 ) console.warn( "THREE.ObjectLoader: more than one clip specified on node, not yet supported" );
 
 			}
 

+ 1 - 1
src/math/Box2.js

@@ -1,5 +1,5 @@
 /**
- * @author bhouston / http://exocortex.com
+ * @author bhouston / http://clara.io
  */
 
 THREE.Box2 = function ( min, max ) {

+ 1 - 1
src/math/Box3.js

@@ -1,5 +1,5 @@
 /**
- * @author bhouston / http://exocortex.com
+ * @author bhouston / http://clara.io
  * @author WestLangley / http://github.com/WestLangley
  */
 

+ 1 - 1
src/math/Euler.js

@@ -1,7 +1,7 @@
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author WestLangley / http://github.com/WestLangley
- * @author bhouston / http://exocortex.com
+ * @author bhouston / http://clara.io
  */
 
 THREE.Euler = function ( x, y, z, order ) {

+ 1 - 1
src/math/Frustum.js

@@ -1,7 +1,7 @@
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author alteredq / http://alteredqualia.com/
- * @author bhouston / http://exocortex.com
+ * @author bhouston / http://clara.io
  */
 
 THREE.Frustum = function ( p0, p1, p2, p3, p4, p5 ) {

+ 1 - 1
src/math/Line3.js

@@ -1,5 +1,5 @@
 /**
- * @author bhouston / http://exocortex.com
+ * @author bhouston / http://clara.io
  */
 
 THREE.Line3 = function ( start, end ) {

+ 1 - 1
src/math/Matrix3.js

@@ -1,7 +1,7 @@
 /**
  * @author alteredq / http://alteredqualia.com/
  * @author WestLangley / http://github.com/WestLangley
- * @author bhouston / http://exocortex.com
+ * @author bhouston / http://clara.io
  */
 
 THREE.Matrix3 = function () {

+ 1 - 1
src/math/Matrix4.js

@@ -7,7 +7,7 @@
  * @author alteredq / http://alteredqualia.com/
  * @author mikael emtinger / http://gomo.se/
  * @author timknip / http://www.floorplanner.com/
- * @author bhouston / http://exocortex.com
+ * @author bhouston / http://clara.io
  * @author WestLangley / http://github.com/WestLangley
  */
 

+ 1 - 1
src/math/Plane.js

@@ -1,5 +1,5 @@
 /**
- * @author bhouston / http://exocortex.com
+ * @author bhouston / http://clara.io
  */
 
 THREE.Plane = function ( normal, constant ) {

+ 1 - 1
src/math/Quaternion.js

@@ -2,7 +2,7 @@
  * @author mikael emtinger / http://gomo.se/
  * @author alteredq / http://alteredqualia.com/
  * @author WestLangley / http://github.com/WestLangley
- * @author bhouston / http://exocortex.com
+ * @author bhouston / http://clara.io
  */
 
 THREE.Quaternion = function ( x, y, z, w ) {

+ 1 - 1
src/math/Ray.js

@@ -1,5 +1,5 @@
 /**
- * @author bhouston / http://exocortex.com
+ * @author bhouston / http://clara.io
  */
 
 THREE.Ray = function ( origin, direction ) {

+ 1 - 1
src/math/Sphere.js

@@ -1,5 +1,5 @@
 /**
- * @author bhouston / http://exocortex.com
+ * @author bhouston / http://clara.io
  * @author mrdoob / http://mrdoob.com/
  */
 

+ 1 - 1
src/math/Triangle.js

@@ -1,5 +1,5 @@
 /**
- * @author bhouston / http://exocortex.com
+ * @author bhouston / http://clara.io
  * @author mrdoob / http://mrdoob.com/
  */
 

Vissa filer visades inte eftersom för många filer har ändrats