Browse Source

Better reflection shader

David Catuhe 9 năm trước cách đây
mục cha
commit
d53493a57e

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


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


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


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


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


+ 9 - 9
src/Materials/Textures/babylon.renderTargetTexture.js

@@ -35,23 +35,23 @@ var BABYLON;
             // Rendering groups
             this._renderingManager = new BABYLON.RenderingManager(scene);
         }
-        Object.defineProperty(RenderTargetTexture, "REFRESHRATE_RENDERONCE", {
+        Object.defineProperty(RenderTargetTexture, "REFRESHRATE_RENDER_ONCE", {
             get: function () {
-                return RenderTargetTexture._REFRESHRATE_RENDERONCE;
+                return RenderTargetTexture._REFRESHRATE_RENDER_ONCE;
             },
             enumerable: true,
             configurable: true
         });
-        Object.defineProperty(RenderTargetTexture, "REFRESHRATE_RENDERONEVERYFRAME", {
+        Object.defineProperty(RenderTargetTexture, "REFRESHRATE_RENDER_ONEVERYFRAME", {
             get: function () {
-                return RenderTargetTexture._REFRESHRATE_RENDERONEVERYFRAME;
+                return RenderTargetTexture._REFRESHRATE_RENDER_ONEVERYFRAME;
             },
             enumerable: true,
             configurable: true
         });
-        Object.defineProperty(RenderTargetTexture, "REFRESHRATE_RENDERONEVERYTWOFRAME", {
+        Object.defineProperty(RenderTargetTexture, "REFRESHRATE_RENDER_ONEVERYTWOFRAMES", {
             get: function () {
-                return RenderTargetTexture._REFRESHRATE_RENDERONEVERYTWOFRAME;
+                return RenderTargetTexture._REFRESHRATE_RENDER_ONEVERYTWOFRAMES;
             },
             enumerable: true,
             configurable: true
@@ -226,9 +226,9 @@ var BABYLON;
             newTexture.renderList = this.renderList.slice(0);
             return newTexture;
         };
-        RenderTargetTexture._REFRESHRATE_RENDERONCE = 0;
-        RenderTargetTexture._REFRESHRATE_RENDERONEVERYFRAME = 1;
-        RenderTargetTexture._REFRESHRATE_RENDERONEVERYTWOFRAME = 2;
+        RenderTargetTexture._REFRESHRATE_RENDER_ONCE = 0;
+        RenderTargetTexture._REFRESHRATE_RENDER_ONEVERYFRAME = 1;
+        RenderTargetTexture._REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
         return RenderTargetTexture;
     })(BABYLON.Texture);
     BABYLON.RenderTargetTexture = RenderTargetTexture;

+ 9 - 9
src/Materials/Textures/babylon.renderTargetTexture.ts

@@ -1,19 +1,19 @@
 module BABYLON {
     export class RenderTargetTexture extends Texture {
-        public static _REFRESHRATE_RENDERONCE: number = 0;
-        public static _REFRESHRATE_RENDERONEVERYFRAME: number = 1;
-        public static _REFRESHRATE_RENDERONEVERYTWOFRAME: number = 2;
+        public static _REFRESHRATE_RENDER_ONCE: number = 0;
+        public static _REFRESHRATE_RENDER_ONEVERYFRAME: number = 1;
+        public static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number = 2;
 
-        public static get REFRESHRATE_RENDERONCE(): number {
-            return RenderTargetTexture._REFRESHRATE_RENDERONCE;
+        public static get REFRESHRATE_RENDER_ONCE(): number {
+            return RenderTargetTexture._REFRESHRATE_RENDER_ONCE;
         }
 
-        public static get REFRESHRATE_RENDERONEVERYFRAME(): number {
-            return RenderTargetTexture._REFRESHRATE_RENDERONEVERYFRAME;
+        public static get REFRESHRATE_RENDER_ONEVERYFRAME(): number {
+            return RenderTargetTexture._REFRESHRATE_RENDER_ONEVERYFRAME;
         }
 
-        public static get REFRESHRATE_RENDERONEVERYTWOFRAME(): number {
-            return RenderTargetTexture._REFRESHRATE_RENDERONEVERYTWOFRAME;
+        public static get REFRESHRATE_RENDER_ONEVERYTWOFRAMES(): number {
+            return RenderTargetTexture._REFRESHRATE_RENDER_ONEVERYTWOFRAMES;
         }
 
         public renderList = new Array<AbstractMesh>();

+ 1 - 2
src/Mesh/babylon.meshBuilder.ts

@@ -390,7 +390,6 @@
             var updatable = options.updatable;
             var sideOrientation = options.sideOrientation || Mesh.DEFAULTSIDE;
             var instance = options.instance;
-            options.arc = (options.arc <= 0) ? 1.0 : options.arc || 1.0;
 
             // tube geometry
             var tubePathArray = (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) => {
@@ -782,4 +781,4 @@
             return extrudedGeneric;
         }
     }
-}
+}

+ 28 - 28
src/Particles/babylon.solidParticleSystem.js

@@ -14,10 +14,10 @@ var BABYLON;
             this._uvs = new Array();
             this._index = 0; // indices index
             this._shapeCounter = 0;
-            this._setParticleColor = true;
-            this._setParticleTexture = true;
-            this._setParticleRotation = true;
-            this._setParticleVertex = false;
+            this._computeParticleColor = true;
+            this._computeParticleTexture = true;
+            this._computeParticleRotation = true;
+            this._computeParticleVertex = false;
             this._cam_axisZ = BABYLON.Vector3.Zero();
             this._cam_axisY = BABYLON.Vector3.Zero();
             this._cam_axisX = BABYLON.Vector3.Zero();
@@ -196,7 +196,7 @@ var BABYLON;
                     this._particle.rotation.x = 0.0;
                     this._particle.rotation.y = 0.0;
                 }
-                if (this._setParticleRotation) {
+                if (this._computeParticleRotation) {
                     if (this._particle.quaternion) {
                         this._quaternion.x = this._particle.quaternion.x;
                         this._quaternion.y = this._particle.quaternion.y;
@@ -215,23 +215,23 @@ var BABYLON;
                     idx = index + pt * 3;
                     colidx = colorIndex + pt * 4;
                     uvidx = uvIndex + pt * 2;
-                    this._vertex.x = this._particle._shape[pt].x;
-                    this._vertex.y = this._particle._shape[pt].y;
-                    this._vertex.z = this._particle._shape[pt].z;
-                    if (this._setParticleVertex) {
+                    this._vertex.x = this._particle._shape[pt].x * this._particle.scale.x;
+                    this._vertex.y = this._particle._shape[pt].y * this._particle.scale.y;
+                    this._vertex.z = this._particle._shape[pt].z * this._particle.scale.z;
+                    if (this._computeParticleVertex) {
                         this.updateParticleVertex(this._particle, this._vertex, pt);
                     }
                     BABYLON.Vector3.TransformCoordinatesToRef(this._vertex, this._rotMatrix, this._rotated);
-                    this._positions[idx] = this._particle.position.x + this._cam_axisX.x * this._rotated.x * this._particle.scale.x + this._cam_axisY.x * this._rotated.y * this._particle.scale.y + this._cam_axisZ.x * this._rotated.z * this._particle.scale.z;
-                    this._positions[idx + 1] = this._particle.position.y + this._cam_axisX.y * this._rotated.x * this._particle.scale.x + this._cam_axisY.y * this._rotated.y * this._particle.scale.y + this._cam_axisZ.y * this._rotated.z * this._particle.scale.z;
-                    this._positions[idx + 2] = this._particle.position.z + this._cam_axisX.z * this._rotated.x * this._particle.scale.x + this._cam_axisY.z * this._rotated.y * this._particle.scale.y + this._cam_axisZ.z * this._rotated.z * this._particle.scale.z;
-                    if (this._setParticleColor) {
+                    this._positions[idx] = this._particle.position.x + this._cam_axisX.x * this._rotated.x + this._cam_axisY.x * this._rotated.y + this._cam_axisZ.x * this._rotated.z;
+                    this._positions[idx + 1] = this._particle.position.y + this._cam_axisX.y * this._rotated.x + this._cam_axisY.y * this._rotated.y + this._cam_axisZ.y * this._rotated.z;
+                    this._positions[idx + 2] = this._particle.position.z + this._cam_axisX.z * this._rotated.x + this._cam_axisY.z * this._rotated.y + this._cam_axisZ.z * this._rotated.z;
+                    if (this._computeParticleColor) {
                         this._colors[colidx] = this._particle.color.r;
                         this._colors[colidx + 1] = this._particle.color.g;
                         this._colors[colidx + 2] = this._particle.color.b;
                         this._colors[colidx + 3] = this._particle.color.a;
                     }
-                    if (this._setParticleTexture) {
+                    if (this._computeParticleTexture) {
                         this._uvs[uvidx] = this._particle._shapeUV[pt * 2] * (this._particle.uvs.z - this._particle.uvs.x) + this._particle.uvs.x;
                         this._uvs[uvidx + 1] = this._particle._shapeUV[pt * 2 + 1] * (this._particle.uvs.w - this._particle.uvs.y) + this._particle.uvs.y;
                     }
@@ -241,10 +241,10 @@ var BABYLON;
                 uvIndex = uvidx + 2;
             }
             if (update) {
-                if (this._setParticleColor) {
+                if (this._computeParticleColor) {
                     this.mesh.updateVerticesData(BABYLON.VertexBuffer.ColorKind, this._colors, false, false);
                 }
-                if (this._setParticleTexture) {
+                if (this._computeParticleTexture) {
                     this.mesh.updateVerticesData(BABYLON.VertexBuffer.UVKind, this._uvs, false, false);
                 }
                 this.mesh.updateVerticesData(BABYLON.VertexBuffer.PositionKind, this._positions, false, false);
@@ -292,44 +292,44 @@ var BABYLON;
         SolidParticleSystem.prototype.dispose = function () {
             this.mesh.dispose();
         };
-        Object.defineProperty(SolidParticleSystem.prototype, "setParticleRotation", {
+        Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
             // getters
             get: function () {
-                return this._setParticleRotation;
+                return this._computeParticleRotation;
             },
             // Optimizer setters
             set: function (val) {
-                this._setParticleRotation = val;
+                this._computeParticleRotation = val;
             },
             enumerable: true,
             configurable: true
         });
-        Object.defineProperty(SolidParticleSystem.prototype, "setParticleColor", {
+        Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
             get: function () {
-                return this._setParticleColor;
+                return this._computeParticleColor;
             },
             set: function (val) {
-                this._setParticleColor = val;
+                this._computeParticleColor = val;
             },
             enumerable: true,
             configurable: true
         });
-        Object.defineProperty(SolidParticleSystem.prototype, "setParticleTexture", {
+        Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
             get: function () {
-                return this._setParticleTexture;
+                return this._computeParticleTexture;
             },
             set: function (val) {
-                this._setParticleTexture = val;
+                this._computeParticleTexture = val;
             },
             enumerable: true,
             configurable: true
         });
-        Object.defineProperty(SolidParticleSystem.prototype, "setParticleVertex", {
+        Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
             get: function () {
-                return this._setParticleVertex;
+                return this._computeParticleVertex;
             },
             set: function (val) {
-                this._setParticleVertex = val;
+                this._computeParticleVertex = val;
             },
             enumerable: true,
             configurable: true

+ 1 - 1
src/Particles/babylon.solidParticleSystem.ts

@@ -400,4 +400,4 @@ module BABYLON {
         public afterUpdateParticles(start?: number, stop?: number, update?: boolean): void {
         }
     }
-}
+}

+ 23 - 22
src/Physics/Plugins/babylon.cannonJSPlugin.ts

@@ -32,7 +32,7 @@
                     bodyY = registeredMesh.body.position.y,
                     bodyZ = registeredMesh.body.position.z;
 
-                if(!registeredMesh.delta) {
+                if (!registeredMesh.delta) {
                     registeredMesh.delta = Vector3.Zero();
                 }
 
@@ -54,10 +54,10 @@
         public registerMesh(mesh: AbstractMesh, impostor: number, options?: PhysicsBodyCreationOptions): any {
             this.unregisterMesh(mesh);
 
-			if (!mesh.rotationQuaternion) {
+            if (!mesh.rotationQuaternion) {
                 mesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
             }
-			
+
             mesh.computeWorldMatrix(true);
 
             var shape = this._createShape(mesh, impostor, options);
@@ -67,13 +67,13 @@
 
         private _createShape(mesh: AbstractMesh, impostor: number, options?: PhysicsBodyCreationOptions) {
 		
-			//get the correct bounding box
-			var oldQuaternion = mesh.rotationQuaternion;
-			mesh.rotationQuaternion = new Quaternion(0, 0, 0, 1);
+            //get the correct bounding box
+            var oldQuaternion = mesh.rotationQuaternion;
+            mesh.rotationQuaternion = new Quaternion(0, 0, 0, 1);
             mesh.computeWorldMatrix(true);
-			
-			var returnValue;
-		
+
+            var returnValue;
+
             switch (impostor) {
                 case PhysicsEngine.SphereImpostor:
                     var bbox = mesh.getBoundingInfo().boundingBox;
@@ -82,8 +82,8 @@
                     var radiusZ = bbox.maximumWorld.z - bbox.minimumWorld.z;
 
                     returnValue = new CANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
-					
-					break;
+
+                    break;
                 //TMP also for cylinder - TODO Cannon supports cylinder natively.
                 case PhysicsEngine.CylinderImpostor:
                     Tools.Warn("CylinderImposter not yet implemented, using BoxImposter instead");
@@ -92,23 +92,23 @@
                     var min = bbox.minimumWorld;
                     var max = bbox.maximumWorld;
                     var box = max.subtract(min).scale(0.5);
-                    returnValue =  new CANNON.Box(new CANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
-					break;
+                    returnValue = new CANNON.Box(new CANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
+                    break;
                 case PhysicsEngine.PlaneImpostor:
                     Tools.Warn("Attention, Cannon.js PlaneImposter might not behave as you wish. Consider using BoxImposter instead");
                     returnValue = new CANNON.Plane();
-					break;
+                    break;
                 case PhysicsEngine.MeshImpostor:
                     var rawVerts = mesh.getVerticesData(VertexBuffer.PositionKind);
                     var rawFaces = mesh.getIndices();
 
                     returnValue = this._createConvexPolyhedron(rawVerts, rawFaces, mesh, options);
-					break;
+                    break;
             }
-			
-			mesh.rotationQuaternion = oldQuaternion;
-			
-			return returnValue;
+
+            mesh.rotationQuaternion = oldQuaternion;
+
+            return returnValue;
         }
 
         private _createConvexPolyhedron(rawVerts: number[] | Float32Array, rawFaces: number[], mesh: AbstractMesh, options?: PhysicsBodyCreationOptions): any {
@@ -308,11 +308,11 @@
         public isSupported(): boolean {
             return window.CANNON !== undefined;
         }
-        
-        public getWorldObject() : any {
+
+        public getWorldObject(): any {
             return this._world;
         }
-        
+
         public getPhysicsBodyOfMesh(mesh: AbstractMesh) {
             for (var index = 0; index < this._registeredMeshes.length; index++) {
                 var registeredMesh = this._registeredMeshes[index];
@@ -325,3 +325,4 @@
     }
 }
 
+

+ 37 - 36
src/Physics/Plugins/babylon.oimoJSPlugin.ts

@@ -20,11 +20,11 @@ module BABYLON {
 
         public registerMesh(mesh: AbstractMesh, impostor: number, options: PhysicsBodyCreationOptions): any {
             this.unregisterMesh(mesh);
-            
+
             if (!mesh.rotationQuaternion) {
                 mesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
             }
-            
+
             mesh.computeWorldMatrix(true);
 
             var bbox = mesh.getBoundingInfo().boundingBox;
@@ -35,12 +35,12 @@ module BABYLON {
             //calculate rotation to fit Oimo's needs (Euler...)
             var rot = new OIMO.Euler().setFromQuaternion({ x: mesh.rotationQuaternion.x, y: mesh.rotationQuaternion.y, z: mesh.rotationQuaternion.z, s: mesh.rotationQuaternion.w });
 
-			//get the correct bounding box
-			var oldQuaternion = mesh.rotationQuaternion;
-			mesh.rotationQuaternion = new Quaternion(0, 0, 0, 1);
+            //get the correct bounding box
+            var oldQuaternion = mesh.rotationQuaternion;
+            mesh.rotationQuaternion = new Quaternion(0, 0, 0, 1);
             mesh.computeWorldMatrix(true);
-			
-            var bodyConfig : any = {
+
+            var bodyConfig: any = {
                 pos: [bbox.center.x, bbox.center.y, bbox.center.z],
                 rot: [rot.x / OIMO.TO_RAD, rot.y / OIMO.TO_RAD, rot.z / OIMO.TO_RAD],
                 move: options.mass != 0,
@@ -80,7 +80,7 @@ module BABYLON {
                     bodyConfig.size = [sizeX, sizeY, sizeZ];
                     break;
             }
-            
+
             var body = new OIMO.Body(bodyConfig);
 
             //We have to access the rigid body's properties to set the quaternion. 
@@ -97,8 +97,8 @@ module BABYLON {
                 delta: deltaPosition
             });
 			
-			//for the sake of consistency.
-			mesh.rotationQuaternion = oldQuaternion;
+            //for the sake of consistency.
+            mesh.rotationQuaternion = oldQuaternion;
 
             return body;
         }
@@ -110,7 +110,7 @@ module BABYLON {
                 rotations = [];
 
             var initialMesh = parts[0].mesh;
-            
+
             for (var index = 0; index < parts.length; index++) {
                 var part = parts[index];
                 var bodyParameters = this._createBodyAsCompound(part, options, initialMesh);
@@ -132,9 +132,9 @@ module BABYLON {
             
             //Reset the body's rotation to be of the initial mesh's.
             var rot = new OIMO.Euler().setFromQuaternion({ x: initialMesh.rotationQuaternion.x, y: initialMesh.rotationQuaternion.y, z: initialMesh.rotationQuaternion.z, s: initialMesh.rotationQuaternion.w });
-			
-			body.resetRotation(rot.x / OIMO.TO_RAD, rot.y / OIMO.TO_RAD, rot.z / OIMO.TO_RAD);
-            
+
+            body.resetRotation(rot.x / OIMO.TO_RAD, rot.y / OIMO.TO_RAD, rot.z / OIMO.TO_RAD);
+
             this._registeredMeshes.push({
                 mesh: initialMesh,
                 body: body
@@ -145,8 +145,8 @@ module BABYLON {
 
         private _createBodyAsCompound(part: PhysicsCompoundBodyPart, options: PhysicsBodyCreationOptions, initialMesh: AbstractMesh): any {
             var mesh = part.mesh;
-			
-			if (!mesh.rotationQuaternion) {
+
+            if (!mesh.rotationQuaternion) {
                 mesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
             }
 			
@@ -154,19 +154,19 @@ module BABYLON {
             mesh.computeWorldMatrix(true);
 
             var rot = new OIMO.Euler().setFromQuaternion({ x: mesh.rotationQuaternion.x, y: mesh.rotationQuaternion.y, z: mesh.rotationQuaternion.z, s: mesh.rotationQuaternion.w });
-            
-            var bodyParameters : any = {
+
+            var bodyParameters: any = {
                 pos: [mesh.position.x, mesh.position.y, mesh.position.z],
                 //A bug in Oimo (Body class) prevents us from using rot directly.
-                rot: [0,0,0],
-				//For future reference, if the bug will ever be fixed.
+                rot: [0, 0, 0],
+                //For future reference, if the bug will ever be fixed.
                 realRot: [rot.x / OIMO.TO_RAD, rot.y / OIMO.TO_RAD, rot.z / OIMO.TO_RAD]
             };
-			
-			var oldQuaternion = mesh.rotationQuaternion;
-			mesh.rotationQuaternion = new Quaternion(0, 0, 0, 1);
+
+            var oldQuaternion = mesh.rotationQuaternion;
+            mesh.rotationQuaternion = new Quaternion(0, 0, 0, 1);
             mesh.computeWorldMatrix(true);
-            
+
             switch (part.impostor) {
                 case PhysicsEngine.SphereImpostor:
                     var bbox = mesh.getBoundingInfo().boundingBox;
@@ -178,10 +178,10 @@ module BABYLON {
                         this._checkWithEpsilon(radiusX),
                         this._checkWithEpsilon(radiusY),
                         this._checkWithEpsilon(radiusZ)) / 2;
-                    
+
                     bodyParameters.type = 'sphere';
                     bodyParameters.size = [size, size, size];
-                    
+
                     break;
 
                 case PhysicsEngine.PlaneImpostor:
@@ -194,14 +194,14 @@ module BABYLON {
                     var sizeX = this._checkWithEpsilon(box.x);
                     var sizeY = this._checkWithEpsilon(box.y);
                     var sizeZ = this._checkWithEpsilon(box.z);
-                    
+
                     bodyParameters.type = 'box';
                     bodyParameters.size = [sizeX, sizeY, sizeZ];
-                    
+
                     break;
             }
-			
-			mesh.rotationQuaternion = oldQuaternion;
+
+            mesh.rotationQuaternion = oldQuaternion;
 
             return bodyParameters;
         }
@@ -323,11 +323,11 @@ module BABYLON {
         public isSupported(): boolean {
             return OIMO !== undefined;
         }
-        
-        public getWorldObject() : any {
+
+        public getWorldObject(): any {
             return this._world;
         }
-        
+
         public getPhysicsBodyOfMesh(mesh: AbstractMesh) {
             for (var index = 0; index < this._registeredMeshes.length; index++) {
                 var registeredMesh = this._registeredMeshes[index];
@@ -356,8 +356,8 @@ module BABYLON {
 
                 var body = this._registeredMeshes[i].body.body;
                 var mesh = this._registeredMeshes[i].mesh;
-                
-                if(!this._registeredMeshes[i].delta) {
+
+                if (!this._registeredMeshes[i].delta) {
                     this._registeredMeshes[i].delta = Vector3.Zero();
                 }
 
@@ -370,7 +370,7 @@ module BABYLON {
                         mesh.position.z = parentShape.position.z * OIMO.WORLD_SCALE;
                     } else {
                         mesh.position.copyFrom(body.getPosition()).addInPlace(this._registeredMeshes[i].delta);
-                        
+
                     }
                     mesh.rotationQuaternion.copyFrom(body.getQuaternion());
                     mesh.computeWorldMatrix();
@@ -379,3 +379,4 @@ module BABYLON {
         }
     }
 }
+

+ 4 - 4
src/Physics/babylon.physicsEngine.ts

@@ -11,8 +11,8 @@
         dispose(): void;
         isSupported(): boolean;
         updateBodyPosition(mesh: AbstractMesh): void;
-        getWorldObject() : any; //Will return the physics world object of the engine used.
-        getPhysicsBodyOfMesh(mesh: AbstractMesh) : any;
+        getWorldObject(): any; //Will return the physics world object of the engine used.
+        getPhysicsBodyOfMesh(mesh: AbstractMesh): any;
     }
 
     export interface PhysicsBodyCreationOptions {
@@ -86,7 +86,7 @@
         public isSupported(): boolean {
             return this._currentPlugin.isSupported();
         }
-        
+
         public getPhysicsBodyOfMesh(mesh: AbstractMesh) {
             return this._currentPlugin.getPhysicsBodyOfMesh(mesh);
         }
@@ -103,4 +103,4 @@
         public static ConvexHullImpostor = 8;
         public static Epsilon = 0.001;
     }
-}
+}

+ 0 - 1
src/Probes/babylon.reflectionProbe.js

@@ -1,7 +1,6 @@
 var BABYLON;
 (function (BABYLON) {
     var ReflectionProbe = (function () {
-        //http://localhost:61437/Playground/index%20-%20debug.html#KA93U#7
         function ReflectionProbe(name, size, scene, generateMipMaps) {
             var _this = this;
             if (generateMipMaps === void 0) { generateMipMaps = true; }

+ 0 - 1
src/Probes/babylon.reflectionProbe.ts

@@ -10,7 +10,6 @@
 
         public position = Vector3.Zero();
           
-        //http://localhost:61437/Playground/index%20-%20debug.html#KA93U#7
         constructor(public name: string, size: number, scene: Scene, generateMipMaps = true) {
             this._scene = scene;
 

+ 111 - 60
src/Shaders/default.fragment.fx

@@ -152,24 +152,72 @@ uniform vec4 diffuseRightColor;
 uniform vec4 opacityParts;
 #endif
 
-#ifdef REFLECTIONFRESNEL
-uniform vec4 reflectionLeftColor;
-uniform vec4 reflectionRightColor;
-#endif
-
 #ifdef EMISSIVEFRESNEL
 uniform vec4 emissiveLeftColor;
 uniform vec4 emissiveRightColor;
 #endif
 
+// Reflection
 #ifdef REFLECTION
-varying vec3 vReflectionUVW;
+uniform vec2 vReflectionInfos;
+
 #ifdef REFLECTIONMAP_3D
 uniform samplerCube reflectionCubeSampler;
 #else
 uniform sampler2D reflection2DSampler;
 #endif
-uniform vec2 vReflectionInfos;
+
+#ifdef REFLECTIONMAP_SKYBOX
+	varying vec3 vPositionUVW;
+#else
+	uniform mat4 reflectionMatrix;
+#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION)
+	uniform mat4 view;
+#endif
+#endif
+
+vec3 computeReflectionCoords(vec4 worldPos, vec3 worldNormal)
+{
+#ifdef REFLECTIONMAP_SPHERICAL
+	vec3 coords = vec3(view * vec4(worldNormal, 0.0));
+
+	return vec3(reflectionMatrix * vec4(coords, 1.0));
+#endif
+
+#ifdef REFLECTIONMAP_PLANAR
+	vec3 viewDir = worldPos.xyz - vEyePosition;
+	vec3 coords = normalize(reflect(viewDir, worldNormal));
+
+	return vec3(reflectionMatrix * vec4(coords, 1));
+#endif
+
+#ifdef REFLECTIONMAP_CUBIC
+	vec3 viewDir = worldPos.xyz - vEyePosition;
+	vec3 coords = reflect(viewDir, worldNormal);
+#ifdef INVERTCUBICMAP
+	coords.y = 1.0 - coords.y;
+#endif
+	return vec3(reflectionMatrix * vec4(coords, 0));
+#endif
+
+#ifdef REFLECTIONMAP_PROJECTION
+	return vec3(reflectionMatrix * (view * worldPos));
+#endif
+
+#ifdef REFLECTIONMAP_SKYBOX
+	return vPositionUVW;
+#endif
+
+#ifdef REFLECTIONMAP_EXPLICIT
+	return vec3(0, 0, 0);
+#endif
+}
+
+#ifdef REFLECTIONFRESNEL
+uniform vec4 reflectionLeftColor;
+uniform vec4 reflectionRightColor;
+#endif
+
 #endif
 
 // Shadows
@@ -506,13 +554,13 @@ void main(void) {
 	float glossiness = vSpecularColor.a;
 	vec3 specularColor = vSpecularColor.rgb;
 
-	#ifdef SPECULAR
-		vec4 specularMapColor = texture2D(specularSampler, vSpecularUV);
-		specularColor = specularMapColor.rgb;
-		#ifdef GLOSSINESS
-			glossiness = glossiness * specularMapColor.a;
-		#endif
-	#endif
+#ifdef SPECULAR
+	vec4 specularMapColor = texture2D(specularSampler, vSpecularUV);
+	specularColor = specularMapColor.rgb;
+#ifdef GLOSSINESS
+	glossiness = glossiness * specularMapColor.a;
+#endif
+#endif
 #else
 	float glossiness = 0.;
 #endif
@@ -541,11 +589,11 @@ void main(void) {
 #ifdef SHADOWVSM0
 	shadow = computeShadowWithVSM(vPositionFromLight0, shadowSampler0, shadowsInfo0.z, shadowsInfo0.x);
 #else
-	#ifdef SHADOWPCF0
-		shadow = computeShadowWithPCF(vPositionFromLight0, shadowSampler0, shadowsInfo0.y, shadowsInfo0.z, shadowsInfo0.x);
-	#else
-		shadow = computeShadow(vPositionFromLight0, shadowSampler0, shadowsInfo0.x, shadowsInfo0.z);
-	#endif
+#ifdef SHADOWPCF0
+	shadow = computeShadowWithPCF(vPositionFromLight0, shadowSampler0, shadowsInfo0.y, shadowsInfo0.z, shadowsInfo0.x);
+#else
+	shadow = computeShadow(vPositionFromLight0, shadowSampler0, shadowsInfo0.x, shadowsInfo0.z);
+#endif
 #endif
 #else
 	shadow = 1.;
@@ -573,11 +621,11 @@ void main(void) {
 #ifdef SHADOWVSM1
 	shadow = computeShadowWithVSM(vPositionFromLight1, shadowSampler1, shadowsInfo1.z, shadowsInfo1.x);
 #else
-	#ifdef SHADOWPCF1
-		shadow = computeShadowWithPCF(vPositionFromLight1, shadowSampler1, shadowsInfo1.y, shadowsInfo1.z, shadowsInfo1.x);
-	#else
-		shadow = computeShadow(vPositionFromLight1, shadowSampler1, shadowsInfo1.x, shadowsInfo1.z);
-	#endif
+#ifdef SHADOWPCF1
+	shadow = computeShadowWithPCF(vPositionFromLight1, shadowSampler1, shadowsInfo1.y, shadowsInfo1.z, shadowsInfo1.x);
+#else
+	shadow = computeShadow(vPositionFromLight1, shadowSampler1, shadowsInfo1.x, shadowsInfo1.z);
+#endif
 #endif
 #else
 	shadow = 1.;
@@ -605,11 +653,11 @@ void main(void) {
 #ifdef SHADOWVSM2
 	shadow = computeShadowWithVSM(vPositionFromLight2, shadowSampler2, shadowsInfo2.z, shadowsInfo2.x);
 #else
-	#ifdef SHADOWPCF2
-		shadow = computeShadowWithPCF(vPositionFromLight2, shadowSampler2, shadowsInfo2.y, shadowsInfo2.z, shadowsInfo2.x);
-	#else
-		shadow = computeShadow(vPositionFromLight2, shadowSampler2, shadowsInfo2.x, shadowsInfo2.z);
-	#endif	
+#ifdef SHADOWPCF2
+	shadow = computeShadowWithPCF(vPositionFromLight2, shadowSampler2, shadowsInfo2.y, shadowsInfo2.z, shadowsInfo2.x);
+#else
+	shadow = computeShadow(vPositionFromLight2, shadowSampler2, shadowsInfo2.x, shadowsInfo2.z);
+#endif	
 #endif	
 #else
 	shadow = 1.;
@@ -637,11 +685,11 @@ void main(void) {
 #ifdef SHADOWVSM3
 	shadow = computeShadowWithVSM(vPositionFromLight3, shadowSampler3, shadowsInfo3.z, shadowsInfo3.x);
 #else
-	#ifdef SHADOWPCF3
-		shadow = computeShadowWithPCF(vPositionFromLight3, shadowSampler3, shadowsInfo3.y, shadowsInfo3.z, shadowsInfo3.x);
-	#else
-		shadow = computeShadow(vPositionFromLight3, shadowSampler3, shadowsInfo3.x, shadowsInfo3.z);
-	#endif	
+#ifdef SHADOWPCF3
+	shadow = computeShadowWithPCF(vPositionFromLight3, shadowSampler3, shadowsInfo3.y, shadowsInfo3.z, shadowsInfo3.x);
+#else
+	shadow = computeShadow(vPositionFromLight3, shadowSampler3, shadowsInfo3.x, shadowsInfo3.z);
+#endif	
 #endif	
 #else
 	shadow = 1.;
@@ -655,34 +703,37 @@ void main(void) {
 	// Reflection
 	vec3 reflectionColor = vec3(0., 0., 0.);
 
+
 #ifdef REFLECTION
-	#ifdef REFLECTIONMAP_3D
-			float bias = 0.;
+	vec3 vReflectionUVW = computeReflectionCoords(vec4(vPositionW, 1.0), normalW);
 
-		#ifdef ROUGHNESS
-				bias = vReflectionInfos.y;
-		#endif
+#ifdef REFLECTIONMAP_3D
+	float bias = 0.;
 
-		#ifdef SPECULARTERM
-			#ifdef SPECULAR
-				#ifdef GLOSSINESS
-						bias *= (1.0 - specularMapColor.a);
-				#endif
-			#endif
-		#endif
+#ifdef ROUGHNESS
+	bias = vReflectionInfos.y;
+#endif
+
+#ifdef SPECULARTERM
+#ifdef SPECULAR
+#ifdef GLOSSINESS
+	bias *= (1.0 - specularMapColor.a);
+#endif
+#endif
+#endif
 
-		reflectionColor = textureCube(reflectionCubeSampler, vReflectionUVW, bias).rgb * vReflectionInfos.x * shadow;
-	#else
-		vec2 coords = vReflectionUVW.xy;
+	reflectionColor = textureCube(reflectionCubeSampler, vReflectionUVW, bias).rgb * vReflectionInfos.x * shadow;
+#else
+	vec2 coords = vReflectionUVW.xy;
 
-		#ifdef REFLECTIONMAP_PROJECTION
-			coords /= vReflectionUVW.z;
-		#endif
+#ifdef REFLECTIONMAP_PROJECTION
+	coords /= vReflectionUVW.z;
+#endif
 
-		coords.y = 1.0 - coords.y;
+	coords.y = 1.0 - coords.y;
 
-		reflectionColor = texture2D(reflection2DSampler, coords).rgb * vReflectionInfos.x * shadow;
-#endif	
+	reflectionColor = texture2D(reflection2DSampler, coords).rgb * vReflectionInfos.x * shadow;
+#endif
 
 #ifdef REFLECTIONFRESNEL
 	float reflectionFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, reflectionRightColor.a, reflectionLeftColor.a);
@@ -725,7 +776,7 @@ void main(void) {
 	// Emissive
 	vec3 emissiveColor = vEmissiveColor;
 #ifdef EMISSIVE
-    emissiveColor += texture2D(emissiveSampler, vEmissiveUV).rgb * vEmissiveInfos.y;
+	emissiveColor += texture2D(emissiveSampler, vEmissiveUV).rgb * vEmissiveInfos.y;
 #endif
 
 #ifdef EMISSIVEFRESNEL
@@ -745,7 +796,7 @@ void main(void) {
 #ifdef EMISSIVEASILLUMINATION
 	vec3 finalDiffuse = clamp(diffuseBase * diffuseColor + vAmbientColor, 0.0, 1.0) * baseColor.rgb;
 #else
-    vec3 finalDiffuse = clamp(diffuseBase * diffuseColor + emissiveColor + vAmbientColor, 0.0, 1.0) * baseColor.rgb;
+	vec3 finalDiffuse = clamp(diffuseBase * diffuseColor + emissiveColor + vAmbientColor, 0.0, 1.0) * baseColor.rgb;
 #endif
 
 #ifdef SPECULARTERM
@@ -758,11 +809,11 @@ void main(void) {
 	alpha = clamp(alpha + dot(finalSpecular, vec3(0.3, 0.59, 0.11)), 0., 1.);
 #endif
 
-// Composition
+	// Composition
 #ifdef EMISSIVEASILLUMINATION
-    vec4 color = vec4(clamp(finalDiffuse * baseAmbientColor + finalSpecular + reflectionColor + emissiveColor, 0.0, 1.0), alpha);
+	vec4 color = vec4(clamp(finalDiffuse * baseAmbientColor + finalSpecular + reflectionColor + emissiveColor, 0.0, 1.0), alpha);
 #else
-    vec4 color = vec4(finalDiffuse * baseAmbientColor + finalSpecular + reflectionColor, alpha);
+	vec4 color = vec4(finalDiffuse * baseAmbientColor + finalSpecular + reflectionColor, alpha);
 #endif
 
 #ifdef LIGHTMAP

+ 5 - 44
src/Shaders/default.vertex.fx

@@ -121,52 +121,17 @@ varying vec4 vPositionFromLight3;
 #endif
 #endif
 
-#ifdef REFLECTION
-uniform vec3 vEyePosition;
-varying vec3 vReflectionUVW;
-uniform mat4 reflectionMatrix;
-
-vec3 computeReflectionCoords(vec4 worldPos, vec3 worldNormal)
-{
-#ifdef REFLECTIONMAP_SPHERICAL
-	vec3 coords = vec3(view * vec4(worldNormal, 0.0));
-
-	return vec3(reflectionMatrix * vec4(coords, 1.0));
-#endif
-
-#ifdef REFLECTIONMAP_PLANAR
-	vec3 viewDir = worldPos.xyz - vEyePosition;
-	vec3 coords = normalize(reflect(viewDir, worldNormal));
-
-	return vec3(reflectionMatrix * vec4(coords, 1));
-#endif
-
-#ifdef REFLECTIONMAP_CUBIC
-	vec3 viewDir = worldPos.xyz - vEyePosition;
-	vec3 coords = reflect(viewDir, worldNormal);
-#ifdef INVERTCUBICMAP
-	coords.y = 1.0 - coords.y;
-#endif
-	return vec3(reflectionMatrix * vec4(coords, 0));
-#endif
-
-#ifdef REFLECTIONMAP_PROJECTION
-	return vec3(reflectionMatrix * (view * worldPos));
-#endif
-
 #ifdef REFLECTIONMAP_SKYBOX
-	return position;
-#endif
-
-#ifdef REFLECTIONMAP_EXPLICIT
-	return vec3(0, 0, 0);
-#endif
-}
+varying vec3 vPositionUVW;
 #endif
 
 void main(void) {
 	mat4 finalWorld;
 
+#ifdef REFLECTIONMAP_SKYBOX
+	vPositionUVW = position;
+#endif 
+
 #ifdef INSTANCES
 	finalWorld = mat4(world0, world1, world2, world3);
 #else
@@ -236,10 +201,6 @@ void main(void) {
 	}
 #endif
 
-#ifdef REFLECTION
-	vReflectionUVW = computeReflectionCoords(vec4(vPositionW, 1.0), vNormalW);
-#endif
-
 #ifdef EMISSIVE
 	if (vEmissiveInfos.x == 0.)
 	{

+ 2 - 2
src/babylon.scene.ts

@@ -320,7 +320,7 @@
         }
 
         public set workerCollisions(enabled: boolean) {
-        
+
             enabled = (enabled && !!Worker);
 
             this._workerCollisions = enabled;
@@ -2410,4 +2410,4 @@
             return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
         }
     }
-} 
+}