Просмотр исходного кода

Fix #519
New MultiMaterial.clone() function

David Catuhe 10 лет назад
Родитель
Сommit
1a540cff92

+ 8 - 0
Babylon/Materials/babylon.multiMaterial.js

@@ -32,6 +32,14 @@ var BABYLON;
             }
             return true;
         };
+        MultiMaterial.prototype.clone = function (name) {
+            var newMultiMaterial = new MultiMaterial(name, this.getScene());
+            for (var index = 0; index < this.subMaterials.length; index++) {
+                var subMaterial = this.subMaterials[index];
+                newMultiMaterial.subMaterials.push(subMaterial);
+            }
+            return newMultiMaterial;
+        };
         return MultiMaterial;
     })(BABYLON.Material);
     BABYLON.MultiMaterial = MultiMaterial;

+ 12 - 0
Babylon/Materials/babylon.multiMaterial.ts

@@ -30,5 +30,17 @@
 
             return true;
         }
+
+
+        public clone(name: string): MultiMaterial {
+            var newMultiMaterial = new MultiMaterial(name, this.getScene());
+
+            for (var index = 0; index < this.subMaterials.length; index++) {
+                var subMaterial = this.subMaterials[index];
+                newMultiMaterial.subMaterials.push(subMaterial);
+            }
+
+            return newMultiMaterial;
+        }
     }
 } 

+ 4 - 4
Babylon/Math/babylon.math.js

@@ -2713,11 +2713,11 @@ var BABYLON;
             var normal0;
             if (va === undefined || va === null) {
                 var point;
-                if (vt.x !== 1) {
-                    point = new Vector3(1, 0, 0);
+                if (vt.y !== 1) {
+                    point = new Vector3(0, -1, 0);
                 }
-                else if (vt.y !== 1) {
-                    point = new Vector3(0, 1, 0);
+                else if (vt.x !== 1) {
+                    point = new Vector3(1, 0, 0);
                 }
                 else if (vt.z !== 1) {
                     point = new Vector3(0, 0, 1);

+ 3 - 2
Babylon/babylon.engine.js

@@ -970,11 +970,12 @@ var BABYLON;
             this._drawCalls++;
             // Render
             var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
+            var mult = this._uintIndicesCurrentlySet ? 4 : 2;
             if (instancesCount) {
-                this._caps.instancedArrays.drawElementsInstancedANGLE(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, indexFormat, indexStart * 2, instancesCount);
+                this._caps.instancedArrays.drawElementsInstancedANGLE(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, indexFormat, indexStart * mult, instancesCount);
                 return;
             }
-            this._gl.drawElements(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, indexFormat, indexStart * 2);
+            this._gl.drawElements(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, indexFormat, indexStart * mult);
         };
         Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
             // Apply states

+ 3 - 2
Babylon/babylon.engine.ts

@@ -1148,12 +1148,13 @@
             this._drawCalls++;
             // Render
             var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
+            var mult = this._uintIndicesCurrentlySet ? 4 : 2;
             if (instancesCount) {
-                this._caps.instancedArrays.drawElementsInstancedANGLE(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, indexFormat, indexStart * 2, instancesCount);
+                this._caps.instancedArrays.drawElementsInstancedANGLE(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, indexFormat, indexStart * mult, instancesCount);
                 return;
             }
 
-            this._gl.drawElements(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, indexFormat, indexStart * 2);
+            this._gl.drawElements(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, indexFormat, indexStart * mult);
         }
 
         public drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void {

Разница между файлами не показана из-за своего большого размера
+ 16 - 7
babylon.2.1-beta.debug.js


Разница между файлами не показана из-за своего большого размера
+ 15 - 13
babylon.2.1-beta.js


Разница между файлами не показана из-за своего большого размера
+ 20 - 18
babylon.2.1-beta.noworker.js


+ 1 - 0
what's new - 2.1 - proposal.md

@@ -13,6 +13,7 @@
  - New Loaders folder with a first additionnal plugin: [STL](http://doc.babylonjs.com/page.php?p=25109)  ([raananw](http://www.github.com/raananw), [deltakosh](http://www.github.com/deltakosh))
  - Gulp building process revamped, updated and simplified and now includes a config.json ([raananw](http://www.github.com/raananw)) 
  - **Updates**
+ - New ```MultiMaterial.clone()``` function ([deltakosh](http://www.github.com/deltakosh))
  - Faster ```mesh.computeNormals()``` function ([jbousquie](https://github.com/jbousquie))
  - Added the ability [to dynamically update or to morph](http://doc.babylonjs.com/page.php?p=25096) an mesh instance ([jbousquie](https://github.com/jbousquie))
  - Allow static Mesh.MergeMeshes to work with clones & Mesh subclasses ([Palmer-JC](http://www.github.com/Palmer-JC))