Browse Source

Adding ShaderMaterial.setVector4
Adding more debug info for importMesh

David catuhe 10 năm trước cách đây
mục cha
commit
1f3b216f2e

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 468 - 465
dist/preview release - alpha/babylon.2.2.d.ts


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 12 - 11
dist/preview release - alpha/babylon.2.2.js


+ 19 - 2
dist/preview release - alpha/babylon.2.2.max.js

@@ -18349,6 +18349,13 @@ var BABYLON;
             this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
             return this;
         };
+        Effect.prototype.setVector4 = function (uniformName, vector4) {
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === vector4.x && this._valueCache[uniformName][1] === vector4.y && this._valueCache[uniformName][2] === vector4.z && this._valueCache[uniformName][3] === vector4.w)
+                return this;
+            this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w);
+            this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
+            return this;
+        };
         Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
             if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === x && this._valueCache[uniformName][1] === y && this._valueCache[uniformName][2] === z && this._valueCache[uniformName][3] === w)
                 return this;
@@ -19393,7 +19400,7 @@ var BABYLON;
                     try {
                         if (!plugin.importMesh(meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons)) {
                             if (onerror) {
-                                onerror(scene, 'unable to load the scene');
+                                onerror(scene, 'Unable to import meshes from ' + rootUrl + sceneFilename);
                             }
                             scene._removePendingData(loadingToken);
                             return;
@@ -19401,7 +19408,7 @@ var BABYLON;
                     }
                     catch (e) {
                         if (onerror) {
-                            onerror(scene, e);
+                            onerror(scene, 'Unable to import meshes from ' + rootUrl + sceneFilename + ' (Exception: ' + e + ')');
                         }
                         scene._removePendingData(loadingToken);
                         return;
@@ -25706,6 +25713,7 @@ var BABYLON;
             this._colors4 = new Array();
             this._vectors2 = new Array();
             this._vectors3 = new Array();
+            this._vectors4 = new Array();
             this._matrices = new Array();
             this._cachedWorldViewMatrix = new BABYLON.Matrix();
             this._shaderPath = shaderPath;
@@ -25764,6 +25772,11 @@ var BABYLON;
             this._vectors3[name] = value;
             return this;
         };
+        ShaderMaterial.prototype.setVector4 = function (name, value) {
+            this._checkUniform(name);
+            this._vectors4[name] = value;
+            return this;
+        };
         ShaderMaterial.prototype.setMatrix = function (name, value) {
             this._checkUniform(name);
             this._matrices[name] = value;
@@ -25865,6 +25878,10 @@ var BABYLON;
                 for (name in this._vectors3) {
                     this._effect.setVector3(name, this._vectors3[name]);
                 }
+                // Vector4        
+                for (name in this._vectors4) {
+                    this._effect.setVector4(name, this._vectors4[name]);
+                }
                 // Matrix      
                 for (name in this._matrices) {
                     this._effect.setMatrix(name, this._matrices[name]);

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 12 - 11
dist/preview release - alpha/babylon.2.2.noworker.js


+ 2 - 2
src/Loading/babylon.sceneLoader.js

@@ -60,7 +60,7 @@ var BABYLON;
                     try {
                         if (!plugin.importMesh(meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons)) {
                             if (onerror) {
-                                onerror(scene, 'unable to load the scene');
+                                onerror(scene, 'Unable to import meshes from ' + rootUrl + sceneFilename);
                             }
                             scene._removePendingData(loadingToken);
                             return;
@@ -68,7 +68,7 @@ var BABYLON;
                     }
                     catch (e) {
                         if (onerror) {
-                            onerror(scene, e);
+                            onerror(scene, 'Unable to import meshes from ' + rootUrl + sceneFilename + ' (Exception: ' + e + ')');
                         }
                         scene._removePendingData(loadingToken);
                         return;

+ 2 - 2
src/Loading/babylon.sceneLoader.ts

@@ -79,14 +79,14 @@
                     try {
                         if (!plugin.importMesh(meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons)) {
                             if (onerror) {
-                                onerror(scene, 'unable to load the scene');
+                                onerror(scene, 'Unable to import meshes from ' + rootUrl + sceneFilename);
                             }
                             scene._removePendingData(loadingToken);
                             return;
                         }
                     } catch (e) {
                         if (onerror) {
-                            onerror(scene, e);
+                            onerror(scene, 'Unable to import meshes from ' + rootUrl + sceneFilename + ' (Exception: ' + e + ')');
                         }
                         scene._removePendingData(loadingToken);
                         return;

+ 7 - 0
src/Materials/babylon.effect.js

@@ -329,6 +329,13 @@ var BABYLON;
             this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
             return this;
         };
+        Effect.prototype.setVector4 = function (uniformName, vector4) {
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === vector4.x && this._valueCache[uniformName][1] === vector4.y && this._valueCache[uniformName][2] === vector4.z && this._valueCache[uniformName][3] === vector4.w)
+                return this;
+            this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w);
+            this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
+            return this;
+        };
         Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
             if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === x && this._valueCache[uniformName][1] === y && this._valueCache[uniformName][2] === z && this._valueCache[uniformName][3] === w)
                 return this;

+ 11 - 0
src/Materials/babylon.effect.ts

@@ -424,6 +424,17 @@
             return this;
         }
 
+        public setVector4(uniformName: string, vector4: Vector4): Effect {
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === vector4.x && this._valueCache[uniformName][1] === vector4.y && this._valueCache[uniformName][2] === vector4.z && this._valueCache[uniformName][3] === vector4.w)
+                return this;
+
+            this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w);
+
+            this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
+
+            return this;
+        }
+
         public setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect {
             if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === x && this._valueCache[uniformName][1] === y && this._valueCache[uniformName][2] === z && this._valueCache[uniformName][3] === w)
                 return this;

+ 10 - 0
src/Materials/babylon.shaderMaterial.js

@@ -17,6 +17,7 @@ var BABYLON;
             this._colors4 = new Array();
             this._vectors2 = new Array();
             this._vectors3 = new Array();
+            this._vectors4 = new Array();
             this._matrices = new Array();
             this._cachedWorldViewMatrix = new BABYLON.Matrix();
             this._shaderPath = shaderPath;
@@ -75,6 +76,11 @@ var BABYLON;
             this._vectors3[name] = value;
             return this;
         };
+        ShaderMaterial.prototype.setVector4 = function (name, value) {
+            this._checkUniform(name);
+            this._vectors4[name] = value;
+            return this;
+        };
         ShaderMaterial.prototype.setMatrix = function (name, value) {
             this._checkUniform(name);
             this._matrices[name] = value;
@@ -176,6 +182,10 @@ var BABYLON;
                 for (name in this._vectors3) {
                     this._effect.setVector3(name, this._vectors3[name]);
                 }
+                // Vector4        
+                for (name in this._vectors4) {
+                    this._effect.setVector4(name, this._vectors4[name]);
+                }
                 // Matrix      
                 for (name in this._matrices) {
                     this._effect.setMatrix(name, this._matrices[name]);

+ 13 - 0
src/Materials/babylon.shaderMaterial.ts

@@ -9,6 +9,7 @@
         private _colors4 = new Array<Color4>();
         private _vectors2 = new Array<Vector2>();
         private _vectors3 = new Array<Vector3>();
+        private _vectors4 = new Array<Vector4>();
         private _matrices = new Array<Matrix>();
         private _cachedWorldViewMatrix = new Matrix();
         private _renderId: number;
@@ -91,6 +92,13 @@
             return this;
         }
 
+        public setVector4(name: string, value: Vector4): ShaderMaterial {
+            this._checkUniform(name);
+            this._vectors4[name] = value;
+
+            return this;
+        }
+
         public setMatrix(name: string, value: Matrix): ShaderMaterial {
             this._checkUniform(name);
             this._matrices[name] = value;
@@ -225,6 +233,11 @@
                     this._effect.setVector3(name, this._vectors3[name]);
                 }
 
+                // Vector4        
+                for (name in this._vectors4) {
+                    this._effect.setVector4(name, this._vectors4[name]);
+                }
+
                 // Matrix      
                 for (name in this._matrices) {
                     this._effect.setMatrix(name, this._matrices[name]);