Pārlūkot izejas kodu

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js

Julian 8 gadi atpakaļ
vecāks
revīzija
972d0ba2e9

+ 2 - 1
canvas2D/src/Engine/babylon.ellipse2d.ts

@@ -203,8 +203,9 @@
             return ((x * x) / (w * w) + (y * y) / (h * h)) <= 1;
         }
 
-        protected updateLevelBoundingInfo() {
+        protected updateLevelBoundingInfo(): boolean {
             BoundingInfo2D.CreateFromSizeToRef(this.actualSize, this._levelBoundingInfo);
+            return true;
         }
 
         /**

+ 2 - 1
canvas2D/src/Engine/babylon.group2d.ts

@@ -340,7 +340,7 @@
             return true;
         }
 
-        protected updateLevelBoundingInfo() {
+        protected updateLevelBoundingInfo(): boolean {
             let size: Size;
 
             // If the size is set by the user, the boundingInfo is computed from this value
@@ -353,6 +353,7 @@
             }
 
             BoundingInfo2D.CreateFromSizeToRef(size, this._levelBoundingInfo);
+            return true;
         }
 
         // Method called only on renderable groups to prepare the rendering

+ 2 - 1
canvas2D/src/Engine/babylon.lines2d.ts

@@ -369,11 +369,12 @@
             return res;
         }
 
-        protected updateLevelBoundingInfo() {
+        protected updateLevelBoundingInfo(): boolean {
             if (!this._boundingMin) {
                 this._computeLines2D();
             }
             BoundingInfo2D.CreateFromMinMaxToRef(this._boundingMin.x, this._boundingMax.x, this._boundingMin.y, this._boundingMax.y, this._levelBoundingInfo);
+            return true;
         }
 
         /**

+ 3 - 0
canvas2D/src/Engine/babylon.prim2dBase.ts

@@ -2565,6 +2565,9 @@
                     this._boundingInfo.clear();
                 } else {
                     this._boundingInfo.copyFrom(this.levelBoundingInfo);
+                    if (this._isFlagSet(SmartPropertyPrim.flagLevelBoundingInfoDirty)) {
+                        return this._boundingInfo;
+                    }
                 }
                 let bi = this._boundingInfo;
 

+ 2 - 1
canvas2D/src/Engine/babylon.rectangle2d.ts

@@ -288,8 +288,9 @@
             return true;
         }
 
-        protected updateLevelBoundingInfo() {
+        protected updateLevelBoundingInfo(): boolean {
             BoundingInfo2D.CreateFromSizeToRef(this.actualSize, this._levelBoundingInfo);
+            return true;
         }
 
         /**

+ 7 - 4
canvas2D/src/Engine/babylon.smartPropertyPrim.ts

@@ -1178,8 +1178,11 @@
          */
         public get levelBoundingInfo(): BoundingInfo2D {
             if (this._isFlagSet(SmartPropertyPrim.flagLevelBoundingInfoDirty)) {
-                this.updateLevelBoundingInfo();
-                this._clearFlags(SmartPropertyPrim.flagLevelBoundingInfoDirty);
+                if (this.updateLevelBoundingInfo()) {
+                    this._clearFlags(SmartPropertyPrim.flagLevelBoundingInfoDirty);
+                } else {
+                    this._levelBoundingInfo.clear();
+                }
             }
             return this._levelBoundingInfo;
         }
@@ -1187,8 +1190,8 @@
         /**
          * This method must be overridden by a given Primitive implementation to compute its boundingInfo
          */
-        protected updateLevelBoundingInfo() {
-
+        protected updateLevelBoundingInfo(): boolean {
+            return false;
         }
 
         /**

+ 2 - 1
canvas2D/src/Engine/babylon.sprite2d.ts

@@ -241,8 +241,9 @@
             this._alignToPixel = value;
         }
 
-        protected updateLevelBoundingInfo() {
+        protected updateLevelBoundingInfo(): boolean {
             BoundingInfo2D.CreateFromSizeToRef(this.size, this._levelBoundingInfo);
+            return true;
         }
 
         /**

+ 4 - 0
canvas2D/src/Engine/babylon.text2d.ts

@@ -296,7 +296,11 @@
         }
 
         protected updateLevelBoundingInfo() {
+            if (!this.owner || !this._text) {
+                return false;
+            }
             BoundingInfo2D.CreateFromSizeToRef(this.actualSize, this._levelBoundingInfo);
+            return true;
         }
 
         /**

+ 7 - 7
dist/preview release/canvas2D/babylon.canvas2d.d.ts

@@ -1152,7 +1152,7 @@ declare module BABYLON {
         /**
          * This method must be overridden by a given Primitive implementation to compute its boundingInfo
          */
-        protected updateLevelBoundingInfo(): void;
+        protected updateLevelBoundingInfo(): boolean;
         /**
          * Property method called when the Primitive becomes dirty
          */
@@ -2642,7 +2642,7 @@ declare module BABYLON {
          */
         trackedNode: Node;
         protected levelIntersect(intersectInfo: IntersectInfo2D): boolean;
-        protected updateLevelBoundingInfo(): void;
+        protected updateLevelBoundingInfo(): boolean;
         protected _prepareGroupRender(context: PrepareRender2DContext): void;
         protected _groupRender(): void;
         _setCacheGroupDirty(): void;
@@ -2732,7 +2732,7 @@ declare module BABYLON {
         private static _i1;
         private static _i2;
         protected levelIntersect(intersectInfo: IntersectInfo2D): boolean;
-        protected updateLevelBoundingInfo(): void;
+        protected updateLevelBoundingInfo(): boolean;
         /**
          * Create an Rectangle 2D Shape primitive. May be a sharp rectangle (with sharp corners), or a rounded one.
          * @param settings a combination of settings, possible ones are
@@ -2850,7 +2850,7 @@ declare module BABYLON {
         actualSize: Size;
         subdivisions: number;
         protected levelIntersect(intersectInfo: IntersectInfo2D): boolean;
-        protected updateLevelBoundingInfo(): void;
+        protected updateLevelBoundingInfo(): boolean;
         /**
          * Create an Ellipse 2D Shape primitive
          * @param settings a combination of settings, possible ones are
@@ -2971,7 +2971,7 @@ declare module BABYLON {
          * Get/set if the sprite rendering should be aligned to the target rendering device pixel or not
          */
         alignToPixel: boolean;
-        protected updateLevelBoundingInfo(): void;
+        protected updateLevelBoundingInfo(): boolean;
         /**
          * Get the animatable array (see http://doc.babylonjs.com/tutorials/Animations)
          */
@@ -3301,7 +3301,7 @@ declare module BABYLON {
          * Dispose the primitive, remove it from its parent
          */
         dispose(): boolean;
-        protected updateLevelBoundingInfo(): void;
+        protected updateLevelBoundingInfo(): boolean;
         /**
          * Create a Text primitive
          * @param text the text to display
@@ -3474,7 +3474,7 @@ declare module BABYLON {
         protected readonly boundingMin: Vector2;
         protected readonly boundingMax: Vector2;
         protected getUsedShaderCategories(dataPart: InstanceDataBase): string[];
-        protected updateLevelBoundingInfo(): void;
+        protected updateLevelBoundingInfo(): boolean;
         /**
          * Create an 2D Lines Shape primitive. The defined lines may be opened or closed (see below)
          * @param points an array that describe the points to use to draw the line, must contain at least two entries.

+ 19 - 2
dist/preview release/canvas2D/babylon.canvas2d.js

@@ -3484,8 +3484,12 @@ var BABYLON;
              */
             get: function () {
                 if (this._isFlagSet(SmartPropertyPrim_1.flagLevelBoundingInfoDirty)) {
-                    this.updateLevelBoundingInfo();
-                    this._clearFlags(SmartPropertyPrim_1.flagLevelBoundingInfoDirty);
+                    if (this.updateLevelBoundingInfo()) {
+                        this._clearFlags(SmartPropertyPrim_1.flagLevelBoundingInfoDirty);
+                    }
+                    else {
+                        this._levelBoundingInfo.clear();
+                    }
                 }
                 return this._levelBoundingInfo;
             },
@@ -3496,6 +3500,7 @@ var BABYLON;
          * This method must be overridden by a given Primitive implementation to compute its boundingInfo
          */
         SmartPropertyPrim.prototype.updateLevelBoundingInfo = function () {
+            return false;
         };
         /**
          * Property method called when the Primitive becomes dirty
@@ -5918,6 +5923,9 @@ var BABYLON;
                     }
                     else {
                         this._boundingInfo.copyFrom(this.levelBoundingInfo);
+                        if (this._isFlagSet(BABYLON.SmartPropertyPrim.flagLevelBoundingInfoDirty)) {
+                            return this._boundingInfo;
+                        }
                     }
                     var bi = this._boundingInfo;
                     var tps = new BABYLON.BoundingInfo2D();
@@ -8944,6 +8952,7 @@ var BABYLON;
                 size = new BABYLON.Size(0, 0);
             }
             BABYLON.BoundingInfo2D.CreateFromSizeToRef(size, this._levelBoundingInfo);
+            return true;
         };
         // Method called only on renderable groups to prepare the rendering
         Group2D.prototype._prepareGroupRender = function (context) {
@@ -9937,6 +9946,7 @@ var BABYLON;
         };
         Rectangle2D.prototype.updateLevelBoundingInfo = function () {
             BABYLON.BoundingInfo2D.CreateFromSizeToRef(this.actualSize, this._levelBoundingInfo);
+            return true;
         };
         Rectangle2D.prototype.createModelRenderCache = function (modelKey) {
             var renderCache = new Rectangle2DRenderCache(this.owner.engine, modelKey);
@@ -10333,6 +10343,7 @@ var BABYLON;
         };
         Ellipse2D.prototype.updateLevelBoundingInfo = function () {
             BABYLON.BoundingInfo2D.CreateFromSizeToRef(this.actualSize, this._levelBoundingInfo);
+            return true;
         };
         Ellipse2D.prototype.createModelRenderCache = function (modelKey) {
             var renderCache = new Ellipse2DRenderCache(this.owner.engine, modelKey);
@@ -10751,6 +10762,7 @@ var BABYLON;
         });
         Sprite2D.prototype.updateLevelBoundingInfo = function () {
             BABYLON.BoundingInfo2D.CreateFromSizeToRef(this.size, this._levelBoundingInfo);
+            return true;
         };
         /**
          * Get the animatable array (see http://doc.babylonjs.com/tutorials/Animations)
@@ -11583,7 +11595,11 @@ var BABYLON;
             return true;
         };
         Text2D.prototype.updateLevelBoundingInfo = function () {
+            if (!this.owner || !this._text) {
+                return false;
+            }
             BABYLON.BoundingInfo2D.CreateFromSizeToRef(this.actualSize, this._levelBoundingInfo);
+            return true;
         };
         Text2D.prototype.levelIntersect = function (intersectInfo) {
             // For now I can't do something better that boundingInfo is a hit, detecting an intersection on a particular letter would be possible, but do we really need it? Not for now...
@@ -12170,6 +12186,7 @@ var BABYLON;
                 this._computeLines2D();
             }
             BABYLON.BoundingInfo2D.CreateFromMinMaxToRef(this._boundingMin.x, this._boundingMax.x, this._boundingMin.y, this._boundingMax.y, this._levelBoundingInfo);
+            return true;
         };
         Lines2D.prototype.createModelRenderCache = function (modelKey) {
             var renderCache = new Lines2DRenderCache(this.owner.engine, modelKey);

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 8 - 8
dist/preview release/canvas2D/babylon.canvas2d.min.js


+ 15 - 8
src/Animations/babylon.animatable.ts

@@ -99,21 +99,24 @@
         }
 
         public stop(animationName?: string): void {
-            var idx = this._scene._activeAnimatables.indexOf(this);
+            
+            if (animationName) {
 
-            if (idx > -1) {
+                var idx = this._scene._activeAnimatables.indexOf(this);
 
-                if(animationName){
+                if (idx > -1) {
 
                     var animations = this._animations;
                     var numberOfAnimationsStopped = 0;
+                    
                     for (var index = animations.length - 1; index >= 0; index--) {
                         if (typeof animationName === "string" && animations[index].name != animationName) {
                             continue;
                         }
+
                         animations[index].reset();
                         animations.splice(index, 1);
-                        numberOfAnimationsStopped ++;
+                        numberOfAnimationsStopped++;
                     }
 
                     if (animations.length == numberOfAnimationsStopped) {
@@ -123,21 +126,25 @@
                             this.onAnimationEnd();
                         }
                     }
+                }
 
-                } else {
+            } else {
 
+                var index = this._scene._activeAnimatables.indexOf(this);
+
+                if (index > -1) {
                     this._scene._activeAnimatables.splice(index, 1);
                     var animations = this._animations;
-
+                    
                     for (var index = 0; index < animations.length; index++) {
                         animations[index].reset();
                     }
-
+                    
                     if (this.onAnimationEnd) {
                         this.onAnimationEnd();
                     }
-
                 }
+
             }
         }