|
@@ -24208,6 +24208,8 @@ var BABYLON;
|
|
|
this._doubleClickOccured = false;
|
|
|
/** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
|
|
|
this.cameraToUseForPointers = null;
|
|
|
+ this._pointerX = 0;
|
|
|
+ this._pointerY = 0;
|
|
|
this._startingPointerPosition = new BABYLON.Vector2(0, 0);
|
|
|
this._previousStartingPointerPosition = new BABYLON.Vector2(0, 0);
|
|
|
this._startingPointerTime = 0;
|
|
@@ -56451,6 +56453,8 @@ var BABYLON;
|
|
|
// Animations
|
|
|
BABYLON.Animation.AppendSerializedAnimations(particleSystem, serializationObject);
|
|
|
// Particle system
|
|
|
+ serializationObject.renderingGroupId = particleSystem.renderingGroupId;
|
|
|
+ serializationObject.isBillboardBased = particleSystem.isBillboardBased;
|
|
|
serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
|
|
|
serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
|
|
|
serializationObject.minSize = particleSystem.minSize;
|
|
@@ -56510,12 +56514,22 @@ var BABYLON;
|
|
|
particleSystem.particleTexture.name = parsedParticleSystem.textureName;
|
|
|
}
|
|
|
// Emitter
|
|
|
- if (parsedParticleSystem.emitterId) {
|
|
|
+ if (parsedParticleSystem.emitterId === undefined) {
|
|
|
+ particleSystem.emitter = BABYLON.Vector3.Zero();
|
|
|
+ }
|
|
|
+ else if (parsedParticleSystem.emitterId) {
|
|
|
particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
|
|
|
}
|
|
|
else {
|
|
|
particleSystem.emitter = BABYLON.Vector3.FromArray(parsedParticleSystem.emitter);
|
|
|
}
|
|
|
+ // Misc.
|
|
|
+ if (parsedParticleSystem.renderingGroupId !== undefined) {
|
|
|
+ particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
|
|
|
+ }
|
|
|
+ if (parsedParticleSystem.isBillboardBased !== undefined) {
|
|
|
+ particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
|
|
|
+ }
|
|
|
// Animations
|
|
|
if (parsedParticleSystem.animations) {
|
|
|
for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
|
|
@@ -56573,7 +56587,7 @@ var BABYLON;
|
|
|
var emitterType;
|
|
|
if (parsedParticleSystem.particleEmitterType) {
|
|
|
switch (parsedParticleSystem.particleEmitterType.type) {
|
|
|
- case "SphereEmitter":
|
|
|
+ case "SphereParticleEmitter":
|
|
|
emitterType = new BABYLON.SphereParticleEmitter();
|
|
|
break;
|
|
|
case "SphereDirectedParticleEmitter":
|
|
@@ -56899,7 +56913,7 @@ var BABYLON;
|
|
|
return "#define CONEEMITTER";
|
|
|
};
|
|
|
/**
|
|
|
- * Returns the string "BoxEmitter"
|
|
|
+ * Returns the string "ConeEmitter"
|
|
|
* @returns a string containing the class name
|
|
|
*/
|
|
|
ConeParticleEmitter.prototype.getClassName = function () {
|
|
@@ -57037,6 +57051,7 @@ var BABYLON;
|
|
|
var serializationObject = {};
|
|
|
serializationObject.type = this.getClassName();
|
|
|
serializationObject.radius = this.radius;
|
|
|
+ serializationObject.radiusRange = this.radiusRange;
|
|
|
serializationObject.directionRandomizer = this.directionRandomizer;
|
|
|
return serializationObject;
|
|
|
};
|
|
@@ -57046,6 +57061,7 @@ var BABYLON;
|
|
|
*/
|
|
|
SphereParticleEmitter.prototype.parse = function (serializationObject) {
|
|
|
this.radius = serializationObject.radius;
|
|
|
+ this.radiusRange = serializationObject.radiusRange;
|
|
|
this.directionRandomizer = serializationObject.directionRandomizer;
|
|
|
};
|
|
|
return SphereParticleEmitter;
|
|
@@ -102561,20 +102577,81 @@ var BABYLON;
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
|
/**
|
|
|
- * This class is made for on one-liner static method to help creating particle systems.
|
|
|
+ * Represents a set of particle systems working together to create a specific effect
|
|
|
+ */
|
|
|
+ var ParticleSystemSet = /** @class */ (function () {
|
|
|
+ function ParticleSystemSet() {
|
|
|
+ /**
|
|
|
+ * Gets or sets the particle system list
|
|
|
+ */
|
|
|
+ this.systems = new Array();
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Starts all particle systems of the set
|
|
|
+ * @param emitter defines an optional mesh to use as emitter for the particle systems
|
|
|
+ */
|
|
|
+ ParticleSystemSet.prototype.start = function (emitter) {
|
|
|
+ for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
|
|
|
+ var system = _a[_i];
|
|
|
+ if (emitter) {
|
|
|
+ system.emitter = emitter;
|
|
|
+ }
|
|
|
+ system.start();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Serialize the set into a JSON compatible object
|
|
|
+ * @returns a JSON compatible representation of the set
|
|
|
+ */
|
|
|
+ ParticleSystemSet.prototype.serialize = function () {
|
|
|
+ var result = {};
|
|
|
+ result.systems = [];
|
|
|
+ for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
|
|
|
+ var system = _a[_i];
|
|
|
+ result.systems.push(system.serialize());
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Parse a new ParticleSystemSet from a serialized source
|
|
|
+ * @param data defines a JSON compatible representation of the set
|
|
|
+ * @param scene defines the hosting scene
|
|
|
+ * @param gpu defines if we want GPU particles or CPU particles
|
|
|
+ * @returns a new ParticleSystemSet
|
|
|
+ */
|
|
|
+ ParticleSystemSet.Parse = function (data, scene, gpu) {
|
|
|
+ if (gpu === void 0) { gpu = false; }
|
|
|
+ var result = new ParticleSystemSet();
|
|
|
+ var rootUrl = BABYLON.ParticleHelper.BaseAssetsUrl + "/textures/";
|
|
|
+ for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
|
|
|
+ var system = _a[_i];
|
|
|
+ result.systems.push(gpu ? BABYLON.GPUParticleSystem.Parse(system, scene, rootUrl) : BABYLON.ParticleSystem.Parse(system, scene, rootUrl));
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+ return ParticleSystemSet;
|
|
|
+ }());
|
|
|
+ BABYLON.ParticleSystemSet = ParticleSystemSet;
|
|
|
+})(BABYLON || (BABYLON = {}));
|
|
|
+
|
|
|
+//# sourceMappingURL=babylon.particleSystemSet.js.map
|
|
|
+
|
|
|
+var BABYLON;
|
|
|
+(function (BABYLON) {
|
|
|
+ /**
|
|
|
+ * This class is made for on one-liner static method to help creating particle system set.
|
|
|
*/
|
|
|
var ParticleHelper = /** @class */ (function () {
|
|
|
function ParticleHelper() {
|
|
|
}
|
|
|
/**
|
|
|
- * This is the main static method (one-liner) of this helper to create different particle systems.
|
|
|
+ * 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
|
|
|
- * @param emitter The object where the particle system will start to emit from.
|
|
|
- * @param scene The scene where the particle system should live.
|
|
|
- * @param gpu If the system will use gpu.
|
|
|
- * @returns the ParticleSystem created.
|
|
|
+ * @param scene The scene where the particle system should live
|
|
|
+ * @param gpu If the system will use gpu
|
|
|
+ * @returns the ParticleSystemSet created
|
|
|
*/
|
|
|
- ParticleHelper.CreateAsync = function (type, emitter, scene, gpu) {
|
|
|
+ ParticleHelper.CreateAsync = function (type, scene, gpu) {
|
|
|
if (scene === void 0) { scene = BABYLON.Engine.LastCreatedScene; }
|
|
|
if (gpu === void 0) { gpu = false; }
|
|
|
return new Promise(function (resolve, reject) {
|
|
@@ -102585,160 +102662,31 @@ var BABYLON;
|
|
|
if (gpu && !BABYLON.GPUParticleSystem.IsSupported) {
|
|
|
return reject("Particle system with GPU is not supported.");
|
|
|
}
|
|
|
- BABYLON.Tools.LoadFile(ParticleHelper._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(ParticleHelper.CreateSystem(newData, scene, emitter));
|
|
|
+ return resolve(BABYLON.ParticleSystemSet.Parse(newData, scene, gpu));
|
|
|
}, undefined, undefined, undefined, function (req, exception) {
|
|
|
return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
/**
|
|
|
- * 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, scene);
|
|
|
- // Where the particles come from
|
|
|
- system.emitter = emitter; // the starting object, the emitter
|
|
|
- ParticleHelper.UpdateSystem(system, data, scene);
|
|
|
- return system;
|
|
|
- };
|
|
|
- /**
|
|
|
- * Static function used to update a particle system from a IParticleSystemData
|
|
|
- * @param system defines the particle system to update
|
|
|
- * @param data defines the source data
|
|
|
- * @param scene defines the hosting scene
|
|
|
- */
|
|
|
- ParticleHelper.UpdateSystem = function (system, data, scene) {
|
|
|
- // Texture of each particle
|
|
|
- if (data.textureFile) {
|
|
|
- system.particleTexture = new BABYLON.Texture(ParticleHelper._baseAssetsUrl + "/textures/" + data.textureFile, scene);
|
|
|
- }
|
|
|
- // 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);
|
|
|
- system.colorDead = new BABYLON.Color4(data.colorDead.r, data.colorDead.g, data.colorDead.b, data.colorDead.a);
|
|
|
- // Size of each particle (random between...
|
|
|
- system.minSize = data.minSize;
|
|
|
- system.maxSize = data.maxSize;
|
|
|
- system.minScaleX = data.minScaleX;
|
|
|
- system.maxScaleX = data.maxScaleX;
|
|
|
- system.minScaleY = data.minScaleY;
|
|
|
- system.maxScaleY = data.maxScaleY;
|
|
|
- // Life time of each particle (random between...
|
|
|
- system.minLifeTime = data.minLifeTime;
|
|
|
- system.maxLifeTime = data.maxLifeTime;
|
|
|
- // Emission rate
|
|
|
- system.emitRate = data.emitRate;
|
|
|
- // Blend mode : BLENDMODE_ONEONE, or BLENDMODE_STANDARD
|
|
|
- system.blendMode = data.blendMode;
|
|
|
- // Set the gravity of all particles
|
|
|
- system.gravity = new BABYLON.Vector3(data.gravity.x, data.gravity.y, data.gravity.z);
|
|
|
- // Angular speed, in radians
|
|
|
- system.minAngularSpeed = data.minAngularSpeed;
|
|
|
- system.maxAngularSpeed = data.maxAngularSpeed;
|
|
|
- // Speed
|
|
|
- system.minEmitPower = data.minEmitPower;
|
|
|
- system.maxEmitPower = data.maxEmitPower;
|
|
|
- system.updateSpeed = data.updateSpeed;
|
|
|
- switch (data.emitterType) {
|
|
|
- case "box":
|
|
|
- if (!data.direction1 || !data.direction2) {
|
|
|
- throw new Error("Directions are missing in this particle system.");
|
|
|
- }
|
|
|
- if (!data.minEmitBox || !data.maxEmitBox) {
|
|
|
- throw new Error("EmitBox is missing in this particle system.");
|
|
|
- }
|
|
|
- system.createBoxEmitter(new BABYLON.Vector3(data.direction1.x, data.direction1.y, data.direction1.z), new BABYLON.Vector3(data.direction2.x, data.direction2.y, data.direction2.z), new BABYLON.Vector3(data.minEmitBox.x, data.minEmitBox.y, data.minEmitBox.z), new BABYLON.Vector3(data.maxEmitBox.x, data.maxEmitBox.y, data.maxEmitBox.z));
|
|
|
- break;
|
|
|
- case "sphere":
|
|
|
- system.createSphereEmitter(data.radius);
|
|
|
- break;
|
|
|
- case "directed_sphere":
|
|
|
- if (!data.direction1 || !data.direction2) {
|
|
|
- throw new Error("Directions are missing in this particle system.");
|
|
|
- }
|
|
|
- system.createDirectedSphereEmitter(data.radius, new BABYLON.Vector3(data.direction1.x, data.direction1.y, data.direction1.z), new BABYLON.Vector3(data.direction2.x, data.direction2.y, data.direction2.z));
|
|
|
- break;
|
|
|
- case "cone":
|
|
|
- system.createConeEmitter(data.radius, data.angle);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- };
|
|
|
- /**
|
|
|
* Static function used to export a particle system to a IParticleSystemData variable.
|
|
|
* Please note that texture file name is not exported and must be added manually
|
|
|
* @param system defines the particle system to export
|
|
|
*/
|
|
|
- ParticleHelper.ExportSystem = function (system) {
|
|
|
- var outData = {};
|
|
|
- // Colors of all particles
|
|
|
- outData.color1 = { r: system.color1.r, g: system.color1.g, b: system.color1.b, a: system.color1.a };
|
|
|
- outData.color2 = { r: system.color2.r, g: system.color2.g, b: system.color2.b, a: system.color2.a };
|
|
|
- outData.colorDead = { r: system.colorDead.r, g: system.colorDead.g, b: system.colorDead.b, a: system.colorDead.a };
|
|
|
- // Size of each particle (random between...
|
|
|
- outData.minSize = system.minSize;
|
|
|
- outData.maxSize = system.maxSize;
|
|
|
- outData.minScaleX = system.minScaleX;
|
|
|
- outData.maxScaleX = system.maxScaleX;
|
|
|
- outData.minScaleY = system.minScaleY;
|
|
|
- outData.maxScaleY = system.maxScaleY;
|
|
|
- // Life time of each particle (random between...
|
|
|
- outData.minLifeTime = system.minLifeTime;
|
|
|
- outData.maxLifeTime = system.maxLifeTime;
|
|
|
- // Emission rate
|
|
|
- outData.emitRate = system.emitRate;
|
|
|
- // Blend mode : BLENDMODE_ONEONE, or BLENDMODE_STANDARD
|
|
|
- outData.blendMode = system.blendMode;
|
|
|
- // Set the gravity of all particles
|
|
|
- outData.gravity = { x: system.gravity.x, y: system.gravity.y, z: system.gravity.z };
|
|
|
- // Angular speed, in radians
|
|
|
- outData.minAngularSpeed = system.minAngularSpeed;
|
|
|
- outData.maxAngularSpeed = system.maxAngularSpeed;
|
|
|
- // Speed
|
|
|
- outData.minEmitPower = system.minEmitPower;
|
|
|
- outData.maxEmitPower = system.maxEmitPower;
|
|
|
- outData.updateSpeed = system.updateSpeed;
|
|
|
- switch (system.particleEmitterType.getClassName()) {
|
|
|
- case "BoxEmitter":
|
|
|
- outData.emitterType = "box";
|
|
|
- outData.direction1 = { x: system.direction1.x, y: system.direction1.y, z: system.direction1.z };
|
|
|
- outData.direction2 = { x: system.direction2.x, y: system.direction2.y, z: system.direction2.z };
|
|
|
- outData.minEmitBox = { x: system.minEmitBox.x, y: system.minEmitBox.y, z: system.minEmitBox.z };
|
|
|
- outData.maxEmitBox = { x: system.maxEmitBox.x, y: system.maxEmitBox.y, z: system.maxEmitBox.z };
|
|
|
- break;
|
|
|
- case "SphereParticleEmitter":
|
|
|
- outData.emitterType = "sphere";
|
|
|
- outData.radius = system.particleEmitterType.radius;
|
|
|
- break;
|
|
|
- case "SphereDirectedParticleEmitter":
|
|
|
- outData.emitterType = "directed_sphere";
|
|
|
- var sphereDirectedParticleEmitter = system.particleEmitterType;
|
|
|
- outData.radius = sphereDirectedParticleEmitter.radius;
|
|
|
- outData.direction1 = { x: sphereDirectedParticleEmitter.direction1.x, y: sphereDirectedParticleEmitter.direction1.y, z: sphereDirectedParticleEmitter.direction1.z };
|
|
|
- outData.direction2 = { x: sphereDirectedParticleEmitter.direction2.x, y: sphereDirectedParticleEmitter.direction2.y, z: sphereDirectedParticleEmitter.direction2.z };
|
|
|
- break;
|
|
|
- case "ConeEmitter":
|
|
|
- outData.emitterType = "cone";
|
|
|
- outData.radius = system.particleEmitterType.radius;
|
|
|
- outData.angle = system.particleEmitterType.angle;
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
+ ParticleHelper.ExportSet = function (systems) {
|
|
|
+ var set = new BABYLON.ParticleSystemSet();
|
|
|
+ for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
|
|
|
+ var system = systems_1[_i];
|
|
|
+ set.systems.push(system);
|
|
|
}
|
|
|
- return outData;
|
|
|
+ return set;
|
|
|
};
|
|
|
/**
|
|
|
- * Base Assets URL.
|
|
|
+ * Gets or sets base Assets URL
|
|
|
*/
|
|
|
- ParticleHelper._baseAssetsUrl = "https://assets.babylonjs.com/particles";
|
|
|
+ ParticleHelper.BaseAssetsUrl = "https://assets.babylonjs.com/particles";
|
|
|
return ParticleHelper;
|
|
|
}());
|
|
|
BABYLON.ParticleHelper = ParticleHelper;
|