Sfoglia il codice sorgente

step 2..needs cleaning and linting

David Catuhe 6 anni fa
parent
commit
8248719d1c

+ 1 - 2
src/Animations/animation.ts

@@ -7,7 +7,7 @@ import { Scene } from "../scene";
 import { IAnimatable } from "../Misc/tools";
 import { Node } from "../node";
 import { SerializationHelper } from "../Misc/decorators";
-import { _TypeStore } from 'Misc';
+import { _TypeStore } from '../Misc/typeStore';
 
 declare type Animatable = import("./animatable").Animatable;
 declare type RuntimeAnimation = import("./runtimeAnimation").RuntimeAnimation;
@@ -1238,6 +1238,5 @@ export class Animation {
     }
 }
 
-
 _TypeStore.RegisteredTypes["BABYLON.Animation"] = Animation;
 Node._AnimationRangeFactory = (name: string, from: number, to: number) => new AnimationRange(name, from, to);

+ 18 - 23
src/Animations/animationComponent.ts

@@ -1,8 +1,8 @@
 import { Scene } from "../scene";
 import { Node } from "../node";
 import { RuntimeAnimation } from './runtimeAnimation';
-import { Matrix, Tmp, Quaternion, Vector3 } from '../Maths';
-import { Nullable } from 'types';
+import { Matrix, Tmp, Quaternion, Vector3 } from '../Maths/math';
+import { Nullable } from '../types';
 import { Animation } from './animation';
 import { Animatable } from './animatable';
 import { PrecisionDate } from 'Misc';
@@ -48,8 +48,7 @@ declare module "../scene" {
          * @returns the animatable object created for this animation
          */
         beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number,
-            onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable
-
+            onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
 
         /**
          * Will start the animation sequence of a given target
@@ -69,7 +68,6 @@ declare module "../scene" {
             onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean,
             targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
 
-
         /**
          * Will start the animation sequence of a given target and its hierarchy
          * @param target defines the target
@@ -89,7 +87,6 @@ declare module "../scene" {
             onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean,
             targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
 
-
         /**
          * Begin a new animation on a given node
          * @param target defines the target where the animation will take place
@@ -170,7 +167,7 @@ Scene.prototype._animate = function(): void {
 
     // Late animation bindings
     this._processLateAnimationBindings();
-}
+};
 
 Scene.prototype.beginWeightedAnimation = function(target: any, from: number, to: number, weight = 1.0, loop?: boolean, speedRatio: number = 1.0,
     onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable {
@@ -179,7 +176,7 @@ Scene.prototype.beginWeightedAnimation = function(target: any, from: number, to:
     returnedAnimatable.weight = weight;
 
     return returnedAnimatable;
-}
+};
 
 Scene.prototype.beginAnimation = function(target: any, from: number, to: number, loop?: boolean, speedRatio: number = 1.0,
     onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent = true,
@@ -214,7 +211,7 @@ Scene.prototype.beginAnimation = function(target: any, from: number, to: number,
     animatable.reset();
 
     return animatable;
-}
+};
 
 Scene.prototype.beginHierarchyAnimation = function(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio: number = 1.0,
     onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent = true,
@@ -229,7 +226,7 @@ Scene.prototype.beginHierarchyAnimation = function(target: any, directDescendant
     }
 
     return result;
-}
+};
 
 Scene.prototype.beginDirectAnimation = function(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable {
     if (speedRatio === undefined) {
@@ -239,8 +236,7 @@ Scene.prototype.beginDirectAnimation = function(target: any, animations: Animati
     var animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, animations, onAnimationLoop);
 
     return animatable;
-}
-
+};
 
 Scene.prototype.beginDirectHierarchyAnimation = function(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[] {
     let children = target.getDescendants(directDescendantsOnly);
@@ -252,7 +248,7 @@ Scene.prototype.beginDirectHierarchyAnimation = function(target: Node, directDes
     }
 
     return result;
-}
+};
 
 Scene.prototype.getAnimatableByTarget = function(target: any): Nullable<Animatable> {
     for (var index = 0; index < this._activeAnimatables.length; index++) {
@@ -262,7 +258,7 @@ Scene.prototype.getAnimatableByTarget = function(target: any): Nullable<Animatab
     }
 
     return null;
-}
+};
 
 Scene.prototype.getAllAnimatablesByTarget = function(target: any): Array<Animatable> {
     let result = [];
@@ -273,7 +269,7 @@ Scene.prototype.getAllAnimatablesByTarget = function(target: any): Array<Animata
     }
 
     return result;
-}
+};
 
 /**
  * Will stop the animation of the given target
@@ -287,7 +283,7 @@ Scene.prototype.stopAnimation = function(target: any, animationName?: string, ta
     for (var animatable of animatables) {
         animatable.stop(animationName, targetMask);
     }
-}
+};
 
 /**
  * Stops and removes all animations that have been applied to the scene
@@ -303,8 +299,7 @@ Scene.prototype.stopAllAnimations = function(): void {
     for (var group of this.animationGroups) {
         group.stop();
     }
-}
-
+};
 
 Scene.prototype._registerTargetForLateAnimationBinding = function(runtimeAnimation: RuntimeAnimation, originalValue: any): void {
     let target = runtimeAnimation.target;
@@ -324,7 +319,7 @@ Scene.prototype._registerTargetForLateAnimationBinding = function(runtimeAnimati
 
     target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
     target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
-}
+};
 
 Scene.prototype._processLateAnimationBindingsForMatrices = function(holder: {
     totalWeight: number,
@@ -374,7 +369,7 @@ Scene.prototype._processLateAnimationBindingsForMatrices = function(holder: {
 
     Matrix.ComposeToRef(finalScaling, finalQuaternion, finalPosition, originalAnimation._workValue);
     return originalAnimation._workValue;
-}
+};
 
 Scene.prototype._processLateAnimationBindingsForQuaternions = function(holder: {
     totalWeight: number,
@@ -435,7 +430,7 @@ Scene.prototype._processLateAnimationBindingsForQuaternions = function(holder: {
     }
 
     return cumulativeQuaternion!;
-}
+};
 
 Scene.prototype._processLateAnimationBindings = function(): void {
     if (!this._registeredForLateAnimationBindings.length) {
@@ -504,7 +499,7 @@ Scene.prototype._processLateAnimationBindings = function(): void {
         target._lateAnimationHolders = {};
     }
     this._registeredForLateAnimationBindings.reset();
-}
+};
 
 declare module "../Bones/bone" {
     export interface Bone {
@@ -581,4 +576,4 @@ Bone.prototype.copyAnimationRange = function(source: Bone, rangeName: string, fr
     }
     this.animations[0].createRange(rangeName, from + frameOffset, to + frameOffset);
     return true;
-}
+};

+ 5 - 4
src/Cameras/camera.ts

@@ -12,8 +12,7 @@ import { AbstractMesh } from "../Meshes/abstractMesh";
 import { Ray } from "../Culling/ray";
 import { ICullable } from "../Culling/boundingInfo";
 import { Logger } from "../Misc/logger";
-
-import { Animation } from "../Animations/animation";
+import { _TypeStore } from '../Misc';
 
 declare type PostProcess = import("../PostProcesses/postProcess").PostProcess;
 declare type RenderTargetTexture = import("../Materials/Textures/renderTargetTexture").RenderTargetTexture;
@@ -1211,8 +1210,10 @@ export class Camera extends Node {
         if (parsedCamera.animations) {
             for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
                 var parsedAnimation = parsedCamera.animations[animationIndex];
-
-                camera.animations.push(Animation.Parse(parsedAnimation));
+                const internalClass = _TypeStore.GetClass("BABYLON.Animation");
+                if (internalClass) {
+                    camera.animations.push(internalClass.Parse(parsedAnimation));
+                }
             }
             Node.ParseAnimationRanges(camera, parsedCamera, scene);
         }

+ 6 - 3
src/Lights/light.ts

@@ -6,8 +6,9 @@ import { Node } from "../node";
 import { AbstractMesh } from "../Meshes/abstractMesh";
 import { Effect } from "../Materials/effect";
 import { UniformBuffer } from "../Materials/uniformBuffer";
-import { Animation } from "../Animations/animation";
 import { IShadowGenerator } from "./Shadows/shadowGenerator";
+import { _TypeStore } from '../Misc/typeStore';
+
 /**
  * Base class of all the lights in Babylon. It groups all the generic information about lights.
  * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
@@ -610,8 +611,10 @@ export abstract class Light extends Node {
         if (parsedLight.animations) {
             for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
                 var parsedAnimation = parsedLight.animations[animationIndex];
-
-                light.animations.push(Animation.Parse(parsedAnimation));
+                const internalClass = _TypeStore.GetClass("BABYLON.Animation");
+                if (internalClass) {
+                    light.animations.push(internalClass.Parse(parsedAnimation));
+                }
             }
             Node.ParseAnimationRanges(light, parsedLight, scene);
         }

+ 10 - 7
src/Loading/Plugins/babylonFileLoader.ts

@@ -11,7 +11,6 @@ import { Material } from "../../Materials/material";
 import { MultiMaterial } from "../../Materials/multiMaterial";
 import { CubeTexture } from "../../Materials/Textures/cubeTexture";
 import { HDRCubeTexture } from "../../Materials/Textures/hdrCubeTexture";
-import { Animation } from "../../Animations/animation";
 import { AnimationGroup } from "../../Animations/animationGroup";
 import { Light } from "../../Lights/light";
 import { SceneComponentConstants } from "../../sceneComponent";
@@ -27,6 +26,7 @@ import { MorphTargetManager } from "../../Morph/morphTargetManager";
 import { CannonJSPlugin } from "../../Physics/Plugins/cannonJSPlugin";
 import { OimoJSPlugin } from "../../Physics/Plugins/oimoJSPlugin";
 import { ReflectionProbe } from "../../Probes/reflectionProbe";
+import { _TypeStore } from 'Misc';
 
 /** @hidden */
 export var _BabylonLoaderRegistered = true;
@@ -104,11 +104,14 @@ var loadAssetContainer = (scene: Scene, data: string, rootUrl: string, onError?:
         if (parsedData.animations !== undefined && parsedData.animations !== null) {
             for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
                 var parsedAnimation = parsedData.animations[index];
-                var animation = Animation.Parse(parsedAnimation);
-                scene.animations.push(animation);
-                container.animations.push(animation);
-                log += (index === 0 ? "\n\tAnimations:" : "");
-                log += "\n\t\t" + animation.toString(fullDetails);
+                const internalClass = _TypeStore.GetClass("BABYLON.Animation");
+                if (internalClass) {
+                    let animation = internalClass.Parse(parsedAnimation);
+                    scene.animations.push(animation);
+                    container.animations.push(animation);
+                    log += (index === 0 ? "\n\tAnimations:" : "");
+                    log += "\n\t\t" + animation.toString(fullDetails);
+                }
             }
         }
 
@@ -376,7 +379,7 @@ SceneLoader.RegisterPlugin({
                                         parsedData.geometries[geometryType].forEach((parsedGeometryData: any) => {
                                             if (parsedGeometryData.id === parsedMesh.geometryId) {
                                                 switch (geometryType) {
-                                                       case "vertexData":
+                                                    case "vertexData":
                                                         Geometry.Parse(parsedGeometryData, scene, rootUrl);
                                                         break;
                                                 }