Browse Source

Adds the `.setTime(timeInSeconds)` method to the AnimationMixer object.
Updates typescript definition accordingly.

Bug-Reaper 5 years ago
parent
commit
6223184b10
2 changed files with 10 additions and 0 deletions
  1. 1 0
      src/animation/AnimationMixer.d.ts
  2. 9 0
      src/animation/AnimationMixer.js

+ 1 - 0
src/animation/AnimationMixer.d.ts

@@ -13,6 +13,7 @@ export class AnimationMixer extends EventDispatcher {
 	existingAction( clip: AnimationClip, root?: any ): AnimationAction;
 	existingAction( clip: AnimationClip, root?: any ): AnimationAction;
 	stopAllAction(): AnimationMixer;
 	stopAllAction(): AnimationMixer;
 	update( deltaTime: number ): AnimationMixer;
 	update( deltaTime: number ): AnimationMixer;
+	setTime( timeInSeconds: number ): AnimationMixer;
 	getRoot(): any;
 	getRoot(): any;
 	uncacheClip( clip: AnimationClip ): void;
 	uncacheClip( clip: AnimationClip ): void;
 	uncacheRoot( root: any ): void;
 	uncacheRoot( root: any ): void;

+ 9 - 0
src/animation/AnimationMixer.js

@@ -653,6 +653,15 @@ AnimationMixer.prototype = Object.assign( Object.create( EventDispatcher.prototy
 
 
 	},
 	},
 
 
+	// Allows you to seek to a specific time in an animation.
+	setTime: function( timeInSeconds ) {
+		this.time=0; // Zero out time attribute for AnimationMixer object;
+    for(var i=0;i<this._actions.length;i++){
+      this._actions[i].time=0; // Zero out time attribute for all associated AnimationAction objects.
+    }
+    return this.update(timeInSeconds); // Update used to set exact time. Returns "this" AnimationMixer object.
+	},
+
 	// return this mixer's root target object
 	// return this mixer's root target object
 	getRoot: function () {
 	getRoot: function () {