瀏覽代碼

Fixed comments and object signatures

Also cleaned up formatting for spaces
Christine Morten 5 年之前
父節點
當前提交
592a537104
共有 3 個文件被更改,包括 32 次插入27 次删除
  1. 11 6
      src/Animations/animatable.ts
  2. 12 12
      src/Animations/animation.ts
  3. 9 9
      src/Animations/animationGroup.ts

+ 11 - 6
src/Animations/animatable.ts

@@ -106,6 +106,7 @@ export class Animatable {
      * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
      * @param animations defines a group of animation to add to the new Animatable
      * @param onAnimationLoop defines a callback to call when animation loops
+     * @param isAdditive defines whether the animation should be evaluated additively
      */
     constructor(scene: Scene,
         /** defines the target object */
@@ -438,14 +439,18 @@ declare module "../scene" {
         /** @hidden */
         _processLateAnimationBindingsForMatrices(holder: {
             totalWeight: number,
+            totalAdditiveWeight: number,
             animations: RuntimeAnimation[],
+            additiveAnimations: RuntimeAnimation[],
             originalValue: Matrix
         }): any;
 
         /** @hidden */
         _processLateAnimationBindingsForQuaternions(holder: {
             totalWeight: number,
+            totalAdditiveWeight: number,
             animations: RuntimeAnimation[],
+            additiveAnimations: RuntimeAnimation[],
             originalValue: Quaternion
         }, refQuaternion: Quaternion): Quaternion;
 
@@ -763,7 +768,7 @@ Scene.prototype._registerTargetForLateAnimationBinding = function(runtimeAnimati
     } else {
         target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
         target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
-    } 
+    }
 };
 
 Scene.prototype._processLateAnimationBindingsForMatrices = function(holder: {
@@ -789,7 +794,7 @@ Scene.prototype._processLateAnimationBindingsForMatrices = function(holder: {
     var scale = 1;
     var skipOverride = false;
     if (holder.totalWeight < 1.0) {
-        // We need to mix the original value in      
+        // We need to mix the original value in
         scale = 1.0 - holder.totalWeight;
     } else {
         normalizer = holder.totalWeight;
@@ -804,7 +809,7 @@ Scene.prototype._processLateAnimationBindingsForMatrices = function(holder: {
 
         startIndex = 1;
         // We need to normalize the weights
-        originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);    
+        originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);
     }
 
     // Add up the override animations
@@ -848,7 +853,7 @@ Scene.prototype._processLateAnimationBindingsForMatrices = function(holder: {
         finalQuaternion.multiplyToRef(currentQuaternion, currentQuaternion);
         Quaternion.SlerpToRef(finalQuaternion, currentQuaternion, runtimeAnimation.weight, finalQuaternion);
         currentPosition.scaleAndAddToRef(runtimeAnimation.weight, finalPosition);
-        
+
     }
 
     let workValue = originalAnimation ? originalAnimation._animationState.workValue : TmpVectors.Matrix[0].clone();
@@ -896,10 +901,10 @@ Scene.prototype._processLateAnimationBindingsForQuaternions = function(holder: {
         } else {
             if (holder.animations.length === 2) { // Slerp as soon as we can
                 Quaternion.SlerpToRef(holder.animations[0].currentValue, holder.animations[1].currentValue, holder.animations[1].weight / holder.totalWeight, refQuaternion);
-                
+
                 if (!holder.totalAdditiveWeight) {
                     return refQuaternion;
-                }               
+                }
             }
 
             quaternions = [];

+ 12 - 12
src/Animations/animation.ts

@@ -235,9 +235,9 @@ export class Animation {
     public static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame = 0, range?: string, cloneOriginal = false, clonedName?: string): Animation {
         let animation = sourceAnimation;
 
-		if ( cloneOriginal ) {
-			animation = sourceAnimation.clone();
-			animation.name = clonedName || animation.name;
+        if (cloneOriginal) {
+            animation = sourceAnimation.clone();
+            animation.name = clonedName || animation.name;
         }
 
         if (!animation._keys.length) {
@@ -248,7 +248,7 @@ export class Animation {
         let startIndex = 0;
         let firstKey = animation._keys[0];
         let endIndex = animation._keys.length - 1;
-        let lastKey = animation._keys[endIndex];       
+        let lastKey = animation._keys[endIndex];
         let valueStore = {
             referenceValue: firstKey.value,
             referencePosition: TmpVectors.Vector3[0],
@@ -268,7 +268,7 @@ export class Animation {
                 from = rangeValue.from;
                 to = rangeValue.to;
             }
-        } 
+        }
         let fromKeyFound = firstKey.frame === from;
         let toKeyFound = lastKey.frame === to;
 
@@ -285,7 +285,7 @@ export class Animation {
             valueStore.referenceValue = value.clone ? value.clone() : value;
             referenceFound = true;
         }
-        
+
         // Reference frame is after the last frame, so just use the last frame
         else if (referenceFrame >= lastKey.frame) {
             let value = animation._getKeyValue(lastKey.value);
@@ -336,7 +336,7 @@ export class Animation {
                     let key: IAnimationKey = {
                         frame: from,
                         value: value.clone ? value.clone() : value
-                    }
+                    };
                     animation._keys.splice(index + 1, 0, key);
                     startIndex = index + 1;
                 }
@@ -360,7 +360,7 @@ export class Animation {
                     let key: IAnimationKey = {
                         frame: to,
                         value: value.clone ? value.clone() : value
-                    }
+                    };
                     animation._keys.splice(index + 1, 0, key);
                     endIndex = index + 1;
                 }
@@ -399,23 +399,23 @@ export class Animation {
                     valueStore.referenceQuaternion.multiplyToRef(valueStore.keyQuaternion, valueStore.keyQuaternion);
                     Matrix.ComposeToRef(valueStore.keyScaling, valueStore.keyQuaternion, valueStore.keyPosition, key.value);
                     break;
-                
+
                 case Animation.ANIMATIONTYPE_QUATERNION:
                     valueStore.referenceValue.multiplyToRef(key.value, key.value);
                     break;
-                
+
                 case Animation.ANIMATIONTYPE_VECTOR2:
                 case Animation.ANIMATIONTYPE_VECTOR3:
                 case Animation.ANIMATIONTYPE_COLOR3:
                 case Animation.ANIMATIONTYPE_COLOR4:
                     key.value.subtractToRef(valueStore.referenceValue, key.value);
                     break;
-                
+
                 case Animation.ANIMATIONTYPE_SIZE:
                     key.value.width -= valueStore.referenceValue.width;
                     key.value.height -= valueStore.referenceValue.height;
                     break;
-                
+
                 default:
                     key.value -= valueStore.referenceValue;
             }

+ 9 - 9
src/Animations/animationGroup.ts

@@ -323,14 +323,14 @@ export class AnimationGroup implements IDisposable {
         for (var index = 0; index < this._targetedAnimations.length; index++) {
             const targetedAnimation = this._targetedAnimations[index];
             let animatable = this._scene.beginDirectAnimation(
-                targetedAnimation.target, 
-                [targetedAnimation.animation], 
-                from !== undefined ? from : this._from, 
-                to !== undefined ? to : this._to, 
-                loop, 
-                speedRatio, 
-                undefined, 
-                undefined, 
+                targetedAnimation.target,
+                [targetedAnimation.animation],
+                from !== undefined ? from : this._from,
+                to !== undefined ? to : this._to,
+                loop,
+                speedRatio,
+                undefined,
+                undefined,
                 isAdditive !== undefined ? isAdditive : this._isAdditive
             );
             animatable.onAnimationEnd = () => {
@@ -636,7 +636,7 @@ export class AnimationGroup implements IDisposable {
         }
 
         animationGroup.isAdditive = true;
-        
+
         return animationGroup;
     }