Jelajahi Sumber

Move emitter to sub folder

David Catuhe 7 tahun lalu
induk
melakukan
8dbe50e011

+ 7 - 6
Tools/Gulp/config.json

@@ -272,10 +272,10 @@
             "files": [
             "files": [
                 "../../src/Particles/babylon.particle.js",
                 "../../src/Particles/babylon.particle.js",
                 "../../src/Particles/babylon.particleSystem.js",
                 "../../src/Particles/babylon.particleSystem.js",
-                "../../src/Particles/babylon.boxParticleEmitter.js",
-                "../../src/Particles/babylon.coneParticleEmitter.js",
-                "../../src/Particles/babylon.sphereParticleEmitter.js",
-                "../../src/Particles/babylon.iParticleEmitterType.js"
+                "../../src/Particles/EmitterTypes/babylon.boxParticleEmitter.js",
+                "../../src/Particles/EmitterTypes/babylon.coneParticleEmitter.js",
+                "../../src/Particles/EmitterTypes/babylon.sphereParticleEmitter.js",
+                "../../src/Particles/EmitterTypes/babylon.IParticleEmitterType.js"
             ],
             ],
             "dependUpon": [
             "dependUpon": [
                 "core"
                 "core"
@@ -287,10 +287,11 @@
         },
         },
         "gpuParticles": {
         "gpuParticles": {
             "files": [
             "files": [
-                "../../src/Particles/babylon.gpuParticleSystem.js"
+                "../../src/Particles/babylon.gpuParticleSystem.js"          
             ],
             ],
             "dependUpon": [
             "dependUpon": [
-                "core"
+                "core",
+                "particles"
             ],
             ],
             "shaders": [
             "shaders": [
                 "gpuRenderParticles.vertex",
                 "gpuRenderParticles.vertex",

File diff ditekan karena terlalu besar
+ 15609 - 15585
dist/preview release/babylon.d.ts


File diff ditekan karena terlalu besar
+ 23 - 23
dist/preview release/babylon.js


File diff ditekan karena terlalu besar
+ 153 - 95
dist/preview release/babylon.max.js


File diff ditekan karena terlalu besar
+ 23 - 23
dist/preview release/babylon.worker.js


File diff ditekan karena terlalu besar
+ 11907 - 11883
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


File diff ditekan karena terlalu besar
+ 22 - 22
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 114 - 79
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -50541,22 +50541,6 @@ var BABYLON;
              */
              */
             this.gravity = BABYLON.Vector3.Zero();
             this.gravity = BABYLON.Vector3.Zero();
             /**
             /**
-             * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
-             */
-            this.direction1 = new BABYLON.Vector3(0, 1.0, 0);
-            /**
-             * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
-             */
-            this.direction2 = new BABYLON.Vector3(0, 1.0, 0);
-            /**
-             * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
-             */
-            this.minEmitBox = new BABYLON.Vector3(-0.5, -0.5, -0.5);
-            /**
-             * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
-             */
-            this.maxEmitBox = new BABYLON.Vector3(0.5, 0.5, 0.5);
-            /**
              * Random color of each particle after it has been emitted, between color1 and color2 vectors.
              * Random color of each particle after it has been emitted, between color1 and color2 vectors.
              */
              */
             this.color1 = new BABYLON.Color4(1.0, 1.0, 1.0, 1.0);
             this.color1 = new BABYLON.Color4(1.0, 1.0, 1.0, 1.0);
@@ -50639,8 +50623,8 @@ var BABYLON;
             this._vertexBuffers[BABYLON.VertexBuffer.PositionKind] = positions;
             this._vertexBuffers[BABYLON.VertexBuffer.PositionKind] = positions;
             this._vertexBuffers[BABYLON.VertexBuffer.ColorKind] = colors;
             this._vertexBuffers[BABYLON.VertexBuffer.ColorKind] = colors;
             this._vertexBuffers["options"] = options;
             this._vertexBuffers["options"] = options;
-            // Default behaviors
-            this.particleEmitterType = new BABYLON.BoxParticleEmitter(this);
+            // Default emitter type
+            this.particleEmitterType = new BABYLON.BoxParticleEmitter();
             this.updateFunction = function (particles) {
             this.updateFunction = function (particles) {
                 for (var index = 0; index < particles.length; index++) {
                 for (var index = 0; index < particles.length; index++) {
                     var particle = particles[index];
                     var particle = particles[index];
@@ -50667,6 +50651,82 @@ var BABYLON;
                 }
                 }
             };
             };
         }
         }
+        Object.defineProperty(ParticleSystem.prototype, "direction1", {
+            /**
+              * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
+              * This only works when particleEmitterTyps is a BoxParticleEmitter
+              */
+            get: function () {
+                if (this.particleEmitterType.direction1) {
+                    return this.particleEmitterType.direction1;
+                }
+                return BABYLON.Vector3.Zero();
+            },
+            set: function (value) {
+                if (this.particleEmitterType.direction1) {
+                    this.particleEmitterType.direction1 = value;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(ParticleSystem.prototype, "direction2", {
+            /**
+             * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
+             * This only works when particleEmitterTyps is a BoxParticleEmitter
+             */
+            get: function () {
+                if (this.particleEmitterType.direction2) {
+                    return this.particleEmitterType.direction2;
+                }
+                return BABYLON.Vector3.Zero();
+            },
+            set: function (value) {
+                if (this.particleEmitterType.direction2) {
+                    this.particleEmitterType.direction2 = value;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(ParticleSystem.prototype, "minEmitBox", {
+            /**
+             * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
+             * This only works when particleEmitterTyps is a BoxParticleEmitter
+             */
+            get: function () {
+                if (this.particleEmitterType.minEmitBox) {
+                    return this.particleEmitterType.minEmitBox;
+                }
+                return BABYLON.Vector3.Zero();
+            },
+            set: function (value) {
+                if (this.particleEmitterType.minEmitBox) {
+                    this.particleEmitterType.minEmitBox = value;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(ParticleSystem.prototype, "maxEmitBox", {
+            /**
+             * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
+             * This only works when particleEmitterTyps is a BoxParticleEmitter
+             */
+            get: function () {
+                if (this.particleEmitterType.maxEmitBox) {
+                    return this.particleEmitterType.maxEmitBox;
+                }
+                return BABYLON.Vector3.Zero();
+            },
+            set: function (value) {
+                if (this.particleEmitterType.maxEmitBox) {
+                    this.particleEmitterType.maxEmitBox = value;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(ParticleSystem.prototype, "onDispose", {
         Object.defineProperty(ParticleSystem.prototype, "onDispose", {
             /**
             /**
              * Sets a callback that will be triggered when the system is disposed.
              * Sets a callback that will be triggered when the system is disposed.
@@ -50974,13 +51034,14 @@ var BABYLON;
         };
         };
         /**
         /**
          * Renders the particle system in its current state.
          * Renders the particle system in its current state.
-         * @returns the current number of particles.
+         * @returns the current number of particles
          */
          */
         ParticleSystem.prototype.render = function () {
         ParticleSystem.prototype.render = function () {
             var effect = this._getEffect();
             var effect = this._getEffect();
             // Check
             // Check
-            if (!this.emitter || !effect.isReady() || !this.particleTexture || !this.particleTexture.isReady() || !this._particles.length)
+            if (!this.emitter || !effect.isReady() || !this.particleTexture || !this.particleTexture.isReady() || !this._particles.length) {
                 return 0;
                 return 0;
+            }
             var engine = this._scene.getEngine();
             var engine = this._scene.getEngine();
             // Render
             // Render
             engine.enableEffect(effect);
             engine.enableEffect(effect);
@@ -51091,7 +51152,7 @@ var BABYLON;
          * @returns the emitter
          * @returns the emitter
          */
          */
         ParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
         ParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
-            var particleEmitter = new BABYLON.BoxParticleEmitter(this);
+            var particleEmitter = new BABYLON.BoxParticleEmitter();
             this.direction1 = direction1;
             this.direction1 = direction1;
             this.direction2 = direction2;
             this.direction2 = direction2;
             this.minEmitBox = minEmitBox;
             this.minEmitBox = minEmitBox;
@@ -51290,75 +51351,25 @@ var BABYLON;
         // all property should be come public variables and passed through constructor.
         // all property should be come public variables and passed through constructor.
         /**
         /**
          * Creates a new instance of @see BoxParticleEmitter
          * Creates a new instance of @see BoxParticleEmitter
-         * @param _particleSystem the particle system associated with the emitter
          */
          */
-        function BoxParticleEmitter(_particleSystem) {
-            this._particleSystem = _particleSystem;
-        }
-        Object.defineProperty(BoxParticleEmitter.prototype, "direction1", {
-            /**
-             * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
-             */
-            get: function () {
-                return this._particleSystem.direction1;
-            },
+        function BoxParticleEmitter() {
             /**
             /**
              * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
              * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
              */
              */
-            set: function (value) {
-                this._particleSystem.direction1 = value;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(BoxParticleEmitter.prototype, "direction2", {
-            /**
-             * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
-             */
-            get: function () {
-                return this._particleSystem.direction2;
-            },
+            this.direction1 = new BABYLON.Vector3(0, 1.0, 0);
             /**
             /**
              * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
              * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
              */
              */
-            set: function (value) {
-                this._particleSystem.direction2 = value;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(BoxParticleEmitter.prototype, "minEmitBox", {
-            /**
-             * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
-             */
-            get: function () {
-                return this._particleSystem.minEmitBox;
-            },
+            this.direction2 = new BABYLON.Vector3(0, 1.0, 0);
             /**
             /**
              * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
              * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
              */
              */
-            set: function (value) {
-                this._particleSystem.minEmitBox = value;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(BoxParticleEmitter.prototype, "maxEmitBox", {
-            /**
-             * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
-             */
-            get: function () {
-                return this._particleSystem.maxEmitBox;
-            },
+            this.minEmitBox = new BABYLON.Vector3(-0.5, -0.5, -0.5);
             /**
             /**
              * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
              * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
              */
              */
-            set: function (value) {
-                this._particleSystem.maxEmitBox = value;
-            },
-            enumerable: true,
-            configurable: true
-        });
+            this.maxEmitBox = new BABYLON.Vector3(0.5, 0.5, 0.5);
+        }
         /**
         /**
          * Called by the particle System when the direction is computed for the created particle.
          * Called by the particle System when the direction is computed for the created particle.
          * @param emitPower is the power of the particle (speed)
          * @param emitPower is the power of the particle (speed)
@@ -51389,10 +51400,16 @@ var BABYLON;
          * @returns the new emitter
          * @returns the new emitter
          */
          */
         BoxParticleEmitter.prototype.clone = function () {
         BoxParticleEmitter.prototype.clone = function () {
-            var newOne = new BoxParticleEmitter(this._particleSystem);
+            var newOne = new BoxParticleEmitter();
             BABYLON.Tools.DeepCopy(this, newOne);
             BABYLON.Tools.DeepCopy(this, newOne);
             return newOne;
             return newOne;
         };
         };
+        /**
+         * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
+         * @param effect defines the update shader
+         */
+        BoxParticleEmitter.prototype.applyToShader = function (effect) {
+        };
         return BoxParticleEmitter;
         return BoxParticleEmitter;
     }());
     }());
     BABYLON.BoxParticleEmitter = BoxParticleEmitter;
     BABYLON.BoxParticleEmitter = BoxParticleEmitter;
@@ -51501,6 +51518,12 @@ var BABYLON;
             BABYLON.Tools.DeepCopy(this, newOne);
             BABYLON.Tools.DeepCopy(this, newOne);
             return newOne;
             return newOne;
         };
         };
+        /**
+         * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
+         * @param effect defines the update shader
+         */
+        ConeParticleEmitter.prototype.applyToShader = function (effect) {
+        };
         return ConeParticleEmitter;
         return ConeParticleEmitter;
     }());
     }());
     BABYLON.ConeParticleEmitter = ConeParticleEmitter;
     BABYLON.ConeParticleEmitter = ConeParticleEmitter;
@@ -51575,6 +51598,12 @@ var BABYLON;
             BABYLON.Tools.DeepCopy(this, newOne);
             BABYLON.Tools.DeepCopy(this, newOne);
             return newOne;
             return newOne;
         };
         };
+        /**
+         * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
+         * @param effect defines the update shader
+         */
+        SphereParticleEmitter.prototype.applyToShader = function (effect) {
+        };
         return SphereParticleEmitter;
         return SphereParticleEmitter;
     }());
     }());
     BABYLON.SphereParticleEmitter = SphereParticleEmitter;
     BABYLON.SphereParticleEmitter = SphereParticleEmitter;
@@ -51626,6 +51655,12 @@ var BABYLON;
             BABYLON.Tools.DeepCopy(this, newOne);
             BABYLON.Tools.DeepCopy(this, newOne);
             return newOne;
             return newOne;
         };
         };
+        /**
+         * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
+         * @param effect defines the update shader
+         */
+        SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
+        };
         return SphereDirectedParticleEmitter;
         return SphereDirectedParticleEmitter;
     }(SphereParticleEmitter));
     }(SphereParticleEmitter));
     BABYLON.SphereDirectedParticleEmitter = SphereDirectedParticleEmitter;
     BABYLON.SphereDirectedParticleEmitter = SphereDirectedParticleEmitter;
@@ -51635,7 +51670,7 @@ var BABYLON;
 
 
 
 
 
 
-//# sourceMappingURL=babylon.iParticleEmitterType.js.map
+//# sourceMappingURL=babylon.IParticleEmitterType.js.map
 
 
 var BABYLON;
 var BABYLON;
 (function (BABYLON) {
 (function (BABYLON) {

+ 114 - 79
dist/preview release/customConfigurations/minimalGLTFViewer/es6.js

@@ -50527,22 +50527,6 @@ var BABYLON;
              */
              */
             this.gravity = BABYLON.Vector3.Zero();
             this.gravity = BABYLON.Vector3.Zero();
             /**
             /**
-             * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
-             */
-            this.direction1 = new BABYLON.Vector3(0, 1.0, 0);
-            /**
-             * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
-             */
-            this.direction2 = new BABYLON.Vector3(0, 1.0, 0);
-            /**
-             * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
-             */
-            this.minEmitBox = new BABYLON.Vector3(-0.5, -0.5, -0.5);
-            /**
-             * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
-             */
-            this.maxEmitBox = new BABYLON.Vector3(0.5, 0.5, 0.5);
-            /**
              * Random color of each particle after it has been emitted, between color1 and color2 vectors.
              * Random color of each particle after it has been emitted, between color1 and color2 vectors.
              */
              */
             this.color1 = new BABYLON.Color4(1.0, 1.0, 1.0, 1.0);
             this.color1 = new BABYLON.Color4(1.0, 1.0, 1.0, 1.0);
@@ -50625,8 +50609,8 @@ var BABYLON;
             this._vertexBuffers[BABYLON.VertexBuffer.PositionKind] = positions;
             this._vertexBuffers[BABYLON.VertexBuffer.PositionKind] = positions;
             this._vertexBuffers[BABYLON.VertexBuffer.ColorKind] = colors;
             this._vertexBuffers[BABYLON.VertexBuffer.ColorKind] = colors;
             this._vertexBuffers["options"] = options;
             this._vertexBuffers["options"] = options;
-            // Default behaviors
-            this.particleEmitterType = new BABYLON.BoxParticleEmitter(this);
+            // Default emitter type
+            this.particleEmitterType = new BABYLON.BoxParticleEmitter();
             this.updateFunction = function (particles) {
             this.updateFunction = function (particles) {
                 for (var index = 0; index < particles.length; index++) {
                 for (var index = 0; index < particles.length; index++) {
                     var particle = particles[index];
                     var particle = particles[index];
@@ -50653,6 +50637,82 @@ var BABYLON;
                 }
                 }
             };
             };
         }
         }
+        Object.defineProperty(ParticleSystem.prototype, "direction1", {
+            /**
+              * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
+              * This only works when particleEmitterTyps is a BoxParticleEmitter
+              */
+            get: function () {
+                if (this.particleEmitterType.direction1) {
+                    return this.particleEmitterType.direction1;
+                }
+                return BABYLON.Vector3.Zero();
+            },
+            set: function (value) {
+                if (this.particleEmitterType.direction1) {
+                    this.particleEmitterType.direction1 = value;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(ParticleSystem.prototype, "direction2", {
+            /**
+             * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
+             * This only works when particleEmitterTyps is a BoxParticleEmitter
+             */
+            get: function () {
+                if (this.particleEmitterType.direction2) {
+                    return this.particleEmitterType.direction2;
+                }
+                return BABYLON.Vector3.Zero();
+            },
+            set: function (value) {
+                if (this.particleEmitterType.direction2) {
+                    this.particleEmitterType.direction2 = value;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(ParticleSystem.prototype, "minEmitBox", {
+            /**
+             * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
+             * This only works when particleEmitterTyps is a BoxParticleEmitter
+             */
+            get: function () {
+                if (this.particleEmitterType.minEmitBox) {
+                    return this.particleEmitterType.minEmitBox;
+                }
+                return BABYLON.Vector3.Zero();
+            },
+            set: function (value) {
+                if (this.particleEmitterType.minEmitBox) {
+                    this.particleEmitterType.minEmitBox = value;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(ParticleSystem.prototype, "maxEmitBox", {
+            /**
+             * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
+             * This only works when particleEmitterTyps is a BoxParticleEmitter
+             */
+            get: function () {
+                if (this.particleEmitterType.maxEmitBox) {
+                    return this.particleEmitterType.maxEmitBox;
+                }
+                return BABYLON.Vector3.Zero();
+            },
+            set: function (value) {
+                if (this.particleEmitterType.maxEmitBox) {
+                    this.particleEmitterType.maxEmitBox = value;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(ParticleSystem.prototype, "onDispose", {
         Object.defineProperty(ParticleSystem.prototype, "onDispose", {
             /**
             /**
              * Sets a callback that will be triggered when the system is disposed.
              * Sets a callback that will be triggered when the system is disposed.
@@ -50960,13 +51020,14 @@ var BABYLON;
         };
         };
         /**
         /**
          * Renders the particle system in its current state.
          * Renders the particle system in its current state.
-         * @returns the current number of particles.
+         * @returns the current number of particles
          */
          */
         ParticleSystem.prototype.render = function () {
         ParticleSystem.prototype.render = function () {
             var effect = this._getEffect();
             var effect = this._getEffect();
             // Check
             // Check
-            if (!this.emitter || !effect.isReady() || !this.particleTexture || !this.particleTexture.isReady() || !this._particles.length)
+            if (!this.emitter || !effect.isReady() || !this.particleTexture || !this.particleTexture.isReady() || !this._particles.length) {
                 return 0;
                 return 0;
+            }
             var engine = this._scene.getEngine();
             var engine = this._scene.getEngine();
             // Render
             // Render
             engine.enableEffect(effect);
             engine.enableEffect(effect);
@@ -51077,7 +51138,7 @@ var BABYLON;
          * @returns the emitter
          * @returns the emitter
          */
          */
         ParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
         ParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
-            var particleEmitter = new BABYLON.BoxParticleEmitter(this);
+            var particleEmitter = new BABYLON.BoxParticleEmitter();
             this.direction1 = direction1;
             this.direction1 = direction1;
             this.direction2 = direction2;
             this.direction2 = direction2;
             this.minEmitBox = minEmitBox;
             this.minEmitBox = minEmitBox;
@@ -51276,75 +51337,25 @@ var BABYLON;
         // all property should be come public variables and passed through constructor.
         // all property should be come public variables and passed through constructor.
         /**
         /**
          * Creates a new instance of @see BoxParticleEmitter
          * Creates a new instance of @see BoxParticleEmitter
-         * @param _particleSystem the particle system associated with the emitter
          */
          */
-        function BoxParticleEmitter(_particleSystem) {
-            this._particleSystem = _particleSystem;
-        }
-        Object.defineProperty(BoxParticleEmitter.prototype, "direction1", {
-            /**
-             * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
-             */
-            get: function () {
-                return this._particleSystem.direction1;
-            },
+        function BoxParticleEmitter() {
             /**
             /**
              * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
              * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
              */
              */
-            set: function (value) {
-                this._particleSystem.direction1 = value;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(BoxParticleEmitter.prototype, "direction2", {
-            /**
-             * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
-             */
-            get: function () {
-                return this._particleSystem.direction2;
-            },
+            this.direction1 = new BABYLON.Vector3(0, 1.0, 0);
             /**
             /**
              * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
              * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
              */
              */
-            set: function (value) {
-                this._particleSystem.direction2 = value;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(BoxParticleEmitter.prototype, "minEmitBox", {
-            /**
-             * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
-             */
-            get: function () {
-                return this._particleSystem.minEmitBox;
-            },
+            this.direction2 = new BABYLON.Vector3(0, 1.0, 0);
             /**
             /**
              * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
              * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
              */
              */
-            set: function (value) {
-                this._particleSystem.minEmitBox = value;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(BoxParticleEmitter.prototype, "maxEmitBox", {
-            /**
-             * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
-             */
-            get: function () {
-                return this._particleSystem.maxEmitBox;
-            },
+            this.minEmitBox = new BABYLON.Vector3(-0.5, -0.5, -0.5);
             /**
             /**
              * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
              * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
              */
              */
-            set: function (value) {
-                this._particleSystem.maxEmitBox = value;
-            },
-            enumerable: true,
-            configurable: true
-        });
+            this.maxEmitBox = new BABYLON.Vector3(0.5, 0.5, 0.5);
+        }
         /**
         /**
          * Called by the particle System when the direction is computed for the created particle.
          * Called by the particle System when the direction is computed for the created particle.
          * @param emitPower is the power of the particle (speed)
          * @param emitPower is the power of the particle (speed)
@@ -51375,10 +51386,16 @@ var BABYLON;
          * @returns the new emitter
          * @returns the new emitter
          */
          */
         BoxParticleEmitter.prototype.clone = function () {
         BoxParticleEmitter.prototype.clone = function () {
-            var newOne = new BoxParticleEmitter(this._particleSystem);
+            var newOne = new BoxParticleEmitter();
             BABYLON.Tools.DeepCopy(this, newOne);
             BABYLON.Tools.DeepCopy(this, newOne);
             return newOne;
             return newOne;
         };
         };
+        /**
+         * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
+         * @param effect defines the update shader
+         */
+        BoxParticleEmitter.prototype.applyToShader = function (effect) {
+        };
         return BoxParticleEmitter;
         return BoxParticleEmitter;
     }());
     }());
     BABYLON.BoxParticleEmitter = BoxParticleEmitter;
     BABYLON.BoxParticleEmitter = BoxParticleEmitter;
@@ -51487,6 +51504,12 @@ var BABYLON;
             BABYLON.Tools.DeepCopy(this, newOne);
             BABYLON.Tools.DeepCopy(this, newOne);
             return newOne;
             return newOne;
         };
         };
+        /**
+         * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
+         * @param effect defines the update shader
+         */
+        ConeParticleEmitter.prototype.applyToShader = function (effect) {
+        };
         return ConeParticleEmitter;
         return ConeParticleEmitter;
     }());
     }());
     BABYLON.ConeParticleEmitter = ConeParticleEmitter;
     BABYLON.ConeParticleEmitter = ConeParticleEmitter;
@@ -51561,6 +51584,12 @@ var BABYLON;
             BABYLON.Tools.DeepCopy(this, newOne);
             BABYLON.Tools.DeepCopy(this, newOne);
             return newOne;
             return newOne;
         };
         };
+        /**
+         * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
+         * @param effect defines the update shader
+         */
+        SphereParticleEmitter.prototype.applyToShader = function (effect) {
+        };
         return SphereParticleEmitter;
         return SphereParticleEmitter;
     }());
     }());
     BABYLON.SphereParticleEmitter = SphereParticleEmitter;
     BABYLON.SphereParticleEmitter = SphereParticleEmitter;
@@ -51612,6 +51641,12 @@ var BABYLON;
             BABYLON.Tools.DeepCopy(this, newOne);
             BABYLON.Tools.DeepCopy(this, newOne);
             return newOne;
             return newOne;
         };
         };
+        /**
+         * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
+         * @param effect defines the update shader
+         */
+        SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
+        };
         return SphereDirectedParticleEmitter;
         return SphereDirectedParticleEmitter;
     }(SphereParticleEmitter));
     }(SphereParticleEmitter));
     BABYLON.SphereDirectedParticleEmitter = SphereDirectedParticleEmitter;
     BABYLON.SphereDirectedParticleEmitter = SphereDirectedParticleEmitter;
@@ -51621,7 +51656,7 @@ var BABYLON;
 
 
 
 
 
 
-//# sourceMappingURL=babylon.iParticleEmitterType.js.map
+//# sourceMappingURL=babylon.IParticleEmitterType.js.map
 
 
 var BABYLON;
 var BABYLON;
 (function (BABYLON) {
 (function (BABYLON) {

File diff ditekan karena terlalu besar
+ 153 - 95
dist/preview release/es6.js


File diff ditekan karena terlalu besar
+ 23 - 23
dist/preview release/viewer/babylon.viewer.js


+ 11 - 0
src/Particles/babylon.iParticleEmitterType.ts

@@ -26,5 +26,16 @@ module BABYLON {
          * @returns the new emitter
          * @returns the new emitter
          */
          */
         clone(): IParticleEmitterType;
         clone(): IParticleEmitterType;
+
+        /**
+         * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
+         * @param effect defines the update shader
+         */
+        applyToShader(effect: Effect): void;
+
+        /**
+         * Returns a string to use to update the GPU particles update shader
+         */
+        getEffectDefines(): string;
     }
     }
 }
 }

+ 23 - 44
src/Particles/babylon.boxParticleEmitter.ts

@@ -8,62 +8,25 @@ module BABYLON {
         /**
         /**
          * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
          * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
          */
          */
-        public get direction1(): Vector3 {
-            return this._particleSystem.direction1;
-        }
+        public direction1 = new Vector3(0, 1.0, 0);
         /**
         /**
          * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
          * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
          */
          */
-        public set direction1(value: Vector3) {
-            this._particleSystem.direction1 = value;
-        }
-
-        /**
-         * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
-         */
-        public get direction2(): Vector3 {
-            return this._particleSystem.direction2;
-        }
-        /**
-         * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
-         */
-        public set direction2(value: Vector3) {
-            this._particleSystem.direction2 = value;
-        }
+        public direction2 = new Vector3(0, 1.0, 0);
 
 
         /**
         /**
          * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
          * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
          */
          */
-        public get minEmitBox(): Vector3 {
-            return this._particleSystem.minEmitBox;
-        }
-        /**
-         * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
-         */
-        public set minEmitBox(value: Vector3) {
-            this._particleSystem.minEmitBox = value;
-        }
-
+        public minEmitBox = new Vector3(-0.5, -0.5, -0.5);
         /**
         /**
          * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
          * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
          */
          */
-        public get maxEmitBox(): Vector3 {
-            return this._particleSystem.maxEmitBox;
-        }
-        /**
-         * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
-         */
-        public set maxEmitBox(value: Vector3) {
-            this._particleSystem.maxEmitBox = value;
-        }
-        
-        // to be updated like the rest of emitters when breaking changes.
-        // all property should be come public variables and passed through constructor.
+        public maxEmitBox = new Vector3(0.5, 0.5, 0.5);  
+               
         /**
         /**
          * Creates a new instance of @see BoxParticleEmitter
          * Creates a new instance of @see BoxParticleEmitter
-         * @param _particleSystem the particle system associated with the emitter
          */
          */
-        constructor(private _particleSystem: ParticleSystem) {
+        constructor() {
 
 
         }
         }
 
 
@@ -102,11 +65,27 @@ module BABYLON {
          */
          */
         public clone(): BoxParticleEmitter
         public clone(): BoxParticleEmitter
         {
         {
-            let newOne = new BoxParticleEmitter(this._particleSystem);
+            let newOne = new BoxParticleEmitter();
 
 
             Tools.DeepCopy(this, newOne);
             Tools.DeepCopy(this, newOne);
 
 
             return newOne;
             return newOne;
         }
         }
+
+        /**
+         * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
+         * @param effect defines the update shader
+         */        
+        public applyToShader(effect: Effect): void {            
+            effect.setVector3("direction1", this.direction1);
+            effect.setVector3("direction2", this.direction2);
+        }
+
+        /**
+         * Returns a string to use to update the GPU particles update shader
+         */
+        public getEffectDefines(): string {
+            return "#define BOXEMITTER"
+        }
     }
     }
 }
 }

+ 16 - 1
src/Particles/babylon.coneParticleEmitter.ts

@@ -103,6 +103,21 @@ module BABYLON {
             Tools.DeepCopy(this, newOne);
             Tools.DeepCopy(this, newOne);
 
 
             return newOne;
             return newOne;
-        }          
+        }        
+        
+        /**
+         * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
+         * @param effect defines the update shader
+         */        
+        public applyToShader(effect: Effect): void {
+            
+        }
+
+        /**
+         * Returns a string to use to update the GPU particles update shader
+         */
+        public getEffectDefines(): string {
+            return "#define CONEEMITTER"
+        }        
     }
     }
 }
 }

+ 30 - 0
src/Particles/babylon.sphereParticleEmitter.ts

@@ -67,6 +67,21 @@ module BABYLON {
             Tools.DeepCopy(this, newOne);
             Tools.DeepCopy(this, newOne);
 
 
             return newOne;
             return newOne;
+        }    
+        
+        /**
+         * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
+         * @param effect defines the update shader
+         */        
+        public applyToShader(effect: Effect): void {
+            
+        }    
+        
+        /**
+         * Returns a string to use to update the GPU particles update shader
+         */
+        public getEffectDefines(): string {
+            return "#define SPHEREEMITTER"
         }        
         }        
     }
     }
 
 
@@ -118,6 +133,21 @@ module BABYLON {
             Tools.DeepCopy(this, newOne);
             Tools.DeepCopy(this, newOne);
 
 
             return newOne;
             return newOne;
+        }     
+        
+        /**
+         * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
+         * @param effect defines the update shader
+         */        
+        public applyToShader(effect: Effect): void {
+            
+        }       
+        
+        /**
+         * Returns a string to use to update the GPU particles update shader
+         */
+        public getEffectDefines(): string {
+            return "#define SPHEREEMITTER"
         }          
         }          
     }
     }
 }
 }

+ 65 - 21
src/Particles/babylon.gpuParticleSystem.ts

@@ -56,6 +56,14 @@
         private _randomTexture: RawTexture;
         private _randomTexture: RawTexture;
 
 
         private readonly _attributesStrideSize = 14;
         private readonly _attributesStrideSize = 14;
+        private _updateEffectOptions: EffectCreationOptions;
+
+        public static get IsSupported(): boolean {
+            if (!Engine.LastCreatedEngine) {
+                return false;
+            }
+            return Engine.LastCreatedEngine.webGLVersion > 1;
+        }
 
 
         /**
         /**
         * An event triggered when the system is disposed.
         * An event triggered when the system is disposed.
@@ -120,6 +128,12 @@
         public gravity = Vector3.Zero();    
         public gravity = Vector3.Zero();    
 
 
         /**
         /**
+         * The particle emitter type defines the emitter used by the particle system.
+         * It can be for example box, sphere, or cone...
+         */
+        public particleEmitterType: IParticleEmitterType;        
+
+        /**
          * Gets the maximum number of particles supported by this system
          * Gets the maximum number of particles supported by this system
          */
          */
         public get capacity(): number {
         public get capacity(): number {
@@ -166,20 +180,30 @@
          * @param capacity The max number of particles alive at the same time
          * @param capacity The max number of particles alive at the same time
          * @param scene The scene the particle system belongs to
          * @param scene The scene the particle system belongs to
          */
          */
-        constructor(name: string, capacity: number, scene: Scene) {
+        constructor(name: string, options: Partial<{
+                        capacity: number,
+                        randomTextureSize: number
+                    }>, scene: Scene) {
             this.id = name;
             this.id = name;
             this.name = name;
             this.name = name;
             this._scene = scene || Engine.LastCreatedScene;
             this._scene = scene || Engine.LastCreatedScene;
-            this._capacity = capacity;
-            this._activeCount = capacity;
-            this._currentActiveCount = 0;
             this._engine = this._scene.getEngine();
             this._engine = this._scene.getEngine();
 
 
+            let fullOptions = {
+                capacity: 50000,
+                randomTextureSize: this._engine.getCaps().maxTextureSize,
+                ...options
+            };
+
+            this._capacity = fullOptions.capacity;
+            this._activeCount = fullOptions.capacity;
+            this._currentActiveCount = 0;
+
             this._scene.particleSystems.push(this);
             this._scene.particleSystems.push(this);
 
 
-            let updateEffectOptions: EffectCreationOptions = {
+            this._updateEffectOptions = {
                 attributes: ["position", "age", "life", "seed", "size", "color", "direction"],
                 attributes: ["position", "age", "life", "seed", "size", "color", "direction"],
-                uniformsNames: ["currentCount", "timeDelta", "generalRandom", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "gravity"],
+                uniformsNames: ["currentCount", "timeDelta", "generalRandoms", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "gravity", "direction1", "direction2"],
                 uniformBuffersNames: [],
                 uniformBuffersNames: [],
                 samplers:["randomSampler"],
                 samplers:["randomSampler"],
                 defines: "",
                 defines: "",
@@ -191,12 +215,12 @@
                 transformFeedbackVaryings: ["outPosition", "outAge", "outLife", "outSeed", "outSize", "outColor", "outDirection"]
                 transformFeedbackVaryings: ["outPosition", "outAge", "outLife", "outSeed", "outSize", "outColor", "outDirection"]
             };
             };
 
 
-            this._updateEffect = new Effect("gpuUpdateParticles", updateEffectOptions, this._scene.getEngine());   
+            this._updateEffect = new Effect("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());   
 
 
             this._renderEffect = new Effect("gpuRenderParticles", ["position", "age", "life", "size", "color", "offset", "uv"], ["view", "projection", "colorDead"], ["textureSampler"], this._scene.getEngine());
             this._renderEffect = new Effect("gpuRenderParticles", ["position", "age", "life", "size", "color", "offset", "uv"], ["view", "projection", "colorDead"], ["textureSampler"], this._scene.getEngine());
 
 
             // Random data
             // Random data
-            var maxTextureSize = this._engine.getCaps().maxTextureSize;
+            var maxTextureSize = Math.min(this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
             var d = [];
             var d = [];
             for (var i = 0; i < maxTextureSize; ++i) {
             for (var i = 0; i < maxTextureSize; ++i) {
                 d.push(Math.random());
                 d.push(Math.random());
@@ -206,17 +230,15 @@
             this._randomTexture = new RawTexture(new Float32Array(d), maxTextureSize, 1, Engine.TEXTUREFORMAT_RGB32F, this._scene, false, false, Texture.NEAREST_SAMPLINGMODE, Engine.TEXTURETYPE_FLOAT)
             this._randomTexture = new RawTexture(new Float32Array(d), maxTextureSize, 1, Engine.TEXTUREFORMAT_RGB32F, this._scene, false, false, Texture.NEAREST_SAMPLINGMODE, Engine.TEXTURETYPE_FLOAT)
             this._randomTexture.wrapU = Texture.WRAP_ADDRESSMODE;
             this._randomTexture.wrapU = Texture.WRAP_ADDRESSMODE;
             this._randomTexture.wrapV = Texture.WRAP_ADDRESSMODE;
             this._randomTexture.wrapV = Texture.WRAP_ADDRESSMODE;
+
+            // Default emitter type
+            this.particleEmitterType = new BoxParticleEmitter();            
         }
         }
 
 
         /**
         /**
          * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
          * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
          */
          */
         public animate(): void {
         public animate(): void {
-            if (this._currentRenderId === this._scene.getRenderId()) {
-                return;
-            }
-
-            this._currentRenderId = this._scene.getRenderId();
             this._timeDelta = this.updateSpeed * this._scene.getAnimationRatio();               
             this._timeDelta = this.updateSpeed * this._scene.getAnimationRatio();               
         }
         }
 
 
@@ -253,8 +275,8 @@
             return vao;
             return vao;
         }        
         }        
         
         
-        private _initialize(): void {
-            if (this._buffer0) {
+        private _initialize(force = false): void {
+            if (this._buffer0 && !force) {
                 return;
                 return;
             }
             }
 
 
@@ -312,27 +334,47 @@
             this._targetBuffer = this._buffer1;
             this._targetBuffer = this._buffer1;
 
 
         }
         }
+
+        /** @ignore */
+        public _recreateUpdateEffect(defines: string) {
+            if (this._updateEffectOptions.defines === defines) {
+                return;
+            }
+            this._updateEffectOptions.defines = defines;
+            this._updateEffect = new Effect("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());   
+        }
+
         /**
         /**
          * Renders the particle system in its current state.
          * Renders the particle system in its current state.
-         * @returns the current number of particles.
+         * @returns the current number of particles
          */
          */
         public render(): number {
         public render(): number {
+            this._recreateUpdateEffect(this.particleEmitterType.getEffectDefines());
+
             if (!this.emitter || !this._updateEffect.isReady() || !this._renderEffect.isReady() ) {
             if (!this.emitter || !this._updateEffect.isReady() || !this._renderEffect.isReady() ) {
                 return 0;
                 return 0;
             }
             }
 
 
+            if (this._currentRenderId === this._scene.getRenderId()) {
+                return 0;
+            }
+
+            this._currentRenderId = this._scene.getRenderId();
+            
+
             // Get everything ready to render
             // Get everything ready to render
             this. _initialize();
             this. _initialize();
 
 
             this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + this.emitRate);
             this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + this.emitRate);
             
             
             // Enable update effect
             // Enable update effect
+
             this._engine.enableEffect(this._updateEffect);
             this._engine.enableEffect(this._updateEffect);
             this._engine.setState(false);    
             this._engine.setState(false);    
             
             
             this._updateEffect.setFloat("currentCount", this._currentActiveCount);
             this._updateEffect.setFloat("currentCount", this._currentActiveCount);
             this._updateEffect.setFloat("timeDelta", this._timeDelta);
             this._updateEffect.setFloat("timeDelta", this._timeDelta);
-            this._updateEffect.setFloat("generalRandom", Math.random());
+            this._updateEffect.setFloat2("generalRandoms", Math.random(), Math.random());
             this._updateEffect.setTexture("randomSampler", this._randomTexture);
             this._updateEffect.setTexture("randomSampler", this._randomTexture);
             this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
             this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
             this._updateEffect.setDirectColor4("color1", this.color1);
             this._updateEffect.setDirectColor4("color1", this.color1);
@@ -340,6 +382,8 @@
             this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
             this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
             this._updateEffect.setVector3("gravity", this.gravity);
             this._updateEffect.setVector3("gravity", this.gravity);
 
 
+            this.particleEmitterType.applyToShader(this._updateEffect);
+
             let emitterWM: Matrix;
             let emitterWM: Matrix;
             if ((<AbstractMesh>this.emitter).position) {
             if ((<AbstractMesh>this.emitter).position) {
                 var emitterMesh = (<AbstractMesh>this.emitter);
                 var emitterMesh = (<AbstractMesh>this.emitter);
@@ -392,16 +436,16 @@
             // Switch buffers
             // Switch buffers
             let tmpBuffer = this._sourceBuffer;
             let tmpBuffer = this._sourceBuffer;
             this._sourceBuffer = this._targetBuffer;
             this._sourceBuffer = this._targetBuffer;
-            this._targetBuffer = tmpBuffer;            
-
-            return 0;
+            this._targetBuffer = tmpBuffer;     
+            
+            return this._currentActiveCount;
         }
         }
 
 
         /**
         /**
          * Rebuilds the particle system
          * Rebuilds the particle system
          */
          */
         public rebuild(): void {
         public rebuild(): void {
-            
+            this._initialize(true);
         }
         }
 
 
         /**
         /**

+ 66 - 11
src/Particles/babylon.particleSystem.ts

@@ -36,7 +36,7 @@
         animate(): void;
         animate(): void;
         /**
         /**
          * Renders the particle system in its current state.
          * Renders the particle system in its current state.
-         * @returns the current number of particles.
+         * @returns the current number of particles
          */
          */
         render(): number;
         render(): number;
         /**
         /**
@@ -213,23 +213,77 @@
          */
          */
         public gravity = Vector3.Zero();
         public gravity = Vector3.Zero();
 
 
-        /**
+       /**
          * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
          * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
+         * This only works when particleEmitterTyps is a BoxParticleEmitter
          */
          */
-        public direction1 = new Vector3(0, 1.0, 0);
+        public get direction1(): Vector3 {
+            if ((<BoxParticleEmitter>this.particleEmitterType).direction1) {
+                return (<BoxParticleEmitter>this.particleEmitterType).direction1;
+            }
+
+            return Vector3.Zero();
+        }
+
+        public set direction1(value: Vector3) {
+            if ((<BoxParticleEmitter>this.particleEmitterType).direction1) {
+                (<BoxParticleEmitter>this.particleEmitterType).direction1 = value;
+            }
+        }
+
         /**
         /**
          * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
          * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
+         * This only works when particleEmitterTyps is a BoxParticleEmitter
          */
          */
-        public direction2 = new Vector3(0, 1.0, 0);
+        public get direction2(): Vector3 {
+            if ((<BoxParticleEmitter>this.particleEmitterType).direction2) {
+                return (<BoxParticleEmitter>this.particleEmitterType).direction2;
+            }
+
+            return Vector3.Zero();
+        }
+
+        public set direction2(value: Vector3) {
+            if ((<BoxParticleEmitter>this.particleEmitterType).direction2) {
+                (<BoxParticleEmitter>this.particleEmitterType).direction2 = value;
+            }
+        }
 
 
         /**
         /**
          * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
          * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
+         * This only works when particleEmitterTyps is a BoxParticleEmitter
          */
          */
-        public minEmitBox = new Vector3(-0.5, -0.5, -0.5);
+        public get minEmitBox(): Vector3 {
+            if ((<BoxParticleEmitter>this.particleEmitterType).minEmitBox) {
+                return (<BoxParticleEmitter>this.particleEmitterType).minEmitBox;
+            }
+
+            return Vector3.Zero();
+        }
+
+        public set minEmitBox(value: Vector3) {
+            if ((<BoxParticleEmitter>this.particleEmitterType).minEmitBox) {
+                (<BoxParticleEmitter>this.particleEmitterType).minEmitBox = value;
+            }
+        }
+
         /**
         /**
          * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
          * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
+         * This only works when particleEmitterTyps is a BoxParticleEmitter
          */
          */
-        public maxEmitBox = new Vector3(0.5, 0.5, 0.5);
+        public get maxEmitBox(): Vector3 {
+            if ((<BoxParticleEmitter>this.particleEmitterType).maxEmitBox) {
+                return (<BoxParticleEmitter>this.particleEmitterType).maxEmitBox;
+            }
+
+            return Vector3.Zero();
+        }
+
+        public set maxEmitBox(value: Vector3) {
+            if ((<BoxParticleEmitter>this.particleEmitterType).maxEmitBox) {
+                (<BoxParticleEmitter>this.particleEmitterType).maxEmitBox = value;
+            }
+        }
 
 
         /**
         /**
          * Random color of each particle after it has been emitted, between color1 and color2 vectors.
          * Random color of each particle after it has been emitted, between color1 and color2 vectors.
@@ -387,8 +441,8 @@
             this._vertexBuffers[VertexBuffer.ColorKind] = colors;
             this._vertexBuffers[VertexBuffer.ColorKind] = colors;
             this._vertexBuffers["options"] = options;
             this._vertexBuffers["options"] = options;
 
 
-            // Default behaviors
-            this.particleEmitterType = new BoxParticleEmitter(this);
+            // Default emitter type
+            this.particleEmitterType = new BoxParticleEmitter();
 
 
             this.updateFunction = (particles: Particle[]): void => {
             this.updateFunction = (particles: Particle[]): void => {
                 for (var index = 0; index < particles.length; index++) {
                 for (var index = 0; index < particles.length; index++) {
@@ -767,14 +821,15 @@
 
 
         /**
         /**
          * Renders the particle system in its current state.
          * Renders the particle system in its current state.
-         * @returns the current number of particles.
+         * @returns the current number of particles
          */
          */
         public render(): number {
         public render(): number {
             var effect = this._getEffect();
             var effect = this._getEffect();
 
 
             // Check
             // Check
-            if (!this.emitter || !effect.isReady() || !this.particleTexture || !this.particleTexture.isReady() || !this._particles.length)
+            if (!this.emitter || !effect.isReady() || !this.particleTexture || !this.particleTexture.isReady() || !this._particles.length) {
                 return 0;
                 return 0;
+            }
 
 
             var engine = this._scene.getEngine();
             var engine = this._scene.getEngine();
 
 
@@ -898,7 +953,7 @@
          * @returns the emitter
          * @returns the emitter
          */
          */
         public createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter {
         public createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter {
-            var particleEmitter = new BoxParticleEmitter(this);
+            var particleEmitter = new BoxParticleEmitter();
             this.direction1 = direction1;
             this.direction1 = direction1;
             this.direction2 = direction2;
             this.direction2 = direction2;
             this.minEmitBox = minEmitBox;
             this.minEmitBox = minEmitBox;

+ 12 - 2
src/Shaders/gpuUpdateParticles.vertex.fx

@@ -2,7 +2,7 @@
 
 
 uniform float currentCount;
 uniform float currentCount;
 uniform float timeDelta;
 uniform float timeDelta;
-uniform float generalRandom;
+uniform vec2 generalRandoms;
 uniform mat4 emitterWM;
 uniform mat4 emitterWM;
 uniform vec2 lifeTime;
 uniform vec2 lifeTime;
 uniform vec2 sizeRange;
 uniform vec2 sizeRange;
@@ -11,6 +11,11 @@ uniform vec4 color2;
 uniform vec3 gravity;
 uniform vec3 gravity;
 uniform sampler2D randomSampler;
 uniform sampler2D randomSampler;
 
 
+#ifdef BOXEMITTER
+uniform vec3 direction1;
+uniform vec3 direction2;
+#endif
+
 // Particles state
 // Particles state
 in vec3 position;
 in vec3 position;
 in float age;
 in float age;
@@ -39,7 +44,8 @@ void main() {
     outPosition = (emitterWM * vec4(0., 0., 0., 1.)).xyz;
     outPosition = (emitterWM * vec4(0., 0., 0., 1.)).xyz;
 
 
     // Let's get some random values
     // Let's get some random values
-    vec3 randoms = getRandomVec3(generalRandom);
+    vec3 randoms = getRandomVec3(generalRandoms.x);
+    vec3 randoms2 = getRandomVec3(generalRandoms.y);
 
 
     // Age and life
     // Age and life
     outAge = 0.0;
     outAge = 0.0;
@@ -55,7 +61,11 @@ void main() {
     outColor = color1 + (color2 - color1) * randoms.b;
     outColor = color1 + (color2 - color1) * randoms.b;
 
 
     // Direction
     // Direction
+#ifdef BOXEMITTER
+    outDirection = direction1 + (direction2 - direction1) * randoms2;
+#else    
     outDirection = 2.0 * (getRandomVec3(seed) - vec3(0.5, 0.5, 0.5));
     outDirection = 2.0 * (getRandomVec3(seed) - vec3(0.5, 0.5, 0.5));
+#endif
   } else {   
   } else {   
     outPosition = position + (direction + gravity) * timeDelta;
     outPosition = position + (direction + gravity) * timeDelta;
     outAge = age + timeDelta;
     outAge = age + timeDelta;