From 32f61254e7a85fa74152ac1de61b7ff9ef737fea Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Mon, 14 Apr 2014 21:56:15 -0400 Subject: [PATCH 01/10] Factor out Visualizer interface It turns out a `Visualizer` instance only needs `update` and `destroy` functions. Also start cleaning up other visualizer to conform to the interface and remove uneeded cruft. --- Source/DynamicScene/DynamicModelVisualizer.js | 117 +++---------- Source/DynamicScene/GeometryVisualizer.js | 164 ++++++------------ Source/DynamicScene/Visualizer.js | 37 ++++ Specs/DynamicScene/GeometryVisualizerSpec.js | 14 +- 4 files changed, 117 insertions(+), 215 deletions(-) create mode 100644 Source/DynamicScene/Visualizer.js diff --git a/Source/DynamicScene/DynamicModelVisualizer.js b/Source/DynamicScene/DynamicModelVisualizer.js index 61c2b26aafc7..3cbe925f1451 100644 --- a/Source/DynamicScene/DynamicModelVisualizer.js +++ b/Source/DynamicScene/DynamicModelVisualizer.js @@ -24,67 +24,34 @@ define([ var matrix3Scratch = new Matrix3(); /** - * A {@link DynamicObject} visualizer which maps the {@link DynamicModel} instance - * in DynamicObject.model to a {@link Model} primitive. + * A {@link Visualizer} which maps the {@link DynamicModel} instance + * in {@link DynamicObject.model} to a {@link Model} primitive. * @alias DynamicModelVisualizer * @constructor * * @param {Scene} scene The scene the primitives will be rendered in. - * @param {DynamicObjectCollection} [dynamicObjectCollection] The dynamicObjectCollection to visualize. + * @param {DynamicObjectCollection} dynamicObjectCollection The dynamicObjectCollection to visualize. */ var DynamicModelVisualizer = function(scene, dynamicObjectCollection) { //>>includeStart('debug', pragmas.debug); if (!defined(scene)) { throw new DeveloperError('scene is required.'); } + if (!defined(dynamicObjectCollection)) { + throw new DeveloperError('dynamicObjectCollection is required.'); + } //>>includeEnd('debug'); this._scene = scene; this._primitives = scene.primitives; this._modelCollection = []; this._dynamicObjectCollection = undefined; - this.setDynamicObjectCollection(dynamicObjectCollection); - }; - - /** - * Returns the scene being used by this visualizer. - * - * @returns {Scene} The scene being used by this visualizer. - */ - DynamicModelVisualizer.prototype.getScene = function() { - return this._scene; - }; - - /** - * Gets the DynamicObjectCollection being visualized. - * - * @returns {DynamicObjectCollection} The DynamicObjectCollection being visualized. - */ - DynamicModelVisualizer.prototype.getDynamicObjectCollection = function() { - return this._dynamicObjectCollection; - }; - - /** - * Sets the DynamicObjectCollection to visualize. - * - * @param dynamicObjectCollection The DynamicObjectCollection to visualizer. - */ - DynamicModelVisualizer.prototype.setDynamicObjectCollection = function(dynamicObjectCollection) { - var oldCollection = this._dynamicObjectCollection; - if (oldCollection !== dynamicObjectCollection) { - if (defined(oldCollection)) { - oldCollection.collectionChanged.removeEventListener(DynamicModelVisualizer.prototype._onObjectsRemoved, this); - this.removeAllPrimitives(); - } - this._dynamicObjectCollection = dynamicObjectCollection; - if (defined(dynamicObjectCollection)) { - dynamicObjectCollection.collectionChanged.addEventListener(DynamicModelVisualizer.prototype._onObjectsRemoved, this); - } - } + this._dynamicObjectCollection = dynamicObjectCollection; + dynamicObjectCollection.collectionChanged.addEventListener(DynamicModelVisualizer.prototype._onObjectsRemoved, this); }; /** - * Updates all of the primitives created by this visualizer to match their + * Updates all models created this visualizer to match their * DynamicObject counterpart at the given time. * * @param {JulianDate} time The time to update to. @@ -107,64 +74,27 @@ define([ }; /** - * Removes all primitives from the scene. + * Removes and destroys all models created by this instance. + * @memberof DynamicModelVisualizer */ - DynamicModelVisualizer.prototype.removeAllPrimitives = function() { - if (defined(this._dynamicObjectCollection)) { - var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for (var i = dynamicObjects.length - 1; i > -1; i--) { - var model = dynamicObjects[i]._modelPrimitive; - if (defined(model)) { - this._primitives.remove(model); - if (!model.isDestroyed()) { - model.destroy(); - } - model = undefined; + DynamicModelVisualizer.prototype.destroy = function() { + var dynamicObjects = this._dynamicObjectCollection.getObjects(); + for (var i = dynamicObjects.length - 1; i > -1; i--) { + var model = dynamicObjects[i]._modelPrimitive; + if (defined(model)) { + this._primitives.remove(model); + if (!model.isDestroyed()) { + model.destroy(); } + model = undefined; } } + return destroyObject(this); }; /** - * Returns true if this object was destroyed; otherwise, false. - *

- * If this object was destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. - * - * @memberof DynamicModelVisualizer - * - * @return {Boolean} True if this object was destroyed; otherwise, false. - * - * @see DynamicModelVisualizer#destroy - */ - DynamicModelVisualizer.prototype.isDestroyed = function() { - return false; - }; - - /** - * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic - * release of WebGL resources, instead of relying on the garbage collector to destroy this object. - *

- * Once an object is destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. Therefore, - * assign the return value (undefined) to the object as done in the example. - * - * @memberof DynamicModelVisualizer - * - * @return {undefined} - * - * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called. - * - * @see DynamicModelVisualizer#isDestroyed - * - * @example - * visualizer = visualizer && visualizer.destroy(); + * @private */ - DynamicModelVisualizer.prototype.destroy = function() { - this.removeAllPrimitives(); - return destroyObject(this); - }; - DynamicModelVisualizer.prototype._updateObject = function(time, dynamicObject) { var context = this._scene._context; var dynamicModel = dynamicObject._model; @@ -238,6 +168,9 @@ define([ } }; + /** + * @private + */ DynamicModelVisualizer.prototype._onObjectsRemoved = function(dynamicObjectCollection, added, removed) { for (var i = removed.length - 1; i > -1; i--) { var dynamicObject = removed[i]; diff --git a/Source/DynamicScene/GeometryVisualizer.js b/Source/DynamicScene/GeometryVisualizer.js index 20aaf5208b97..bdea89495b38 100644 --- a/Source/DynamicScene/GeometryVisualizer.js +++ b/Source/DynamicScene/GeometryVisualizer.js @@ -54,6 +54,43 @@ define(['../Core/AssociativeArray', this._dynamicUpdaters.removeAll(); }; + function removeUpdater(that, updater) { + //We don't keep track of which batch an updater is in, so just remove it from all of them. + that._outlineBatch.remove(updater); + that._closedColorBatch.remove(updater); + that._closedMaterialBatch.remove(updater); + that._openColorBatch.remove(updater); + that._openMaterialBatch.remove(updater); + that._dynamicBatch.remove(updater); + } + + function insertUpdaterIntoBatch(that, time, updater) { + if (updater.isDynamic) { + that._dynamicBatch.add(time, updater); + return; + } + + if (updater.outlineEnabled) { + that._outlineBatch.add(time, updater); + } + + if (updater.fillEnabled) { + if (updater.isClosed) { + if (updater.fillMaterialProperty instanceof ColorMaterialProperty) { + that._closedColorBatch.add(time, updater); + } else { + that._closedMaterialBatch.add(time, updater); + } + } else { + if (updater.fillMaterialProperty instanceof ColorMaterialProperty) { + that._openColorBatch.add(time, updater); + } else { + that._openMaterialBatch.add(time, updater); + } + } + } + } + /** * A general purpose visualizer for all graphics that can be represented by {@link Primitive} instances. * @alias GeometryVisualizer @@ -61,7 +98,7 @@ define(['../Core/AssociativeArray', * * @param {GeometryUpdater} type The updater to be used for creating the geometry. * @param {Scene} scene The scene the primitives will be rendered in. - * @param {DynamicObjectCollection} [dynamicObjectCollection] The dynamicObjectCollection to visualize. + * @param {DynamicObjectCollection} dynamicObjectCollection The dynamicObjectCollection to visualize. */ var GeometryVisualizer = function(type, scene, dynamicObjectCollection) { //>>includeStart('debug', pragmas.debug); @@ -71,6 +108,9 @@ define(['../Core/AssociativeArray', if (!defined(scene)) { throw new DeveloperError('scene is required.'); } + if (!defined(dynamicObjectCollection)) { + throw new DeveloperError('dynamicObjectCollection is required.'); + } //>>includeEnd('debug'); this._type = type; @@ -92,88 +132,12 @@ define(['../Core/AssociativeArray', this._subscriptions = new AssociativeArray(); this._updaters = new AssociativeArray(); - this.setDynamicObjectCollection(dynamicObjectCollection); - }; - /** - * Returns the scene being used by this visualizer. - * @memberof GeometryVisualizer - * - * @returns {Scene} The scene being used by this visualizer. - */ - GeometryVisualizer.prototype.getScene = function() { - return this._scene; + this._dynamicObjectCollection = dynamicObjectCollection; + dynamicObjectCollection.collectionChanged.addEventListener(GeometryVisualizer.prototype._onCollectionChanged, this); + this._onCollectionChanged(dynamicObjectCollection, dynamicObjectCollection.getObjects(), emptyArray); }; - /** - * Gets the DynamicObjectCollection being visualized. - * @memberof GeometryVisualizer - * - * @returns {DynamicObjectCollection} The DynamicObjectCollection being visualized. - */ - GeometryVisualizer.prototype.getDynamicObjectCollection = function() { - return this._dynamicObjectCollection; - }; - - /** - * Sets the DynamicObjectCollection to visualize. - * @memberof GeometryVisualizer - * - * @param {DynamicObjectCollection} dynamicObjectCollection The DynamicObjectCollection to visualizer. - */ - GeometryVisualizer.prototype.setDynamicObjectCollection = function(dynamicObjectCollection) { - var oldCollection = this._dynamicObjectCollection; - if (oldCollection !== dynamicObjectCollection) { - if (defined(oldCollection)) { - oldCollection.collectionChanged.removeEventListener(GeometryVisualizer.prototype._onCollectionChanged, this); - this.removeAllPrimitives(); - } - this._dynamicObjectCollection = dynamicObjectCollection; - if (defined(dynamicObjectCollection)) { - dynamicObjectCollection.collectionChanged.addEventListener(GeometryVisualizer.prototype._onCollectionChanged, this); - //Add all existing items to the collection. - this._onCollectionChanged(dynamicObjectCollection, dynamicObjectCollection.getObjects(), emptyArray); - } - } - }; - - function removeUpdater(that, updater) { - //We don't keep track of which batch an updater is in, so just remove it from all of them. - that._outlineBatch.remove(updater); - that._closedColorBatch.remove(updater); - that._closedMaterialBatch.remove(updater); - that._openColorBatch.remove(updater); - that._openMaterialBatch.remove(updater); - that._dynamicBatch.remove(updater); - } - - function insertUpdaterIntoBatch(that, time, updater) { - if (updater.isDynamic) { - that._dynamicBatch.add(time, updater); - return; - } - - if (updater.outlineEnabled) { - that._outlineBatch.add(time, updater); - } - - if (updater.fillEnabled) { - if (updater.isClosed) { - if (updater.fillMaterialProperty instanceof ColorMaterialProperty) { - that._closedColorBatch.add(time, updater); - } else { - that._closedMaterialBatch.add(time, updater); - } - } else { - if (updater.fillMaterialProperty instanceof ColorMaterialProperty) { - that._openColorBatch.add(time, updater); - } else { - that._openMaterialBatch.add(time, updater); - } - } - } - } - /** * Updates all of the primitives created by this visualizer to match their * DynamicObject counterpart at the given time. @@ -190,7 +154,6 @@ define(['../Core/AssociativeArray', } //>>includeEnd('debug'); - var addedObjects = this._addedObjects; var added = addedObjects.values; var removedObjects = this._removedObjects; @@ -245,10 +208,17 @@ define(['../Core/AssociativeArray', }; /** - * Removes all primitives from the scene. + * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic + * release of WebGL resources, instead of relying on the garbage collector to destroy this object. + *

+ * Once an object is destroyed, it should not be used; calling any function other than + * isDestroyed will result in a {@link DeveloperError} exception. Therefore, + * assign the return value (undefined) to the object as done in the example. * @memberof GeometryVisualizer + * + * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called. */ - GeometryVisualizer.prototype.removeAllPrimitives = function() { + GeometryVisualizer.prototype.destroy = function() { this._addedObjects.removeAll(); this._removedObjects.removeAll(); @@ -265,34 +235,6 @@ define(['../Core/AssociativeArray', subscriptions[i](); } this._subscriptions.removeAll(); - }; - - /** - * Returns true if this object was destroyed; otherwise, false. - *

- * If this object was destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. - * @memberof GeometryVisualizer - * - * @returns {Boolean} True if this object was destroyed; otherwise, false. - */ - GeometryVisualizer.prototype.isDestroyed = function() { - return false; - }; - - /** - * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic - * release of WebGL resources, instead of relying on the garbage collector to destroy this object. - *

- * Once an object is destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. Therefore, - * assign the return value (undefined) to the object as done in the example. - * @memberof GeometryVisualizer - * - * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called. - */ - GeometryVisualizer.prototype.destroy = function() { - this.removeAllPrimitives(); return destroyObject(this); }; diff --git a/Source/DynamicScene/Visualizer.js b/Source/DynamicScene/Visualizer.js new file mode 100644 index 000000000000..7a324e2f9c9d --- /dev/null +++ b/Source/DynamicScene/Visualizer.js @@ -0,0 +1,37 @@ +/*global define*/ +define(['../Core/DeveloperError'], function(DeveloperError) { + "use strict"; + + /** + * Defines the interface for visualizers. Visualizers are plug-ins to + * {@link DataSourceDisplay} that render data associated with + * {@link DataSource} instances. + * This object is an interface for documentation purposes and is not intended + * to be instantiated directly. + * @alias Visualizer + * @constructor + */ + var Visualizer = function() { + DeveloperError.throwInstantiationError(); + }; + + /** + * Updates the visualization to the provided time. + * @memberof Visualizer + * + * @param {JulianDate} time The time. + * + * @returns {Boolean} True if the display was updated to the provided time, + * false if the visualizer is waiting for an asynchronous operation to + * complete before data can be updated. + */ + Visualizer.prototype.update = DeveloperError.throwInstantiationError(); + + /** + * Removes all visualization and cleans up any resources associated with this instance. + * @memberof Visualizer + */ + Visualizer.prototype.destroy = DeveloperError.throwInstantiationError(); + + return Visualizer; +}); \ No newline at end of file diff --git a/Specs/DynamicScene/GeometryVisualizerSpec.js b/Specs/DynamicScene/GeometryVisualizerSpec.js index 2e60d3e70d99..0c5d09a9b39b 100644 --- a/Specs/DynamicScene/GeometryVisualizerSpec.js +++ b/Specs/DynamicScene/GeometryVisualizerSpec.js @@ -50,20 +50,10 @@ defineSuite(['DynamicScene/GeometryVisualizer', destroyScene(scene); }); - it('Constructor sets expected values', function() { + it('Can create and destroy', function() { var objects = new DynamicObjectCollection(); var visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene, objects); - expect(visualizer.getScene()).toBe(scene); - expect(visualizer.getDynamicObjectCollection()).toBe(objects); - visualizer.update(time); - expect(scene.primitives.length).toBe(0); - expect(visualizer.isDestroyed()).toBe(false); - visualizer.destroy(); - expect(visualizer.isDestroyed()).toBe(true); - - visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene); - expect(visualizer.getDynamicObjectCollection()).toBeUndefined(); - visualizer.update(time); + expect(visualizer.update(time)).toBe(true); expect(scene.primitives.length).toBe(0); visualizer.destroy(); }); From cb8e7d6cb20bd0c4ece0b0d053307aee88ba97d3 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Sat, 26 Apr 2014 22:16:05 -0400 Subject: [PATCH 02/10] Ongoing visualizer cleanup. --- .../DynamicBillboardVisualizer.js | 132 ++++-------------- .../DynamicConeVisualizerUsingCustomSensor.js | 127 ++++------------- Source/DynamicScene/DynamicLabelVisualizer.js | 125 +++-------------- Source/DynamicScene/DynamicModelVisualizer.js | 13 +- Source/DynamicScene/DynamicPathVisualizer.js | 121 +++------------- Source/DynamicScene/DynamicPointVisualizer.js | 130 ++++------------- .../DynamicScene/DynamicPyramidVisualizer.js | 126 +++-------------- .../DynamicScene/DynamicVectorVisualizer.js | 124 +++------------- Source/DynamicScene/GeometryVisualizer.js | 9 +- Source/DynamicScene/Visualizer.js | 4 +- Specs/DynamicScene/DataSourceDisplaySpec.js | 4 - .../DynamicBillboardVisualizerSpec.js | 49 +------ ...amicConeVisualizerUsingCustomSensorSpec.js | 53 ------- .../DynamicLabelVisualizerSpec.js | 49 +------ .../DynamicModelVisualizerSpec.js | 20 --- .../DynamicScene/DynamicPathVisualizerSpec.js | 76 ---------- .../DynamicPointVisualizerSpec.js | 47 +------ .../DynamicPyramidVisualizerSpec.js | 51 ------- .../DynamicVectorVisualizerSpec.js | 56 +------- 19 files changed, 176 insertions(+), 1140 deletions(-) diff --git a/Source/DynamicScene/DynamicBillboardVisualizer.js b/Source/DynamicScene/DynamicBillboardVisualizer.js index 857e90a928b9..b646cecfa18d 100644 --- a/Source/DynamicScene/DynamicBillboardVisualizer.js +++ b/Source/DynamicScene/DynamicBillboardVisualizer.js @@ -23,7 +23,6 @@ define([ TextureAtlasBuilder) { "use strict"; - //Callback to create a callback so that we close over all of the proper values. function textureReady(dynamicObject, billboardCollection, textureValue) { return function(imageIndex) { //By the time the texture was loaded, the billboard might already be @@ -41,83 +40,42 @@ define([ } /** - * A DynamicObject visualizer which maps the DynamicBillboard instance - * in DynamicObject.billboard to a Billboard primitive. + * A {@link Visualizer} which maps the {@link DynamicBillboard} instance + * in {@link DynamicObject.billboard} to a {@link Billboard}. * @alias DynamicBillboardVisualizer * @constructor * * @param {Scene} scene The scene the primitives will be rendered in. - * @param {DynamicObjectCollection} [dynamicObjectCollection] The dynamicObjectCollection to visualize. - * - * @see DynamicBillboard - * @see DynamicObject - * @see DynamicObjectCollection - * @see CompositeDynamicObjectCollection - * @see DynamicConeVisualizer - * @see DynamicConeVisualizerUsingCustomSensor - * @see DynamicLabelVisualizer - * @see DynamicPointVisualizer - * @see DynamicPyramidVisualizer + * @param {DynamicObjectCollection} dynamicObjectCollection The dynamicObjectCollection to visualize. */ var DynamicBillboardVisualizer = function(scene, dynamicObjectCollection) { //>>includeStart('debug', pragmas.debug); if (!defined(scene)) { throw new DeveloperError('scene is required.'); } + if (!defined(dynamicObjectCollection)) { + throw new DeveloperError('dynamicObjectCollection is required.'); + } //>>includeEnd('debug'); - this._scene = scene; - this._unusedIndexes = []; - this._dynamicObjectCollection = undefined; - - var billboardCollection = this._billboardCollection = new BillboardCollection(); - var atlas = this._textureAtlas = scene.createTextureAtlas(); - this._textureAtlasBuilder = new TextureAtlasBuilder(atlas); + var billboardCollection = new BillboardCollection(); + var atlas = scene.createTextureAtlas(); billboardCollection.textureAtlas = atlas; scene.primitives.add(billboardCollection); - this.setDynamicObjectCollection(dynamicObjectCollection); - }; + dynamicObjectCollection.collectionChanged.addEventListener(DynamicBillboardVisualizer.prototype._onObjectsRemoved, this); - /** - * Returns the scene being used by this visualizer. - * - * @returns {Scene} The scene being used by this visualizer. - */ - DynamicBillboardVisualizer.prototype.getScene = function() { - return this._scene; - }; - - /** - * Gets the DynamicObjectCollection being visualized. - * - * @returns {DynamicObjectCollection} The DynamicObjectCollection being visualized. - */ - DynamicBillboardVisualizer.prototype.getDynamicObjectCollection = function() { - return this._dynamicObjectCollection; - }; - - /** - * Sets the DynamicObjectCollection to visualize. - * - * @param dynamicObjectCollection The DynamicObjectCollection to visualizer. - */ - DynamicBillboardVisualizer.prototype.setDynamicObjectCollection = function(dynamicObjectCollection) { - var oldCollection = this._dynamicObjectCollection; - if (oldCollection !== dynamicObjectCollection) { - if (defined(oldCollection)) { - oldCollection.collectionChanged.removeEventListener(DynamicBillboardVisualizer.prototype._onObjectsRemoved, this); - this.removeAllPrimitives(); - } - this._dynamicObjectCollection = dynamicObjectCollection; - if (defined(dynamicObjectCollection)) { - dynamicObjectCollection.collectionChanged.addEventListener(DynamicBillboardVisualizer.prototype._onObjectsRemoved, this); - } - } + this._scene = scene; + this._unusedIndexes = []; + this._textureAtlas = atlas; + this._billboardCollection = billboardCollection; + this._textureAtlasBuilder = new TextureAtlasBuilder(atlas); + this._dynamicObjectCollection = dynamicObjectCollection; }; /** * Updates all of the primitives created by this visualizer to match their * DynamicObject counterpart at the given time. + * @memberof DynamicBillboardVisualizer * * @param {JulianDate} time The time to update to. * @returns {Boolean} This function always returns true. @@ -131,7 +89,7 @@ define([ if (defined(this._dynamicObjectCollection)) { var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for ( var i = 0, len = dynamicObjects.length; i < len; i++) { + for (var i = 0, len = dynamicObjects.length; i < len; i++) { updateObject(this, time, dynamicObjects[i]); } } @@ -139,56 +97,18 @@ define([ }; /** - * Removes all primitives from the scene. - */ - DynamicBillboardVisualizer.prototype.removeAllPrimitives = function() { - if (defined(this._dynamicObjectCollection)) { - this._unusedIndexes = []; - this._billboardCollection.removeAll(); - var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for ( var i = dynamicObjects.length - 1; i > -1; i--) { - dynamicObjects[i]._billboardVisualizerIndex = undefined; - } - } - }; - - /** - * Returns true if this object was destroyed; otherwise, false. - *

- * If this object was destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. - * + * Removes and destroys all primitives created by this instance. * @memberof DynamicBillboardVisualizer - * - * @returns {Boolean} True if this object was destroyed; otherwise, false. - * - * @see DynamicBillboardVisualizer#destroy - */ - DynamicBillboardVisualizer.prototype.isDestroyed = function() { - return false; - }; - - /** - * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic - * release of WebGL resources, instead of relying on the garbage collector to destroy this object. - *

- * Once an object is destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. Therefore, - * assign the return value (undefined) to the object as done in the example. - * - * @memberof DynamicBillboardVisualizer - * - * @returns {undefined} - * - * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called. - * - * @see DynamicBillboardVisualizer#isDestroyed - * - * @example - * visualizer = visualizer && visualizer.destroy(); */ DynamicBillboardVisualizer.prototype.destroy = function() { - this.setDynamicObjectCollection(undefined); + var dynamicObjectCollection = this._dynamicObjectCollection; + dynamicObjectCollection.collectionChanged.removeEventListener(DynamicBillboardVisualizer.prototype._onObjectsRemoved, this); + + var dynamicObjects = dynamicObjectCollection.getObjects(); + var length = dynamicObjects.length; + for (var i = 0; i < length; i++) { + dynamicObjects[i]._billboardVisualizerIndex = undefined; + } this._scene.primitives.remove(this._billboardCollection); return destroyObject(this); }; diff --git a/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js b/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js index 097eb6e6ef27..ba8be7d3d404 100644 --- a/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js +++ b/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js @@ -77,79 +77,37 @@ define([ } /** - * A DynamicObject visualizer which maps the DynamicCone instance - * in DynamicObject.cone to a CustomSensor primitive. + * A {@link Visualizer} which maps the {@link DynamicCone} instance + * in {@link DynamicObject.cone} to a {@link CustomSensor}. * @alias DynamicConeVisualizerUsingCustomSensor * @constructor * * @param {Scene} scene The scene the primitives will be rendered in. - * @param {DynamicObjectCollection} [dynamicObjectCollection] The dynamicObjectCollection to visualize. - * - * @see DynamicCone - * @see DynamicObject - * @see DynamicObjectCollection - * @see CompositeDynamicObjectCollection - * @see DynamicBillboardVisualizer - * @see DynamicConeVisualizer - * @see DynamicLabelVisualizer - * @see DynamicPointVisualizer - * @see DynamicPyramidVisualizer + * @param {DynamicObjectCollection} dynamicObjectCollection The dynamicObjectCollection to visualize. */ var DynamicConeVisualizerUsingCustomSensor = function(scene, dynamicObjectCollection) { //>>includeStart('debug', pragmas.debug); if (!defined(scene)) { throw new DeveloperError('scene is required.'); } + if (!defined(dynamicObjectCollection)) { + throw new DeveloperError('dynamicObjectCollection is required.'); + } //>>includeEnd('debug'); + dynamicObjectCollection.collectionChanged.addEventListener(DynamicConeVisualizerUsingCustomSensor.prototype._onObjectsRemoved, this); + this._scene = scene; this._unusedIndexes = []; this._primitives = scene.primitives; this._coneCollection = []; - this._dynamicObjectCollection = undefined; - this.setDynamicObjectCollection(dynamicObjectCollection); - }; - - /** - * Returns the scene being used by this visualizer. - * - * @returns {Scene} The scene being used by this visualizer. - */ - DynamicConeVisualizerUsingCustomSensor.prototype.getScene = function() { - return this._scene; - }; - - /** - * Gets the DynamicObjectCollection being visualized. - * - * @returns {DynamicObjectCollection} The DynamicObjectCollection being visualized. - */ - DynamicConeVisualizerUsingCustomSensor.prototype.getDynamicObjectCollection = function() { - return this._dynamicObjectCollection; - }; - - /** - * Sets the DynamicObjectCollection to visualize. - * - * @param dynamicObjectCollection The DynamicObjectCollection to visualizer. - */ - DynamicConeVisualizerUsingCustomSensor.prototype.setDynamicObjectCollection = function(dynamicObjectCollection) { - var oldCollection = this._dynamicObjectCollection; - if (oldCollection !== dynamicObjectCollection) { - if (defined(oldCollection)) { - oldCollection.collectionChanged.removeEventListener(DynamicConeVisualizerUsingCustomSensor.prototype._onObjectsRemoved, this); - this.removeAllPrimitives(); - } - this._dynamicObjectCollection = dynamicObjectCollection; - if (defined(dynamicObjectCollection)) { - dynamicObjectCollection.collectionChanged.addEventListener(DynamicConeVisualizerUsingCustomSensor.prototype._onObjectsRemoved, this); - } - } + this._dynamicObjectCollection = dynamicObjectCollection; }; /** * Updates all of the primitives created by this visualizer to match their * DynamicObject counterpart at the given time. + * @memberof DynamicLabelVisualizer * * @param {JulianDate} time The time to update to. * @returns {Boolean} This function always returns true. @@ -171,62 +129,25 @@ define([ }; /** - * Removes all primitives from the scene. + * Removes and destroys all primitives created by this instance. + * @memberof DynamicLabelVisualizer */ - DynamicConeVisualizerUsingCustomSensor.prototype.removeAllPrimitives = function() { - var i, len; - for (i = 0, len = this._coneCollection.length; i < len; i++) { - this._primitives.remove(this._coneCollection[i]); + DynamicConeVisualizerUsingCustomSensor.prototype.destroy = function() { + var dynamicObjectCollection = this._dynamicObjectCollection; + dynamicObjectCollection.collectionChanged.removeEventListener(DynamicConeVisualizerUsingCustomSensor.prototype._onObjectsRemoved, this); + + var i; + var dynamicObjects = dynamicObjectCollection.getObjects(); + var length = dynamicObjects.length; + for (i = 0; i < length; i++) { + dynamicObjects[i]._coneVisualizerIndex = undefined; } - if (defined(this._dynamicObjectCollection)) { - var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for (i = dynamicObjects.length - 1; i > -1; i--) { - dynamicObjects[i]._coneVisualizerIndex = undefined; - } + length = this._coneCollection.length; + for (i = 0; i < length; i++) { + this._primitives.remove(this._coneCollection[i]); } - this._unusedIndexes = []; - this._coneCollection = []; - }; - - /** - * Returns true if this object was destroyed; otherwise, false. - *

- * If this object was destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. - * - * @memberof DynamicConeVisualizerUsingCustomSensor - * - * @returns {Boolean} True if this object was destroyed; otherwise, false. - * - * @see DynamicConeVisualizerUsingCustomSensor#destroy - */ - DynamicConeVisualizerUsingCustomSensor.prototype.isDestroyed = function() { - return false; - }; - - /** - * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic - * release of WebGL resources, instead of relying on the garbage collector to destroy this object. - *

- * Once an object is destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. Therefore, - * assign the return value (undefined) to the object as done in the example. - * - * @memberof DynamicConeVisualizerUsingCustomSensor - * - * @returns {undefined} - * - * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called. - * - * @see DynamicConeVisualizerUsingCustomSensor#isDestroyed - * - * @example - * visualizer = visualizer && visualizer.destroy(); - */ - DynamicConeVisualizerUsingCustomSensor.prototype.destroy = function() { - this.setDynamicObjectCollection(undefined); return destroyObject(this); }; diff --git a/Source/DynamicScene/DynamicLabelVisualizer.js b/Source/DynamicScene/DynamicLabelVisualizer.js index 4c0d810637e9..6957a8a98b1f 100644 --- a/Source/DynamicScene/DynamicLabelVisualizer.js +++ b/Source/DynamicScene/DynamicLabelVisualizer.js @@ -24,81 +24,38 @@ define([ "use strict"; /** - * A DynamicObject visualizer which maps the DynamicLabel instance - * in DynamicObject.label to a Label primitive. + * A {@link Visualizer} which maps the {@link DynamicLabel} instance + * in {@link DynamicObject.label} to a {@link Label}. * @alias DynamicLabelVisualizer * @constructor * * @param {Scene} scene The scene the primitives will be rendered in. - * @param {DynamicObjectCollection} [dynamicObjectCollection] The dynamicObjectCollection to visualize. - * - * @see DynamicLabel - * @see Scene - * @see DynamicObject - * @see DynamicObjectCollection - * @see CompositeDynamicObjectCollection - * @see DynamicBillboardVisualizer - * @see DynamicConeVisualizer - * @see DynamicConeVisualizerUsingCustomSensor - * @see DynamicPointVisualizer - * @see DynamicPyramidVisualizer + * @param {DynamicObjectCollection} dynamicObjectCollection The dynamicObjectCollection to visualize. */ var DynamicLabelVisualizer = function(scene, dynamicObjectCollection) { //>>includeStart('debug', pragmas.debug); if (!defined(scene)) { throw new DeveloperError('scene is required.'); } + if (!defined(dynamicObjectCollection)) { + throw new DeveloperError('dynamicObjectCollection is required.'); + } //>>includeEnd('debug'); - this._scene = scene; - this._unusedIndexes = []; - this._dynamicObjectCollection = undefined; - - var labelCollection = this._labelCollection = new LabelCollection(); + var labelCollection = new LabelCollection(); scene.primitives.add(labelCollection); - this.setDynamicObjectCollection(dynamicObjectCollection); - }; + dynamicObjectCollection.collectionChanged.addEventListener(DynamicLabelVisualizer.prototype._onObjectsRemoved, this); - /** - * Returns the scene being used by this visualizer. - * - * @returns {Scene} The scene being used by this visualizer. - */ - DynamicLabelVisualizer.prototype.getScene = function() { - return this._scene; - }; - - /** - * Gets the DynamicObjectCollection being visualized. - * - * @returns {DynamicObjectCollection} The DynamicObjectCollection being visualized. - */ - DynamicLabelVisualizer.prototype.getDynamicObjectCollection = function() { - return this._dynamicObjectCollection; - }; - - /** - * Sets the DynamicObjectCollection to visualize. - * - * @param dynamicObjectCollection The DynamicObjectCollection to visualizer. - */ - DynamicLabelVisualizer.prototype.setDynamicObjectCollection = function(dynamicObjectCollection) { - var oldCollection = this._dynamicObjectCollection; - if (oldCollection !== dynamicObjectCollection) { - if (defined(oldCollection)) { - oldCollection.collectionChanged.removeEventListener(DynamicLabelVisualizer.prototype._onObjectsRemoved, this); - this.removeAllPrimitives(); - } - this._dynamicObjectCollection = dynamicObjectCollection; - if (defined(dynamicObjectCollection)) { - dynamicObjectCollection.collectionChanged.addEventListener(DynamicLabelVisualizer.prototype._onObjectsRemoved, this); - } - } + this._scene = scene; + this._unusedIndexes = []; + this._labelCollection = labelCollection; + this._dynamicObjectCollection = dynamicObjectCollection; }; /** * Updates all of the primitives created by this visualizer to match their * DynamicObject counterpart at the given time. + * @memberof DynamicLabelVisualizer * * @param {JulianDate} time The time to update to. * @returns {Boolean} This function always returns true. @@ -120,56 +77,18 @@ define([ }; /** - * Removes all primitives from the scene. - */ - DynamicLabelVisualizer.prototype.removeAllPrimitives = function() { - this._unusedIndexes = []; - this._labelCollection.removeAll(); - if (defined(this._dynamicObjectCollection)) { - var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for ( var i = dynamicObjects.length - 1; i > -1; i--) { - dynamicObjects[i]._labelVisualizerIndex = undefined; - } - } - }; - - /** - * Returns true if this object was destroyed; otherwise, false. - *

- * If this object was destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. - * - * @memberof DynamicLabelVisualizer - * - * @returns {Boolean} True if this object was destroyed; otherwise, false. - * - * @see DynamicLabelVisualizer#destroy - */ - DynamicLabelVisualizer.prototype.isDestroyed = function() { - return false; - }; - - /** - * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic - * release of WebGL resources, instead of relying on the garbage collector to destroy this object. - *

- * Once an object is destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. Therefore, - * assign the return value (undefined) to the object as done in the example. - * + * Removes and destroys all primitives created by this instance. * @memberof DynamicLabelVisualizer - * - * @returns {undefined} - * - * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called. - * - * @see DynamicLabelVisualizer#isDestroyed - * - * @example - * visualizer = visualizer && visualizer.destroy(); */ DynamicLabelVisualizer.prototype.destroy = function() { - this.setDynamicObjectCollection(undefined); + var dynamicObjectCollection = this._dynamicObjectCollection; + dynamicObjectCollection.collectionChanged.removeEventListener(DynamicLabelVisualizer.prototype._onObjectsRemoved, this); + + var dynamicObjects = dynamicObjectCollection.getObjects(); + var length = dynamicObjects.length; + for (var i = 0; i < length; i++) { + dynamicObjects[i]._labelVisualizerIndex = undefined; + } this._scene.primitives.remove(this._labelCollection); return destroyObject(this); }; diff --git a/Source/DynamicScene/DynamicModelVisualizer.js b/Source/DynamicScene/DynamicModelVisualizer.js index 6f6b3f3739a8..e5543a17ba0b 100644 --- a/Source/DynamicScene/DynamicModelVisualizer.js +++ b/Source/DynamicScene/DynamicModelVisualizer.js @@ -25,7 +25,7 @@ define([ /** * A {@link Visualizer} which maps the {@link DynamicModel} instance - * in {@link DynamicObject.model} to a {@link Model} primitive. + * in {@link DynamicObject.model} to a {@link Model}. * @alias DynamicModelVisualizer * @constructor * @@ -42,16 +42,18 @@ define([ } //>>includeEnd('debug'); + dynamicObjectCollection.collectionChanged.addEventListener(DynamicModelVisualizer.prototype._onObjectsRemoved, this); + this._scene = scene; this._primitives = scene.primitives; this._dynamicObjectCollection = undefined; this._dynamicObjectCollection = dynamicObjectCollection; - dynamicObjectCollection.collectionChanged.addEventListener(DynamicModelVisualizer.prototype._onObjectsRemoved, this); }; /** * Updates all models created this visualizer to match their * DynamicObject counterpart at the given time. + * @memberof DynamicModelVisualizer * * @param {JulianDate} time The time to update to. * @returns {Boolean} This function always returns true. @@ -73,19 +75,20 @@ define([ }; /** - * Removes and destroys all models created by this instance. + * Removes and destroys all primitives created by this instance. * @memberof DynamicModelVisualizer */ DynamicModelVisualizer.prototype.destroy = function() { var dynamicObjects = this._dynamicObjectCollection.getObjects(); for (var i = dynamicObjects.length - 1; i > -1; i--) { - var model = dynamicObjects[i]._modelPrimitive; + var dynamicObject = dynamicObjects[i]; + var model = dynamicObject._modelPrimitive; if (defined(model)) { this._primitives.remove(model); if (!model.isDestroyed()) { model.destroy(); } - model = undefined; + dynamicObject._modelPrimitive = undefined; } } return destroyObject(this); diff --git a/Source/DynamicScene/DynamicPathVisualizer.js b/Source/DynamicScene/DynamicPathVisualizer.js index b17f077e2939..618d90da3035 100644 --- a/Source/DynamicScene/DynamicPathVisualizer.js +++ b/Source/DynamicScene/DynamicPathVisualizer.js @@ -423,73 +423,29 @@ define([ }; /** - * A DynamicObject visualizer which maps the DynamicPath instance - * in DynamicObject.path to a Polyline primitive. + * A {@link Visualizer} which maps the {@link DynamicPath} instance + * in {@link DynamicObject.path} to a {@link Polyline}. * @alias DynamicPathVisualizer * @constructor * * @param {Scene} scene The scene the primitives will be rendered in. - * @param {DynamicObjectCollection} [dynamicObjectCollection] The dynamicObjectCollection to visualize. - * - * @see DynamicPath - * @see Polyline - * @see DynamicObject - * @see CompositeDynamicObjectCollection - * @see DynamicBillboardVisualizer - * @see DynamicConeVisualizer - * @see DynamicConeVisualizerUsingCustomSensor - * @see DynamicLabelVisualizer - * @see DynamicPointVisualizer - * @see DynamicPyramidVisualizer + * @param {DynamicObjectCollection} dynamicObjectCollection The dynamicObjectCollection to visualize. */ var DynamicPathVisualizer = function(scene, dynamicObjectCollection) { //>>includeStart('debug', pragmas.debug); if (!defined(scene)) { throw new DeveloperError('scene is required.'); } + if (!defined(dynamicObjectCollection)) { + throw new DeveloperError('dynamicObjectCollection is required.'); + } //>>includeEnd('debug'); + dynamicObjectCollection.collectionChanged.addEventListener(DynamicPathVisualizer.prototype._onObjectsRemoved, this); + this._scene = scene; this._updaters = {}; - this._dynamicObjectCollection = undefined; - this.setDynamicObjectCollection(dynamicObjectCollection); - }; - - /** - * Returns the scene being used by this visualizer. - * - * @returns {Scene} The scene being used by this visualizer. - */ - DynamicPathVisualizer.prototype.getScene = function() { - return this._scene; - }; - - /** - * Gets the DynamicObjectCollection being visualized. - * - * @returns {DynamicObjectCollection} The DynamicObjectCollection being visualized. - */ - DynamicPathVisualizer.prototype.getDynamicObjectCollection = function() { - return this._dynamicObjectCollection; - }; - - /** - * Sets the DynamicObjectCollection to visualize. - * - * @param dynamicObjectCollection The DynamicObjectCollection to visualizer. - */ - DynamicPathVisualizer.prototype.setDynamicObjectCollection = function(dynamicObjectCollection) { - var oldCollection = this._dynamicObjectCollection; - if (oldCollection !== dynamicObjectCollection) { - if (defined(oldCollection)) { - oldCollection.collectionChanged.removeEventListener(DynamicPathVisualizer.prototype._onObjectsRemoved, this); - this.removeAllPrimitives(); - } - this._dynamicObjectCollection = dynamicObjectCollection; - if (defined(dynamicObjectCollection)) { - dynamicObjectCollection.collectionChanged.addEventListener(DynamicPathVisualizer.prototype._onObjectsRemoved, this); - } - } + this._dynamicObjectCollection = dynamicObjectCollection; }; /** @@ -561,63 +517,26 @@ define([ }; /** - * Removes all primitives from the scene. + * Removes and destroys all primitives created by this instance. + * @memberof DynamicVectorVisualizer */ - DynamicPathVisualizer.prototype.removeAllPrimitives = function() { + DynamicPathVisualizer.prototype.destroy = function() { + var dynamicObjectCollection = this._dynamicObjectCollection; + dynamicObjectCollection.collectionChanged.removeEventListener(DynamicPathVisualizer.prototype._onObjectsRemoved, this); + var updaters = this._updaters; for ( var key in updaters) { if (updaters.hasOwnProperty(key)) { updaters[key].destroy(); } } - this._updaters = {}; - if (defined(this._dynamicObjectCollection)) { - var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for ( var i = dynamicObjects.length - 1; i > -1; i--) { - dynamicObjects[i]._pathUpdater = undefined; - dynamicObjects[i]._pathVisualizerIndex = undefined; - } + var dynamicObjects = dynamicObjectCollection.getObjects(); + var length = dynamicObjects.length; + for (var i = 0; i < length; i++) { + dynamicObjects[i]._pathUpdater = undefined; + dynamicObjects[i]._pathVisualizerIndex = undefined; } - }; - - /** - * Returns true if this object was destroyed; otherwise, false. - *

- * If this object was destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. - * - * @memberof DynamicPathVisualizer - * - * @returns {Boolean} True if this object was destroyed; otherwise, false. - * - * @see DynamicPathVisualizer#destroy - */ - DynamicPathVisualizer.prototype.isDestroyed = function() { - return false; - }; - - /** - * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic - * release of WebGL resources, instead of relying on the garbage collector to destroy this object. - *

- * Once an object is destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. Therefore, - * assign the return value (undefined) to the object as done in the example. - * - * @memberof DynamicPathVisualizer - * - * @returns {undefined} - * - * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called. - * - * @see DynamicPathVisualizer#isDestroyed - * - * @example - * visualizer = visualizer && visualizer.destroy(); - */ - DynamicPathVisualizer.prototype.destroy = function() { - this.setDynamicObjectCollection(undefined); return destroyObject(this); }; diff --git a/Source/DynamicScene/DynamicPointVisualizer.js b/Source/DynamicScene/DynamicPointVisualizer.js index 0255b12cf8bb..e0d72d05b16e 100644 --- a/Source/DynamicScene/DynamicPointVisualizer.js +++ b/Source/DynamicScene/DynamicPointVisualizer.js @@ -18,83 +18,43 @@ define([ "use strict"; /** - * A DynamicObject visualizer which maps the DynamicPoint instance - * in DynamicObject.point to a Billboard primitive with a point texture. - * @alias DynamicPointVisualizer + * A {@link Visualizer} which maps the {@link DynamicPoint} instance + * in {@link DynamicObject.point} to a {@link Billboard}. + * @alias DynamicLabelVisualizer * @constructor * * @param {Scene} scene The scene the primitives will be rendered in. - * @param {DynamicObjectCollection} [dynamicObjectCollection] The dynamicObjectCollection to visualize. - * - * @see DynamicPoint - * @see Scene - * @see DynamicObject - * @see DynamicObjectCollection - * @see CompositeDynamicObjectCollection - * @see DynamicBillboardVisualizer - * @see DynamicConeVisualizer - * @see DynamicConeVisualizerUsingCustomSensor - * @see DynamicLabelVisualizer - * @see DynamicPyramidVisualizer + * @param {DynamicObjectCollection} dynamicObjectCollection The dynamicObjectCollection to visualize. */ var DynamicPointVisualizer = function(scene, dynamicObjectCollection) { //>>includeStart('debug', pragmas.debug); if (!defined(scene)) { throw new DeveloperError('scene is required.'); } + if (!defined(dynamicObjectCollection)) { + throw new DeveloperError('dynamicObjectCollection is required.'); + } //>>includeEnd('debug'); - this._scene = scene; - this._unusedIndexes = []; - this._dynamicObjectCollection = undefined; - var billboardCollection = this._billboardCollection = new BillboardCollection(); - var atlas = this._textureAtlas = scene.createTextureAtlas(); - this._textureAtlasBuilder = new TextureAtlasBuilder(atlas); + dynamicObjectCollection.collectionChanged.addEventListener(DynamicPointVisualizer.prototype._onObjectsRemoved, this); + + var atlas = scene.createTextureAtlas(); + var billboardCollection = new BillboardCollection(); billboardCollection.textureAtlas = atlas; scene.primitives.add(billboardCollection); - this.setDynamicObjectCollection(dynamicObjectCollection); - }; - - /** - * Returns the scene being used by this visualizer. - * - * @returns {Scene} The scene being used by this visualizer. - */ - DynamicPointVisualizer.prototype.getScene = function() { - return this._scene; - }; - - /** - * Gets the DynamicObjectCollection being visualized. - * - * @returns {DynamicObjectCollection} The DynamicObjectCollection being visualized. - */ - DynamicPointVisualizer.prototype.getDynamicObjectCollection = function() { - return this._dynamicObjectCollection; - }; - /** - * Sets the DynamicObjectCollection to visualize. - * - * @param dynamicObjectCollection The DynamicObjectCollection to visualizer. - */ - DynamicPointVisualizer.prototype.setDynamicObjectCollection = function(dynamicObjectCollection) { - var oldCollection = this._dynamicObjectCollection; - if (oldCollection !== dynamicObjectCollection) { - if (defined(oldCollection)) { - oldCollection.collectionChanged.removeEventListener(DynamicPointVisualizer.prototype._onObjectsRemoved, this); - this.removeAllPrimitives(); - } - this._dynamicObjectCollection = dynamicObjectCollection; - if (defined(dynamicObjectCollection)) { - dynamicObjectCollection.collectionChanged.addEventListener(DynamicPointVisualizer.prototype._onObjectsRemoved, this); - } - } + this._scene = scene; + this._unusedIndexes = []; + this._dynamicObjectCollection = dynamicObjectCollection; + this._textureAtlas = atlas; + this._billboardCollection = billboardCollection; + this._textureAtlasBuilder = new TextureAtlasBuilder(atlas); }; /** * Updates all of the primitives created by this visualizer to match their * DynamicObject counterpart at the given time. + * @memberof DynamicPointVisualizer * * @param {JulianDate} time The time to update to. * @returns {Boolean} This function always returns true. @@ -116,56 +76,16 @@ define([ }; /** - * Removes all primitives from the scene. - */ - DynamicPointVisualizer.prototype.removeAllPrimitives = function() { - this._unusedIndexes = []; - this._billboardCollection.removeAll(); - if (defined(this._dynamicObjectCollection)) { - var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for ( var i = dynamicObjects.length - 1; i > -1; i--) { - dynamicObjects[i]._pointVisualizerIndex = undefined; - } - } - }; - - /** - * Returns true if this object was destroyed; otherwise, false. - *

- * If this object was destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. - * + * Removes and destroys all primitives created by this instance. * @memberof DynamicPointVisualizer - * - * @returns {Boolean} True if this object was destroyed; otherwise, false. - * - * @see DynamicPointVisualizer#destroy - */ - DynamicPointVisualizer.prototype.isDestroyed = function() { - return false; - }; - - /** - * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic - * release of WebGL resources, instead of relying on the garbage collector to destroy this object. - *

- * Once an object is destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. Therefore, - * assign the return value (undefined) to the object as done in the example. - * - * @memberof DynamicPointVisualizer - * - * @returns {undefined} - * - * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called. - * - * @see DynamicPointVisualizer#isDestroyed - * - * @example - * visualizer = visualizer && visualizer.destroy(); */ DynamicPointVisualizer.prototype.destroy = function() { - this.setDynamicObjectCollection(undefined); + var dynamicObjectCollection = this._dynamicObjectCollection; + var dynamicObjects = this._dynamicObjectCollection.getObjects(); + for ( var i = dynamicObjects.length - 1; i > -1; i--) { + dynamicObjects[i]._pointVisualizerIndex = undefined; + } + dynamicObjectCollection.collectionChanged.removeEventListener(DynamicPointVisualizer.prototype._onObjectsRemoved, this); this._scene.primitives.remove(this._billboardCollection); return destroyObject(this); }; diff --git a/Source/DynamicScene/DynamicPyramidVisualizer.js b/Source/DynamicScene/DynamicPyramidVisualizer.js index 168752f29ec3..1265ff6372e3 100644 --- a/Source/DynamicScene/DynamicPyramidVisualizer.js +++ b/Source/DynamicScene/DynamicPyramidVisualizer.js @@ -30,78 +30,37 @@ define([ var matrix3Scratch = new Matrix3(); /** - * A DynamicObject visualizer which maps the DynamicPyramid instance - * in DynamicObject.pyramid to a Pyramid primitive. + * A {@link Visualizer} which maps the {@link DynamicPyramid} instance + * in {@link DynamicObject.pyramid} to a {@link CustomSensorVolume}. * @alias DynamicPyramidVisualizer * @constructor * * @param {Scene} scene The scene the primitives will be rendered in. - * @param {DynamicObjectCollection} [dynamicObjectCollection] The dynamicObjectCollection to visualize. - * - * @see DynamicPyramid - * @see DynamicObject - * @see CompositeDynamicObjectCollection - * @see DynamicBillboardVisualizer - * @see DynamicConeVisualizer - * @see DynamicConeVisualizerUsingCustomSensor - * @see DynamicLabelVisualizer - * @see DynamicPointVisualizer + * @param {DynamicObjectCollection} dynamicObjectCollection The dynamicObjectCollection to visualize. */ var DynamicPyramidVisualizer = function(scene, dynamicObjectCollection) { //>>includeStart('debug', pragmas.debug); if (!defined(scene)) { throw new DeveloperError('scene is required.'); } + if (!defined(dynamicObjectCollection)) { + throw new DeveloperError('dynamicObjectCollection is required.'); + } //>>includeEnd('debug'); + dynamicObjectCollection.collectionChanged.addEventListener(DynamicPyramidVisualizer.prototype._onObjectsRemoved, this); + this._scene = scene; this._unusedIndexes = []; this._primitives = scene.primitives; this._pyramidCollection = []; - this._dynamicObjectCollection = undefined; - this.setDynamicObjectCollection(dynamicObjectCollection); - }; - - /** - * Returns the scene being used by this visualizer. - * - * @returns {Scene} The scene being used by this visualizer. - */ - DynamicPyramidVisualizer.prototype.getScene = function() { - return this._scene; - }; - - /** - * Gets the DynamicObjectCollection being visualized. - * - * @returns {DynamicObjectCollection} The DynamicObjectCollection being visualized. - */ - DynamicPyramidVisualizer.prototype.getDynamicObjectCollection = function() { - return this._dynamicObjectCollection; - }; - - /** - * Sets the DynamicObjectCollection to visualize. - * - * @param dynamicObjectCollection The DynamicObjectCollection to visualizer. - */ - DynamicPyramidVisualizer.prototype.setDynamicObjectCollection = function(dynamicObjectCollection) { - var oldCollection = this._dynamicObjectCollection; - if (oldCollection !== dynamicObjectCollection) { - if (defined(oldCollection)) { - oldCollection.collectionChanged.removeEventListener(DynamicPyramidVisualizer.prototype._onObjectsRemoved, this); - this.removeAllPrimitives(); - } - this._dynamicObjectCollection = dynamicObjectCollection; - if (defined(dynamicObjectCollection)) { - dynamicObjectCollection.collectionChanged.addEventListener(DynamicPyramidVisualizer.prototype._onObjectsRemoved, this); - } - } + this._dynamicObjectCollection = dynamicObjectCollection; }; /** - * Updates all of the primitives created by this visualizer to match their + * Updates all of the sensors created by this visualizer to match their * DynamicObject counterpart at the given time. + * @memberof DynamicPyramidVisualizer * * @param {JulianDate} time The time to update to. * @returns {Boolean} This function always returns true. @@ -123,62 +82,23 @@ define([ }; /** - * Removes all primitives from the scene. + * Removes and destroys all primitives created by this instance. + * @memberof DynamicPyramidVisualizer */ - DynamicPyramidVisualizer.prototype.removeAllPrimitives = function() { - var i, len; - for (i = 0, len = this._pyramidCollection.length; i < len; i++) { - this._primitives.remove(this._pyramidCollection[i]); + DynamicPyramidVisualizer.prototype.destroy = function() { + var i; + var length = this._pyramidCollection.length; + var primitives = this._primitives; + for (i = 0; i < length; i++) { + primitives.remove(this._pyramidCollection[i]); } - if (defined(this._dynamicObjectCollection)) { - var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for (i = dynamicObjects.length - 1; i > -1; i--) { - dynamicObjects[i]._pyramidVisualizerIndex = undefined; - } + var dynamicObjects = this._dynamicObjectCollection.getObjects(); + length = dynamicObjects.length; + for (i = 0; i < length; i++) { + dynamicObjects[i]._pyramidVisualizerIndex = undefined; } - this._unusedIndexes = []; - this._pyramidCollection = []; - }; - - /** - * Returns true if this object was destroyed; otherwise, false. - *

- * If this object was destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. - * - * @memberof DynamicPyramidVisualizer - * - * @returns {Boolean} True if this object was destroyed; otherwise, false. - * - * @see DynamicPyramidVisualizer#destroy - */ - DynamicPyramidVisualizer.prototype.isDestroyed = function() { - return false; - }; - - /** - * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic - * release of WebGL resources, instead of relying on the garbage collector to destroy this object. - *

- * Once an object is destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. Therefore, - * assign the return value (undefined) to the object as done in the example. - * - * @memberof DynamicPyramidVisualizer - * - * @returns {undefined} - * - * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called. - * - * @see DynamicPyramidVisualizer#isDestroyed - * - * @example - * visualizer = visualizer && visualizer.destroy(); - */ - DynamicPyramidVisualizer.prototype.destroy = function() { - this.setDynamicObjectCollection(undefined); return destroyObject(this); }; diff --git a/Source/DynamicScene/DynamicVectorVisualizer.js b/Source/DynamicScene/DynamicVectorVisualizer.js index 0b3734d81b2b..c494b7c67ca9 100644 --- a/Source/DynamicScene/DynamicVectorVisualizer.js +++ b/Source/DynamicScene/DynamicVectorVisualizer.js @@ -18,80 +18,39 @@ define([ "use strict"; /** - * A DynamicObject visualizer which maps the DynamicPolyline instance - * in DynamicObject.vector to a Polyline primitive. + * A {@link Visualizer} which maps the {@link DynamicVector} instance + * in {@link DynamicObject.vector} to a {@link Polyline}. * @alias DynamicVectorVisualizer * @constructor * * @param {Scene} scene The scene the primitives will be rendered in. - * @param {DynamicObjectCollection} [dynamicObjectCollection] The dynamicObjectCollection to visualize. - * - * @see DynamicPolyline - * @see DynamicObject - * @see CompositeDynamicObjectCollection - * @see DynamicBillboardVisualizer - * @see DynamicConeVisualizer - * @see DynamicConeVisualizerUsingCustomSensor - * @see DynamicLabelVisualizer - * @see DynamicPointVisualizer - * @see DynamicPyramidVisualizer + * @param {DynamicObjectCollection} dynamicObjectCollection The dynamicObjectCollection to visualize. */ var DynamicVectorVisualizer = function(scene, dynamicObjectCollection) { //>>includeStart('debug', pragmas.debug); if (!defined(scene)) { throw new DeveloperError('scene is required.'); } + if (!defined(dynamicObjectCollection)) { + throw new DeveloperError('dynamicObjectCollection is required.'); + } //>>includeEnd('debug'); + dynamicObjectCollection.collectionChanged.addEventListener(DynamicVectorVisualizer.prototype._onObjectsRemoved, this); + var polylineCollection = new PolylineCollection(); + scene.primitives.add(polylineCollection); + this._scene = scene; this._unusedIndexes = []; this._primitives = scene.primitives; - var polylineCollection = this._polylineCollection = new PolylineCollection(); - scene.primitives.add(polylineCollection); - this._dynamicObjectCollection = undefined; - this.setDynamicObjectCollection(dynamicObjectCollection); - }; - - /** - * Returns the scene being used by this visualizer. - * - * @returns {Scene} The scene being used by this visualizer. - */ - DynamicVectorVisualizer.prototype.getScene = function() { - return this._scene; - }; - - /** - * Gets the DynamicObjectCollection being visualized. - * - * @returns {DynamicObjectCollection} The DynamicObjectCollection being visualized. - */ - DynamicVectorVisualizer.prototype.getDynamicObjectCollection = function() { - return this._dynamicObjectCollection; - }; - - /** - * Sets the DynamicObjectCollection to visualize. - * - * @param dynamicObjectCollection The DynamicObjectCollection to visualizer. - */ - DynamicVectorVisualizer.prototype.setDynamicObjectCollection = function(dynamicObjectCollection) { - var oldCollection = this._dynamicObjectCollection; - if (oldCollection !== dynamicObjectCollection) { - if (defined(oldCollection)) { - oldCollection.collectionChanged.removeEventListener(DynamicVectorVisualizer.prototype._onObjectsRemoved, this); - this.removeAllPrimitives(); - } - this._dynamicObjectCollection = dynamicObjectCollection; - if (defined(dynamicObjectCollection)) { - dynamicObjectCollection.collectionChanged.addEventListener(DynamicVectorVisualizer.prototype._onObjectsRemoved, this); - } - } + this._polylineCollection = polylineCollection; + this._dynamicObjectCollection = dynamicObjectCollection; }; /** * Updates all of the primitives created by this visualizer to match their * DynamicObject counterpart at the given time. + * @memberof DynamicVectorVisualizer * * @param {JulianDate} time The time to update to. * @returns {Boolean} This function always returns true. @@ -113,59 +72,18 @@ define([ }; /** - * Removes all primitives from the scene. + * Removes and destroys all primitives created by this instance. + * @memberof DynamicVectorVisualizer */ - DynamicVectorVisualizer.prototype.removeAllPrimitives = function() { - var i; - this._polylineCollection.removeAll(); + DynamicVectorVisualizer.prototype.destroy = function() { + var dynamicObjectCollection = this._dynamicObjectCollection; + dynamicObjectCollection.collectionChanged.removeEventListener(DynamicVectorVisualizer.prototype._onObjectsRemoved, this); - if (defined(this._dynamicObjectCollection)) { - var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for (i = dynamicObjects.length - 1; i > -1; i--) { - dynamicObjects[i]._vectorVisualizerIndex = undefined; - } + var dynamicObjects = this._dynamicObjectCollection.getObjects(); + for (var i = dynamicObjects.length - 1; i > -1; i--) { + dynamicObjects[i]._vectorVisualizerIndex = undefined; } - this._unusedIndexes = []; - }; - - /** - * Returns true if this object was destroyed; otherwise, false. - *

- * If this object was destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. - * - * @memberof DynamicVectorVisualizer - * - * @returns {Boolean} True if this object was destroyed; otherwise, false. - * - * @see DynamicVectorVisualizer#destroy - */ - DynamicVectorVisualizer.prototype.isDestroyed = function() { - return false; - }; - - /** - * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic - * release of WebGL resources, instead of relying on the garbage collector to destroy this object. - *

- * Once an object is destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. Therefore, - * assign the return value (undefined) to the object as done in the example. - * - * @memberof DynamicVectorVisualizer - * - * @returns {undefined} - * - * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called. - * - * @see DynamicVectorVisualizer#isDestroyed - * - * @example - * visualizer = visualizer && visualizer.destroy(); - */ - DynamicVectorVisualizer.prototype.destroy = function() { - this.setDynamicObjectCollection(undefined); this._scene.primitives.remove(this._polylineCollection); return destroyObject(this); }; diff --git a/Source/DynamicScene/GeometryVisualizer.js b/Source/DynamicScene/GeometryVisualizer.js index cd62c0656414..5e0fc13ec55b 100644 --- a/Source/DynamicScene/GeometryVisualizer.js +++ b/Source/DynamicScene/GeometryVisualizer.js @@ -208,15 +208,8 @@ define(['../Core/AssociativeArray', }; /** - * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic - * release of WebGL resources, instead of relying on the garbage collector to destroy this object. - *

- * Once an object is destroyed, it should not be used; calling any function other than - * isDestroyed will result in a {@link DeveloperError} exception. Therefore, - * assign the return value (undefined) to the object as done in the example. + * Removes and destroys all primitives created by this instance. * @memberof GeometryVisualizer - * - * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called. */ GeometryVisualizer.prototype.destroy = function() { this._addedObjects.removeAll(); diff --git a/Source/DynamicScene/Visualizer.js b/Source/DynamicScene/Visualizer.js index 7a324e2f9c9d..446bfb701e8f 100644 --- a/Source/DynamicScene/Visualizer.js +++ b/Source/DynamicScene/Visualizer.js @@ -25,13 +25,13 @@ define(['../Core/DeveloperError'], function(DeveloperError) { * false if the visualizer is waiting for an asynchronous operation to * complete before data can be updated. */ - Visualizer.prototype.update = DeveloperError.throwInstantiationError(); + Visualizer.prototype.update = DeveloperError.throwInstantiationError; /** * Removes all visualization and cleans up any resources associated with this instance. * @memberof Visualizer */ - Visualizer.prototype.destroy = DeveloperError.throwInstantiationError(); + Visualizer.prototype.destroy = DeveloperError.throwInstantiationError; return Visualizer; }); \ No newline at end of file diff --git a/Specs/DynamicScene/DataSourceDisplaySpec.js b/Specs/DynamicScene/DataSourceDisplaySpec.js index 5bf18a4706de..8d3a0644f4bd 100644 --- a/Specs/DynamicScene/DataSourceDisplaySpec.js +++ b/Specs/DynamicScene/DataSourceDisplaySpec.js @@ -45,10 +45,6 @@ defineSuite([ return this.dynamicObjectCollection; }; - MockVisualizer.prototype.setDynamicObjectCollection = function(dynamicObjectCollection) { - this.dynamicObjectCollection = dynamicObjectCollection; - }; - MockVisualizer.prototype.update = function(time) { this.lastUpdateTime = time; this.updatesCalled++; diff --git a/Specs/DynamicScene/DynamicBillboardVisualizerSpec.js b/Specs/DynamicScene/DynamicBillboardVisualizerSpec.js index 74d192597bd3..7b6d5b3487dd 100644 --- a/Specs/DynamicScene/DynamicBillboardVisualizerSpec.js +++ b/Specs/DynamicScene/DynamicBillboardVisualizerSpec.js @@ -59,11 +59,9 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('constructor sets expected parameters and adds collection to scene.', function() { + it('constructor adds collection to scene.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicBillboardVisualizer(scene, dynamicObjectCollection); - expect(visualizer.getScene()).toEqual(scene); - expect(visualizer.getDynamicObjectCollection()).toEqual(dynamicObjectCollection); var billboardCollection = scene.primitives.get(0); expect(billboardCollection instanceof BillboardCollection).toEqual(true); }); @@ -76,19 +74,6 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('update does nothing if no dynamicObjectCollection.', function() { - visualizer = new DynamicBillboardVisualizer(scene); - visualizer.update(new JulianDate()); - }); - - it('isDestroy returns false until destroyed.', function() { - visualizer = new DynamicBillboardVisualizer(scene); - expect(visualizer.isDestroyed()).toEqual(false); - visualizer.destroy(); - expect(visualizer.isDestroyed()).toEqual(true); - visualizer = undefined; - }); - it('object with no billboard does not create a billboard.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicBillboardVisualizer(scene, dynamicObjectCollection); @@ -289,36 +274,4 @@ defineSuite([ var bb = billboardCollection.get(0); expect(bb.id).toEqual(testObject); }); - - it('setDynamicObjectCollection removes old objects and add new ones.', function() { - var dynamicObjectCollection = new DynamicObjectCollection(); - var testObject = dynamicObjectCollection.getOrCreateObject('test'); - testObject.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112)); - testObject.billboard = new DynamicBillboard(); - testObject.billboard.show = new ConstantProperty(true); - testObject.billboard.image = new ConstantProperty('Data/Images/Blue.png'); - - var dynamicObjectCollection2 = new DynamicObjectCollection(); - var testObject2 = dynamicObjectCollection2.getOrCreateObject('test2'); - testObject2.position = new ConstantProperty(new Cartesian3(5678, 9101112, 1234)); - testObject2.billboard = new DynamicBillboard(); - testObject2.billboard.show = new ConstantProperty(true); - testObject2.billboard.image = new ConstantProperty('Data/Images/Green.png'); - - visualizer = new DynamicBillboardVisualizer(scene, dynamicObjectCollection); - - var time = new JulianDate(); - var billboardCollection = scene.primitives.get(0); - - visualizer.update(time); - expect(billboardCollection.length).toEqual(1); - var bb = billboardCollection.get(0); - expect(bb.id).toEqual(testObject); - - visualizer.setDynamicObjectCollection(dynamicObjectCollection2); - visualizer.update(time); - expect(billboardCollection.length).toEqual(1); - bb = billboardCollection.get(0); - expect(bb.id).toEqual(testObject2); - }); }, 'WebGL'); diff --git a/Specs/DynamicScene/DynamicConeVisualizerUsingCustomSensorSpec.js b/Specs/DynamicScene/DynamicConeVisualizerUsingCustomSensorSpec.js index c2cc1f975765..80468da2f3b8 100644 --- a/Specs/DynamicScene/DynamicConeVisualizerUsingCustomSensorSpec.js +++ b/Specs/DynamicScene/DynamicConeVisualizerUsingCustomSensorSpec.js @@ -57,13 +57,6 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('constructor sets expected parameters.', function() { - var dynamicObjectCollection = new DynamicObjectCollection(); - visualizer = new DynamicConeVisualizerUsingCustomSensor(scene, dynamicObjectCollection); - expect(visualizer.getScene()).toEqual(scene); - expect(visualizer.getDynamicObjectCollection()).toEqual(dynamicObjectCollection); - }); - it('update throws if no time specified.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicConeVisualizerUsingCustomSensor(scene, dynamicObjectCollection); @@ -72,19 +65,6 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('update does nothing if no dynamicObjectCollection.', function() { - visualizer = new DynamicConeVisualizerUsingCustomSensor(scene); - visualizer.update(new JulianDate()); - }); - - it('isDestroy returns false until destroyed.', function() { - visualizer = new DynamicConeVisualizerUsingCustomSensor(scene); - expect(visualizer.isDestroyed()).toEqual(false); - visualizer.destroy(); - expect(visualizer.isDestroyed()).toEqual(true); - visualizer = undefined; - }); - it('object with no cone does not create a primitive.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicConeVisualizerUsingCustomSensor(scene, dynamicObjectCollection); @@ -252,37 +232,4 @@ defineSuite([ visualizer.update(time); expect(scene.primitives.get(0).id).toEqual(testObject); }); - - it('setDynamicObjectCollection removes old objects and add new ones.', function() { - var dynamicObjectCollection = new DynamicObjectCollection(); - var testObject = dynamicObjectCollection.getOrCreateObject('test'); - testObject.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112)); - testObject.orientation = new ConstantProperty(new Quaternion(0, 0, 0, 1)); - var cone = testObject.cone = new DynamicCone(); - cone.maximumClockAngle = new ConstantProperty(1); - cone.outerHalfAngle = new ConstantProperty(1); - - var dynamicObjectCollection2 = new DynamicObjectCollection(); - var testObject2 = dynamicObjectCollection2.getOrCreateObject('test2'); - testObject2.position = new ConstantProperty(new Cartesian3(5678, 9101112, 1234)); - testObject2.orientation = new ConstantProperty(new Quaternion(1, 0, 0, 0)); - var cone2 = testObject2.cone = new DynamicCone(); - cone2.maximumClockAngle = new ConstantProperty(0.12); - cone2.outerHalfAngle = new ConstantProperty(1.1); - - visualizer = new DynamicConeVisualizerUsingCustomSensor(scene, dynamicObjectCollection); - - var time = new JulianDate(); - - visualizer.update(time); - expect(scene.primitives.length).toEqual(1); - var conePrimitive = scene.primitives.get(0); - expect(conePrimitive.id).toEqual(testObject); - - visualizer.setDynamicObjectCollection(dynamicObjectCollection2); - visualizer.update(time); - expect(scene.primitives.length).toEqual(1); - conePrimitive = scene.primitives.get(0); - expect(conePrimitive.id).toEqual(testObject2); - }); }, 'WebGL'); diff --git a/Specs/DynamicScene/DynamicLabelVisualizerSpec.js b/Specs/DynamicScene/DynamicLabelVisualizerSpec.js index 8578fe444357..408f2f5f8afa 100644 --- a/Specs/DynamicScene/DynamicLabelVisualizerSpec.js +++ b/Specs/DynamicScene/DynamicLabelVisualizerSpec.js @@ -55,11 +55,9 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('constructor sets expected parameters and adds collection to scene.', function() { + it('constructor adds collection to scene.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicLabelVisualizer(scene, dynamicObjectCollection); - expect(visualizer.getScene()).toEqual(scene); - expect(visualizer.getDynamicObjectCollection()).toEqual(dynamicObjectCollection); var labelCollection = scene.primitives.get(0); expect(labelCollection instanceof LabelCollection).toEqual(true); }); @@ -72,19 +70,6 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('update does nothing if no dynamicObjectCollection.', function() { - visualizer = new DynamicLabelVisualizer(scene); - visualizer.update(new JulianDate()); - }); - - it('isDestroy returns false until destroyed.', function() { - visualizer = new DynamicLabelVisualizer(scene); - expect(visualizer.isDestroyed()).toEqual(false); - visualizer.destroy(); - expect(visualizer.isDestroyed()).toEqual(true); - visualizer = undefined; - }); - it('object with no label does not create a label.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicLabelVisualizer(scene, dynamicObjectCollection); @@ -261,36 +246,4 @@ defineSuite([ var l = labelCollection.get(0); expect(l.id).toEqual(testObject); }); - - it('setDynamicObjectCollection removes old objects and add new ones.', function() { - var dynamicObjectCollection = new DynamicObjectCollection(); - var testObject = dynamicObjectCollection.getOrCreateObject('test'); - testObject.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112)); - testObject.label = new DynamicLabel(); - testObject.label.show = new ConstantProperty(true); - testObject.label.text = new ConstantProperty('lorum ipsum'); - - var dynamicObjectCollection2 = new DynamicObjectCollection(); - var testObject2 = dynamicObjectCollection2.getOrCreateObject('test2'); - testObject2.position = new ConstantProperty(new Cartesian3(5678, 9101112, 1234)); - testObject2.label = new DynamicLabel(); - testObject2.label.show = new ConstantProperty(true); - testObject2.label.text = new ConstantProperty('the quick brown'); - - visualizer = new DynamicLabelVisualizer(scene, dynamicObjectCollection); - - var time = new JulianDate(); - var labelCollection = scene.primitives.get(0); - - visualizer.update(time); - expect(labelCollection.length).toEqual(1); - var l = labelCollection.get(0); - expect(l.id).toEqual(testObject); - - visualizer.setDynamicObjectCollection(dynamicObjectCollection2); - visualizer.update(time); - expect(labelCollection.length).toEqual(1); - l = labelCollection.get(0); - expect(l.id).toEqual(testObject2); - }); }, 'WebGL'); \ No newline at end of file diff --git a/Specs/DynamicScene/DynamicModelVisualizerSpec.js b/Specs/DynamicScene/DynamicModelVisualizerSpec.js index dcc8cdc023ce..76d78698f9b1 100644 --- a/Specs/DynamicScene/DynamicModelVisualizerSpec.js +++ b/Specs/DynamicScene/DynamicModelVisualizerSpec.js @@ -55,13 +55,6 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('constructor sets expected parameters.', function() { - var dynamicObjectCollection = new DynamicObjectCollection(); - visualizer = new DynamicModelVisualizer(scene, dynamicObjectCollection); - expect(visualizer.getScene()).toEqual(scene); - expect(visualizer.getDynamicObjectCollection()).toEqual(dynamicObjectCollection); - }); - it('update throws if no time specified.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicModelVisualizer(scene, dynamicObjectCollection); @@ -70,19 +63,6 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('update does nothing if no dynamicObjectCollection.', function() { - visualizer = new DynamicModelVisualizer(scene); - visualizer.update(new JulianDate()); - }); - - it('isDestroy returns false until destroyed.', function() { - visualizer = new DynamicModelVisualizer(scene); - expect(visualizer.isDestroyed()).toEqual(false); - visualizer.destroy(); - expect(visualizer.isDestroyed()).toEqual(true); - visualizer = undefined; - }); - it('object with no model does not create one.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicModelVisualizer(scene, dynamicObjectCollection); diff --git a/Specs/DynamicScene/DynamicPathVisualizerSpec.js b/Specs/DynamicScene/DynamicPathVisualizerSpec.js index 3aadf6633ea5..3fb95fe06c82 100644 --- a/Specs/DynamicScene/DynamicPathVisualizerSpec.js +++ b/Specs/DynamicScene/DynamicPathVisualizerSpec.js @@ -55,14 +55,6 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('constructor sets expected parameters and adds no primitives to scene.', function() { - var dynamicObjectCollection = new DynamicObjectCollection(); - visualizer = new DynamicPathVisualizer(scene, dynamicObjectCollection); - expect(visualizer.getScene()).toEqual(scene); - expect(visualizer.getDynamicObjectCollection()).toEqual(dynamicObjectCollection); - expect(scene.primitives.length).toEqual(0); - }); - it('update throws if no time specified.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicPathVisualizer(scene, dynamicObjectCollection); @@ -71,19 +63,6 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('update does nothing if no dynamicObjectCollection.', function() { - visualizer = new DynamicPathVisualizer(scene); - visualizer.update(new JulianDate()); - }); - - it('isDestroy returns false until destroyed.', function() { - visualizer = new DynamicPathVisualizer(scene); - expect(visualizer.isDestroyed()).toEqual(false); - visualizer.destroy(); - expect(visualizer.isDestroyed()).toEqual(true); - visualizer = undefined; - }); - it('object with no path does not create one.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicPathVisualizer(scene, dynamicObjectCollection); @@ -220,61 +199,6 @@ defineSuite([ expect(primitive.id).toEqual(testObject); }); - it('setDynamicObjectCollection removes old objects and add new ones.', function() { - var times = [new JulianDate(0, 0), new JulianDate(1, 0)]; - var updateTime = new JulianDate(0.5, 0); - var positions = [new Cartesian3(1234, 5678, 9101112), new Cartesian3(5678, 1234, 1101112)]; - - var dynamicObjectCollection = new DynamicObjectCollection(); - visualizer = new DynamicPathVisualizer(scene, dynamicObjectCollection); - - expect(scene.primitives.length).toEqual(0); - - var testObject = dynamicObjectCollection.getOrCreateObject('test'); - var position = new SampledPositionProperty(); - testObject.position = position; - position.addSamples(times, positions); - - var path = testObject.path = new DynamicPath(); - path.show = new ConstantProperty(true); - path.color = new ConstantProperty(new Color(0.8, 0.7, 0.6, 0.5)); - path.width = new ConstantProperty(12.5); - path.outlineColor = new ConstantProperty(new Color(0.1, 0.2, 0.3, 0.4)); - path.outlineWidth = new ConstantProperty(2.5); - path.leadTime = new ConstantProperty(25); - path.trailTime = new ConstantProperty(10); - - visualizer.update(updateTime); - - var dynamicObjectCollection2 = new DynamicObjectCollection(); - var testObject2 = dynamicObjectCollection2.getOrCreateObject('test2'); - var position2 = new SampledPositionProperty(); - testObject2.position = position; - position2.addSamples(times, positions); - - var path2 = testObject2.path = new DynamicPath(); - path2.show = new ConstantProperty(true); - path2.color = new ConstantProperty(new Color(0.8, 0.7, 0.6, 0.5)); - path2.width = new ConstantProperty(12.5); - path2.outlineColor = new ConstantProperty(new Color(0.1, 0.2, 0.3, 0.4)); - path2.outlineWidth = new ConstantProperty(2.5); - path2.leadTime = new ConstantProperty(25); - path2.trailTime = new ConstantProperty(10); - - expect(scene.primitives.length).toEqual(1); - var polylineCollection = scene.primitives.get(0); - expect(polylineCollection.length).toEqual(1); - var primitive = polylineCollection.get(0); - expect(primitive.id).toEqual(testObject); - - visualizer.setDynamicObjectCollection(dynamicObjectCollection2); - visualizer.update(updateTime); - expect(scene.primitives.length).toEqual(1); - polylineCollection = scene.primitives.get(0); - primitive = polylineCollection.get(0); - expect(primitive.id).toEqual(testObject2); - }); - it('subSample works for constant properties', function() { var property = new ConstantPositionProperty(new Cartesian3(1000, 2000, 3000)); var start = new JulianDate(0, 0); diff --git a/Specs/DynamicScene/DynamicPointVisualizerSpec.js b/Specs/DynamicScene/DynamicPointVisualizerSpec.js index a94d8e474e6e..6f9aef82f917 100644 --- a/Specs/DynamicScene/DynamicPointVisualizerSpec.js +++ b/Specs/DynamicScene/DynamicPointVisualizerSpec.js @@ -47,11 +47,9 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('constructor sets expected parameters and adds collection to scene.', function() { + it('constructor adds collection to scene.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicPointVisualizer(scene, dynamicObjectCollection); - expect(visualizer.getScene()).toEqual(scene); - expect(visualizer.getDynamicObjectCollection()).toEqual(dynamicObjectCollection); expect(scene.primitives.length).toEqual(1); var billboardCollection = scene.primitives.get(0); expect(billboardCollection instanceof BillboardCollection).toEqual(true); @@ -65,19 +63,6 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('update does nothing if no dynamicObjectCollection.', function() { - visualizer = new DynamicPointVisualizer(scene); - visualizer.update(new JulianDate()); - }); - - it('isDestroy returns false until destroyed.', function() { - visualizer = new DynamicPointVisualizer(scene); - expect(visualizer.isDestroyed()).toEqual(false); - visualizer.destroy(); - expect(visualizer.isDestroyed()).toEqual(true); - visualizer = undefined; - }); - it('object with no point does not create a billboard.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicPointVisualizer(scene, dynamicObjectCollection); @@ -203,34 +188,4 @@ defineSuite([ var bb = billboardCollection.get(0); expect(bb.id).toEqual(testObject); }); - - it('setDynamicObjectCollection removes old objects and add new ones.', function() { - var dynamicObjectCollection = new DynamicObjectCollection(); - var testObject = dynamicObjectCollection.getOrCreateObject('test'); - testObject.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112)); - testObject.point = new DynamicPoint(); - testObject.point.show = new ConstantProperty(true); - - var dynamicObjectCollection2 = new DynamicObjectCollection(); - var testObject2 = dynamicObjectCollection2.getOrCreateObject('test2'); - testObject2.position = new ConstantProperty(new Cartesian3(5678, 9101112, 1234)); - testObject2.point = new DynamicPoint(); - testObject2.point.show = new ConstantProperty(true); - - visualizer = new DynamicPointVisualizer(scene, dynamicObjectCollection); - - var time = new JulianDate(); - var billboardCollection = scene.primitives.get(0); - - visualizer.update(time); - expect(billboardCollection.length).toEqual(1); - var bb = billboardCollection.get(0); - expect(bb.id).toEqual(testObject); - - visualizer.setDynamicObjectCollection(dynamicObjectCollection2); - visualizer.update(time); - expect(billboardCollection.length).toEqual(1); - bb = billboardCollection.get(0); - expect(bb.id).toEqual(testObject2); - }); }, 'WebGL'); \ No newline at end of file diff --git a/Specs/DynamicScene/DynamicPyramidVisualizerSpec.js b/Specs/DynamicScene/DynamicPyramidVisualizerSpec.js index 68faee020d1b..df7f4ac21fbd 100644 --- a/Specs/DynamicScene/DynamicPyramidVisualizerSpec.js +++ b/Specs/DynamicScene/DynamicPyramidVisualizerSpec.js @@ -55,13 +55,6 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('constructor sets expected parameters.', function() { - var dynamicObjectCollection = new DynamicObjectCollection(); - visualizer = new DynamicPyramidVisualizer(scene, dynamicObjectCollection); - expect(visualizer.getScene()).toEqual(scene); - expect(visualizer.getDynamicObjectCollection()).toEqual(dynamicObjectCollection); - }); - it('update throws if no time specified.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicPyramidVisualizer(scene, dynamicObjectCollection); @@ -70,19 +63,6 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('update does nothing if no dynamicObjectCollection.', function() { - visualizer = new DynamicPyramidVisualizer(scene); - visualizer.update(new JulianDate()); - }); - - it('isDestroy returns false until destroyed.', function() { - visualizer = new DynamicPyramidVisualizer(scene); - expect(visualizer.isDestroyed()).toEqual(false); - visualizer.destroy(); - expect(visualizer.isDestroyed()).toEqual(true); - visualizer = undefined; - }); - it('object with no pyramid does not create a primitive.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicPyramidVisualizer(scene, dynamicObjectCollection); @@ -187,35 +167,4 @@ defineSuite([ visualizer.update(time); expect(scene.primitives.get(0).id).toEqual(testObject); }); - - it('setDynamicObjectCollection removes old objects and add new ones.', function() { - var dynamicObjectCollection = new DynamicObjectCollection(); - var testObject = dynamicObjectCollection.getOrCreateObject('test'); - testObject.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112)); - testObject.orientation = new ConstantProperty(new Quaternion(0, 0, 0, 1)); - var pyramid = testObject.pyramid = new DynamicPyramid(); - pyramid.directions = new ConstantProperty([new Spherical(0, 0, 0), new Spherical(1, 0, 0), new Spherical(2, 0, 0), new Spherical(3, 0, 0)]); - - var dynamicObjectCollection2 = new DynamicObjectCollection(); - var testObject2 = dynamicObjectCollection2.getOrCreateObject('test2'); - testObject2.position = new ConstantProperty(new Cartesian3(5678, 9101112, 1234)); - testObject2.orientation = new ConstantProperty(new Quaternion(1, 0, 0, 0)); - var pyramid2 = testObject2.pyramid = new DynamicPyramid(); - pyramid2.directions = new ConstantProperty([new Spherical(3, 0, 0), new Spherical(2, 0, 0), new Spherical(1, 0, 0), new Spherical(0.5, 0, 0)]); - - visualizer = new DynamicPyramidVisualizer(scene, dynamicObjectCollection); - - var time = new JulianDate(); - - visualizer.update(time); - expect(scene.primitives.length).toEqual(1); - var pyramidPrimitive = scene.primitives.get(0); - expect(pyramidPrimitive.id).toEqual(testObject); - - visualizer.setDynamicObjectCollection(dynamicObjectCollection2); - visualizer.update(time); - expect(scene.primitives.length).toEqual(1); - pyramidPrimitive = scene.primitives.get(0); - expect(pyramidPrimitive.id).toEqual(testObject2); - }); }, 'WebGL'); diff --git a/Specs/DynamicScene/DynamicVectorVisualizerSpec.js b/Specs/DynamicScene/DynamicVectorVisualizerSpec.js index 988e4062f43d..088efaad9fce 100644 --- a/Specs/DynamicScene/DynamicVectorVisualizerSpec.js +++ b/Specs/DynamicScene/DynamicVectorVisualizerSpec.js @@ -53,11 +53,9 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('constructor sets expected parameters and adds collection to scene.', function() { + it('constructor adds collection to scene.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicVectorVisualizer(scene, dynamicObjectCollection); - expect(visualizer.getScene()).toEqual(scene); - expect(visualizer.getDynamicObjectCollection()).toEqual(dynamicObjectCollection); expect(scene.primitives.length).toEqual(1); }); @@ -69,19 +67,6 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('update does nothing if no dynamicObjectCollection.', function() { - visualizer = new DynamicVectorVisualizer(scene); - visualizer.update(new JulianDate()); - }); - - it('isDestroy returns false until destroyed.', function() { - visualizer = new DynamicVectorVisualizer(scene); - expect(visualizer.isDestroyed()).toEqual(false); - visualizer.destroy(); - expect(visualizer.isDestroyed()).toEqual(true); - visualizer = undefined; - }); - it('object with no vector does not create one.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicVectorVisualizer(scene, dynamicObjectCollection); @@ -209,43 +194,4 @@ defineSuite([ var primitive = polylineCollection.get(0); expect(primitive.id).toEqual(testObject); }); - - it('setDynamicObjectCollection removes old objects and add new ones.', function() { - var dynamicObjectCollection = new DynamicObjectCollection(); - var testObject = dynamicObjectCollection.getOrCreateObject('test'); - testObject.position = new ConstantProperty(new Cartesian3(5678, 1234, 1101112)); - testObject.vector = new DynamicVector(); - testObject.vector.show = new ConstantProperty(true); - testObject.vector.color = new ConstantProperty(new Color(0.8, 0.7, 0.6, 0.5)); - testObject.vector.width = new ConstantProperty(12.5); - testObject.vector.length = new ConstantProperty(13.5); - testObject.vector.direction = new ConstantProperty(new Cartesian3(1, 2, 3)); - - var dynamicObjectCollection2 = new DynamicObjectCollection(); - var testObject2 = dynamicObjectCollection2.getOrCreateObject('test2'); - testObject2.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112)); - testObject2.vector = new DynamicVector(); - testObject2.vector.show = new ConstantProperty(true); - testObject2.vector.color = new ConstantProperty(new Color(0.8, 0.7, 0.6, 0.5)); - testObject2.vector.width = new ConstantProperty(12.5); - testObject2.vector.length = new ConstantProperty(13.5); - testObject2.vector.direction = new ConstantProperty(new Cartesian3(1, 2, 3)); - - visualizer = new DynamicVectorVisualizer(scene, dynamicObjectCollection); - - var time = new JulianDate(); - - visualizer.update(time); - expect(scene.primitives.length).toEqual(1); - var polylineCollection = scene.primitives.get(0); - expect(polylineCollection.length).toEqual(1); - var primitive = polylineCollection.get(0); - expect(primitive.id).toEqual(testObject); - - visualizer.setDynamicObjectCollection(dynamicObjectCollection2); - visualizer.update(time); - expect(scene.primitives.length).toEqual(1); - primitive = polylineCollection.get(0); - expect(primitive.id).toEqual(testObject2); - }); }, 'WebGL'); From ffb06b36dfe3b59bc31afa8c572b5c57a9534d9b Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Sun, 27 Apr 2014 13:14:19 -0400 Subject: [PATCH 03/10] Cleanup Visualizer-related documentation. --- Source/DynamicScene/DynamicBillboardVisualizer.js | 5 ++--- .../DynamicConeVisualizerUsingCustomSensor.js | 11 ++--------- Source/DynamicScene/DynamicLabelVisualizer.js | 4 ++-- Source/DynamicScene/DynamicModelVisualizer.js | 5 ++--- Source/DynamicScene/DynamicObject.js | 2 +- Source/DynamicScene/DynamicPathVisualizer.js | 6 +++--- Source/DynamicScene/DynamicPointVisualizer.js | 7 +++---- Source/DynamicScene/DynamicPyramidVisualizer.js | 5 ++--- Source/DynamicScene/DynamicVectorVisualizer.js | 5 ++--- Source/DynamicScene/GeometryVisualizer.js | 2 +- Source/DynamicScene/Visualizer.js | 10 ++++++++++ 11 files changed, 30 insertions(+), 32 deletions(-) diff --git a/Source/DynamicScene/DynamicBillboardVisualizer.js b/Source/DynamicScene/DynamicBillboardVisualizer.js index b646cecfa18d..d411dd9a499e 100644 --- a/Source/DynamicScene/DynamicBillboardVisualizer.js +++ b/Source/DynamicScene/DynamicBillboardVisualizer.js @@ -40,8 +40,7 @@ define([ } /** - * A {@link Visualizer} which maps the {@link DynamicBillboard} instance - * in {@link DynamicObject.billboard} to a {@link Billboard}. + * A {@link Visualizer} which maps {@link DynamicObject#billboard} to a {@link Billboard}. * @alias DynamicBillboardVisualizer * @constructor * @@ -73,7 +72,7 @@ define([ }; /** - * Updates all of the primitives created by this visualizer to match their + * Updates the primitives created by this visualizer to match their * DynamicObject counterpart at the given time. * @memberof DynamicBillboardVisualizer * diff --git a/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js b/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js index ba8be7d3d404..23d0d5354abe 100644 --- a/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js +++ b/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js @@ -29,12 +29,6 @@ define([ MaterialProperty) { "use strict"; - //CZML_TODO DynamicConeVisualizerUsingCustomSensor is a temporary workaround - //because ComplexConicSensor has major performance issues. As soon as - //ComplexConicSensor is working, this class can be deleted and - //DynamicConeVisualizer is a drop in replacement that already does things - //"the right way". - var matrix3Scratch = new Matrix3(); function assignSpherical(index, array, clock, cone) { @@ -77,8 +71,7 @@ define([ } /** - * A {@link Visualizer} which maps the {@link DynamicCone} instance - * in {@link DynamicObject.cone} to a {@link CustomSensor}. + * A {@link Visualizer} which maps {@link DynamicObject#cone} to a {@link CustomSensor}. * @alias DynamicConeVisualizerUsingCustomSensor * @constructor * @@ -105,7 +98,7 @@ define([ }; /** - * Updates all of the primitives created by this visualizer to match their + * Updates the primitives created by this visualizer to match their * DynamicObject counterpart at the given time. * @memberof DynamicLabelVisualizer * diff --git a/Source/DynamicScene/DynamicLabelVisualizer.js b/Source/DynamicScene/DynamicLabelVisualizer.js index 6957a8a98b1f..2990a088827f 100644 --- a/Source/DynamicScene/DynamicLabelVisualizer.js +++ b/Source/DynamicScene/DynamicLabelVisualizer.js @@ -25,7 +25,7 @@ define([ /** * A {@link Visualizer} which maps the {@link DynamicLabel} instance - * in {@link DynamicObject.label} to a {@link Label}. + * in {@link DynamicObject#label} to a {@link Label}. * @alias DynamicLabelVisualizer * @constructor * @@ -53,7 +53,7 @@ define([ }; /** - * Updates all of the primitives created by this visualizer to match their + * Updates the primitives created by this visualizer to match their * DynamicObject counterpart at the given time. * @memberof DynamicLabelVisualizer * diff --git a/Source/DynamicScene/DynamicModelVisualizer.js b/Source/DynamicScene/DynamicModelVisualizer.js index e5543a17ba0b..4a690bd3dcdf 100644 --- a/Source/DynamicScene/DynamicModelVisualizer.js +++ b/Source/DynamicScene/DynamicModelVisualizer.js @@ -24,8 +24,7 @@ define([ var matrix3Scratch = new Matrix3(); /** - * A {@link Visualizer} which maps the {@link DynamicModel} instance - * in {@link DynamicObject.model} to a {@link Model}. + * A {@link Visualizer} which maps {@link DynamicObject#model} to a {@link Model}. * @alias DynamicModelVisualizer * @constructor * @@ -51,7 +50,7 @@ define([ }; /** - * Updates all models created this visualizer to match their + * Updates models created this visualizer to match their * DynamicObject counterpart at the given time. * @memberof DynamicModelVisualizer * diff --git a/Source/DynamicScene/DynamicObject.js b/Source/DynamicScene/DynamicObject.js index a9a094ba7eb4..4cfa0e28c8a3 100644 --- a/Source/DynamicScene/DynamicObject.js +++ b/Source/DynamicScene/DynamicObject.js @@ -285,7 +285,7 @@ define(['../Core/createGuid', /** * Adds a property to this object. Once a property is added, it can be - * observed with {@link DynamicObject.definitionChanged} and composited + * observed with {@link DynamicObject#definitionChanged} and composited * with {@link CompositeDynamicObjectCollection} * @memberof DynamicObject * diff --git a/Source/DynamicScene/DynamicPathVisualizer.js b/Source/DynamicScene/DynamicPathVisualizer.js index 618d90da3035..960b1ffedf69 100644 --- a/Source/DynamicScene/DynamicPathVisualizer.js +++ b/Source/DynamicScene/DynamicPathVisualizer.js @@ -423,8 +423,7 @@ define([ }; /** - * A {@link Visualizer} which maps the {@link DynamicPath} instance - * in {@link DynamicObject.path} to a {@link Polyline}. + * A {@link Visualizer} which maps {@link DynamicObject#path} to a {@link Polyline}. * @alias DynamicPathVisualizer * @constructor * @@ -451,6 +450,7 @@ define([ /** * Updates all of the primitives created by this visualizer to match their * DynamicObject counterpart at the given time. + * @memberof DynamicPathVisualizer * * @param {JulianDate} time The time to update to. * @returns {Boolean} This function always returns true. @@ -518,7 +518,7 @@ define([ /** * Removes and destroys all primitives created by this instance. - * @memberof DynamicVectorVisualizer + * @memberof DynamicPathVisualizer */ DynamicPathVisualizer.prototype.destroy = function() { var dynamicObjectCollection = this._dynamicObjectCollection; diff --git a/Source/DynamicScene/DynamicPointVisualizer.js b/Source/DynamicScene/DynamicPointVisualizer.js index e0d72d05b16e..773325d5fc42 100644 --- a/Source/DynamicScene/DynamicPointVisualizer.js +++ b/Source/DynamicScene/DynamicPointVisualizer.js @@ -18,9 +18,8 @@ define([ "use strict"; /** - * A {@link Visualizer} which maps the {@link DynamicPoint} instance - * in {@link DynamicObject.point} to a {@link Billboard}. - * @alias DynamicLabelVisualizer + * A {@link Visualizer} which maps {@link DynamicObject#point} to a {@link Billboard}. + * @alias DynamicPointVisualizer * @constructor * * @param {Scene} scene The scene the primitives will be rendered in. @@ -52,7 +51,7 @@ define([ }; /** - * Updates all of the primitives created by this visualizer to match their + * Updates the primitives created by this visualizer to match their * DynamicObject counterpart at the given time. * @memberof DynamicPointVisualizer * diff --git a/Source/DynamicScene/DynamicPyramidVisualizer.js b/Source/DynamicScene/DynamicPyramidVisualizer.js index 1265ff6372e3..c2eb3594c75e 100644 --- a/Source/DynamicScene/DynamicPyramidVisualizer.js +++ b/Source/DynamicScene/DynamicPyramidVisualizer.js @@ -30,8 +30,7 @@ define([ var matrix3Scratch = new Matrix3(); /** - * A {@link Visualizer} which maps the {@link DynamicPyramid} instance - * in {@link DynamicObject.pyramid} to a {@link CustomSensorVolume}. + * A {@link Visualizer} which maps {@link DynamicObject#pyramid} to a {@link CustomSensorVolume}. * @alias DynamicPyramidVisualizer * @constructor * @@ -58,7 +57,7 @@ define([ }; /** - * Updates all of the sensors created by this visualizer to match their + * Updates the sensors created by this visualizer to match their * DynamicObject counterpart at the given time. * @memberof DynamicPyramidVisualizer * diff --git a/Source/DynamicScene/DynamicVectorVisualizer.js b/Source/DynamicScene/DynamicVectorVisualizer.js index c494b7c67ca9..761211e469db 100644 --- a/Source/DynamicScene/DynamicVectorVisualizer.js +++ b/Source/DynamicScene/DynamicVectorVisualizer.js @@ -18,8 +18,7 @@ define([ "use strict"; /** - * A {@link Visualizer} which maps the {@link DynamicVector} instance - * in {@link DynamicObject.vector} to a {@link Polyline}. + * A {@link Visualizer} which maps {@link DynamicObject#vector} to a {@link Polyline}. * @alias DynamicVectorVisualizer * @constructor * @@ -48,7 +47,7 @@ define([ }; /** - * Updates all of the primitives created by this visualizer to match their + * Updates the primitives created by this visualizer to match their * DynamicObject counterpart at the given time. * @memberof DynamicVectorVisualizer * diff --git a/Source/DynamicScene/GeometryVisualizer.js b/Source/DynamicScene/GeometryVisualizer.js index 5e0fc13ec55b..ceddf11795bf 100644 --- a/Source/DynamicScene/GeometryVisualizer.js +++ b/Source/DynamicScene/GeometryVisualizer.js @@ -92,7 +92,7 @@ define(['../Core/AssociativeArray', } /** - * A general purpose visualizer for all graphics that can be represented by {@link Primitive} instances. + * A general purpose visualizer for geometry represented by {@link Primitive} instances. * @alias GeometryVisualizer * @constructor * diff --git a/Source/DynamicScene/Visualizer.js b/Source/DynamicScene/Visualizer.js index 446bfb701e8f..96afa5fe250f 100644 --- a/Source/DynamicScene/Visualizer.js +++ b/Source/DynamicScene/Visualizer.js @@ -10,6 +10,16 @@ define(['../Core/DeveloperError'], function(DeveloperError) { * to be instantiated directly. * @alias Visualizer * @constructor + * + * @see DynamicBillboardVisualizer + * @see DynamicConeVisualizerUsingCustomSensor + * @see DynamicLabelVisualizer + * @see DynamicModelVisualizer + * @see DynamicPathVisualizer + * @see DynamicPointVisualizer + * @see DynamicPyramidVisualizer + * @see DynamicVectorVisualizer + * @see GeometryVisualizer */ var Visualizer = function() { DeveloperError.throwInstantiationError(); From d491e257638cc6006c09a6f53b0117f3e3837ab6 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Sun, 27 Apr 2014 14:37:28 -0400 Subject: [PATCH 04/10] Update CHANGES --- CHANGES.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 5e9611de2a5d..fc8ca8e9e5de 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,16 @@ Beta Releases * Renamed and moved `Scene.primitives.centralBody` moved to `Scene.globe`. * Removed `CesiumWidget.centralBody` and `Viewer.centralBody`. Use `Scene.globe`. * Renamed `CentralBody` to `Globe`. + * Refactored visualizers, removing `setDynamicObjectCollection`, `getDynamicObjectCollection`, `getScene`, and `removeAllPrimitives` which are all superfluous after the introduction of `DataSourceDisplay`. The affected classes are: + * `DynamicBillboardVisualizer` + * `DynamicConeVisualizerUsingCustomSensor` + * `DynamicLabelVisualizer` + * `DynamicModelVisualizer` + * `DynamicPathVisualizer` + * `DynamicPointVisualizer` + * `DynamicPyramidVisualizer` + * `DynamicVectorVisualizer` + * `GeometryVisualizer` * Renamed Extent to Rectangle * `Extent` -> `Rectangle` * `ExtentGeometry` -> `RectangleGeomtry` From a9241bb996bcaa43defbe13d44bc1d7c6faebef9 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Sun, 27 Apr 2014 14:41:14 -0400 Subject: [PATCH 05/10] Remove TODOs --- Source/DynamicScene/DynamicBillboardVisualizer.js | 1 - Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js | 1 - Source/DynamicScene/DynamicLabelVisualizer.js | 1 - Source/DynamicScene/DynamicPathVisualizer.js | 1 - Source/DynamicScene/DynamicPointVisualizer.js | 1 - Source/DynamicScene/DynamicPyramidVisualizer.js | 1 - Source/DynamicScene/DynamicVectorVisualizer.js | 1 - 7 files changed, 7 deletions(-) diff --git a/Source/DynamicScene/DynamicBillboardVisualizer.js b/Source/DynamicScene/DynamicBillboardVisualizer.js index d411dd9a499e..ab80bd47558c 100644 --- a/Source/DynamicScene/DynamicBillboardVisualizer.js +++ b/Source/DynamicScene/DynamicBillboardVisualizer.js @@ -166,7 +166,6 @@ define([ billboard._visualizerUrl = undefined; billboard._visualizerTextureAvailable = false; - // CZML_TODO Determine official defaults billboard.color = Color.WHITE; billboard.eyeOffset = Cartesian3.ZERO; billboard.pixelOffset = Cartesian2.ZERO; diff --git a/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js b/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js index 23d0d5354abe..4e8218f5041d 100644 --- a/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js +++ b/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js @@ -194,7 +194,6 @@ define([ dynamicObject._coneVisualizerIndex = coneVisualizerIndex; cone.id = dynamicObject; - // CZML_TODO Determine official defaults cone.material = Material.fromType(Material.ColorType); cone.intersectionColor = Color.clone(Color.YELLOW); cone.intersectionWidth = 5.0; diff --git a/Source/DynamicScene/DynamicLabelVisualizer.js b/Source/DynamicScene/DynamicLabelVisualizer.js index 2990a088827f..c86687865bab 100644 --- a/Source/DynamicScene/DynamicLabelVisualizer.js +++ b/Source/DynamicScene/DynamicLabelVisualizer.js @@ -143,7 +143,6 @@ define([ dynamicObject._labelVisualizerIndex = labelVisualizerIndex; label.id = dynamicObject; - // CZML_TODO Determine official defaults label.text = ''; label.scale = 1.0; label.font = '30px sans-serif'; diff --git a/Source/DynamicScene/DynamicPathVisualizer.js b/Source/DynamicScene/DynamicPathVisualizer.js index 960b1ffedf69..6cdd3bf8bd71 100644 --- a/Source/DynamicScene/DynamicPathVisualizer.js +++ b/Source/DynamicScene/DynamicPathVisualizer.js @@ -354,7 +354,6 @@ define([ dynamicObject._pathVisualizerIndex = pathVisualizerIndex; polyline.id = dynamicObject; - // CZML_TODO Determine official defaults polyline.width = 1; var material = polyline.material; if (!defined(material) || (material.type !== Material.PolylineOutlineType)) { diff --git a/Source/DynamicScene/DynamicPointVisualizer.js b/Source/DynamicScene/DynamicPointVisualizer.js index 773325d5fc42..a961363e9b8c 100644 --- a/Source/DynamicScene/DynamicPointVisualizer.js +++ b/Source/DynamicScene/DynamicPointVisualizer.js @@ -135,7 +135,6 @@ define([ dynamicObject._pointVisualizerIndex = pointVisualizerIndex; billboard.id = dynamicObject; - // CZML_TODO Determine official defaults billboard._visualizerColor = Color.clone(Color.WHITE, billboard._visualizerColor); billboard._visualizerOutlineColor = Color.clone(Color.BLACK, billboard._visualizerOutlineColor); billboard._visualizerOutlineWidth = 0; diff --git a/Source/DynamicScene/DynamicPyramidVisualizer.js b/Source/DynamicScene/DynamicPyramidVisualizer.js index c2eb3594c75e..76093029053f 100644 --- a/Source/DynamicScene/DynamicPyramidVisualizer.js +++ b/Source/DynamicScene/DynamicPyramidVisualizer.js @@ -156,7 +156,6 @@ define([ dynamicObject._pyramidVisualizerIndex = pyramidVisualizerIndex; pyramid.id = dynamicObject; - // CZML_TODO Determine official defaults pyramid.radius = Number.POSITIVE_INFINITY; pyramid.showIntersection = true; pyramid.intersectionColor = Color.YELLOW; diff --git a/Source/DynamicScene/DynamicVectorVisualizer.js b/Source/DynamicScene/DynamicVectorVisualizer.js index 761211e469db..be169979be15 100644 --- a/Source/DynamicScene/DynamicVectorVisualizer.js +++ b/Source/DynamicScene/DynamicVectorVisualizer.js @@ -126,7 +126,6 @@ define([ dynamicObject._vectorVisualizerIndex = vectorVisualizerIndex; polyline.id = dynamicObject; - // CZML_TODO Determine official defaults polyline.width = 1; var material = polyline.material; if (!defined(material) || (material.type !== Material.PolylineArrowType)) { From 58fd85c8b06b4950e733fe64a2311a9125e74cd8 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Mon, 28 Apr 2014 17:28:00 -0400 Subject: [PATCH 06/10] Changes after review. Fix DynamicConeVisualizerUsingCustomSensor doc. Use already obtained local variable in DynamicPointVisualizer.prototype.destroy Remove unecessary if checks. --- .../DynamicBillboardVisualizer.js | 8 +- .../DynamicConeVisualizerUsingCustomSensor.js | 12 ++- Source/DynamicScene/DynamicLabelVisualizer.js | 8 +- Source/DynamicScene/DynamicModelVisualizer.js | 8 +- Source/DynamicScene/DynamicPathVisualizer.js | 74 +++++++++---------- Source/DynamicScene/DynamicPointVisualizer.js | 10 +-- .../DynamicScene/DynamicPyramidVisualizer.js | 8 +- .../DynamicScene/DynamicVectorVisualizer.js | 8 +- 8 files changed, 60 insertions(+), 76 deletions(-) diff --git a/Source/DynamicScene/DynamicBillboardVisualizer.js b/Source/DynamicScene/DynamicBillboardVisualizer.js index ab80bd47558c..a1f3f3235d4c 100644 --- a/Source/DynamicScene/DynamicBillboardVisualizer.js +++ b/Source/DynamicScene/DynamicBillboardVisualizer.js @@ -86,11 +86,9 @@ define([ } //>>includeEnd('debug'); - if (defined(this._dynamicObjectCollection)) { - var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for (var i = 0, len = dynamicObjects.length; i < len; i++) { - updateObject(this, time, dynamicObjects[i]); - } + var dynamicObjects = this._dynamicObjectCollection.getObjects(); + for (var i = 0, len = dynamicObjects.length; i < len; i++) { + updateObject(this, time, dynamicObjects[i]); } return true; }; diff --git a/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js b/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js index 4e8218f5041d..6d9f214a9585 100644 --- a/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js +++ b/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js @@ -100,7 +100,7 @@ define([ /** * Updates the primitives created by this visualizer to match their * DynamicObject counterpart at the given time. - * @memberof DynamicLabelVisualizer + * @memberof DynamicConeVisualizerUsingCustomSensor * * @param {JulianDate} time The time to update to. * @returns {Boolean} This function always returns true. @@ -112,18 +112,16 @@ define([ } //>>includeEnd('debug'); - if (defined(this._dynamicObjectCollection)) { - var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for ( var i = 0, len = dynamicObjects.length; i < len; i++) { - updateObject(this, time, dynamicObjects[i]); - } + var dynamicObjects = this._dynamicObjectCollection.getObjects(); + for ( var i = 0, len = dynamicObjects.length; i < len; i++) { + updateObject(this, time, dynamicObjects[i]); } return true; }; /** * Removes and destroys all primitives created by this instance. - * @memberof DynamicLabelVisualizer + * @memberof DynamicConeVisualizerUsingCustomSensor */ DynamicConeVisualizerUsingCustomSensor.prototype.destroy = function() { var dynamicObjectCollection = this._dynamicObjectCollection; diff --git a/Source/DynamicScene/DynamicLabelVisualizer.js b/Source/DynamicScene/DynamicLabelVisualizer.js index c86687865bab..ba071bf32d72 100644 --- a/Source/DynamicScene/DynamicLabelVisualizer.js +++ b/Source/DynamicScene/DynamicLabelVisualizer.js @@ -67,11 +67,9 @@ define([ } //>>includeEnd('debug'); - if (defined(this._dynamicObjectCollection)) { - var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for ( var i = 0, len = dynamicObjects.length; i < len; i++) { - updateObject(this, time, dynamicObjects[i]); - } + var dynamicObjects = this._dynamicObjectCollection.getObjects(); + for ( var i = 0, len = dynamicObjects.length; i < len; i++) { + updateObject(this, time, dynamicObjects[i]); } return true; }; diff --git a/Source/DynamicScene/DynamicModelVisualizer.js b/Source/DynamicScene/DynamicModelVisualizer.js index 4a690bd3dcdf..58dd1afba5d0 100644 --- a/Source/DynamicScene/DynamicModelVisualizer.js +++ b/Source/DynamicScene/DynamicModelVisualizer.js @@ -64,11 +64,9 @@ define([ } //>>includeEnd('debug'); - if (defined(this._dynamicObjectCollection)) { - var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for (var i = 0, len = dynamicObjects.length; i < len; i++) { - this._updateObject(time, dynamicObjects[i]); - } + var dynamicObjects = this._dynamicObjectCollection.getObjects(); + for (var i = 0, len = dynamicObjects.length; i < len; i++) { + this._updateObject(time, dynamicObjects[i]); } return true; }; diff --git a/Source/DynamicScene/DynamicPathVisualizer.js b/Source/DynamicScene/DynamicPathVisualizer.js index 6cdd3bf8bd71..933f01bf8c3d 100644 --- a/Source/DynamicScene/DynamicPathVisualizer.js +++ b/Source/DynamicScene/DynamicPathVisualizer.js @@ -461,55 +461,53 @@ define([ } //>>includeEnd('debug'); - if (defined(this._dynamicObjectCollection)) { - var updaters = this._updaters; - for ( var key in updaters) { - if (updaters.hasOwnProperty(key)) { - updaters[key].update(time); - } + var updaters = this._updaters; + for ( var key in updaters) { + if (updaters.hasOwnProperty(key)) { + updaters[key].update(time); } + } - var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for ( var i = 0, len = dynamicObjects.length; i < len; i++) { - var dynamicObject = dynamicObjects[i]; + var dynamicObjects = this._dynamicObjectCollection.getObjects(); + for ( var i = 0, len = dynamicObjects.length; i < len; i++) { + var dynamicObject = dynamicObjects[i]; - if (!defined(dynamicObject._path)) { - continue; - } + if (!defined(dynamicObject._path)) { + continue; + } - var positionProperty = dynamicObject._position; - if (!defined(positionProperty)) { - continue; - } + var positionProperty = dynamicObject._position; + if (!defined(positionProperty)) { + continue; + } - var lastUpdater = dynamicObject._pathUpdater; + var lastUpdater = dynamicObject._pathUpdater; - var frameToVisualize = ReferenceFrame.FIXED; - if (this._scene.mode === SceneMode.SCENE3D) { - frameToVisualize = positionProperty._referenceFrame; - } + var frameToVisualize = ReferenceFrame.FIXED; + if (this._scene.mode === SceneMode.SCENE3D) { + frameToVisualize = positionProperty._referenceFrame; + } - var currentUpdater = this._updaters[frameToVisualize]; + var currentUpdater = this._updaters[frameToVisualize]; - if ((lastUpdater === currentUpdater) && (defined(currentUpdater))) { - currentUpdater.updateObject(time, dynamicObject); - continue; - } + if ((lastUpdater === currentUpdater) && (defined(currentUpdater))) { + currentUpdater.updateObject(time, dynamicObject); + continue; + } - if (defined(lastUpdater)) { - lastUpdater.removeObject(dynamicObject); - } + if (defined(lastUpdater)) { + lastUpdater.removeObject(dynamicObject); + } - if (!defined(currentUpdater)) { - currentUpdater = new PolylineUpdater(this._scene, frameToVisualize); - currentUpdater.update(time); - this._updaters[frameToVisualize] = currentUpdater; - } + if (!defined(currentUpdater)) { + currentUpdater = new PolylineUpdater(this._scene, frameToVisualize); + currentUpdater.update(time); + this._updaters[frameToVisualize] = currentUpdater; + } - dynamicObject._pathUpdater = currentUpdater; - if (defined(currentUpdater)) { - currentUpdater.updateObject(time, dynamicObject); - } + dynamicObject._pathUpdater = currentUpdater; + if (defined(currentUpdater)) { + currentUpdater.updateObject(time, dynamicObject); } } return true; diff --git a/Source/DynamicScene/DynamicPointVisualizer.js b/Source/DynamicScene/DynamicPointVisualizer.js index a961363e9b8c..771424098cb1 100644 --- a/Source/DynamicScene/DynamicPointVisualizer.js +++ b/Source/DynamicScene/DynamicPointVisualizer.js @@ -65,11 +65,9 @@ define([ } //>>includeEnd('debug'); - if (defined(this._dynamicObjectCollection)) { - var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for ( var i = 0, len = dynamicObjects.length; i < len; i++) { - updateObject(this, time, dynamicObjects[i]); - } + var dynamicObjects = this._dynamicObjectCollection.getObjects(); + for ( var i = 0, len = dynamicObjects.length; i < len; i++) { + updateObject(this, time, dynamicObjects[i]); } return true; }; @@ -80,7 +78,7 @@ define([ */ DynamicPointVisualizer.prototype.destroy = function() { var dynamicObjectCollection = this._dynamicObjectCollection; - var dynamicObjects = this._dynamicObjectCollection.getObjects(); + var dynamicObjects = dynamicObjectCollection.getObjects(); for ( var i = dynamicObjects.length - 1; i > -1; i--) { dynamicObjects[i]._pointVisualizerIndex = undefined; } diff --git a/Source/DynamicScene/DynamicPyramidVisualizer.js b/Source/DynamicScene/DynamicPyramidVisualizer.js index 76093029053f..cfc1e6fcf05c 100644 --- a/Source/DynamicScene/DynamicPyramidVisualizer.js +++ b/Source/DynamicScene/DynamicPyramidVisualizer.js @@ -71,11 +71,9 @@ define([ } //>>includeEnd('debug'); - if (defined(this._dynamicObjectCollection)) { - var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for ( var i = 0, len = dynamicObjects.length; i < len; i++) { - updateObject(this, time, dynamicObjects[i]); - } + var dynamicObjects = this._dynamicObjectCollection.getObjects(); + for ( var i = 0, len = dynamicObjects.length; i < len; i++) { + updateObject(this, time, dynamicObjects[i]); } return true; }; diff --git a/Source/DynamicScene/DynamicVectorVisualizer.js b/Source/DynamicScene/DynamicVectorVisualizer.js index be169979be15..580e1939be35 100644 --- a/Source/DynamicScene/DynamicVectorVisualizer.js +++ b/Source/DynamicScene/DynamicVectorVisualizer.js @@ -61,11 +61,9 @@ define([ } //>>includeEnd('debug'); - if (defined(this._dynamicObjectCollection)) { - var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for ( var i = 0, len = dynamicObjects.length; i < len; i++) { - updateObject(this, time, dynamicObjects[i]); - } + var dynamicObjects = this._dynamicObjectCollection.getObjects(); + for ( var i = 0, len = dynamicObjects.length; i < len; i++) { + updateObject(this, time, dynamicObjects[i]); } return true; }; From 2b0191f2c6d8b85c58a20ebcc641dabe6dd1bbd2 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Mon, 28 Apr 2014 17:55:41 -0400 Subject: [PATCH 07/10] Changes after review. 1. Put back isDestroyed function. 2. Document Visualizer functions correctly. --- Source/DynamicScene/DynamicBillboardVisualizer.js | 10 ++++++++++ .../DynamicConeVisualizerUsingCustomSensor.js | 10 ++++++++++ Source/DynamicScene/DynamicLabelVisualizer.js | 10 ++++++++++ Source/DynamicScene/DynamicModelVisualizer.js | 10 ++++++++++ Source/DynamicScene/DynamicPathVisualizer.js | 10 ++++++++++ Source/DynamicScene/DynamicPointVisualizer.js | 10 ++++++++++ Source/DynamicScene/DynamicPyramidVisualizer.js | 10 ++++++++++ Source/DynamicScene/DynamicVectorVisualizer.js | 10 ++++++++++ Source/DynamicScene/GeometryVisualizer.js | 10 ++++++++++ Source/DynamicScene/Visualizer.js | 11 +++++++++++ 10 files changed, 101 insertions(+) diff --git a/Source/DynamicScene/DynamicBillboardVisualizer.js b/Source/DynamicScene/DynamicBillboardVisualizer.js index a1f3f3235d4c..57bb42ce4d96 100644 --- a/Source/DynamicScene/DynamicBillboardVisualizer.js +++ b/Source/DynamicScene/DynamicBillboardVisualizer.js @@ -93,6 +93,16 @@ define([ return true; }; + /** + * Returns true if this object was destroyed; otherwise, false. + * @memberof DynamicBillboardVisualizer + * + * @returns {Boolean} True if this object was destroyed; otherwise, false. + */ + DynamicBillboardVisualizer.prototype.isDestroyed = function() { + return false; + }; + /** * Removes and destroys all primitives created by this instance. * @memberof DynamicBillboardVisualizer diff --git a/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js b/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js index 6d9f214a9585..8281540df56e 100644 --- a/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js +++ b/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js @@ -119,6 +119,16 @@ define([ return true; }; + /** + * Returns true if this object was destroyed; otherwise, false. + * @memberof DynamicConeVisualizerUsingCustomSensor + * + * @returns {Boolean} True if this object was destroyed; otherwise, false. + */ + DynamicConeVisualizerUsingCustomSensor.prototype.isDestroyed = function() { + return false; + }; + /** * Removes and destroys all primitives created by this instance. * @memberof DynamicConeVisualizerUsingCustomSensor diff --git a/Source/DynamicScene/DynamicLabelVisualizer.js b/Source/DynamicScene/DynamicLabelVisualizer.js index ba071bf32d72..04ef15ab28bb 100644 --- a/Source/DynamicScene/DynamicLabelVisualizer.js +++ b/Source/DynamicScene/DynamicLabelVisualizer.js @@ -74,6 +74,16 @@ define([ return true; }; + /** + * Returns true if this object was destroyed; otherwise, false. + * @memberof DynamicLabelVisualizer + * + * @returns {Boolean} True if this object was destroyed; otherwise, false. + */ + DynamicLabelVisualizer.prototype.isDestroyed = function() { + return false; + }; + /** * Removes and destroys all primitives created by this instance. * @memberof DynamicLabelVisualizer diff --git a/Source/DynamicScene/DynamicModelVisualizer.js b/Source/DynamicScene/DynamicModelVisualizer.js index 044e7637aecc..bc353f630aa5 100644 --- a/Source/DynamicScene/DynamicModelVisualizer.js +++ b/Source/DynamicScene/DynamicModelVisualizer.js @@ -71,6 +71,16 @@ define([ return true; }; + /** + * Returns true if this object was destroyed; otherwise, false. + * @memberof DynamicModelVisualizer + * + * @returns {Boolean} True if this object was destroyed; otherwise, false. + */ + DynamicModelVisualizer.prototype.isDestroyed = function() { + return false; + }; + /** * Removes and destroys all primitives created by this instance. * @memberof DynamicModelVisualizer diff --git a/Source/DynamicScene/DynamicPathVisualizer.js b/Source/DynamicScene/DynamicPathVisualizer.js index 933f01bf8c3d..74e95e6e6274 100644 --- a/Source/DynamicScene/DynamicPathVisualizer.js +++ b/Source/DynamicScene/DynamicPathVisualizer.js @@ -513,6 +513,16 @@ define([ return true; }; + /** + * Returns true if this object was destroyed; otherwise, false. + * @memberof DynamicPathVisualizer + * + * @returns {Boolean} True if this object was destroyed; otherwise, false. + */ + DynamicPathVisualizer.prototype.isDestroyed = function() { + return false; + }; + /** * Removes and destroys all primitives created by this instance. * @memberof DynamicPathVisualizer diff --git a/Source/DynamicScene/DynamicPointVisualizer.js b/Source/DynamicScene/DynamicPointVisualizer.js index 771424098cb1..e4322c35d337 100644 --- a/Source/DynamicScene/DynamicPointVisualizer.js +++ b/Source/DynamicScene/DynamicPointVisualizer.js @@ -72,6 +72,16 @@ define([ return true; }; + /** + * Returns true if this object was destroyed; otherwise, false. + * @memberof DynamicPointVisualizer + * + * @returns {Boolean} True if this object was destroyed; otherwise, false. + */ + DynamicPointVisualizer.prototype.isDestroyed = function() { + return false; + }; + /** * Removes and destroys all primitives created by this instance. * @memberof DynamicPointVisualizer diff --git a/Source/DynamicScene/DynamicPyramidVisualizer.js b/Source/DynamicScene/DynamicPyramidVisualizer.js index cfc1e6fcf05c..2c9a2fdfd15b 100644 --- a/Source/DynamicScene/DynamicPyramidVisualizer.js +++ b/Source/DynamicScene/DynamicPyramidVisualizer.js @@ -78,6 +78,16 @@ define([ return true; }; + /** + * Returns true if this object was destroyed; otherwise, false. + * @memberof DynamicPyramidVisualizer + * + * @returns {Boolean} True if this object was destroyed; otherwise, false. + */ + DynamicPyramidVisualizer.prototype.isDestroyed = function() { + return false; + }; + /** * Removes and destroys all primitives created by this instance. * @memberof DynamicPyramidVisualizer diff --git a/Source/DynamicScene/DynamicVectorVisualizer.js b/Source/DynamicScene/DynamicVectorVisualizer.js index 580e1939be35..8166ebe66599 100644 --- a/Source/DynamicScene/DynamicVectorVisualizer.js +++ b/Source/DynamicScene/DynamicVectorVisualizer.js @@ -68,6 +68,16 @@ define([ return true; }; + /** + * Returns true if this object was destroyed; otherwise, false. + * @memberof DynamicVectorVisualizer + * + * @returns {Boolean} True if this object was destroyed; otherwise, false. + */ + DynamicVectorVisualizer.prototype.isDestroyed = function() { + return false; + }; + /** * Removes and destroys all primitives created by this instance. * @memberof DynamicVectorVisualizer diff --git a/Source/DynamicScene/GeometryVisualizer.js b/Source/DynamicScene/GeometryVisualizer.js index ceddf11795bf..9464d124cb70 100644 --- a/Source/DynamicScene/GeometryVisualizer.js +++ b/Source/DynamicScene/GeometryVisualizer.js @@ -207,6 +207,16 @@ define(['../Core/AssociativeArray', return isUpdated; }; + /** + * Returns true if this object was destroyed; otherwise, false. + * @memberof GeometryVisualizer + * + * @returns {Boolean} True if this object was destroyed; otherwise, false. + */ + GeometryVisualizer.prototype.isDestroyed = function() { + return false; + }; + /** * Removes and destroys all primitives created by this instance. * @memberof GeometryVisualizer diff --git a/Source/DynamicScene/Visualizer.js b/Source/DynamicScene/Visualizer.js index 96afa5fe250f..277dd15fefb6 100644 --- a/Source/DynamicScene/Visualizer.js +++ b/Source/DynamicScene/Visualizer.js @@ -28,6 +28,7 @@ define(['../Core/DeveloperError'], function(DeveloperError) { /** * Updates the visualization to the provided time. * @memberof Visualizer + * @function * * @param {JulianDate} time The time. * @@ -37,9 +38,19 @@ define(['../Core/DeveloperError'], function(DeveloperError) { */ Visualizer.prototype.update = DeveloperError.throwInstantiationError; + /** + * Returns true if this object was destroyed; otherwise, false. + * @memberof Visualizer + * @function + * + * @returns {Boolean} True if this object was destroyed; otherwise, false. + */ + Visualizer.prototype.isDestroyed = DeveloperError.throwInstantiationError; + /** * Removes all visualization and cleans up any resources associated with this instance. * @memberof Visualizer + * @function */ Visualizer.prototype.destroy = DeveloperError.throwInstantiationError; From 5a038040ff1280aacc183c654669f69d3d3c69f4 Mon Sep 17 00:00:00 2001 From: Scott Hunter Date: Tue, 29 Apr 2014 10:28:42 -0400 Subject: [PATCH 08/10] Clean up whitespace. --- Source/DynamicScene/DynamicBillboardVisualizer.js | 2 +- .../DynamicScene/DynamicConeVisualizerUsingCustomSensor.js | 4 ++-- Source/DynamicScene/DynamicLabelVisualizer.js | 4 ++-- Source/DynamicScene/DynamicObject.js | 2 +- Source/DynamicScene/DynamicPathVisualizer.js | 4 ++-- Source/DynamicScene/DynamicPointVisualizer.js | 6 +++--- Source/DynamicScene/DynamicPyramidVisualizer.js | 4 ++-- Source/DynamicScene/DynamicVectorVisualizer.js | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Source/DynamicScene/DynamicBillboardVisualizer.js b/Source/DynamicScene/DynamicBillboardVisualizer.js index 57bb42ce4d96..d013c0ed5071 100644 --- a/Source/DynamicScene/DynamicBillboardVisualizer.js +++ b/Source/DynamicScene/DynamicBillboardVisualizer.js @@ -295,7 +295,7 @@ define([ DynamicBillboardVisualizer.prototype._onObjectsRemoved = function(dynamicObjectCollection, added, dynamicObjects) { var thisBillboardCollection = this._billboardCollection; var thisUnusedIndexes = this._unusedIndexes; - for ( var i = dynamicObjects.length - 1; i > -1; i--) { + for (var i = dynamicObjects.length - 1; i > -1; i--) { var dynamicObject = dynamicObjects[i]; var billboardVisualizerIndex = dynamicObject._billboardVisualizerIndex; if (defined(billboardVisualizerIndex)) { diff --git a/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js b/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js index 8281540df56e..95aedd0db096 100644 --- a/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js +++ b/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js @@ -113,7 +113,7 @@ define([ //>>includeEnd('debug'); var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for ( var i = 0, len = dynamicObjects.length; i < len; i++) { + for (var i = 0, len = dynamicObjects.length; i < len; i++) { updateObject(this, time, dynamicObjects[i]); } return true; @@ -300,7 +300,7 @@ define([ DynamicConeVisualizerUsingCustomSensor.prototype._onObjectsRemoved = function(dynamicObjectCollection, added, dynamicObjects) { var thisConeCollection = this._coneCollection; var thisUnusedIndexes = this._unusedIndexes; - for ( var i = dynamicObjects.length - 1; i > -1; i--) { + for (var i = dynamicObjects.length - 1; i > -1; i--) { var dynamicObject = dynamicObjects[i]; var coneVisualizerIndex = dynamicObject._coneVisualizerIndex; if (defined(coneVisualizerIndex)) { diff --git a/Source/DynamicScene/DynamicLabelVisualizer.js b/Source/DynamicScene/DynamicLabelVisualizer.js index 04ef15ab28bb..2fcd156f0219 100644 --- a/Source/DynamicScene/DynamicLabelVisualizer.js +++ b/Source/DynamicScene/DynamicLabelVisualizer.js @@ -68,7 +68,7 @@ define([ //>>includeEnd('debug'); var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for ( var i = 0, len = dynamicObjects.length; i < len; i++) { + for (var i = 0, len = dynamicObjects.length; i < len; i++) { updateObject(this, time, dynamicObjects[i]); } return true; @@ -272,7 +272,7 @@ define([ DynamicLabelVisualizer.prototype._onObjectsRemoved = function(dynamicObjectCollection, added, dynamicObjects) { var thisLabelCollection = this._labelCollection; var thisUnusedIndexes = this._unusedIndexes; - for ( var i = dynamicObjects.length - 1; i > -1; i--) { + for (var i = dynamicObjects.length - 1; i > -1; i--) { var dynamicObject = dynamicObjects[i]; var labelVisualizerIndex = dynamicObject._labelVisualizerIndex; if (defined(labelVisualizerIndex)) { diff --git a/Source/DynamicScene/DynamicObject.js b/Source/DynamicScene/DynamicObject.js index 4cfa0e28c8a3..e29f5b81beeb 100644 --- a/Source/DynamicScene/DynamicObject.js +++ b/Source/DynamicScene/DynamicObject.js @@ -358,7 +358,7 @@ define(['../Core/createGuid', var propertyNames = this._propertyNames; var propertyNamesLength = propertyNames.length; - for ( var i = 0; i < propertyNamesLength; i++) { + for (var i = 0; i < propertyNamesLength; i++) { var name = propertyNames[i]; var targetProperty = this[name]; var sourceProperty = source[name]; diff --git a/Source/DynamicScene/DynamicPathVisualizer.js b/Source/DynamicScene/DynamicPathVisualizer.js index 74e95e6e6274..037dab5181a6 100644 --- a/Source/DynamicScene/DynamicPathVisualizer.js +++ b/Source/DynamicScene/DynamicPathVisualizer.js @@ -469,7 +469,7 @@ define([ } var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for ( var i = 0, len = dynamicObjects.length; i < len; i++) { + for (var i = 0, len = dynamicObjects.length; i < len; i++) { var dynamicObject = dynamicObjects[i]; if (!defined(dynamicObject._path)) { @@ -548,7 +548,7 @@ define([ }; DynamicPathVisualizer.prototype._onObjectsRemoved = function(dynamicObjectCollection, added, dynamicObjects) { - for ( var i = dynamicObjects.length - 1; i > -1; i--) { + for (var i = dynamicObjects.length - 1; i > -1; i--) { var dynamicObject = dynamicObjects[i]; var _pathUpdater = dynamicObject._pathUpdater; if (defined(_pathUpdater)) { diff --git a/Source/DynamicScene/DynamicPointVisualizer.js b/Source/DynamicScene/DynamicPointVisualizer.js index e4322c35d337..03d007c443bd 100644 --- a/Source/DynamicScene/DynamicPointVisualizer.js +++ b/Source/DynamicScene/DynamicPointVisualizer.js @@ -66,7 +66,7 @@ define([ //>>includeEnd('debug'); var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for ( var i = 0, len = dynamicObjects.length; i < len; i++) { + for (var i = 0, len = dynamicObjects.length; i < len; i++) { updateObject(this, time, dynamicObjects[i]); } return true; @@ -89,7 +89,7 @@ define([ DynamicPointVisualizer.prototype.destroy = function() { var dynamicObjectCollection = this._dynamicObjectCollection; var dynamicObjects = dynamicObjectCollection.getObjects(); - for ( var i = dynamicObjects.length - 1; i > -1; i--) { + for (var i = dynamicObjects.length - 1; i > -1; i--) { dynamicObjects[i]._pointVisualizerIndex = undefined; } dynamicObjectCollection.collectionChanged.removeEventListener(DynamicPointVisualizer.prototype._onObjectsRemoved, this); @@ -256,7 +256,7 @@ define([ DynamicPointVisualizer.prototype._onObjectsRemoved = function(dynamicObjectCollection, added, dynamicObjects) { var thisBillboardCollection = this._billboardCollection; var thisUnusedIndexes = this._unusedIndexes; - for ( var i = dynamicObjects.length - 1; i > -1; i--) { + for (var i = dynamicObjects.length - 1; i > -1; i--) { var dynamicObject = dynamicObjects[i]; var pointVisualizerIndex = dynamicObject._pointVisualizerIndex; if (defined(pointVisualizerIndex)) { diff --git a/Source/DynamicScene/DynamicPyramidVisualizer.js b/Source/DynamicScene/DynamicPyramidVisualizer.js index 2c9a2fdfd15b..625014a48d1e 100644 --- a/Source/DynamicScene/DynamicPyramidVisualizer.js +++ b/Source/DynamicScene/DynamicPyramidVisualizer.js @@ -72,7 +72,7 @@ define([ //>>includeEnd('debug'); var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for ( var i = 0, len = dynamicObjects.length; i < len; i++) { + for (var i = 0, len = dynamicObjects.length; i < len; i++) { updateObject(this, time, dynamicObjects[i]); } return true; @@ -223,7 +223,7 @@ define([ DynamicPyramidVisualizer.prototype._onObjectsRemoved = function(dynamicObjectCollection, added, dynamicObjects) { var thisPyramidCollection = this._pyramidCollection; var thisUnusedIndexes = this._unusedIndexes; - for ( var i = dynamicObjects.length - 1; i > -1; i--) { + for (var i = dynamicObjects.length - 1; i > -1; i--) { var dynamicObject = dynamicObjects[i]; var pyramidVisualizerIndex = dynamicObject._pyramidVisualizerIndex; if (defined(pyramidVisualizerIndex)) { diff --git a/Source/DynamicScene/DynamicVectorVisualizer.js b/Source/DynamicScene/DynamicVectorVisualizer.js index 8166ebe66599..3fb624eed5b9 100644 --- a/Source/DynamicScene/DynamicVectorVisualizer.js +++ b/Source/DynamicScene/DynamicVectorVisualizer.js @@ -62,7 +62,7 @@ define([ //>>includeEnd('debug'); var dynamicObjects = this._dynamicObjectCollection.getObjects(); - for ( var i = 0, len = dynamicObjects.length; i < len; i++) { + for (var i = 0, len = dynamicObjects.length; i < len; i++) { updateObject(this, time, dynamicObjects[i]); } return true; @@ -175,7 +175,7 @@ define([ DynamicVectorVisualizer.prototype._onObjectsRemoved = function(dynamicObjectCollection, added, dynamicObjects) { var thisPolylineCollection = this._polylineCollection; var thisUnusedIndexes = this._unusedIndexes; - for ( var i = dynamicObjects.length - 1; i > -1; i--) { + for (var i = dynamicObjects.length - 1; i > -1; i--) { var dynamicObject = dynamicObjects[i]; var vectorVisualizerIndex = dynamicObject._vectorVisualizerIndex; if (defined(vectorVisualizerIndex)) { From 5fbc9d78007b3565d48b3c45a1edf7cab4baf021 Mon Sep 17 00:00:00 2001 From: Scott Hunter Date: Tue, 29 Apr 2014 10:43:17 -0400 Subject: [PATCH 09/10] Add back tests for isDestroy. --- Specs/DynamicScene/DataSourceDisplaySpec.js | 11 ----------- Specs/DynamicScene/DynamicBillboardVisualizerSpec.js | 9 +++++++++ .../DynamicConeVisualizerUsingCustomSensorSpec.js | 9 +++++++++ Specs/DynamicScene/DynamicLabelVisualizerSpec.js | 9 +++++++++ Specs/DynamicScene/DynamicModelVisualizerSpec.js | 9 +++++++++ Specs/DynamicScene/DynamicPathVisualizerSpec.js | 9 +++++++++ Specs/DynamicScene/DynamicPointVisualizerSpec.js | 9 +++++++++ Specs/DynamicScene/DynamicPyramidVisualizerSpec.js | 9 +++++++++ Specs/DynamicScene/DynamicVectorVisualizerSpec.js | 9 +++++++++ Specs/DynamicScene/GeometryVisualizerSpec.js | 2 ++ 10 files changed, 74 insertions(+), 11 deletions(-) diff --git a/Specs/DynamicScene/DataSourceDisplaySpec.js b/Specs/DynamicScene/DataSourceDisplaySpec.js index 8d3a0644f4bd..25ec30f1b789 100644 --- a/Specs/DynamicScene/DataSourceDisplaySpec.js +++ b/Specs/DynamicScene/DataSourceDisplaySpec.js @@ -37,22 +37,11 @@ defineSuite([ this.destroyed = false; }; - MockVisualizer.prototype.getScene = function() { - return this.scene; - }; - - MockVisualizer.prototype.getDynamicObjectCollection = function() { - return this.dynamicObjectCollection; - }; - MockVisualizer.prototype.update = function(time) { this.lastUpdateTime = time; this.updatesCalled++; }; - MockVisualizer.prototype.removeAllPrimitives = function() { - }; - MockVisualizer.prototype.isDestroyed = function() { return this.destroyed; }; diff --git a/Specs/DynamicScene/DynamicBillboardVisualizerSpec.js b/Specs/DynamicScene/DynamicBillboardVisualizerSpec.js index 7b6d5b3487dd..cbe215c40d68 100644 --- a/Specs/DynamicScene/DynamicBillboardVisualizerSpec.js +++ b/Specs/DynamicScene/DynamicBillboardVisualizerSpec.js @@ -74,6 +74,15 @@ defineSuite([ }).toThrowDeveloperError(); }); + it('isDestroy returns false until destroyed.', function() { + var dynamicObjectCollection = new DynamicObjectCollection(); + visualizer = new DynamicBillboardVisualizer(scene, dynamicObjectCollection); + expect(visualizer.isDestroyed()).toEqual(false); + visualizer.destroy(); + expect(visualizer.isDestroyed()).toEqual(true); + visualizer = undefined; + }); + it('object with no billboard does not create a billboard.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicBillboardVisualizer(scene, dynamicObjectCollection); diff --git a/Specs/DynamicScene/DynamicConeVisualizerUsingCustomSensorSpec.js b/Specs/DynamicScene/DynamicConeVisualizerUsingCustomSensorSpec.js index 80468da2f3b8..ea220cbdcd20 100644 --- a/Specs/DynamicScene/DynamicConeVisualizerUsingCustomSensorSpec.js +++ b/Specs/DynamicScene/DynamicConeVisualizerUsingCustomSensorSpec.js @@ -65,6 +65,15 @@ defineSuite([ }).toThrowDeveloperError(); }); + it('isDestroy returns false until destroyed.', function() { + var dynamicObjectCollection = new DynamicObjectCollection(); + visualizer = new DynamicConeVisualizerUsingCustomSensor(scene, dynamicObjectCollection); + expect(visualizer.isDestroyed()).toEqual(false); + visualizer.destroy(); + expect(visualizer.isDestroyed()).toEqual(true); + visualizer = undefined; + }); + it('object with no cone does not create a primitive.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicConeVisualizerUsingCustomSensor(scene, dynamicObjectCollection); diff --git a/Specs/DynamicScene/DynamicLabelVisualizerSpec.js b/Specs/DynamicScene/DynamicLabelVisualizerSpec.js index 408f2f5f8afa..717e52b45683 100644 --- a/Specs/DynamicScene/DynamicLabelVisualizerSpec.js +++ b/Specs/DynamicScene/DynamicLabelVisualizerSpec.js @@ -70,6 +70,15 @@ defineSuite([ }).toThrowDeveloperError(); }); + it('isDestroy returns false until destroyed.', function() { + var dynamicObjectCollection = new DynamicObjectCollection(); + visualizer = new DynamicLabelVisualizer(scene, dynamicObjectCollection); + expect(visualizer.isDestroyed()).toEqual(false); + visualizer.destroy(); + expect(visualizer.isDestroyed()).toEqual(true); + visualizer = undefined; + }); + it('object with no label does not create a label.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicLabelVisualizer(scene, dynamicObjectCollection); diff --git a/Specs/DynamicScene/DynamicModelVisualizerSpec.js b/Specs/DynamicScene/DynamicModelVisualizerSpec.js index 4454aeb778c2..a914b8024432 100644 --- a/Specs/DynamicScene/DynamicModelVisualizerSpec.js +++ b/Specs/DynamicScene/DynamicModelVisualizerSpec.js @@ -63,6 +63,15 @@ defineSuite([ }).toThrowDeveloperError(); }); + it('isDestroy returns false until destroyed.', function() { + var dynamicObjectCollection = new DynamicObjectCollection(); + visualizer = new DynamicModelVisualizer(scene, dynamicObjectCollection); + expect(visualizer.isDestroyed()).toEqual(false); + visualizer.destroy(); + expect(visualizer.isDestroyed()).toEqual(true); + visualizer = undefined; + }); + it('object with no model does not create one.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicModelVisualizer(scene, dynamicObjectCollection); diff --git a/Specs/DynamicScene/DynamicPathVisualizerSpec.js b/Specs/DynamicScene/DynamicPathVisualizerSpec.js index 3fb95fe06c82..36e06a153912 100644 --- a/Specs/DynamicScene/DynamicPathVisualizerSpec.js +++ b/Specs/DynamicScene/DynamicPathVisualizerSpec.js @@ -63,6 +63,15 @@ defineSuite([ }).toThrowDeveloperError(); }); + it('isDestroy returns false until destroyed.', function() { + var dynamicObjectCollection = new DynamicObjectCollection(); + visualizer = new DynamicPathVisualizer(scene, dynamicObjectCollection); + expect(visualizer.isDestroyed()).toEqual(false); + visualizer.destroy(); + expect(visualizer.isDestroyed()).toEqual(true); + visualizer = undefined; + }); + it('object with no path does not create one.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicPathVisualizer(scene, dynamicObjectCollection); diff --git a/Specs/DynamicScene/DynamicPointVisualizerSpec.js b/Specs/DynamicScene/DynamicPointVisualizerSpec.js index 6f9aef82f917..4881c148655c 100644 --- a/Specs/DynamicScene/DynamicPointVisualizerSpec.js +++ b/Specs/DynamicScene/DynamicPointVisualizerSpec.js @@ -63,6 +63,15 @@ defineSuite([ }).toThrowDeveloperError(); }); + it('isDestroy returns false until destroyed.', function() { + var dynamicObjectCollection = new DynamicObjectCollection(); + visualizer = new DynamicPointVisualizer(scene, dynamicObjectCollection); + expect(visualizer.isDestroyed()).toEqual(false); + visualizer.destroy(); + expect(visualizer.isDestroyed()).toEqual(true); + visualizer = undefined; + }); + it('object with no point does not create a billboard.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicPointVisualizer(scene, dynamicObjectCollection); diff --git a/Specs/DynamicScene/DynamicPyramidVisualizerSpec.js b/Specs/DynamicScene/DynamicPyramidVisualizerSpec.js index df7f4ac21fbd..bc5305f7ae4b 100644 --- a/Specs/DynamicScene/DynamicPyramidVisualizerSpec.js +++ b/Specs/DynamicScene/DynamicPyramidVisualizerSpec.js @@ -63,6 +63,15 @@ defineSuite([ }).toThrowDeveloperError(); }); + it('isDestroy returns false until destroyed.', function() { + var dynamicObjectCollection = new DynamicObjectCollection(); + visualizer = new DynamicPyramidVisualizer(scene, dynamicObjectCollection); + expect(visualizer.isDestroyed()).toEqual(false); + visualizer.destroy(); + expect(visualizer.isDestroyed()).toEqual(true); + visualizer = undefined; + }); + it('object with no pyramid does not create a primitive.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicPyramidVisualizer(scene, dynamicObjectCollection); diff --git a/Specs/DynamicScene/DynamicVectorVisualizerSpec.js b/Specs/DynamicScene/DynamicVectorVisualizerSpec.js index 088efaad9fce..18355afb26e6 100644 --- a/Specs/DynamicScene/DynamicVectorVisualizerSpec.js +++ b/Specs/DynamicScene/DynamicVectorVisualizerSpec.js @@ -67,6 +67,15 @@ defineSuite([ }).toThrowDeveloperError(); }); + it('isDestroy returns false until destroyed.', function() { + var dynamicObjectCollection = new DynamicObjectCollection(); + visualizer = new DynamicVectorVisualizer(scene, dynamicObjectCollection); + expect(visualizer.isDestroyed()).toEqual(false); + visualizer.destroy(); + expect(visualizer.isDestroyed()).toEqual(true); + visualizer = undefined; + }); + it('object with no vector does not create one.', function() { var dynamicObjectCollection = new DynamicObjectCollection(); visualizer = new DynamicVectorVisualizer(scene, dynamicObjectCollection); diff --git a/Specs/DynamicScene/GeometryVisualizerSpec.js b/Specs/DynamicScene/GeometryVisualizerSpec.js index 2f0e8495e791..001cff7f61ae 100644 --- a/Specs/DynamicScene/GeometryVisualizerSpec.js +++ b/Specs/DynamicScene/GeometryVisualizerSpec.js @@ -55,7 +55,9 @@ defineSuite(['DynamicScene/GeometryVisualizer', var visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene, objects); expect(visualizer.update(time)).toBe(true); expect(scene.primitives.length).toBe(0); + expect(visualizer.isDestroyed()).toBe(false); visualizer.destroy(); + expect(visualizer.isDestroyed()).toBe(true); }); it('Creates and removes static color open geometry', function() { From 2169e977d95ed68ab31e7d3077fc80de665c02d5 Mon Sep 17 00:00:00 2001 From: Scott Hunter Date: Tue, 29 Apr 2014 10:47:24 -0400 Subject: [PATCH 10/10] Fix indentation. --- CHANGES.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index fc8ca8e9e5de..5bf20172e2d3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -37,11 +37,11 @@ Beta Releases * `TilingScheme.tileXYToNativeExtent` -> `TilingScheme.tileXYToNativeRectangle` * `TilingScheme.tileXYToExtent` -> `TilingScheme.tileXYToRectangle` * Converted 'DataSource' get methods into properties. - * 'getName` -> `name` - * 'getClock` -> `clock` - * 'getChangedEvent` -> `changedEvent` - * 'getDynamicObjectCollection` -> `dynamicObjects` - * 'getErrorEvent` -> `errorEvent` + * 'getName` -> `name` + * 'getClock` -> `clock` + * 'getChangedEvent` -> `changedEvent` + * 'getDynamicObjectCollection` -> `dynamicObjects` + * 'getErrorEvent` -> `errorEvent` * `BaseLayerPicker` has been extended to support terrain selection. * The `BaseLayerPicker` constructor function now takes the container element and an options object instead of a CentralBody and ImageryLayerCollection. * The `BaseLayerPickerViewModel` constructor function now takes an options object instead of a CentralBody and ImageryLayerCollection.