Sfoglia il codice sorgente

Adding api comment for Animatable

David Catuhe 7 anni fa
parent
commit
a561520854

File diff suppressed because it is too large
+ 9083 - 9000
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/babylon.js


+ 23 - 8
dist/preview release/babylon.max.js

@@ -51471,6 +51471,9 @@ var BABYLON;
 
 var BABYLON;
 (function (BABYLON) {
+    /**
+     * Class used to store an actual running animation
+     */
     var Animatable = /** @class */ (function () {
         function Animatable(scene, target, fromFrame, toFrame, loopAnimation, speedRatio, onAnimationEnd, animations) {
             if (fromFrame === void 0) { fromFrame = 0; }
@@ -51488,6 +51491,14 @@ var BABYLON;
             this._paused = false;
             this._speedRatio = 1;
             this._weight = -1.0;
+            /**
+             * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
+             * This will only apply for non looping animation (default is true)
+             */
+            this.disposeOnEnd = true;
+            /**
+             * Gets a boolean indicating if the animation has started
+             */
             this.animationStarted = false;
             /**
              * Observer raised when the animation ends
@@ -51730,16 +51741,20 @@ var BABYLON;
             }
             this.animationStarted = running;
             if (!running) {
-                // Remove from active animatables
-                index = this._scene._activeAnimatables.indexOf(this);
-                this._scene._activeAnimatables.splice(index, 1);
-                // Dispose all runtime animations
-                for (index = 0; index < runtimeAnimations.length; index++) {
-                    runtimeAnimations[index].dispose();
+                if (this.disposeOnEnd) {
+                    // Remove from active animatables
+                    index = this._scene._activeAnimatables.indexOf(this);
+                    this._scene._activeAnimatables.splice(index, 1);
+                    // Dispose all runtime animations
+                    for (index = 0; index < runtimeAnimations.length; index++) {
+                        runtimeAnimations[index].dispose();
+                    }
                 }
                 this._raiseOnAnimationEnd();
-                this.onAnimationEnd = null;
-                this.onAnimationEndObservable.clear();
+                if (this.disposeOnEnd) {
+                    this.onAnimationEnd = null;
+                    this.onAnimationEndObservable.clear();
+                }
             }
             return running;
         };

+ 23 - 8
dist/preview release/babylon.no-module.max.js

@@ -51438,6 +51438,9 @@ var BABYLON;
 
 var BABYLON;
 (function (BABYLON) {
+    /**
+     * Class used to store an actual running animation
+     */
     var Animatable = /** @class */ (function () {
         function Animatable(scene, target, fromFrame, toFrame, loopAnimation, speedRatio, onAnimationEnd, animations) {
             if (fromFrame === void 0) { fromFrame = 0; }
@@ -51455,6 +51458,14 @@ var BABYLON;
             this._paused = false;
             this._speedRatio = 1;
             this._weight = -1.0;
+            /**
+             * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
+             * This will only apply for non looping animation (default is true)
+             */
+            this.disposeOnEnd = true;
+            /**
+             * Gets a boolean indicating if the animation has started
+             */
             this.animationStarted = false;
             /**
              * Observer raised when the animation ends
@@ -51697,16 +51708,20 @@ var BABYLON;
             }
             this.animationStarted = running;
             if (!running) {
-                // Remove from active animatables
-                index = this._scene._activeAnimatables.indexOf(this);
-                this._scene._activeAnimatables.splice(index, 1);
-                // Dispose all runtime animations
-                for (index = 0; index < runtimeAnimations.length; index++) {
-                    runtimeAnimations[index].dispose();
+                if (this.disposeOnEnd) {
+                    // Remove from active animatables
+                    index = this._scene._activeAnimatables.indexOf(this);
+                    this._scene._activeAnimatables.splice(index, 1);
+                    // Dispose all runtime animations
+                    for (index = 0; index < runtimeAnimations.length; index++) {
+                        runtimeAnimations[index].dispose();
+                    }
                 }
                 this._raiseOnAnimationEnd();
-                this.onAnimationEnd = null;
-                this.onAnimationEndObservable.clear();
+                if (this.disposeOnEnd) {
+                    this.onAnimationEnd = null;
+                    this.onAnimationEndObservable.clear();
+                }
             }
             return running;
         };

File diff suppressed because it is too large
+ 1 - 1
dist/preview release/babylon.worker.js


+ 23 - 8
dist/preview release/es6.js

@@ -51438,6 +51438,9 @@ var BABYLON;
 
 var BABYLON;
 (function (BABYLON) {
+    /**
+     * Class used to store an actual running animation
+     */
     var Animatable = /** @class */ (function () {
         function Animatable(scene, target, fromFrame, toFrame, loopAnimation, speedRatio, onAnimationEnd, animations) {
             if (fromFrame === void 0) { fromFrame = 0; }
@@ -51455,6 +51458,14 @@ var BABYLON;
             this._paused = false;
             this._speedRatio = 1;
             this._weight = -1.0;
+            /**
+             * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
+             * This will only apply for non looping animation (default is true)
+             */
+            this.disposeOnEnd = true;
+            /**
+             * Gets a boolean indicating if the animation has started
+             */
             this.animationStarted = false;
             /**
              * Observer raised when the animation ends
@@ -51697,16 +51708,20 @@ var BABYLON;
             }
             this.animationStarted = running;
             if (!running) {
-                // Remove from active animatables
-                index = this._scene._activeAnimatables.indexOf(this);
-                this._scene._activeAnimatables.splice(index, 1);
-                // Dispose all runtime animations
-                for (index = 0; index < runtimeAnimations.length; index++) {
-                    runtimeAnimations[index].dispose();
+                if (this.disposeOnEnd) {
+                    // Remove from active animatables
+                    index = this._scene._activeAnimatables.indexOf(this);
+                    this._scene._activeAnimatables.splice(index, 1);
+                    // Dispose all runtime animations
+                    for (index = 0; index < runtimeAnimations.length; index++) {
+                        runtimeAnimations[index].dispose();
+                    }
                 }
                 this._raiseOnAnimationEnd();
-                this.onAnimationEnd = null;
-                this.onAnimationEndObservable.clear();
+                if (this.disposeOnEnd) {
+                    this.onAnimationEnd = null;
+                    this.onAnimationEndObservable.clear();
+                }
             }
             return running;
         };

File diff suppressed because it is too large
+ 4 - 4
dist/preview release/gui/babylon.gui.js


File diff suppressed because it is too large
+ 5 - 5
dist/preview release/gui/babylon.gui.min.js


+ 0 - 192
dist/preview release/typedocValidationBaseline.json

@@ -63,198 +63,6 @@
         }
       }
     },
-    "Animatable": {
-      "Class": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Constructor": {
-        "new Animatable": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "scene": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "target": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "fromFrame": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "toFrame": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "loopAnimation": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "speedRatio": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "onAnimationEnd": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "animations": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      },
-      "Property": {
-        "animationStarted": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "fromFrame": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "loopAnimation": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onAnimationEnd": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "target": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "toFrame": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      },
-      "Method": {
-        "appendAnimations": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "target": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "animations": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "disableBlending": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "enableBlending": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "blendingSpeed": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "getAnimationByTargetProperty": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "property": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "getAnimations": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "getRuntimeAnimationByTargetProperty": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "property": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "goToFrame": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "frame": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "pause": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "reset": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "restart": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "stop": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "animationName": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      }
-    },
     "AnimationGroup": {
       "Constructor": {
         "new AnimationGroup": {

File diff suppressed because it is too large
+ 1 - 1
dist/preview release/viewer/babylon.viewer.js


+ 23 - 8
dist/preview release/viewer/babylon.viewer.max.js

@@ -51559,6 +51559,9 @@ var BABYLON;
 
 var BABYLON;
 (function (BABYLON) {
+    /**
+     * Class used to store an actual running animation
+     */
     var Animatable = /** @class */ (function () {
         function Animatable(scene, target, fromFrame, toFrame, loopAnimation, speedRatio, onAnimationEnd, animations) {
             if (fromFrame === void 0) { fromFrame = 0; }
@@ -51576,6 +51579,14 @@ var BABYLON;
             this._paused = false;
             this._speedRatio = 1;
             this._weight = -1.0;
+            /**
+             * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
+             * This will only apply for non looping animation (default is true)
+             */
+            this.disposeOnEnd = true;
+            /**
+             * Gets a boolean indicating if the animation has started
+             */
             this.animationStarted = false;
             /**
              * Observer raised when the animation ends
@@ -51818,16 +51829,20 @@ var BABYLON;
             }
             this.animationStarted = running;
             if (!running) {
-                // Remove from active animatables
-                index = this._scene._activeAnimatables.indexOf(this);
-                this._scene._activeAnimatables.splice(index, 1);
-                // Dispose all runtime animations
-                for (index = 0; index < runtimeAnimations.length; index++) {
-                    runtimeAnimations[index].dispose();
+                if (this.disposeOnEnd) {
+                    // Remove from active animatables
+                    index = this._scene._activeAnimatables.indexOf(this);
+                    this._scene._activeAnimatables.splice(index, 1);
+                    // Dispose all runtime animations
+                    for (index = 0; index < runtimeAnimations.length; index++) {
+                        runtimeAnimations[index].dispose();
+                    }
                 }
                 this._raiseOnAnimationEnd();
-                this.onAnimationEnd = null;
-                this.onAnimationEndObservable.clear();
+                if (this.disposeOnEnd) {
+                    this.onAnimationEnd = null;
+                    this.onAnimationEndObservable.clear();
+                }
             }
             return running;
         };

+ 94 - 9
src/Animations/babylon.animatable.ts

@@ -1,4 +1,7 @@
 module BABYLON {
+    /**
+     * Class used to store an actual running animation
+     */
     export class Animatable {
         private _localDelayOffset: Nullable<number> = null;
         private _pausedDelay: Nullable<number> = null;
@@ -9,6 +12,15 @@
         private _weight = -1.0;
         private _syncRoot: Animatable;
 
+        /**
+         * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
+         * This will only apply for non looping animation (default is true)
+         */
+        public disposeOnEnd = true;
+
+        /**
+         * Gets a boolean indicating if the animation has started
+         */
         public animationStarted = false;
 
         /**
@@ -69,7 +81,30 @@
         }
 
 
-        constructor(scene: Scene, public target: any, public fromFrame: number = 0, public toFrame: number = 100, public loopAnimation: boolean = false, speedRatio: number = 1.0, public onAnimationEnd?: Nullable<() => void>, animations?: any) {
+        /**
+         * Creates a new Animatable
+         * @param scene defines the hosting scene
+         * @param target defines the target object
+         * @param fromFrame defines the starting frame number (default is 0)
+         * @param toFrame defines the ending frame number (default is 100)
+         * @param loopAnimation defines if the animation must loop (default is false)
+         * @param speedRatio defines the factor to apply to animation speed (default is 1)
+         * @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
+         */
+        constructor(scene: Scene, 
+            /** defines the target object */
+            public target: any, 
+            /** defines the starting frame number (default is 0) */
+            public fromFrame: number = 0, 
+            /** defines the ending frame number (default is 100) */
+            public toFrame: number = 100, 
+            /** defines if the animation must loop (default is false)  */
+            public loopAnimation: boolean = false, 
+            speedRatio: number = 1.0, 
+            /** defines a callback to call when animation ends if it is not looping */
+            public onAnimationEnd?: Nullable<() => void>, 
+            animations?: Animation[]) {
             this._scene = scene;
             if (animations) {
                 this.appendAnimations(target, animations);
@@ -101,10 +136,19 @@
             return this;
         }
 
+        /**
+         * Gets the list of runtime animations
+         * @returns an array of RuntimeAnimation
+         */
         public getAnimations(): RuntimeAnimation[] {
             return this._runtimeAnimations;
         }
 
+        /**
+         * Adds more animations to the current animatable
+         * @param target defines the target of the animations
+         * @param animations defines the new animations to add
+         */
         public appendAnimations(target: any, animations: Animation[]): void {
             for (var index = 0; index < animations.length; index++) {
                 var animation = animations[index];
@@ -113,6 +157,11 @@
             }
         }
 
+        /**
+         * Gets the source animation for a specific property
+         * @param property defines the propertyu to look for
+         * @returns null or the source animation for the given property
+         */
         public getAnimationByTargetProperty(property: string): Nullable<Animation> {
             var runtimeAnimations = this._runtimeAnimations;
 
@@ -125,6 +174,11 @@
             return null;
         }
 
+        /**
+         * Gets the runtime animation for a specific property
+         * @param property defines the propertyu to look for
+         * @returns null or the runtime animation for the given property
+         */
         public getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation> {
             var runtimeAnimations = this._runtimeAnimations;
 
@@ -137,6 +191,9 @@
             return null;
         }
 
+        /**
+         * Resets the animatable to its original state
+         */
         public reset(): void {
             var runtimeAnimations = this._runtimeAnimations;
 
@@ -148,6 +205,11 @@
             this._pausedDelay = null;
         }
 
+        /**
+         * Allows the animatable to blend with current running animations
+         * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
+         * @param blendingSpeed defines the blending speed to use
+         */
         public enableBlending(blendingSpeed: number): void {
             var runtimeAnimations = this._runtimeAnimations;
 
@@ -157,6 +219,10 @@
             }
         }
 
+        /**
+         * Disable animation blending
+         * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
+         */
         public disableBlending(): void {
             var runtimeAnimations = this._runtimeAnimations;
 
@@ -165,6 +231,10 @@
             }
         }
 
+        /**
+         * Jump directly to a given frame
+         * @param frame defines the frame to jump to
+         */
         public goToFrame(frame: number): void {
             var runtimeAnimations = this._runtimeAnimations;
 
@@ -184,6 +254,9 @@
             }
         }
 
+        /**
+         * Pause the animation
+         */
         public pause(): void {
             if (this._paused) {
                 return;
@@ -191,6 +264,9 @@
             this._paused = true;
         }
 
+        /**
+         * Restart the animation
+         */
         public restart(): void {
             this._paused = false;
         }
@@ -203,6 +279,10 @@
             this.onAnimationEndObservable.notifyObservers(this);
         }
 
+        /**
+         * Stop and delete the current animation
+         * @param animationName defines a string used to only stop some of the runtime animations instead of all
+         */
         public stop(animationName?: string): void {
             if (animationName) {
                 var idx = this._scene._activeAnimatables.indexOf(this);
@@ -291,18 +371,23 @@
             this.animationStarted = running;
 
             if (!running) {
-                // Remove from active animatables
-                index = this._scene._activeAnimatables.indexOf(this);
-                this._scene._activeAnimatables.splice(index, 1);
+                if (this.disposeOnEnd) {
+                    // Remove from active animatables
+                    index = this._scene._activeAnimatables.indexOf(this);
+                    this._scene._activeAnimatables.splice(index, 1);
 
-                // Dispose all runtime animations
-                for (index = 0; index < runtimeAnimations.length; index++) {
-                    runtimeAnimations[index].dispose();
+                    // Dispose all runtime animations
+                    for (index = 0; index < runtimeAnimations.length; index++) {
+                        runtimeAnimations[index].dispose();
+                    }
                 }
 
                 this._raiseOnAnimationEnd();
-                this.onAnimationEnd = null
-                this.onAnimationEndObservable.clear();
+
+                if (this.disposeOnEnd) {
+                    this.onAnimationEnd = null
+                    this.onAnimationEndObservable.clear();
+                }
             }
 
             return running;