Selaa lähdekoodia

Integrating PRs

David Catuhe 10 vuotta sitten
vanhempi
commit
74e19c8d2b

+ 13 - 9
Babylon/Math/babylon.math.js

@@ -284,8 +284,9 @@ var BABYLON;
         Vector2.prototype.equals = function (otherVector) {
             return otherVector && this.x === otherVector.x && this.y === otherVector.y;
         };
-        Vector2.prototype.equalsWithEpsilon = function (otherVector) {
-            return otherVector && BABYLON.Tools.WithinEpsilon(this.x, otherVector.x) && BABYLON.Tools.WithinEpsilon(this.y, otherVector.y);
+        Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
+            if (epsilon === void 0) { epsilon = BABYLON.Engine.Epsilon; }
+            return otherVector && BABYLON.Tools.WithinEpsilon(this.x, otherVector.x, epsilon) && BABYLON.Tools.WithinEpsilon(this.y, otherVector.y, epsilon);
         };
         // Properties
         Vector2.prototype.length = function () {
@@ -484,8 +485,9 @@ var BABYLON;
         Vector3.prototype.equals = function (otherVector) {
             return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
         };
-        Vector3.prototype.equalsWithEpsilon = function (otherVector) {
-            return otherVector && BABYLON.Tools.WithinEpsilon(this.x, otherVector.x) && BABYLON.Tools.WithinEpsilon(this.y, otherVector.y) && BABYLON.Tools.WithinEpsilon(this.z, otherVector.z);
+        Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
+            if (epsilon === void 0) { epsilon = BABYLON.Engine.Epsilon; }
+            return otherVector && BABYLON.Tools.WithinEpsilon(this.x, otherVector.x, epsilon) && BABYLON.Tools.WithinEpsilon(this.y, otherVector.y, epsilon) && BABYLON.Tools.WithinEpsilon(this.z, otherVector.z, epsilon);
         };
         Vector3.prototype.equalsToFloats = function (x, y, z) {
             return this.x === x && this.y === y && this.z === z;
@@ -982,11 +984,13 @@ var BABYLON;
         Vector4.prototype.equals = function (otherVector) {
             return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
         };
-        Vector4.prototype.equalsWithEpsilon = function (otherVector) {
-            return Math.abs(this.x - otherVector.x) < BABYLON.Engine.Epsilon &&
-                Math.abs(this.y - otherVector.y) < BABYLON.Engine.Epsilon &&
-                Math.abs(this.z - otherVector.z) < BABYLON.Engine.Epsilon &&
-                Math.abs(this.w - otherVector.w) < BABYLON.Engine.Epsilon;
+        Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
+            if (epsilon === void 0) { epsilon = BABYLON.Engine.Epsilon; }
+            return otherVector
+                && BABYLON.Tools.WithinEpsilon(this.x, otherVector.x, epsilon)
+                && BABYLON.Tools.WithinEpsilon(this.y, otherVector.y, epsilon)
+                && BABYLON.Tools.WithinEpsilon(this.z, otherVector.z, epsilon)
+                && BABYLON.Tools.WithinEpsilon(this.w, otherVector.w, epsilon);
         };
         Vector4.prototype.equalsToFloats = function (x, y, z, w) {
             return this.x === x && this.y === y && this.z === z && this.w === w;

+ 15 - 15
Babylon/Math/babylon.math.ts

@@ -1025,7 +1025,7 @@
             var sign = -1.0;
             var pi = Math.PI;
             var nbRevert = 0;
-            var cross: Vector3; 
+            var cross: Vector3;
             var dot = 0.0;
 
             // step 1  : rotation around w
@@ -1042,7 +1042,7 @@
             else {
                 t = w.z / w.x;
                 x = - t * Math.sqrt(1 / (1 + t * t));
-                z = Math.sqrt(1 / (1 + t *t));
+                z = Math.sqrt(1 / (1 + t * t));
             }
 
             u1 = new Vector3(x, y, z);
@@ -1053,8 +1053,8 @@
             }
 
             dot = Vector3.Dot(u, u1);
-            roll = Math.acos(dot) * sign;      
-             
+            roll = Math.acos(dot) * sign;
+
             if (Vector3.Dot(u1, X) < 0) { // checks X orientation
                 roll = Math.PI + roll;
                 u1 = u1.scaleInPlace(-1);
@@ -1076,7 +1076,7 @@
             }
             else {
                 t = u1.z / u1.x;
-                x = - t * Math.sqrt(1  / (1 + t * t));
+                x = - t * Math.sqrt(1 / (1 + t * t));
                 z = Math.sqrt(1 / (1 + t * t));
             }
 
@@ -1088,7 +1088,7 @@
             }
 
             dot = Vector3.Dot(w, w2);
-            pitch = Math.acos(dot) * sign;      
+            pitch = Math.acos(dot) * sign;
             if (Vector3.Dot(v2, Y) < 0) { // checks for Y orientation
                 pitch = Math.PI + pitch;
                 v2 = v2.scaleInPlace(-1);
@@ -1229,11 +1229,11 @@
         }
 
         public equalsWithEpsilon(otherVector: Vector4, epsilon: number = Engine.Epsilon): boolean {
-            return otherVector 
-            && Tools.WithinEpsilon(this.x, otherVector.x, epsilon) 
-            && Tools.WithinEpsilon(this.y, otherVector.y, epsilon) 
-            && Tools.WithinEpsilon(this.z, otherVector.z, epsilon)
-            && Tools.WithinEpsilon(this.w, otherVector.w, epsilon);
+            return otherVector
+                && Tools.WithinEpsilon(this.x, otherVector.x, epsilon)
+                && Tools.WithinEpsilon(this.y, otherVector.y, epsilon)
+                && Tools.WithinEpsilon(this.z, otherVector.z, epsilon)
+                && Tools.WithinEpsilon(this.w, otherVector.w, epsilon);
         }
 
         public equalsToFloats(x: number, y: number, z: number, w: number): boolean {
@@ -1733,7 +1733,7 @@
                 num2 = flag ? ((-Math.sin(num * num5)) * num6) : ((Math.sin(num * num5)) * num6);
             }
 
-            return new Quaternion((num3 * left.x) + (num2 * right.x),(num3 * left.y) + (num2 * right.y),(num3 * left.z) + (num2 * right.z),(num3 * left.w) + (num2 * right.w));
+            return new Quaternion((num3 * left.x) + (num2 * right.x), (num3 * left.y) + (num2 * right.y), (num3 * left.z) + (num2 * right.z), (num3 * left.w) + (num2 * right.w));
         }
     }
 
@@ -3537,7 +3537,7 @@
 
     export class Curve3 {
         private _points: Vector3[];
-        private _length:number = 0;
+        private _length: number = 0;
 
         // QuadraticBezier(origin_V3, control_V3, destination_V3, nbPoints)
         public static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3 {
@@ -3571,7 +3571,7 @@
         public static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3 {
             var hermite = new Array<Vector3>();
             var step = 1 / nbPoints;
-            for(var i = 0; i <= nbPoints; i++) {
+            for (var i = 0; i <= nbPoints; i++) {
                 hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
             }
             return new Curve3(hermite);
@@ -3695,4 +3695,4 @@
             SIMDHelper._isEnabled = true;
         }
     }
-}
+}

+ 29 - 6
Babylon/PostProcess/babylon.volumetricLightScatteringPostProcess.js

@@ -45,9 +45,25 @@ var BABYLON;
             * Array containing the excluded meshes not rendered in the internal pass
             */
             this.excludedMeshes = new Array();
+            /**
+            * Controls the overall intensity of the post-process
+            * @type {number}
+            */
             this.exposure = 0.3;
+            /**
+            * Dissipates each sample's contribution in range [0, 1]
+            * @type {number}
+            */
             this.decay = 0.96815;
+            /**
+            * Controls the overall intensity of each sample
+            * @type {number}
+            */
             this.weight = 0.58767;
+            /**
+            * Controls the density of each sample
+            * @type {number}
+            */
             this.density = 0.926;
             var scene = camera.getScene();
             this._viewPort = new BABYLON.Viewport(0, 0, 1, 1).toGlobal(scene.getEngine());
@@ -76,8 +92,13 @@ var BABYLON;
                 if (this.useDiffuseColor) {
                     defines.push("#define DIFFUSE_COLOR_RENDER");
                 }
-                else {
-                    defines.push("#define BASIC_RENDER");
+                else if (material) {
+                    if (material.diffuseTexture !== undefined) {
+                        defines.push("#define BASIC_RENDER");
+                    }
+                    else {
+                        defines.push("#define DIFFUSE_COLOR_RENDER");
+                    }
                 }
                 defines.push("#define NEED_UV");
                 needUV = true;
@@ -89,10 +110,12 @@ var BABYLON;
                 }
                 if (material.opacityTexture !== undefined) {
                     defines.push("#define OPACITY");
-                    if (material.opacityTexture.getAlphaFromRGB)
+                    if (material.opacityTexture.getAlphaFromRGB) {
                         defines.push("#define OPACITYRGB");
-                    if (!needUV)
+                    }
+                    if (!needUV) {
                         defines.push("#define NEED_UV");
+                    }
                 }
                 if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)) {
                     attribs.push(BABYLON.VertexBuffer.UVKind);
@@ -198,10 +221,10 @@ var BABYLON;
                     // Alpha test
                     if (material && (mesh === _this.mesh || material.needAlphaTesting() || material.opacityTexture !== undefined)) {
                         var alphaTexture = material.getAlphaTestTexture();
-                        if (_this.useDiffuseColor && mesh === _this.mesh) {
+                        if ((_this.useDiffuseColor || alphaTexture === undefined) && mesh === _this.mesh) {
                             _this._volumetricLightScatteringPass.setColor3("color", material.diffuseColor);
                         }
-                        else {
+                        if (material.needAlphaTesting() || (mesh === _this.mesh && alphaTexture && !_this.useDiffuseColor)) {
                             _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
                             if (alphaTexture) {
                                 _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());

+ 30 - 6
Babylon/PostProcess/babylon.volumetricLightScatteringPostProcess.ts

@@ -35,9 +35,25 @@
         */
         public excludedMeshes = new Array<AbstractMesh>();
 
+        /**
+        * Controls the overall intensity of the post-process
+        * @type {number}
+        */
         public exposure = 0.3;
+        /**
+        * Dissipates each sample's contribution in range [0, 1]
+        * @type {number}
+        */
         public decay = 0.96815;
+        /**
+        * Controls the overall intensity of each sample
+        * @type {number}
+        */
         public weight = 0.58767;
+        /**
+        * Controls the density of each sample
+        * @type {number}
+        */
         public density = 0.926;
 
         /**
@@ -87,8 +103,13 @@
             if (mesh === this.mesh) {
                 if (this.useDiffuseColor) {
                     defines.push("#define DIFFUSE_COLOR_RENDER");
-                } else {
-                    defines.push("#define BASIC_RENDER");
+                }
+                else if (material) {
+                    if (material.diffuseTexture !== undefined) {
+                        defines.push("#define BASIC_RENDER");
+                    } else {
+                        defines.push("#define DIFFUSE_COLOR_RENDER");
+                    }
                 }
                 defines.push("#define NEED_UV");
                 needUV = true;
@@ -102,10 +123,12 @@
 
                 if (material.opacityTexture !== undefined) {
                     defines.push("#define OPACITY");
-                    if (material.opacityTexture.getAlphaFromRGB)
+                    if (material.opacityTexture.getAlphaFromRGB) {
                         defines.push("#define OPACITYRGB");
-                    if (!needUV)
+                    }
+                    if (!needUV) {
                         defines.push("#define NEED_UV");
+                    }
                 }
 
                 if (mesh.isVerticesDataPresent(VertexBuffer.UVKind)) {
@@ -238,9 +261,10 @@
                     if (material && (mesh === this.mesh || material.needAlphaTesting() || material.opacityTexture !== undefined)) {
                         var alphaTexture = material.getAlphaTestTexture();
 
-                        if (this.useDiffuseColor && mesh === this.mesh) {
+                        if ((this.useDiffuseColor || alphaTexture === undefined) && mesh === this.mesh) {
                             this._volumetricLightScatteringPass.setColor3("color", material.diffuseColor);
-                        } else {
+                        }
+                        if (material.needAlphaTesting() || (mesh === this.mesh && alphaTexture && !this.useDiffuseColor)) {
                             this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
                             if (alphaTexture) {
                                 this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());

+ 1 - 1
Babylon/babylon.engine.js

@@ -587,7 +587,7 @@ var BABYLON;
         });
         Object.defineProperty(Engine, "Version", {
             get: function () {
-                return "2.1.0";
+                return "2.2.0-alpha";
             },
             enumerable: true,
             configurable: true

+ 1 - 1
Babylon/babylon.engine.ts

@@ -461,7 +461,7 @@
         }
 
         public static get Version(): string {
-            return "2.1.0";
+            return "2.2.0-alpha";
         }
 
         // Updatable statics so stick with vars here

+ 20 - 15
Preview release - Alpha/babylon.2.2.d.ts

@@ -352,6 +352,7 @@ interface WebGLTexture {
     _cachedCoordinatesMode: number;
     _cachedWrapU: number;
     _cachedWrapV: number;
+    _isDisabled: boolean;
 }
 interface WebGLBuffer {
     references: number;
@@ -1878,20 +1879,6 @@ declare module BABYLON {
     }
 }
 declare module BABYLON {
-    class VRCamera extends FreeCamera {
-        private _leftCamera;
-        private _rightCamera;
-        private _offsetOrientation;
-        private _deviceOrientationHandler;
-        constructor(name: string, position: Vector3, scene: Scene, compensateDistorsion?: boolean);
-        _update(): void;
-        _updateCamera(camera: FreeCamera): void;
-        _onOrientationEvent(evt: DeviceOrientationEvent): void;
-        attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
-        detachControl(element: HTMLElement): void;
-    }
-}
-declare module BABYLON {
     class VRDeviceOrientationFreeCamera extends FreeCamera {
         _alpha: number;
         _beta: number;
@@ -4802,6 +4789,7 @@ declare module BABYLON {
         name: string;
         onApply: (effect: Effect) => void;
         onBeforeRender: (effect: Effect) => void;
+        onAfterRender: (effect: Effect) => void;
         onSizeChanged: () => void;
         onActivate: (camera: Camera) => void;
         width: number;
@@ -4813,10 +4801,11 @@ declare module BABYLON {
         private _engine;
         private _renderRatio;
         private _reusable;
+        private _textureType;
         _textures: SmartArray<WebGLTexture>;
         _currentRenderTextureInd: number;
         private _effect;
-        constructor(name: string, fragmentUrl: string, parameters: string[], samplers: string[], ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: string);
+        constructor(name: string, fragmentUrl: string, parameters: string[], samplers: string[], ratio: number | any, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: string, textureType?: number);
         isReusable(): boolean;
         activate(camera: Camera, sourceTexture?: WebGLTexture): void;
         apply(): Effect;
@@ -4979,9 +4968,25 @@ declare module BABYLON {
         * Array containing the excluded meshes not rendered in the internal pass
         */
         excludedMeshes: AbstractMesh[];
+        /**
+        * Controls the overall intensity of the post-process
+        * @type {number}
+        */
         exposure: number;
+        /**
+        * Dissipates each sample's contribution in range [0, 1]
+        * @type {number}
+        */
         decay: number;
+        /**
+        * Controls the overall intensity of each sample
+        * @type {number}
+        */
         weight: number;
+        /**
+        * Controls the density of each sample
+        * @type {number}
+        */
         density: number;
         /**
          * @constructor

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 25 - 22
Preview release - Alpha/babylon.2.2.js


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 56 - 21
Preview release - Alpha/babylon.2.2.max.js


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 24 - 21
Preview release - Alpha/babylon.2.2.noworker.js


+ 2 - 0
Preview release - Alpha/what's new.md

@@ -4,6 +4,8 @@
   - **Updates**
     - Depth-of-field improvements [PR](https://github.com/BabylonJS/Babylon.js/pull/567) [jahow](https://github.com/jahow)
     - Engine now initialize WebGL with preserveDrawingBuffer = false by default [deltakosh](https://github.com/deltakosh)
+    - withEpsilon with a user defined epsilon [PR](https://github.com/BabylonJS/Babylon.js/pull/573) [RaananW](https://github.com/RaananW)
+    - Adding onAfterRender function in BABYLON.PostProcess [PR](https://github.com/BabylonJS/Babylon.js/pull/572) [julien-moreau](https://github.com/julien-moreau)    
   - **Bug fixes**
  
   - **Breaking changes**