Procházet zdrojové kódy

Opening more tools from ParticleHelper

David Catuhe před 7 roky
rodič
revize
64ca6a81a3

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 41387
Playground/babylon.d.txt


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 14852 - 14847
dist/preview release/babylon.d.ts


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
dist/preview release/babylon.js


+ 16 - 13
dist/preview release/babylon.max.js

@@ -100620,35 +100620,38 @@ var BABYLON;
          * @returns the ParticleSystem created.
          */
         ParticleHelper.CreateAsync = function (type, emitter, scene, gpu) {
-            var _this = this;
             if (scene === void 0) { scene = BABYLON.Engine.LastCreatedScene; }
             if (gpu === void 0) { gpu = false; }
             return new Promise(function (resolve, reject) {
-                if (scene) {
-                    _this._scene = scene;
-                }
-                else {
-                    return reject("A particle system need a scene.");
+                if (!scene) {
+                    scene = BABYLON.Engine.LastCreatedScene;
+                    ;
                 }
                 if (gpu && !BABYLON.GPUParticleSystem.IsSupported) {
                     return reject("Particle system with GPU is not supported.");
                 }
-                _this._emitter = emitter;
-                BABYLON.Tools.LoadFile(_this._baseAssetsUrl + "/systems/" + type + ".json", function (data, response) {
+                BABYLON.Tools.LoadFile(ParticleHelper._baseAssetsUrl + "/systems/" + type + ".json", function (data, response) {
                     var newData = JSON.parse(data.toString());
-                    return resolve(_this._createSystem(newData));
+                    return resolve(ParticleHelper.CreateSystem(newData, scene, emitter));
                 }, undefined, undefined, undefined, function (req, exception) {
                     return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
                 });
             });
         };
-        ParticleHelper._createSystem = function (data) {
+        /**
+         * Static function used to create a new particle system from a IParticleSystemData
+         * @param data defines the source data
+         * @param scene defines the hosting scene
+         * @param emitter defines the particle emitter
+         * @returns a new ParticleSystem based on referenced data
+         */
+        ParticleHelper.CreateSystem = function (data, scene, emitter) {
             // Create a particle system
-            var system = new BABYLON.ParticleSystem(data.type, data.capacity, this._scene);
+            var system = new BABYLON.ParticleSystem(data.type, data.capacity, scene);
             // Texture of each particle
-            system.particleTexture = new BABYLON.Texture(this._baseAssetsUrl + "/textures/" + data.textureFile, this._scene);
+            system.particleTexture = new BABYLON.Texture(ParticleHelper._baseAssetsUrl + "/textures/" + data.textureFile, scene);
             // Where the particles come from
-            system.emitter = this._emitter; // the starting object, the emitter
+            system.emitter = emitter; // the starting object, the emitter
             // Colors of all particles
             system.color1 = new BABYLON.Color4(data.color1.r, data.color1.g, data.color1.b, data.color1.a);
             system.color2 = new BABYLON.Color4(data.color2.r, data.color2.g, data.color2.b, data.color2.a);

+ 16 - 13
dist/preview release/babylon.no-module.max.js

@@ -100587,35 +100587,38 @@ var BABYLON;
          * @returns the ParticleSystem created.
          */
         ParticleHelper.CreateAsync = function (type, emitter, scene, gpu) {
-            var _this = this;
             if (scene === void 0) { scene = BABYLON.Engine.LastCreatedScene; }
             if (gpu === void 0) { gpu = false; }
             return new Promise(function (resolve, reject) {
-                if (scene) {
-                    _this._scene = scene;
-                }
-                else {
-                    return reject("A particle system need a scene.");
+                if (!scene) {
+                    scene = BABYLON.Engine.LastCreatedScene;
+                    ;
                 }
                 if (gpu && !BABYLON.GPUParticleSystem.IsSupported) {
                     return reject("Particle system with GPU is not supported.");
                 }
-                _this._emitter = emitter;
-                BABYLON.Tools.LoadFile(_this._baseAssetsUrl + "/systems/" + type + ".json", function (data, response) {
+                BABYLON.Tools.LoadFile(ParticleHelper._baseAssetsUrl + "/systems/" + type + ".json", function (data, response) {
                     var newData = JSON.parse(data.toString());
-                    return resolve(_this._createSystem(newData));
+                    return resolve(ParticleHelper.CreateSystem(newData, scene, emitter));
                 }, undefined, undefined, undefined, function (req, exception) {
                     return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
                 });
             });
         };
-        ParticleHelper._createSystem = function (data) {
+        /**
+         * Static function used to create a new particle system from a IParticleSystemData
+         * @param data defines the source data
+         * @param scene defines the hosting scene
+         * @param emitter defines the particle emitter
+         * @returns a new ParticleSystem based on referenced data
+         */
+        ParticleHelper.CreateSystem = function (data, scene, emitter) {
             // Create a particle system
-            var system = new BABYLON.ParticleSystem(data.type, data.capacity, this._scene);
+            var system = new BABYLON.ParticleSystem(data.type, data.capacity, scene);
             // Texture of each particle
-            system.particleTexture = new BABYLON.Texture(this._baseAssetsUrl + "/textures/" + data.textureFile, this._scene);
+            system.particleTexture = new BABYLON.Texture(ParticleHelper._baseAssetsUrl + "/textures/" + data.textureFile, scene);
             // Where the particles come from
-            system.emitter = this._emitter; // the starting object, the emitter
+            system.emitter = emitter; // the starting object, the emitter
             // Colors of all particles
             system.color1 = new BABYLON.Color4(data.color1.r, data.color1.g, data.color1.b, data.color1.a);
             system.color2 = new BABYLON.Color4(data.color2.r, data.color2.g, data.color2.b, data.color2.a);

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
dist/preview release/babylon.worker.js


+ 16 - 13
dist/preview release/es6.js

@@ -100587,35 +100587,38 @@ var BABYLON;
          * @returns the ParticleSystem created.
          */
         ParticleHelper.CreateAsync = function (type, emitter, scene, gpu) {
-            var _this = this;
             if (scene === void 0) { scene = BABYLON.Engine.LastCreatedScene; }
             if (gpu === void 0) { gpu = false; }
             return new Promise(function (resolve, reject) {
-                if (scene) {
-                    _this._scene = scene;
-                }
-                else {
-                    return reject("A particle system need a scene.");
+                if (!scene) {
+                    scene = BABYLON.Engine.LastCreatedScene;
+                    ;
                 }
                 if (gpu && !BABYLON.GPUParticleSystem.IsSupported) {
                     return reject("Particle system with GPU is not supported.");
                 }
-                _this._emitter = emitter;
-                BABYLON.Tools.LoadFile(_this._baseAssetsUrl + "/systems/" + type + ".json", function (data, response) {
+                BABYLON.Tools.LoadFile(ParticleHelper._baseAssetsUrl + "/systems/" + type + ".json", function (data, response) {
                     var newData = JSON.parse(data.toString());
-                    return resolve(_this._createSystem(newData));
+                    return resolve(ParticleHelper.CreateSystem(newData, scene, emitter));
                 }, undefined, undefined, undefined, function (req, exception) {
                     return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
                 });
             });
         };
-        ParticleHelper._createSystem = function (data) {
+        /**
+         * Static function used to create a new particle system from a IParticleSystemData
+         * @param data defines the source data
+         * @param scene defines the hosting scene
+         * @param emitter defines the particle emitter
+         * @returns a new ParticleSystem based on referenced data
+         */
+        ParticleHelper.CreateSystem = function (data, scene, emitter) {
             // Create a particle system
-            var system = new BABYLON.ParticleSystem(data.type, data.capacity, this._scene);
+            var system = new BABYLON.ParticleSystem(data.type, data.capacity, scene);
             // Texture of each particle
-            system.particleTexture = new BABYLON.Texture(this._baseAssetsUrl + "/textures/" + data.textureFile, this._scene);
+            system.particleTexture = new BABYLON.Texture(ParticleHelper._baseAssetsUrl + "/textures/" + data.textureFile, scene);
             // Where the particles come from
-            system.emitter = this._emitter; // the starting object, the emitter
+            system.emitter = emitter; // the starting object, the emitter
             // Colors of all particles
             system.color1 = new BABYLON.Color4(data.color1.r, data.color1.g, data.color1.b, data.color1.a);
             system.color2 = new BABYLON.Color4(data.color2.r, data.color2.g, data.color2.b, data.color2.a);

+ 17 - 1
dist/preview release/gui/babylon.gui.d.ts

@@ -2252,9 +2252,25 @@ declare module BABYLON.GUI {
 
 declare module BABYLON.GUI {
     /**
+     * Class used as a root to all buttons
+     */
+    class AbstractButton3D extends Control3D {
+        /**
+         * Creates a new button
+         * @param name defines the control name
+         */
+        constructor(name?: string);
+        protected _getTypeName(): string;
+        protected _createNode(scene: Scene): TransformNode;
+    }
+}
+
+
+declare module BABYLON.GUI {
+    /**
      * Class used to create a button in 3D
      */
-    class Button3D extends Control3D {
+    class Button3D extends AbstractButton3D {
         /** @hidden */
         protected _currentMaterial: Material;
         private _facadeTexture;

+ 35 - 1
dist/preview release/gui/babylon.gui.js

@@ -6587,6 +6587,9 @@ var BABYLON;
                         this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
                         delete this._lastControlDown[pointerEvent.pointerId];
                     }
+                    if (pointerEvent.pointerType === "touch") {
+                        this._handlePointerOut(pointerId, false);
+                    }
                 }
                 return true;
             };
@@ -7478,6 +7481,37 @@ var BABYLON;
     var GUI;
     (function (GUI) {
         /**
+         * Class used as a root to all buttons
+         */
+        var AbstractButton3D = /** @class */ (function (_super) {
+            __extends(AbstractButton3D, _super);
+            /**
+             * Creates a new button
+             * @param name defines the control name
+             */
+            function AbstractButton3D(name) {
+                return _super.call(this, name) || this;
+            }
+            AbstractButton3D.prototype._getTypeName = function () {
+                return "AbstractButton3D";
+            };
+            // Mesh association
+            AbstractButton3D.prototype._createNode = function (scene) {
+                return new BABYLON.TransformNode("button" + this.name);
+            };
+            return AbstractButton3D;
+        }(GUI.Control3D));
+        GUI.AbstractButton3D = AbstractButton3D;
+    })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
+})(BABYLON || (BABYLON = {}));
+
+/// <reference path="../../../../dist/preview release/babylon.d.ts"/>
+
+var BABYLON;
+(function (BABYLON) {
+    var GUI;
+    (function (GUI) {
+        /**
          * Class used to create a button in 3D
          */
         var Button3D = /** @class */ (function (_super) {
@@ -7626,7 +7660,7 @@ var BABYLON;
                 }
             };
             return Button3D;
-        }(GUI.Control3D));
+        }(GUI.AbstractButton3D));
         GUI.Button3D = Button3D;
     })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
 })(BABYLON || (BABYLON = {}));

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 2 - 2
dist/preview release/gui/babylon.gui.min.js


+ 17 - 1
dist/preview release/gui/babylon.gui.module.d.ts

@@ -2257,9 +2257,25 @@ declare module BABYLON.GUI {
 
 declare module BABYLON.GUI {
     /**
+     * Class used as a root to all buttons
+     */
+    class AbstractButton3D extends Control3D {
+        /**
+         * Creates a new button
+         * @param name defines the control name
+         */
+        constructor(name?: string);
+        protected _getTypeName(): string;
+        protected _createNode(scene: Scene): TransformNode;
+    }
+}
+
+
+declare module BABYLON.GUI {
+    /**
      * Class used to create a button in 3D
      */
-    class Button3D extends Control3D {
+    class Button3D extends AbstractButton3D {
         /** @hidden */
         protected _currentMaterial: Material;
         private _facadeTexture;

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
dist/preview release/viewer/babylon.viewer.js


+ 16 - 13
dist/preview release/viewer/babylon.viewer.max.js

@@ -100708,35 +100708,38 @@ var BABYLON;
          * @returns the ParticleSystem created.
          */
         ParticleHelper.CreateAsync = function (type, emitter, scene, gpu) {
-            var _this = this;
             if (scene === void 0) { scene = BABYLON.Engine.LastCreatedScene; }
             if (gpu === void 0) { gpu = false; }
             return new Promise(function (resolve, reject) {
-                if (scene) {
-                    _this._scene = scene;
-                }
-                else {
-                    return reject("A particle system need a scene.");
+                if (!scene) {
+                    scene = BABYLON.Engine.LastCreatedScene;
+                    ;
                 }
                 if (gpu && !BABYLON.GPUParticleSystem.IsSupported) {
                     return reject("Particle system with GPU is not supported.");
                 }
-                _this._emitter = emitter;
-                BABYLON.Tools.LoadFile(_this._baseAssetsUrl + "/systems/" + type + ".json", function (data, response) {
+                BABYLON.Tools.LoadFile(ParticleHelper._baseAssetsUrl + "/systems/" + type + ".json", function (data, response) {
                     var newData = JSON.parse(data.toString());
-                    return resolve(_this._createSystem(newData));
+                    return resolve(ParticleHelper.CreateSystem(newData, scene, emitter));
                 }, undefined, undefined, undefined, function (req, exception) {
                     return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
                 });
             });
         };
-        ParticleHelper._createSystem = function (data) {
+        /**
+         * Static function used to create a new particle system from a IParticleSystemData
+         * @param data defines the source data
+         * @param scene defines the hosting scene
+         * @param emitter defines the particle emitter
+         * @returns a new ParticleSystem based on referenced data
+         */
+        ParticleHelper.CreateSystem = function (data, scene, emitter) {
             // Create a particle system
-            var system = new BABYLON.ParticleSystem(data.type, data.capacity, this._scene);
+            var system = new BABYLON.ParticleSystem(data.type, data.capacity, scene);
             // Texture of each particle
-            system.particleTexture = new BABYLON.Texture(this._baseAssetsUrl + "/textures/" + data.textureFile, this._scene);
+            system.particleTexture = new BABYLON.Texture(ParticleHelper._baseAssetsUrl + "/textures/" + data.textureFile, scene);
             // Where the particles come from
-            system.emitter = this._emitter; // the starting object, the emitter
+            system.emitter = emitter; // the starting object, the emitter
             // Colors of all particles
             system.color1 = new BABYLON.Color4(data.color1.r, data.color1.g, data.color1.b, data.color1.a);
             system.color2 = new BABYLON.Color4(data.color2.r, data.color2.g, data.color2.b, data.color2.a);

+ 15 - 16
src/Helpers/babylon.particleHelper.ts

@@ -113,10 +113,6 @@ module BABYLON {
          */
         private static _baseAssetsUrl = "https://assets.babylonjs.com/particles";
 
-        private static _scene: Scene;
-
-        private static _emitter: AbstractMesh;
-
         /**
          * This is the main static method (one-liner) of this helper to create different particle systems.
          * @param type This string represents the type to the particle system to create
@@ -129,21 +125,17 @@ module BABYLON {
                                    scene: Nullable<Scene> = Engine.LastCreatedScene, gpu: boolean = false): Promise<ParticleSystem> {
             
             return new Promise((resolve, reject) => {
-                if (scene) {
-                    this._scene = scene;
-                } else {
-                    return reject("A particle system need a scene.");
+                if (!scene) {
+                    scene = Engine.LastCreatedScene;;
                 }
 
                 if (gpu && !GPUParticleSystem.IsSupported) {
                     return reject("Particle system with GPU is not supported.");
                 }
 
-                this._emitter = emitter;
-
-                Tools.LoadFile(`${this._baseAssetsUrl}/systems/${type}.json`, (data, response) => {
+                Tools.LoadFile(`${ParticleHelper._baseAssetsUrl}/systems/${type}.json`, (data, response) => {
                     const newData = JSON.parse(data.toString()) as IParticleSystemData;
-                    return resolve(this._createSystem(newData));
+                    return resolve(ParticleHelper.CreateSystem(newData, scene!, emitter));
                 }, undefined, undefined, undefined, (req, exception) => {
                     return reject(`An error occured while the creation of your particle system. Check if your type '${type}' exists.`);
                 });
@@ -151,13 +143,20 @@ module BABYLON {
             });
         }
 
-        private static _createSystem(data: IParticleSystemData): ParticleSystem {
+        /**
+         * Static function used to create a new particle system from a IParticleSystemData
+         * @param data defines the source data
+         * @param scene defines the hosting scene
+         * @param emitter defines the particle emitter
+         * @returns a new ParticleSystem based on referenced data
+         */
+        public static CreateSystem(data: IParticleSystemData, scene: Scene, emitter: AbstractMesh): ParticleSystem {
             // Create a particle system
-            const system = new ParticleSystem(data.type, data.capacity, this._scene);
+            const system = new ParticleSystem(data.type, data.capacity, scene);
             // Texture of each particle
-            system.particleTexture = new Texture(`${this._baseAssetsUrl}/textures/${data.textureFile}`, this._scene);
+            system.particleTexture = new Texture(`${ParticleHelper._baseAssetsUrl}/textures/${data.textureFile}`, scene);
             // Where the particles come from
-            system.emitter = this._emitter; // the starting object, the emitter
+            system.emitter = emitter; // the starting object, the emitter
 
             // Colors of all particles
             system.color1 = new Color4(data.color1.r, data.color1.g, data.color1.b, data.color1.a);