diff --git a/Apps/Sandcastle/gallery/Camera.html b/Apps/Sandcastle/gallery/Camera.html
index 122ca1eb7b6f..699de7fa7a4f 100644
--- a/Apps/Sandcastle/gallery/Camera.html
+++ b/Apps/Sandcastle/gallery/Camera.html
@@ -206,7 +206,7 @@
Sandcastle.highlight(flyToRectangle);
});
- Sandcastle.addToolbarButton('View an Rectangle', function() {
+ Sandcastle.addToolbarButton('View a Rectangle', function() {
reset(scene);
viewAnRectangle(scene);
Sandcastle.highlight(viewAnRectangle);
diff --git a/CHANGES.md b/CHANGES.md
index 4510b179d979..8a2420f55808 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -9,6 +9,17 @@ 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`.
+ * Replaced `Model.computeWorldBoundingSphere` with `Model.boundingSphere`.
+ * 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`
@@ -26,37 +37,36 @@ Beta Releases
* `TilingScheme.extentToNativeRectangle` -> `TilingScheme.rectangleToNativeRectangle`
* `TilingScheme.tileXYToNativeExtent` -> `TilingScheme.tileXYToNativeRectangle`
* `TilingScheme.tileXYToExtent` -> `TilingScheme.tileXYToRectangle`
- * Converted 'DataSource' get methods into properties.
- * 'getName` -> `name`
- * 'getClock` -> `clock`
- * 'getChangedEvent` -> `changedEvent`
- * 'getDynamicObjectCollection` -> `dynamicObjects`
- * 'getErrorEvent` -> `errorEvent`
- * `BaseLayerPicker` has been extended to support terrain selection.
+ * Converted `DataSource` get methods into properties.
+ * `getName` -> `name`
+ * `getClock` -> `clock`
+ * `getChangedEvent` -> `changedEvent`
+ * `getDynamicObjectCollection` -> `dynamicObjects`
+ * `getErrorEvent` -> `errorEvent`
+ * `BaseLayerPicker` has been extended to support terrain selection ([#1607](https://github.com/AnalyticalGraphicsInc/cesium/pull/1607)).
* 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.
+ * The `BaseLayerPickerViewModel` constructor function now takes an options object instead of a `CentralBody` and `ImageryLayerCollection`.
* `ImageryProviderViewModel` -> `ProviderViewModel`
* `BaseLayerPickerViewModel.selectedName` -> `BaseLayerPickerViewModel.buttonTooltip`
* `BaseLayerPickerViewModel.selectedIconUrl` -> `BaseLayerPickerViewModel.buttonImageUrl`
* `BaseLayerPickerViewModel.selectedItem` -> `BaseLayerPickerViewModel.selectedImagery`
* `BaseLayerPickerViewModel.imageryLayers`has been removed and replaced with `BaseLayerPickerViewModel.centralBody`
- * See [#1607](https://github.com/AnalyticalGraphicsInc/cesium/pull/1607) for full details.
- * `TimeIntervalCollection.clear` renamed to `TimeIntervalColection.removeAll`
+ * Renamed `TimeIntervalCollection.clear` to `TimeIntervalColection.removeAll`
* `Context` is now private
- * Removed `Scene.context`: replaced by adding `drawingBufferWidth`, `drawingBufferHeight`, `maximumAliasedLineWidth` properties and `createTextureAtlas` function to `Scene`.
- * `Camera` constructor takes `Scene` as parameter instead of `Context`
+ * Removed `Scene.context`. Instead, use `Scene.drawingBufferWidth`, `Scene.drawingBufferHeight`, `Scene.maximumAliasedLineWidth`, and `Scene.createTextureAtlas`.
* `Billboard.computeScreenSpacePosition`, `Label.computeScreenSpacePosition`, `SceneTransforms.clipToWindowCoordinates` and `SceneTransforms.clipToDrawingBufferCoordinates` take a `Scene` parameter instead of a `Context`.
- * Types implementing the `ImageryProvider` interface are now required to have a `hasAlphaChannel` property.
- * Removed `checkForChromeFrame` since it is no longer supported by Google. See [Google's official announcement](http://blog.chromium.org/2013/06/retiring-chrome-frame.html).
- * Types implementing `DataSource` no longer need to implement `getIsTimeVarying`, since it is no longer needed.
- * Replaced `Model.computeWorldBoundingSphere` with `Model.boundingSphere`.
+ * `Camera` constructor takes `Scene` as parameter instead of `Context`
+ * Types implementing the `ImageryProvider` interface arenow require a `hasAlphaChannel` property.
+ * Removed `checkForChromeFrame` since Chrome Frame is no longer supported by Google. See [Google's official announcement](http://blog.chromium.org/2013/06/retiring-chrome-frame.html).
+ * Types implementing `DataSource` no longer need to implement `getIsTimeVarying`.
+* Added a `NavigationHelpButton` widget that, when clicked, displays information about how to navigate around the globe with the mouse. The new button is enabled by default in the `Viewer` widget.
+* Added `Model.minimumPixelSize` property so models remain visible when the viewer zooms out.
* Added `DynamicRectangle` to support DataSource provided `RectangleGeometry`.
* Added `DynamicWall` to support DataSource provided `WallGeometry`.
* Improved texture upload performance and reduced memory usage when using `BingMapsImageryProvider` and other imagery providers that return false from `hasAlphaChannel`.
-* Added a `NavigationHelpButton` widget that, when clicked, displays information about how to navigate around the globe with the mouse. The new button is enabled by default in the `Viewer` widget.
* Added the ability to offset the grid in the `GridMaterial`.
* `GeometryVisualizer` now creates geometry asynchronously to prevent locking up the browser.
-* `Clock.canAnimate` was added to prevent time from advancing, even while the clock is animating.
+* Add `Clock.canAnimate` to prevent time from advancing, even while the clock is animating.
* `Viewer` now prevents time from advancing if asynchronous geometry is being processed in order to avoid showing an incomplete picture. This can be disabled via the `Viewer.allowDataSourcesToSuspendAnimation` settings.
* Added `Model.minimumPixelSize` property so models remain visible when the viewer zooms out.
* Added ability to modify glTF material parameters using `Model.getMaterial`, `ModelMaterial`, and `ModelMesh.material`.
diff --git a/Source/DynamicScene/CzmlDataSource.js b/Source/DynamicScene/CzmlDataSource.js
index 0829ca663cca..da5e65966cbc 100644
--- a/Source/DynamicScene/CzmlDataSource.js
+++ b/Source/DynamicScene/CzmlDataSource.js
@@ -1138,6 +1138,7 @@ define(['../Core/Cartesian2',
processPacketData(Boolean, model, 'show', modelData.show, interval, sourceUri);
processPacketData(Number, model, 'scale', modelData.scale, interval, sourceUri);
+ processPacketData(Number, model, 'minimumPixelSize', modelData.minimumPixelSize, interval, sourceUri);
processPacketData(Uri, model, 'uri', modelData.gltf, interval, sourceUri);
}
diff --git a/Source/DynamicScene/DynamicBillboardVisualizer.js b/Source/DynamicScene/DynamicBillboardVisualizer.js
index 857e90a928b9..d013c0ed5071 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,41 @@ define([
}
/**
- * A DynamicObject visualizer which maps the DynamicBillboard instance
- * in DynamicObject.billboard to a Billboard primitive.
+ * A {@link Visualizer} which maps {@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);
- };
-
- /**
- * 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;
- };
+ dynamicObjectCollection.collectionChanged.addEventListener(DynamicBillboardVisualizer.prototype._onObjectsRemoved, this);
- /**
- * 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
+ * Updates 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.
@@ -129,66 +86,36 @@ 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 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.
- *
* @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.
- *
+ * Removes and destroys all primitives created by this instance.
* @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);
};
@@ -247,7 +174,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;
@@ -369,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 097eb6e6ef27..95aedd0db096 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,79 +71,36 @@ define([
}
/**
- * A DynamicObject visualizer which maps the DynamicCone instance
- * in DynamicObject.cone to a CustomSensor primitive.
+ * A {@link Visualizer} which maps {@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
+ * Updates the primitives created by this visualizer to match their
* DynamicObject counterpart at the given time.
+ * @memberof DynamicConeVisualizerUsingCustomSensor
*
* @param {JulianDate} time The time to update to.
* @returns {Boolean} This function always returns true.
@@ -161,72 +112,43 @@ 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 all primitives from the scene.
- */
- DynamicConeVisualizerUsingCustomSensor.prototype.removeAllPrimitives = function() {
- var i, len;
- for (i = 0, len = this._coneCollection.length; i < len; i++) {
- this._primitives.remove(this._coneCollection[i]);
- }
-
- if (defined(this._dynamicObjectCollection)) {
- var dynamicObjects = this._dynamicObjectCollection.getObjects();
- for (i = dynamicObjects.length - 1; i > -1; i--) {
- dynamicObjects[i]._coneVisualizerIndex = undefined;
- }
- }
-
- 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.
- *
+ * Removes and destroys all primitives created by this instance.
* @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);
+ 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;
+ }
+
+ length = this._coneCollection.length;
+ for (i = 0; i < length; i++) {
+ this._primitives.remove(this._coneCollection[i]);
+ }
+
return destroyObject(this);
};
@@ -280,7 +202,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;
@@ -379,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 4c0d810637e9..2fcd156f0219 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);
- };
-
- /**
- * Returns the scene being used by this visualizer.
- *
- * @returns {Scene} The scene being used by this visualizer.
- */
- DynamicLabelVisualizer.prototype.getScene = function() {
- return this._scene;
- };
+ dynamicObjectCollection.collectionChanged.addEventListener(DynamicLabelVisualizer.prototype._onObjectsRemoved, this);
- /**
- * 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
+ * Updates 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.
@@ -110,66 +67,36 @@ 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 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);
};
@@ -224,7 +151,6 @@ define([
dynamicObject._labelVisualizerIndex = labelVisualizerIndex;
label.id = dynamicObject;
- // CZML_TODO Determine official defaults
label.text = '';
label.scale = 1.0;
label.font = '30px sans-serif';
@@ -346,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/DynamicModel.js b/Source/DynamicScene/DynamicModel.js
index 56907bdd20ad..406529b446c9 100644
--- a/Source/DynamicScene/DynamicModel.js
+++ b/Source/DynamicScene/DynamicModel.js
@@ -25,6 +25,8 @@ define(['../Core/defaultValue',
this._showSubscription = undefined;
this._scale = undefined;
this._scaleSubscription = undefined;
+ this._minimumPixelSize = undefined;
+ this._minimumPixelSizeSubscription = undefined;
this._uri = undefined;
this._uriSubscription = undefined;
this._definitionChanged = new Event();
@@ -49,11 +51,17 @@ define(['../Core/defaultValue',
*/
show : createDynamicPropertyDescriptor('show'),
/**
- * Gets or sets the {@Cartesian3} {@link Property} specifying the model's scale.
+ * Gets or sets the Number {@link Property} specifying the model's scale.
* @memberof DynamicModel.prototype
* @type {Property}
*/
scale : createDynamicPropertyDescriptor('scale'),
+ /**
+ * Gets or sets the Number {@link Property} specifying the model's approximate minimum pixel size regardless of zoom.
+ * @memberof DynamicModel.prototype
+ * @type {Property}
+ */
+ minimumPixelSize : createDynamicPropertyDescriptor('minimumPixelSize'),
/**
* Gets or sets the string {@link Property} specifying the model's uri.
* @memberof DynamicModel.prototype
@@ -75,6 +83,7 @@ define(['../Core/defaultValue',
}
result.show = this.show;
result.scale = this.scale;
+ result.minimumPixelSize = this.minimumPixelSize;
result.uri = this.uri;
return result;
};
@@ -95,6 +104,7 @@ define(['../Core/defaultValue',
this.show = defaultValue(this.show, source.show);
this.scale = defaultValue(this.scale, source.scale);
+ this.minimumPixelSize = defaultValue(this.minimumPixelSize, source.minimumPixelSize);
this.uri = defaultValue(this.uri, source.uri);
};
diff --git a/Source/DynamicScene/DynamicModelVisualizer.js b/Source/DynamicScene/DynamicModelVisualizer.js
index 280680eaeaf2..bc353f630aa5 100644
--- a/Source/DynamicScene/DynamicModelVisualizer.js
+++ b/Source/DynamicScene/DynamicModelVisualizer.js
@@ -24,67 +24,35 @@ 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 {@link DynamicObject#model} to a {@link Model}.
* @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');
+ dynamicObjectCollection.collectionChanged.addEventListener(DynamicModelVisualizer.prototype._onObjectsRemoved, this);
+
this._scene = scene;
this._primitives = scene.primitives;
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;
};
/**
- * Updates all of the primitives created by this visualizer to match their
+ * Updates 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.
@@ -96,74 +64,46 @@ 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;
};
- /**
- * Removes all primitives from the scene.
- */
- 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;
- }
- }
- }
- };
-
/**
* 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
+ * @returns {Boolean} True if this object was destroyed; otherwise, false.
*/
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.
- *
+ * Removes and destroys all primitives created by this instance.
* @memberof DynamicModelVisualizer
- *
- * @return {undefined}
- *
- * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
- *
- * @see DynamicModelVisualizer#isDestroyed
- *
- * @example
- * visualizer = visualizer && visualizer.destroy();
*/
DynamicModelVisualizer.prototype.destroy = function() {
- this.removeAllPrimitives();
+ var dynamicObjects = this._dynamicObjectCollection.getObjects();
+ for (var i = dynamicObjects.length - 1; i > -1; i--) {
+ var dynamicObject = dynamicObjects[i];
+ var model = dynamicObject._modelPrimitive;
+ if (defined(model)) {
+ this._primitives.remove(model);
+ if (!model.isDestroyed()) {
+ model.destroy();
+ }
+ dynamicObject._modelPrimitive = undefined;
+ }
+ }
return destroyObject(this);
};
+ /**
+ * @private
+ */
DynamicModelVisualizer.prototype._updateObject = function(time, dynamicObject) {
var context = this._scene._context;
var dynamicModel = dynamicObject._model;
@@ -206,7 +146,6 @@ define([
dynamicObject._modelPrimitiveUri = uri;
model.id = dynamicObject;
- model.scale = 1.0;
model._visualizerOrientation = Quaternion.clone(Quaternion.IDENTITY);
this._primitives.add(model);
dynamicObject._modelPrimitive = model;
@@ -235,8 +174,19 @@ define([
model.scale = scale;
}
}
+
+ var minimumPixelSizeProperty = dynamicModel._minimumPixelSize;
+ if (defined(minimumPixelSizeProperty)) {
+ var minimumPixelSize = minimumPixelSizeProperty.getValue(time);
+ if (defined(minimumPixelSize)) {
+ model.minimumPixelSize = minimumPixelSize;
+ }
+ }
};
+ /**
+ * @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/DynamicObject.js b/Source/DynamicScene/DynamicObject.js
index a9a094ba7eb4..e29f5b81beeb 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
*
@@ -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 b17f077e2939..037dab5181a6 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)) {
@@ -423,78 +422,34 @@ define([
};
/**
- * A DynamicObject visualizer which maps the DynamicPath instance
- * in DynamicObject.path to a Polyline primitive.
+ * A {@link Visualizer} which maps {@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;
};
/**
* 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.
@@ -506,123 +461,94 @@ 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];
-
- if (!defined(dynamicObject._path)) {
- continue;
- }
-
- var positionProperty = dynamicObject._position;
- if (!defined(positionProperty)) {
- continue;
- }
+ var dynamicObjects = this._dynamicObjectCollection.getObjects();
+ for (var i = 0, len = dynamicObjects.length; i < len; i++) {
+ var dynamicObject = dynamicObjects[i];
- var lastUpdater = dynamicObject._pathUpdater;
+ if (!defined(dynamicObject._path)) {
+ continue;
+ }
- var frameToVisualize = ReferenceFrame.FIXED;
- if (this._scene.mode === SceneMode.SCENE3D) {
- frameToVisualize = positionProperty._referenceFrame;
- }
+ var positionProperty = dynamicObject._position;
+ if (!defined(positionProperty)) {
+ continue;
+ }
- var currentUpdater = this._updaters[frameToVisualize];
+ var lastUpdater = dynamicObject._pathUpdater;
- if ((lastUpdater === currentUpdater) && (defined(currentUpdater))) {
- currentUpdater.updateObject(time, dynamicObject);
- continue;
- }
+ var frameToVisualize = ReferenceFrame.FIXED;
+ if (this._scene.mode === SceneMode.SCENE3D) {
+ frameToVisualize = positionProperty._referenceFrame;
+ }
- if (defined(lastUpdater)) {
- lastUpdater.removeObject(dynamicObject);
- }
+ var currentUpdater = this._updaters[frameToVisualize];
- if (!defined(currentUpdater)) {
- currentUpdater = new PolylineUpdater(this._scene, frameToVisualize);
- currentUpdater.update(time);
- this._updaters[frameToVisualize] = currentUpdater;
- }
+ if ((lastUpdater === currentUpdater) && (defined(currentUpdater))) {
+ currentUpdater.updateObject(time, dynamicObject);
+ continue;
+ }
- dynamicObject._pathUpdater = currentUpdater;
- if (defined(currentUpdater)) {
- currentUpdater.updateObject(time, dynamicObject);
- }
+ if (defined(lastUpdater)) {
+ lastUpdater.removeObject(dynamicObject);
}
- }
- return true;
- };
- /**
- * Removes all primitives from the scene.
- */
- DynamicPathVisualizer.prototype.removeAllPrimitives = function() {
- var updaters = this._updaters;
- for ( var key in updaters) {
- if (updaters.hasOwnProperty(key)) {
- updaters[key].destroy();
+ if (!defined(currentUpdater)) {
+ currentUpdater = new PolylineUpdater(this._scene, frameToVisualize);
+ currentUpdater.update(time);
+ this._updaters[frameToVisualize] = currentUpdater;
}
- }
- 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;
+ dynamicObject._pathUpdater = currentUpdater;
+ if (defined(currentUpdater)) {
+ currentUpdater.updateObject(time, dynamicObject);
}
}
+ return true;
};
/**
* 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.
- *
+ * Removes and destroys all primitives created by this instance.
* @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);
+ 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();
+ }
+ }
+
+ var dynamicObjects = dynamicObjectCollection.getObjects();
+ var length = dynamicObjects.length;
+ for (var i = 0; i < length; i++) {
+ dynamicObjects[i]._pathUpdater = undefined;
+ dynamicObjects[i]._pathVisualizerIndex = undefined;
+ }
return destroyObject(this);
};
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 0255b12cf8bb..03d007c443bd 100644
--- a/Source/DynamicScene/DynamicPointVisualizer.js
+++ b/Source/DynamicScene/DynamicPointVisualizer.js
@@ -18,83 +18,42 @@ define([
"use strict";
/**
- * A DynamicObject visualizer which maps the DynamicPoint instance
- * in DynamicObject.point to a Billboard primitive with a point texture.
+ * 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.
- * @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
+ * Updates 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.
@@ -106,66 +65,34 @@ 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 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.
- *
* @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.
- *
+ * Removes and destroys all primitives created by this instance.
* @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 = 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);
};
@@ -216,7 +143,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;
@@ -330,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 168752f29ec3..625014a48d1e 100644
--- a/Source/DynamicScene/DynamicPyramidVisualizer.js
+++ b/Source/DynamicScene/DynamicPyramidVisualizer.js
@@ -30,78 +30,36 @@ 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 {@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;
+ this._dynamicObjectCollection = dynamicObjectCollection;
};
/**
- * 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);
- }
- }
- };
-
- /**
- * Updates all of the primitives 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
*
* @param {JulianDate} time The time to update to.
* @returns {Boolean} This function always returns true.
@@ -113,72 +71,41 @@ 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 all primitives from the scene.
- */
- DynamicPyramidVisualizer.prototype.removeAllPrimitives = function() {
- var i, len;
- for (i = 0, len = this._pyramidCollection.length; i < len; i++) {
- this._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;
- }
- }
-
- 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.
- *
+ * Removes and destroys all primitives created by this instance.
* @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);
+ var i;
+ var length = this._pyramidCollection.length;
+ var primitives = this._primitives;
+ for (i = 0; i < length; i++) {
+ primitives.remove(this._pyramidCollection[i]);
+ }
+
+ var dynamicObjects = this._dynamicObjectCollection.getObjects();
+ length = dynamicObjects.length;
+ for (i = 0; i < length; i++) {
+ dynamicObjects[i]._pyramidVisualizerIndex = undefined;
+ }
+
return destroyObject(this);
};
@@ -237,7 +164,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;
@@ -297,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 0b3734d81b2b..3fb624eed5b9 100644
--- a/Source/DynamicScene/DynamicVectorVisualizer.js
+++ b/Source/DynamicScene/DynamicVectorVisualizer.js
@@ -18,80 +18,38 @@ define([
"use strict";
/**
- * A DynamicObject visualizer which maps the DynamicPolyline instance
- * in DynamicObject.vector to a Polyline primitive.
+ * A {@link Visualizer} which maps {@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
+ * Updates 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.
@@ -103,69 +61,36 @@ 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 all primitives from the scene.
- */
- DynamicVectorVisualizer.prototype.removeAllPrimitives = function() {
- var i;
- this._polylineCollection.removeAll();
-
- if (defined(this._dynamicObjectCollection)) {
- var dynamicObjects = this._dynamicObjectCollection.getObjects();
- for (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.
- *
+ * Removes and destroys all primitives created by this instance.
* @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);
+ var dynamicObjectCollection = this._dynamicObjectCollection;
+ dynamicObjectCollection.collectionChanged.removeEventListener(DynamicVectorVisualizer.prototype._onObjectsRemoved, this);
+
+ var dynamicObjects = this._dynamicObjectCollection.getObjects();
+ for (var i = dynamicObjects.length - 1; i > -1; i--) {
+ dynamicObjects[i]._vectorVisualizerIndex = undefined;
+ }
+
this._scene.primitives.remove(this._polylineCollection);
return destroyObject(this);
};
@@ -209,7 +134,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)) {
@@ -251,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)) {
diff --git a/Source/DynamicScene/GeometryVisualizer.js b/Source/DynamicScene/GeometryVisualizer.js
index cd33dd64b5ac..9464d124cb70 100644
--- a/Source/DynamicScene/GeometryVisualizer.js
+++ b/Source/DynamicScene/GeometryVisualizer.js
@@ -54,14 +54,51 @@ 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.
+ * A general purpose visualizer for geometry represented by {@link Primitive} instances.
* @alias GeometryVisualizer
* @constructor
*
* @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,20 @@ define(['../Core/AssociativeArray',
};
/**
- * Removes all primitives from the scene.
+ * 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
*/
- GeometryVisualizer.prototype.removeAllPrimitives = function() {
+ GeometryVisualizer.prototype.destroy = function() {
this._addedObjects.removeAll();
this._removedObjects.removeAll();
@@ -265,34 +238,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..277dd15fefb6
--- /dev/null
+++ b/Source/DynamicScene/Visualizer.js
@@ -0,0 +1,58 @@
+/*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
+ *
+ * @see DynamicBillboardVisualizer
+ * @see DynamicConeVisualizerUsingCustomSensor
+ * @see DynamicLabelVisualizer
+ * @see DynamicModelVisualizer
+ * @see DynamicPathVisualizer
+ * @see DynamicPointVisualizer
+ * @see DynamicPyramidVisualizer
+ * @see DynamicVectorVisualizer
+ * @see GeometryVisualizer
+ */
+ var Visualizer = function() {
+ DeveloperError.throwInstantiationError();
+ };
+
+ /**
+ * Updates the visualization to the provided time.
+ * @memberof Visualizer
+ * @function
+ *
+ * @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;
+
+ /**
+ * 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;
+
+ return Visualizer;
+});
\ No newline at end of file
diff --git a/Source/Scene/PrimitivePipeline.js b/Source/Scene/PrimitivePipeline.js
index 07ffc136506c..7b4681331c49 100644
--- a/Source/Scene/PrimitivePipeline.js
+++ b/Source/Scene/PrimitivePipeline.js
@@ -12,6 +12,7 @@ define([
'../Core/Geometry',
'../Core/GeometryAttribute',
'../Core/GeometryPipeline',
+ '../Core/IndexDatatype',
'../Core/Matrix4',
'../Core/WebMercatorProjection'
], function(
@@ -27,6 +28,7 @@ define([
Geometry,
GeometryAttribute,
GeometryPipeline,
+ IndexDatatype,
Matrix4,
WebMercatorProjection) {
"use strict";
@@ -440,7 +442,7 @@ define([
var geometry = items[i];
var attributes = geometry.attributes;
- count += 4 + BoundingSphere.packedLength + geometry.indices.length;
+ count += 3 + BoundingSphere.packedLength + geometry.indices.length;
for ( var property in attributes) {
if (attributes.hasOwnProperty(property) && defined(attributes[property])) {
@@ -472,11 +474,6 @@ define([
BoundingSphere.pack(geometry.boundingSphere, packedData, count);
count += BoundingSphere.packedLength;
- packedData[count++] = ComponentDatatype.fromTypedArray(geometry.indices).value;
- packedData[count++] = geometry.indices.length;
- packedData.set(geometry.indices, count);
- count += geometry.indices.length;
-
var attributes = geometry.attributes;
var attributesToWrite = [];
for ( var property in attributes) {
@@ -501,6 +498,10 @@ define([
packedData.set(attribute.values, count);
count += attribute.values.length;
}
+
+ packedData[count++] = geometry.indices.length;
+ packedData.set(geometry.indices, count);
+ count += geometry.indices.length;
}
transferableObjects.push(packedData.buffer);
@@ -529,23 +530,19 @@ define([
var boundingSphere = BoundingSphere.unpack(packedGeometry, packedGeometryIndex);
packedGeometryIndex += BoundingSphere.packedLength;
- var type = ComponentDatatype.fromValue(packedGeometry[packedGeometryIndex++]);
- var length = packedGeometry[packedGeometryIndex++];
- var indices = ComponentDatatype.createTypedArray(type, length);
- for (i = 0; i < length; i++) {
- indices[i] = packedGeometry[packedGeometryIndex++];
- }
-
+ var length;
+ var values;
+ var componentsPerAttribute;
var attributes = {};
var numAttributes = packedGeometry[packedGeometryIndex++];
for (i = 0; i < numAttributes; i++) {
var name = stringTable[packedGeometry[packedGeometryIndex++]];
var componentDatatype = ComponentDatatype.fromValue(packedGeometry[packedGeometryIndex++]);
- var componentsPerAttribute = packedGeometry[packedGeometryIndex++];
+ componentsPerAttribute = packedGeometry[packedGeometryIndex++];
var normalize = packedGeometry[packedGeometryIndex++] !== 0;
length = packedGeometry[packedGeometryIndex++];
- var values = ComponentDatatype.createTypedArray(componentDatatype, length);
+ values = ComponentDatatype.createTypedArray(componentDatatype, length);
for (var valuesIndex = 0; valuesIndex < length; valuesIndex++) {
values[valuesIndex] = packedGeometry[packedGeometryIndex++];
}
@@ -558,6 +555,13 @@ define([
});
}
+ var numberOfVertices = values.length / componentsPerAttribute;
+ length = packedGeometry[packedGeometryIndex++];
+ var indices = IndexDatatype.createTypedArray(numberOfVertices, length);
+ for (i = 0; i < length; i++) {
+ indices[i] = packedGeometry[packedGeometryIndex++];
+ }
+
result[resultIndex++] = new Geometry({
primitiveType : primitiveType,
boundingSphere : boundingSphere,
diff --git a/Source/Scene/SceneTransforms.js b/Source/Scene/SceneTransforms.js
index 317d855c25af..bdc0ba41fc2a 100644
--- a/Source/Scene/SceneTransforms.js
+++ b/Source/Scene/SceneTransforms.js
@@ -49,7 +49,7 @@ define([
* @example
* // Output the window position of longitude/latitude (0, 0) every time the mouse moves.
* var scene = widget.scene;
- * var ellipsoid = widget._globe.ellipsoid;
+ * var ellipsoid = scene.globe.ellipsoid;
* var position = ellipsoid.cartographicToCartesian(new Cesium.Cartographic(0.0, 0.0));
* var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
* handler.setInputAction(function(movement) {
@@ -97,7 +97,7 @@ define([
* @example
* // Output the window position of longitude/latitude (0, 0) every time the mouse moves.
* var scene = widget.scene;
- * var ellipsoid = widget._globe.ellipsoid;
+ * var ellipsoid = scene.globe.ellipsoid;
* var position = ellipsoid.cartographicToCartesian(new Cesium.Cartographic(0.0, 0.0));
* var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
* handler.setInputAction(function(movement) {
diff --git a/Source/Widgets/Viewer/Viewer.js b/Source/Widgets/Viewer/Viewer.js
index 96e426c45c00..0a4368eb6e45 100644
--- a/Source/Widgets/Viewer/Viewer.js
+++ b/Source/Widgets/Viewer/Viewer.js
@@ -293,14 +293,14 @@ Either specify options.terrainProvider instead or set options.baseLayerPicker to
geocoder = new Geocoder({
container : geocoderContainer,
scene : cesiumWidget.scene,
- ellipsoid : cesiumWidget._globe.ellipsoid
+ ellipsoid : cesiumWidget.scene.globe.ellipsoid
});
}
//HomeButton
var homeButton;
if (!defined(options.homeButton) || options.homeButton !== false) {
- homeButton = new HomeButton(toolbar, cesiumWidget.scene, cesiumWidget._globe.ellipsoid);
+ homeButton = new HomeButton(toolbar, cesiumWidget.scene, cesiumWidget.scene.globe.ellipsoid);
if (defined(geocoder)) {
eventHelper.add(homeButton.viewModel.command.afterExecute, function() {
var viewModel = geocoder.viewModel;
@@ -325,7 +325,7 @@ Either specify options.terrainProvider instead or set options.baseLayerPicker to
var terrainProviderViewModels = defaultValue(options.terrainProviderViewModels, createDefaultTerrainProviderViewModels());
baseLayerPicker = new BaseLayerPicker(toolbar, {
- globe : cesiumWidget._globe,
+ globe : cesiumWidget.scene.globe,
imageryProviderViewModels : imageryProviderViewModels,
selectedImageryProviderViewModel : options.selectedImageryProviderViewModel,
terrainProviderViewModels : terrainProviderViewModels,
diff --git a/Source/Widgets/Viewer/viewerDynamicObjectMixin.js b/Source/Widgets/Viewer/viewerDynamicObjectMixin.js
index bc8774ae94b0..5df20e4ff64a 100644
--- a/Source/Widgets/Viewer/viewerDynamicObjectMixin.js
+++ b/Source/Widgets/Viewer/viewerDynamicObjectMixin.js
@@ -275,7 +275,7 @@ define(['../../Core/BoundingSphere',
}
if (isTracking && defined(value.position)) {
- dynamicObjectView = new DynamicObjectView(value, scene, viewer.cesiumWidget._globe.ellipsoid);
+ dynamicObjectView = new DynamicObjectView(value, scene, viewer.scene.globe.ellipsoid);
} else {
dynamicObjectView = undefined;
}
diff --git a/Specs/Core/ComponentDatatypeSpec.js b/Specs/Core/ComponentDatatypeSpec.js
new file mode 100644
index 000000000000..9596f8db68dc
--- /dev/null
+++ b/Specs/Core/ComponentDatatypeSpec.js
@@ -0,0 +1,135 @@
+/*global defineSuite*/
+defineSuite(['Core/ComponentDatatype'], function(ComponentDatatype) {
+ "use strict";
+ /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
+
+ it('fromValue works', function() {
+ expect(ComponentDatatype.fromValue(ComponentDatatype.BYTE.value)).toBe(ComponentDatatype.BYTE);
+ expect(ComponentDatatype.fromValue(ComponentDatatype.UNSIGNED_BYTE.value)).toBe(ComponentDatatype.UNSIGNED_BYTE);
+ expect(ComponentDatatype.fromValue(ComponentDatatype.SHORT.value)).toBe(ComponentDatatype.SHORT);
+ expect(ComponentDatatype.fromValue(ComponentDatatype.UNSIGNED_SHORT.value)).toBe(ComponentDatatype.UNSIGNED_SHORT);
+ expect(ComponentDatatype.fromValue(ComponentDatatype.FLOAT.value)).toBe(ComponentDatatype.FLOAT);
+ expect(ComponentDatatype.fromValue(ComponentDatatype.DOUBLE.value)).toBe(ComponentDatatype.DOUBLE);
+ });
+
+ it('fromTypedArray works', function() {
+ expect(ComponentDatatype.fromTypedArray(new Int8Array())).toBe(ComponentDatatype.BYTE);
+ expect(ComponentDatatype.fromTypedArray(new Uint8Array())).toBe(ComponentDatatype.UNSIGNED_BYTE);
+ expect(ComponentDatatype.fromTypedArray(new Int16Array())).toBe(ComponentDatatype.SHORT);
+ expect(ComponentDatatype.fromTypedArray(new Uint16Array())).toBe(ComponentDatatype.UNSIGNED_SHORT);
+ expect(ComponentDatatype.fromTypedArray(new Float32Array())).toBe(ComponentDatatype.FLOAT);
+ expect(ComponentDatatype.fromTypedArray(new Float64Array())).toBe(ComponentDatatype.DOUBLE);
+ });
+
+ it('validate works', function() {
+ expect(ComponentDatatype.validate(ComponentDatatype.BYTE)).toBe(true);
+ expect(ComponentDatatype.validate(ComponentDatatype.UNSIGNED_BYTE)).toBe(true);
+ expect(ComponentDatatype.validate(ComponentDatatype.SHORT)).toBe(true);
+ expect(ComponentDatatype.validate(ComponentDatatype.UNSIGNED_SHORT)).toBe(true);
+ expect(ComponentDatatype.validate(ComponentDatatype.FLOAT)).toBe(true);
+ expect(ComponentDatatype.validate(ComponentDatatype.DOUBLE)).toBe(true);
+ expect(ComponentDatatype.validate(undefined)).toBe(false);
+ expect(ComponentDatatype.validate({})).toBe(false);
+ });
+
+ it('createTypedArray works with size', function() {
+ var typedArray = ComponentDatatype.createTypedArray(ComponentDatatype.BYTE, 0);
+ expect(typedArray).toBeInstanceOf(Int8Array);
+ expect(typedArray.length).toBe(0);
+
+ typedArray = ComponentDatatype.createTypedArray(ComponentDatatype.UNSIGNED_BYTE, 1);
+ expect(typedArray).toBeInstanceOf(Uint8Array);
+ expect(typedArray.length).toBe(1);
+
+ typedArray = ComponentDatatype.createTypedArray(ComponentDatatype.SHORT, 2);
+ expect(typedArray).toBeInstanceOf(Int16Array);
+ expect(typedArray.length).toBe(2);
+
+ typedArray = ComponentDatatype.createTypedArray(ComponentDatatype.UNSIGNED_SHORT, 3);
+ expect(typedArray).toBeInstanceOf(Uint16Array);
+ expect(typedArray.length).toBe(3);
+
+ typedArray = ComponentDatatype.createTypedArray(ComponentDatatype.FLOAT, 6);
+ expect(typedArray).toBeInstanceOf(Float32Array);
+ expect(typedArray.length).toBe(6);
+
+ typedArray = ComponentDatatype.createTypedArray(ComponentDatatype.DOUBLE, 7);
+ expect(typedArray).toBeInstanceOf(Float64Array);
+ expect(typedArray.length).toBe(7);
+ });
+
+ it('createTypedArray works with values', function() {
+ var values = [34, 12, 4, 1];
+ var typedArray = ComponentDatatype.createTypedArray(ComponentDatatype.BYTE, values);
+ expect(typedArray).toBeInstanceOf(Int8Array);
+ expect(typedArray).toEqual(values);
+ expect(typedArray.length).toBe(values.length);
+
+ typedArray = ComponentDatatype.createTypedArray(ComponentDatatype.UNSIGNED_BYTE, values);
+ expect(typedArray).toBeInstanceOf(Uint8Array);
+ expect(typedArray).toEqual(values);
+ expect(typedArray.length).toBe(values.length);
+
+ typedArray = ComponentDatatype.createTypedArray(ComponentDatatype.SHORT, values);
+ expect(typedArray).toBeInstanceOf(Int16Array);
+ expect(typedArray).toEqual(values);
+ expect(typedArray.length).toBe(values.length);
+
+ typedArray = ComponentDatatype.createTypedArray(ComponentDatatype.UNSIGNED_SHORT, values);
+ expect(typedArray).toBeInstanceOf(Uint16Array);
+ expect(typedArray).toEqual(values);
+ expect(typedArray.length).toBe(values.length);
+
+ typedArray = ComponentDatatype.createTypedArray(ComponentDatatype.FLOAT, values);
+ expect(typedArray).toBeInstanceOf(Float32Array);
+ expect(typedArray).toEqual(values);
+ expect(typedArray.length).toBe(values.length);
+
+ typedArray = ComponentDatatype.createTypedArray(ComponentDatatype.DOUBLE, values);
+ expect(typedArray).toBeInstanceOf(Float64Array);
+ expect(typedArray).toEqual(values);
+ expect(typedArray.length).toBe(values.length);
+ });
+
+ it('createArrayBufferView works', function() {
+ var buffer = new ArrayBuffer(100);
+ expect(ComponentDatatype.createArrayBufferView(ComponentDatatype.BYTE, buffer, 0, 1)).toBeInstanceOf(Int8Array);
+ expect(ComponentDatatype.createArrayBufferView(ComponentDatatype.UNSIGNED_BYTE, buffer, 0, 1)).toBeInstanceOf(Uint8Array);
+ expect(ComponentDatatype.createArrayBufferView(ComponentDatatype.SHORT, buffer, 0, 1)).toBeInstanceOf(Int16Array);
+ expect(ComponentDatatype.createArrayBufferView(ComponentDatatype.UNSIGNED_SHORT, buffer, 0, 1)).toBeInstanceOf(Uint16Array);
+ expect(ComponentDatatype.createArrayBufferView(ComponentDatatype.FLOAT, buffer, 0, 1)).toBeInstanceOf(Float32Array);
+ expect(ComponentDatatype.createArrayBufferView(ComponentDatatype.DOUBLE, buffer, 0, 1)).toBeInstanceOf(Float64Array);
+ });
+
+ it('createTypedArray throws without type', function() {
+ expect(function() {
+ ComponentDatatype.createTypedArray(undefined, 1);
+ }).toThrowDeveloperError();
+ });
+
+ it('createTypedArray throws without length or values', function() {
+ expect(function() {
+ ComponentDatatype.createTypedArray(ComponentDatatype.FLOAT, undefined);
+ }).toThrowDeveloperError();
+ });
+
+ it('createArrayBufferView throws without type', function() {
+ var buffer = new ArrayBuffer(100);
+ expect(function() {
+ ComponentDatatype.createTypedArray(undefined, buffer, 0, 1);
+ }).toThrowDeveloperError();
+ });
+
+ it('createArrayBufferView throws with invalid type', function() {
+ var buffer = new ArrayBuffer(100);
+ expect(function() {
+ ComponentDatatype.createTypedArray({}, buffer, 0, 1);
+ }).toThrowDeveloperError();
+ });
+
+ it('createArrayBufferView throws without buffer', function() {
+ expect(function() {
+ ComponentDatatype.createTypedArray(ComponentDatatype.BYTE, undefined, 0, 1);
+ }).toThrowDeveloperError();
+ });
+});
diff --git a/Specs/DynamicScene/DataSourceDisplaySpec.js b/Specs/DynamicScene/DataSourceDisplaySpec.js
index 5bf18a4706de..25ec30f1b789 100644
--- a/Specs/DynamicScene/DataSourceDisplaySpec.js
+++ b/Specs/DynamicScene/DataSourceDisplaySpec.js
@@ -37,26 +37,11 @@ defineSuite([
this.destroyed = false;
};
- MockVisualizer.prototype.getScene = function() {
- return this.scene;
- };
-
- MockVisualizer.prototype.getDynamicObjectCollection = function() {
- return this.dynamicObjectCollection;
- };
-
- MockVisualizer.prototype.setDynamicObjectCollection = function(dynamicObjectCollection) {
- this.dynamicObjectCollection = 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 74d192597bd3..cbe215c40d68 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,13 +74,9 @@ 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);
+ var dynamicObjectCollection = new DynamicObjectCollection();
+ visualizer = new DynamicBillboardVisualizer(scene, dynamicObjectCollection);
expect(visualizer.isDestroyed()).toEqual(false);
visualizer.destroy();
expect(visualizer.isDestroyed()).toEqual(true);
@@ -289,36 +283,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..ea220cbdcd20 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,13 +65,9 @@ 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);
+ var dynamicObjectCollection = new DynamicObjectCollection();
+ visualizer = new DynamicConeVisualizerUsingCustomSensor(scene, dynamicObjectCollection);
expect(visualizer.isDestroyed()).toEqual(false);
visualizer.destroy();
expect(visualizer.isDestroyed()).toEqual(true);
@@ -252,37 +241,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..717e52b45683 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,13 +70,9 @@ 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);
+ var dynamicObjectCollection = new DynamicObjectCollection();
+ visualizer = new DynamicLabelVisualizer(scene, dynamicObjectCollection);
expect(visualizer.isDestroyed()).toEqual(false);
visualizer.destroy();
expect(visualizer.isDestroyed()).toEqual(true);
@@ -261,36 +255,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/DynamicModelSpec.js b/Specs/DynamicScene/DynamicModelSpec.js
index 3628c10aaa56..175c87426d95 100644
--- a/Specs/DynamicScene/DynamicModelSpec.js
+++ b/Specs/DynamicScene/DynamicModelSpec.js
@@ -18,7 +18,8 @@ defineSuite([
var source = new DynamicModel();
source.uri = new ConstantProperty('');
source.show = new ConstantProperty(true);
- source.scale = new ConstantProperty(new Cartesian3());
+ source.scale = new ConstantProperty(1.0);
+ source.minimumPixelSize = new ConstantProperty(2.0);
var target = new DynamicModel();
target.merge(source);
@@ -26,40 +27,47 @@ defineSuite([
expect(target.uri).toBe(source.uri);
expect(target.show).toBe(source.show);
expect(target.scale).toBe(source.scale);
+ expect(target.minimumPixelSize).toBe(source.minimumPixelSize);
});
it('merge does not assign assigned properties', function() {
var source = new DynamicModel();
source.uri = new ConstantProperty('');
source.show = new ConstantProperty(true);
- source.scale = new ConstantProperty(new Cartesian3());
+ source.scale = new ConstantProperty(1.0);
+ source.minimumPixelSize = new ConstantProperty(2.0);
var uri = new ConstantProperty('');
var show = new ConstantProperty(true);
- var scale = new ConstantProperty(new Cartesian3());
+ var scale = new ConstantProperty(1.0);
+ var minimumPixelSize = new ConstantProperty(2.0);
var target = new DynamicModel();
target.uri = uri;
target.show = show;
target.scale = scale;
+ target.minimumPixelSize = minimumPixelSize;
target.merge(source);
expect(target.uri).toBe(uri);
expect(target.show).toBe(show);
expect(target.scale).toBe(scale);
+ expect(target.minimumPixelSize).toBe(minimumPixelSize);
});
it('clone works', function() {
var source = new DynamicModel();
source.uri = new ConstantProperty('');
source.show = new ConstantProperty(true);
- source.scale = new ConstantProperty(new Cartesian3());
+ source.scale = new ConstantProperty(1.0);
+ source.minimumPixelSize = new ConstantProperty(2.0);
var result = source.clone();
expect(result.uri).toBe(source.uri);
expect(result.show).toBe(source.show);
expect(result.scale).toBe(source.scale);
+ expect(result.minimumPixelSize).toBe(source.minimumPixelSize);
});
it('merge throws if source undefined', function() {
diff --git a/Specs/DynamicScene/DynamicModelVisualizerSpec.js b/Specs/DynamicScene/DynamicModelVisualizerSpec.js
index dcc8cdc023ce..a914b8024432 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,13 +63,9 @@ 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);
+ var dynamicObjectCollection = new DynamicObjectCollection();
+ visualizer = new DynamicModelVisualizer(scene, dynamicObjectCollection);
expect(visualizer.isDestroyed()).toEqual(false);
visualizer.destroy();
expect(visualizer.isDestroyed()).toEqual(true);
@@ -113,6 +102,7 @@ defineSuite([
var model = new DynamicModel();
model.show = new ConstantProperty(true);
model.scale = new ConstantProperty(2);
+ model.minimumPixelSize = new ConstantProperty(24.0);
model.uri = new ConstantProperty(duckUrl);
var testObject = dynamicObjectCollection.getOrCreateObject('test');
@@ -127,6 +117,7 @@ defineSuite([
visualizer.update(time);
expect(primitive.show).toEqual(true);
expect(primitive.scale).toEqual(2);
+ expect(primitive.minimumPixelSize).toEqual(24.0);
});
it('removing removes primitives.', function() {
diff --git a/Specs/DynamicScene/DynamicPathVisualizerSpec.js b/Specs/DynamicScene/DynamicPathVisualizerSpec.js
index 3aadf6633ea5..36e06a153912 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,13 +63,9 @@ 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);
+ var dynamicObjectCollection = new DynamicObjectCollection();
+ visualizer = new DynamicPathVisualizer(scene, dynamicObjectCollection);
expect(visualizer.isDestroyed()).toEqual(false);
visualizer.destroy();
expect(visualizer.isDestroyed()).toEqual(true);
@@ -220,61 +208,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..4881c148655c 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,13 +63,9 @@ 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);
+ var dynamicObjectCollection = new DynamicObjectCollection();
+ visualizer = new DynamicPointVisualizer(scene, dynamicObjectCollection);
expect(visualizer.isDestroyed()).toEqual(false);
visualizer.destroy();
expect(visualizer.isDestroyed()).toEqual(true);
@@ -203,34 +197,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..bc5305f7ae4b 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,13 +63,9 @@ 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);
+ var dynamicObjectCollection = new DynamicObjectCollection();
+ visualizer = new DynamicPyramidVisualizer(scene, dynamicObjectCollection);
expect(visualizer.isDestroyed()).toEqual(false);
visualizer.destroy();
expect(visualizer.isDestroyed()).toEqual(true);
@@ -187,35 +176,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..18355afb26e6 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,13 +67,9 @@ 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);
+ var dynamicObjectCollection = new DynamicObjectCollection();
+ visualizer = new DynamicVectorVisualizer(scene, dynamicObjectCollection);
expect(visualizer.isDestroyed()).toEqual(false);
visualizer.destroy();
expect(visualizer.isDestroyed()).toEqual(true);
@@ -209,43 +203,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');
diff --git a/Specs/DynamicScene/GeometryVisualizerSpec.js b/Specs/DynamicScene/GeometryVisualizerSpec.js
index e749e36598e0..001cff7f61ae 100644
--- a/Specs/DynamicScene/GeometryVisualizerSpec.js
+++ b/Specs/DynamicScene/GeometryVisualizerSpec.js
@@ -50,22 +50,14 @@ 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);
expect(visualizer.update(time)).toBe(true);
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();
- expect(visualizer.update(time)).toBe(true);
- expect(scene.primitives.length).toBe(0);
- visualizer.destroy();
});
it('Creates and removes static color open geometry', function() {
@@ -384,4 +376,4 @@ defineSuite(['DynamicScene/GeometryVisualizer',
visualizer.update(undefined);
}).toThrowDeveloperError();
});
-}, 'WebGL');
\ No newline at end of file
+}, 'WebGL');
diff --git a/Specs/Renderer/ContextSpec.js b/Specs/Renderer/ContextSpec.js
index 6035ec724429..412ad8a4f425 100644
--- a/Specs/Renderer/ContextSpec.js
+++ b/Specs/Renderer/ContextSpec.js
@@ -236,7 +236,7 @@ defineSuite([
pixel = renderFragment(context, fsDragDepth, 1.0, false);
- if (context.getFragmentDepth) {
+ if (context.fragmentDepth) {
expect(pixel).toEqual([0, 255, 0, 255]);
} else {
expect(pixel).toEqual([255, 0, 0, 255]);
diff --git a/Specs/Renderer/FramebufferSpec.js b/Specs/Renderer/FramebufferSpec.js
index f4e175bf2487..fed3d10a447b 100644
--- a/Specs/Renderer/FramebufferSpec.js
+++ b/Specs/Renderer/FramebufferSpec.js
@@ -337,7 +337,9 @@ defineSuite([
})
});
- expect(renderDepthAttachment(framebuffer, framebuffer.depthTexture)).toEqualEpsilon([128, 128, 128, 128], 1);
+ if (framebuffer.status === WebGLRenderingContext.FRAMEBUFFER_COMPLETE) {
+ expect(renderDepthAttachment(framebuffer, framebuffer.depthTexture)).toEqualEpsilon([128, 128, 128, 128], 1);
+ }
}
});
@@ -356,7 +358,9 @@ defineSuite([
})
});
- expect(renderDepthAttachment(framebuffer, framebuffer.depthStencilTexture)).toEqualEpsilon([128, 128, 128, 128], 1);
+ if (framebuffer.status === WebGLRenderingContext.FRAMEBUFFER_COMPLETE) {
+ expect(renderDepthAttachment(framebuffer, framebuffer.depthStencilTexture)).toEqualEpsilon([128, 128, 128, 128], 1);
+ }
}
});