Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Particle system updates and name changes #6429

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ Change Log
* Fix Firefox WebGL console warnings. [#5912](https://github.com/AnalyticalGraphicsInc/cesium/issues/5912)
* Fix parsing Cesium.js in older browsers that do not support all TypedArray types. [#6396](https://github.com/AnalyticalGraphicsInc/cesium/pull/6396)
* Fix flicker when adding, removing, or modifiying entities. [#3945](https://github.com/AnalyticalGraphicsInc/cesium/issues/3945)

##### Additions :tada:
* Added color and scale attributes to the `ParticleSystem` class constructor. When defined the variables override startColor and endColor and startScale and endScale. [#6429](https://github.com/AnalyticalGraphicsInc/cesium/pull/6429)
* Improved `MapboxImageryProvider` performance by 300% via `tiles.mapbox.com` subdomain switching. [#6426](https://github.com/AnalyticalGraphicsInc/cesium/issues/6426)

##### Deprecated :hourglass_flowing_sand:
* `Particle.size`, `ParticleSystem.rate`, `ParticleSystem.lifeTime`, `ParticleSystem.life`, `ParticleSystem.minimumLife`, and `ParticleSystem.maximumLife` have been renamed to `Particle.imageSize`, `ParticleSystem.emissionRate`, `ParticleSystem.lifetime`, `ParticleSystem.particleLife`, `ParticleSystem.minimumParticleLife`, and `ParticleSystem.maximumParticleLife`. Use of the `size`, `rate`, `lifeTime`, `life`, `minimumLife`, and `maximumLife` parameters is deprecated and will be removed in Cesium 1.46.
* `ParticleSystem.forces` array has been switched out for singular function `ParticleSystems.updateCallback`. Use of the `forces` parameter is deprecated and will be removed in Cesium 1.46.
* Any width and height variables in `ParticleSystem` will no longer be individual components. `ParticleSystem.minimumWidth` and `ParticleSystem.minimumHeight` will now be `ParticleSystem.minimumImageSize`, `ParticleSystem.maximumWidth` and `ParticleSystem.maximumHeight` will now be `ParticleSystem.maximumImageSize`, and `ParticleSystem.width` and `ParticleSystem.height` will now be `ParticleSystem.imageSize`. Use of the `minimumWidth`, `minimumHeight`, `maximumWidth`, `maximumHeight`, `width`, and `height` parameters is deprecated and will be removed in Cesium 1.46.

### 1.44 - 2018-04-02

##### Highlights :sparkler:
Expand Down
57 changes: 42 additions & 15 deletions Source/Scene/Particle.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ define([
'../Core/Color',
'../Core/defaultValue',
'../Core/defined',
'../Core/defineProperties'
'../Core/defineProperties',
'../Core/deprecationWarning'
], function(
Cartesian2,
Cartesian3,
Color,
defaultValue,
defined,
defineProperties) {
defineProperties,
deprecationWarning) {
'use strict';

var defaultSize = new Cartesian2(1.0, 1.0);
Expand All @@ -23,16 +25,17 @@ define([
* @constructor
*
* @param {Object} options An object with the following properties:
* @param {Number} [options.mass=1.0] The mass of particles in kilograms.
* @param {Number} [options.mass=1.0] The mass of the particle in kilograms.
* @param {Cartesian3} [options.position=Cartesian3.ZERO] The initial position of the particle in world coordinates.
* @param {Cartesian3} [options.velocity=Cartesian3.ZERO] The velocity vector of the particle in world coordinates.
* @param {Number} [options.life=Number.MAX_VALUE] The life of particles in seconds.
* @param {Number} [options.life=Number.MAX_VALUE] The life of the particle in seconds.
* @param {Object} [options.image] The URI, HTMLImageElement, or HTMLCanvasElement to use for the billboard.
* @param {Color} [options.startColor=Color.WHITE] The color of a particle when it is born.
* @param {Color} [options.endColor=Color.WHITE] The color of a particle when it dies.
* @param {Number} [options.startScale=1.0] The scale of the particle when it is born.
* @param {Number} [options.endScale=1.0] The scale of the particle when it dies.
* @param {Cartesian2} [options.size=new Cartesian2(1.0, 1.0)] The dimensions of particles in pixels.
* @param {Cartesian2} [options.size=new Cartesian2(1.0, 1.0)] The dimensions of particles in pixels. This has been deprecated. Use imageSize instead.
* @param {Cartesian2} [options.imageSize=new Cartesian2(1.0, 1.0)] The dimensions, width by height, to scale the particle image in pixels.
*/
function Particle(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
Expand Down Expand Up @@ -92,11 +95,15 @@ define([
*/
this.endScale = defaultValue(options.endScale, 1.0);
/**
* The dimensions of the particle in pixels.
* The dimensions, width by height, to scale the particle image in pixels.
* @type {Cartesian2}
* @default new Cartesian(1.0, 1.0)
*/
this.size = Cartesian2.clone(defaultValue(options.size, defaultSize));
this.imageSize = Cartesian2.clone(defaultValue(options.imageSize, defaultSize));
if (defined(options.size)) {
deprecationWarning('size', 'size was deprecated in Cesium 1.45. It will be removed in 1.46. Use imageSize instead.');
this.imageSize = Cartesian2.clone(defaultValue(options.size, defaultSize));
}

this._age = 0.0;
this._normalizedAge = 0.0;
Expand Down Expand Up @@ -125,6 +132,22 @@ define([
get : function() {
return this._normalizedAge;
}
},
/**
* The dimensions of the particle in pixels. This has been deprecated. Use {@link Particle#imageSize} instead.
* @type {Cartesian2}
* @default new Cartesian(1.0, 1.0)
* @deprecated
*/
size : {
get : function() {
deprecationWarning('size', 'size was deprecated in Cesium 1.45. It will be removed in 1.46. Use imageSize instead.');
return this.imageSize;
},
set : function(value) {
deprecationWarning('size', 'size was deprecated in Cesium 1.45. It will be removed in 1.46. Use imageSize instead.');
this.imageSize = value;
}
}
});

Expand All @@ -133,19 +156,23 @@ define([
/**
* @private
*/
Particle.prototype.update = function(dt, forces) {
Particle.prototype.update = function(dt, particleUpdateFunction) {
// Apply the velocity
Cartesian3.multiplyByScalar(this.velocity, dt, deltaScratch);
Cartesian3.add(this.position, deltaScratch, this.position);

// Update any forces.
if (defined(forces)) {
var length = forces.length;
for (var i = 0; i < length; ++i) {
var force = forces[i];
if (typeof force === 'function') {
// Force is just a simple callback function.
force(this, dt);
if (defined(particleUpdateFunction)) {
if (typeof particleUpdateFunction === 'function') {
particleUpdateFunction(this, dt);
} else if (particleUpdateFunction instanceof Array) {
var length = particleUpdateFunction.length;
for (var i = 0; i < length; ++i) {
var force = particleUpdateFunction[i];
if (typeof force === 'function') {
// Force is just a simple callback function.
force(this, dt);
}
}
}
}
Expand Down
Loading