diff options
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/animation.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/animation.js | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/animation.js b/js/helper-classes/RDGE/src/core/script/animation.js index 2e13cce6..2af5b207 100755 --- a/js/helper-classes/RDGE/src/core/script/animation.js +++ b/js/helper-classes/RDGE/src/core/script/animation.js | |||
@@ -32,11 +32,11 @@ POSSIBILITY OF SUCH DAMAGE. | |||
32 | var RDGE = RDGE || {}; | 32 | var RDGE = RDGE || {}; |
33 | RDGE.animation = RDGE.animation || {}; | 33 | RDGE.animation = RDGE.animation || {}; |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * channelController | 36 | * channelController |
37 | * The channel controller is really the workhorse of the RDGE animation system. It handles timing, | 37 | * The channel controller is really the workhorse of the RDGE animation system. It handles timing, |
38 | * interpolation, and sampling of attributes over the lifetime of an animation. Each channel controller | 38 | * interpolation, and sampling of attributes over the lifetime of an animation. Each channel controller |
39 | * is responsible for animating a single attribute. The current implementation supports animating vector, | 39 | * is responsible for animating a single attribute. The current implementation supports animating vector, |
40 | * boolean, or quaternion attributes. This class is used internally by the animation system. | 40 | * boolean, or quaternion attributes. This class is used internally by the animation system. |
41 | * | 41 | * |
42 | * @param _animation - the animation resource | 42 | * @param _animation - the animation resource |
@@ -44,16 +44,16 @@ RDGE.animation = RDGE.animation || {}; | |||
44 | * | 44 | * |
45 | */ | 45 | */ |
46 | RDGE.animation.channelController = function (_animation, _channel) { | 46 | RDGE.animation.channelController = function (_animation, _channel) { |
47 | /** | 47 | /** |
48 | * this.interpolate - Enable/Disable interpolation between animation frames. | 48 | * this.interpolate - Enable/Disable interpolation between animation frames. |
49 | * Typically this should be enabled for smoother looking animation. However, | 49 | * Typically this should be enabled for smoother looking animation. However, |
50 | * there may be applications where interpolation is undesireable. | 50 | * there may be applications where interpolation is undesireable. |
51 | */ | 51 | */ |
52 | this.interpolate = false; | 52 | this.interpolate = false; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * this.animation - the animation resource. | 55 | * this.animation - the animation resource. |
56 | * This is where the keyframes for the channel are stored. | 56 | * This is where the keyframes for the channel are stored. |
57 | */ | 57 | */ |
58 | this.animation = _animation; | 58 | this.animation = _animation; |
59 | 59 | ||
@@ -77,20 +77,20 @@ RDGE.animation.channelController = function (_animation, _channel) { | |||
77 | */ | 77 | */ |
78 | this.endTime = this.animation.clipEnd / this.animation.framesPerSec; | 78 | this.endTime = this.animation.clipEnd / this.animation.framesPerSec; |
79 | 79 | ||
80 | /** | 80 | /** |
81 | * this.cachedFrame - cached frame index, this optimizes best case scenario computeFrame calls. | 81 | * this.cachedFrame - cached frame index, this optimizes best case scenario computeFrame calls. |
82 | */ | 82 | */ |
83 | this.cachedFrame = -1; | 83 | this.cachedFrame = -1; |
84 | 84 | ||
85 | /** | 85 | /** |
86 | * oneFrameInSecs - stores the interval of a single frame in seconds. This is used for internal calculations. | 86 | * oneFrameInSecs - stores the interval of a single frame in seconds. This is used for internal calculations. |
87 | */ | 87 | */ |
88 | oneFrameInSecs = 1.0 / _animation.framesPerSec; | 88 | oneFrameInSecs = 1.0 / _animation.framesPerSec; |
89 | 89 | ||
90 | /** | 90 | /** |
91 | * this.channel.timeline - stores the animation timeline. | 91 | * this.channel.timeline - stores the animation timeline. |
92 | * Currently this is calculated based on the framePerSec settings of the animation. | 92 | * Currently this is calculated based on the framePerSec settings of the animation. |
93 | * Eventually the timeline should be exported with the animation. Individual channels | 93 | * Eventually the timeline should be exported with the animation. Individual channels |
94 | * may have different timelines depending on which frames are keyed. | 94 | * may have different timelines depending on which frames are keyed. |
95 | */ | 95 | */ |
96 | this.channel.timeline = new Array(this.channel.numKeys + 1); | 96 | this.channel.timeline = new Array(this.channel.numKeys + 1); |
@@ -98,11 +98,11 @@ RDGE.animation.channelController = function (_animation, _channel) { | |||
98 | this.channel.timeline[i] = i / this.animation.framesPerSec; | 98 | this.channel.timeline[i] = i / this.animation.framesPerSec; |
99 | } | 99 | } |
100 | 100 | ||
101 | /** this.computeFrame | 101 | /** this.computeFrame |
102 | * Calculates the current frame index of the animation at the current time. | 102 | * Calculates the current frame index of the animation at the current time. |
103 | * In the worst case, this function will perform a binary search for the frame | 103 | * In the worst case, this function will perform a binary search for the frame |
104 | * whose time is closest to and less than the current time. In the best case, | 104 | * whose time is closest to and less than the current time. In the best case, |
105 | * the current frame is near the most recently cached frame, or it remains unchanged. | 105 | * the current frame is near the most recently cached frame, or it remains unchanged. |
106 | */ | 106 | */ |
107 | this.computeFrame = function () { | 107 | this.computeFrame = function () { |
108 | var absTime = this.localTime + this.startTime; | 108 | var absTime = this.localTime + this.startTime; |
@@ -146,7 +146,7 @@ RDGE.animation.channelController = function (_animation, _channel) { | |||
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | // binary search... | 149 | // binary search... |
150 | while (start + 1 < end) { | 150 | while (start + 1 < end) { |
151 | var mid = Math.floor((start + end) / 2); | 151 | var mid = Math.floor((start + end) / 2); |
152 | if (absTime > this.channel.timeline[mid]) { | 152 | if (absTime > this.channel.timeline[mid]) { |
@@ -262,9 +262,9 @@ RDGE.animation.channelController = function (_animation, _channel) { | |||
262 | }; | 262 | }; |
263 | }; | 263 | }; |
264 | 264 | ||
265 | /** | 265 | /** |
266 | * track | 266 | * track |
267 | * Each track advances and samples from a list of channel controllers, and is assigned to a scene graph node. | 267 | * Each track advances and samples from a list of channel controllers, and is assigned to a scene graph node. |
268 | * | 268 | * |
269 | * @param _animation - the animation resource | 269 | * @param _animation - the animation resource |
270 | * @param _track - the track id | 270 | * @param _track - the track id |