Преглед изворни кода

allow for setting per action local roots.

Ben Houston пре 10 година
родитељ
комит
e0fdbbd1ff
3 измењених фајлова са 13 додато и 4 уклоњено
  1. 1 3
      examples/js/UCSCharacter.js
  2. 9 0
      src/animation/AnimationAction.js
  3. 3 1
      src/animation/AnimationMixer.js

+ 1 - 3
examples/js/UCSCharacter.js

@@ -55,9 +55,7 @@ THREE.UCSCharacter = function() {
 			mesh.castShadow = true;
 			mesh.castShadow = true;
 			mesh.receiveShadow = true;
 			mesh.receiveShadow = true;
 
 
-			var clipBones = THREE.AnimationClip.FromJSONLoaderAnimation( geometry.animation, geometry.bones, mesh.uuid );
-
-			scope.mixer.addAction( new THREE.AnimationAction( clipBones, 0, 1, 1, true ) );
+			scope.mixer.addAction( new THREE.AnimationAction( geometry.clips[0], 0, 1, 1, true ).setLocalRoot( mesh ) );
 			
 			
 			scope.setSkin( 0 );
 			scope.setSkin( 0 );
 			
 			

+ 9 - 0
src/animation/AnimationAction.js

@@ -10,6 +10,7 @@ THREE.AnimationAction = function ( clip, startTime, timeScale, weight, loop ) {
 
 
 	if( clip === undefined ) throw new Error( 'clip is null' );
 	if( clip === undefined ) throw new Error( 'clip is null' );
 	this.clip = clip;
 	this.clip = clip;
+	this.localRoot = null;
 	this.startTime = startTime || 0;
 	this.startTime = startTime || 0;
 	this.timeScale = timeScale || 1;
 	this.timeScale = timeScale || 1;
 	this.weight = weight || 1;
 	this.weight = weight || 1;
@@ -26,6 +27,14 @@ THREE.AnimationAction.prototype = {
 
 
 	constructor: THREE.AnimationAction,
 	constructor: THREE.AnimationAction,
 
 
+	setLocalRoot: function( localRoot ) {
+
+		this.localRoot = localRoot;
+
+		return this;
+		
+	},
+
 	updateTime: function( clipDeltaTime ) {
 	updateTime: function( clipDeltaTime ) {
 
 
 		var newClipTime = this.clipTime + clipDeltaTime;
 		var newClipTime = this.clipTime + clipDeltaTime;

+ 3 - 1
src/animation/AnimationMixer.js

@@ -30,6 +30,8 @@ THREE.AnimationMixer.prototype = {
 
 
 		var tracks = action.clip.tracks;
 		var tracks = action.clip.tracks;
 
 
+		var root = action.localRoot || this.root;
+
 		for( var i = 0; i < tracks.length; i ++ ) {
 		for( var i = 0; i < tracks.length; i ++ ) {
 
 
 			var track = tracks[ i ];
 			var track = tracks[ i ];
@@ -40,7 +42,7 @@ THREE.AnimationMixer.prototype = {
 
 
 			if( j < 0 ) {
 			if( j < 0 ) {
 			
 			
-				propertyBinding = new THREE.PropertyBinding( this.root, track.name );
+				propertyBinding = new THREE.PropertyBinding( root, track.name );
 				this.propertyBindings.push( propertyBinding );
 				this.propertyBindings.push( propertyBinding );
 			
 			
 			}
 			}