diff --git a/CHANGES.md b/CHANGES.md index 8f4a15a772c5..ea010fc22328 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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: diff --git a/Source/Scene/Particle.js b/Source/Scene/Particle.js index 436d71a0b649..052daf14ef7e 100644 --- a/Source/Scene/Particle.js +++ b/Source/Scene/Particle.js @@ -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); @@ -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); @@ -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; @@ -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; + } } }); @@ -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); + } } } } diff --git a/Source/Scene/ParticleSystem.js b/Source/Scene/ParticleSystem.js index 6ce7467f73ca..28e26ad5720a 100644 --- a/Source/Scene/ParticleSystem.js +++ b/Source/Scene/ParticleSystem.js @@ -6,6 +6,7 @@ define([ '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', + '../Core/deprecationWarning', '../Core/destroyObject', '../Core/Event', '../Core/JulianDate', @@ -22,6 +23,7 @@ define([ defaultValue, defined, defineProperties, + deprecationWarning, destroyObject, Event, JulianDate, @@ -32,6 +34,8 @@ define([ Particle) { 'use strict'; + var defaultImageSize = new Cartesian2(1.0, 1.0); + /** * A ParticleSystem manages the updating and display of a collection of particles. * @@ -40,36 +44,48 @@ define([ * * @param {Object} [options] Object with the following properties: * @param {Boolean} [options.show=true] Whether to display the particle system. - * @param {ParticleSystem~applyForce[]} [options.forces] An array of force callbacks. + * @param {ParticleSystem~applyForce[]} [options.forces] An array of force callbacks. This has been deprecated. Use updateCallback instead. + * @param {ParticleSystem~updateCallback} [options.updateCallback] The callback function to be called each frame to update a particle. * @param {ParticleEmitter} [options.emitter=new CircleEmitter(0.5)] The particle emitter for this system. * @param {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] The 4x4 transformation matrix that transforms the particle system from model to world coordinates. * @param {Matrix4} [options.emitterModelMatrix=Matrix4.IDENTITY] The 4x4 transformation matrix that transforms the particle system emitter within the particle systems local coordinate system. - * @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 {Number} [options.rate=5] The number of particles to emit per second. + * @param {Number} [options.rate = 5] The number of particles to emit per second. This has been deprecated. Use emissionRate instead. + * @param {Number} [options.emissionRate=5] The number of particles to emit per second. * @param {ParticleBurst[]} [options.bursts] An array of {@link ParticleBurst}, emitting bursts of particles at periodic times. - * @param {Boolean} [options.loop=true] Whether the particle system should loop it's bursts when it is complete. - * @param {Number} [options.speed] Sets the minimum and maximum speed in meters per second - * @param {Number} [options.minimumSpeed=1.0] Sets the minimum speed in meters per second. - * @param {Number} [options.maximumSpeed=1.0] Sets the maximum speed in meters per second. - * @param {Number} [options.life] Sets the minimum and maximum life of particles in seconds. - * @param {Number} [options.minimumLife=5.0] Sets the minimum life of particles in seconds. - * @param {Number} [options.maximumLife=5.0] Sets the maximum life of particles in seconds. - * @param {Number} [options.mass] Sets the minimum and maximum mass of particles in kilograms. - * @param {Number} [options.minimumMass=1.0] Sets the minimum mass of particles in kilograms. - * @param {Number} [options.maximumMass=1.0] Sets the maximum mass of particles in kilograms. + * @param {Boolean} [options.loop=true] Whether the particle system should loop its bursts when it is complete. + * @param {Number} [options.scale=1.0] Sets the scale to apply to the image of the particle for the duration of its particleLife. + * @param {Number} [options.startScale] The initial scale to apply to the image of the particle at the beginning of its life. + * @param {Number} [options.endScale] The final scale to apply to the image of the particle at the end of its life. + * @param {Color} [options.color=Color.WHITE] Sets the color of a particle for the duration of its particleLife. + * @param {Color} [options.startColor] The color of the particle at the beginning of its life. + * @param {Color} [options.endColor] The color of the particle at the end of its life. * @param {Object} [options.image] The URI, HTMLImageElement, or HTMLCanvasElement to use for the billboard. - * @param {Number} [options.width] Sets the minimum and maximum width of particles in pixels. - * @param {Number} [options.minimumWidth=1.0] Sets the minimum width of particles in pixels. - * @param {Number} [options.maximumWidth=1.0] Sets the maximum width of particles in pixels. - * @param {Number} [options.height] Sets the minimum and maximum height of particles in pixels. - * @param {Number} [options.minimumHeight=1.0] Sets the minimum height of particles in pixels. - * @param {Number} [options.maximumHeight=1.0] Sets the maximum height of particles in pixels. - * @param {Number} [options.lifeTime=Number.MAX_VALUE] How long the particle system will emit particles, in seconds. - * - * @demo {@link https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=ParticleSystem.html|Particle Systems Demo} + * @param {Number} [options.width=1.0] Sets the minimum and maximum width of particles in pixels. This has been deprecated. Use imageSize's x component instead. + * @param {Number} [options.minimumWidth] Sets the minimum width of particles in pixels. This has been deprecated. Use minimumImageSize's x component instead. + * @param {Number} [options.maximumWidth] Sets the maximum width of particles in pixels. This has been deprecated. Use maximumImageSize's x component instead. + * @param {Number} [options.height=1.0] Overwrites the minimum and maximum height of particles in pixels. This has been deprecated. Use imageSize's y component instead. + * @param {Number} [options.minimumHeight] Sets the minimum height of particles in pixels. This has been deprecated. Use minimumImageSize's y component instead. + * @param {Number} [options.maximumHeight] Sets the maximum height of particles in pixels. This has been deprecated. Use maximumImageSize's y component instead. + * @param {Cartesian2} [options.imageSize=new Cartesian2(1.0, 1.0)] If set, overrides the minimumImageSize and maximumImageSize inputs that scale the particle image's dimensions in pixels. + * @param {Cartesian2} [options.minimumImageSize] Sets the minimum bound, width by height, above which to randomly scale the particle image's dimensions in pixels. + * @param {Cartesian2} [options.maximumImageSize] Sets the maximum bound, width by height, below which to randomly scale the particle image's dimensions in pixels. + * @param {Number} [options.speed=1.0] If set, overrides the minimumSpeed and maximumSpeed inputs with this value. + * @param {Number} [options.minimumSpeed] Sets the minimum bound in meters per second above which a particle's actual speed will be randomly chosen. + * @param {Number} [options.maximumSpeed] Sets the maximum bound in meters per second below which a particle's actual speed will be randomly chosen. + * @param {Number} [options.lifeTime=Number.MAX_VALUE] How long the particle system will emit particles, in seconds. This has been deprecated. Use lifetime instead. + * @param {Number} [options.lifetime=Number.MAX_VALUE] How long the particle system will emit particles, in seconds. + * @param {Number} [options.life=5.0] If set, overrides the minimumLife and maximumLife inputs with this value. This has been deprecated. Use particleLife instead. + * @param {Number} [options.minimumLife] Sets the minimum life of particles in seconds. This has been deprecated. Use minimumParticleLife instead. + * @param {Number} [options.maximumLife] Sets the maximum life of particles in seconds. This has been deprecated. Use maximumParticleLife instead. + * @param {Number} [options.particleLife=5.0] If set, overrides the minimumParticleLife and maximumParticleLife inputs with this value. + * @param {Number} [options.minimumParticleLife] Sets the minimum bound in seconds for the possible duration of a particle's life above which a particle's actual life will be randomly chosen. + * @param {Number} [options.maximumParticleLife] Sets the maximum bound in seconds for the possible duration of a particle's life below which a particle's actual life will be randomly chosen. + * @param {Number} [options.mass=1.0] Sets the minimum and maximum mass of particles in kilograms. + * @param {Number} [options.minimumMass] Sets the minimum bound for the mass of a particle in kilograms. A particle's actual mass will be chosen as a random amount above this value. + * @param {Number} [options.maximumMass] Sets the maximum mass of particles in kilograms. A particle's actual mass will be chosen as a random amount below this value. + * @tutorial {@link https://cesiumjs.org/tutorials/Particle-Systems-Tutorial/|Particle Systems Tutorial} + * @demo {@link https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/?src=Particle%20System.html&label=Showcases|Particle Systems Tutorial Demo} + * @demo {@link https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/?src=Particle%20System%20Fireworks.html&label=Showcases|Particle Systems Fireworks Demo} */ function ParticleSystem(options) { options = defaultValue(options, defaultValue.EMPTY_OBJECT); @@ -83,11 +99,20 @@ define([ /** * An array of force callbacks. The callback is passed a {@link Particle} and the difference from the last time + * @type {ParticleSystem~updateCallback} + * @default undefined + */ + this.updateCallback = options.updateCallback; + /** + * An array of force callbacks. The callback is passed a {@link Particle} and the difference from the last time. This has been deprecated. Use updateCallback instead. * @type {ParticleSystem~applyForce[]} * @default undefined + * @deprecated */ - this.forces = options.forces; - + if (defined(options.forces)) { + deprecationWarning('forces', 'forces was deprecated in Cesium 1.45. It will be removed in 1.46. Use updateCallback instead.'); + this.updateCallback = options.forces; + } /** * Whether the particle system should loop it's bursts when it is complete. * @type {Boolean} @@ -115,30 +140,87 @@ define([ this._matrixDirty = true; this._combinedMatrix = new Matrix4(); - this._startColor = Color.clone(defaultValue(options.startColor, Color.WHITE)); - this._endColor = Color.clone(defaultValue(options.endColor, Color.WHITE)); + this._startColor = Color.clone(defaultValue(options.color, defaultValue(options.startColor, Color.WHITE))); + this._endColor = Color.clone(defaultValue(options.color, defaultValue(options.endColor, Color.WHITE))); - this._startScale = defaultValue(options.startScale, 1.0); - this._endScale = defaultValue(options.endScale, 1.0); + this._startScale = defaultValue(options.scale, defaultValue(options.startScale, 1.0)); + this._endScale = defaultValue(options.scale, defaultValue(options.endScale, 1.0)); - this._rate = defaultValue(options.rate, 5); + this._emissionRate = defaultValue(options.emissionRate, 5.0); + if (defined(options.rate)) { + deprecationWarning('rate', 'rate was deprecated in Cesium 1.45. It will be removed in 1.46. Use emissionRate instead.'); + this._emissionRate = options.rate; + } this._minimumSpeed = defaultValue(options.speed, defaultValue(options.minimumSpeed, 1.0)); this._maximumSpeed = defaultValue(options.speed, defaultValue(options.maximumSpeed, 1.0)); - this._minimumLife = defaultValue(options.life, defaultValue(options.minimumLife, 5.0)); - this._maximumLife = defaultValue(options.life, defaultValue(options.maximumLife, 5.0)); + var particleLife; + if (defined(options.life)) { + deprecationWarning('life', 'life was deprecated in Cesium 1.45. It will be removed in 1.46. Use particleLife instead.'); + particleLife = options.life; + } + this._minimumParticleLife = defaultValue(options.particleLife, defaultValue(options.minimumParticleLife, 5.0)); + if (defined(particleLife) || defined(options.minimumLife)) { + deprecationWarning('minimumLife', 'minimumLife was deprecated in Cesium 1.45. It will be removed in 1.46. Use minimumParticleLife instead.'); + this._minimumParticleLife = defaultValue(particleLife, defaultValue(options.minimumLife, 5.0)); + } + this._maximumParticleLife = defaultValue(options.particleLife, defaultValue(options.maximumParticleLife, 5.0)); + if (defined(particleLife) || defined(options.maximumLife)) { + deprecationWarning('maximumLife', 'maximumLife was deprecated in Cesium 1.45. It will be removed in 1.46. Use maximumParticleLife instead.'); + this._maximumParticleLife = defaultValue(particleLife, defaultValue(options.maximumLife, 5.0)); + } this._minimumMass = defaultValue(options.mass, defaultValue(options.minimumMass, 1.0)); this._maximumMass = defaultValue(options.mass, defaultValue(options.maximumMass, 1.0)); - this._minimumWidth = defaultValue(options.width, defaultValue(options.minimumWidth, 1.0)); - this._maximumWidth = defaultValue(options.width, defaultValue(options.maximumWidth, 1.0)); + var width; + if (defined(options.width)) { + deprecationWarning('width', 'width was deprecated in Cesium 1.45. It will be removed in 1.46. Instead of width' + + ' and height components for pixel dimensions we switched to a Cartesian2. Use imageSize instead.'); + width = options.width; + } + var height; + if (defined(options.height)) { + deprecationWarning('height', 'height was deprecated in Cesium 1.45. It will be removed in 1.46. Instead of width' + + ' and height components for pixel dimensions we switched to a Cartesian2. Use imageSize instead.'); + height = options.height; + } + this._minimumImageSize = defaultValue(options.imageSize, defaultValue(options.minimumImageSize, defaultImageSize)); + this._maximumImageSize = defaultValue(options.imageSize, defaultValue(options.maximumImageSize, defaultImageSize)); + if (defined(width) || defined(options.minimumWidth) || defined(options.maximumWidth) + || defined(height) || defined(options.minimumHeight) || defined(options.maximumHeight)) { + + if (defined(options.minimumWidth)) { + deprecationWarning('minimumWidth', 'minimumWidth was deprecated in Cesium 1.45. It will be removed in 1.46. Instead of width' + + ' and height components for pixel dimensions we switched to a Cartesian2. Use the x component of minimumImageSize instead.'); + } + if (defined(options.maximumWidth)) { + deprecationWarning('maximumWidth', 'maximumWidth was deprecated in Cesium 1.45. It will be removed in 1.46. Instead of width' + + ' and height components for pixel dimensions we switched to a Cartesian2. Use the x component of maximumImageSize instead.'); + } + if (defined(options.minimumHeight)) { + deprecationWarning('minimumHeight', 'minimumHeight was deprecated in Cesium 1.45. It will be removed in 1.46. Instead of width' + + ' and height components for pixel dimensions we switched to a Cartesian2. Use the y component of minimumImageSize instead.'); + } + if (defined(options.maximumHeight)) { + deprecationWarning('maximumHeight', 'maximumHeight was deprecated in Cesium 1.45. It will be removed in 1.46. Instead of width' + + ' and height components for pixel dimensions we switched to a Cartesian2. Use the y component of maximumImageSize instead.'); + } - this._minimumHeight = defaultValue(options.height, defaultValue(options.minimumHeight, 1.0)); - this._maximumHeight = defaultValue(options.height, defaultValue(options.maximumHeight, 1.0)); + var minimumWidth = defaultValue(width, defaultValue(options.minimumWidth, 1.0)); + var maximumWidth = defaultValue(width, defaultValue(options.maximumWidth, 1.0)); + var minimumHeight = defaultValue(height, defaultValue(options.minimumHeight, 1.0)); + var maximumHeight = defaultValue(height, defaultValue(options.maximumHeight, 1.0)); + this._minimumImageSize = new Cartesian2(minimumWidth, minimumHeight); + this._maximumImageSize = new Cartesian2(maximumWidth, maximumHeight); + } - this._lifeTime = defaultValue(options.lifeTime, Number.MAX_VALUE); + this._lifetime = defaultValue(options.lifetime, Number.MAX_VALUE); + if (defined(options.lifeTime)) { + deprecationWarning('lifeTime', 'lifeTime was deprecated in Cesium 1.45. It will be removed in 1.46. Use lifetime instead.'); + this._lifetime = defaultValue(options.lifeTime, Number.MAX_VALUE); + } this._billboardCollection = undefined; this._particles = []; @@ -162,7 +244,7 @@ define([ * The particle emitter for this * @memberof ParticleSystem.prototype * @type {ParticleEmitter} - * @default CricleEmitter + * @default CircleEmitter */ emitter : { get : function() { @@ -226,7 +308,7 @@ define([ } }, /** - * The color of a particle when it is born. + * The color of the particle at the beginning of its life. * @memberof ParticleSystem.prototype * @type {Color} * @default Color.WHITE @@ -243,7 +325,7 @@ define([ } }, /** - * The color of a particle when it dies. + * The color of the particle at the end of its life. * @memberof ParticleSystem.prototype * @type {Color} * @default Color.WHITE @@ -260,7 +342,7 @@ define([ } }, /** - * The scale of the particle when it is born. + * The initial scale to apply to the image of the particle at the beginning of its life. * @memberof ParticleSystem.prototype * @type {Number} * @default 1.0 @@ -277,7 +359,7 @@ define([ } }, /** - * The scale of the particle when it dies. + * The final scale to apply to the image of the particle at the end of its life. * @memberof ParticleSystem.prototype * @type {Number} * @default 1.0 @@ -294,25 +376,42 @@ define([ } }, /** - * The number of particles to emit per second. + * The number of particles to emit per second. This has been deprecated. Use {@link ParticleSystem#emissionRate} instead. * @memberof ParticleSystem.prototype * @type {Number} * @default 5 + * @deprecated */ rate : { get : function() { - return this._rate; + deprecationWarning('rate', 'rate was deprecated in Cesium 1.45. It will be removed in 1.46. Use emissionRate instead.'); + return this._emissionRate; + }, + set : function(value) { + deprecationWarning('rate', 'rate was deprecated in Cesium 1.45. It will be removed in 1.46. Use emissionRate instead.'); + this.emissionRate = value; + } + }, + /** + * The number of particles to emit per second. + * @memberof ParticleSystem.prototype + * @type {Number} + * @default 5 + */ + emissionRate : { + get : function() { + return this._emissionRate; }, set : function(value) { //>>includeStart('debug', pragmas.debug); Check.typeOf.number.greaterThanOrEquals('value', value, 0.0); //>>includeEnd('debug'); - this._rate = value; + this._emissionRate = value; this._updateParticlePool = true; } }, /** - * Sets the minimum speed in meters per second. + * Sets the minimum bound in meters per second above which a particle's actual speed will be randomly chosen. * @memberof ParticleSystem.prototype * @type {Number} * @default 1.0 @@ -329,7 +428,7 @@ define([ } }, /** - * Sets the maximum speed in meters per second. + * Sets the maximum bound in meters per second below which a particle's actual speed will be randomly chosen. * @memberof ParticleSystem.prototype * @type {Number} * @default 1.0 @@ -346,37 +445,71 @@ define([ } }, /** - * Sets the minimum life of particles in seconds. + * Sets the minimum life of particles in seconds. This has been deprecated. Use {@link ParticleSystem#minimumParticleLife} instead. * @memberof ParticleSystem.prototype * @type {Number} * @default 5.0 + * @deprecated */ minimumLife : { get : function() { - return this._minimumLife; + deprecationWarning('minimumLife', 'minimumLife was deprecated in Cesium 1.45. It will be removed in 1.46. Use minimumParticleLife instead.'); + return this._minimumParticleLife; + }, + set : function(value) { + deprecationWarning('minimumLife', 'minimumLife was deprecated in Cesium 1.45. It will be removed in 1.46. Use minimumParticleLife instead.'); + this.minimumParticleLife = value; + } + }, + /** + * Sets the minimum bound in seconds for the possible duration of a particle's life above which a particle's actual life will be randomly chosen. + * @memberof ParticleSystem.prototype + * @type {Number} + * @default 5.0 + */ + minimumParticleLife : { + get : function() { + return this._minimumParticleLife; }, set : function(value) { //>>includeStart('debug', pragmas.debug); Check.typeOf.number.greaterThanOrEquals('value', value, 0.0); //>>includeEnd('debug'); - this._minimumLife = value; + this._minimumParticleLife = value; } }, /** - * Sets the maximum life of particles in seconds. + * Sets the maximum life of particles in seconds. This has been deprecated. Use {@link ParticleSystem#maximumParticleLife} instead. * @memberof ParticleSystem.prototype * @type {Number} * @default 5.0 + * @deprecated */ maximumLife : { get : function() { - return this._maximumLife; + deprecationWarning('maximumLife', 'maximumLife was deprecated in Cesium 1.45. It will be removed in 1.46. Use maximumParticleLife instead.'); + return this._maximumParticleLife; + }, + set : function(value) { + deprecationWarning('maximumLife', 'maximumLife was deprecated in Cesium 1.45. It will be removed in 1.46. Use maximumParticleLife instead.'); + this.maximumParticleLife = value; + } + }, + /** + * Sets the maximum bound in seconds for the possible duration of a particle's life below which a particle's actual life will be randomly chosen. + * @memberof ParticleSystem.prototype + * @type {Number} + * @default 5.0 + */ + maximumParticleLife : { + get : function() { + return this._maximumParticleLife; }, set : function(value) { //>>includeStart('debug', pragmas.debug); Check.typeOf.number.greaterThanOrEquals('value', value, 0.0); //>>includeEnd('debug'); - this._maximumLife = value; + this._maximumParticleLife = value; this._updateParticlePool = true; } }, @@ -415,88 +548,151 @@ define([ } }, /** - * Sets the minimum width of particles in pixels. + * Sets the minimum width of particles in pixels. This has been deprecated. Use {@link ParticleSystem#minimumImageSize} instead. * @memberof ParticleSystem.prototype * @type {Number} * @default 1.0 + * @deprecated */ minimumWidth : { get : function() { - return this._minimumWidth; + deprecationWarning('width', 'width was deprecated in Cesium 1.45. It will be removed in 1.46. Instead of width' + + ' and height components for pixel dimensions we switched to a Cartesian2. Use imageSize instead.'); + return this._minimumImageSize.x; }, set : function(value) { - //>>includeStart('debug', pragmas.debug); - Check.typeOf.number.greaterThanOrEquals('value', value, 0.0); - //>>includeEnd('debug'); - this._minimumWidth = value; + deprecationWarning('width', 'width was deprecated in Cesium 1.45. It will be removed in 1.46. Instead of width' + + ' and height components for pixel dimensions we switched to a Cartesian2. Use imageSize instead.'); + this.minimumImageSize = new Cartesian2(value, this.minimumImageSize.y); } }, /** - * Sets the maximum width of particles in pixels. + * Sets the maximum width of particles in pixels. This has been deprecated. Use {@link ParticleSystem#maximumImageSize} instead. * @memberof ParticleSystem.prototype * @type {Number} * @default 1.0 + * @deprecated */ maximumWidth : { get : function() { - return this._maximumWidth; + deprecationWarning('width', 'width was deprecated in Cesium 1.45. It will be removed in 1.46. Instead of width' + + ' and height components for pixel dimensions we switched to a Cartesian2. Use imageSize instead.'); + return this._maximumImageSize.x; }, set : function(value) { - //>>includeStart('debug', pragmas.debug); - Check.typeOf.number.greaterThanOrEquals('value', value, 0.0); - //>>includeEnd('debug'); - this._maximumWidth = value; + deprecationWarning('width', 'width was deprecated in Cesium 1.45. It will be removed in 1.46. Instead of width' + + ' and height components for pixel dimensions we switched to a Cartesian2. Use imageSize instead.'); + this.maximumImageSize = new Cartesian2(value, this.maximumImageSize.y); } }, /** - * Sets the minimum height of particles in pixels. + * Sets the minimum height of particles in pixels. This has been deprecated. Use {@link ParticleSystem#minimumImageSize} instead. * @memberof ParticleSystem.prototype * @type {Number} * @default 1.0 + * @deprecated */ minimumHeight : { get : function() { - return this._minimumHeight; + deprecationWarning('height', 'height was deprecated in Cesium 1.45. It will be removed in 1.46. Instead of width' + + ' and height components for pixel dimensions we switched to a Cartesian2. Use imageSize instead.'); + return this._minimumImageSize.y; }, set : function(value) { - //>>includeStart('debug', pragmas.debug); - Check.typeOf.number.greaterThanOrEquals('value', value, 0.0); - //>>includeEnd('debug'); - this._minimumHeight = value; + deprecationWarning('height', 'height was deprecated in Cesium 1.45. It will be removed in 1.46. Instead of width' + + ' and height components for pixel dimensions we switched to a Cartesian2. Use imageSize instead.'); + this.minimumImageSize = new Cartesian2(this.minimumImageSize.x, value); } }, /** - * Sets the maximum height of particles in pixels. + * Sets the maximum height of particles in pixels. This has been deprecated. Use {@link ParticleSystem#maximumImageSize} instead. * @memberof ParticleSystem.prototype * @type {Number} * @default 1.0 + * @deprecated */ maximumHeight : { get : function() { - return this._maximumHeight; + deprecationWarning('height', 'height was deprecated in Cesium 1.45. It will be removed in 1.46. Instead of width' + + ' height components for pixel dimensions we switched to a Cartesian2. Use imageSize instead.'); + return this._maximumImageSize.y; + }, + set : function(value) { + deprecationWarning('height', 'height was deprecated in Cesium 1.45. It will be removed in 1.46. Instead of width' + + ' and height components for pixel dimensions we switched to a Cartesian2. Use imageSize instead.'); + this.maximumImageSize = new Cartesian2(this.maximumImageSize.x, value); + } + }, + /** + * Sets the minimum bound, width by height, above which to randomly scale the particle image's dimensions in pixels. + * @memberof ParticleSystem.prototype + * @type {Cartesian2} + * @default new Cartesian2(1.0, 1.0) + */ + minimumImageSize : { + get : function() { + return this._minimumImageSize; }, set : function(value) { //>>includeStart('debug', pragmas.debug); - Check.typeOf.number.greaterThanOrEquals('value', value, 0.0); + Check.typeOf.object('value', value); + Check.typeOf.number.greaterThanOrEquals('value.x', value.x, 0.0); + Check.typeOf.number.greaterThanOrEquals('value.y', value.y, 0.0); //>>includeEnd('debug'); - this._maximumHeight = value; + this._minimumImageSize = value; } }, /** - * How long the particle system will emit particles, in seconds. + * Sets the maximum bound, width by height, below which to randomly scale the particle image's dimensions in pixels. + * @memberof ParticleSystem.prototype + * @type {Cartesian2} + * @default new Cartesian2(1.0, 1.0) + */ + maximumImageSize : { + get : function() { + return this._maximumImageSize; + }, + set : function(value) { + //>>includeStart('debug', pragmas.debug); + Check.typeOf.object('value', value); + Check.typeOf.number.greaterThanOrEquals('value.x', value.x, 0.0); + Check.typeOf.number.greaterThanOrEquals('value.y', value.y, 0.0); + //>>includeEnd('debug'); + this._maximumImageSize = value; + } + }, + /** + * How long the particle system will emit particles, in seconds. This has been deprecated. Use {@link ParticleSystem#lifetime} instead. * @memberof ParticleSystem.prototype * @type {Number} * @default Number.MAX_VALUE + * @deprecated */ lifeTime : { get : function() { - return this._lifeTime; + deprecationWarning('lifeTime', 'lifeTime was deprecated in Cesium 1.45. It will be removed in 1.46. Use lifetime instead.'); + return this._lifetime; + }, + set : function(value) { + deprecationWarning('lifeTime', 'lifeTime was deprecated in Cesium 1.45. It will be removed in 1.46. Use lifetime instead.'); + this.lifetime = value; + } + }, + /** + * How long the particle system will emit particles, in seconds. + * @memberof ParticleSystem.prototype + * @type {Number} + * @default Number.MAX_VALUE + */ + lifetime : { + get : function() { + return this._lifetime; }, set : function(value) { //>>includeStart('debug', pragmas.debug); Check.typeOf.number.greaterThanOrEquals('value', value, 0.0); //>>includeEnd('debug'); - this._lifeTime = value; + this._lifetime = value; } }, /** @@ -522,8 +718,8 @@ define([ }); function updateParticlePool(system) { - var rate = system._rate; - var life = system._maximumLife; + var emissionRate = system._emissionRate; + var life = system._maximumParticleLife; var burstAmount = 0; var bursts = system._bursts; @@ -537,7 +733,7 @@ define([ var billboardCollection = system._billboardCollection; var image = system.image; - var particleEstimate = Math.ceil(rate * life + burstAmount); + var particleEstimate = Math.ceil(emissionRate * life + burstAmount); var particles = system._particles; var particlePool = system._particlePool; var numToAdd = Math.max(particleEstimate - particles.length - particlePool.length, 0); @@ -597,8 +793,8 @@ define([ image : particle.image }); } - billboard.width = particle.size.x; - billboard.height = particle.size.y; + billboard.width = particle.imageSize.x; + billboard.height = particle.imageSize.y; billboard.position = particle.position; billboard.show = true; @@ -610,8 +806,7 @@ define([ billboard.color = new Color(r,g,b,a); // Update the scale - var scale = CesiumMath.lerp(particle.startScale, particle.endScale, particle.normalizedAge); - billboard.scale = scale; + billboard.scale = CesiumMath.lerp(particle.startScale, particle.endScale, particle.normalizedAge); } function addParticle(system, particle) { @@ -620,12 +815,10 @@ define([ particle.startScale = system._startScale; particle.endScale = system._endScale; particle.image = system.image; - particle.life = CesiumMath.randomBetween(system._minimumLife, system._maximumLife); + particle.life = CesiumMath.randomBetween(system._minimumParticleLife, system._maximumParticleLife); particle.mass = CesiumMath.randomBetween(system._minimumMass, system._maximumMass); - - var width = CesiumMath.randomBetween(system._minimumWidth, system._maximumWidth); - var height = CesiumMath.randomBetween(system._minimumHeight, system._maximumHeight); - particle.size = Cartesian2.fromElements(width, height, particle.size); + particle.imageSize.x = CesiumMath.randomBetween(system._minimumImageSize.x, system._maximumImageSize.x); + particle.imageSize.y = CesiumMath.randomBetween(system._minimumImageSize.y, system._maximumImageSize.y); // Reset the normalizedAge and age in case the particle was reused. particle._normalizedAge = 0.0; @@ -643,10 +836,10 @@ define([ return 0; } - dt = CesiumMath.mod(dt, system._lifeTime); + dt = CesiumMath.mod(dt, system._lifetime); - // Compute the number of particles to emit based on the rate. - var v = dt * system._rate; + // Compute the number of particles to emit based on the emissionRate. + var v = dt * system._emissionRate; var numToEmit = Math.floor(v); system._carryOver += (v - numToEmit); if (system._carryOver > 1.0) @@ -702,7 +895,7 @@ define([ var particles = this._particles; var emitter = this._emitter; - var forces = this.forces; + var updateCallback = this.updateCallback; var i; var particle; @@ -711,7 +904,7 @@ define([ var length = particles.length; for (i = 0; i < length; ++i) { particle = particles[i]; - if (!particle.update(dt, forces)) { + if (!particle.update(dt, updateCallback)) { removeBillboard(particle); // Add the particle back to the pool so it can be reused. addParticleToPool(this, particle); @@ -763,9 +956,9 @@ define([ this._previousTime = JulianDate.clone(frameState.time, this._previousTime); this._currentTime += dt; - if (this._lifeTime !== Number.MAX_VALUE && this._currentTime > this._lifeTime) { + if (this._lifetime !== Number.MAX_VALUE && this._currentTime > this._lifetime) { if (this.loop) { - this._currentTime = CesiumMath.mod(this._currentTime, this._lifeTime); + this._currentTime = CesiumMath.mod(this._currentTime, this._lifetime); if (this.bursts) { var burstLength = this.bursts.length; // Reset any bursts @@ -817,12 +1010,35 @@ define([ }; /** - * A function used to apply a force to the particle on each time step. + * A function used to modify attributes of the particle at each time step. This can include force modifications, + * color, sizing, etc. + * + * @see {@link https://cesiumjs.org/tutorials/Particle-Systems-Tutorial/|Particle Systems Tutorial} + * + * @callback ParticleSystem~updateCallback + * + * @param {Particle} particle The particle being updated. + * @param {Number} dt The time in seconds since the last update. + * + * @example + * function applyGravity(particle, dt) { + * var position = particle.position; + * var gravityVector = Cesium.Cartesian3.normalize(position, new Cesium.Cartesian3()); + * Cesium.Cartesian3.multiplyByScalar(gravityVector, GRAVITATIONAL_CONSTANT * dt, gravityVector); + * particle.velocity = Cesium.Cartesian3.add(particle.velocity, gravityVector, particle.velocity); + * } + */ + + /** + * A function used to apply a force to the particle on each time step. This has been deprecated because forces[] + * was deprecated. Use updateCallback instead. * @callback ParticleSystem~applyForce * * @param {Particle} particle The particle to apply the force to. * @param {Number} dt The time since the last update. * + * @deprecated + * * @example * function applyGravity(particle, dt) { * var position = particle.position; diff --git a/Specs/Scene/ParticleSpec.js b/Specs/Scene/ParticleSpec.js index 5353c5fec733..00b45c6c67da 100644 --- a/Specs/Scene/ParticleSpec.js +++ b/Specs/Scene/ParticleSpec.js @@ -21,7 +21,7 @@ defineSuite([ expect(p.endColor).toEqual(Color.WHITE); expect(p.startScale).toEqual(1.0); expect(p.endScale).toEqual(1.0); - expect(p.size).toEqual(new Cartesian2(1.0, 1.0)); + expect(p.imageSize).toEqual(new Cartesian2(1.0, 1.0)); }); it('constructor', function() { @@ -35,7 +35,7 @@ defineSuite([ endColor : Color.LIME, startScale : 0.5, endScale : 20.0, - size : new Cartesian2(7.0, 8.0) + imageSize : new Cartesian2(7.0, 8.0) }; var p = new Particle(options); expect(p.mass).toEqual(options.mass); @@ -47,7 +47,7 @@ defineSuite([ expect(p.endColor).toEqual(options.endColor); expect(p.startScale).toEqual(options.startScale); expect(p.endScale).toEqual(options.endScale); - expect(p.size).toEqual(options.size); + expect(p.imageSize).toEqual(options.imageSize); }); it('update without forces', function() { @@ -99,4 +99,31 @@ defineSuite([ expect(p.mass).toEqual(expectedMass); expect(p.update(dt)).toEqual(false); }); + + it('update with updateFunction', function() { + var increaseMass = function(particle, dt) { + particle.mass++; + }; + var forces = increaseMass; + + var position = new Cartesian3(1.0, 2.0, 3.0); + var velocity = Cartesian3.normalize(new Cartesian3(-1.0, 1.0, 1.0), new Cartesian3()); + var p = new Particle({ + life : 15.0, + position : position, + velocity : velocity + }); + + var dt = 10.0; + var expectedMass = p.mass + 1; + var expectedPosition = Cartesian3.add(p.position, Cartesian3.multiplyByScalar(p.velocity, dt, new Cartesian3()), new Cartesian3()); + + expect(p.update(dt, forces)).toEqual(true); + expect(p.position).toEqual(expectedPosition); + expect(p.velocity).toEqual(velocity); + expect(p.age).toEqual(dt); + expect(p.normalizedAge).toEqual(dt / p.life); + expect(p.mass).toEqual(expectedMass); + expect(p.update(dt)).toEqual(false); + }); }); diff --git a/Specs/Scene/ParticleSystemSpec.js b/Specs/Scene/ParticleSystemSpec.js index f772e51fd666..907e97cd2c02 100644 --- a/Specs/Scene/ParticleSystemSpec.js +++ b/Specs/Scene/ParticleSystemSpec.js @@ -1,5 +1,6 @@ defineSuite([ 'Scene/ParticleSystem', + 'Core/Cartesian2', 'Core/Cartesian3', 'Core/Color', 'Core/Matrix4', @@ -9,6 +10,7 @@ defineSuite([ 'Specs/createScene' ], function( ParticleSystem, + Cartesian2, Cartesian3, Color, Matrix4, @@ -43,21 +45,21 @@ defineSuite([ expect(p.endColor).toEqual(Color.WHITE); expect(p.startScale).toEqual(1.0); expect(p.endScale).toEqual(1.0); - expect(p.rate).toEqual(5.0); + expect(p.emissionRate).toEqual(5.0); expect(p.bursts).toBeUndefined(); expect(p.loop).toEqual(true); expect(p.minimumSpeed).toEqual(1.0); expect(p.maximumSpeed).toEqual(1.0); - expect(p.minimumLife).toEqual(5.0); - expect(p.maximumLife).toEqual(5.0); + expect(p.minimumParticleLife).toEqual(5.0); + expect(p.maximumParticleLife).toEqual(5.0); expect(p.minimumMass).toEqual(1.0); expect(p.maximumMass).toEqual(1.0); expect(p.image).toBeUndefined(); - expect(p.minimumWidth).toEqual(1.0); - expect(p.maximumWidth).toEqual(1.0); - expect(p.minimumHeight).toEqual(1.0); - expect(p.maximumHeight).toEqual(1.0); - expect(p.lifeTime).toEqual(Number.MAX_VALUE); + expect(p.minimumImageSize.x).toEqual(1.0); + expect(p.minimumImageSize.y).toEqual(1.0); + expect(p.maximumImageSize.x).toEqual(1.0); + expect(p.maximumImageSize.y).toEqual(1.0); + expect(p.lifetime).toEqual(Number.MAX_VALUE); expect(p.complete).toBeDefined(); expect(p.isComplete).toEqual(false); }); @@ -65,7 +67,7 @@ defineSuite([ it('constructor', function() { var options = { show : false, - forces : [function(p) { p.mass++; }], + updateCallback : (function(p) { p.mass++; }), emitter : new CircleEmitter(10.0), modelMatrix : new Matrix4(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0), emitterModelMatrix : new Matrix4(10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0), @@ -73,25 +75,23 @@ defineSuite([ endColor : Color.LAVENDAR_BLUSH, startScale : 19.0, endScale : 20.0, - rate : 21.0, + emissionRate : 21.0, bursts : [new ParticleBurst()], loop : false, minimumSpeed : 22.0, maximumSpeed : 23.0, - minimumLife : 24.0, - maximumLife : 25.0, + minimumParticleLife : 24.0, + maximumParticleLife : 25.0, minimumMass : 26.0, maximumMass : 27.0, image : 'url/to/image', - minimumWidth : 28.0, - maximumWidth : 29.0, - minimumHeight : 30.0, - maximumHeight : 31.0, - lifeTime : 32.0 + minimumImageSize : new Cartesian2(28.0, 30.0), + maximumImageSize : new Cartesian2(29.0, 31.0), + lifetime : 32.0 }; var p = new ParticleSystem(options); expect(p.show).toEqual(options.show); - expect(p.forces).toEqual(options.forces); + expect(p.updateCallback).toEqual(options.updateCallback); expect(p.emitter).toEqual(options.emitter); expect(p.modelMatrix).toEqual(options.modelMatrix); expect(p.emitterModelMatrix).toEqual(options.emitterModelMatrix); @@ -99,21 +99,19 @@ defineSuite([ expect(p.endColor).toEqual(options.endColor); expect(p.startScale).toEqual(options.startScale); expect(p.endScale).toEqual(options.endScale); - expect(p.rate).toEqual(options.rate); + expect(p.emissionRate).toEqual(options.emissionRate); expect(p.bursts).toEqual(options.bursts); expect(p.loop).toEqual(options.loop); expect(p.minimumSpeed).toEqual(options.minimumSpeed); expect(p.maximumSpeed).toEqual(options.maximumSpeed); - expect(p.minimumLife).toEqual(options.minimumLife); - expect(p.maximumLife).toEqual(options.maximumLife); + expect(p.minimumParticleLife).toEqual(options.minimumParticleLife); + expect(p.maximumParticleLife).toEqual(options.maximumParticleLife); expect(p.minimumMass).toEqual(options.minimumMass); expect(p.maximumMass).toEqual(options.maximumMass); expect(p.image).toEqual(options.image); - expect(p.minimumWidth).toEqual(options.minimumWidth); - expect(p.maximumWidth).toEqual(options.maximumWidth); - expect(p.minimumHeight).toEqual(options.minimumHeight); - expect(p.maximumHeight).toEqual(options.maximumHeight); - expect(p.lifeTime).toEqual(options.lifeTime); + expect(p.minimumImageSize).toEqual(options.minimumImageSize); + expect(p.maximumImageSize).toEqual(options.maximumImageSize); + expect(p.lifetime).toEqual(options.lifetime); expect(p.complete).toBeDefined(); expect(p.isComplete).toEqual(false); }); @@ -128,21 +126,19 @@ defineSuite([ var endColor = Color.LAVENDAR_BLUSH; var startScale = 19.0; var endScale = 20.0; - var rate = 21.0; + var emissionRate = 21.0; var bursts = [new ParticleBurst()]; var loop = false; var minimumSpeed = 22.0; var maximumSpeed = 23.0; - var minimumLife = 24.0; - var maximumLife = 25.0; + var minimumParticleLife = 24.0; + var maximumParticleLife = 25.0; var minimumMass = 26.0; var maximumMass = 27.0; var image = 'url/to/image'; - var minimumWidth = 28.0; - var maximumWidth = 29.0; - var minimumHeight = 30.0; - var maximumHeight = 31.0; - var lifeTime = 32.0; + var minimumImageSize = new Cartesian2(28.0, 30.0); + var maximumImageSize = new Cartesian2(29.0, 31.0); + var lifetime = 32.0; var p = new ParticleSystem(); p.show = show; @@ -154,21 +150,19 @@ defineSuite([ p.endColor = endColor; p.startScale = startScale; p.endScale = endScale; - p.rate = rate; + p.emissionRate = emissionRate; p.bursts = bursts; p.loop = loop; p.minimumSpeed = minimumSpeed; p.maximumSpeed = maximumSpeed; - p.minimumLife = minimumLife; - p.maximumLife = maximumLife; + p.minimumParticleLife = minimumParticleLife; + p.maximumParticleLife = maximumParticleLife; p.minimumMass = minimumMass; p.maximumMass = maximumMass; p.image = image; - p.minimumWidth = minimumWidth; - p.maximumWidth = maximumWidth; - p.minimumHeight = minimumHeight; - p.maximumHeight = maximumHeight; - p.lifeTime = lifeTime; + p.minimumImageSize = Cartesian2.clone(minimumImageSize, new Cartesian2()); + p.maximumImageSize = Cartesian2.clone(maximumImageSize, new Cartesian2()); + p.lifetime = lifetime; expect(p.show).toEqual(show); expect(p.forces).toEqual(forces); @@ -179,21 +173,19 @@ defineSuite([ expect(p.endColor).toEqual(endColor); expect(p.startScale).toEqual(startScale); expect(p.endScale).toEqual(endScale); - expect(p.rate).toEqual(rate); + expect(p.emissionRate).toEqual(emissionRate); expect(p.bursts).toEqual(bursts); expect(p.loop).toEqual(loop); expect(p.minimumSpeed).toEqual(minimumSpeed); expect(p.maximumSpeed).toEqual(maximumSpeed); - expect(p.minimumLife).toEqual(minimumLife); - expect(p.maximumLife).toEqual(maximumLife); + expect(p.minimumParticleLife).toEqual(minimumParticleLife); + expect(p.maximumParticleLife).toEqual(maximumParticleLife); expect(p.minimumMass).toEqual(minimumMass); expect(p.maximumMass).toEqual(maximumMass); expect(p.image).toEqual(image); - expect(p.minimumWidth).toEqual(minimumWidth); - expect(p.maximumWidth).toEqual(maximumWidth); - expect(p.minimumHeight).toEqual(minimumHeight); - expect(p.maximumHeight).toEqual(maximumHeight); - expect(p.lifeTime).toEqual(lifeTime); + expect(p.minimumImageSize).toEqual(minimumImageSize); + expect(p.maximumImageSize).toEqual(maximumImageSize); + expect(p.lifetime).toEqual(lifetime); expect(p.complete).toBeDefined(); expect(p.isComplete).toEqual(false); }); @@ -247,10 +239,10 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('throws with invalid rate', function() { + it('throws with invalid emissionRate', function() { var p = new ParticleSystem(); expect(function() { - p.rate = -1.0; + p.emissionRate = -1.0; }).toThrowDeveloperError(); }); @@ -268,17 +260,17 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('throws with invalid minimumLife', function() { + it('throws with invalid minimumParticleLife', function() { var p = new ParticleSystem(); expect(function() { - p.minimumLife = -1.0; + p.minimumParticleLife = -1.0; }).toThrowDeveloperError(); }); - it('throws with invalid maximumLife', function() { + it('throws with invalid maximumParticleLife', function() { var p = new ParticleSystem(); expect(function() { - p.maximumLife = -1.0; + p.maximumParticleLife = -1.0; }).toThrowDeveloperError(); }); @@ -299,35 +291,35 @@ defineSuite([ it('throws with invalid minimumWidth', function() { var p = new ParticleSystem(); expect(function() { - p.minimumWidth = -1.0; + p.minimumImageSize = new Cartesian2(-1.0, 2.0); }).toThrowDeveloperError(); }); it('throws with invalid maximumWidth', function() { var p = new ParticleSystem(); expect(function() { - p.maximumWidth = -1.0; + p.maximumImageSize = new Cartesian2(-1.0, 2.0); }).toThrowDeveloperError(); }); it('throws with invalid minimumHeight', function() { var p = new ParticleSystem(); expect(function() { - p.minimumHeight = -1.0; + p.minimumImageSize = new Cartesian2(2.0, -1.0); }).toThrowDeveloperError(); }); it('throws with invalid maximumHeight', function() { var p = new ParticleSystem(); expect(function() { - p.maximumHeight = -1.0; + p.maximumImageSize = new Cartesian2(2.0, -1.0); }).toThrowDeveloperError(); }); - it('throws with invalid lifeTime', function() { + it('throws with invalid lifetime', function() { var p = new ParticleSystem(); expect(function() { - p.lifeTime = -1.0; + p.lifetime = -1.0; }).toThrowDeveloperError(); }); @@ -335,9 +327,8 @@ defineSuite([ scene.primitives.add(new ParticleSystem({ image : greenImage, emitter : new CircleEmitter(1.0), - rate : 10000, - width : 100, - height : 100 + emissoinRate : 10000, + imageSize : new Cartesian2(100, 100) })); scene.camera.position = new Cartesian3(0.0, 0.0, 20.0); scene.camera.direction = new Cartesian3(0.0, 0.0, -1.0);