Browse Source

Merge pull request #1396 from vousk/patch_arrayIteration

Patch array iteration
David Catuhe 9 years ago
parent
commit
786b0c85b2
3 changed files with 36 additions and 34 deletions
  1. 2 2
      src/Mesh/babylon.mesh.ts
  2. 31 29
      src/Tools/babylon.andOrNotEvaluator.ts
  3. 3 3
      src/Tools/babylon.tags.ts

+ 2 - 2
src/Mesh/babylon.mesh.ts

@@ -439,9 +439,9 @@
             if (!this._geometry) {
                 var result = [];
                 if (this._delayInfo) {
-                    for (var kind in this._delayInfo) {
+                    this._delayInfo.forEach( function(kind, index, array) {
                         result.push(kind);
-                    }
+                    });
                 }
                 return result;
             }

+ 31 - 29
src/Tools/babylon.andOrNotEvaluator.ts

@@ -32,48 +32,50 @@
             var or = parenthesisContent.split("||");
 
             for (var i in or) {
-                var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
-                var and = ori.split("&&");
+                if (or.hasOwnProperty(i)) {
+                    var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
+                    var and = ori.split("&&");
 
-                if (and.length > 1) {
-                    for (var j = 0; j < and.length; ++j) {
-                        var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
-                        if (andj !== "true" && andj !== "false") {
-                            if (andj[0] === "!") {
-                                result = !evaluateCallback(andj.substring(1));
+                    if (and.length > 1) {
+                        for (var j = 0; j < and.length; ++j) {
+                            var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
+                            if (andj !== "true" && andj !== "false") {
+                                if (andj[0] === "!") {
+                                    result = !evaluateCallback(andj.substring(1));
+                                }
+                                else {
+                                    result = evaluateCallback(andj);
+                                }
                             }
                             else {
-                                result = evaluateCallback(andj);
+                                result = andj === "true" ? true : false;
+                            }
+                            if (!result) { // no need to continue since 'false && ... && ...' will always return false
+                                ori = "false";
+                                break;
                             }
-                        }
-                        else {
-                            result = andj === "true" ? true : false;
-                        }
-                        if (!result) { // no need to continue since 'false && ... && ...' will always return false
-                            ori = "false";
-                            break;
                         }
                     }
-                }
 
-                if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
-                    result = true;
-                    break;
-                }
+                    if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
+                        result = true;
+                        break;
+                    }
 
-                // result equals false (or undefined)
+                    // result equals false (or undefined)
 
-                if (ori !== "true" && ori !== "false") {
-                    if (ori[0] === "!") {
-                        result = !evaluateCallback(ori.substring(1));
+                    if (ori !== "true" && ori !== "false") {
+                        if (ori[0] === "!") {
+                            result = !evaluateCallback(ori.substring(1));
+                        }
+                        else {
+                            result = evaluateCallback(ori);
+                        }
                     }
                     else {
-                        result = evaluateCallback(ori);
+                        result = ori === "true" ? true : false;
                     }
                 }
-                else {
-                    result = ori === "true" ? true : false;
-                }
             }
 
             // the whole parenthesis scope is replaced by 'true' or 'false'

+ 3 - 3
src/Tools/babylon.tags.ts

@@ -66,9 +66,9 @@
             }
 
             var tags = tagsString.split(" ");
-            for (var t in tags) {
-                Tags._AddTagTo(obj, tags[t]);
-            }
+            tags.forEach( function(tag, index, array) {
+                Tags._AddTagTo(obj, tag);
+            });
         }
 
         public static _AddTagTo(obj: any, tag: string): void {