Преглед изворни кода

Merge pull request #2 from BabylonJS/master

update from bjs
KK пре 9 година
родитељ
комит
c4882e0115

Разлика између датотеке није приказан због своје велике величине
+ 7 - 7
dist/preview release/babylon.core.js


Разлика између датотеке није приказан због своје велике величине
+ 971 - 968
dist/preview release/babylon.d.ts


Разлика између датотеке није приказан због своје велике величине
+ 19 - 19
dist/preview release/babylon.js


Разлика између датотеке није приказан због своје велике величине
+ 147 - 29
dist/preview release/babylon.max.js


Разлика између датотеке није приказан због своје велике величине
+ 21 - 21
dist/preview release/babylon.noworker.js


+ 1 - 0
dist/preview release/what's new.md

@@ -18,6 +18,7 @@
     - New `Mesh.CreateIcoSphere()` method. [Demo here](http://www.babylonjs-playground.com/#24DUYD) (G'kar)
     - New `Mesh.CreateIcoSphere()` method. [Demo here](http://www.babylonjs-playground.com/#24DUYD) (G'kar)
     - Introducing [babylon.core.js](http://doc.babylonjs.com/generals/Framework_versions) ([deltakosh](https://github.com/deltakosh))
     - Introducing [babylon.core.js](http://doc.babylonjs.com/generals/Framework_versions) ([deltakosh](https://github.com/deltakosh))
   - **Updates**
   - **Updates**
+	- Unity3D exporter will recognise instances of prefabs ([ozRocker](https://github.com/punkoffice))
     - New parse mechanism (for loading .babylon file) ([deltakosh](https://github.com/deltakosh))   
     - New parse mechanism (for loading .babylon file) ([deltakosh](https://github.com/deltakosh))   
     - New button to log the camera position in the debug layer ([temechon](https://github.com/temechon))
     - New button to log the camera position in the debug layer ([temechon](https://github.com/temechon))
     - Added `Animatable.goToFrame()` ([deltakosh](https://github.com/deltakosh))   
     - Added `Animatable.goToFrame()` ([deltakosh](https://github.com/deltakosh))   

+ 14 - 0
materialsLibrary/test/add/addfire.js

@@ -0,0 +1,14 @@
+window.prepareFire = function() {
+    var fire = new BABYLON.FireMaterial("fire", scene);
+    fire.diffuseTexture = new BABYLON.Texture("textures/fire/diffuse.png", scene);
+    fire.distortionTexture = new BABYLON.Texture("textures/fire/distortion.png", scene);
+    fire.opacityTexture = new BABYLON.Texture("textures/fire/opacity.png", scene);
+    
+    registerRangeUI("fire", "speed", 0, 20, function(value) {
+		fire.speed = value;
+	}, function() {
+		return fire.speed;
+	});
+    
+    return fire;
+};

+ 19 - 0
materialsLibrary/test/add/addterrain.js

@@ -0,0 +1,19 @@
+window.prepareTerrain = function() {
+    var terrain = new BABYLON.TerrainMaterial("terrain", scene);
+    terrain.specularColor = new BABYLON.Color3(0.5, 0.5, 0.5);
+    terrain.specularPower = 64;
+    terrain.mixTexture = new BABYLON.Texture("textures/mixMap.png", scene);
+    terrain.diffuseTexture1 = new BABYLON.Texture("textures/floor.png", scene);
+    terrain.diffuseTexture2 = new BABYLON.Texture("textures/rock.png", scene);
+    terrain.diffuseTexture3 = new BABYLON.Texture("textures/grass.png", scene);
+    
+    terrain.bumpTexture1 = new BABYLON.Texture("textures/floor_bump.png", scene);
+    terrain.bumpTexture2 = new BABYLON.Texture("textures/rockn.png", scene);
+    terrain.bumpTexture3 = new BABYLON.Texture("textures/grassn.png", scene);
+    
+    terrain.diffuseTexture1.uScale = terrain.diffuseTexture1.vScale = 10;
+    terrain.diffuseTexture2.uScale = terrain.diffuseTexture2.vScale = 10;
+    terrain.diffuseTexture3.uScale = terrain.diffuseTexture3.vScale = 10;
+    
+    return terrain;
+};

+ 11 - 20
materialsLibrary/test/index.html

@@ -51,6 +51,8 @@
     <script src="add/addnormal.js"></script>
     <script src="add/addnormal.js"></script>
 	<script src="add/addwater.js"></script>
 	<script src="add/addwater.js"></script>
 	<script src="add/addfur.js"></script>
 	<script src="add/addfur.js"></script>
+	<script src="add/addterrain.js"></script>
+	<script src="add/addfire.js"></script>
 	
 	
 	<script>
 	<script>
 		if (BABYLON.Engine.isSupported()) {
 		if (BABYLON.Engine.isSupported()) {
@@ -85,6 +87,9 @@
 			var knot = BABYLON.Mesh.CreateTorusKnot("knot", 10, 3, 128, 64, 2, 3, scene);
 			var knot = BABYLON.Mesh.CreateTorusKnot("knot", 10, 3, 128, 64, 2, 3, scene);
 			knot.setEnabled(false);
 			knot.setEnabled(false);
 			
 			
+			var heightMap = BABYLON.Mesh.CreateGroundFromHeightMap("heightMap", "textures/heightMap.png", 100, 100, 100, 0, 10, scene, false);
+			heightMap.setEnabled(false);
+			
 			// Skybox
 			// Skybox
 			var skybox = BABYLON.Mesh.CreateBox("skyBox", 1000.0, scene);
 			var skybox = BABYLON.Mesh.CreateBox("skyBox", 1000.0, scene);
 			var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);
 			var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);
@@ -180,26 +185,9 @@
 				water.addToRenderList(shadowCaster2);
 				water.addToRenderList(shadowCaster2);
 				water.addToRenderList(shadowCaster3);
 				water.addToRenderList(shadowCaster3);
 				
 				
-				var fire = new BABYLON.FireMaterial("fire", scene);
-				fire.diffuseTexture = new BABYLON.Texture("textures/fire/diffuse.png", scene);
-				fire.distortionTexture = new BABYLON.Texture("textures/fire/distortion.png", scene);
-				fire.opacityTexture = new BABYLON.Texture("textures/fire/opacity.png", scene);
-				
-				var terrain = new BABYLON.TerrainMaterial("terrain", scene);
-				terrain.specularColor = new BABYLON.Color3(0.5, 0.5, 0.5);
-				terrain.specularPower = 64;
-				terrain.mixTexture = new BABYLON.Texture("textures/mixMap.png", scene);
-				terrain.diffuseTexture1 = new BABYLON.Texture("textures/grass.png", scene);
-				terrain.diffuseTexture2 = new BABYLON.Texture("textures/rock.png", scene);
-				terrain.diffuseTexture3 = new BABYLON.Texture("textures/floor.png", scene);
+				var fire = prepareFire();
 				
 				
-				terrain.bumpTexture1 = new BABYLON.Texture("textures/grassn.png", scene);
-				terrain.bumpTexture2 = new BABYLON.Texture("textures/rockn.png", scene);
-				terrain.bumpTexture3 = new BABYLON.Texture("textures/floor_bump.png", scene);
-				
-				terrain.diffuseTexture1.uScale = terrain.diffuseTexture1.vScale = 10;
-				terrain.diffuseTexture2.uScale = terrain.diffuseTexture2.vScale = 10;
-				terrain.diffuseTexture3.uScale = terrain.diffuseTexture3.vScale = 10;
+				var terrain = prepareTerrain();
 				
 				
 				var pbr = preparePBR();
 				var pbr = preparePBR();
 								
 								
@@ -248,7 +236,7 @@
 					window.enableMaterial(options.material);
 					window.enableMaterial(options.material);
 				});
 				});
 
 
-				gui.add(options, 'mesh', ['sphere', 'knot', 'plane', 'ground', 'rabbit']).onFinishChange(function () {
+				gui.add(options, 'mesh', ['sphere', 'knot', 'plane', 'ground', 'heightMap', 'rabbit']).onFinishChange(function () {
 					currentMesh.setEnabled(false);
 					currentMesh.setEnabled(false);
 					switch (options.mesh) {
 					switch (options.mesh) {
 						case "sphere":
 						case "sphere":
@@ -263,6 +251,9 @@
 						case "ground":
 						case "ground":
 							currentMesh = ground;
 							currentMesh = ground;
 							break;
 							break;
+						case "heightMap":
+							currentMesh = heightMap;
+							break;
 						case "rabbit":
 						case "rabbit":
 							currentMesh = rabbit;
 							currentMesh = rabbit;
 							break;
 							break;

BIN
materialsLibrary/test/textures/heightMap.png


BIN
materialsLibrary/test/textures/mixMap.png


+ 2 - 2
src/LensFlare/babylon.lensFlareSystem.js

@@ -85,7 +85,7 @@ var BABYLON;
                 return false;
                 return false;
             var engine = this._scene.getEngine();
             var engine = this._scene.getEngine();
             var viewport = this._scene.activeCamera.viewport;
             var viewport = this._scene.activeCamera.viewport;
-            var globalViewport = viewport.toGlobal(engine);
+            var globalViewport = viewport.toScreenGlobal(engine);
             // Position
             // Position
             if (!this.computeEffectivePosition(globalViewport)) {
             if (!this.computeEffectivePosition(globalViewport)) {
                 return false;
                 return false;
@@ -144,7 +144,7 @@ var BABYLON;
                 var x = centerX - (distX * flare.position);
                 var x = centerX - (distX * flare.position);
                 var y = centerY - (distY * flare.position);
                 var y = centerY - (distY * flare.position);
                 var cw = flare.size;
                 var cw = flare.size;
-                var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera);
+                var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
                 var cx = 2 * (x / globalViewport.width) - 1.0;
                 var cx = 2 * (x / globalViewport.width) - 1.0;
                 var cy = 1.0 - 2 * (y / globalViewport.height);
                 var cy = 1.0 - 2 * (y / globalViewport.height);
                 var viewportMatrix = BABYLON.Matrix.FromValues(cw / 2, 0, 0, 0, 0, ch / 2, 0, 0, 0, 0, 1, 0, cx, cy, 0, 1);
                 var viewportMatrix = BABYLON.Matrix.FromValues(cw / 2, 0, 0, 0, 0, ch / 2, 0, 0, 0, 0, 1, 0, cx, cy, 0, 1);

+ 2 - 2
src/LensFlare/babylon.lensFlareSystem.ts

@@ -118,7 +118,7 @@
 
 
             var engine = this._scene.getEngine();
             var engine = this._scene.getEngine();
             var viewport = this._scene.activeCamera.viewport;
             var viewport = this._scene.activeCamera.viewport;
-            var globalViewport = viewport.toGlobal(engine);
+            var globalViewport = viewport.toScreenGlobal(engine);
 
 
             // Position
             // Position
             if (!this.computeEffectivePosition(globalViewport)) {
             if (!this.computeEffectivePosition(globalViewport)) {
@@ -187,7 +187,7 @@
                 var y = centerY - (distY * flare.position);
                 var y = centerY - (distY * flare.position);
 
 
                 var cw = flare.size;
                 var cw = flare.size;
-                var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera);
+                var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
                 var cx = 2 * (x / globalViewport.width) - 1.0;
                 var cx = 2 * (x / globalViewport.width) - 1.0;
                 var cy = 1.0 - 2 * (y / globalViewport.height);
                 var cy = 1.0 - 2 * (y / globalViewport.height);
 
 

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

@@ -230,6 +230,7 @@ var BABYLON;
             var serializationObject = _super.prototype.serialize.call(this);
             var serializationObject = _super.prototype.serialize.call(this);
             serializationObject.options = this._options;
             serializationObject.options = this._options;
             serializationObject.shaderPath = this._shaderPath;
             serializationObject.shaderPath = this._shaderPath;
+            serializationObject.customType = "BABYLON.ShaderMaterial";
             // Texture
             // Texture
             serializationObject.textures = {};
             serializationObject.textures = {};
             for (var name in this._textures) {
             for (var name in this._textures) {

+ 143 - 143
src/Materials/babylon.shaderMaterial.ts

@@ -2,17 +2,17 @@
     export class ShaderMaterial extends Material {
     export class ShaderMaterial extends Material {
         private _shaderPath: any;
         private _shaderPath: any;
         private _options: any;
         private _options: any;
-        private _textures : { [name: string]: Texture } = {};
-        private _floats : { [name: string]: number }= {};
-        private _floatsArrays : { [name: string]: number[] } = {};
-        private _colors3 : { [name: string]: Color3 } = {};
-        private _colors4 : { [name: string]: Color4 } = {};
-        private _vectors2 : { [name: string]: Vector2 } = {};
-        private _vectors3 : { [name: string]: Vector3 } = {};
-        private _vectors4 : { [name: string]: Vector4 } = {};
-        private _matrices : { [name: string]: Matrix } = {};
-        private _matrices3x3 : { [name: string]: Float32Array } = {};
-        private _matrices2x2 : { [name: string]: Float32Array } = {};
+        private _textures: { [name: string]: Texture } = {};
+        private _floats: { [name: string]: number } = {};
+        private _floatsArrays: { [name: string]: number[] } = {};
+        private _colors3: { [name: string]: Color3 } = {};
+        private _colors4: { [name: string]: Color4 } = {};
+        private _vectors2: { [name: string]: Vector2 } = {};
+        private _vectors3: { [name: string]: Vector3 } = {};
+        private _vectors4: { [name: string]: Vector4 } = {};
+        private _matrices: { [name: string]: Matrix } = {};
+        private _matrices3x3: { [name: string]: Float32Array } = {};
+        private _matrices2x2: { [name: string]: Float32Array } = {};
         private _cachedWorldViewMatrix = new Matrix();
         private _cachedWorldViewMatrix = new Matrix();
         private _renderId: number;
         private _renderId: number;
 
 
@@ -281,7 +281,7 @@
             var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
             var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
 
 
             return newShaderMaterial;
             return newShaderMaterial;
-        }        
+        }
 
 
         public dispose(forceDisposeEffect?: boolean): void {
         public dispose(forceDisposeEffect?: boolean): void {
             for (var name in this._textures) {
             for (var name in this._textures) {
@@ -292,141 +292,141 @@
 
 
             super.dispose(forceDisposeEffect);
             super.dispose(forceDisposeEffect);
         }
         }
-		
+
         public serialize(): any {
         public serialize(): any {
             var serializationObject = super.serialize();
             var serializationObject = super.serialize();
             serializationObject.options = this._options;
             serializationObject.options = this._options;
-			serializationObject.shaderPath = this._shaderPath;
-			serializationObject.customType      = "BABYLON.ShaderMaterial";
+            serializationObject.shaderPath = this._shaderPath;
+            serializationObject.customType = "BABYLON.ShaderMaterial";
 			
 			
-			// Texture
-			serializationObject.textures = {};
-			for (var name in this._textures) {
-				serializationObject.textures[name] = this._textures[name].serialize();
-			}
-
-			// Float    
-			serializationObject.floats = {};
-			for (name in this._floats) {
-				serializationObject.floats[name] = this._floats[name];
-			}
-
-			// Float s   
-			serializationObject.floatArrays = {};
-			for (name in this._floatsArrays) {
-				serializationObject.floatArrays[name] = this._floatsArrays[name];
-			}
-
-			// Color3    
-			serializationObject.colors3 = {};		
-			for (name in this._colors3) {
-				serializationObject.colors3[name] = this._colors3[name].asArray();
-			}
-
-			// Color4  
-			serializationObject.colors4 = {};		
-			for (name in this._colors4) {
-				serializationObject.colors4[name] = this._colors4[name].asArray();
-			}
-
-			// Vector2  
-			serializationObject.vectors2 = {};		
-			for (name in this._vectors2) {
-				serializationObject.vectors2[name] = this._vectors2[name].asArray();
-			}
-
-			// Vector3        
-			serializationObject.vectors3 = {};		
-			for (name in this._vectors3) {
-				serializationObject.vectors3[name] = this._vectors3[name].asArray();
-			}
-
-			// Vector4        
-			serializationObject.vectors4 = {};		
-			for (name in this._vectors4) {
-				serializationObject.vectors4[name] = this._vectors4[name].asArray();
-			}
-
-			// Matrix      
-			serializationObject.matrices = {};
-			for (name in this._matrices) {
-				serializationObject.matrices[name] = this._matrices[name].asArray();
-			}
-
-			// Matrix 3x3
-			serializationObject.matrices3x3 = {};
-			for (name in this._matrices3x3) {
-				serializationObject.matrices3x3[name] = this._matrices3x3[name];
-			}
-
-			// Matrix 2x2
-			serializationObject.matrices2x2 = {};
-			for (name in this._matrices2x2) {
-				serializationObject.matrices2x2[name] = this._matrices2x2[name];
-			}
-			
-			return serializationObject;
-		}
-		
-		public static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial {
+            // Texture
+            serializationObject.textures = {};
+            for (var name in this._textures) {
+                serializationObject.textures[name] = this._textures[name].serialize();
+            }
+
+            // Float    
+            serializationObject.floats = {};
+            for (name in this._floats) {
+                serializationObject.floats[name] = this._floats[name];
+            }
+
+            // Float s   
+            serializationObject.floatArrays = {};
+            for (name in this._floatsArrays) {
+                serializationObject.floatArrays[name] = this._floatsArrays[name];
+            }
+
+            // Color3    
+            serializationObject.colors3 = {};
+            for (name in this._colors3) {
+                serializationObject.colors3[name] = this._colors3[name].asArray();
+            }
+
+            // Color4  
+            serializationObject.colors4 = {};
+            for (name in this._colors4) {
+                serializationObject.colors4[name] = this._colors4[name].asArray();
+            }
+
+            // Vector2  
+            serializationObject.vectors2 = {};
+            for (name in this._vectors2) {
+                serializationObject.vectors2[name] = this._vectors2[name].asArray();
+            }
+
+            // Vector3        
+            serializationObject.vectors3 = {};
+            for (name in this._vectors3) {
+                serializationObject.vectors3[name] = this._vectors3[name].asArray();
+            }
+
+            // Vector4        
+            serializationObject.vectors4 = {};
+            for (name in this._vectors4) {
+                serializationObject.vectors4[name] = this._vectors4[name].asArray();
+            }
+
+            // Matrix      
+            serializationObject.matrices = {};
+            for (name in this._matrices) {
+                serializationObject.matrices[name] = this._matrices[name].asArray();
+            }
+
+            // Matrix 3x3
+            serializationObject.matrices3x3 = {};
+            for (name in this._matrices3x3) {
+                serializationObject.matrices3x3[name] = this._matrices3x3[name];
+            }
+
+            // Matrix 2x2
+            serializationObject.matrices2x2 = {};
+            for (name in this._matrices2x2) {
+                serializationObject.matrices2x2[name] = this._matrices2x2[name];
+            }
+
+            return serializationObject;
+        }
+
+        public static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial {
             var material = new ShaderMaterial(source.name, scene, source.shaderPath, source.options);
             var material = new ShaderMaterial(source.name, scene, source.shaderPath, source.options);
 			
 			
-			// Texture
-			for (var name in source.textures) {
-				material.setTexture(name, <Texture> Texture.Parse(source.textures[name], scene, rootUrl));
-			}
-
-			// Float    
-			for (name in source.floats) {
-				material.setFloat(name, source.floats[name]);
-			}
-
-			// Float s   
-			for (name in source.floatsArrays) {
-				material.setFloats(name, source.floatsArrays[name]);
-			}
-
-			// Color3        
-			for (name in source.colors3) {
-				material.setColor3(name, Color3.FromArray(source.colors3[name]));
-			}
-
-			// Color4      
-			for (name in source.colors4) {
-				material.setColor4(name, Color4.FromArray(source.colors4[name]));
-			}
-
-			// Vector2        
-			for (name in source.vectors2) {
-				material.setVector2(name, Vector2.FromArray(source.vectors2[name]));
-			}
-
-			// Vector3        
-			for (name in source.vectors3) {
-				material.setVector3(name, Vector3.FromArray(source.vectors3[name]));
-			}
-
-			// Vector4        
-			for (name in source.vectors4) {
-				material.setVector4(name, Vector4.FromArray(source.vectors4[name]));
-			}
-
-			// Matrix      
-			for (name in source.matrices) {
-				material.setMatrix(name, Matrix.FromArray(source.matrices[name]));
-			}
-
-			// Matrix 3x3
-			for (name in source.matrices3x3) {
-				material.setMatrix3x3(name, source.matrices3x3[name]);
-			}
-
-			// Matrix 2x2
-			for (name in source.matrices2x2) {
-				material.setMatrix2x2(name, source.matrices2x2[name]);
-			}
-			
-			return material;
-		}
+            // Texture
+            for (var name in source.textures) {
+                material.setTexture(name, <Texture>Texture.Parse(source.textures[name], scene, rootUrl));
+            }
+
+            // Float    
+            for (name in source.floats) {
+                material.setFloat(name, source.floats[name]);
+            }
+
+            // Float s   
+            for (name in source.floatsArrays) {
+                material.setFloats(name, source.floatsArrays[name]);
+            }
+
+            // Color3        
+            for (name in source.colors3) {
+                material.setColor3(name, Color3.FromArray(source.colors3[name]));
+            }
+
+            // Color4      
+            for (name in source.colors4) {
+                material.setColor4(name, Color4.FromArray(source.colors4[name]));
+            }
+
+            // Vector2        
+            for (name in source.vectors2) {
+                material.setVector2(name, Vector2.FromArray(source.vectors2[name]));
+            }
+
+            // Vector3        
+            for (name in source.vectors3) {
+                material.setVector3(name, Vector3.FromArray(source.vectors3[name]));
+            }
+
+            // Vector4        
+            for (name in source.vectors4) {
+                material.setVector4(name, Vector4.FromArray(source.vectors4[name]));
+            }
+
+            // Matrix      
+            for (name in source.matrices) {
+                material.setMatrix(name, Matrix.FromArray(source.matrices[name]));
+            }
+
+            // Matrix 3x3
+            for (name in source.matrices3x3) {
+                material.setMatrix3x3(name, source.matrices3x3[name]);
+            }
+
+            // Matrix 2x2
+            for (name in source.matrices2x2) {
+                material.setMatrix2x2(name, source.matrices2x2[name]);
+            }
+
+            return material;
+        }
     }
     }
-} 
+} 

+ 5 - 0
src/Math/babylon.math.js

@@ -2234,6 +2234,11 @@ var BABYLON;
             var height = engine.getRenderHeight();
             var height = engine.getRenderHeight();
             return new Viewport(this.x * width, this.y * height, this.width * width, this.height * height);
             return new Viewport(this.x * width, this.y * height, this.width * width, this.height * height);
         };
         };
+        Viewport.prototype.toScreenGlobal = function (engine) {
+            var width = engine.getRenderWidth(true);
+            var height = engine.getRenderHeight(true);
+            return new Viewport(this.x * width, this.y * height, this.width * width, this.height * height);
+        };
         return Viewport;
         return Viewport;
     })();
     })();
     BABYLON.Viewport = Viewport;
     BABYLON.Viewport = Viewport;

+ 7 - 1
src/Math/babylon.math.ts

@@ -2797,11 +2797,17 @@
         constructor(public x: number, public y: number, public width: number, public height: number) {
         constructor(public x: number, public y: number, public width: number, public height: number) {
         }
         }
 
 
-        public toGlobal(engine): Viewport {
+        public toGlobal(engine: Engine): Viewport {
             var width = engine.getRenderWidth();
             var width = engine.getRenderWidth();
             var height = engine.getRenderHeight();
             var height = engine.getRenderHeight();
             return new Viewport(this.x * width, this.y * height, this.width * width, this.height * height);
             return new Viewport(this.x * width, this.y * height, this.width * width, this.height * height);
         }
         }
+
+        public toScreenGlobal(engine: Engine): Viewport {
+            var width = engine.getRenderWidth(true);
+            var height = engine.getRenderHeight(true);
+            return new Viewport(this.x * width, this.y * height, this.width * width, this.height * height);
+        }
     }
     }
 
 
     export class Frustum {
     export class Frustum {

+ 1 - 0
src/Mesh/babylon.mesh.vertexData.ts

@@ -2165,3 +2165,4 @@
         }
         }
     }
     }
 }
 }
+

+ 1 - 1
src/Rendering/babylon.renderingManager.js

@@ -63,7 +63,7 @@ var BABYLON;
             this._currentRenderParticles = renderParticles;
             this._currentRenderParticles = renderParticles;
             this._currentRenderSprites = renderSprites;
             this._currentRenderSprites = renderSprites;
             for (var index = 0; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
             for (var index = 0; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
-                this._depthBufferAlreadyCleaned = false;
+                this._depthBufferAlreadyCleaned = index == 0;
                 var renderingGroup = this._renderingGroups[index];
                 var renderingGroup = this._renderingGroups[index];
                 var needToStepBack = false;
                 var needToStepBack = false;
                 this._currentIndex = index;
                 this._currentIndex = index;

+ 1 - 1
src/Rendering/babylon.renderingManager.ts

@@ -89,7 +89,7 @@
             this._currentRenderSprites = renderSprites;
             this._currentRenderSprites = renderSprites;
 
 
             for (var index = 0; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
             for (var index = 0; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
-                this._depthBufferAlreadyCleaned = false;
+                this._depthBufferAlreadyCleaned = index == 0;
                 var renderingGroup = this._renderingGroups[index];
                 var renderingGroup = this._renderingGroups[index];
                 var needToStepBack = false;
                 var needToStepBack = false;
 
 

+ 0 - 4
src/Tools/babylon.sceneSerializer.js

@@ -228,10 +228,6 @@ var BABYLON;
             var material;
             var material;
             for (index = 0; index < scene.materials.length; index++) {
             for (index = 0; index < scene.materials.length; index++) {
                 material = scene.materials[index];
                 material = scene.materials[index];
-                //ShaderMaterial is not yet being serialized.
-                if (material instanceof BABYLON.ShaderMaterial) {
-                    continue;
-                }
                 serializationObject.materials.push(material.serialize());
                 serializationObject.materials.push(material.serialize());
             }
             }
             // MultiMaterials
             // MultiMaterials

+ 1 - 1
src/Tools/babylon.sceneSerializer.ts

@@ -268,7 +268,7 @@
                 var multiMaterial = scene.multiMaterials[index];
                 var multiMaterial = scene.multiMaterials[index];
                 serializationObject.multiMaterials.push(multiMaterial.serialize());
                 serializationObject.multiMaterials.push(multiMaterial.serialize());
             }
             }
-
+            
             // Skeletons
             // Skeletons
             serializationObject.skeletons = [];
             serializationObject.skeletons = [];
             for (index = 0; index < scene.skeletons.length; index++) {
             for (index = 0; index < scene.skeletons.length; index++) {

+ 17 - 10
src/babylon.engine.js

@@ -646,18 +646,21 @@ var BABYLON;
                 version: this._glVersion
                 version: this._glVersion
             };
             };
         };
         };
-        Engine.prototype.getAspectRatio = function (camera) {
+        Engine.prototype.getAspectRatio = function (camera, useScreen) {
+            if (useScreen === void 0) { useScreen = false; }
             var viewport = camera.viewport;
             var viewport = camera.viewport;
-            return (this.getRenderWidth() * viewport.width) / (this.getRenderHeight() * viewport.height);
+            return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
         };
         };
-        Engine.prototype.getRenderWidth = function () {
-            if (this._currentRenderTarget) {
+        Engine.prototype.getRenderWidth = function (useScreen) {
+            if (useScreen === void 0) { useScreen = false; }
+            if (!useScreen && this._currentRenderTarget) {
                 return this._currentRenderTarget._width;
                 return this._currentRenderTarget._width;
             }
             }
             return this._renderingCanvas.width;
             return this._renderingCanvas.width;
         };
         };
-        Engine.prototype.getRenderHeight = function () {
-            if (this._currentRenderTarget) {
+        Engine.prototype.getRenderHeight = function (useScreen) {
+            if (useScreen === void 0) { useScreen = false; }
+            if (!useScreen && this._currentRenderTarget) {
                 return this._currentRenderTarget._height;
                 return this._currentRenderTarget._height;
             }
             }
             return this._renderingCanvas.height;
             return this._renderingCanvas.height;
@@ -775,15 +778,19 @@ var BABYLON;
         };
         };
         Engine.prototype.clear = function (color, backBuffer, depthStencil) {
         Engine.prototype.clear = function (color, backBuffer, depthStencil) {
             this.applyStates();
             this.applyStates();
-            this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
-            if (this._depthCullingState.depthMask) {
+            if (backBuffer) {
+                this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
+            }
+            if (depthStencil && this._depthCullingState.depthMask) {
                 this._gl.clearDepth(1.0);
                 this._gl.clearDepth(1.0);
             }
             }
             var mode = 0;
             var mode = 0;
-            if (backBuffer)
+            if (backBuffer) {
                 mode |= this._gl.COLOR_BUFFER_BIT;
                 mode |= this._gl.COLOR_BUFFER_BIT;
-            if (depthStencil && this._depthCullingState.depthMask)
+            }
+            if (depthStencil && this._depthCullingState.depthMask) {
                 mode |= this._gl.DEPTH_BUFFER_BIT;
                 mode |= this._gl.DEPTH_BUFFER_BIT;
+            }
             this._gl.clear(mode);
             this._gl.clear(mode);
         };
         };
         /**
         /**

+ 15 - 10
src/babylon.engine.ts

@@ -727,21 +727,21 @@
             }
             }
         }
         }
 
 
-        public getAspectRatio(camera: Camera): number {
+        public getAspectRatio(camera: Camera, useScreen = false): number {
             var viewport = camera.viewport;
             var viewport = camera.viewport;
-            return (this.getRenderWidth() * viewport.width) / (this.getRenderHeight() * viewport.height);
+            return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
         }
         }
 
 
-        public getRenderWidth(): number {
-            if (this._currentRenderTarget) {
+        public getRenderWidth(useScreen = false): number {
+            if (!useScreen && this._currentRenderTarget) {
                 return this._currentRenderTarget._width;
                 return this._currentRenderTarget._width;
             }
             }
 
 
             return this._renderingCanvas.width;
             return this._renderingCanvas.width;
         }
         }
 
 
-        public getRenderHeight(): number {
-            if (this._currentRenderTarget) {
+        public getRenderHeight(useScreen = false): number {
+            if (!useScreen && this._currentRenderTarget) {
                 return this._currentRenderTarget._height;
                 return this._currentRenderTarget._height;
             }
             }
 
 
@@ -881,17 +881,22 @@
         public clear(color: any, backBuffer: boolean, depthStencil: boolean): void {
         public clear(color: any, backBuffer: boolean, depthStencil: boolean): void {
             this.applyStates();
             this.applyStates();
 
 
-            this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
-            if (this._depthCullingState.depthMask) {
+            if (backBuffer) {
+                this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
+            }
+
+            if (depthStencil && this._depthCullingState.depthMask) {
                 this._gl.clearDepth(1.0);
                 this._gl.clearDepth(1.0);
             }
             }
             var mode = 0;
             var mode = 0;
 
 
-            if (backBuffer)
+            if (backBuffer) {
                 mode |= this._gl.COLOR_BUFFER_BIT;
                 mode |= this._gl.COLOR_BUFFER_BIT;
+            }
 
 
-            if (depthStencil && this._depthCullingState.depthMask)
+            if (depthStencil && this._depthCullingState.depthMask) {
                 mode |= this._gl.DEPTH_BUFFER_BIT;
                 mode |= this._gl.DEPTH_BUFFER_BIT;
+            }
 
 
             this._gl.clear(mode);
             this._gl.clear(mode);
         }
         }