sebavan 6 سال پیش
والد
کامیت
3df7b3de33
1فایلهای تغییر یافته به همراه12 افزوده شده و 3 حذف شده
  1. 12 3
      src/Animations/animatable.ts

+ 12 - 3
src/Animations/animatable.ts

@@ -561,7 +561,13 @@ declare module "../scene" {
 }
 
 Scene.prototype._animate = function(): void {
-    if (!this.animationsEnabled || this._activeAnimatables.length === 0) {
+    if (!this.animationsEnabled) {
+        return;
+    }
+
+    const animatables = this._activeAnimatables;
+    const animatablesLength = animatables.length;
+    if (animatablesLength === 0) {
         return;
     }
 
@@ -573,11 +579,14 @@ Scene.prototype._animate = function(): void {
         }
         this._animationTimeLast = now;
     }
+
     var deltaTime = this.useConstantAnimationDeltaTime ? 16.0 : (now - this._animationTimeLast) * this.animationTimeScale;
     this._animationTime += deltaTime;
+    const animationTime = this._animationTime;
     this._animationTimeLast = now;
-    for (var index = 0; index < this._activeAnimatables.length; index++) {
-        this._activeAnimatables[index]._animate(this._animationTime);
+
+    for (let index = 0; index < animatablesLength; index++) {
+        animatables[index]._animate(animationTime);
     }
 
     // Late animation bindings