Переглянути джерело

allow for setting per action local roots.

Ben Houston 10 роки тому
батько
коміт
e0fdbbd1ff

+ 1 - 3
examples/js/UCSCharacter.js

@@ -55,9 +55,7 @@ THREE.UCSCharacter = function() {
 			mesh.castShadow = 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 );
 			

+ 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' );
 	this.clip = clip;
+	this.localRoot = null;
 	this.startTime = startTime || 0;
 	this.timeScale = timeScale || 1;
 	this.weight = weight || 1;
@@ -26,6 +27,14 @@ THREE.AnimationAction.prototype = {
 
 	constructor: THREE.AnimationAction,
 
+	setLocalRoot: function( localRoot ) {
+
+		this.localRoot = localRoot;
+
+		return this;
+		
+	},
+
 	updateTime: function( 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 root = action.localRoot || this.root;
+
 		for( var i = 0; i < tracks.length; i ++ ) {
 
 			var track = tracks[ i ];
@@ -40,7 +42,7 @@ THREE.AnimationMixer.prototype = {
 
 			if( j < 0 ) {
 			
-				propertyBinding = new THREE.PropertyBinding( this.root, track.name );
+				propertyBinding = new THREE.PropertyBinding( root, track.name );
 				this.propertyBindings.push( propertyBinding );
 			
 			}