Ver código fonte

Adding hasOwnProperty to StandardMaterialDefines checks

David Catuhe 10 anos atrás
pai
commit
f1bad44bc0

Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
dist/preview release - alpha/babylon.2.2.js


+ 11 - 5
dist/preview release - alpha/babylon.2.2.max.js

@@ -18184,7 +18184,10 @@ var BABYLON;
         }
         StandardMaterialDefines.prototype.isEqual = function (other) {
             for (var prop in this) {
-                if (this[prop] != other[prop]) {
+                if (!this.hasOwnProperty(prop)) {
+                    continue;
+                }
+                if (this[prop] !== other[prop]) {
                     return false;
                 }
             }
@@ -18192,15 +18195,18 @@ var BABYLON;
         };
         StandardMaterialDefines.prototype.cloneTo = function (other) {
             for (var prop in this) {
+                if (!this.hasOwnProperty(prop)) {
+                    continue;
+                }
                 other[prop] = this[prop];
             }
         };
         StandardMaterialDefines.prototype.reset = function () {
             for (var prop in this) {
-                if (typeof this[prop] === "function") {
+                if (!this.hasOwnProperty(prop)) {
                     continue;
                 }
-                if (prop == "BonesPerMesh") {
+                if (prop === "BonesPerMesh") {
                     this[prop] = 0;
                     continue;
                 }
@@ -18210,10 +18216,10 @@ var BABYLON;
         StandardMaterialDefines.prototype.toString = function () {
             var result = "";
             for (var prop in this) {
-                if (typeof this[prop] === "function") {
+                if (!this.hasOwnProperty(prop)) {
                     continue;
                 }
-                if (prop == "BonesPerMesh" && this[prop] > 0) {
+                if (prop === "BonesPerMesh" && this[prop] > 0) {
                     result += "#define BonesPerMesh " + this[prop] + "\n";
                     continue;
                 }

Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
dist/preview release - alpha/babylon.2.2.noworker.js


+ 11 - 5
src/Materials/babylon.standardMaterial.js

@@ -81,7 +81,10 @@ var BABYLON;
         }
         StandardMaterialDefines.prototype.isEqual = function (other) {
             for (var prop in this) {
-                if (this[prop] != other[prop]) {
+                if (!this.hasOwnProperty(prop)) {
+                    continue;
+                }
+                if (this[prop] !== other[prop]) {
                     return false;
                 }
             }
@@ -89,15 +92,18 @@ var BABYLON;
         };
         StandardMaterialDefines.prototype.cloneTo = function (other) {
             for (var prop in this) {
+                if (!this.hasOwnProperty(prop)) {
+                    continue;
+                }
                 other[prop] = this[prop];
             }
         };
         StandardMaterialDefines.prototype.reset = function () {
             for (var prop in this) {
-                if (typeof this[prop] === "function") {
+                if (!this.hasOwnProperty(prop)) {
                     continue;
                 }
-                if (prop == "BonesPerMesh") {
+                if (prop === "BonesPerMesh") {
                     this[prop] = 0;
                     continue;
                 }
@@ -107,10 +113,10 @@ var BABYLON;
         StandardMaterialDefines.prototype.toString = function () {
             var result = "";
             for (var prop in this) {
-                if (typeof this[prop] === "function") {
+                if (!this.hasOwnProperty(prop)) {
                     continue;
                 }
-                if (prop == "BonesPerMesh" && this[prop] > 0) {
+                if (prop === "BonesPerMesh" && this[prop] > 0) {
                     result += "#define BonesPerMesh " + this[prop] + "\n";
                     continue;
                 }

+ 14 - 5
src/Materials/babylon.standardMaterial.ts

@@ -71,7 +71,11 @@
 
         public isEqual(other: StandardMaterialDefines): boolean {
             for (var prop in this) {
-                if (this[prop] != other[prop]) {
+                if (!this.hasOwnProperty(prop)) {
+                    continue;
+                }
+
+                if (this[prop] !== other[prop]) {
                     return false;
                 }
             }
@@ -81,16 +85,21 @@
 
         public cloneTo(other: StandardMaterialDefines): void {
             for (var prop in this) {
+                if (!this.hasOwnProperty(prop)) {
+                    continue;
+                }
+
                 other[prop] = this[prop];
             }
         }
 
         public reset(): void {
             for (var prop in this) {
-                if (typeof this[prop] === "function") {
+                if (!this.hasOwnProperty(prop)) {
                     continue;
                 }
-                if (prop == "BonesPerMesh") {
+
+                if (prop === "BonesPerMesh") {
                     this[prop] = 0;
                     continue;
                 }
@@ -102,11 +111,11 @@
         public toString(): string {
             var result = "";
             for (var prop in this) {
-                if (typeof this[prop] === "function") {
+                if (!this.hasOwnProperty(prop)) {
                     continue;
                 }
 
-                if (prop == "BonesPerMesh" && this[prop] > 0) {
+                if (prop === "BonesPerMesh" && this[prop] > 0) {
                     result += "#define BonesPerMesh " + this[prop] + "\n";
                     continue;
                 }