David Catuhe il y a 6 ans
Parent
commit
600cc394ca

Fichier diff supprimé car celui-ci est trop grand
+ 4886 - 4881
Playground/babylon.d.txt


Fichier diff supprimé car celui-ci est trop grand
+ 4896 - 4891
dist/preview release/babylon.d.ts


Fichier diff supprimé car celui-ci est trop grand
+ 1 - 1
dist/preview release/babylon.js


+ 14 - 3
dist/preview release/babylon.max.js

@@ -25403,6 +25403,11 @@ var BABYLON;
              * in order to block unwanted artifacts like system double clicks
              */
             _this.preventDefaultOnPointerDown = true;
+            /**
+             * This is used to call preventDefault() on pointer up
+             * in order to block unwanted artifacts like system double clicks
+             */
+            _this.preventDefaultOnPointerUp = true;
             // Metadata
             /**
              * Gets or sets user defined metadata
@@ -27002,8 +27007,10 @@ var BABYLON;
                         }
                     }
                 }
-                clickInfo.ignore = true;
-                cb(clickInfo, _this._currentPickResult);
+                else {
+                    clickInfo.ignore = true;
+                    cb(clickInfo, _this._currentPickResult);
+                }
             };
             this._onPointerMove = function (evt) {
                 _this._updatePointerPosition(evt);
@@ -27059,6 +27066,10 @@ var BABYLON;
                 _this._pickedUpMesh = null;
                 _this._meshPickProceed = false;
                 _this._updatePointerPosition(evt);
+                if (_this.preventDefaultOnPointerUp && canvas) {
+                    evt.preventDefault();
+                    canvas.focus();
+                }
                 _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
                     // PreObservable support
                     if (_this.onPrePointerObservable.hasObservers()) {
@@ -28904,7 +28915,7 @@ var BABYLON;
                     continue;
                 }
                 mesh._preActivate();
-                if (mesh.isVisible && mesh.visibility > 0 && (mesh.alwaysSelectAsActiveMesh || ((mesh.layerMask & this.activeCamera.layerMask) !== 0 && mesh.isInFrustum(this._frustumPlanes)))) {
+                if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
                     this._activeMeshes.push(mesh);
                     this.activeCamera._activeMeshes.push(mesh);
                     mesh._activate(this._renderId);

+ 14 - 3
dist/preview release/babylon.no-module.max.js

@@ -25370,6 +25370,11 @@ var BABYLON;
              * in order to block unwanted artifacts like system double clicks
              */
             _this.preventDefaultOnPointerDown = true;
+            /**
+             * This is used to call preventDefault() on pointer up
+             * in order to block unwanted artifacts like system double clicks
+             */
+            _this.preventDefaultOnPointerUp = true;
             // Metadata
             /**
              * Gets or sets user defined metadata
@@ -26969,8 +26974,10 @@ var BABYLON;
                         }
                     }
                 }
-                clickInfo.ignore = true;
-                cb(clickInfo, _this._currentPickResult);
+                else {
+                    clickInfo.ignore = true;
+                    cb(clickInfo, _this._currentPickResult);
+                }
             };
             this._onPointerMove = function (evt) {
                 _this._updatePointerPosition(evt);
@@ -27026,6 +27033,10 @@ var BABYLON;
                 _this._pickedUpMesh = null;
                 _this._meshPickProceed = false;
                 _this._updatePointerPosition(evt);
+                if (_this.preventDefaultOnPointerUp && canvas) {
+                    evt.preventDefault();
+                    canvas.focus();
+                }
                 _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
                     // PreObservable support
                     if (_this.onPrePointerObservable.hasObservers()) {
@@ -28871,7 +28882,7 @@ var BABYLON;
                     continue;
                 }
                 mesh._preActivate();
-                if (mesh.isVisible && mesh.visibility > 0 && (mesh.alwaysSelectAsActiveMesh || ((mesh.layerMask & this.activeCamera.layerMask) !== 0 && mesh.isInFrustum(this._frustumPlanes)))) {
+                if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
                     this._activeMeshes.push(mesh);
                     this.activeCamera._activeMeshes.push(mesh);
                     mesh._activate(this._renderId);

Fichier diff supprimé car celui-ci est trop grand
+ 1 - 1
dist/preview release/babylon.worker.js


+ 14 - 3
dist/preview release/es6.js

@@ -25370,6 +25370,11 @@ var BABYLON;
              * in order to block unwanted artifacts like system double clicks
              */
             _this.preventDefaultOnPointerDown = true;
+            /**
+             * This is used to call preventDefault() on pointer up
+             * in order to block unwanted artifacts like system double clicks
+             */
+            _this.preventDefaultOnPointerUp = true;
             // Metadata
             /**
              * Gets or sets user defined metadata
@@ -26969,8 +26974,10 @@ var BABYLON;
                         }
                     }
                 }
-                clickInfo.ignore = true;
-                cb(clickInfo, _this._currentPickResult);
+                else {
+                    clickInfo.ignore = true;
+                    cb(clickInfo, _this._currentPickResult);
+                }
             };
             this._onPointerMove = function (evt) {
                 _this._updatePointerPosition(evt);
@@ -27026,6 +27033,10 @@ var BABYLON;
                 _this._pickedUpMesh = null;
                 _this._meshPickProceed = false;
                 _this._updatePointerPosition(evt);
+                if (_this.preventDefaultOnPointerUp && canvas) {
+                    evt.preventDefault();
+                    canvas.focus();
+                }
                 _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
                     // PreObservable support
                     if (_this.onPrePointerObservable.hasObservers()) {
@@ -28871,7 +28882,7 @@ var BABYLON;
                     continue;
                 }
                 mesh._preActivate();
-                if (mesh.isVisible && mesh.visibility > 0 && (mesh.alwaysSelectAsActiveMesh || ((mesh.layerMask & this.activeCamera.layerMask) !== 0 && mesh.isInFrustum(this._frustumPlanes)))) {
+                if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
                     this._activeMeshes.push(mesh);
                     this.activeCamera._activeMeshes.push(mesh);
                     mesh._activate(this._renderId);

+ 0 - 202
dist/preview release/viewer/babylon.viewer.d.ts

@@ -674,208 +674,6 @@ declare module BabylonViewer {
     }
 }
 declare module BabylonViewer {
-    /**
-        * BABYLON.Animation play mode enum - is the animation looping or playing once
-        */
-    export const enum AnimationPlayMode {
-            ONCE = 0,
-            LOOP = 1
-    }
-    /**
-        * An enum representing the current state of an animation object
-        */
-    export const enum AnimationState {
-            INIT = 0,
-            PLAYING = 1,
-            PAUSED = 2,
-            STOPPED = 3,
-            ENDED = 4
-    }
-    /**
-        * The different type of easing functions available
-        */
-    export const enum EasingFunction {
-            Linear = 0,
-            CircleEase = 1,
-            BackEase = 2,
-            BounceEase = 3,
-            CubicEase = 4,
-            ElasticEase = 5,
-            ExponentialEase = 6,
-            PowerEase = 7,
-            QuadraticEase = 8,
-            QuarticEase = 9,
-            QuinticEase = 10,
-            SineEase = 11
-    }
-    /**
-        * Defines a simple animation to be applied to a model (scale).
-        */
-    export interface ModelAnimationConfiguration {
-            /**
-                * Time of animation, in seconds
-                */
-            time: number;
-            /**
-                * Scale to apply
-                */
-            scaling?: BABYLON.Vector3;
-            /**
-                * Easing function to apply
-                * See SPECTRE.EasingFunction
-                */
-            easingFunction?: number;
-            /**
-                * An Easing mode to apply to the easing function
-                * See BABYLON.EasingFunction
-                */
-            easingMode?: number;
-    }
-    /**
-        * This interface can be implemented to define new types of ModelAnimation objects.
-        */
-    export interface IModelAnimation {
-            /**
-                * Current animation state (playing, stopped etc')
-                */
-            readonly state: AnimationState;
-            /**
-                * the name of the animation
-                */
-            readonly name: string;
-            /**
-                * Get the max numbers of frame available in the animation group
-                *
-                * In correlation to an arry, this would be ".length"
-                */
-            readonly frames: number;
-            /**
-                * Get the current frame playing right now.
-                * This can be used to poll the frame currently playing (and, for exmaple, display a progress bar with the data)
-                *
-                * In correlation to an array, this would be the current index
-                */
-            readonly currentFrame: number;
-            /**
-                * BABYLON.Animation's FPS value
-                */
-            readonly fps: number;
-            /**
-                * Get or set the animation's speed ration (Frame-to-fps)
-                */
-            speedRatio: number;
-            /**
-                * Gets or sets the aimation's play mode.
-                */
-            playMode: AnimationPlayMode;
-            /**
-                * Start the animation
-                */
-            start(): any;
-            /**
-                * Stop the animation.
-                * This will fail silently if the animation group is already stopped.
-                */
-            stop(): any;
-            /**
-                * Pause the animation
-                * This will fail silently if the animation is not currently playing
-                */
-            pause(): any;
-            /**
-                * Reset this animation
-                */
-            reset(): any;
-            /**
-                * Restart the animation
-                */
-            restart(): any;
-            /**
-                * Go to a specific
-                * @param frameNumber the frame number to go to
-                */
-            goToFrame(frameNumber: number): any;
-            /**
-                * Dispose this animation
-                */
-            dispose(): any;
-    }
-    /**
-        * The GroupModelAnimation is an implementation of the IModelAnimation interface using BABYLON's
-        * native GroupAnimation class.
-        */
-    export class GroupModelAnimation implements IModelAnimation {
-            /**
-                * Create a new GroupModelAnimation object using an BABYLON.AnimationGroup object
-                * @param _animationGroup The aniamtion group to base the class on
-                */
-            constructor(_animationGroup: BABYLON.AnimationGroup);
-            /**
-                * Get the animation's name
-                */
-            readonly name: string;
-            /**
-                * Get the current animation's state
-                */
-            readonly state: AnimationState;
-            /**
-             * Sets the speed ratio to use for all animations
-             */
-            speedRatio: number;
-            /**
-                * Get the max numbers of frame available in the animation group
-                *
-                * In correlation to an arry, this would be ".length"
-                */
-            readonly frames: number;
-            /**
-                * Get the current frame playing right now.
-                * This can be used to poll the frame currently playing (and, for exmaple, display a progress bar with the data)
-                *
-                * In correlation to an array, this would be the current index
-                */
-            readonly currentFrame: number;
-            /**
-                * Get the FPS value of this animation
-                */
-            readonly fps: number;
-            /**
-             * Set the play mode.
-             * If the animation is played, it will continue playing at least once more, depending on the new play mode set.
-             * If the animation is not set, the will be initialized and will wait for the user to start playing it.
-             */
-            playMode: AnimationPlayMode;
-            /**
-                * Reset the animation group
-                */
-            reset(): void;
-            /**
-                * Restart the animation group
-                */
-            restart(): void;
-            /**
-                *
-                * @param frameNumber Go to a specific frame in the animation
-                */
-            goToFrame(frameNumber: number): void;
-            /**
-                * Start playing the animation.
-                */
-            start(): void;
-            /**
-                * Pause the animation
-                */
-            pause(): void;
-            /**
-                * Stop the animation.
-                * This will fail silently if the animation group is already stopped.
-                */
-            stop(): void;
-            /**
-                * Dispose this animation object.
-                */
-            dispose(): void;
-    }
 }
 declare module BabylonViewer {
     /**

Fichier diff supprimé car celui-ci est trop grand
+ 1 - 1
dist/preview release/viewer/babylon.viewer.js


Fichier diff supprimé car celui-ci est trop grand
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


+ 1 - 203
dist/preview release/viewer/babylon.viewer.module.d.ts

@@ -732,209 +732,7 @@ declare module 'babylonjs-viewer/model/viewerModel' {
 }
 
 declare module 'babylonjs-viewer/model/modelAnimation' {
-    import { AnimationGroup, Vector3 } from 'babylonjs';
-    /**
-        * Animation play mode enum - is the animation looping or playing once
-        */
-    export const enum AnimationPlayMode {
-            ONCE = 0,
-            LOOP = 1
-    }
-    /**
-        * An enum representing the current state of an animation object
-        */
-    export const enum AnimationState {
-            INIT = 0,
-            PLAYING = 1,
-            PAUSED = 2,
-            STOPPED = 3,
-            ENDED = 4
-    }
-    /**
-        * The different type of easing functions available
-        */
-    export const enum EasingFunction {
-            Linear = 0,
-            CircleEase = 1,
-            BackEase = 2,
-            BounceEase = 3,
-            CubicEase = 4,
-            ElasticEase = 5,
-            ExponentialEase = 6,
-            PowerEase = 7,
-            QuadraticEase = 8,
-            QuarticEase = 9,
-            QuinticEase = 10,
-            SineEase = 11
-    }
-    /**
-        * Defines a simple animation to be applied to a model (scale).
-        */
-    export interface ModelAnimationConfiguration {
-            /**
-                * Time of animation, in seconds
-                */
-            time: number;
-            /**
-                * Scale to apply
-                */
-            scaling?: Vector3;
-            /**
-                * Easing function to apply
-                * See SPECTRE.EasingFunction
-                */
-            easingFunction?: number;
-            /**
-                * An Easing mode to apply to the easing function
-                * See BABYLON.EasingFunction
-                */
-            easingMode?: number;
-    }
-    /**
-        * This interface can be implemented to define new types of ModelAnimation objects.
-        */
-    export interface IModelAnimation {
-            /**
-                * Current animation state (playing, stopped etc')
-                */
-            readonly state: AnimationState;
-            /**
-                * the name of the animation
-                */
-            readonly name: string;
-            /**
-                * Get the max numbers of frame available in the animation group
-                *
-                * In correlation to an arry, this would be ".length"
-                */
-            readonly frames: number;
-            /**
-                * Get the current frame playing right now.
-                * This can be used to poll the frame currently playing (and, for exmaple, display a progress bar with the data)
-                *
-                * In correlation to an array, this would be the current index
-                */
-            readonly currentFrame: number;
-            /**
-                * Animation's FPS value
-                */
-            readonly fps: number;
-            /**
-                * Get or set the animation's speed ration (Frame-to-fps)
-                */
-            speedRatio: number;
-            /**
-                * Gets or sets the aimation's play mode.
-                */
-            playMode: AnimationPlayMode;
-            /**
-                * Start the animation
-                */
-            start(): any;
-            /**
-                * Stop the animation.
-                * This will fail silently if the animation group is already stopped.
-                */
-            stop(): any;
-            /**
-                * Pause the animation
-                * This will fail silently if the animation is not currently playing
-                */
-            pause(): any;
-            /**
-                * Reset this animation
-                */
-            reset(): any;
-            /**
-                * Restart the animation
-                */
-            restart(): any;
-            /**
-                * Go to a specific
-                * @param frameNumber the frame number to go to
-                */
-            goToFrame(frameNumber: number): any;
-            /**
-                * Dispose this animation
-                */
-            dispose(): any;
-    }
-    /**
-        * The GroupModelAnimation is an implementation of the IModelAnimation interface using BABYLON's
-        * native GroupAnimation class.
-        */
-    export class GroupModelAnimation implements IModelAnimation {
-            /**
-                * Create a new GroupModelAnimation object using an AnimationGroup object
-                * @param _animationGroup The aniamtion group to base the class on
-                */
-            constructor(_animationGroup: AnimationGroup);
-            /**
-                * Get the animation's name
-                */
-            readonly name: string;
-            /**
-                * Get the current animation's state
-                */
-            readonly state: AnimationState;
-            /**
-             * Sets the speed ratio to use for all animations
-             */
-            speedRatio: number;
-            /**
-                * Get the max numbers of frame available in the animation group
-                *
-                * In correlation to an arry, this would be ".length"
-                */
-            readonly frames: number;
-            /**
-                * Get the current frame playing right now.
-                * This can be used to poll the frame currently playing (and, for exmaple, display a progress bar with the data)
-                *
-                * In correlation to an array, this would be the current index
-                */
-            readonly currentFrame: number;
-            /**
-                * Get the FPS value of this animation
-                */
-            readonly fps: number;
-            /**
-             * Set the play mode.
-             * If the animation is played, it will continue playing at least once more, depending on the new play mode set.
-             * If the animation is not set, the will be initialized and will wait for the user to start playing it.
-             */
-            playMode: AnimationPlayMode;
-            /**
-                * Reset the animation group
-                */
-            reset(): void;
-            /**
-                * Restart the animation group
-                */
-            restart(): void;
-            /**
-                *
-                * @param frameNumber Go to a specific frame in the animation
-                */
-            goToFrame(frameNumber: number): void;
-            /**
-                * Start playing the animation.
-                */
-            start(): void;
-            /**
-                * Pause the animation
-                */
-            pause(): void;
-            /**
-                * Stop the animation.
-                * This will fail silently if the animation group is already stopped.
-                */
-            stop(): void;
-            /**
-                * Dispose this animation object.
-                */
-            dispose(): void;
-    }
+    
 }
 
 declare module 'babylonjs-viewer/loader/plugins/loaderPlugin' {

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

@@ -33,7 +33,9 @@
 ## Bug fixes
 
 ### Core Engine
-
+- Fixed a bug with `mesh.alwaysSelectAsActiveMesh` preventing layerMask to be taken in account ([Deltakosh](https://github.com/deltakosh))
+- Fixed a bug with pointer up being fire twice ([Deltakosh](https://github.com/deltakosh))
+- Fixed a bug with particle systems being update once per camera instead of once per frame ([Deltakosh](https://github.com/deltakosh)) 
 
 
 ### Viewer

+ 19 - 20
src/Particles/babylon.gpuParticleSystem.ts

@@ -591,9 +591,9 @@ module BABYLON {
          * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
          */
         constructor(name: string, options: Partial<{
-                        capacity: number,
-                        randomTextureSize: number
-                    }>, scene: Scene, isAnimationSheetEnabled: boolean = false) {
+            capacity: number,
+            randomTextureSize: number
+        }>, scene: Scene, isAnimationSheetEnabled: boolean = false) {
             super(name);
             this._scene = scene || Engine.LastCreatedScene;
             // Setup the default processing configuration to the scene.
@@ -626,8 +626,8 @@ module BABYLON {
             this._updateEffectOptions = {
                 attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
                 uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
-                                "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
-                                "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
+                    "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
+                    "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
                 uniformBuffersNames: [],
                 samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
                 defines: "",
@@ -673,7 +673,7 @@ module BABYLON {
         }
 
         private _createUpdateVAO(source: Buffer): WebGLVertexArrayObject {
-            let updateVertexBuffers: {[key: string]: VertexBuffer} = {};
+            let updateVertexBuffers: { [key: string]: VertexBuffer } = {};
             updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
             updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
             updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
@@ -725,7 +725,7 @@ module BABYLON {
         }
 
         private _createRenderVAO(source: Buffer, spriteSource: Buffer): WebGLVertexArrayObject {
-            let renderVertexBuffers: {[key: string]: VertexBuffer} = {};
+            let renderVertexBuffers: { [key: string]: VertexBuffer } = {};
             renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
             renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
             renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
@@ -877,10 +877,10 @@ module BABYLON {
             }
 
             // Sprite data
-            var spriteData = new Float32Array([0.5, 0.5,  1, 1,
-                                              -0.5, 0.5,  0, 1,
-                                             -0.5, -0.5,  0, 0,
-                                             0.5, -0.5,  1, 0]);
+            var spriteData = new Float32Array([0.5, 0.5, 1, 1,
+                -0.5, 0.5, 0, 1,
+                -0.5, -0.5, 0, 0,
+                0.5, -0.5, 1, 0]);
 
             // Buffers
             this._buffer0 = new Buffer(engine, data, false, this._attributesStrideSize);
@@ -1042,9 +1042,9 @@ module BABYLON {
             }
 
             this._renderEffect = new Effect("gpuRenderParticles",
-                                            ["position", "age", "life", "size", "color", "offset", "uv", "direction", "initialDirection", "angle", "cellIndex"],
-                                            uniforms,
-                                            samplers, this._scene.getEngine(), defines);
+                ["position", "age", "life", "size", "color", "offset", "uv", "direction", "initialDirection", "angle", "cellIndex"],
+                uniforms,
+                samplers, this._scene.getEngine(), defines);
         }
 
         /**
@@ -1161,11 +1161,11 @@ module BABYLON {
                     this._preWarmDone = true;
                 }
 
-                if (this._currentRenderId === this._scene.getRenderId()) {
+                if (this._currentRenderId === this._scene.getFrameId()) {
                     return 0;
                 }
 
-                this._currentRenderId = this._scene.getRenderId();
+                this._currentRenderId = this._scene.getFrameId();
             }
 
             // Get everything ready to render
@@ -1294,8 +1294,7 @@ module BABYLON {
                 }
 
                 // Draw order
-                switch (this.blendMode)
-                {
+                switch (this.blendMode) {
                     case ParticleSystem.BLENDMODE_ADD:
                         this._engine.setAlphaMode(Engine.ALPHA_ADD);
                         break;
@@ -1447,7 +1446,7 @@ module BABYLON {
          * @returns the cloned particle system
          */
         public clone(name: string, newEmitter: any): GPUParticleSystem {
-            var result = new GPUParticleSystem(name, {capacity: this._capacity, randomTextureSize: this._randomTextureSize}, this._scene);
+            var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
 
             Tools.DeepCopy(this, result);
 
@@ -1486,7 +1485,7 @@ module BABYLON {
          */
         public static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart = false): GPUParticleSystem {
             var name = parsedParticleSystem.name;
-            var particleSystem = new GPUParticleSystem(name, {capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize}, scene);
+            var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
 
             if (parsedParticleSystem.activeParticleCount) {
                 particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;

+ 149 - 149
src/Particles/babylon.particleSystem.ts

@@ -206,181 +206,181 @@ module BABYLON {
                 for (var index = 0; index < particles.length; index++) {
                     var particle = particles[index];
 
-                        let scaledUpdateSpeed = this._scaledUpdateSpeed;
-                        let previousAge = particle.age;
-                        particle.age += scaledUpdateSpeed;
+                    let scaledUpdateSpeed = this._scaledUpdateSpeed;
+                    let previousAge = particle.age;
+                    particle.age += scaledUpdateSpeed;
 
-                        // Evaluate step to death
-                        if (particle.age > particle.lifeTime) {
-                            let diff = particle.age - previousAge;
-                            let oldDiff = particle.lifeTime - previousAge;
+                    // Evaluate step to death
+                    if (particle.age > particle.lifeTime) {
+                        let diff = particle.age - previousAge;
+                        let oldDiff = particle.lifeTime - previousAge;
 
-                            scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
+                        scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
 
-                            particle.age = particle.lifeTime;
-                        }
+                        particle.age = particle.lifeTime;
+                    }
 
-                        let ratio = particle.age / particle.lifeTime;
-
-                        // Color
-                        if (this._colorGradients && this._colorGradients.length > 0) {
-                            Tools.GetCurrentGradient(ratio, this._colorGradients, (currentGradient, nextGradient, scale) => {
-                                if (currentGradient !== particle._currentColorGradient) {
-                                    particle._currentColor1.copyFrom(particle._currentColor2);
-                                    (<ColorGradient>nextGradient).getColorToRef(particle._currentColor2);
-                                    particle._currentColorGradient = (<ColorGradient>currentGradient);
-                                }
-                                Color4.LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
-                            });
-                        }
-                        else {
-                            particle.colorStep.scaleToRef(scaledUpdateSpeed, this._scaledColorStep);
-                            particle.color.addInPlace(this._scaledColorStep);
+                    let ratio = particle.age / particle.lifeTime;
 
-                            if (particle.color.a < 0) {
-                                particle.color.a = 0;
+                    // Color
+                    if (this._colorGradients && this._colorGradients.length > 0) {
+                        Tools.GetCurrentGradient(ratio, this._colorGradients, (currentGradient, nextGradient, scale) => {
+                            if (currentGradient !== particle._currentColorGradient) {
+                                particle._currentColor1.copyFrom(particle._currentColor2);
+                                (<ColorGradient>nextGradient).getColorToRef(particle._currentColor2);
+                                particle._currentColorGradient = (<ColorGradient>currentGradient);
                             }
-                        }
+                            Color4.LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
+                        });
+                    }
+                    else {
+                        particle.colorStep.scaleToRef(scaledUpdateSpeed, this._scaledColorStep);
+                        particle.color.addInPlace(this._scaledColorStep);
 
-                        // Angular speed
-                        if (this._angularSpeedGradients && this._angularSpeedGradients.length > 0) {
-                            Tools.GetCurrentGradient(ratio, this._angularSpeedGradients, (currentGradient, nextGradient, scale) => {
-                                if (currentGradient !== particle._currentAngularSpeedGradient) {
-                                    particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
-                                    particle._currentAngularSpeed2 = (<FactorGradient>nextGradient).getFactor();
-                                    particle._currentAngularSpeedGradient = (<FactorGradient>currentGradient);
-                                }
-                                particle.angularSpeed = Scalar.Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
-                            });
-                        }
-                        particle.angle += particle.angularSpeed * scaledUpdateSpeed;
-
-                        // Direction
-                        let directionScale = scaledUpdateSpeed;
-
-                        /// Velocity
-                        if (this._velocityGradients && this._velocityGradients.length > 0) {
-                            Tools.GetCurrentGradient(ratio, this._velocityGradients, (currentGradient, nextGradient, scale) => {
-                                if (currentGradient !== particle._currentVelocityGradient) {
-                                    particle._currentVelocity1 = particle._currentVelocity2;
-                                    particle._currentVelocity2 = (<FactorGradient>nextGradient).getFactor();
-                                    particle._currentVelocityGradient = (<FactorGradient>currentGradient);
-                                }
-                                directionScale *= Scalar.Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
-                            });
+                        if (particle.color.a < 0) {
+                            particle.color.a = 0;
                         }
+                    }
 
-                        particle.direction.scaleToRef(directionScale, this._scaledDirection);
-
-                        /// Limit velocity
-                        if (this._limitVelocityGradients && this._limitVelocityGradients.length > 0) {
-                            Tools.GetCurrentGradient(ratio, this._limitVelocityGradients, (currentGradient, nextGradient, scale) => {
-                                if (currentGradient !== particle._currentLimitVelocityGradient) {
-                                    particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
-                                    particle._currentLimitVelocity2 = (<FactorGradient>nextGradient).getFactor();
-                                    particle._currentLimitVelocityGradient = (<FactorGradient>currentGradient);
-                                }
+                    // Angular speed
+                    if (this._angularSpeedGradients && this._angularSpeedGradients.length > 0) {
+                        Tools.GetCurrentGradient(ratio, this._angularSpeedGradients, (currentGradient, nextGradient, scale) => {
+                            if (currentGradient !== particle._currentAngularSpeedGradient) {
+                                particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
+                                particle._currentAngularSpeed2 = (<FactorGradient>nextGradient).getFactor();
+                                particle._currentAngularSpeedGradient = (<FactorGradient>currentGradient);
+                            }
+                            particle.angularSpeed = Scalar.Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
+                        });
+                    }
+                    particle.angle += particle.angularSpeed * scaledUpdateSpeed;
+
+                    // Direction
+                    let directionScale = scaledUpdateSpeed;
+
+                    /// Velocity
+                    if (this._velocityGradients && this._velocityGradients.length > 0) {
+                        Tools.GetCurrentGradient(ratio, this._velocityGradients, (currentGradient, nextGradient, scale) => {
+                            if (currentGradient !== particle._currentVelocityGradient) {
+                                particle._currentVelocity1 = particle._currentVelocity2;
+                                particle._currentVelocity2 = (<FactorGradient>nextGradient).getFactor();
+                                particle._currentVelocityGradient = (<FactorGradient>currentGradient);
+                            }
+                            directionScale *= Scalar.Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
+                        });
+                    }
 
-                                let limitVelocity = Scalar.Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
-                                let currentVelocity = particle.direction.length();
+                    particle.direction.scaleToRef(directionScale, this._scaledDirection);
 
-                                if (currentVelocity > limitVelocity) {
-                                    particle.direction.scaleInPlace(this.limitVelocityDamping);
-                                }
-                            });
-                        }
+                    /// Limit velocity
+                    if (this._limitVelocityGradients && this._limitVelocityGradients.length > 0) {
+                        Tools.GetCurrentGradient(ratio, this._limitVelocityGradients, (currentGradient, nextGradient, scale) => {
+                            if (currentGradient !== particle._currentLimitVelocityGradient) {
+                                particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
+                                particle._currentLimitVelocity2 = (<FactorGradient>nextGradient).getFactor();
+                                particle._currentLimitVelocityGradient = (<FactorGradient>currentGradient);
+                            }
 
-                        /// Drag
-                        if (this._dragGradients && this._dragGradients.length > 0) {
-                            Tools.GetCurrentGradient(ratio, this._dragGradients, (currentGradient, nextGradient, scale) => {
-                                if (currentGradient !== particle._currentDragGradient) {
-                                    particle._currentDrag1 = particle._currentDrag2;
-                                    particle._currentDrag2 = (<FactorGradient>nextGradient).getFactor();
-                                    particle._currentDragGradient = (<FactorGradient>currentGradient);
-                                }
+                            let limitVelocity = Scalar.Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
+                            let currentVelocity = particle.direction.length();
 
-                                let drag = Scalar.Lerp(particle._currentDrag1, particle._currentDrag2, scale);
+                            if (currentVelocity > limitVelocity) {
+                                particle.direction.scaleInPlace(this.limitVelocityDamping);
+                            }
+                        });
+                    }
 
-                                this._scaledDirection.scaleInPlace(1.0 - drag);
-                            });
-                        }
+                    /// Drag
+                    if (this._dragGradients && this._dragGradients.length > 0) {
+                        Tools.GetCurrentGradient(ratio, this._dragGradients, (currentGradient, nextGradient, scale) => {
+                            if (currentGradient !== particle._currentDragGradient) {
+                                particle._currentDrag1 = particle._currentDrag2;
+                                particle._currentDrag2 = (<FactorGradient>nextGradient).getFactor();
+                                particle._currentDragGradient = (<FactorGradient>currentGradient);
+                            }
 
-                        particle.position.addInPlace(this._scaledDirection);
+                            let drag = Scalar.Lerp(particle._currentDrag1, particle._currentDrag2, scale);
 
-                        // Noise
-                        if (noiseTextureData && noiseTextureSize) {
-                            let fetchedColorR = this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
-                            let fetchedColorG = this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
-                            let fetchedColorB = this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
+                            this._scaledDirection.scaleInPlace(1.0 - drag);
+                        });
+                    }
 
-                            let force = Tmp.Vector3[0];
-                            let scaledForce = Tmp.Vector3[1];
+                    particle.position.addInPlace(this._scaledDirection);
 
-                            force.copyFromFloats((2 * fetchedColorR - 1) * this.noiseStrength.x, (2 * fetchedColorG - 1) * this.noiseStrength.y, (2 * fetchedColorB - 1) * this.noiseStrength.z);
+                    // Noise
+                    if (noiseTextureData && noiseTextureSize) {
+                        let fetchedColorR = this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
+                        let fetchedColorG = this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
+                        let fetchedColorB = this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
 
-                            force.scaleToRef(scaledUpdateSpeed, scaledForce);
-                            particle.direction.addInPlace(scaledForce);
-                        }
+                        let force = Tmp.Vector3[0];
+                        let scaledForce = Tmp.Vector3[1];
 
-                        // Gravity
-                        this.gravity.scaleToRef(scaledUpdateSpeed, this._scaledGravity);
-                        particle.direction.addInPlace(this._scaledGravity);
-
-                        // Size
-                        if (this._sizeGradients && this._sizeGradients.length > 0) {
-                            Tools.GetCurrentGradient(ratio, this._sizeGradients, (currentGradient, nextGradient, scale) => {
-                                if (currentGradient !== particle._currentSizeGradient) {
-                                    particle._currentSize1 = particle._currentSize2;
-                                    particle._currentSize2 = (<FactorGradient>nextGradient).getFactor();
-                                    particle._currentSizeGradient = (<FactorGradient>currentGradient);
-                                }
-                                particle.size = Scalar.Lerp(particle._currentSize1, particle._currentSize2, scale);
-                            });
-                        }
+                        force.copyFromFloats((2 * fetchedColorR - 1) * this.noiseStrength.x, (2 * fetchedColorG - 1) * this.noiseStrength.y, (2 * fetchedColorB - 1) * this.noiseStrength.z);
 
-                        // Remap data
-                        if (this._useRampGradients) {
-                            if (this._colorRemapGradients && this._colorRemapGradients.length > 0) {
-                                Tools.GetCurrentGradient(ratio, this._colorRemapGradients, (currentGradient, nextGradient, scale) => {
-                                    let min = Scalar.Lerp((<FactorGradient>currentGradient).factor1, (<FactorGradient>nextGradient).factor1, scale);
-                                    let max = Scalar.Lerp((<FactorGradient>currentGradient).factor2!, (<FactorGradient>nextGradient).factor2!, scale);
+                        force.scaleToRef(scaledUpdateSpeed, scaledForce);
+                        particle.direction.addInPlace(scaledForce);
+                    }
 
-                                    particle.remapData.x = min;
-                                    particle.remapData.y = max - min;
-                                });
+                    // Gravity
+                    this.gravity.scaleToRef(scaledUpdateSpeed, this._scaledGravity);
+                    particle.direction.addInPlace(this._scaledGravity);
+
+                    // Size
+                    if (this._sizeGradients && this._sizeGradients.length > 0) {
+                        Tools.GetCurrentGradient(ratio, this._sizeGradients, (currentGradient, nextGradient, scale) => {
+                            if (currentGradient !== particle._currentSizeGradient) {
+                                particle._currentSize1 = particle._currentSize2;
+                                particle._currentSize2 = (<FactorGradient>nextGradient).getFactor();
+                                particle._currentSizeGradient = (<FactorGradient>currentGradient);
                             }
+                            particle.size = Scalar.Lerp(particle._currentSize1, particle._currentSize2, scale);
+                        });
+                    }
 
-                            if (this._alphaRemapGradients && this._alphaRemapGradients.length > 0) {
-                                Tools.GetCurrentGradient(ratio, this._alphaRemapGradients, (currentGradient, nextGradient, scale) => {
-                                    let min = Scalar.Lerp((<FactorGradient>currentGradient).factor1, (<FactorGradient>nextGradient).factor1, scale);
-                                    let max = Scalar.Lerp((<FactorGradient>currentGradient).factor2!, (<FactorGradient>nextGradient).factor2!, scale);
+                    // Remap data
+                    if (this._useRampGradients) {
+                        if (this._colorRemapGradients && this._colorRemapGradients.length > 0) {
+                            Tools.GetCurrentGradient(ratio, this._colorRemapGradients, (currentGradient, nextGradient, scale) => {
+                                let min = Scalar.Lerp((<FactorGradient>currentGradient).factor1, (<FactorGradient>nextGradient).factor1, scale);
+                                let max = Scalar.Lerp((<FactorGradient>currentGradient).factor2!, (<FactorGradient>nextGradient).factor2!, scale);
 
-                                    particle.remapData.z = min;
-                                    particle.remapData.w = max - min;
-                                });
-                            }
+                                particle.remapData.x = min;
+                                particle.remapData.y = max - min;
+                            });
                         }
 
-                        if (this._isAnimationSheetEnabled) {
-                            particle.updateCellIndex();
+                        if (this._alphaRemapGradients && this._alphaRemapGradients.length > 0) {
+                            Tools.GetCurrentGradient(ratio, this._alphaRemapGradients, (currentGradient, nextGradient, scale) => {
+                                let min = Scalar.Lerp((<FactorGradient>currentGradient).factor1, (<FactorGradient>nextGradient).factor1, scale);
+                                let max = Scalar.Lerp((<FactorGradient>currentGradient).factor2!, (<FactorGradient>nextGradient).factor2!, scale);
+
+                                particle.remapData.z = min;
+                                particle.remapData.w = max - min;
+                            });
                         }
+                    }
 
-                        // Update the position of the attached sub-emitters to match their attached particle
-                        particle._inheritParticleInfoToSubEmitters();
-
-                        if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
-                            this._emitFromParticle(particle);
-                            if (particle._attachedSubEmitters) {
-                                particle._attachedSubEmitters.forEach((subEmitter) => {
-                                    subEmitter.particleSystem.disposeOnStop = true;
-                                    subEmitter.particleSystem.stop();
-                                });
-                                particle._attachedSubEmitters = null;
-                            }
-                            this.recycleParticle(particle);
-                            index--;
-                            continue;
+                    if (this._isAnimationSheetEnabled) {
+                        particle.updateCellIndex();
+                    }
+
+                    // Update the position of the attached sub-emitters to match their attached particle
+                    particle._inheritParticleInfoToSubEmitters();
+
+                    if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
+                        this._emitFromParticle(particle);
+                        if (particle._attachedSubEmitters) {
+                            particle._attachedSubEmitters.forEach((subEmitter) => {
+                                subEmitter.particleSystem.disposeOnStop = true;
+                                subEmitter.particleSystem.stop();
+                            });
+                            particle._attachedSubEmitters = null;
                         }
+                        this.recycleParticle(particle);
+                        index--;
+                        continue;
+                    }
                 }
             };
         }
@@ -1138,14 +1138,14 @@ module BABYLON {
                     }
                     else if (offsetX === 1) {
                         offsetX = 1 - this._epsilon;
-                         }
+                    }
 
                     if (offsetY === 0) {
                         offsetY = this._epsilon;
                     }
                     else if (offsetY === 1) {
                         offsetY = 1 - this._epsilon;
-                         }
+                    }
                 }
 
                 this._vertexData[offset++] = offsetX;
@@ -1565,10 +1565,10 @@ module BABYLON {
                     return;
                 }
 
-                if (this._currentRenderId === this._scene.getRenderId()) {
+                if (this._currentRenderId === this._scene.getFrameId()) {
                     return;
                 }
-                this._currentRenderId = this._scene.getRenderId();
+                this._currentRenderId = this._scene.getFrameId();
             }
 
             this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());

+ 1 - 1
src/babylon.scene.ts

@@ -4179,7 +4179,7 @@ module BABYLON {
 
                 mesh._preActivate();
 
-                if (mesh.isVisible && mesh.visibility > 0 && (mesh.alwaysSelectAsActiveMesh || ((mesh.layerMask & this.activeCamera.layerMask) !== 0 && mesh.isInFrustum(this._frustumPlanes)))) {
+                if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
                     this._activeMeshes.push(mesh);
                     this.activeCamera._activeMeshes.push(mesh);