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

addressing code review comments, removed modification to IAnimatable, added AnimationGroup serialization to sceneSerializer.serialize()

Nicholas Barlow пре 6 година
родитељ
комит
5945d101eb
4 измењених фајлова са 13 додато и 18 уклоњено
  1. 3 6
      src/Animations/animationGroup.ts
  2. 0 10
      src/Misc/decorators.ts
  3. 10 0
      src/Misc/sceneSerializer.ts
  4. 0 2
      src/Misc/tools.ts

+ 3 - 6
src/Animations/animationGroup.ts

@@ -22,11 +22,6 @@ export class TargetedAnimation {
      */
     public target: any;
 
-    public constructor(animation: Animation, target: any){
-        this.animation = animation;
-        this.target = target;
-    }
-
     public serialize(): any {
         var serializationObject: any = {};
         serializationObject.animation = this.animation.serialize();
@@ -190,7 +185,9 @@ export class AnimationGroup implements IDisposable {
      * @returns the TargetedAnimation object
      */
     public addTargetedAnimation(animation: Animation, target: any): TargetedAnimation {
-        let targetedAnimation = new TargetedAnimation (animation, target);
+        let targetedAnimation = new TargetedAnimation ();
+        targetedAnimation.animation = animation;
+        targetedAnimation.target = target;
 
         let keys = animation.getKeys();
         if (this._from > keys[0].frame) {

+ 0 - 10
src/Misc/decorators.ts

@@ -247,16 +247,6 @@ export class SerializationHelper {
                 destination.animations.push(animation.serialize());
             }
         }
-
-        if (source.animationGroups)
-        {
-            destination.animationGroups = [];
-            for (var animationGroupIndex = 0; animationGroupIndex < source.animationGroups.length; animationGroupIndex++) {
-                var animationGroup = source.animationGroups[animationGroupIndex];
-
-                destination.animationGroups.push(animationGroup.serialize());
-            }
-        }
     }
 
     /**

+ 10 - 0
src/Misc/sceneSerializer.ts

@@ -190,6 +190,16 @@ export class SceneSerializer {
         // Animations
         SerializationHelper.AppendSerializedAnimations(scene, serializationObject);
 
+        // Animation Groups
+        if(scene.animationGroups && scene.animationGroups.length > 0){
+            serializationObject.animationGroups = [];
+            for (var animationGroupIndex = 0; animationGroupIndex < scene.animationGroups.length; animationGroupIndex++) {
+                var animationGroup = scene.animationGroups[animationGroupIndex];
+
+                serializationObject.animationGroups.push(animationGroup.serialize());
+            }
+        }
+
         // Reflection probes
         if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
             serializationObject.reflectionProbes = [];

+ 0 - 2
src/Misc/tools.ts

@@ -16,7 +16,6 @@ import { WebRequest } from './webRequest';
 declare type Camera = import("../Cameras/camera").Camera;
 declare type Engine = import("../Engines/engine").Engine;
 declare type Animation = import("../Animations/animation").Animation;
-declare type AnimationGroup = import("../Animations/animationGroup").AnimationGroup;
 
 /**
  * Interface for any object that can request an animation frame
@@ -46,7 +45,6 @@ export interface IAnimatable {
      * Array of animations
      */
     animations: Nullable<Array<Animation>>;
-    animationGroups: Nullable<Array<AnimationGroup>>;
 }
 
 /** Interface used by value gradients (color, factor, ...) */