Browse Source

object loader can now parse tracks on individual objects for scene animations.

Ben Houston 10 years ago
parent
commit
cce87943e0
1 changed files with 26 additions and 0 deletions
  1. 26 0
      src/loaders/ObjectLoader.js

+ 26 - 0
src/loaders/ObjectLoader.js

@@ -57,6 +57,7 @@ THREE.ObjectLoader.prototype = {
 
 		var textures  = this.parseTextures( json.textures, images );
 		var materials = this.parseMaterials( json.materials, textures );
+
 		var object = this.parseObject( json.object, geometries, materials );
 
 		if ( json.images === undefined || json.images.length === 0 ) {
@@ -618,6 +619,31 @@ THREE.ObjectLoader.prototype = {
 
 			}
 
+			if( data.animations ) {
+
+				var dataTracks = data.animations.tracks;
+
+				object.tracks = [];
+
+				if( dataTracks.position ) {
+
+					object.tracks.add( THREE.VectorKeyframeTrack.parse( object.uuid + '.position', dataTracks.position ) );
+
+				}
+
+				if( dataTracks.quaternion ) {
+
+					object.tracks.add( THREE.QuaternionKeyframeTrack.parse( object.uuid + '.quaternion', dataTracks.position ) );
+
+				}
+
+				if( dataTracks.scale ) {
+
+					object.tracks.add( THREE.VectorKeyframeTrack.parse( object.uuid + '.scale', dataTracks.position ) );
+
+				}
+			}
+
 			return object;
 
 		}