diff --git a/CHANGES.md b/CHANGES.md index 098ea3f57417..2b89d6087366 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,8 @@ Change Log ### 1.46 - 2018-06-01 ##### Breaking Changes :mega: +* `ParticleSystem` no longer uses `forces`. [#6510](https://github.com/AnalyticalGraphicsInc/cesium/pull/6510) +* `Particle` no longer uses `size`, `rate`, `lifeTime`, `life`, `minimumLife`, `maximumLife`, `minimumWidth`, `minimumHeight`, `maximumWidth`, and `maximumHeight`. [#6510](https://github.com/AnalyticalGraphicsInc/cesium/pull/6510) * Removed `Scene.copyGlobeDepth`. Globe depth will now be copied by default when supported. [#6393](https://github.com/AnalyticalGraphicsInc/cesium/pull/6393) * The default `classificationType` for `GroundPrimitive`, `CorridorGraphics`, `EllipseGraphics`, `PolygonGraphics` and `RectangleGraphics` is now `ClassificationType.TERRAIN`. If you wish the geometry to color both terrain and 3D tiles, pass in the option `classificationType: Cesium.ClassificationType.BOTH`. diff --git a/Source/Scene/Particle.js b/Source/Scene/Particle.js index 4c1c64490b59..4bfe76569594 100644 --- a/Source/Scene/Particle.js +++ b/Source/Scene/Particle.js @@ -1,19 +1,19 @@ define([ '../Core/Cartesian2', '../Core/Cartesian3', + '../Core/Check', '../Core/Color', '../Core/defaultValue', '../Core/defined', - '../Core/defineProperties', - '../Core/deprecationWarning' + '../Core/defineProperties' ], function( Cartesian2, Cartesian3, + Check, Color, defaultValue, defined, - defineProperties, - deprecationWarning) { + defineProperties) { 'use strict'; var defaultSize = new Cartesian2(1.0, 1.0); @@ -34,7 +34,6 @@ define([ * @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. 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) { @@ -100,10 +99,6 @@ define([ * @default new Cartesian(1.0, 1.0) */ 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; @@ -132,23 +127,6 @@ define([ get : function() { return this._normalizedAge; } - }, - /** - * The dimensions of the particle in pixels. This has been deprecated. Use {@link Particle#imageSize} instead. - * @memberof Particle.prototype - * @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; - } } }); @@ -164,18 +142,7 @@ define([ // Update any forces. 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); - } - } - } + particleUpdateFunction(this, dt); } // Age the particle diff --git a/Source/Scene/ParticleSystem.js b/Source/Scene/ParticleSystem.js index 9cf632368a3c..940ede56a5df 100644 --- a/Source/Scene/ParticleSystem.js +++ b/Source/Scene/ParticleSystem.js @@ -6,7 +6,6 @@ define([ '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', - '../Core/deprecationWarning', '../Core/destroyObject', '../Core/Event', '../Core/JulianDate', @@ -23,7 +22,6 @@ define([ defaultValue, defined, defineProperties, - deprecationWarning, destroyObject, Event, JulianDate, @@ -44,12 +42,10 @@ 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. 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 {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 its bursts when it is complete. @@ -60,23 +56,13 @@ define([ * @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=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. @@ -103,16 +89,7 @@ define([ * @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 - */ - 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} @@ -147,80 +124,20 @@ define([ this._endScale = defaultValue(options.scale, defaultValue(options.endScale, 1.0)); 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)); - 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)); - 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.'); - } - - 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); - 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 = []; @@ -376,23 +293,6 @@ define([ this._endScale = value; } }, - /** - * 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() { - 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 @@ -445,23 +345,6 @@ define([ this._maximumSpeed = value; } }, - /** - * 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() { - 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 @@ -479,23 +362,6 @@ define([ this._minimumParticleLife = value; } }, - /** - * 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() { - 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 @@ -548,82 +414,6 @@ define([ this._maximumMass = value; } }, - /** - * 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() { - 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) { - 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. This has been deprecated. Use {@link ParticleSystem#maximumImageSize} instead. - * @memberof ParticleSystem.prototype - * @type {Number} - * @default 1.0 - * @deprecated - */ - maximumWidth : { - get : function() { - 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) { - 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. This has been deprecated. Use {@link ParticleSystem#minimumImageSize} instead. - * @memberof ParticleSystem.prototype - * @type {Number} - * @default 1.0 - * @deprecated - */ - minimumHeight : { - get : function() { - 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) { - 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. This has been deprecated. Use {@link ParticleSystem#maximumImageSize} instead. - * @memberof ParticleSystem.prototype - * @type {Number} - * @default 1.0 - * @deprecated - */ - maximumHeight : { - get : function() { - 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 @@ -662,23 +452,6 @@ define([ 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() { - 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 @@ -1030,24 +803,5 @@ define([ * } */ - /** - * 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; - * 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); - * } - */ - return ParticleSystem; }); diff --git a/Specs/Scene/ParticleSpec.js b/Specs/Scene/ParticleSpec.js index 00b45c6c67da..cfefce359c99 100644 --- a/Specs/Scene/ParticleSpec.js +++ b/Specs/Scene/ParticleSpec.js @@ -50,7 +50,7 @@ defineSuite([ expect(p.imageSize).toEqual(options.imageSize); }); - it('update without forces', function() { + it('update without update function', function() { 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({ @@ -70,36 +70,6 @@ defineSuite([ expect(p.update(dt)).toEqual(false); }); - it('update with forces', function() { - var times2 = function(particle, dt) { - Cartesian3.add(particle.position, Cartesian3.multiplyByScalar(particle.velocity, dt, new Cartesian3()), particle.position); - }; - var increaseMass = function(particle, dt) { - particle.mass++; - }; - var forces = [times2, 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 expectedPosition = Cartesian3.add(p.position, Cartesian3.multiplyByScalar(p.velocity, 2.0 * dt, new Cartesian3()), new Cartesian3()); - var expectedMass = p.mass + 1; - - 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); - }); - it('update with updateFunction', function() { var increaseMass = function(particle, dt) { particle.mass++;