소스 검색

Move emitter to sub folder

David Catuhe 7 년 전
부모
커밋
8dbe50e011

+ 7 - 6
Tools/Gulp/config.json

@@ -272,10 +272,10 @@
             "files": [
                 "../../src/Particles/babylon.particle.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": [
                 "core"
@@ -287,10 +287,11 @@
         },
         "gpuParticles": {
             "files": [
-                "../../src/Particles/babylon.gpuParticleSystem.js"
+                "../../src/Particles/babylon.gpuParticleSystem.js"          
             ],
             "dependUpon": [
-                "core"
+                "core",
+                "particles"
             ],
             "shaders": [
                 "gpuRenderParticles.vertex",

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 15609 - 15585
dist/preview release/babylon.d.ts


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 23 - 23
dist/preview release/babylon.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 153 - 95
dist/preview release/babylon.max.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 23 - 23
dist/preview release/babylon.worker.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 11907 - 11883
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 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();
             /**
-             * 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.
              */
             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.ColorKind] = colors;
             this._vertexBuffers["options"] = options;
-            // Default behaviors
-            this.particleEmitterType = new BABYLON.BoxParticleEmitter(this);
+            // Default emitter type
+            this.particleEmitterType = new BABYLON.BoxParticleEmitter();
             this.updateFunction = function (particles) {
                 for (var index = 0; index < particles.length; 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", {
             /**
              * 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.
-         * @returns the current number of particles.
+         * @returns the current number of particles
          */
         ParticleSystem.prototype.render = function () {
             var effect = this._getEffect();
             // 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;
+            }
             var engine = this._scene.getEngine();
             // Render
             engine.enableEffect(effect);
@@ -51091,7 +51152,7 @@ var BABYLON;
          * @returns the emitter
          */
         ParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
-            var particleEmitter = new BABYLON.BoxParticleEmitter(this);
+            var particleEmitter = new BABYLON.BoxParticleEmitter();
             this.direction1 = direction1;
             this.direction2 = direction2;
             this.minEmitBox = minEmitBox;
@@ -51290,75 +51351,25 @@ var BABYLON;
         // all property should be come public variables and passed through constructor.
         /**
          * 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.
              */
-            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.
              */
-            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.
              */
-            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.
              */
-            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.
          * @param emitPower is the power of the particle (speed)
@@ -51389,10 +51400,16 @@ var BABYLON;
          * @returns the new emitter
          */
         BoxParticleEmitter.prototype.clone = function () {
-            var newOne = new BoxParticleEmitter(this._particleSystem);
+            var newOne = new BoxParticleEmitter();
             BABYLON.Tools.DeepCopy(this, 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;
     }());
     BABYLON.BoxParticleEmitter = BoxParticleEmitter;
@@ -51501,6 +51518,12 @@ var BABYLON;
             BABYLON.Tools.DeepCopy(this, 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;
     }());
     BABYLON.ConeParticleEmitter = ConeParticleEmitter;
@@ -51575,6 +51598,12 @@ var BABYLON;
             BABYLON.Tools.DeepCopy(this, 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;
     }());
     BABYLON.SphereParticleEmitter = SphereParticleEmitter;
@@ -51626,6 +51655,12 @@ var BABYLON;
             BABYLON.Tools.DeepCopy(this, 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;
     }(SphereParticleEmitter));
     BABYLON.SphereDirectedParticleEmitter = SphereDirectedParticleEmitter;
@@ -51635,7 +51670,7 @@ var BABYLON;
 
 
 
-//# sourceMappingURL=babylon.iParticleEmitterType.js.map
+//# sourceMappingURL=babylon.IParticleEmitterType.js.map
 
 var BABYLON;
 (function (BABYLON) {

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

@@ -50527,22 +50527,6 @@ var BABYLON;
              */
             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.
              */
             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.ColorKind] = colors;
             this._vertexBuffers["options"] = options;
-            // Default behaviors
-            this.particleEmitterType = new BABYLON.BoxParticleEmitter(this);
+            // Default emitter type
+            this.particleEmitterType = new BABYLON.BoxParticleEmitter();
             this.updateFunction = function (particles) {
                 for (var index = 0; index < particles.length; 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", {
             /**
              * 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.
-         * @returns the current number of particles.
+         * @returns the current number of particles
          */
         ParticleSystem.prototype.render = function () {
             var effect = this._getEffect();
             // 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;
+            }
             var engine = this._scene.getEngine();
             // Render
             engine.enableEffect(effect);
@@ -51077,7 +51138,7 @@ var BABYLON;
          * @returns the emitter
          */
         ParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
-            var particleEmitter = new BABYLON.BoxParticleEmitter(this);
+            var particleEmitter = new BABYLON.BoxParticleEmitter();
             this.direction1 = direction1;
             this.direction2 = direction2;
             this.minEmitBox = minEmitBox;
@@ -51276,75 +51337,25 @@ var BABYLON;
         // all property should be come public variables and passed through constructor.
         /**
          * 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.
              */
-            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.
              */
-            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.
              */
-            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.
              */
-            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.
          * @param emitPower is the power of the particle (speed)
@@ -51375,10 +51386,16 @@ var BABYLON;
          * @returns the new emitter
          */
         BoxParticleEmitter.prototype.clone = function () {
-            var newOne = new BoxParticleEmitter(this._particleSystem);
+            var newOne = new BoxParticleEmitter();
             BABYLON.Tools.DeepCopy(this, 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;
     }());
     BABYLON.BoxParticleEmitter = BoxParticleEmitter;
@@ -51487,6 +51504,12 @@ var BABYLON;
             BABYLON.Tools.DeepCopy(this, 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;
     }());
     BABYLON.ConeParticleEmitter = ConeParticleEmitter;
@@ -51561,6 +51584,12 @@ var BABYLON;
             BABYLON.Tools.DeepCopy(this, 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;
     }());
     BABYLON.SphereParticleEmitter = SphereParticleEmitter;
@@ -51612,6 +51641,12 @@ var BABYLON;
             BABYLON.Tools.DeepCopy(this, 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;
     }(SphereParticleEmitter));
     BABYLON.SphereDirectedParticleEmitter = SphereDirectedParticleEmitter;
@@ -51621,7 +51656,7 @@ var BABYLON;
 
 
 
-//# sourceMappingURL=babylon.iParticleEmitterType.js.map
+//# sourceMappingURL=babylon.IParticleEmitterType.js.map
 
 var BABYLON;
 (function (BABYLON) {

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 153 - 95
dist/preview release/es6.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 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
          */
         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.
          */
-        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.
          */
-        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.
          */
-        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.
          */
-        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
-         * @param _particleSystem the particle system associated with the emitter
          */
-        constructor(private _particleSystem: ParticleSystem) {
+        constructor() {
 
         }
 
@@ -102,11 +65,27 @@ module BABYLON {
          */
         public clone(): BoxParticleEmitter
         {
-            let newOne = new BoxParticleEmitter(this._particleSystem);
+            let newOne = new BoxParticleEmitter();
 
             Tools.DeepCopy(this, 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);
 
             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);
 
             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);
 
             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 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.
@@ -120,6 +128,12 @@
         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
          */
         public get capacity(): number {
@@ -166,20 +180,30 @@
          * @param capacity The max number of particles alive at the same time
          * @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.name = name;
             this._scene = scene || Engine.LastCreatedScene;
-            this._capacity = capacity;
-            this._activeCount = capacity;
-            this._currentActiveCount = 0;
             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);
 
-            let updateEffectOptions: EffectCreationOptions = {
+            this._updateEffectOptions = {
                 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: [],
                 samplers:["randomSampler"],
                 defines: "",
@@ -191,12 +215,12 @@
                 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());
 
             // Random data
-            var maxTextureSize = this._engine.getCaps().maxTextureSize;
+            var maxTextureSize = Math.min(this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
             var d = [];
             for (var i = 0; i < maxTextureSize; ++i) {
                 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.wrapU = 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.
          */
         public animate(): void {
-            if (this._currentRenderId === this._scene.getRenderId()) {
-                return;
-            }
-
-            this._currentRenderId = this._scene.getRenderId();
             this._timeDelta = this.updateSpeed * this._scene.getAnimationRatio();               
         }
 
@@ -253,8 +275,8 @@
             return vao;
         }        
         
-        private _initialize(): void {
-            if (this._buffer0) {
+        private _initialize(force = false): void {
+            if (this._buffer0 && !force) {
                 return;
             }
 
@@ -312,27 +334,47 @@
             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.
-         * @returns the current number of particles.
+         * @returns the current number of particles
          */
         public render(): number {
+            this._recreateUpdateEffect(this.particleEmitterType.getEffectDefines());
+
             if (!this.emitter || !this._updateEffect.isReady() || !this._renderEffect.isReady() ) {
                 return 0;
             }
 
+            if (this._currentRenderId === this._scene.getRenderId()) {
+                return 0;
+            }
+
+            this._currentRenderId = this._scene.getRenderId();
+            
+
             // Get everything ready to render
             this. _initialize();
 
             this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + this.emitRate);
             
             // Enable update effect
+
             this._engine.enableEffect(this._updateEffect);
             this._engine.setState(false);    
             
             this._updateEffect.setFloat("currentCount", this._currentActiveCount);
             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.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
             this._updateEffect.setDirectColor4("color1", this.color1);
@@ -340,6 +382,8 @@
             this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
             this._updateEffect.setVector3("gravity", this.gravity);
 
+            this.particleEmitterType.applyToShader(this._updateEffect);
+
             let emitterWM: Matrix;
             if ((<AbstractMesh>this.emitter).position) {
                 var emitterMesh = (<AbstractMesh>this.emitter);
@@ -392,16 +436,16 @@
             // Switch buffers
             let tmpBuffer = this._sourceBuffer;
             this._sourceBuffer = this._targetBuffer;
-            this._targetBuffer = tmpBuffer;            
-
-            return 0;
+            this._targetBuffer = tmpBuffer;     
+            
+            return this._currentActiveCount;
         }
 
         /**
          * Rebuilds the particle system
          */
         public rebuild(): void {
-            
+            this._initialize(true);
         }
 
         /**

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

@@ -36,7 +36,7 @@
         animate(): void;
         /**
          * Renders the particle system in its current state.
-         * @returns the current number of particles.
+         * @returns the current number of particles
          */
         render(): number;
         /**
@@ -213,23 +213,77 @@
          */
         public gravity = Vector3.Zero();
 
-        /**
+       /**
          * 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.
+         * 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.
+         * 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.
+         * 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.
@@ -387,8 +441,8 @@
             this._vertexBuffers[VertexBuffer.ColorKind] = colors;
             this._vertexBuffers["options"] = options;
 
-            // Default behaviors
-            this.particleEmitterType = new BoxParticleEmitter(this);
+            // Default emitter type
+            this.particleEmitterType = new BoxParticleEmitter();
 
             this.updateFunction = (particles: Particle[]): void => {
                 for (var index = 0; index < particles.length; index++) {
@@ -767,14 +821,15 @@
 
         /**
          * Renders the particle system in its current state.
-         * @returns the current number of particles.
+         * @returns the current number of particles
          */
         public render(): number {
             var effect = this._getEffect();
 
             // 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;
+            }
 
             var engine = this._scene.getEngine();
 
@@ -898,7 +953,7 @@
          * @returns the emitter
          */
         public createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter {
-            var particleEmitter = new BoxParticleEmitter(this);
+            var particleEmitter = new BoxParticleEmitter();
             this.direction1 = direction1;
             this.direction2 = direction2;
             this.minEmitBox = minEmitBox;

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

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